diff --git a/docs/404.html b/docs/404.html index 085ef7877..509d6f2db 100644 --- a/docs/404.html +++ b/docs/404.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • diff --git a/docs/class-Appconfig.html b/docs/class-Appconfig.html index e68ed7edd..1ff955fdf 100644 --- a/docs/class-Appconfig.html +++ b/docs/class-Appconfig.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -204,6 +206,9 @@

    Class Appconfig

    +
    +

    Appconfig class

    +
    @@ -232,7 +237,13 @@ CI_Model - Located at models/Appconfig.php + Author: + N/A
    + Since: + 1.0
    + Link: + github.com/jekkos/opensourcepos
    + Located at models/Appconfig.php
    @@ -252,7 +263,7 @@ CI_Model
    # - exists( $key ) + exists( $key )
    @@ -282,7 +293,7 @@ CI_Model
    # - get_all( ) + get_all( )
    @@ -312,7 +323,7 @@ CI_Model
    # - get( $key ) + get( $key )
    @@ -342,7 +353,7 @@ CI_Model
    # - save( $key, $value ) + save( $key, $value )
    @@ -372,7 +383,7 @@ CI_Model
    # - batch_save( $data ) + batch_save( $data )
    @@ -402,7 +413,7 @@ CI_Model
    # - delete( $key ) + delete( $key )
    @@ -432,7 +443,7 @@ CI_Model
    # - delete_all( ) + delete_all( )
    @@ -462,7 +473,7 @@ CI_Model
    # - acquire_save_next_invoice_sequence( ) + acquire_save_next_invoice_sequence( )
    @@ -492,7 +503,7 @@ CI_Model
    # - acquire_save_next_quote_sequence( ) + acquire_save_next_quote_sequence( )
    diff --git a/docs/class-Barcode_lib.html b/docs/class-Barcode_lib.html index a8a2a2e62..0fcedf458 100644 --- a/docs/class-Barcode_lib.html +++ b/docs/class-Barcode_lib.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -204,6 +206,11 @@

    Class Barcode_lib

    +
    +

    Barcode library

    + +

    Library with utilities to manage barcodes

    +
    @@ -219,7 +226,13 @@ - Located at libraries/Barcode_lib.php + Author: + Jekkos
    + Since: + 2.x
    + Link: + github.com/jekkos/opensourcepos
    + Located at libraries/Barcode_lib.php
    @@ -239,7 +252,7 @@
    # - __construct( ) + __construct( )
    @@ -269,7 +282,7 @@
    # - get_list_barcodes( ) + get_list_barcodes( )
    @@ -299,7 +312,7 @@
    # - get_barcode_config( ) + get_barcode_config( )
    @@ -329,7 +342,7 @@
    # - validate_barcode( $barcode ) + validate_barcode( $barcode )
    @@ -359,7 +372,7 @@
    # - barcode_instance( $item, $barcode_config ) + barcode_instance( $item, $barcode_config )
    @@ -389,7 +402,7 @@
    # - generate_receipt_barcode( $barcode_content ) + generate_receipt_barcode( $barcode_content )
    @@ -419,7 +432,7 @@
    # - display_barcode( $item, $barcode_config ) + display_barcode( $item, $barcode_config )
    @@ -449,7 +462,7 @@
    # - listfonts( $folder ) + listfonts( $folder )
    @@ -479,7 +492,7 @@
    # - get_font_name( $font_file_name ) + get_font_name( $font_file_name )
    diff --git a/docs/class-Config.html b/docs/class-Config.html index 6643c3cc2..ed09bf0b6 100644 --- a/docs/class-Config.html +++ b/docs/class-Config.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -239,7 +241,7 @@ CI_Controller - Located at controllers/Config.php + Located at controllers/Config.php
    @@ -653,7 +655,7 @@ CI_Controller
    # - save_locations( ) + save_locations( )
    @@ -683,7 +685,7 @@ CI_Controller
    # - save_tables( ) + save_tables( )
    @@ -713,7 +715,7 @@ CI_Controller
    # - save_rewards( ) + save_rewards( )
    @@ -743,7 +745,7 @@ CI_Controller
    # - save_barcode( ) + save_barcode( )
    @@ -773,7 +775,7 @@ CI_Controller
    # - save_receipt( ) + save_receipt( )
    @@ -803,7 +805,7 @@ CI_Controller
    # - save_invoice( ) + save_invoice( )
    @@ -833,7 +835,7 @@ CI_Controller
    # - remove_logo( ) + remove_logo( )
    @@ -863,7 +865,7 @@ CI_Controller
    # - backup_db( ) + backup_db( )
    diff --git a/docs/class-Customer.html b/docs/class-Customer.html index 834d7f2f7..2ec9f5310 100644 --- a/docs/class-Customer.html +++ b/docs/class-Customer.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • diff --git a/docs/class-Customer_rewards.html b/docs/class-Customer_rewards.html index 0a6761f5c..ed4ff71d9 100644 --- a/docs/class-Customer_rewards.html +++ b/docs/class-Customer_rewards.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -204,6 +206,9 @@

    Class Customer_rewards

    +
    +

    Customer_rewards class

    +
    @@ -232,7 +237,13 @@ CI_Model - Located at models/Customer_rewards.php + Author: + joshua1234511
    + Since: + 3.1
    + Link: + github.com/jekkos/opensourcepos
    + Located at models/Customer_rewards.php
    @@ -252,7 +263,7 @@ CI_Model
    # - exists( $package_id ) + exists( $package_id )
    @@ -282,7 +293,7 @@ CI_Model
    # - save( & $table_data, $package_id ) + save( $package_data, $package_id )
    @@ -312,7 +323,7 @@ CI_Model
    # - get_name( $package_id ) + get_name( $package_id )
    @@ -342,7 +353,7 @@ CI_Model
    # - get_points_percent( $package_id ) + get_points_percent( $package_id )
    @@ -372,7 +383,7 @@ CI_Model
    # - get_all( ) + get_all( )
    @@ -402,7 +413,7 @@ CI_Model
    # - get_undeleted_all( ) + get_undeleted_all( )
    @@ -432,7 +443,7 @@ CI_Model
    # - delete( $package_id ) + delete( $package_id )
    diff --git a/docs/class-Customers.html b/docs/class-Customers.html index 0b0924be1..21dc16ccc 100644 --- a/docs/class-Customers.html +++ b/docs/class-Customers.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • diff --git a/docs/class-Detailed_receivings.html b/docs/class-Detailed_receivings.html index d94519c24..4392aca9f 100644 --- a/docs/class-Detailed_receivings.html +++ b/docs/class-Detailed_receivings.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -239,7 +241,7 @@ CI_Model - Located at models/reports/Detailed_receivings.php + Located at models/reports/Detailed_receivings.php
    @@ -247,38 +249,6 @@ CI_Model - - - - - -
    Methods summary
    - public - - - - -
    - # - __construct( ) - -
    - -
    - - -
    @@ -291,7 +261,7 @@ CI_Model
    # - create( array $inputs ) + create( array $inputs )
    @@ -321,7 +291,7 @@ CI_Model
    # - getDataColumns( ) + getDataColumns( )
    @@ -351,7 +321,7 @@ CI_Model
    # - getDataByReceivingId( $receiving_id ) + getDataByReceivingId( $receiving_id )
    @@ -381,7 +351,7 @@ CI_Model
    # - getData( array $inputs ) + getData( array $inputs )
    @@ -411,7 +381,7 @@ CI_Model
    # - getSummaryData( array $inputs ) + getSummaryData( array $inputs )
    @@ -431,6 +401,14 @@ CI_Model
    + + + + + +
    Methods inherited from Report
    + __construct() +
    diff --git a/docs/class-Detailed_sales.html b/docs/class-Detailed_sales.html index c8c24b782..86811d194 100644 --- a/docs/class-Detailed_sales.html +++ b/docs/class-Detailed_sales.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -239,7 +241,7 @@ CI_Model - Located at models/reports/Detailed_sales.php + Located at models/reports/Detailed_sales.php
    @@ -247,38 +249,6 @@ CI_Model - - - - - -
    Methods summary
    - public - - - - -
    - # - __construct( ) - -
    - -
    - - -
    @@ -291,7 +261,7 @@ CI_Model
    # - create( array $inputs ) + create( array $inputs )
    @@ -321,7 +291,7 @@ CI_Model
    # - getDataColumns( ) + getDataColumns( )
    @@ -351,7 +321,7 @@ CI_Model
    # - getDataBySaleId( $sale_id ) + getDataBySaleId( $sale_id )
    @@ -381,7 +351,7 @@ CI_Model
    # - getData( array $inputs ) + getData( array $inputs )
    @@ -411,7 +381,7 @@ CI_Model
    # - getSummaryData( array $inputs ) + getSummaryData( array $inputs )
    @@ -431,6 +401,14 @@ CI_Model
    + + + + + +
    Methods inherited from Report
    + __construct() +
    diff --git a/docs/class-Dinner_table.html b/docs/class-Dinner_table.html index 623195082..28f72aaf5 100644 --- a/docs/class-Dinner_table.html +++ b/docs/class-Dinner_table.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -204,6 +206,9 @@

    Class Dinner_table

    +
    +

    Dinner_table class

    +
    @@ -232,7 +237,13 @@ CI_Model - Located at models/Dinner_table.php + Author: + jlctmaster
    + Since: + 3.1
    + Link: + github.com/jekkos/opensourcepos
    + Located at models/Dinner_table.php
    @@ -252,7 +263,7 @@ CI_Model
    # - exists( $dinner_table_id ) + exists( $dinner_table_id )
    @@ -282,7 +293,7 @@ CI_Model
    # - save( & $table_data, $dinner_table_id ) + save( $table_data, $dinner_table_id )
    @@ -312,7 +323,7 @@ CI_Model
    # - get_empty_tables( ) + get_empty_tables( )
    @@ -342,7 +353,7 @@ CI_Model
    # - get_name( $dinner_table_id ) + get_name( $dinner_table_id )
    @@ -372,7 +383,7 @@ CI_Model
    # - get_all( ) + get_all( )
    @@ -402,7 +413,7 @@ CI_Model
    # - get_undeleted_all( ) + get_undeleted_all( )
    @@ -432,7 +443,7 @@ CI_Model
    # - delete( $dinner_table_id ) + delete( $dinner_table_id )
    diff --git a/docs/class-Email_lib.html b/docs/class-Email_lib.html index a366fd76f..0bb8c1ce1 100644 --- a/docs/class-Email_lib.html +++ b/docs/class-Email_lib.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -204,6 +206,11 @@

    Class Email_lib

    +
    +

    Email library

    + +

    Library with utilities to configure and send emails

    +
    @@ -219,7 +226,13 @@ - Located at libraries/Email_lib.php + Author: + daN4cat (FrancescoUK)
    + Since: + 3.0
    + Link: + github.com/jekkos/opensourcepos
    + Located at libraries/Email_lib.php
    @@ -239,7 +252,7 @@
    # - __construct( ) + __construct( )
    @@ -269,14 +282,16 @@
    # - sendEmail( $to, $subject, $message, $attachment = NULL ) + sendEmail( $to, $subject, $message, $attachment = NULL )
    - +

    Email sending function +Example of use: $response = sendEmail('john@doe.com', 'Hello', 'This is a message', $filename);

    @@ -252,7 +263,7 @@ CI_Model
    # - exists( $giftcard_id ) + exists( $giftcard_id )
    @@ -282,7 +293,7 @@ CI_Model
    # - get_max_number( ) + get_max_number( )
    @@ -312,7 +323,7 @@ CI_Model
    # - get_total_rows( ) + get_total_rows( )
    @@ -342,7 +353,7 @@ CI_Model
    # - get_info( $giftcard_id ) + get_info( $giftcard_id )
    @@ -372,7 +383,7 @@ CI_Model
    # - get_giftcard_id( $giftcard_number ) + get_giftcard_id( $giftcard_number )
    @@ -402,7 +413,7 @@ CI_Model
    # - get_multiple_info( $giftcard_ids ) + get_multiple_info( $giftcard_ids )
    @@ -432,7 +443,7 @@ CI_Model
    # - save( & $giftcard_data, $giftcard_id = -1 ) + save( & $giftcard_data, $giftcard_id = -1 )
    @@ -462,7 +473,7 @@ CI_Model
    # - update_multiple( $giftcard_data, $giftcard_ids ) + update_multiple( $giftcard_data, $giftcard_ids )
    @@ -492,7 +503,7 @@ CI_Model
    # - delete( $giftcard_id ) + delete( $giftcard_id )
    @@ -522,7 +533,7 @@ CI_Model
    # - delete_list( $giftcard_ids ) + delete_list( $giftcard_ids )
    @@ -552,7 +563,7 @@ CI_Model
    # - get_search_suggestions( $search, $limit = 25 ) + get_search_suggestions( $search, $limit = 25 )
    @@ -582,7 +593,7 @@ CI_Model
    # - search( $search, $rows = 0, $limit_from = 0, $sort = 'giftcard_number', $order = 'asc' ) + search( $search, $rows = 0, $limit_from = 0, $sort = 'giftcard_number', $order = 'asc' )
    @@ -612,7 +623,7 @@ CI_Model
    # - get_found_rows( $search ) + get_found_rows( $search )
    @@ -642,7 +653,7 @@ CI_Model
    # - get_giftcard_value( $giftcard_number ) + get_giftcard_value( $giftcard_number )
    @@ -672,7 +683,7 @@ CI_Model
    # - update_giftcard_value( $giftcard_number, $value ) + update_giftcard_value( $giftcard_number, $value )
    @@ -702,7 +713,7 @@ CI_Model
    # - exists_gitcard_name( $giftcard_name ) + exists_gitcard_name( $giftcard_name )
    @@ -732,7 +743,7 @@ CI_Model
    # - generate_unique_giftcard_name( $value ) + generate_unique_giftcard_name( $value )
    @@ -762,7 +773,7 @@ CI_Model
    # - get_giftcard_customer( $giftcard_number ) + get_giftcard_customer( $giftcard_number )
    diff --git a/docs/class-Giftcards.html b/docs/class-Giftcards.html index 7b7f3ea36..f14595419 100644 --- a/docs/class-Giftcards.html +++ b/docs/class-Giftcards.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • diff --git a/docs/class-Home.html b/docs/class-Home.html index 6309c26ce..6efe2b519 100644 --- a/docs/class-Home.html +++ b/docs/class-Home.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -239,7 +241,7 @@ CI_Controller - Located at controllers/Home.php + Located at controllers/Home.php
    @@ -247,38 +249,6 @@ CI_Controller - - - - - - + + + + + + + + + + + +
    Methods summary
    - public - - - - -
    - # - __construct( ) - -
    - -
    - - -
    @@ -291,7 +261,7 @@ CI_Controller
    # - index( ) + index( )
    @@ -323,7 +293,7 @@ CI_Controller
    # - logout( ) + logout( )
    @@ -347,6 +317,7 @@ CI_Controller
    Methods inherited from Secure_Controller
    + __construct(), check_numeric(), delete(), numeric(), diff --git a/docs/class-Inventory.html b/docs/class-Inventory.html index 8c27f9889..883980545 100644 --- a/docs/class-Inventory.html +++ b/docs/class-Inventory.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -204,6 +206,9 @@

    Class Inventory

    +
    +

    Inventory class

    +
    @@ -232,7 +237,13 @@ CI_Model - Located at models/Inventory.php + Author: + N/A
    + Since: + 1.0
    + Link: + github.com/jekkos/opensourcepos
    + Located at models/Inventory.php
    @@ -252,7 +263,7 @@ CI_Model
    # - insert( $inventory_data ) + insert( $inventory_data )
    @@ -282,7 +293,67 @@ CI_Model
    # - get_inventory_data_for_item( $item_id, $location_id = FALSE ) + get_inventory_data_for_item( $item_id, $location_id = FALSE ) + +
    + +
    + + +
    + public + + + + +
    + # + reset_quantity( $item_id ) + +
    + +
    + + +
    + public + + + + +
    + # + get_inventory_sum( $item_id )
    diff --git a/docs/class-Inventory_low.html b/docs/class-Inventory_low.html index 41ad1b0ad..e8634c267 100644 --- a/docs/class-Inventory_low.html +++ b/docs/class-Inventory_low.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -239,7 +241,7 @@ CI_Model - Located at models/reports/Inventory_low.php + Located at models/reports/Inventory_low.php
    @@ -247,38 +249,6 @@ CI_Model - - - - - -
    Methods summary
    - public - - - - -
    - # - __construct( ) - -
    - -
    - - -
    @@ -291,7 +261,7 @@ CI_Model
    # - getDataColumns( ) + getDataColumns( )
    @@ -321,7 +291,7 @@ CI_Model
    # - getData( array $inputs ) + getData( array $inputs )
    @@ -351,7 +321,7 @@ CI_Model
    # - getSummaryData( array $inputs ) + getSummaryData( array $inputs )
    @@ -371,6 +341,14 @@ CI_Model
    + + + + + +
    Methods inherited from Report
    + __construct() +
    diff --git a/docs/class-Inventory_summary.html b/docs/class-Inventory_summary.html index 8fee9af85..fb1b4eced 100644 --- a/docs/class-Inventory_summary.html +++ b/docs/class-Inventory_summary.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -239,7 +241,7 @@ CI_Model - Located at models/reports/Inventory_summary.php + Located at models/reports/Inventory_summary.php
    @@ -247,38 +249,6 @@ CI_Model - - - - - -
    Methods summary
    - public - - - - -
    - # - __construct( ) - -
    - -
    - - -
    @@ -291,7 +261,7 @@ CI_Model
    # - getDataColumns( ) + getDataColumns( )
    @@ -321,7 +291,7 @@ CI_Model
    # - getData( array $inputs ) + getData( array $inputs )
    @@ -351,7 +321,7 @@ CI_Model
    # - getSummaryData( array $inputs ) + getSummaryData( array $inputs )

    calculates the total value of the given inventory summary by summing all sub_total_values (see Inventory_summary::getData())

    @@ -390,7 +360,7 @@ CI_Model
    # - getItemCountDropdownArray( ) + getItemCountDropdownArray( )

    returns the array for the dropdown-element item-count in the form for the inventory summary-report

    @@ -414,6 +384,14 @@ CI_Model
    + + + + + +
    Methods inherited from Report
    + __construct() +
    diff --git a/docs/class-Item.html b/docs/class-Item.html index 8e8b89768..c77a3f578 100644 --- a/docs/class-Item.html +++ b/docs/class-Item.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -204,6 +206,9 @@

    Class Item

    +
    +

    Item class

    +
    @@ -232,7 +237,13 @@ CI_Model - Located at models/Item.php + Author: + N/A
    + Since: + 1.0
    + Link: + github.com/jekkos/opensourcepos
    + Located at models/Item.php
    @@ -252,7 +263,7 @@ CI_Model
    # - exists( $item_id, $ignore_deleted = FALSE, $deleted = FALSE ) + exists( $item_id, $ignore_deleted = FALSE, $deleted = FALSE )
    @@ -282,7 +293,7 @@ CI_Model
    # - item_number_exists( $item_number, $item_id = '' ) + item_number_exists( $item_number, $item_id = '' )
    @@ -312,7 +323,7 @@ CI_Model
    # - get_total_rows( ) + get_total_rows( )
    @@ -342,7 +353,7 @@ CI_Model
    # - get_found_rows( $search, $filters ) + get_found_rows( $search, $filters )
    @@ -372,7 +383,7 @@ CI_Model
    # - search( $search, $filters, $rows = 0, $limit_from = 0, $sort = 'items.name', $order = 'asc' ) + search( $search, $filters, $rows = 0, $limit_from = 0, $sort = 'items.name', $order = 'asc' )
    @@ -402,7 +413,7 @@ CI_Model
    # - get_all( $stock_location_id = -1, $rows = 0, $limit_from = 0 ) + get_all( $stock_location_id = -1, $rows = 0, $limit_from = 0 )
    @@ -432,7 +443,7 @@ CI_Model
    # - get_info( $item_id ) + get_info( $item_id )
    @@ -462,7 +473,7 @@ CI_Model
    # - get_info_by_id_or_number( $item_id ) + get_info_by_id_or_number( $item_id )
    @@ -492,7 +503,7 @@ CI_Model
    # - get_item_id( $item_number, $ignore_deleted = FALSE, $deleted = FALSE ) + get_item_id( $item_number, $ignore_deleted = FALSE, $deleted = FALSE )
    @@ -522,7 +533,7 @@ CI_Model
    # - get_multiple_info( $item_ids, $location_id ) + get_multiple_info( $item_ids, $location_id )
    @@ -552,7 +563,7 @@ CI_Model
    # - save( & $item_data, $item_id = FALSE ) + save( & $item_data, $item_id = FALSE )
    @@ -582,7 +593,7 @@ CI_Model
    # - update_multiple( $item_data, $item_ids ) + update_multiple( $item_data, $item_ids )
    @@ -612,7 +623,7 @@ CI_Model
    # - delete( $item_id ) + delete( $item_id )
    @@ -642,7 +653,7 @@ CI_Model
    # - undelete( $item_id ) + undelete( $item_id )
    @@ -672,7 +683,7 @@ CI_Model
    # - delete_list( $item_ids ) + delete_list( $item_ids )
    @@ -702,7 +713,7 @@ CI_Model
    # - get_search_suggestions( $search, $filters = array('is_deleted' => FALSE, 'search_custom' => FALSE), $unique = FALSE, $limit = 25 ) + get_search_suggestions( $search, $filters = array('is_deleted' => FALSE, 'search_custom' => FALSE), $unique = FALSE, $limit = 25 )
    @@ -732,7 +743,7 @@ CI_Model
    # - get_stock_search_suggestions( $search, $filters = array('is_deleted' => FALSE, 'search_custom' => FALSE), $unique = FALSE, $limit = 25 ) + get_stock_search_suggestions( $search, $filters = array('is_deleted' => FALSE, 'search_custom' => FALSE), $unique = FALSE, $limit = 25 )
    @@ -762,7 +773,7 @@ CI_Model
    # - get_kit_search_suggestions( $search, $filters = array('is_deleted' => FALSE, 'search_custom' => FALSE), $unique = FALSE, $limit = 25 ) + get_kit_search_suggestions( $search, $filters = array('is_deleted' => FALSE, 'search_custom' => FALSE), $unique = FALSE, $limit = 25 )
    @@ -792,7 +803,7 @@ CI_Model
    # - get_category_suggestions( $search ) + get_category_suggestions( $search )
    @@ -822,7 +833,7 @@ CI_Model
    # - get_location_suggestions( $search ) + get_location_suggestions( $search )
    @@ -852,7 +863,7 @@ CI_Model
    # - get_custom_suggestions( $search, $field_no ) + get_custom_suggestions( $search, $field_no )
    @@ -882,7 +893,7 @@ CI_Model
    # - get_categories( ) + get_categories( )
    @@ -912,7 +923,7 @@ CI_Model
    # - change_cost_price( $item_id, $items_received, $new_price, $old_price = null ) + change_cost_price( $item_id, $items_received, $new_price, $old_price = null )
    diff --git a/docs/class-Item_kit.html b/docs/class-Item_kit.html index 185b3c4f7..e5fb301bb 100644 --- a/docs/class-Item_kit.html +++ b/docs/class-Item_kit.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -204,6 +206,9 @@

    Class Item_kit

    +
    +

    Item_kit class

    +
    @@ -232,7 +237,13 @@ CI_Model - Located at models/Item_kit.php + Author: + N/A
    + Since: + 1.0
    + Link: + github.com/jekkos/opensourcepos
    + Located at models/Item_kit.php
    @@ -252,7 +263,7 @@ CI_Model
    # - exists( $item_kit_id ) + exists( $item_kit_id )
    @@ -282,7 +293,7 @@ CI_Model
    # - is_valid_item_kit( $item_kit_id ) + is_valid_item_kit( $item_kit_id )
    @@ -312,7 +323,7 @@ CI_Model
    # - get_total_rows( ) + get_total_rows( )
    @@ -342,7 +353,7 @@ CI_Model
    # - get_info( $item_kit_id ) + get_info( $item_kit_id )
    @@ -372,7 +383,7 @@ CI_Model
    # - get_multiple_info( $item_kit_ids ) + get_multiple_info( $item_kit_ids )
    @@ -402,7 +413,7 @@ CI_Model
    # - save( & $item_kit_data, $item_kit_id = FALSE ) + save( & $item_kit_data, $item_kit_id = FALSE )
    @@ -432,7 +443,7 @@ CI_Model
    # - delete( $item_kit_id ) + delete( $item_kit_id )
    @@ -462,7 +473,7 @@ CI_Model
    # - delete_list( $item_kit_ids ) + delete_list( $item_kit_ids )
    @@ -492,7 +503,7 @@ CI_Model
    # - get_search_suggestions( $search, $limit = 25 ) + get_search_suggestions( $search, $limit = 25 )
    @@ -522,7 +533,7 @@ CI_Model
    # - search( $search, $rows = 0, $limit_from = 0, $sort = 'name', $order = 'asc' ) + search( $search, $rows = 0, $limit_from = 0, $sort = 'name', $order = 'asc' )
    @@ -552,7 +563,7 @@ CI_Model
    # - get_found_rows( $search ) + get_found_rows( $search )
    diff --git a/docs/class-Item_kit_items.html b/docs/class-Item_kit_items.html index 8f11bea86..40f2c61d5 100644 --- a/docs/class-Item_kit_items.html +++ b/docs/class-Item_kit_items.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -204,6 +206,9 @@

    Class Item_kit_items

    +
    +

    Item_kit_items class

    +
    @@ -232,7 +237,13 @@ CI_Model - Located at models/Item_kit_items.php + Author: + N/A
    + Since: + 1.0
    + Link: + github.com/jekkos/opensourcepos
    + Located at models/Item_kit_items.php
    @@ -252,7 +263,7 @@ CI_Model
    # - get_info( $item_kit_id ) + get_info( $item_kit_id )
    @@ -282,7 +293,7 @@ CI_Model
    # - get_info_for_sale( $item_kit_id ) + get_info_for_sale( $item_kit_id )
    @@ -312,7 +323,7 @@ CI_Model
    # - save( & $item_kit_items_data, $item_kit_id ) + save( & $item_kit_items_data, $item_kit_id )
    @@ -342,7 +353,7 @@ CI_Model
    # - delete( $item_kit_id ) + delete( $item_kit_id )
    diff --git a/docs/class-Item_kits.html b/docs/class-Item_kits.html index 8ce5ff9f4..b1bb75f1c 100644 --- a/docs/class-Item_kits.html +++ b/docs/class-Item_kits.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • diff --git a/docs/class-Item_lib.html b/docs/class-Item_lib.html index b56858ed1..234808cd6 100644 --- a/docs/class-Item_lib.html +++ b/docs/class-Item_lib.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -204,6 +206,11 @@

    Class Item_lib

    +
    +

    Item library

    + +

    Library with utilities to manage items

    +
    @@ -219,7 +226,13 @@ - Located at libraries/Item_lib.php + Author: + Jekkos
    + Since: + 2.x
    + Link: + github.com/jekkos/opensourcepos
    + Located at libraries/Item_lib.php
    @@ -239,7 +252,7 @@
    # - __construct( ) + __construct( )
    @@ -269,7 +282,7 @@
    # - get_item_location( ) + get_item_location( )
    @@ -299,7 +312,7 @@
    # - set_item_location( $location ) + set_item_location( $location )
    @@ -329,7 +342,7 @@
    # - clear_item_location( ) + clear_item_location( )
    diff --git a/docs/class-Item_quantity.html b/docs/class-Item_quantity.html index 1b6a9319c..d6b2ae675 100644 --- a/docs/class-Item_quantity.html +++ b/docs/class-Item_quantity.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -204,6 +206,9 @@

    Class Item_quantity

    +
    +

    Item_quantity class

    +
    @@ -232,7 +237,13 @@ CI_Model - Located at models/Item_quantity.php + Author: + Padungsak
    + Since: + 2.x
    + Link: + github.com/jekkos/opensourcepos
    + Located at models/Item_quantity.php
    @@ -252,7 +263,7 @@ CI_Model
    # - exists( $item_id, $location_id ) + exists( $item_id, $location_id )
    @@ -282,7 +293,7 @@ CI_Model
    # - save( $location_detail, $item_id, $location_id ) + save( $location_detail, $item_id, $location_id )
    @@ -312,7 +323,7 @@ CI_Model
    # - get_item_quantity( $item_id, $location_id ) + get_item_quantity( $item_id, $location_id )
    @@ -342,7 +353,7 @@ CI_Model
    # - change_quantity( $item_id, $location_id, $quantity_change ) + change_quantity( $item_id, $location_id, $quantity_change )
    @@ -372,7 +383,7 @@ CI_Model
    # - reset_quantity( $item_id ) + reset_quantity( $item_id )
    @@ -402,7 +413,7 @@ CI_Model
    # - reset_quantity_list( $item_ids ) + reset_quantity_list( $item_ids )
    diff --git a/docs/class-Item_taxes.html b/docs/class-Item_taxes.html index fdbd14b63..dc79bf451 100644 --- a/docs/class-Item_taxes.html +++ b/docs/class-Item_taxes.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -204,6 +206,9 @@

    Class Item_taxes

    +
    +

    Item_taxes class

    +
    @@ -232,7 +237,13 @@ CI_Model - Located at models/Item_taxes.php + Author: + N/A
    + Since: + 1.0
    + Link: + github.com/jekkos/opensourcepos
    + Located at models/Item_taxes.php
    @@ -252,7 +263,7 @@ CI_Model
    # - get_info( $item_id ) + get_info( $item_id )
    @@ -282,7 +293,7 @@ CI_Model
    # - save( & $items_taxes_data, $item_id ) + save( & $items_taxes_data, $item_id )
    @@ -312,7 +323,7 @@ CI_Model
    # - save_multiple( & $items_taxes_data, $item_ids ) + save_multiple( & $items_taxes_data, $item_ids )
    @@ -342,7 +353,7 @@ CI_Model
    # - delete( $item_id ) + delete( $item_id )
    diff --git a/docs/class-Items.html b/docs/class-Items.html index 6c663e705..bf6e42310 100644 --- a/docs/class-Items.html +++ b/docs/class-Items.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • diff --git a/docs/class-Login.html b/docs/class-Login.html index 23794759f..126b4e359 100644 --- a/docs/class-Login.html +++ b/docs/class-Login.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -232,7 +234,7 @@ CI_Controller - Located at controllers/Login.php + Located at controllers/Login.php
    @@ -240,36 +242,6 @@ CI_Controller - - - - - -
    Methods summary
    - public - - - - -
    - # - __construct( ) - -
    - -
    - - -
    @@ -282,7 +254,7 @@ CI_Controller
    # - index( ) + index( )
    @@ -312,7 +284,7 @@ CI_Controller
    # - login_check( $username ) + login_check( $username )
    diff --git a/docs/class-MY_Lang.html b/docs/class-MY_Lang.html index 394f4a372..03631e5cb 100644 --- a/docs/class-MY_Lang.html +++ b/docs/class-MY_Lang.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -232,7 +234,7 @@ CI_Lang - Located at core/MY_Lang.php + Located at core/MY_Lang.php
    @@ -240,36 +242,6 @@ CI_Lang - - - - - -
    Methods summary
    - public - - - - -
    - # - __construct( ) - -
    - -
    - - -
    @@ -282,7 +254,7 @@ CI_Lang
    # - switch_to( $idiom ) + switch_to( $idiom )
    @@ -312,7 +284,7 @@ CI_Lang
    # - line( $line = '', $log_errors = TRUE ) + line( $line = '', $log_errors = TRUE )

    Fetch a single line of text from the language array. Takes variable number @@ -350,7 +322,7 @@ Overloaded function.

    # - line_tbd( $line = '' ) + line_tbd( $line = '' )
    diff --git a/docs/class-MailchimpConnector.html b/docs/class-MailchimpConnector.html index 50bd87efb..577979d1b 100644 --- a/docs/class-MailchimpConnector.html +++ b/docs/class-MailchimpConnector.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -208,8 +210,6 @@

    MailChimp API v3 REST client Connector

    Interface for communicating with the Mailchimp v3 API

    - -

    Inspired by the work of: - Rajitha Bandara: https://github.com/rajitha-bandara/ci-mailchimp-v3-rest-client - Stefan Ashwell: https://github.com/stef686/codeigniter-mailchimp-api-v3

    @@ -226,7 +226,17 @@ - Located at libraries/Mailchimp_lib.php + Author: +

    daN4cat (FrancescoUK)

    + +

    Inspired by the work of: + - Rajitha Bandara: https://github.com/rajitha-bandara/ci-mailchimp-v3-rest-client + - Stefan Ashwell: https://github.com/stef686/codeigniter-mailchimp-api-v3


    + Since: + 3.1
    + Link: + github.com/jekkos/opensourcepos
    + Located at libraries/Mailchimp_lib.php
    @@ -246,7 +256,7 @@
    # - __construct( $api_key = '' ) + __construct( $api_key = '' )

    Constructor

    @@ -276,7 +286,7 @@
    # - call( string $httpVerb, string $method, array $args = array() ) + call( string $httpVerb, string $method, array $args = array() )

    Call an API method. Every request needs the API key

    diff --git a/docs/class-Mailchimp_lib.html b/docs/class-Mailchimp_lib.html index a03944ab2..77a599ee0 100644 --- a/docs/class-Mailchimp_lib.html +++ b/docs/class-Mailchimp_lib.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -208,8 +210,6 @@

    Mailchimp library, usable from CI code

    Library with utility queries to interface Mailchimp v3 API

    - -

    Inspired by the work of ThinkShout: https://github.com/thinkshout/mailchimp-api-php

    @@ -226,7 +226,15 @@ - Located at libraries/Mailchimp_lib.php + Author: +

    daN4cat (FrancescoUK)

    + +

    Inspired by the work of ThinkShout: https://github.com/thinkshout/mailchimp-api-php


    + Since: + 3.1
    + Link: + github.com/jekkos/opensourcepos
    + Located at libraries/Mailchimp_lib.php
    @@ -246,7 +254,7 @@
    # - __construct( array $params = array() ) + __construct( array $params = array() )
    @@ -276,7 +284,7 @@
    # - getLists( array $parameters = array('fields' => 'lists.id,lists.name,lists.stats.member_count,lists.stats.merge_field_count') ) + getLists( array $parameters = array('fields' => 'lists.id,lists.name,lists.stats.member_count,lists.stats.merge_field_count') )

    Gets information about all lists owned by the authenticated account.

    @@ -321,7 +329,7 @@
    # - getList( string $list_id, array $parameters = array('fields' => 'id,name,stats.member_count,stats.merge_field_count') ) + getList( string $list_id, array $parameters = array('fields' => 'id,name,stats.member_count,stats.merge_field_count') )

    Gets a MailChimp list.

    @@ -366,7 +374,7 @@
    # - getMembers( string $list_id, array $count, $offset, $parameters = array('fields' => 'members.id,members.email_address,members.unique_email_id,members.status,members.merge_fields') ) + getMembers( string $list_id, array $count, $offset, $parameters = array('fields' => 'members.id,members.email_address,members.unique_email_id,members.status,members.merge_fields') )

    Gets information about all members of a MailChimp list.

    @@ -416,7 +424,7 @@
    # - getMemberInfoById( string $list_id, string $md5id, array $parameters = array('fields' => 'email_address,status,merge_fields') ) + getMemberInfoById( string $list_id, string $md5id, array $parameters = array('fields' => 'email_address,status,merge_fields') )

    Gets information about a member of a MailChimp list.

    @@ -463,7 +471,7 @@
    # - getMemberInfo( string $list_id, string $email, array $parameters = array() ) + getMemberInfo( string $list_id, string $email, array $parameters = array() )

    Gets information about a member of a MailChimp list.

    @@ -510,7 +518,7 @@
    # - getMemberActivity( string $list_id, string $email, array $parameters = array() ) + getMemberActivity( string $list_id, string $email, array $parameters = array() )

    Gets activity related to a member of a MailChimp list.

    @@ -557,7 +565,7 @@
    # - addMember( string $list_id, string $email, array $first_name, $last_name, $parameters = array() ) + addMember( string $list_id, string $email, array $first_name, $last_name, $parameters = array() )

    Adds a new member to a MailChimp list.

    @@ -609,7 +617,7 @@
    # - removeMember( string $list_id, string $email ) + removeMember( string $list_id, string $email )

    Removes a member from a MailChimp list.

    @@ -654,7 +662,7 @@
    # - updateMember( string $list_id, string $email, array $first_name, $last_name, $parameters = array() ) + updateMember( string $list_id, string $email, array $first_name, $last_name, $parameters = array() )

    Updates a member of a MailChimp list.

    @@ -706,7 +714,7 @@
    # - addOrUpdateMember( string $list_id, string $email, array $first_name, $last_name, $status, $parameters = array() ) + addOrUpdateMember( string $list_id, string $email, array $first_name, $last_name, $status, $parameters = array() )

    Adds a new or update an existing member of a MailChimp list.

    diff --git a/docs/class-Messages.html b/docs/class-Messages.html index 26ddc9faf..4e0856067 100644 --- a/docs/class-Messages.html +++ b/docs/class-Messages.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • diff --git a/docs/class-Migrate.html b/docs/class-Migrate.html new file mode 100644 index 000000000..903e94a61 --- /dev/null +++ b/docs/class-Migrate.html @@ -0,0 +1,392 @@ + + + + + + Class Migrate + + + + + + +
    + +
    + +
    + + + + + + diff --git a/docs/class-Migration_Sales_Tax_Data.html b/docs/class-Migration_Sales_Tax_Data.html new file mode 100644 index 000000000..4bc3c28f8 --- /dev/null +++ b/docs/class-Migration_Sales_Tax_Data.html @@ -0,0 +1,364 @@ + + + + + + Class Migration_Sales_Tax_Data + + + + + + +
    + +
    + +
    + + + + + + diff --git a/docs/class-Module.html b/docs/class-Module.html index 470b55f09..2e2b2fb10 100644 --- a/docs/class-Module.html +++ b/docs/class-Module.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -204,6 +206,9 @@

    Class Module

    +
    +

    Module class

    +
    @@ -232,7 +237,13 @@ CI_Model - Located at models/Module.php + Author: + N/A
    + Since: + 1.0
    + Link: + github.com/jekkos/opensourcepos
    + Located at models/Module.php
    @@ -240,36 +251,6 @@ CI_Model - - - - - - - + @@ -687,6 +697,6 @@ - + diff --git a/docs/namespace-emberlabs.Barcode.html b/docs/namespace-emberlabs.Barcode.html index fa72b51e1..636857b71 100644 --- a/docs/namespace-emberlabs.Barcode.html +++ b/docs/namespace-emberlabs.Barcode.html @@ -131,6 +131,6 @@ - + diff --git a/docs/namespace-emberlabs.html b/docs/namespace-emberlabs.html index fb7e455d2..efe5aa5f7 100644 --- a/docs/namespace-emberlabs.html +++ b/docs/namespace-emberlabs.html @@ -100,6 +100,6 @@ - + diff --git a/docs/source-class-Appconfig.html b/docs/source-class-Appconfig.html index 4db3ccb32..c07c28f4c 100644 --- a/docs/source-class-Appconfig.html +++ b/docs/source-class-Appconfig.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,99 +207,109 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 
    -
    <?php
    -class Appconfig extends CI_Model 
    -{
    -    public function exists($key)
    -    {
    -        $this->db->from('app_config');  
    -        $this->db->where('app_config.key', $key);
    -
    -        return ($this->db->get()->num_rows() == 1);
    -    }
    -    
    -    public function get_all()
    -    {
    -        $this->db->from('app_config');
    -        $this->db->order_by('key', 'asc');
    -
    -        return $this->db->get();        
    -    }
    -    
    -    public function get($key)
    -    {
    -        $query = $this->db->get_where('app_config', array('key' => $key), 1);
    -
    -        if($query->num_rows() == 1)
    -        {
    -            return $query->row()->value;
    -        }
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
    +
    +/**
    + * Appconfig class
    + *
    + * @link    github.com/jekkos/opensourcepos
    + * @since   1.0
    + * @author  N/A
    + */
    +
    +class Appconfig extends CI_Model
    +{
    +    public function exists($key)
    +    {
    +        $this->db->from('app_config');
    +        $this->db->where('app_config.key', $key);
    +
    +        return ($this->db->get()->num_rows() == 1);
    +    }
    +
    +    public function get_all()
    +    {
    +        $this->db->from('app_config');
    +        $this->db->order_by('key', 'asc');
    +
    +        return $this->db->get();
    +    }
     
    -        return '';
    -    }
    -    
    -    public function save($key, $value)
    -    {
    -        $config_data = array(
    -            'key'   => $key,
    -            'value' => $value
    -        );
    -
    -        if(!$this->exists($key))
    -        {
    -            return $this->db->insert('app_config', $config_data);
    -        }
    -
    -        $this->db->where('key', $key);
    -
    -        return $this->db->update('app_config', $config_data);
    -    }
    -    
    -    public function batch_save($data)
    -    {
    -        $success = TRUE;
    -        
    -        //Run these queries as a transaction, we want to make sure we do all or nothing
    -        $this->db->trans_start();
    -
    -        foreach($data as $key=>$value)
    -        {
    -            $success &= $this->save($key, $value);
    -        }
    -
    -        $this->db->trans_complete();
    -
    -        $success &= $this->db->trans_status();
    +    public function get($key)
    +    {
    +        $query = $this->db->get_where('app_config', array('key' => $key), 1);
    +
    +        if($query->num_rows() == 1)
    +        {
    +            return $query->row()->value;
    +        }
    +
    +        return '';
    +    }
    +
    +    public function save($key, $value)
    +    {
    +        $config_data = array(
    +            'key'   => $key,
    +            'value' => $value
    +        );
    +
    +        if(!$this->exists($key))
    +        {
    +            return $this->db->insert('app_config', $config_data);
    +        }
    +
    +        $this->db->where('key', $key);
    +
    +        return $this->db->update('app_config', $config_data);
    +    }
    +
    +    public function batch_save($data)
    +    {
    +        $success = TRUE;
    +
    +        //Run these queries as a transaction, we want to make sure we do all or nothing
    +        $this->db->trans_start();
     
    -        return $success;
    -    }
    -        
    -    public function delete($key)
    -    {
    -        return $this->db->delete('app_config', array('key' => $key)); 
    -    }
    -    
    -    public function delete_all()
    -    {
    -        return $this->db->empty_table('app_config'); 
    -    }
    -
    -    public function acquire_save_next_invoice_sequence()
    -    {
    -        $last_used = $this->get('last_used_invoice_number') + 1;
    -        $this->save('last_used_invoice_number', $last_used);
    -        return $last_used;
    -    }
    -
    -    public function acquire_save_next_quote_sequence()
    -    {
    -        $last_used = $this->get('last_used_quote_number') + 1;
    -        $this->save('last_used_quote_number', $last_used);
    -        return $last_used;
    -    }
    -}
    -?>
    +
    foreach($data as $key=>$value) + { + $success &= $this->save($key, $value); + } + + $this->db->trans_complete(); + + $success &= $this->db->trans_status(); + + return $success; + } + + public function delete($key) + { + return $this->db->delete('app_config', array('key' => $key)); + } + + public function delete_all() + { + return $this->db->empty_table('app_config'); + } + + public function acquire_save_next_invoice_sequence() + { + $last_used = $this->get('last_used_invoice_number') + 1; + $this->save('last_used_invoice_number', $last_used); + return $last_used; + } + + public function acquire_save_next_quote_sequence() + { + $last_used = $this->get('last_used_quote_number') + 1; + $this->save('last_used_quote_number', $last_used); + return $last_used; + } +} +?> +
    - + diff --git a/docs/source-class-Barcode_lib.html b/docs/source-class-Barcode_lib.html index ceb95a8f7..78d132af4 100644 --- a/docs/source-class-Barcode_lib.html +++ b/docs/source-class-Barcode_lib.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,7 +207,7 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
     use emberlabs\Barcode\BarcodeBase;
    @@ -215,231 +217,241 @@
     require APPPATH.'/views/barcodes/Ean13.php';
     require APPPATH.'/views/barcodes/Ean8.php';
     
    -class Barcode_lib
    -{
    -    private $CI;
    -    private $supported_barcodes = array('Code39' => 'Code 39', 'Code128' => 'Code 128', 'Ean8' => 'EAN 8', 'Ean13' => 'EAN 13');
    -    
    -    public function __construct()
    -    {
    -        $this->CI =& get_instance();
    -    }
    -    
    -    public function get_list_barcodes()
    -    {
    -        return $this->supported_barcodes;
    -    }
    -    
    -    public function get_barcode_config()
    +/**
    + * Barcode library
    + *
    + * Library with utilities to manage barcodes
    + *
    + * @link    github.com/jekkos/opensourcepos
    + * @since   2.x
    + * @author  Jekkos
    + */
    +
    +class Barcode_lib
    +{
    +    private $CI;
    +    private $supported_barcodes = array('Code39' => 'Code 39', 'Code128' => 'Code 128', 'Ean8' => 'EAN 8', 'Ean13' => 'EAN 13');
    +
    +    public function __construct()
         {
    -        $data['company'] = $this->CI->config->item('company');
    -        $data['barcode_content'] = $this->CI->config->item('barcode_content');
    -        $data['barcode_type'] = $this->CI->config->item('barcode_type');
    -        $data['barcode_font'] = $this->CI->config->item('barcode_font');
    -        $data['barcode_font_size'] = $this->CI->config->item('barcode_font_size');
    -        $data['barcode_height'] = $this->CI->config->item('barcode_height');
    -        $data['barcode_width'] = $this->CI->config->item('barcode_width');
    -        $data['barcode_quality'] = $this->CI->config->item('barcode_quality');
    -        $data['barcode_first_row'] = $this->CI->config->item('barcode_first_row');
    -        $data['barcode_second_row'] = $this->CI->config->item('barcode_second_row');
    -        $data['barcode_third_row'] = $this->CI->config->item('barcode_third_row');
    -        $data['barcode_num_in_row'] = $this->CI->config->item('barcode_num_in_row');
    -        $data['barcode_page_width'] = $this->CI->config->item('barcode_page_width');      
    -        $data['barcode_page_cellspacing'] = $this->CI->config->item('barcode_page_cellspacing');
    -        $data['barcode_generate_if_empty'] = $this->CI->config->item('barcode_generate_if_empty');
    -        
    -        return $data;
    -    }
    -
    -    public function validate_barcode($barcode)
    -    {
    -        $barcode_type = $this->CI->config->item('barcode_type');
    -        $barcode_instance = $this->get_barcode_instance($barcode_type);
    -        return $barcode_instance->validate($barcode);
    -    }
    +        $this->CI =& get_instance();
    +    }
    +
    +    public function get_list_barcodes()
    +    {
    +        return $this->supported_barcodes;
    +    }
    +
    +    public function get_barcode_config()
    +    {
    +        $data['company'] = $this->CI->config->item('company');
    +        $data['barcode_content'] = $this->CI->config->item('barcode_content');
    +        $data['barcode_type'] = $this->CI->config->item('barcode_type');
    +        $data['barcode_font'] = $this->CI->config->item('barcode_font');
    +        $data['barcode_font_size'] = $this->CI->config->item('barcode_font_size');
    +        $data['barcode_height'] = $this->CI->config->item('barcode_height');
    +        $data['barcode_width'] = $this->CI->config->item('barcode_width');
    +        $data['barcode_quality'] = $this->CI->config->item('barcode_quality');
    +        $data['barcode_first_row'] = $this->CI->config->item('barcode_first_row');
    +        $data['barcode_second_row'] = $this->CI->config->item('barcode_second_row');
    +        $data['barcode_third_row'] = $this->CI->config->item('barcode_third_row');
    +        $data['barcode_num_in_row'] = $this->CI->config->item('barcode_num_in_row');
    +        $data['barcode_page_width'] = $this->CI->config->item('barcode_page_width');
    +        $data['barcode_page_cellspacing'] = $this->CI->config->item('barcode_page_cellspacing');
    +        $data['barcode_generate_if_empty'] = $this->CI->config->item('barcode_generate_if_empty');
     
    -    public static function barcode_instance($item, $barcode_config)
    -    {
    -        $barcode_instance = Barcode_lib::get_barcode_instance($barcode_config['barcode_type']);
    -        $is_valid = empty($item['item_number']) && $barcode_config['barcode_generate_if_empty'] || $barcode_instance->validate($item['item_number']);
    -
    -        // if barcode validation does not succeed,
    -        if (!$is_valid)
    -        {
    -            $barcode_instance = Barcode_lib::get_barcode_instance();
    -        }
    -        $seed = Barcode_lib::barcode_seed($item, $barcode_instance, $barcode_config);
    -        $barcode_instance->setData($seed);
    -
    -        return $barcode_instance;
    -    }
    -
    -    private static function get_barcode_instance($barcode_type='Code128')
    -    {
    -        switch($barcode_type)
    -        {
    -            case 'Code39':
    -                return new emberlabs\Barcode\Code39();
    -                break;
    -                
    -            case 'Code128':
    -            default:
    -                return new emberlabs\Barcode\Code128();
    -                break;
    -                
    -            case 'Ean8':
    -                return new emberlabs\Barcode\Ean8();
    -                break;
    -                
    -            case 'Ean13':
    -                return new emberlabs\Barcode\Ean13();
    -                break;
    -        }
    -    }
    +        return $data;
    +    }
    +
    +    public function validate_barcode($barcode)
    +    {
    +        $barcode_type = $this->CI->config->item('barcode_type');
    +        $barcode_instance = $this->get_barcode_instance($barcode_type);
    +        return $barcode_instance->validate($barcode);
    +    }
    +
    +    public static function barcode_instance($item, $barcode_config)
    +    {
    +        $barcode_instance = Barcode_lib::get_barcode_instance($barcode_config['barcode_type']);
    +        $is_valid = empty($item['item_number']) && $barcode_config['barcode_generate_if_empty'] || $barcode_instance->validate($item['item_number']);
    +
    +        // if barcode validation does not succeed,
    +        if (!$is_valid)
    +        {
    +            $barcode_instance = Barcode_lib::get_barcode_instance();
    +        }
    +        $seed = Barcode_lib::barcode_seed($item, $barcode_instance, $barcode_config);
    +        $barcode_instance->setData($seed);
    +
    +        return $barcode_instance;
    +    }
    +
    +    private static function get_barcode_instance($barcode_type='Code128')
    +    {
    +        switch($barcode_type)
    +        {
    +            case 'Code39':
    +                return new emberlabs\Barcode\Code39();
    +                break;
    +
    +            case 'Code128':
    +            default:
    +                return new emberlabs\Barcode\Code128();
    +                break;
     
    -    private static function barcode_seed($item, $barcode_instance, $barcode_config)
    -    {
    -        $seed = $barcode_config['barcode_content'] !== "id" && !empty($item['item_number']) ? $item['item_number'] : $item['item_id'];
    +            case 'Ean8':
    +                return new emberlabs\Barcode\Ean8();
    +                break;
     
    -        if( $barcode_config['barcode_content'] !== "id" && !empty($item['item_number']))
    -        {
    -            $seed = $item['item_number'];
    +            case 'Ean13':
    +                return new emberlabs\Barcode\Ean13();
    +                break;
             }
    -        else
    -        {
    -            if ($barcode_config['barcode_generate_if_empty'])
    -            {
    -                // generate barcode with the correct instance
    -                $seed = $barcode_instance->generate($seed);
    -            }
    -            else
    -            {
    -                $seed = $item['item_id'];
    -            }
    -        }
    -        return $seed;
    -    }
    -
    -    private function generate_barcode($item, $barcode_config)
    -    {
    -        try
    -        {
    -            $barcode_instance = Barcode_lib::barcode_instance($item, $barcode_config);
    -            $barcode_instance->setQuality($barcode_config['barcode_quality']);
    -            $barcode_instance->setDimensions($barcode_config['barcode_width'], $barcode_config['barcode_height']);
    -
    -            $barcode_instance->draw();
    -            
    -            return $barcode_instance->base64();
    -        } 
    -        catch(Exception $e)
    +    }
    +
    +    private static function barcode_seed($item, $barcode_instance, $barcode_config)
    +    {
    +        $seed = $barcode_config['barcode_content'] !== "id" && !empty($item['item_number']) ? $item['item_number'] : $item['item_id'];
    +
    +        if( $barcode_config['barcode_content'] !== "id" && !empty($item['item_number']))
    +        {
    +            $seed = $item['item_number'];
    +        }
    +        else
    +        {
    +            if ($barcode_config['barcode_generate_if_empty'])
    +            {
    +                // generate barcode with the correct instance
    +                $seed = $barcode_instance->generate($seed);
    +            }
    +            else
    +            {
    +                $seed = $item['item_id'];
    +            }
    +        }
    +        return $seed;
    +    }
    +
    +    private function generate_barcode($item, $barcode_config)
    +    {
    +        try
             {
    -            echo 'Caught exception: ', $e->getMessage(), "\n";      
    -        }
    -    }
    +            $barcode_instance = Barcode_lib::barcode_instance($item, $barcode_config);
    +            $barcode_instance->setQuality($barcode_config['barcode_quality']);
    +            $barcode_instance->setDimensions($barcode_config['barcode_width'], $barcode_config['barcode_height']);
     
    -    public function generate_receipt_barcode($barcode_content)
    -    {
    -        try
    -        {
    -            // Code128 is the default and used in this case for the receipts
    -            $barcode = $this->get_barcode_instance();
    -
    -            // set the receipt number to generate the barcode for
    -            $barcode->setData($barcode_content);
    -            
    -            // image quality 100
    -            $barcode->setQuality(100);
    -            
    -            // width: 200, height: 30
    -            $barcode->setDimensions(200, 30);
    -
    -            // draw the image
    -            $barcode->draw();
    -            
    -            return $barcode->base64();
    -        } 
    -        catch(Exception $e)
    -        {
    -            echo 'Caught exception: ', $e->getMessage(), "\n";      
    -        }
    -    }
    -    
    -    public function display_barcode($item, $barcode_config)
    -    {
    -        $display_table = "<table>";
    -        $display_table .= "<tr><td align='center'>" . $this->manage_display_layout($barcode_config['barcode_first_row'], $item, $barcode_config) . "</td></tr>";
    -        $barcode = $this->generate_barcode($item, $barcode_config);
    -        $display_table .= "<tr><td align='center'><img src='data:image/png;base64,$barcode' /></td></tr>";
    -        $display_table .= "<tr><td align='center'>" . $this->manage_display_layout($barcode_config['barcode_second_row'], $item, $barcode_config) . "</td></tr>";
    -        $display_table .= "<tr><td align='center'>" . $this->manage_display_layout($barcode_config['barcode_third_row'], $item, $barcode_config) . "</td></tr>";
    -        $display_table .= "</table>";
    -        
    -        return $display_table;
    -    }
    -    
    -    private function manage_display_layout($layout_type, $item, $barcode_config)
    -    {
    -        $result = '';
    -        
    -        if($layout_type == 'name')
    -        {
    -            $result = $this->CI->lang->line('items_name') . " " . $item['name'];
    -        }
    -        elseif($layout_type == 'category' && isset($item['category']))
    -        {
    -            $result = $this->CI->lang->line('items_category') . " " . $item['category'];
    -        }
    -        elseif($layout_type == 'cost_price' && isset($item['cost_price']))
    -        {
    -            $result = $this->CI->lang->line('items_cost_price') . " " . to_currency($item['cost_price']);
    -        }
    -        elseif($layout_type == 'unit_price' && isset($item['unit_price']))
    -        {
    -            $result = $this->CI->lang->line('items_unit_price') . " " . to_currency($item['unit_price']);
    -        }
    -        elseif($layout_type == 'company_name')
    -        {
    -            $result = $barcode_config['company'];
    -        }
    -        elseif($layout_type == 'item_code')
    -        {
    -            $result = $barcode_config['barcode_content'] !== "id" && isset($item['item_number']) ? $item['item_number'] : $item['item_id'];
    -        }
    -
    -        return character_limiter($result, 40);
    -    }
    -    
    -    public function listfonts($folder) 
    -    {
    -        $array = array();
    -
    -        if (($handle = opendir($folder)) !== FALSE)
    -        {
    -            while (($file = readdir($handle)) !== FALSE)
    -            {
    -                if(substr($file, -4, 4) === '.ttf')
    -                {
    -                    $array[$file] = $file;
    -                }
    -            }
    -        }
    -
    -        closedir($handle);
    -
    -        array_unshift($array, $this->CI->lang->line('config_none'));
    -
    -        return $array;
    -    }
    -
    -    public function get_font_name($font_file_name)
    -    {
    -        return substr($font_file_name, 0, -4);
    -    }
    -}
    -
    -?>
    -
    + $barcode_instance->draw(); + + return $barcode_instance->base64(); + } + catch(Exception $e) + { + echo 'Caught exception: ', $e->getMessage(), "\n"; + } + } + + public function generate_receipt_barcode($barcode_content) + { + try + { + // Code128 is the default and used in this case for the receipts + $barcode = $this->get_barcode_instance(); + + // set the receipt number to generate the barcode for + $barcode->setData($barcode_content); + + // image quality 100 + $barcode->setQuality(100); + + // width: 200, height: 30 + $barcode->setDimensions(200, 30); + + // draw the image + $barcode->draw(); + + return $barcode->base64(); + } + catch(Exception $e) + { + echo 'Caught exception: ', $e->getMessage(), "\n"; + } + } + + public function display_barcode($item, $barcode_config) + { + $display_table = "<table>"; + $display_table .= "<tr><td align='center'>" . $this->manage_display_layout($barcode_config['barcode_first_row'], $item, $barcode_config) . "</td></tr>"; + $barcode = $this->generate_barcode($item, $barcode_config); + $display_table .= "<tr><td align='center'><img src='data:image/png;base64,$barcode' /></td></tr>"; + $display_table .= "<tr><td align='center'>" . $this->manage_display_layout($barcode_config['barcode_second_row'], $item, $barcode_config) . "</td></tr>"; + $display_table .= "<tr><td align='center'>" . $this->manage_display_layout($barcode_config['barcode_third_row'], $item, $barcode_config) . "</td></tr>"; + $display_table .= "</table>"; + + return $display_table; + } + + private function manage_display_layout($layout_type, $item, $barcode_config) + { + $result = ''; + + if($layout_type == 'name') + { + $result = $this->CI->lang->line('items_name') . " " . $item['name']; + } + elseif($layout_type == 'category' && isset($item['category'])) + { + $result = $this->CI->lang->line('items_category') . " " . $item['category']; + } + elseif($layout_type == 'cost_price' && isset($item['cost_price'])) + { + $result = $this->CI->lang->line('items_cost_price') . " " . to_currency($item['cost_price']); + } + elseif($layout_type == 'unit_price' && isset($item['unit_price'])) + { + $result = $this->CI->lang->line('items_unit_price') . " " . to_currency($item['unit_price']); + } + elseif($layout_type == 'company_name') + { + $result = $barcode_config['company']; + } + elseif($layout_type == 'item_code') + { + $result = $barcode_config['barcode_content'] !== "id" && isset($item['item_number']) ? $item['item_number'] : $item['item_id']; + } + + return character_limiter($result, 40); + } + + public function listfonts($folder) + { + $array = array(); + + if (($handle = opendir($folder)) !== FALSE) + { + while (($file = readdir($handle)) !== FALSE) + { + if(substr($file, -4, 4) === '.ttf') + { + $array[$file] = $file; + } + } + } + + closedir($handle); + + array_unshift($array, $this->CI->lang->line('config_none')); + + return $array; + } + + public function get_font_name($font_file_name) + { + return substr($font_file_name, 0, -4); + } +} + +?> + - + diff --git a/docs/source-class-Config.html b/docs/source-class-Config.html index 4fbe9a96b..0c24b50bc 100644 --- a/docs/source-class-Config.html +++ b/docs/source-class-Config.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,12 +207,12 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 456: 457: 458: 459: 460: 461: 462: 463: 464: 465: 466: 467: 468: 469: 470: 471: 472: 473: 474: 475: 476: 477: 478: 479: 480: 481: 482: 483: 484: 485: 486: 487: 488: 489: 490: 491: 492: 493: 494: 495: 496: 497: 498: 499: 500: 501: 502: 503: 504: 505: 506: 507: 508: 509: 510: 511: 512: 513: 514: 515: 516: 517: 518: 519: 520: 521: 522: 523: 524: 525: 526: 527: 528: 529: 530: 531: 532: 533: 534: 535: 536: 537: 538: 539: 540: 541: 542: 543: 544: 545: 546: 547: 548: 549: 550: 551: 552: 553: 554: 555: 556: 557: 558: 559: 560: 561: 562: 563: 564: 565: 566: 567: 568: 569: 570: 571: 572: 573: 574: 575: 576: 577: 578: 579: 580: 581: 582: 583: 584: 585: 586: 587: 588: 589: 590: 591: 592: 593: 594: 595: 596: 597: 598: 599: 600: 601: 602: 603: 604: 605: 606: 607: 608: 609: 610: 611: 612: 613: 614: 615: 616: 617: 618: 619: 620: 621: 622: 623: 624: 625: 626: 627: 628: 629: 630: 631: 632: 633: 634: 635: 636: 637: 638: 639: 640: 641: 642: 643: 644: 645: 646: 647: 648: 649: 650: 651: 652: 653: 654: 655: 656: 657: 658: 659: 660: 661: 662: 663: 664: 665: 666: 667: 668: 669: 670: 671: 672: 673: 674: 675: 676: 677: 678: 679: 680: 681: 682: 683: 684: 685: 686: 687: 688: 689: 690: 691: 692: 693: 694: 695: 696: 697: 698: 699: 700: 701: 702: 703: 704: 705: 706: 707: 708: 709: 710: 711: 712: 713: 714: 715: 716: 717: 718: 719: 720: 721: 722: 723: 724: 725: 726: 727: 728: 729: 730: 731: 732: 733: 734: 735: 736: 737: 738: 739: 740: 741: 742: 743: 744: 745: 746: 747: 748: 749: 750: 751: 752: 753: 754: 755: 756: 757: 758: 759: 760: 761: 762: 763: 764: 765: 766: 767: 768: 769: 770: 771: 772: 773: 774: 775: 776: 777: 778: 779: 780: 781: 782: 783: 784: 785: 786: 787: 788: 789: 790: 791: 792: 793: 794: 795: 796: 797: 798: 799: 800: 801: 802: 803: 804: 805: 806: 807: 808: 809: 810: 811: 812: 813: 814: 815: 816: 817: 818: 819: 820: 821: 822: 823: 824: 825: 826: 827: 828: 829: 830: 831: 832: 833: 834: 835: 836: 837: 838: 
    -
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 456: 457: 458: 459: 460: 461: 462: 463: 464: 465: 466: 467: 468: 469: 470: 471: 472: 473: 474: 475: 476: 477: 478: 479: 480: 481: 482: 483: 484: 485: 486: 487: 488: 489: 490: 491: 492: 493: 494: 495: 496: 497: 498: 499: 500: 501: 502: 503: 504: 505: 506: 507: 508: 509: 510: 511: 512: 513: 514: 515: 516: 517: 518: 519: 520: 521: 522: 523: 524: 525: 526: 527: 528: 529: 530: 531: 532: 533: 534: 535: 536: 537: 538: 539: 540: 541: 542: 543: 544: 545: 546: 547: 548: 549: 550: 551: 552: 553: 554: 555: 556: 557: 558: 559: 560: 561: 562: 563: 564: 565: 566: 567: 568: 569: 570: 571: 572: 573: 574: 575: 576: 577: 578: 579: 580: 581: 582: 583: 584: 585: 586: 587: 588: 589: 590: 591: 592: 593: 594: 595: 596: 597: 598: 599: 600: 601: 602: 603: 604: 605: 606: 607: 608: 609: 610: 611: 612: 613: 614: 615: 616: 617: 618: 619: 620: 621: 622: 623: 624: 625: 626: 627: 628: 629: 630: 631: 632: 633: 634: 635: 636: 637: 638: 639: 640: 641: 642: 643: 644: 645: 646: 647: 648: 649: 650: 651: 652: 653: 654: 655: 656: 657: 658: 659: 660: 661: 662: 663: 664: 665: 666: 667: 668: 669: 670: 671: 672: 673: 674: 675: 676: 677: 678: 679: 680: 681: 682: 683: 684: 685: 686: 687: 688: 689: 690: 691: 692: 693: 694: 695: 696: 697: 698: 699: 700: 701: 702: 703: 704: 705: 706: 707: 708: 709: 710: 711: 712: 713: 714: 715: 716: 717: 718: 719: 720: 721: 722: 723: 724: 725: 726: 727: 728: 729: 730: 731: 732: 733: 734: 735: 736: 737: 738: 739: 740: 741: 742: 743: 744: 745: 746: 747: 748: 749: 750: 751: 752: 753: 754: 755: 756: 757: 758: 759: 760: 761: 762: 763: 764: 765: 766: 767: 768: 769: 770: 771: 772: 773: 774: 775: 776: 777: 778: 779: 780: 781: 782: 783: 784: 785: 786: 787: 788: 789: 790: 791: 792: 793: 794: 795: 796: 797: 798: 799: 800: 801: 802: 803: 804: 805: 806: 807: 808: 809: 810: 811: 812: 813: 814: 815: 816: 817: 818: 819: 820: 821: 822: 823: 824: 825: 826: 827: 828: 829: 830: 831: 832: 833: 834: 835: 836: 837: 838: 839: 840: 841: 842: 843: 844: 845: 846: 847: 848: 849: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
     require_once("Secure_Controller.php");
     
    -class Config extends Secure_Controller 
    +class Config extends Secure_Controller
     {
         public function __construct()
         {
    @@ -294,11 +296,11 @@
                 foreach($array as $key => $val)
                 {
                     if(is_array($val) && $key == 'dependencies')
    -                {   
    +                {
                         foreach($val as $key1 => $val1)
                         {
                             if(is_array($val1))
    -                        {   
    +                        {
                                 $license[$i]['text'] .= 'component: ' . $key1 . "\n";
     
                                 foreach($val1 as $key2 => $val2)
    @@ -329,7 +331,7 @@
                         }
                     }
                 }
    -            
    +
                 $license[$i]['text'] = $this->xss_clean($license[$i]['text']);
             }
     
    @@ -348,7 +350,7 @@
                     if(is_array($val))
                     {
                         $license[$i]['text'] .= 'component: ' . $key . "\n";
    -                    
    +
                         foreach($val as $key1 => $val1)
                         {
                             if(is_array($val1))
    @@ -429,7 +431,7 @@
             else
             {
                 $data['mailchimp']['api_key'] = '';
    -            $data['mailchimp']['list_id'] = '';     
    +            $data['mailchimp']['list_id'] = '';
             }
     
             // load mailchimp lists associated to the given api key, already XSS cleaned in the private function
    @@ -449,14 +451,14 @@
                 'phone' => $this->input->post('phone'),
                 'email' => $this->input->post('email'),
                 'fax' => $this->input->post('fax'),
    -            'website' => $this->input->post('website'), 
    +            'website' => $this->input->post('website'),
                 'return_policy' => $this->input->post('return_policy')
             );
     
    -        if (!empty($upload_data['orig_name']))
    +        if(!empty($upload_data['orig_name']))
             {
                 // XSS file image sanity check
    -            if ($this->xss_clean($upload_data['raw_name'], TRUE) === TRUE)
    +            if($this->xss_clean($upload_data['raw_name'], TRUE) === TRUE)
                 {
                     $batch_save_data['company_logo'] = $upload_data['raw_name'] . $upload_data['file_ext'];
                 }
    @@ -517,7 +519,7 @@
             $number_locale = $this->input->post('number_locale');
             $fmt = new \NumberFormatter($number_locale, \NumberFormatter::CURRENCY);
             $currency_symbol = empty($this->input->post('currency_symbol')) ? $fmt->getSymbol(\NumberFormatter::CURRENCY_SYMBOL) : $this->input->post('currency_symbol');
    -        if ($this->input->post('thousands_separator') == 'false')
    +        if($this->input->post('thousands_separator') == 'false')
             {
                 $fmt->setAttribute(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL, '');
             }
    @@ -542,7 +544,7 @@
                 'dateformat' => $this->input->post('dateformat'),
                 'timeformat' => $this->input->post('timeformat'),
                 'thousands_separator' => $this->input->post('thousands_separator'),
    -            'number_locale' => $this->input->post('number_locale'), 
    +            'number_locale' => $this->input->post('number_locale'),
                 'currency_decimals' => $this->input->post('currency_decimals'),
                 'tax_decimals' => $this->input->post('tax_decimals'),
                 'quantity_decimals' => $this->input->post('quantity_decimals'),
    @@ -571,7 +573,7 @@
             {
                 $password = $this->encryption->encrypt($this->input->post('smtp_pass'));
             }
    -        
    +
             $batch_save_data = array(
                 'protocol' => $this->input->post('protocol'),
                 'mailpath' => $this->input->post('mailpath'),
    @@ -601,13 +603,13 @@
                 $password = $this->encryption->encrypt($this->input->post('msg_pwd'));
             }
     
    -        $batch_save_data = array(   
    +        $batch_save_data = array(
                 'msg_msg' => $this->input->post('msg_msg'),
                 'msg_uid' => $this->input->post('msg_uid'),
                 'msg_pwd' => $password,
                 'msg_src' => $this->input->post('msg_src')
             );
    -    
    +
             $result = $this->Appconfig->batch_save($batch_save_data);
             $success = $result ? TRUE : FALSE;
     
    @@ -637,7 +639,7 @@
                     }
                 }
             }
    -        
    +
             return $result;
         }
     
    @@ -645,7 +647,7 @@
         AJAX call from mailchimp config form to fetch the Mailchimp lists when a valid API key is inserted
         */
         public function ajax_check_mailchimp_api_key()
    -    {   
    +    {
             // load mailchimp lists associated to the given api key, already XSS cleaned in the private function
             $lists = $this->_mailchimp($this->input->post('mailchimp_api_key'));
             $success = count($lists) > 0 ? TRUE : FALSE;
    @@ -672,7 +674,7 @@
                 'mailchimp_api_key' => $api_key,
                 'mailchimp_list_id' => $list_id
             );
    -    
    +
             $result = $this->Appconfig->batch_save($batch_save_data);
             $success = $result ? TRUE : FALSE;
     
    @@ -681,34 +683,34 @@
                 'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully')
             ));
         }
    -    
    -    public function stock_locations() 
    +
    +    public function stock_locations()
         {
             $stock_locations = $this->Stock_location->get_all()->result_array();
    -        
    +
             $stock_locations = $this->xss_clean($stock_locations);
     
             $this->load->view('partial/stock_locations', array('stock_locations' => $stock_locations));
    -    } 
    -    
    -    public function dinner_tables() 
    +    }
    +
    +    public function dinner_tables()
         {
             $dinner_tables = $this->Dinner_table->get_all()->result_array();
    -        
    +
             $dinner_tables = $this->xss_clean($dinner_tables);
     
             $this->load->view('partial/dinner_tables', array('dinner_tables' => $dinner_tables));
         }
     
    -    public function customer_rewards() 
    +    public function customer_rewards()
         {
             $customer_rewards = $this->Customer_rewards->get_all()->result_array();
    -        
    +
             $customer_rewards = $this->xss_clean($customer_rewards);
     
             $this->load->view('partial/customer_rewards', array('customer_rewards' => $customer_rewards));
         }
    -    
    +
         private function _clear_session_state()
         {
             $this->sale_lib->clear_sale_location();
    @@ -719,21 +721,21 @@
             $this->receiving_lib->clear_stock_destination();
             $this->receiving_lib->clear_all();
         }
    -    
    -    public function save_locations() 
    +
    +    public function save_locations()
         {
             $this->db->trans_start();
    -        
    +
             $deleted_locations = $this->Stock_location->get_allowed_locations();
             foreach($this->input->post() as $key => $value)
             {
    -            if (strstr($key, 'stock_location'))
    +            if(strstr($key, 'stock_location'))
                 {
                     $location_id = preg_replace("/.*?_(\d+)$/", "$1", $key);
                     unset($deleted_locations[$location_id]);
                     // save or update
                     $location_data = array('location_name' => $value);
    -                if ($this->Stock_location->save($location_data, $location_id))
    +                if($this->Stock_location->save($location_data, $location_id))
                     {
                         $this->_clear_session_state();
                     }
    @@ -741,309 +743,320 @@
             }
     
             // all locations not available in post will be deleted now
    -        foreach ($deleted_locations as $location_id => $location_name)
    +        foreach($deleted_locations as $location_id => $location_name)
             {
                 $this->Stock_location->delete($location_id);
             }
     
             $this->db->trans_complete();
    -        
    +
             $success = $this->db->trans_status();
    -        
    -        echo json_encode(array('success' => $success, 'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully')));
    -    }
    -
    -    public function save_tables() 
    -    {
    -        $this->db->trans_start();
    -        
    -        $this->Appconfig->save('dinner_table_enable',$this->input->post('dinner_table_enable'));
    -
    -        $deleted_tables = $this->Dinner_table->get_all()->result_array();
    -        $not_to_delete = array();
    -        foreach($this->input->post() as $key => $value)
    -        {
    -            if (strstr($key, 'dinner_table') && $key != 'dinner_table_enable')
    -            {
    -
    -                $dinner_table_id = preg_replace("/.*?_(\d+)$/", "$1", $key);
    -                $not_to_delete[] = $dinner_table_id;
    +
    +        echo json_encode(array(
    +            'success' => $success,
    +            'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully')
    +        ));
    +    }
    +
    +    public function save_tables()
    +    {
    +        $this->db->trans_start();
    +
    +        $this->Appconfig->save('dinner_table_enable',$this->input->post('dinner_table_enable'));
    +
    +        $deleted_tables = $this->Dinner_table->get_all()->result_array();
    +        $not_to_delete = array();
    +        foreach($this->input->post() as $key => $value)
    +        {
    +            if(strstr($key, 'dinner_table') && $key != 'dinner_table_enable')
    +            {
     
    -                // save or update
    -                $table_data = array('name' => $value);
    -                if ($this->Dinner_table->save($table_data, $dinner_table_id))
    -                {
    -                    $this->_clear_session_state();
    -                }
    -            }
    -        }
    -
    -        // all locations not available in post will be deleted now
    -        foreach ($deleted_tables as $dinner_table)
    -        {
    -            if(!in_array($dinner_table['dinner_table_id'],$not_to_delete))
    -            {           
    -                $this->Dinner_table->delete($dinner_table['dinner_table_id']);
    -            }
    -        }
    -
    -        $this->db->trans_complete();
    -        
    -        $success = $this->db->trans_status();
    -        
    -        echo json_encode(array('success' => $success, 'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully')));
    -    }
    +                $dinner_table_id = preg_replace("/.*?_(\d+)$/", "$1", $key);
    +                $not_to_delete[] = $dinner_table_id;
    +
    +                // save or update
    +                $table_data = array('name' => $value);
    +                if($this->Dinner_table->save($table_data, $dinner_table_id))
    +                {
    +                    $this->_clear_session_state();
    +                }
    +            }
    +        }
    +
    +        // all locations not available in post will be deleted now
    +        foreach($deleted_tables as $dinner_table)
    +        {
    +            if(!in_array($dinner_table['dinner_table_id'],$not_to_delete))
    +            {
    +                $this->Dinner_table->delete($dinner_table['dinner_table_id']);
    +            }
    +        }
    +
    +        $this->db->trans_complete();
    +
    +        $success = $this->db->trans_status();
     
    -    public function save_rewards() 
    -    {
    -        $this->db->trans_start();
    -        
    -        $this->Appconfig->save('customer_reward_enable',$this->input->post('customer_reward_enable'));
    +        echo json_encode(array(
    +            'success' => $success,
    +            'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully')
    +        ));
    +    }
     
    -        $deleted_packages = $this->Customer_rewards->get_all()->result_array();
    -        $not_to_delete = array();
    -        $array_save = array();
    -        foreach($this->input->post() as $key => $value)
    -        {   
    -            if (strstr($key, 'reward_points') && $key != 'customer_reward_enable')
    -            {
    -                $customer_reward_id = preg_replace("/.*?_(\d+)$/", "$1", $key);
    -                $not_to_delete[] = $customer_reward_id;
    -                $array_save[$customer_reward_id]['points_percent'] = $value;
    -            }
    -            if (strstr($key, 'customer_reward') && $key != 'customer_reward_enable')
    +    public function save_rewards()
    +    {
    +        $this->db->trans_start();
    +
    +        $this->Appconfig->save('customer_reward_enable', $this->input->post('customer_reward_enable'));
    +
    +        $deleted_packages = $this->Customer_rewards->get_all()->result_array();
    +        $not_to_delete = array();
    +        $array_save = array();
    +        foreach($this->input->post() as $key => $value)
    +        {
    +            if(strstr($key, 'reward_points') && $key != 'customer_reward_enable')
                 {
                     $customer_reward_id = preg_replace("/.*?_(\d+)$/", "$1", $key);
                     $not_to_delete[] = $customer_reward_id;
    -                $array_save[$customer_reward_id]['package_name'] = $value;
    +                $array_save[$customer_reward_id]['points_percent'] = $value;
                 }
    -        }
    -        if(!empty($array_save))
    -        foreach ($array_save as $key => $value) {
    -            // save or update
    -                $table_data = array('package_name' => $value['package_name'],'points_percent' => $value['points_percent']);
    -                if ($this->Customer_rewards->save($table_data, $key))
    -                {
    -                    $this->_clear_session_state();
    -                }
    -        }
    -
    -        // all locations not available in post will be deleted now
    -        foreach ($deleted_packages as $customer_reward)
    -        {
    -            if(!in_array($customer_reward['customer_reward_id'],$not_to_delete))
    -            {           
    -                $this->Customer_rewards->delete($customer_reward['customer_reward_id']);
    -            }
    -        }
    -
    -        $this->db->trans_complete();
    -        
    -        $success = $this->db->trans_status();
    -        
    -        echo json_encode(array(
    -            'success' => $success,
    -            'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully')
    -        ));
    -    }
    -
    -    public function save_barcode()
    -    {
    -        $batch_save_data = array(
    -            'barcode_type' => $this->input->post('barcode_type'),
    -            'barcode_quality' => $this->input->post('barcode_quality'),
    -            'barcode_width' => $this->input->post('barcode_width'),
    -            'barcode_height' => $this->input->post('barcode_height'),
    -            'barcode_font' => $this->input->post('barcode_font'),
    -            'barcode_font_size' => $this->input->post('barcode_font_size'),
    -            'barcode_first_row' => $this->input->post('barcode_first_row'),
    -            'barcode_second_row' => $this->input->post('barcode_second_row'),
    -            'barcode_third_row' => $this->input->post('barcode_third_row'),
    -            'barcode_num_in_row' => $this->input->post('barcode_num_in_row'),
    -            'barcode_page_width' => $this->input->post('barcode_page_width'),
    -            'barcode_page_cellspacing' => $this->input->post('barcode_page_cellspacing'),
    -            'barcode_generate_if_empty' => $this->input->post('barcode_generate_if_empty') != NULL,
    -            'barcode_content' => $this->input->post('barcode_content')
    -        );
    -
    -        $result = $this->Appconfig->batch_save($batch_save_data);
    -        $success = $result ? TRUE : FALSE;
    -        
    -        echo json_encode(array(
    -            'success' => $success,
    -            'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully')
    -        ));
    -    }
    -
    -    public function save_receipt()
    -    {
    -        $batch_save_data = array (
    -            'receipt_template' => $this->input->post('receipt_template'),
    -            'receipt_show_company_name' => $this->input->post('receipt_show_company_name') != NULL,
    -            'receipt_show_taxes' => $this->input->post('receipt_show_taxes') != NULL,
    -            'receipt_show_total_discount' => $this->input->post('receipt_show_total_discount') != NULL,
    -            'receipt_show_description' => $this->input->post('receipt_show_description') != NULL,
    -            'receipt_show_serialnumber' => $this->input->post('receipt_show_serialnumber') != NULL,
    -            'print_silently' => $this->input->post('print_silently') != NULL,
    -            'print_header' => $this->input->post('print_header') != NULL,
    -            'print_footer' => $this->input->post('print_footer') != NULL,
    -            'print_top_margin' => $this->input->post('print_top_margin'),
    -            'print_left_margin' => $this->input->post('print_left_margin'),
    -            'print_bottom_margin' => $this->input->post('print_bottom_margin'),
    -            'print_right_margin' => $this->input->post('print_right_margin')
    -        );
    -
    -        $result = $this->Appconfig->batch_save($batch_save_data);
    -        $success = $result ? TRUE : FALSE;
    -
    -        echo json_encode(array(
    -            'success' => $success,
    -            'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully')
    -        ));
    -    }
    -
    -    public function save_invoice()
    -    {
    -        $batch_save_data = array (
    -            'invoice_enable' => $this->input->post('invoice_enable') != NULL,
    -            'default_register_mode' => $this->input->post('default_register_mode'),
    -            'sales_invoice_format' => $this->input->post('sales_invoice_format'),
    -            'sales_quote_format' => $this->input->post('sales_quote_format'),
    -            'recv_invoice_format' => $this->input->post('recv_invoice_format'),
    -            'invoice_default_comments' => $this->input->post('invoice_default_comments'),
    -            'invoice_email_message' => $this->input->post('invoice_email_message'),
    -            'line_sequence' => $this->input->post('line_sequence'),
    -            'last_used_invoice_number' =>$this->input->post('last_used_invoice_number'),
    -            'last_used_quote_number' =>$this->input->post('last_used_quote_number')
    -        );
    -
    -        $result = $this->Appconfig->batch_save($batch_save_data);
    -        $success = $result ? TRUE : FALSE;
    -
    -        // Update the register mode with the latest change so that if the user
    -        // switches immediately back to the register the mode reflects the change
    -        if ($success == TRUE)
    -        {
    -            if ($this->config->item('invoice_enable') == '1')
    -            {
    -                $this->sale_lib->set_mode($batch_save_data['default_register_mode']);
    -            }
    -            else
    -            {
    -                $this->sale_lib->set_mode('sale');
    -            }
    -        }
    -
    -        echo json_encode(array(
    -            'success' => $success,
    -            'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully')
    -        ));
    -    }
    -
    -    public function remove_logo()
    -    {
    -        $result = $this->Appconfig->batch_save(array('company_logo' => ''));
    -        
    -        echo json_encode(array('success' => $result));
    -    }
    -
    -    private function _handle_logo_upload()
    -    {
    -        $this->load->helper('directory');
    +
    +            if(strstr($key, 'customer_reward') && $key != 'customer_reward_enable')
    +            {
    +                $customer_reward_id = preg_replace("/.*?_(\d+)$/", "$1", $key);
    +                $not_to_delete[] = $customer_reward_id;
    +                $array_save[$customer_reward_id]['package_name'] = $value;
    +            }
    +        }
    +
    +        if(!empty($array_save))
    +        {
    +            foreach($array_save as $key => $value)
    +            {
    +                // save or update
    +                $table_data = array('package_name' => $value['package_name'], 'points_percent' => $value['points_percent']);
    +                if($this->Customer_rewards->save($table_data, $key))
    +                {
    +                    $this->_clear_session_state();
    +                }
    +            }
    +        }
    +
    +        // all locations not available in post will be deleted now
    +        foreach($deleted_packages as $customer_reward)
    +        {
    +            if(!in_array($customer_reward['customer_reward_id'], $not_to_delete))
    +            {
    +                $this->Customer_rewards->delete($customer_reward['customer_reward_id']);
    +            }
    +        }
    +
    +        $this->db->trans_complete();
    +
    +        $success = $this->db->trans_status();
    +
    +        echo json_encode(array(
    +            'success' => $success,
    +            'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully')
    +        ));
    +    }
    +
    +    public function save_barcode()
    +    {
    +        $batch_save_data = array(
    +            'barcode_type' => $this->input->post('barcode_type'),
    +            'barcode_quality' => $this->input->post('barcode_quality'),
    +            'barcode_width' => $this->input->post('barcode_width'),
    +            'barcode_height' => $this->input->post('barcode_height'),
    +            'barcode_font' => $this->input->post('barcode_font'),
    +            'barcode_font_size' => $this->input->post('barcode_font_size'),
    +            'barcode_first_row' => $this->input->post('barcode_first_row'),
    +            'barcode_second_row' => $this->input->post('barcode_second_row'),
    +            'barcode_third_row' => $this->input->post('barcode_third_row'),
    +            'barcode_num_in_row' => $this->input->post('barcode_num_in_row'),
    +            'barcode_page_width' => $this->input->post('barcode_page_width'),
    +            'barcode_page_cellspacing' => $this->input->post('barcode_page_cellspacing'),
    +            'barcode_generate_if_empty' => $this->input->post('barcode_generate_if_empty') != NULL,
    +            'barcode_content' => $this->input->post('barcode_content')
    +        );
    +
    +        $result = $this->Appconfig->batch_save($batch_save_data);
    +        $success = $result ? TRUE : FALSE;
    +
    +        echo json_encode(array(
    +            'success' => $success,
    +            'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully')
    +        ));
    +    }
    +
    +    public function save_receipt()
    +    {
    +        $batch_save_data = array (
    +            'receipt_template' => $this->input->post('receipt_template'),
    +            'receipt_show_company_name' => $this->input->post('receipt_show_company_name') != NULL,
    +            'receipt_show_taxes' => $this->input->post('receipt_show_taxes') != NULL,
    +            'receipt_show_total_discount' => $this->input->post('receipt_show_total_discount') != NULL,
    +            'receipt_show_description' => $this->input->post('receipt_show_description') != NULL,
    +            'receipt_show_serialnumber' => $this->input->post('receipt_show_serialnumber') != NULL,
    +            'print_silently' => $this->input->post('print_silently') != NULL,
    +            'print_header' => $this->input->post('print_header') != NULL,
    +            'print_footer' => $this->input->post('print_footer') != NULL,
    +            'print_top_margin' => $this->input->post('print_top_margin'),
    +            'print_left_margin' => $this->input->post('print_left_margin'),
    +            'print_bottom_margin' => $this->input->post('print_bottom_margin'),
    +            'print_right_margin' => $this->input->post('print_right_margin')
    +        );
    +
    +        $result = $this->Appconfig->batch_save($batch_save_data);
    +        $success = $result ? TRUE : FALSE;
    +
    +        echo json_encode(array(
    +            'success' => $success,
    +            'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully')
    +        ));
    +    }
    +
    +    public function save_invoice()
    +    {
    +        $batch_save_data = array (
    +            'invoice_enable' => $this->input->post('invoice_enable') != NULL,
    +            'default_register_mode' => $this->input->post('default_register_mode'),
    +            'sales_invoice_format' => $this->input->post('sales_invoice_format'),
    +            'sales_quote_format' => $this->input->post('sales_quote_format'),
    +            'recv_invoice_format' => $this->input->post('recv_invoice_format'),
    +            'invoice_default_comments' => $this->input->post('invoice_default_comments'),
    +            'invoice_email_message' => $this->input->post('invoice_email_message'),
    +            'line_sequence' => $this->input->post('line_sequence'),
    +            'last_used_invoice_number' =>$this->input->post('last_used_invoice_number'),
    +            'last_used_quote_number' =>$this->input->post('last_used_quote_number')
    +        );
    +
    +        $result = $this->Appconfig->batch_save($batch_save_data);
    +        $success = $result ? TRUE : FALSE;
    +
    +        // Update the register mode with the latest change so that if the user
    +        // switches immediately back to the register the mode reflects the change
    +        if($success == TRUE)
    +        {
    +            if($this->config->item('invoice_enable') == '1')
    +            {
    +                $this->sale_lib->set_mode($batch_save_data['default_register_mode']);
    +            }
    +            else
    +            {
    +                $this->sale_lib->set_mode('sale');
    +            }
    +        }
    +
    +        echo json_encode(array(
    +            'success' => $success,
    +            'message' => $this->lang->line('config_saved_' . ($success ? '' : 'un') . 'successfully')
    +        ));
    +    }
     
    -        // load upload library
    -        $config = array('upload_path' => './uploads/',
    -                'allowed_types' => 'gif|jpg|png',
    -                'max_size' => '1024',
    -                'max_width' => '800',
    -                'max_height' => '680',
    -                'file_name' => 'company_logo');
    -        $this->load->library('upload', $config);
    -        $this->upload->do_upload('company_logo');
    -
    -        return strlen($this->upload->display_errors()) == 0 || !strcmp($this->upload->display_errors(), '<p>'.$this->lang->line('upload_no_file_selected').'</p>');
    -    }
    -    
    -    private function _check_encryption()
    -    {
    -        $encryption_key = $this->config->item('encryption_key');
    -
    -        // check if the encryption_key config item is the default one
    -        if($encryption_key == '' || $encryption_key == 'YOUR KEY')
    -        {
    -            // Config path
    -            $config_path = APPPATH . 'config/config.php';
    -
    -            // Open the file
    -            $config = file_get_contents($config_path);
    -
    -            // $key will be assigned a 32-byte (256-bit) hex-encoded random key
    -            $key = bin2hex($this->encryption->create_key(32));
    -
    -            // set the encryption key in the config item
    -            $this->config->set_item('encryption_key', $key);
    -
    -            // replace the empty placeholder with a real randomly generated encryption key
    -            $config = preg_replace("/(.*encryption_key.*)('');/", "$1'$key';", $config);
    -
    -            $result = FALSE;
    +    public function remove_logo()
    +    {
    +        $result = $this->Appconfig->batch_save(array('company_logo' => ''));
    +
    +        echo json_encode(array('success' => $result));
    +    }
    +
    +    private function _handle_logo_upload()
    +    {
    +        $this->load->helper('directory');
    +
    +        // load upload library
    +        $config = array('upload_path' => './uploads/',
    +                'allowed_types' => 'gif|jpg|png',
    +                'max_size' => '1024',
    +                'max_width' => '800',
    +                'max_height' => '680',
    +                'file_name' => 'company_logo');
    +        $this->load->library('upload', $config);
    +        $this->upload->do_upload('company_logo');
    +
    +        return strlen($this->upload->display_errors()) == 0 || !strcmp($this->upload->display_errors(), '<p>'.$this->lang->line('upload_no_file_selected').'</p>');
    +    }
    +
    +    private function _check_encryption()
    +    {
    +        $encryption_key = $this->config->item('encryption_key');
    +
    +        // check if the encryption_key config item is the default one
    +        if($encryption_key == '' || $encryption_key == 'YOUR KEY')
    +        {
    +            // Config path
    +            $config_path = APPPATH . 'config/config.php';
    +
    +            // Open the file
    +            $config = file_get_contents($config_path);
     
    -            // Chmod the file
    -            @chmod($config_path, 0777);
    -            
    -            // Write the new config.php file
    -            $handle = fopen($config_path, 'w+');
    +            // $key will be assigned a 32-byte (256-bit) hex-encoded random key
    +            $key = bin2hex($this->encryption->create_key(32));
    +
    +            // set the encryption key in the config item
    +            $this->config->set_item('encryption_key', $key);
     
    -            // Verify file permissions
    -            if(is_writable($config_path))
    -            {
    -                // Write the file
    -                $result = (fwrite($handle, $config) === FALSE) ? FALSE : TRUE;
    -            }
    -
    -            fclose($handle);
    -
    -            // Chmod the file
    -            @chmod($config_path, 0444);
    -            
    -            return $result;
    -        }
    -        
    -        return TRUE;
    -    }
    +            // replace the empty placeholder with a real randomly generated encryption key
    +            $config = preg_replace("/(.*encryption_key.*)('');/", "$1'$key';", $config);
    +
    +            $result = FALSE;
    +
    +            // Chmod the file
    +            @chmod($config_path, 0777);
    +
    +            // Write the new config.php file
    +            $handle = fopen($config_path, 'w+');
    +
    +            // Verify file permissions
    +            if(is_writable($config_path))
    +            {
    +                // Write the file
    +                $result = (fwrite($handle, $config) === FALSE) ? FALSE : TRUE;
    +            }
     
    -    public function backup_db()
    -    {
    -        $employee_id = $this->Employee->get_logged_in_employee_info()->person_id;
    -        if($this->Employee->has_module_grant('config', $employee_id))
    -        {
    -            $this->load->dbutil();
    -
    -            $prefs = array(
    -                'format' => 'zip',
    -                'filename' => 'ospos.sql'
    -            );
    -
    -            $backup = $this->dbutil->backup($prefs);
    -
    -            $file_name = 'ospos-' . date("Y-m-d-H-i-s") .'.zip';
    -            $save = 'uploads/' . $file_name;
    -            $this->load->helper('download');
    -            while(ob_get_level())
    -            {
    -                ob_end_clean();
    -            }
    -
    -            force_download($file_name, $backup);
    -        }
    -        else
    -        {
    -            redirect('no_access/config');
    -        }
    -    }
    -}
    -?>
    -
    +
    fclose($handle); + + // Chmod the file + @chmod($config_path, 0444); + + return $result; + } + + return TRUE; + } + + public function backup_db() + { + $employee_id = $this->Employee->get_logged_in_employee_info()->person_id; + if($this->Employee->has_module_grant('config', $employee_id)) + { + $this->load->dbutil(); + + $prefs = array( + 'format' => 'zip', + 'filename' => 'ospos.sql' + ); + + $backup = $this->dbutil->backup($prefs); + + $file_name = 'ospos-' . date("Y-m-d-H-i-s") .'.zip'; + $save = 'uploads/' . $file_name; + $this->load->helper('download'); + while(ob_get_level()) + { + ob_end_clean(); + } + + force_download($file_name, $backup); + } + else + { + redirect('no_access/config'); + } + } +} +?> +
    - + diff --git a/docs/source-class-Customer.html b/docs/source-class-Customer.html index dd313ef6a..a80519bbd 100644 --- a/docs/source-class-Customer.html +++ b/docs/source-class-Customer.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -206,7 +208,7 @@
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 
    -
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
     /**
      * Customer class
    @@ -217,16 +219,16 @@
      */
     
     class Customer extends Person
    -{   
    +{
         /*
         Determines if a given person_id is a customer
         */
         public function exists($person_id)
         {
    -        $this->db->from('customers');   
    +        $this->db->from('customers');
             $this->db->join('people', 'people.person_id = customers.person_id');
             $this->db->where('customers.person_id', $person_id);
    -        
    +
             return ($this->db->get()->num_rows() == 1);
         }
     
    @@ -244,7 +246,7 @@
             }
     
             return ($this->db->get()->num_rows() == 1);
    -    }   
    +    }
     
         /*
         Gets total of rows
    @@ -256,14 +258,14 @@
     
             return $this->db->count_all_results();
         }
    -    
    +
         /*
         Returns all the customers
         */
         public function get_all($rows = 0, $limit_from = 0)
         {
             $this->db->from('customers');
    -        $this->db->join('people', 'customers.person_id = people.person_id');            
    +        $this->db->join('people', 'customers.person_id = people.person_id');
             $this->db->where('deleted', 0);
             $this->db->order_by('last_name', 'asc');
     
    @@ -272,9 +274,9 @@
                 $this->db->limit($rows, $limit_from);
             }
     
    -        return $this->db->get();        
    +        return $this->db->get();
         }
    -    
    +
         /*
         Gets information about a particular customer
         */
    @@ -284,7 +286,7 @@
             $this->db->join('people', 'people.person_id = customers.person_id');
             $this->db->where('customers.person_id', $customer_id);
             $query = $this->db->get();
    -        
    +
             if($query->num_rows() == 1)
             {
                 return $query->row();
    @@ -293,25 +295,25 @@
             {
                 //Get empty base parent object, as $customer_id is NOT a customer
                 $person_obj = parent::get_info(-1);
    -            
    +
                 //Get all the fields from customer table
                 //append those fields to base parent object, we we have a complete empty object
                 foreach($this->db->list_fields('customers') as $field)
                 {
                     $person_obj->$field = '';
                 }
    -            
    +
                 return $person_obj;
             }
         }
    -    
    +
         /*
         Gets stats about a particular customer
         */
         public function get_stats($customer_id)
         {
             // create a temporary table to contain all the sum and average of items
    -        $this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_items_temp') . 
    +        $this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_items_temp') .
                 ' (INDEX(sale_id))
                 (
                     SELECT
    @@ -352,14 +354,14 @@
     
             return $stat;
         }
    -    
    +
         /*
         Gets information about multiple customers
         */
         public function get_multiple_info($customer_ids)
         {
             $this->db->from('customers');
    -        $this->db->join('people', 'people.person_id = customers.person_id');        
    +        $this->db->join('people', 'people.person_id = customers.person_id');
             $this->db->where_in('customers.person_id', $customer_ids);
             $this->db->order_by('last_name', 'asc');
     
    @@ -413,14 +415,14 @@
                     $success = $this->db->update('customers', $customer_data);
                 }
             }
    -        
    +
             $this->db->trans_complete();
     
             $success &= $this->db->trans_status();
     
             return $success;
         }
    -    
    +
         /*
         Updates reward points value
         */
    @@ -428,7 +430,7 @@
         {
             $this->db->where('person_id', $customer_id);
             $this->db->update('customers', array('points' => $value));
    -    } 
    +    }
     
     
         /*
    @@ -440,7 +442,7 @@
     
             return $this->db->update('customers', array('deleted' => 1));
         }
    -    
    +
         /*
         Deletes a list of customers
         */
    @@ -450,19 +452,19 @@
     
             return $this->db->update('customers', array('deleted' => 1));
         }
    -    
    +
         /*
         Get search suggestions to find customers
         */
         public function get_search_suggestions($search, $unique = TRUE, $limit = 25)
         {
             $suggestions = array();
    -        
    +
             $this->db->from('customers');
             $this->db->join('people', 'customers.person_id = people.person_id');
    -        $this->db->group_start();       
    +        $this->db->group_start();
                 $this->db->like('first_name', $search);
    -            $this->db->or_like('last_name', $search); 
    +            $this->db->or_like('last_name', $search);
                 $this->db->or_like('CONCAT(first_name, " ", last_name)', $search);
             $this->db->group_end();
             $this->db->where('deleted', 0);
    @@ -504,7 +506,7 @@
                     $suggestions[] = array('value' => $row->person_id, 'label' => $row->account_number);
                 }
             }
    -        
    +
             //only return $limit suggestions
             if(count($suggestions > $limit))
             {
    @@ -533,7 +535,7 @@
     
             return $this->db->get()->num_rows();
         }
    -    
    +
         /*
         Performs a search on customers
         */
    @@ -557,7 +559,7 @@
                 $this->db->limit($rows, $limit_from);
             }
     
    -        return $this->db->get();    
    +        return $this->db->get();
         }
     }
     ?>
    @@ -569,6 +571,6 @@
     
     
     
    -
    +
     
     
    diff --git a/docs/source-class-Customer_rewards.html b/docs/source-class-Customer_rewards.html
    index 59058e1eb..751f4e122 100644
    --- a/docs/source-class-Customer_rewards.html
    +++ b/docs/source-class-Customer_rewards.html
    @@ -80,6 +80,8 @@
     				
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,91 +207,100 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 
    -
    <?php
    -class Customer_rewards extends CI_Model
    -{
    -    public function exists($package_id)
    -    {
    -        $this->db->from('customers_packages');  
    -        $this->db->where('package_id', $package_id);
    -
    -        return ($this->db->get()->num_rows() >= 1);
    -    }
    -
    -    public function save(&$table_data, $package_id) 
    -    {
    -        $name = $$table_data['package_name'];
    -        $points_percent = $$table_data['points_percent'];
    -
    -        if(!$this->exists($package_id))
    -        {
    -            $this->db->trans_start();
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
    +
    +/**
    + * Customer_rewards class
    + *
    + * @link    github.com/jekkos/opensourcepos
    + * @since   3.1
    + * @author  joshua1234511
    + */
    +
    +class Customer_rewards extends CI_Model
    +{
    +    public function exists($package_id)
    +    {
    +        $this->db->from('customers_packages');
    +        $this->db->where('package_id', $package_id);
    +
    +        return ($this->db->get()->num_rows() >= 1);
    +    }
     
    -            $location_data = array('package_name'=>$name, 'deleted'=>0, 'points_percent'=>$points_percent);
    -            $this->db->insert('customers_packages', $table_data);
    -            $package_id = $this->db->insert_id();
    -
    -            $this->db->trans_complete();
    -
    -            return $this->db->trans_status();
    -        }
    -        else 
    -        {
    -            $this->db->where('package_id', $package_id);
    -
    -            return $this->db->update('customers_packages', $table_data);
    -        }
    -    }
    -
    -    public function get_name($package_id)
    -    {
    -        $this->db->from('customers_packages');
    -        $this->db->where('package_id',$package_id);
    +    public function save($package_data, $package_id)
    +    {
    +        $name = $package_data['package_name'];
    +        $points_percent = $package_data['points_percent'];
    +
    +        if(!$this->exists($package_id))
    +        {
    +            $this->db->trans_start();
    +
    +            $location_data = array('package_name' => $name, 'deleted' => 0, 'points_percent'=>$points_percent);
    +            $this->db->insert('customers_packages', $package_data);
    +            $package_id = $this->db->insert_id();
    +
    +            $this->db->trans_complete();
    +
    +            return $this->db->trans_status();
    +        }
    +        else
    +        {
    +            $this->db->where('package_id', $package_id);
     
    -        return $this->db->get()->row()->package_name;
    -    }
    -
    -    public function get_points_percent($package_id)
    -    {
    -        $this->db->from('customers_packages');
    -        $this->db->where('package_id',$package_id);
    -
    -        return $this->db->get()->row()->points_percent;
    -    }
    -
    -    public function get_all()
    -    {
    -        $this->db->from('customers_packages');
    -
    -        return $this->db->get();
    -    }
    -
    -    public function get_undeleted_all()
    -    {
    -        $this->db->from('customers_packages');
    -        $this->db->where('deleted', 0);
    -
    -        return $this->db->get();
    -    }
    -
    -    /*
    -    Deletes one reward
    -    */
    -    public function delete($package_id)
    -    {
    -        $this->db->trans_start();
    -
    -        $this->db->where('package_id', $package_id);
    -        $this->db->update('customers_packages', array('deleted' => 1));
    -
    -        $this->db->trans_complete();
    -
    -        return $this->db->trans_status();
    -    }
    -}
    -?>
    -
    +
    return $this->db->update('customers_packages', $package_data); + } + } + + public function get_name($package_id) + { + $this->db->from('customers_packages'); + $this->db->where('package_id', $package_id); + + return $this->db->get()->row()->package_name; + } + + public function get_points_percent($package_id) + { + $this->db->from('customers_packages'); + $this->db->where('package_id', $package_id); + + return $this->db->get()->row()->points_percent; + } + + public function get_all() + { + $this->db->from('customers_packages'); + + return $this->db->get(); + } + + public function get_undeleted_all() + { + $this->db->from('customers_packages'); + $this->db->where('deleted', 0); + + return $this->db->get(); + } + + /* + Deletes one reward + */ + public function delete($package_id) + { + $this->db->trans_start(); + + $this->db->where('package_id', $package_id); + $this->db->update('customers_packages', array('deleted' => 1)); + + $this->db->trans_complete(); + + return $this->db->trans_status(); + } +} +?> +
    - + diff --git a/docs/source-class-Customers.html b/docs/source-class-Customers.html index 0424d3fc0..e184aafe6 100644 --- a/docs/source-class-Customers.html +++ b/docs/source-class-Customers.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -625,6 +627,6 @@ - + diff --git a/docs/source-class-Detailed_receivings.html b/docs/source-class-Detailed_receivings.html index 540dd71e3..b28e1ab4f 100644 --- a/docs/source-class-Detailed_receivings.html +++ b/docs/source-class-Detailed_receivings.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,149 +207,146 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     
     require_once("Report.php");
     
     class Detailed_receivings extends Report
     {
    -    function __construct()
    +    public function create(array $inputs)
         {
    -        parent::__construct();
    -    }
    -
    -    public function create(array $inputs)
    -    {
    -        //Create our temp tables to work with the data in our report
    -        $this->Receiving->create_temp_table($inputs);
    -    }
    -
    -    public function getDataColumns()
    -    {
    -        $columns = array(
    -            'summary' => array(
    -                array('id' => $this->lang->line('reports_receiving_id')),
    -                array('receiving_date' => $this->lang->line('reports_date')),
    -                array('quantity' => $this->lang->line('reports_quantity')),
    -                array('employee_name' => $this->lang->line('reports_received_by')),
    -                array('supplier_name' => $this->lang->line('reports_supplied_by')),
    -                array('total' => $this->lang->line('reports_total'), 'sorter' => 'number_sorter'),
    -                array('payment_type' => $this->lang->line('reports_payment_type')),
    -                array('comment' => $this->lang->line('reports_comments')),
    -                array('reference' => $this->lang->line('receivings_reference'))),
    -            'details' => array(
    -                $this->lang->line('reports_item_number'),
    -                $this->lang->line('reports_name'),
    -                $this->lang->line('reports_category'),
    -                $this->lang->line('reports_quantity'),
    -                $this->lang->line('reports_total'),
    -                $this->lang->line('reports_discount'))
    -        );
    -
    -        return $columns;
    -    }
    -
    -    public function getDataByReceivingId($receiving_id)
    -    {
    -        $this->db->select('receiving_id, 
    -        MAX(receiving_date) as receiving_date, 
    -        SUM(quantity_purchased) AS items_purchased, 
    -        MAX(CONCAT(employee.first_name, " ", employee.last_name)) AS employee_name, 
    -        MAX(supplier.company_name) AS supplier_name, 
    -        SUM(subtotal) AS subtotal, 
    -        SUM(total) AS total, 
    -        SUM(profit) AS profit, 
    -        MAX(payment_type) as payment_type, 
    -        MAX(comment) as comment, 
    -        MAX(reference) as reference');
    -        $this->db->from('receivings_items_temp');
    -        $this->db->join('people AS employee', 'receivings_items_temp.employee_id = employee.person_id');
    -        $this->db->join('suppliers AS supplier', 'receivings_items_temp.supplier_id = supplier.person_id', 'left');
    -        $this->db->where('receiving_id', $receiving_id);
    -        $this->db->group_by('receiving_id');
    -
    -        return $this->db->get()->row_array();
    -    }
    -
    -    public function getData(array $inputs)
    -    {
    -        $this->db->select('receiving_id, 
    -        MAX(receiving_date) as receiving_date, 
    -        SUM(quantity_purchased) AS items_purchased, 
    -        MAX(CONCAT(employee.first_name," ",employee.last_name)) AS employee_name, 
    -        MAX(supplier.company_name) AS supplier_name, 
    -        SUM(total) AS total, 
    -        SUM(profit) AS profit, 
    -        MAX(payment_type) AS payment_type, 
    -        MAX(comment) AS comment, 
    -        MAX(reference) AS reference');
    -        $this->db->from('receivings_items_temp AS receivings_items_temp');
    -        $this->db->join('people AS employee', 'receivings_items_temp.employee_id = employee.person_id');
    -        $this->db->join('suppliers AS supplier', 'receivings_items_temp.supplier_id = supplier.person_id', 'left');
    +        //Create our temp tables to work with the data in our report
    +        $this->Receiving->create_temp_table($inputs);
    +    }
    +
    +    public function getDataColumns()
    +    {
    +        $columns = array(
    +            'summary' => array(
    +                array('id' => $this->lang->line('reports_receiving_id')),
    +                array('receiving_date' => $this->lang->line('reports_date')),
    +                array('quantity' => $this->lang->line('reports_quantity')),
    +                array('employee_name' => $this->lang->line('reports_received_by')),
    +                array('supplier_name' => $this->lang->line('reports_supplied_by')),
    +                array('total' => $this->lang->line('reports_total'), 'sorter' => 'number_sorter'),
    +                array('payment_type' => $this->lang->line('reports_payment_type')),
    +                array('comment' => $this->lang->line('reports_comments')),
    +                array('reference' => $this->lang->line('receivings_reference'))),
    +            'details' => array(
    +                $this->lang->line('reports_item_number'),
    +                $this->lang->line('reports_name'),
    +                $this->lang->line('reports_category'),
    +                $this->lang->line('reports_quantity'),
    +                $this->lang->line('reports_total'),
    +                $this->lang->line('reports_discount'))
    +        );
    +
    +        return $columns;
    +    }
    +
    +    public function getDataByReceivingId($receiving_id)
    +    {
    +        $this->db->select('receiving_id,
    +            MAX(receiving_date) as receiving_date,
    +            SUM(quantity_purchased) AS items_purchased,
    +            MAX(CONCAT(employee.first_name, " ", employee.last_name)) AS employee_name,
    +            MAX(supplier.company_name) AS supplier_name,
    +            SUM(subtotal) AS subtotal,
    +            SUM(total) AS total,
    +            SUM(profit) AS profit,
    +            MAX(payment_type) as payment_type,
    +            MAX(comment) as comment,
    +            MAX(reference) as reference');
    +        $this->db->from('receivings_items_temp');
    +        $this->db->join('people AS employee', 'receivings_items_temp.employee_id = employee.person_id');
    +        $this->db->join('suppliers AS supplier', 'receivings_items_temp.supplier_id = supplier.person_id', 'left');
    +        $this->db->where('receiving_id', $receiving_id);
    +        $this->db->group_by('receiving_id');
    +
    +        return $this->db->get()->row_array();
    +    }
    +
    +    public function getData(array $inputs)
    +    {
    +        $this->db->select('receiving_id,
    +            MAX(receiving_date) as receiving_date,
    +            SUM(quantity_purchased) AS items_purchased,
    +            MAX(CONCAT(employee.first_name," ",employee.last_name)) AS employee_name,
    +            MAX(supplier.company_name) AS supplier_name,
    +            SUM(total) AS total,
    +            SUM(profit) AS profit,
    +            MAX(payment_type) AS payment_type,
    +            MAX(comment) AS comment,
    +            MAX(reference) AS reference');
    +        $this->db->from('receivings_items_temp AS receivings_items_temp');
    +        $this->db->join('people AS employee', 'receivings_items_temp.employee_id = employee.person_id');
    +        $this->db->join('suppliers AS supplier', 'receivings_items_temp.supplier_id = supplier.person_id', 'left');
    +
    +        if($inputs['location_id'] != 'all')
    +        {
    +            $this->db->where('item_location', $inputs['location_id']);
    +        }
     
    -        if($inputs['location_id'] != 'all')
    +        if($inputs['receiving_type'] == 'receiving')
             {
    -            $this->db->where('item_location', $inputs['location_id']);
    +            $this->db->where('quantity_purchased > 0');
             }
    -        if($inputs['receiving_type'] == 'receiving')
    +        elseif($inputs['receiving_type'] == 'returns')
             {
    -            $this->db->where('quantity_purchased > 0');
    +            $this->db->where('quantity_purchased < 0');
             }
    -        elseif($inputs['receiving_type'] == 'returns')
    +        elseif($inputs['receiving_type'] == 'requisitions')
             {
    -            $this->db->where('quantity_purchased < 0');
    +            $this->db->having('items_purchased = 0');
             }
    -        elseif($inputs['receiving_type'] == 'requisitions')
    -        {
    -            $this->db->having('items_purchased = 0');
    -        }
    -        $this->db->group_by('receiving_id', 'receiving_date');
    -        $this->db->order_by('receiving_id');
    +        $this->db->group_by('receiving_id', 'receiving_date');
    +        $this->db->order_by('receiving_id');
    +
    +        $data = array();
    +        $data['summary'] = $this->db->get()->result_array();
    +        $data['details'] = array();
     
    -        $data = array();
    -        $data['summary'] = $this->db->get()->result_array();
    -        $data['details'] = array();
    -
    -        foreach($data['summary'] as $key=>$value)
    -        {
    -            $this->db->select('name, item_number, category, quantity_purchased, serialnumber,total, discount_percent, item_location, receivings_items_temp.receiving_quantity');
    -            $this->db->from('receivings_items_temp');
    -            $this->db->join('items', 'receivings_items_temp.item_id = items.item_id');
    -            $this->db->where('receiving_id = '.$value['receiving_id']);
    -            $data['details'][$key] = $this->db->get()->result_array();
    -        }
    -
    -        return $data;
    -    }
    -
    -    public function getSummaryData(array $inputs)
    -    {
    -        $this->db->select('SUM(total) AS total');
    -        $this->db->from('receivings_items_temp');
    -
    -        if($inputs['location_id'] != 'all')
    -        {
    -            $this->db->where('item_location', $inputs['location_id']);
    -        }
    -        if($inputs['receiving_type'] == 'receiving')
    -        {
    -            $this->db->where('quantity_purchased > 0');
    -        }
    -        elseif($inputs['receiving_type'] == 'returns')
    -        {
    -            $this->db->where('quantity_purchased < 0');
    -        }
    -        elseif($inputs['receiving_type'] == 'requisitions')
    -        {
    -            $this->db->where('quantity_purchased = 0');
    -        }
    -
    -        return $this->db->get()->row_array();
    -    }
    -}
    -?>
    -
    +
    foreach($data['summary'] as $key=>$value) + { + $this->db->select('name, item_number, category, quantity_purchased, serialnumber,total, discount_percent, item_location, receivings_items_temp.receiving_quantity'); + $this->db->from('receivings_items_temp'); + $this->db->join('items', 'receivings_items_temp.item_id = items.item_id'); + $this->db->where('receiving_id = '.$value['receiving_id']); + $data['details'][$key] = $this->db->get()->result_array(); + } + + return $data; + } + + public function getSummaryData(array $inputs) + { + $this->db->select('SUM(total) AS total'); + $this->db->from('receivings_items_temp'); + + if($inputs['location_id'] != 'all') + { + $this->db->where('item_location', $inputs['location_id']); + } + + if($inputs['receiving_type'] == 'receiving') + { + $this->db->where('quantity_purchased > 0'); + } + elseif($inputs['receiving_type'] == 'returns') + { + $this->db->where('quantity_purchased < 0'); + } + elseif($inputs['receiving_type'] == 'requisitions') + { + $this->db->where('quantity_purchased = 0'); + } + + return $this->db->get()->row_array(); + } +} +?> +
    - + diff --git a/docs/source-class-Detailed_sales.html b/docs/source-class-Detailed_sales.html index bd76327ce..b537db1cd 100644 --- a/docs/source-class-Detailed_sales.html +++ b/docs/source-class-Detailed_sales.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,144 +207,150 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 
    -
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
     require_once("Report.php");
     
     class Detailed_sales extends Report
     {
    -    function __construct()
    +    public function create(array $inputs)
         {
    -        parent::__construct();
    -    }
    -
    -    public function create(array $inputs)
    -    {
    -        //Create our temp tables to work with the data in our report
    -        $this->Sale->create_temp_table($inputs);
    -    }
    -
    -    public function getDataColumns()
    -    {
    -        return array(
    -            'summary' => array(
    -                array('id' => $this->lang->line('reports_sale_id')),
    -                array('sale_date' => $this->lang->line('reports_date')),
    -                array('quantity' => $this->lang->line('reports_quantity')),
    -                array('employee_name' => $this->lang->line('reports_sold_by')),
    -                array('customer_name' => $this->lang->line('reports_sold_to')),
    -                array('subtotal' => $this->lang->line('reports_subtotal'), 'sorter' => 'number_sorter'),
    -                array('tax' => $this->lang->line('reports_tax'), 'sorter' => 'number_sorter'),
    -                array('total' => $this->lang->line('reports_total'), 'sorter' => 'number_sorter'),
    -                array('cost' => $this->lang->line('reports_cost'), 'sorter' => 'number_sorter'),
    -                array('profit' => $this->lang->line('reports_profit'), 'sorter' => 'number_sorter'),
    -                array('payment_type' => $this->lang->line('sales_amount_tendered')),
    -                array('comment' => $this->lang->line('reports_comments'))),
    -            'details' => array(
    -                $this->lang->line('reports_name'),
    -                $this->lang->line('reports_category'),
    -                $this->lang->line('reports_serial_number'),
    -                $this->lang->line('reports_description'),
    -                $this->lang->line('reports_quantity'),
    -                $this->lang->line('reports_subtotal'),
    -                $this->lang->line('reports_tax'),
    -                $this->lang->line('reports_total'),
    -                $this->lang->line('reports_cost'),
    -                $this->lang->line('reports_profit'),
    -                $this->lang->line('reports_discount')),
    -            'details_rewards' => array(
    -                $this->lang->line('reports_used'),
    -                $this->lang->line('reports_earned'))
    -        );
    -    }
    -
    -    public function getDataBySaleId($sale_id)
    -    {
    -        $this->db->select('sale_id, sale_date, SUM(quantity_purchased) AS items_purchased, employee_name, customer_name, SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit, payment_type, comment');
    -        $this->db->from('sales_items_temp');
    -        $this->db->where('sale_id', $sale_id);
    -
    -        return $this->db->get()->row_array();
    -    }
    -
    -    public function getData(array $inputs)
    -    {
    -        $this->db->select('sale_id, 
    -        MAX(sale_date) AS sale_date, 
    -        SUM(quantity_purchased) AS items_purchased, 
    -        MAX(employee_name) AS employee_name, 
    -        MAX(customer_name) AS customer_name, 
    -        SUM(subtotal) AS subtotal, 
    -        SUM(tax) AS tax, 
    -        SUM(total) AS total, 
    -        SUM(cost) AS cost, 
    -        SUM(profit) AS profit, 
    -        MAX(payment_type) AS payment_type, 
    -        MAX(comment) AS comment');
    -        $this->db->from('sales_items_temp');
    -
    -        if($inputs['location_id'] != 'all')
    -        {
    -            $this->db->where('item_location', $inputs['location_id']);
    -        }
    -
    -        if($inputs['sale_type'] == 'sales')
    -        {
    -            $this->db->where('quantity_purchased > 0');
    -        }
    -        elseif($inputs['sale_type'] == 'returns')
    -        {
    -            $this->db->where('quantity_purchased < 0');
    -        }
    -
    -        $this->db->group_by('sale_id');
    -        $this->db->order_by('MAX(sale_date)');
    -
    -        $data = array();
    -        $data['summary'] = $this->db->get()->result_array();
    -        $data['details'] = array();
    -        $data['rewards'] = array();
    -
    -        foreach($data['summary'] as $key=>$value)
    -        {
    -            $this->db->select('name, category, quantity_purchased, item_location, serialnumber, description, subtotal, tax, total, cost, profit, discount_percent');
    -            $this->db->from('sales_items_temp');
    -            $this->db->where('sale_id', $value['sale_id']);
    -            $data['details'][$key] = $this->db->get()->result_array();
    -            $this->db->select('used, earned');
    -            $this->db->from('sales_reward_points');
    -            $this->db->where('sale_id', $value['sale_id']);
    -            $data['rewards'][$key] = $this->db->get()->result_array();
    -        }
    -
    -        return $data;
    -    }
    -
    -    public function getSummaryData(array $inputs)
    -    {
    -        $this->db->select('SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit');
    -        $this->db->from('sales_items_temp');
    -
    -        if($inputs['location_id'] != 'all')
    -        {
    -            $this->db->where('item_location', $inputs['location_id']);
    -        }
    -
    -        if($inputs['sale_type'] == 'sales')
    -        {
    -            $this->db->where('quantity_purchased > 0');
    -        }
    -        elseif($inputs['sale_type'] == 'returns')
    -        {
    -            $this->db->where('quantity_purchased < 0');
    -        }
    -
    -        return $this->db->get()->row_array();
    -    }
    -}
    -?>
    -
    +
    //Create our temp tables to work with the data in our report + $this->Sale->create_temp_table($inputs); + } + + public function getDataColumns() + { + return array( + 'summary' => array( + array('id' => $this->lang->line('reports_sale_id')), + array('sale_date' => $this->lang->line('reports_date')), + array('quantity' => $this->lang->line('reports_quantity')), + array('employee_name' => $this->lang->line('reports_sold_by')), + array('customer_name' => $this->lang->line('reports_sold_to')), + array('subtotal' => $this->lang->line('reports_subtotal'), 'sorter' => 'number_sorter'), + array('tax' => $this->lang->line('reports_tax'), 'sorter' => 'number_sorter'), + array('total' => $this->lang->line('reports_total'), 'sorter' => 'number_sorter'), + array('cost' => $this->lang->line('reports_cost'), 'sorter' => 'number_sorter'), + array('profit' => $this->lang->line('reports_profit'), 'sorter' => 'number_sorter'), + array('payment_type' => $this->lang->line('sales_amount_tendered')), + array('comment' => $this->lang->line('reports_comments'))), + 'details' => array( + $this->lang->line('reports_name'), + $this->lang->line('reports_category'), + $this->lang->line('reports_serial_number'), + $this->lang->line('reports_description'), + $this->lang->line('reports_quantity'), + $this->lang->line('reports_subtotal'), + $this->lang->line('reports_tax'), + $this->lang->line('reports_total'), + $this->lang->line('reports_cost'), + $this->lang->line('reports_profit'), + $this->lang->line('reports_discount')), + 'details_rewards' => array( + $this->lang->line('reports_used'), + $this->lang->line('reports_earned')) + ); + } + + public function getDataBySaleId($sale_id) + { + $this->db->select('sale_id, + sale_date, + SUM(quantity_purchased) AS items_purchased, + employee_name, + customer_name, + SUM(subtotal) AS subtotal, + SUM(tax) AS tax, + SUM(total) AS total, + SUM(cost) AS cost, + SUM(profit) AS profit, + payment_type, + comment'); + $this->db->from('sales_items_temp'); + $this->db->where('sale_id', $sale_id); + + return $this->db->get()->row_array(); + } + + public function getData(array $inputs) + { + $this->db->select('sale_id, + MAX(sale_date) AS sale_date, + SUM(quantity_purchased) AS items_purchased, + MAX(employee_name) AS employee_name, + MAX(customer_name) AS customer_name, + SUM(subtotal) AS subtotal, + SUM(tax) AS tax, + SUM(total) AS total, + SUM(cost) AS cost, + SUM(profit) AS profit, + MAX(payment_type) AS payment_type, + MAX(comment) AS comment'); + $this->db->from('sales_items_temp'); + + if($inputs['location_id'] != 'all') + { + $this->db->where('item_location', $inputs['location_id']); + } + + if($inputs['sale_type'] == 'sales') + { + $this->db->where('quantity_purchased > 0'); + } + elseif($inputs['sale_type'] == 'returns') + { + $this->db->where('quantity_purchased < 0'); + } + + $this->db->group_by('sale_id'); + $this->db->order_by('MAX(sale_date)'); + + $data = array(); + $data['summary'] = $this->db->get()->result_array(); + $data['details'] = array(); + $data['rewards'] = array(); + + foreach($data['summary'] as $key=>$value) + { + $this->db->select('name, category, quantity_purchased, item_location, serialnumber, description, subtotal, tax, total, cost, profit, discount_percent'); + $this->db->from('sales_items_temp'); + $this->db->where('sale_id', $value['sale_id']); + $data['details'][$key] = $this->db->get()->result_array(); + $this->db->select('used, earned'); + $this->db->from('sales_reward_points'); + $this->db->where('sale_id', $value['sale_id']); + $data['rewards'][$key] = $this->db->get()->result_array(); + } + + return $data; + } + + public function getSummaryData(array $inputs) + { + $this->db->select('SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit'); + $this->db->from('sales_items_temp'); + + if($inputs['location_id'] != 'all') + { + $this->db->where('item_location', $inputs['location_id']); + } + + if($inputs['sale_type'] == 'sales') + { + $this->db->where('quantity_purchased > 0'); + } + elseif($inputs['sale_type'] == 'returns') + { + $this->db->where('quantity_purchased < 0'); + } + + return $this->db->get()->row_array(); + } +} +?> +
    - + diff --git a/docs/source-class-Dinner_table.html b/docs/source-class-Dinner_table.html index 51736e94b..d91dfee64 100644 --- a/docs/source-class-Dinner_table.html +++ b/docs/source-class-Dinner_table.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,110 +207,119 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 
    -
    <?php
    -class Dinner_table extends CI_Model
    -{
    -    public function exists($dinner_table_id)
    -    {
    -        $this->db->from('dinner_tables');  
    -        $this->db->where('dinner_table_id', $dinner_table_id);
    -
    -        return ($this->db->get()->num_rows() >= 1);
    -    }
    -
    -    public function save(&$table_data, $dinner_table_id) 
    -    {
    -        $name = $$table_data['name'];
    -
    -        if(!$this->exists($dinner_table_id))
    -        {
    -            $this->db->trans_start();
    -
    -            $location_data = array('name'=>$name, 'deleted'=>0);
    -            $this->db->insert('dinner_tables', $table_data);
    -            $dinner_table_id = $this->db->insert_id();
    -
    -            $this->db->trans_complete();
    -
    -            return $this->db->trans_status();
    -        }
    -        else 
    -        {
    -            $this->db->where('dinner_table_id', $dinner_table_id);
    -
    -            return $this->db->update('dinner_tables', $table_data);
    -        }
    -    }
    -
    -    /*
    -    Get empty tables
    -    */
    -    public function get_empty_tables()
    -    {
    -        $this->db->from('dinner_tables');
    -        $this->db->where('status', 0);
    -        $this->db->where('deleted', 0);
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
    +
    +/**
    + * Dinner_table class
    + *
    + * @link    github.com/jekkos/opensourcepos
    + * @since   3.1
    + * @author  jlctmaster
    + */
    +
    +class Dinner_table extends CI_Model
    +{
    +    public function exists($dinner_table_id)
    +    {
    +        $this->db->from('dinner_tables');
    +        $this->db->where('dinner_table_id', $dinner_table_id);
    +
    +        return ($this->db->get()->num_rows() >= 1);
    +    }
    +
    +    public function save($table_data, $dinner_table_id)
    +    {
    +        $name = $table_data['name'];
    +
    +        if(!$this->exists($dinner_table_id))
    +        {
    +            $this->db->trans_start();
    +
    +            $location_data = array('name' => $name, 'deleted' => 0);
    +            $this->db->insert('dinner_tables', $table_data);
    +            $dinner_table_id = $this->db->insert_id();
    +
    +            $this->db->trans_complete();
    +
    +            return $this->db->trans_status();
    +        }
    +        else
    +        {
    +            $this->db->where('dinner_table_id', $dinner_table_id);
    +
    +            return $this->db->update('dinner_tables', $table_data);
    +        }
    +    }
     
    -        $empty_tables =  $this->db->get()->result_array();
    -
    -        $empty_tables_array = array();
    -        foreach($empty_tables as $empty_table)
    -        {
    -            $empty_tables_array[$empty_table['dinner_table_id']] = $empty_table['name'];
    -        }
    -
    -        return $empty_tables_array;
    -
    -    }
    -
    -    public function get_name($dinner_table_id)
    -    {
    -        if(empty($dinner_table_id))
    -        {
    -            return '';
    -        }
    -        else
    -        {
    -            $this->db->from('dinner_tables');
    -            $this->db->where('dinner_table_id',$dinner_table_id);
    -
    -            return $this->db->get()->row()->name;
    -        }
    -    }
    -
    -    public function get_all()
    -    {
    -        $this->db->from('dinner_tables');
    -
    -        return $this->db->get();
    -    }
    -
    -    public function get_undeleted_all()
    -    {
    -        $this->db->from('dinner_tables');
    -        $this->db->where('deleted', 0);
    -
    -        return $this->db->get();
    -    }
    -
    -    /*
    -    Deletes one table
    -    */
    -    public function delete($dinner_table_id)
    -    {
    -        $this->db->trans_start();
    -
    -        $this->db->where('dinner_table_id', $dinner_table_id);
    -        $this->db->update('dinner_tables', array('deleted' => 1));
    -
    -        $this->db->trans_complete();
    -
    -        return $this->db->trans_status();
    -    }
    -}
    -?>
    -
    +
    /* + Get empty tables + */ + public function get_empty_tables() + { + $this->db->from('dinner_tables'); + $this->db->where('status', 0); + $this->db->where('deleted', 0); + + $empty_tables = $this->db->get()->result_array(); + + $empty_tables_array = array(); + foreach($empty_tables as $empty_table) + { + $empty_tables_array[$empty_table['dinner_table_id']] = $empty_table['name']; + } + + return $empty_tables_array; + + } + + public function get_name($dinner_table_id) + { + if(empty($dinner_table_id)) + { + return ''; + } + else + { + $this->db->from('dinner_tables'); + $this->db->where('dinner_table_id', $dinner_table_id); + + return $this->db->get()->row()->name; + } + } + + public function get_all() + { + $this->db->from('dinner_tables'); + + return $this->db->get(); + } + + public function get_undeleted_all() + { + $this->db->from('dinner_tables'); + $this->db->where('deleted', 0); + + return $this->db->get(); + } + + /* + Deletes one table + */ + public function delete($dinner_table_id) + { + $this->db->trans_start(); + + $this->db->where('dinner_table_id', $dinner_table_id); + $this->db->update('dinner_tables', array('deleted' => 1)); + + $this->db->trans_complete(); + + return $this->db->trans_status(); + } +} +?> +
    - + diff --git a/docs/source-class-Email_lib.html b/docs/source-class-Email_lib.html index 7e8877d05..b9ca5c329 100644 --- a/docs/source-class-Email_lib.html +++ b/docs/source-class-Email_lib.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,66 +207,76 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
    - 
    -class Email_lib
    -{
    -    private $CI;
    -
    -    public function __construct()
    -    {
    -        $this->CI =& get_instance();
    -        
    -        $this->CI->load->library('email');
    +
    +/**
    + * Email library
    + *
    + * Library with utilities to configure and send emails
    + *
    + * @link    github.com/jekkos/opensourcepos
    + * @since   3.0
    + * @author  daN4cat (FrancescoUK)
    + */
     
    -        $config = array(
    -            'mailtype' => 'html',
    -            'useragent' => 'OSPOS',
    -            'validate' => TRUE,
    -            'protocol' => $this->CI->config->item('protocol'),
    -            'mailpath' => $this->CI->config->item('mailpath'),
    -            'smtp_host' => $this->CI->config->item('smtp_host'),
    -            'smtp_user' => $this->CI->config->item('smtp_user'),
    -            'smtp_pass' => $this->CI->encryption->decrypt($this->CI->config->item('smtp_pass')),
    -            'smtp_port' => $this->CI->config->item('smtp_port'),
    -            'smtp_timeout' => $this->CI->config->item('smtp_timeout'),
    -            'smtp_crypto' => $this->CI->config->item('smtp_crypto')
    -        );
    -        
    -        $this->CI->email->initialize($config);
    -    }
    -    
    -    /*
    -     * Email sending function
    -     * Example of use: $response = sendEmail('john@doe.com', 'Hello', 'This is a message', $filename);
    -     */
    -    public function sendEmail($to, $subject, $message, $attachment = NULL)
    -    {
    -        $email = $this->CI->email;
    -        
    -        $email->from($this->CI->config->item('email'), $this->CI->config->item('company'));
    -        $email->to($to);
    -        $email->subject($subject);
    -        $email->message($message);
    -        if( !empty($attachment) )
    -        {
    -            $email->attach($attachment);
    -        }
    -
    -        $result = $email->send();
    -        
    -        if(!$result)
    -        {
    -            error_log($email->print_debugger());
    -        }
    -        
    -        return $result;
    -    }
    -}
    -
    -?>
    -
    +
    class Email_lib +{ + private $CI; + + public function __construct() + { + $this->CI =& get_instance(); + + $this->CI->load->library('email'); + + $config = array( + 'mailtype' => 'html', + 'useragent' => 'OSPOS', + 'validate' => TRUE, + 'protocol' => $this->CI->config->item('protocol'), + 'mailpath' => $this->CI->config->item('mailpath'), + 'smtp_host' => $this->CI->config->item('smtp_host'), + 'smtp_user' => $this->CI->config->item('smtp_user'), + 'smtp_pass' => $this->CI->encryption->decrypt($this->CI->config->item('smtp_pass')), + 'smtp_port' => $this->CI->config->item('smtp_port'), + 'smtp_timeout' => $this->CI->config->item('smtp_timeout'), + 'smtp_crypto' => $this->CI->config->item('smtp_crypto') + ); + + $this->CI->email->initialize($config); + } + + /** + * Email sending function + * Example of use: $response = sendEmail('john@doe.com', 'Hello', 'This is a message', $filename); + */ + public function sendEmail($to, $subject, $message, $attachment = NULL) + { + $email = $this->CI->email; + + $email->from($this->CI->config->item('email'), $this->CI->config->item('company')); + $email->to($to); + $email->subject($subject); + $email->message($message); + if(!empty($attachment)) + { + $email->attach($attachment); + } + + $result = $email->send(); + + if(!$result) + { + error_log($email->print_debugger()); + } + + return $result; + } +} + +?> +
    - + diff --git a/docs/source-class-Employee.html b/docs/source-class-Employee.html index ecfd64a0b..8ef58870c 100644 --- a/docs/source-class-Employee.html +++ b/docs/source-class-Employee.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -206,7 +208,7 @@
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 456: 457: 458: 459: 460: 461: 462: 463: 464: 465: 466: 467: 468: 
    -
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
     /**
      * Employee class
    @@ -223,12 +225,12 @@
         */
         public function exists($person_id)
         {
    -        $this->db->from('employees');   
    +        $this->db->from('employees');
             $this->db->join('people', 'people.person_id = employees.person_id');
             $this->db->where('employees.person_id', $person_id);
     
             return ($this->db->get()->num_rows() == 1);
    -    }   
    +    }
     
         /*
         Gets total of rows
    @@ -247,21 +249,21 @@
         public function get_all($limit = 10000, $offset = 0)
         {
             $this->db->from('employees');
    -        $this->db->where('deleted', 0);     
    -        $this->db->join('people', 'employees.person_id = people.person_id');            
    +        $this->db->where('deleted', 0);
    +        $this->db->join('people', 'employees.person_id = people.person_id');
             $this->db->order_by('last_name', 'asc');
             $this->db->limit($limit);
             $this->db->offset($offset);
     
    -        return $this->db->get();        
    +        return $this->db->get();
         }
    -    
    +
         /*
         Gets information about a particular employee
         */
         public function get_info($employee_id)
         {
    -        $this->db->from('employees');   
    +        $this->db->from('employees');
             $this->db->join('people', 'people.person_id = employees.person_id');
             $this->db->where('employees.person_id', $employee_id);
             $query = $this->db->get();
    @@ -292,11 +294,11 @@
         public function get_multiple_info($employee_ids)
         {
             $this->db->from('employees');
    -        $this->db->join('people', 'people.person_id = employees.person_id');        
    +        $this->db->join('people', 'people.person_id = employees.person_id');
             $this->db->where_in('employees.person_id', $employee_ids);
             $this->db->order_by('last_name', 'asc');
     
    -        return $this->db->get();        
    +        return $this->db->get();
         }
     
         /*
    @@ -322,12 +324,12 @@
                     $success = $this->db->update('employees', $employee_data);
                 }
     
    -            //We have either inserted or updated a new employee, now lets set permissions. 
    +            //We have either inserted or updated a new employee, now lets set permissions.
                 if($success)
                 {
                     //First lets clear out any grants the employee currently has.
                     $success = $this->db->delete('grants', array('person_id' => $employee_id));
    -                
    +
                     //Now insert the new grants
                     if($success)
                     {
    @@ -364,7 +366,7 @@
     
             //Delete permissions
             if($this->db->delete('grants', array('person_id' => $employee_id)))
    -        {   
    +        {
                 $this->db->where('person_id', $employee_id);
                 $success = $this->db->update('employees', array('deleted' => 1));
             }
    @@ -415,7 +417,7 @@
             $this->db->join('people', 'employees.person_id = people.person_id');
             $this->db->group_start();
                 $this->db->like('first_name', $search);
    -            $this->db->or_like('last_name', $search); 
    +            $this->db->or_like('last_name', $search);
                 $this->db->or_like('CONCAT(first_name, " ", last_name)', $search);
             $this->db->group_end();
             $this->db->where('deleted', 0);
    @@ -507,7 +509,7 @@
                 $this->db->limit($rows, $limit_from);
             }
     
    -        return $this->db->get();    
    +        return $this->db->get();
         }
     
         /*
    @@ -551,7 +553,7 @@
     
             redirect('login');
         }
    -    
    +
         /*
         Determins if a employee is logged in
         */
    @@ -615,7 +617,7 @@
     
             $query = $this->db->get_where('grants', array('person_id' => $person_id, 'permission_id' => $permission_id), 1);
     
    -        return ($query->num_rows() == 1); 
    +        return ($query->num_rows() == 1);
         }
     
         /*
    @@ -681,6 +683,6 @@
     
     
     
    -
    +
     
     
    diff --git a/docs/source-class-Employees.html b/docs/source-class-Employees.html
    index 800b6f7bd..22c486fe3 100644
    --- a/docs/source-class-Employees.html
    +++ b/docs/source-class-Employees.html
    @@ -80,6 +80,8 @@
     				
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -424,6 +426,6 @@ - + diff --git a/docs/source-class-Giftcard.html b/docs/source-class-Giftcard.html index fcc660fb1..4493fda20 100644 --- a/docs/source-class-Giftcard.html +++ b/docs/source-class-Giftcard.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,315 +207,327 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 
    -
    <?php
    -class Giftcard extends CI_Model
    -{
    -    /*
    -    Determines if a given giftcard_id is a giftcard
    -    */
    -    public function exists($giftcard_id)
    -    {
    -        $this->db->from('giftcards');
    -        $this->db->where('giftcard_id', $giftcard_id);
    -        $this->db->where('deleted', 0);
    -
    -        return ($this->db->get()->num_rows() == 1);
    -    }
    -    
    -    /*
    -    Gets max gift card number
    -    */
    -    public function get_max_number()
    -    {
    -        $this->db->select_max('giftcard_number');
    -        $this->db->from('giftcards');
    -        $this->db->where('giftcard_number REGEXP', "'^[0-9]+$'", FALSE);
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
    +
    +/**
    + * Giftcard class
    + *
    + * @link    github.com/jekkos/opensourcepos
    + * @since   1.0
    + * @author  N/A
    + */
    +
    +class Giftcard extends CI_Model
    +{
    +    /*
    +    Determines if a given giftcard_id is a giftcard
    +    */
    +    public function exists($giftcard_id)
    +    {
    +        $this->db->from('giftcards');
    +        $this->db->where('giftcard_id', $giftcard_id);
    +        $this->db->where('deleted', 0);
    +
    +        return ($this->db->get()->num_rows() == 1);
    +    }
     
    -        return $this->db->get()->row();
    -    }
    -    
    -    /*
    -    Gets total of rows
    -    */
    -    public function get_total_rows()
    -    {
    -        $this->db->from('giftcards');
    -        $this->db->where('deleted', 0);
    +    /*
    +    Gets max gift card number
    +    */
    +    public function get_max_number()
    +    {
    +        $this->db->select('cast(giftcard_number AS UNSIGNED) AS giftcard_number');
    +        $this->db->from('giftcards');
    +        $this->db->where('giftcard_number REGEXP', "'^[0-9]+$'", FALSE);
    +        $this->db->order_by("giftcard_number","desc");
    +        $this->db->limit(1);
     
    -        return $this->db->count_all_results();
    -    }
    -
    -    /*
    -    Gets information about a particular giftcard
    -    */
    -    public function get_info($giftcard_id)
    -    {
    -        $this->db->from('giftcards');
    -        $this->db->join('people', 'people.person_id = giftcards.person_id', 'left');
    -        $this->db->where('giftcard_id', $giftcard_id);
    -        $this->db->where('deleted', 0);
    -
    -        $query = $this->db->get();
    +
    +        return $this->db->get()->row();
    +    }
    +
    +    /*
    +    Gets total of rows
    +    */
    +    public function get_total_rows()
    +    {
    +        $this->db->from('giftcards');
    +        $this->db->where('deleted', 0);
    +
    +        return $this->db->count_all_results();
    +    }
     
    -        if($query->num_rows() == 1)
    -        {
    -            return $query->row();
    -        }
    -        else
    -        {
    -            //Get empty base parent object, as $giftcard_id is NOT an giftcard
    -            $giftcard_obj = new stdClass();
    -
    -            //Get all the fields from giftcards table
    -            foreach($this->db->list_fields('giftcards') as $field)
    -            {
    -                $giftcard_obj->$field = '';
    -            }
    -
    -            return $giftcard_obj;
    -        }
    -    }
    -
    -    /*
    -    Gets an giftcard id given an giftcard number
    -    */
    -    public function get_giftcard_id($giftcard_number)
    -    {
    -        $this->db->from('giftcards');
    -        $this->db->where('giftcard_number', $giftcard_number);
    -        $this->db->where('deleted', 0);
    -
    -        $query = $this->db->get();
    -
    -        if($query->num_rows() == 1)
    -        {
    -            return $query->row()->giftcard_id;
    -        }
    -
    -        return FALSE;
    -    }
    -
    -    /*
    -    Gets information about multiple giftcards
    -    */
    -    public function get_multiple_info($giftcard_ids)
    -    {
    -        $this->db->from('giftcards');
    -        $this->db->where_in('giftcard_id', $giftcard_ids);
    -        $this->db->where('deleted', 0);
    -        $this->db->order_by('giftcard_number', 'asc');
    -
    -        return $this->db->get();
    -    }
    -
    -    /*
    -    Inserts or updates a giftcard
    -    */
    -    public function save(&$giftcard_data, $giftcard_id = -1)
    -    {
    -        if($giftcard_id == -1 || !$this->exists($giftcard_id))
    -        {
    -            if($this->db->insert('giftcards', $giftcard_data))
    -            {
    -                $giftcard_data['giftcard_id'] = $this->db->insert_id();
    -
    -                return TRUE;
    -            }
    -
    -            return FALSE;
    -        }
    -
    -        $this->db->where('giftcard_id', $giftcard_id);
    -
    -        return $this->db->update('giftcards', $giftcard_data);
    -    }
    -
    -    /*
    -    Updates multiple giftcards at once
    -    */
    -    public function update_multiple($giftcard_data, $giftcard_ids)
    -    {
    -        $this->db->where_in('giftcard_id', $giftcard_ids);
    +    /*
    +    Gets information about a particular giftcard
    +    */
    +    public function get_info($giftcard_id)
    +    {
    +        $this->db->from('giftcards');
    +        $this->db->join('people', 'people.person_id = giftcards.person_id', 'left');
    +        $this->db->where('giftcard_id', $giftcard_id);
    +        $this->db->where('deleted', 0);
    +
    +        $query = $this->db->get();
    +
    +        if($query->num_rows() == 1)
    +        {
    +            return $query->row();
    +        }
    +        else
    +        {
    +            //Get empty base parent object, as $giftcard_id is NOT an giftcard
    +            $giftcard_obj = new stdClass();
    +
    +            //Get all the fields from giftcards table
    +            foreach($this->db->list_fields('giftcards') as $field)
    +            {
    +                $giftcard_obj->$field = '';
    +            }
    +
    +            return $giftcard_obj;
    +        }
    +    }
    +
    +    /*
    +    Gets an giftcard id given an giftcard number
    +    */
    +    public function get_giftcard_id($giftcard_number)
    +    {
    +        $this->db->from('giftcards');
    +        $this->db->where('giftcard_number', $giftcard_number);
    +        $this->db->where('deleted', 0);
    +
    +        $query = $this->db->get();
    +
    +        if($query->num_rows() == 1)
    +        {
    +            return $query->row()->giftcard_id;
    +        }
    +
    +        return FALSE;
    +    }
    +
    +    /*
    +    Gets information about multiple giftcards
    +    */
    +    public function get_multiple_info($giftcard_ids)
    +    {
    +        $this->db->from('giftcards');
    +        $this->db->where_in('giftcard_id', $giftcard_ids);
    +        $this->db->where('deleted', 0);
    +        $this->db->order_by('giftcard_number', 'asc');
    +
    +        return $this->db->get();
    +    }
    +
    +    /*
    +    Inserts or updates a giftcard
    +    */
    +    public function save(&$giftcard_data, $giftcard_id = -1)
    +    {
    +        if($giftcard_id == -1 || !$this->exists($giftcard_id))
    +        {
    +            if($this->db->insert('giftcards', $giftcard_data))
    +            {
    +                $giftcard_data['giftcard_number'] = $this->db->insert_id();
    +
    +                return TRUE;
    +            }
    +
    +            return FALSE;
    +        }
     
    -        return $this->db->update('giftcards', $giftcard_data);
    -    }
    -
    -    /*
    -    Deletes one giftcard
    -    */
    -    public function delete($giftcard_id)
    -    {
    -        $this->db->where('giftcard_id', $giftcard_id);
    -
    -        return $this->db->update('giftcards', array('deleted' => 1));
    -    }
    -
    -    /*
    -    Deletes a list of giftcards
    -    */
    -    public function delete_list($giftcard_ids)
    -    {
    -        $this->db->where_in('giftcard_id', $giftcard_ids);
    -
    -        return $this->db->update('giftcards', array('deleted' => 1));
    -    }
    -
    -    /*
    -    Get search suggestions to find giftcards
    -    */
    -    public function get_search_suggestions($search, $limit = 25)
    -    {
    -        $suggestions = array();
    -
    -        $this->db->from('giftcards');
    -        $this->db->like('giftcard_number', $search);
    -        $this->db->where('deleted', 0);
    -        $this->db->order_by('giftcard_number', 'asc');
    -        foreach($this->db->get()->result() as $row)
    -        {
    -            $suggestions[]=array('label' => $row->giftcard_number);
    -        }
    -
    -        $this->db->from('customers');
    -        $this->db->join('people', 'customers.person_id = people.person_id', 'left');
    -        $this->db->group_start();
    -            $this->db->like('first_name', $search);
    -            $this->db->or_like('last_name', $search);
    -            $this->db->or_like('CONCAT(first_name, " ", last_name)', $search);
    -        $this->db->group_end();
    -        $this->db->where('deleted', 0);
    -        $this->db->order_by('last_name', 'asc');
    -        foreach($this->db->get()->result() as $row)
    -        {
    -            $suggestions[] = array('label' => $row->first_name.' '.$row->last_name);
    -        }           
    -
    -        //only return $limit suggestions
    -        if(count($suggestions > $limit))
    -        {
    -            $suggestions = array_slice($suggestions, 0, $limit);
    -        }
    -
    -        return $suggestions;
    -    }
    -    
    -    /*
    -    Performs a search on giftcards
    -    */
    -    public function search($search, $rows = 0, $limit_from = 0, $sort = 'giftcard_number', $order = 'asc')
    -    {
    -        $this->db->from('giftcards');
    -        $this->db->join('people', 'giftcards.person_id = people.person_id', 'left');
    -        $this->db->group_start();
    -            $this->db->like('first_name', $search);
    -            $this->db->or_like('last_name', $search);
    -            $this->db->or_like('CONCAT(first_name, " ", last_name)', $search);
    -            $this->db->or_like('giftcard_number', $search);
    -            $this->db->or_like('giftcards.person_id', $search);
    -        $this->db->group_end();
    -        $this->db->where('giftcards.deleted', 0);
    -        $this->db->order_by($sort, $order);
    -
    -        if($rows > 0)
    -        {
    -            $this->db->limit($rows, $limit_from);
    -        }
    -
    -        return $this->db->get();
    -    }
    -    
    -    /*
    -    Gets gift cards
    -    */
    -    public function get_found_rows($search)
    -    {
    -        $this->db->from('giftcards');
    -        $this->db->join('people', 'giftcards.person_id = people.person_id', 'left');
    -        $this->db->group_start();
    -            $this->db->like('first_name', $search);
    -            $this->db->or_like('last_name', $search);
    -            $this->db->or_like('CONCAT(first_name, " ", last_name)', $search);
    -            $this->db->or_like('giftcard_number', $search);
    -            $this->db->or_like('giftcards.person_id', $search);
    -        $this->db->group_end();
    -        $this->db->where('giftcards.deleted', 0);
    -
    -        return $this->db->get()->num_rows();
    -    }
    -    
    -    /*
    -    Gets gift card value
    -    */
    -    public function get_giftcard_value($giftcard_number)
    -    {
    -        if( !$this->exists($this->get_giftcard_id($giftcard_number)) )
    -        {
    -            return 0;
    -        }
    -        
    -        $this->db->from('giftcards');
    -        $this->db->where('giftcard_number', $giftcard_number);
    -
    -        return $this->db->get()->row()->value;
    -    }
    -    
    -    /*
    -    Updates gift card value
    -    */
    -    public function update_giftcard_value($giftcard_number, $value)
    -    {
    -        $this->db->where('giftcard_number', $giftcard_number);
    -        $this->db->update('giftcards', array('value' => $value));
    -    }
    +        $this->db->where('giftcard_id', $giftcard_id);
    +
    +        return $this->db->update('giftcards', $giftcard_data);
    +    }
    +
    +    /*
    +    Updates multiple giftcards at once
    +    */
    +    public function update_multiple($giftcard_data, $giftcard_ids)
    +    {
    +        $this->db->where_in('giftcard_id', $giftcard_ids);
    +
    +        return $this->db->update('giftcards', $giftcard_data);
    +    }
    +
    +    /*
    +    Deletes one giftcard
    +    */
    +    public function delete($giftcard_id)
    +    {
    +        $this->db->where('giftcard_id', $giftcard_id);
    +
    +        return $this->db->update('giftcards', array('deleted' => 1));
    +    }
    +
    +    /*
    +    Deletes a list of giftcards
    +    */
    +    public function delete_list($giftcard_ids)
    +    {
    +        $this->db->where_in('giftcard_id', $giftcard_ids);
    +
    +        return $this->db->update('giftcards', array('deleted' => 1));
    +    }
    +
    +    /*
    +    Get search suggestions to find giftcards
    +    */
    +    public function get_search_suggestions($search, $limit = 25)
    +    {
    +        $suggestions = array();
    +
    +        $this->db->from('giftcards');
    +        $this->db->like('giftcard_number', $search);
    +        $this->db->where('deleted', 0);
    +        $this->db->order_by('giftcard_number', 'asc');
    +        foreach($this->db->get()->result() as $row)
    +        {
    +            $suggestions[]=array('label' => $row->giftcard_number);
    +        }
    +
    +        $this->db->from('customers');
    +        $this->db->join('people', 'customers.person_id = people.person_id', 'left');
    +        $this->db->group_start();
    +            $this->db->like('first_name', $search);
    +            $this->db->or_like('last_name', $search);
    +            $this->db->or_like('CONCAT(first_name, " ", last_name)', $search);
    +        $this->db->group_end();
    +        $this->db->where('deleted', 0);
    +        $this->db->order_by('last_name', 'asc');
    +        foreach($this->db->get()->result() as $row)
    +        {
    +            $suggestions[] = array('label' => $row->first_name.' '.$row->last_name);
    +        }
    +
    +        //only return $limit suggestions
    +        if(count($suggestions > $limit))
    +        {
    +            $suggestions = array_slice($suggestions, 0, $limit);
    +        }
    +
    +        return $suggestions;
    +    }
    +
    +    /*
    +    Performs a search on giftcards
    +    */
    +    public function search($search, $rows = 0, $limit_from = 0, $sort = 'giftcard_number', $order = 'asc')
    +    {
    +        $this->db->from('giftcards');
    +        $this->db->join('people', 'giftcards.person_id = people.person_id', 'left');
    +        $this->db->group_start();
    +            $this->db->like('first_name', $search);
    +            $this->db->or_like('last_name', $search);
    +            $this->db->or_like('CONCAT(first_name, " ", last_name)', $search);
    +            $this->db->or_like('giftcard_number', $search);
    +            $this->db->or_like('giftcards.person_id', $search);
    +        $this->db->group_end();
    +        $this->db->where('giftcards.deleted', 0);
    +        $this->db->order_by($sort, $order);
    +
    +        if($rows > 0)
    +        {
    +            $this->db->limit($rows, $limit_from);
    +        }
    +
    +        return $this->db->get();
    +    }
    +
    +    /*
    +    Gets gift cards
    +    */
    +    public function get_found_rows($search)
    +    {
    +        $this->db->from('giftcards');
    +        $this->db->join('people', 'giftcards.person_id = people.person_id', 'left');
    +        $this->db->group_start();
    +            $this->db->like('first_name', $search);
    +            $this->db->or_like('last_name', $search);
    +            $this->db->or_like('CONCAT(first_name, " ", last_name)', $search);
    +            $this->db->or_like('giftcard_number', $search);
    +            $this->db->or_like('giftcards.person_id', $search);
    +        $this->db->group_end();
    +        $this->db->where('giftcards.deleted', 0);
    +
    +        return $this->db->get()->num_rows();
    +    }
    +
    +    /*
    +    Gets gift card value
    +    */
    +    public function get_giftcard_value($giftcard_number)
    +    {
    +        if( !$this->exists($this->get_giftcard_id($giftcard_number)) )
    +        {
    +            return 0;
    +        }
    +
    +        $this->db->from('giftcards');
    +        $this->db->where('giftcard_number', $giftcard_number);
     
    -    /*
    -    Determines if a given giftcard_name esists
    -    */
    -    public function exists_gitcard_name($giftcard_name)
    -    {
    -        $giftcard_name = strtoupper($giftcard_name);
    -        $this->db->from('giftcards');
    -        $this->db->where('giftcard_number', $giftcard_name);
    -        $this->db->where('deleted', 0);
    -
    -        return ($this->db->get()->num_rows() == 1);
    -    }
    -
    -    /*
    -    Generate unique gift card name/number
    -    */
    -    public function generate_unique_giftcard_name($value)
    -    {
    -        $value = str_replace('.', 'DE', $value);
    -        $random = bin2hex(openssl_random_pseudo_bytes(3));
    -        $giftcard_name = (string)$random . '-' . $value;
    -        if($this->exists_gitcard_name($giftcard_name))
    -        {
    -            $this->generate_unique_giftcard_name($value);
    -        }
    -
    -        return strtoupper($giftcard_name);
    -    }
    -
    -    /*
    -    Gets gift card customer
    -    */
    -    public function get_giftcard_customer($giftcard_number)
    -    {
    -        if( !$this->exists($this->get_giftcard_id($giftcard_number)) )
    -        {
    -            return 0;
    -        }
    -        
    -        $this->db->from('giftcards');
    -        $this->db->where('giftcard_number', $giftcard_number);
    -
    -        return $this->db->get()->row()->person_id;
    -    }
    -}
    -?>
    -
    +
    return $this->db->get()->row()->value; + } + + /* + Updates gift card value + */ + public function update_giftcard_value($giftcard_number, $value) + { + $this->db->where('giftcard_number', $giftcard_number); + $this->db->update('giftcards', array('value' => $value)); + } + + /* + Determines if a given giftcard_name esists + */ + public function exists_gitcard_name($giftcard_name) + { + $giftcard_name = strtoupper($giftcard_name); + $this->db->from('giftcards'); + $this->db->where('giftcard_number', $giftcard_name); + $this->db->where('deleted', 0); + + return ($this->db->get()->num_rows() == 1); + } + + /* + Generate unique gift card name/number + */ + public function generate_unique_giftcard_name($value) + { + $value = str_replace('.', 'DE', $value); + $random = bin2hex(openssl_random_pseudo_bytes(3)); + $giftcard_name = (string)$random . '-' . $value; + if($this->exists_gitcard_name($giftcard_name)) + { + $this->generate_unique_giftcard_name($value); + } + + return strtoupper($giftcard_name); + } + + /* + Gets gift card customer + */ + public function get_giftcard_customer($giftcard_number) + { + if( !$this->exists($this->get_giftcard_id($giftcard_number)) ) + { + return 0; + } + + $this->db->from('giftcards'); + $this->db->where('giftcard_number', $giftcard_number); + + return $this->db->get()->row()->person_id; + } +} +?> +
    - + diff --git a/docs/source-class-Giftcards.html b/docs/source-class-Giftcards.html index 3519671f2..02c391e34 100644 --- a/docs/source-class-Giftcards.html +++ b/docs/source-class-Giftcards.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -361,6 +363,6 @@ - + diff --git a/docs/source-class-Home.html b/docs/source-class-Home.html index f17da8f61..6588583fe 100644 --- a/docs/source-class-Home.html +++ b/docs/source-class-Home.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,31 +207,27 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     
     require_once("Secure_Controller.php");
     
     class Home extends Secure_Controller 
     {
    -    public function __construct()
    +    public function index()
         {
    -        parent::__construct();  
    +        $this->load->view('home');
         }
     
    -    public function index()
    +    public function logout()
         {
    -        $this->load->view('home');
    -    }
    -
    -    public function logout()
    -    {
    -        $this->track_page('logout', 'logout');
    -
    -        $this->Employee->logout();
    -    }
    -}
    -?>
    +
    $this->track_page('logout', 'logout'); + + $this->Employee->logout(); + } +} +?> +
    - + diff --git a/docs/source-class-Inventory.html b/docs/source-class-Inventory.html index f80316b6d..0687bff6c 100644 --- a/docs/source-class-Inventory.html +++ b/docs/source-class-Inventory.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,29 +207,68 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 
    -
    <?php
    -class Inventory extends CI_Model 
    -{   
    -    public function insert($inventory_data)
    -    {
    -        return $this->db->insert('inventory', $inventory_data);
    -    }
    -    
    -    public function get_inventory_data_for_item($item_id, $location_id = FALSE)
    -    {
    -        $this->db->from('inventory');
    -        $this->db->where('trans_items', $item_id);
    -        if($location_id != FALSE)
    -        {
    -            $this->db->where('trans_location', $location_id);
    -        }
    -        $this->db->order_by('trans_date', 'desc');
    -
    -        return $this->db->get();        
    -    }
    -}
    -?>
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
    +
    +/**
    + * Inventory class
    + *
    + * @link    github.com/jekkos/opensourcepos
    + * @since   1.0
    + * @author  N/A
    + */
    +
    +class Inventory extends CI_Model
    +{
    +    public function insert($inventory_data)
    +    {
    +        return $this->db->insert('inventory', $inventory_data);
    +    }
    +
    +    public function get_inventory_data_for_item($item_id, $location_id = FALSE)
    +    {
    +        $this->db->from('inventory');
    +        $this->db->where('trans_items', $item_id);
    +        if($location_id != FALSE)
    +        {
    +            $this->db->where('trans_location', $location_id);
    +        }
    +        $this->db->order_by('trans_date', 'desc');
    +
    +        return $this->db->get();
    +    }
    +
    +    public function reset_quantity($item_id)
    +    {
    +        $inventory_sums = $this->Inventory->get_inventory_sum($item_id);
    +        foreach($inventory_sums as $inventory_sum)
    +        {
    +            if ($inventory_sum['sum'] > 0)
    +            {
    +                return $this->Inventory->insert(array(
    +                    'trans_inventory' => -1 * $inventory_sum['sum'],
    +                    'trans_items' => $item_id,
    +                    'trans_location' => $inventory_sum['location_id'],
    +                    'trans_comment' => $this->lang->line('items_is_deleted'),
    +                    'trans_user' => $this->Employee->get_logged_in_employee_info()->person_id)
    +                );
    +            }
    +        }
    +        return TRUE;
    +    }
    +
    +    public function get_inventory_sum($item_id)
    +    {
    +        $this->db->select('SUM(trans_inventory) AS sum, MAX(trans_location) AS location_id');
    +        $this->db->from('inventory');
    +        $this->db->where('trans_items', $item_id);
    +        $this->db->group_by('trans_location');
    +
    +        return $this->db->get()->result_array();
    +    }
    +}
    +?>
    +
    - + diff --git a/docs/source-class-Inventory_low.html b/docs/source-class-Inventory_low.html index d65809930..d64e9317e 100644 --- a/docs/source-class-Inventory_low.html +++ b/docs/source-class-Inventory_low.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,50 +207,45 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     
     require_once("Report.php");
     
     class Inventory_low extends Report
     {
    -    function __construct()
    +    public function getDataColumns()
         {
    -        parent::__construct();
    -    }
    -
    -    public function getDataColumns()
    -    {
    -        return array(
    -            array('item_name' => $this->lang->line('reports_item_name')),
    -            array('item_number' => $this->lang->line('reports_item_number')),
    -            array('quantity' => $this->lang->line('reports_quantity')),
    -            array('reorder_level' => $this->lang->line('reports_reorder_level')),
    -            array('location_name' => $this->lang->line('reports_stock_location')));
    -    }
    -    
    -    public function getData(array $inputs)
    -    {
    -        $this->db->select('items.name, items.item_number, item_quantities.quantity, items.reorder_level, stock_locations.location_name');
    -        $this->db->from('items');
    -        $this->db->join('item_quantities', 'items.item_id = item_quantities.item_id');
    -        $this->db->join('stock_locations', 'item_quantities.location_id = stock_locations.location_id');
    -        $this->db->where('items.deleted', 0);
    -        $this->db->where('stock_locations.deleted', 0);
    -        $this->db->where('items.stock_type', 0);
    -        $this->db->where('item_quantities.quantity <= items.reorder_level');
    -        $this->db->order_by('items.name');
    -
    -        return $this->db->get()->result_array();
    +        return array(
    +            array('item_name' => $this->lang->line('reports_item_name')),
    +            array('item_number' => $this->lang->line('reports_item_number')),
    +            array('quantity' => $this->lang->line('reports_quantity')),
    +            array('reorder_level' => $this->lang->line('reports_reorder_level')),
    +            array('location_name' => $this->lang->line('reports_stock_location')));
    +    }
    +
    +    public function getData(array $inputs)
    +    {
    +        $this->db->select('items.name, items.item_number, item_quantities.quantity, items.reorder_level, stock_locations.location_name');
    +        $this->db->from('items');
    +        $this->db->join('item_quantities', 'items.item_id = item_quantities.item_id');
    +        $this->db->join('stock_locations', 'item_quantities.location_id = stock_locations.location_id');
    +        $this->db->where('items.deleted', 0);
    +        $this->db->where('stock_locations.deleted', 0);
    +        $this->db->where('items.stock_type', 0);
    +        $this->db->where('item_quantities.quantity <= items.reorder_level');
    +        $this->db->order_by('items.name');
    +
    +        return $this->db->get()->result_array();
    +    }
    +
    +    public function getSummaryData(array $inputs)
    +    {
    +        return array();
         }
    -    
    -    public function getSummaryData(array $inputs)
    -    {
    -        return array();
    -    }
    -}
    -?>
    -
    +
    } +?> +
    - + diff --git a/docs/source-class-Inventory_summary.html b/docs/source-class-Inventory_summary.html index e46813aab..5e685c776 100644 --- a/docs/source-class-Inventory_summary.html +++ b/docs/source-class-Inventory_summary.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,92 +207,87 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     
     require_once("Report.php");
     
     class Inventory_summary extends Report
     {
    -    function __construct()
    +    public function getDataColumns()
         {
    -        parent::__construct();
    -    }
    -
    -    public function getDataColumns()
    -    {
    -        return array(array('item_name' => $this->lang->line('reports_item_name')),
    -                    array('item_number' => $this->lang->line('reports_item_number')),
    -                    array('quantity' => $this->lang->line('reports_quantity')),
    -                    array('reorder_level' => $this->lang->line('reports_reorder_level')),
    -                    array('location_name' => $this->lang->line('reports_stock_location')),
    -                    array('cost_price' => $this->lang->line('reports_cost_price'), 'sorter' => 'number_sorter'),
    -                    array('unit_price' => $this->lang->line('reports_unit_price'), 'sorter' => 'number_sorter'),
    -                    array('subtotal' => $this->lang->line('reports_sub_total_value'), 'sorter' => 'number_sorter'));
    -    }
    -
    -    public function getData(array $inputs)
    -    {   
    -        $this->db->select('items.name, items.item_number, item_quantities.quantity, items.reorder_level, stock_locations.location_name, items.cost_price, items.unit_price, (items.cost_price * item_quantities.quantity) AS sub_total_value');
    -        $this->db->from('items AS items');
    -        $this->db->join('item_quantities AS item_quantities', 'items.item_id = item_quantities.item_id');
    -        $this->db->join('stock_locations AS stock_locations', 'item_quantities.location_id = stock_locations.location_id');
    -        $this->db->where('items.deleted', 0);
    -        $this->db->where('items.stock_type', 0);
    -        $this->db->where('stock_locations.deleted', 0);
    -
    -        // should be corresponding to values Inventory_summary::getItemCountDropdownArray() returns...
    -        if($inputs['item_count'] == 'zero_and_less')
    -        {
    -            $this->db->where('item_quantities.quantity <= 0');
    -        }
    -        elseif($inputs['item_count'] == 'more_than_zero')
    +        return array(array('item_name' => $this->lang->line('reports_item_name')),
    +                    array('item_number' => $this->lang->line('reports_item_number')),
    +                    array('quantity' => $this->lang->line('reports_quantity')),
    +                    array('reorder_level' => $this->lang->line('reports_reorder_level')),
    +                    array('location_name' => $this->lang->line('reports_stock_location')),
    +                    array('cost_price' => $this->lang->line('reports_cost_price'), 'sorter' => 'number_sorter'),
    +                    array('unit_price' => $this->lang->line('reports_unit_price'), 'sorter' => 'number_sorter'),
    +                    array('subtotal' => $this->lang->line('reports_sub_total_value'), 'sorter' => 'number_sorter'));
    +    }
    +
    +    public function getData(array $inputs)
    +    {
    +        $this->db->select('items.name, items.item_number, item_quantities.quantity, items.reorder_level, stock_locations.location_name, items.cost_price, items.unit_price, (items.cost_price * item_quantities.quantity) AS sub_total_value');
    +        $this->db->from('items AS items');
    +        $this->db->join('item_quantities AS item_quantities', 'items.item_id = item_quantities.item_id');
    +        $this->db->join('stock_locations AS stock_locations', 'item_quantities.location_id = stock_locations.location_id');
    +        $this->db->where('items.deleted', 0);
    +        $this->db->where('items.stock_type', 0);
    +        $this->db->where('stock_locations.deleted', 0);
    +
    +        // should be corresponding to values Inventory_summary::getItemCountDropdownArray() returns...
    +        if($inputs['item_count'] == 'zero_and_less')
    +        {
    +            $this->db->where('item_quantities.quantity <= 0');
    +        }
    +        elseif($inputs['item_count'] == 'more_than_zero')
    +        {
    +            $this->db->where('item_quantities.quantity > 0');
    +        }
    +
    +        if($inputs['location_id'] != 'all')
             {
    -            $this->db->where('item_quantities.quantity > 0');
    +            $this->db->where('stock_locations.location_id', $inputs['location_id']);
             }
     
    -        if($inputs['location_id'] != 'all')
    -        {
    -            $this->db->where('stock_locations.location_id', $inputs['location_id']);
    -        }
    +        $this->db->order_by('items.name');
    +
    +        return $this->db->get()->result_array();
    +    }
     
    -        $this->db->order_by('items.name');
    -
    -        return $this->db->get()->result_array();
    -    }
    -
    -    /**
    -     * calculates the total value of the given inventory summary by summing all sub_total_values (see Inventory_summary::getData())
    -     * 
    -     * @param array $inputs expects the reports-data-array which Inventory_summary::getData() returns
    -     * @return array
    -     */
    -    public function getSummaryData(array $inputs)
    -    {
    -        $return = array('total_inventory_value' => 0);
    +    /**
    +     * calculates the total value of the given inventory summary by summing all sub_total_values (see Inventory_summary::getData())
    +     *
    +     * @param array $inputs expects the reports-data-array which Inventory_summary::getData() returns
    +     * @return array
    +     */
    +    public function getSummaryData(array $inputs)
    +    {
    +        $return = array('total_inventory_value' => 0);
    +
    +        foreach($inputs as $input)
    +        {
    +            $return['total_inventory_value'] += $input['sub_total_value'];
    +        }
     
    -        foreach($inputs as $input)
    -        {
    -            $return['total_inventory_value'] += $input['sub_total_value'];
    -        }
    -
    -        return $return;
    -    }
    -
    -    /**
    -     * returns the array for the dropdown-element item-count in the form for the inventory summary-report
    -     * 
    -     * @return array
    -     */
    -    public function getItemCountDropdownArray()
    -    {
    -        return array('all' => $this->lang->line('reports_all'),
    -                    'zero_and_less' => $this->lang->line('reports_zero_and_less'),
    -                    'more_than_zero' => $this->lang->line('reports_more_than_zero'));
    -    }
    -}
    -?>
    -
    + return $return; + } + + /** + * returns the array for the dropdown-element item-count in the form for the inventory summary-report + * + * @return array + */ + public function getItemCountDropdownArray() + { + return array('all' => $this->lang->line('reports_all'), + 'zero_and_less' => $this->lang->line('reports_zero_and_less'), + 'more_than_zero' => $this->lang->line('reports_more_than_zero')); + } +} +?> + - + diff --git a/docs/source-class-Item.html b/docs/source-class-Item.html index 75ca89759..bf00d6f00 100644 --- a/docs/source-class-Item.html +++ b/docs/source-class-Item.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,822 +207,837 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 456: 457: 458: 459: 460: 461: 462: 463: 464: 465: 466: 467: 468: 469: 470: 471: 472: 473: 474: 475: 476: 477: 478: 479: 480: 481: 482: 483: 484: 485: 486: 487: 488: 489: 490: 491: 492: 493: 494: 495: 496: 497: 498: 499: 500: 501: 502: 503: 504: 505: 506: 507: 508: 509: 510: 511: 512: 513: 514: 515: 516: 517: 518: 519: 520: 521: 522: 523: 524: 525: 526: 527: 528: 529: 530: 531: 532: 533: 534: 535: 536: 537: 538: 539: 540: 541: 542: 543: 544: 545: 546: 547: 548: 549: 550: 551: 552: 553: 554: 555: 556: 557: 558: 559: 560: 561: 562: 563: 564: 565: 566: 567: 568: 569: 570: 571: 572: 573: 574: 575: 576: 577: 578: 579: 580: 581: 582: 583: 584: 585: 586: 587: 588: 589: 590: 591: 592: 593: 594: 595: 596: 597: 598: 599: 600: 601: 602: 603: 604: 605: 606: 607: 608: 609: 610: 611: 612: 613: 614: 615: 616: 617: 618: 619: 620: 621: 622: 623: 624: 625: 626: 627: 628: 629: 630: 631: 632: 633: 634: 635: 636: 637: 638: 639: 640: 641: 642: 643: 644: 645: 646: 647: 648: 649: 650: 651: 652: 653: 654: 655: 656: 657: 658: 659: 660: 661: 662: 663: 664: 665: 666: 667: 668: 669: 670: 671: 672: 673: 674: 675: 676: 677: 678: 679: 680: 681: 682: 683: 684: 685: 686: 687: 688: 689: 690: 691: 692: 693: 694: 695: 696: 697: 698: 699: 700: 701: 702: 703: 704: 705: 706: 707: 708: 709: 710: 711: 712: 713: 714: 715: 716: 717: 718: 719: 720: 721: 722: 723: 724: 725: 726: 727: 728: 729: 730: 731: 732: 733: 734: 735: 736: 737: 738: 739: 740: 741: 742: 743: 744: 745: 746: 747: 748: 749: 750: 751: 752: 753: 754: 755: 756: 757: 758: 759: 760: 761: 762: 763: 764: 765: 766: 767: 768: 769: 770: 771: 772: 773: 774: 775: 776: 777: 778: 779: 780: 781: 782: 783: 784: 785: 786: 787: 788: 789: 790: 791: 792: 793: 794: 795: 796: 797: 798: 799: 800: 801: 802: 803: 804: 805: 806: 807: 808: 809: 810: 811: 812: 813: 814: 815: 
    -
    <?php
    -class Item extends CI_Model
    -{
    -    /*
    -    Determines if a given item_id is an item
    -    */
    -    public function exists($item_id, $ignore_deleted = FALSE, $deleted = FALSE)
    -    {
    -        if (ctype_digit($item_id))
    -        {
    -            $this->db->from('items');
    -            $this->db->where('item_id', (int) $item_id);
    -            if ($ignore_deleted == FALSE)
    -            {
    -                $this->db->where('deleted', $deleted);
    -            }
    -
    -            return ($this->db->get()->num_rows() == 1);
    -        }
    -
    -        return FALSE;
    -    }
    -
    -    /*
    -    Determines if a given item_number exists
    -    */
    -    public function item_number_exists($item_number, $item_id = '')
    -    {
    -        $this->db->from('items');
    -        $this->db->where('item_number', (string) $item_number);
    -        if(ctype_digit($item_id))
    -        {
    -            $this->db->where('item_id !=', (int) $item_id);
    -        }
    -
    -        return ($this->db->get()->num_rows() == 1);
    -    }
    -
    -    /*
    -    Gets total of rows
    -    */
    -    public function get_total_rows()
    -    {
    -        $this->db->from('items');
    -        $this->db->where('deleted', 0);
    -
    -        return $this->db->count_all_results();
    -    }
    -
    -    /*
    -    Get number of rows
    -    */
    -    public function get_found_rows($search, $filters)
    -    {
    -        return $this->search($search, $filters)->num_rows();
    -    }
    -
    -    /*
    -    Perform a search on items
    -    */
    -    public function search($search, $filters, $rows = 0, $limit_from = 0, $sort = 'items.name', $order = 'asc')
    -    {
    -        $this->db->select('MAX(items.name) as name');
    -        $this->db->select('MAX(items.category) as category');
    -        $this->db->select('MAX(items.supplier_id) as supplier_id');
    -        $this->db->select('MAX(items.item_number) as item_number');
    -        $this->db->select('MAX(items.description) as description');
    -        $this->db->select('MAX(items.cost_price) as cost_price');
    -        $this->db->select('MAX(items.unit_price) as unit_price');
    -        $this->db->select('MAX(items.reorder_level) as reorder_level');
    -        $this->db->select('MAX(items.receiving_quantity) as receiving_quantity');
    -        $this->db->select('items.item_id as item_id');
    -        $this->db->select('MAX(items.pic_filename) as pic_filename');
    -        $this->db->select('MAX(items.allow_alt_description) as allow_alt_description');
    -        $this->db->select('MAX(items.is_serialized) as is_serialized');
    -        $this->db->select('MAX(items.deleted) as deleted');
    -        $this->db->select('MAX(items.custom1) as custom1');
    -        $this->db->select('MAX(items.custom2) as custom2');
    -        $this->db->select('MAX(items.custom3) as custom3');
    -        $this->db->select('MAX(items.custom4) as custom4');
    -        $this->db->select('MAX(items.custom5) as custom5');
    -        $this->db->select('MAX(items.custom6) as custom6');
    -        $this->db->select('MAX(items.custom7) as custom7');
    -        $this->db->select('MAX(items.custom8) as custom8');
    -        $this->db->select('MAX(items.custom9) as custom9');
    -        $this->db->select('MAX(items.custom10) as custom10');
    -
    -        $this->db->select('MAX(suppliers.person_id) as person_id');
    -        $this->db->select('MAX(suppliers.company_name) as company_name');
    -        $this->db->select('MAX(suppliers.agency_name) as agency_name');
    -        $this->db->select('MAX(suppliers.account_number) as account_number');
    -        $this->db->select('MAX(suppliers.deleted) as deleted');
    -
    -        $this->db->select('MAX(inventory.trans_id) as trans_id');
    -        $this->db->select('MAX(inventory.trans_items) as trans_items');
    -        $this->db->select('MAX(inventory.trans_user) as trans_user');
    -        $this->db->select('MAX(inventory.trans_date) as trans_date');
    -        $this->db->select('MAX(inventory.trans_comment) as trans_comment');
    -        $this->db->select('MAX(inventory.trans_location) as trans_location');
    -        $this->db->select('MAX(inventory.trans_inventory) as trans_inventory');
    -
    -        if($filters['stock_location_id'] > -1)
    -        {
    -            $this->db->select('MAX(item_quantities.item_id) as qty_item_id');
    -            $this->db->select('MAX(item_quantities.location_id) as location_id');
    -            $this->db->select('MAX(item_quantities.quantity) as quantity');
    -        }
    -
    -        $this->db->from('items as items');
    -        $this->db->join('suppliers as suppliers', 'suppliers.person_id = items.supplier_id', 'left');
    -        $this->db->join('inventory as inventory', 'inventory.trans_items = items.item_id');
    -
    -        if($filters['stock_location_id'] > -1)
    -        {
    -            $this->db->join('item_quantities as item_quantities', 'item_quantities.item_id = items.item_id');
    -            $this->db->where('location_id', $filters['stock_location_id']);
    -        }
    -
    -        if(empty($this->config->item('date_or_time_format')))
    -        {
    -            $this->db->where('DATE_FORMAT(trans_date, "%Y-%m-%d") BETWEEN ' . $this->db->escape($filters['start_date']) . ' AND ' . $this->db->escape($filters['end_date']));
    -        }
    -        else
    -        {
    -            $this->db->where('trans_date BETWEEN ' . $this->db->escape(rawurldecode($filters['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($filters['end_date'])));
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 456: 457: 458: 459: 460: 461: 462: 463: 464: 465: 466: 467: 468: 469: 470: 471: 472: 473: 474: 475: 476: 477: 478: 479: 480: 481: 482: 483: 484: 485: 486: 487: 488: 489: 490: 491: 492: 493: 494: 495: 496: 497: 498: 499: 500: 501: 502: 503: 504: 505: 506: 507: 508: 509: 510: 511: 512: 513: 514: 515: 516: 517: 518: 519: 520: 521: 522: 523: 524: 525: 526: 527: 528: 529: 530: 531: 532: 533: 534: 535: 536: 537: 538: 539: 540: 541: 542: 543: 544: 545: 546: 547: 548: 549: 550: 551: 552: 553: 554: 555: 556: 557: 558: 559: 560: 561: 562: 563: 564: 565: 566: 567: 568: 569: 570: 571: 572: 573: 574: 575: 576: 577: 578: 579: 580: 581: 582: 583: 584: 585: 586: 587: 588: 589: 590: 591: 592: 593: 594: 595: 596: 597: 598: 599: 600: 601: 602: 603: 604: 605: 606: 607: 608: 609: 610: 611: 612: 613: 614: 615: 616: 617: 618: 619: 620: 621: 622: 623: 624: 625: 626: 627: 628: 629: 630: 631: 632: 633: 634: 635: 636: 637: 638: 639: 640: 641: 642: 643: 644: 645: 646: 647: 648: 649: 650: 651: 652: 653: 654: 655: 656: 657: 658: 659: 660: 661: 662: 663: 664: 665: 666: 667: 668: 669: 670: 671: 672: 673: 674: 675: 676: 677: 678: 679: 680: 681: 682: 683: 684: 685: 686: 687: 688: 689: 690: 691: 692: 693: 694: 695: 696: 697: 698: 699: 700: 701: 702: 703: 704: 705: 706: 707: 708: 709: 710: 711: 712: 713: 714: 715: 716: 717: 718: 719: 720: 721: 722: 723: 724: 725: 726: 727: 728: 729: 730: 731: 732: 733: 734: 735: 736: 737: 738: 739: 740: 741: 742: 743: 744: 745: 746: 747: 748: 749: 750: 751: 752: 753: 754: 755: 756: 757: 758: 759: 760: 761: 762: 763: 764: 765: 766: 767: 768: 769: 770: 771: 772: 773: 774: 775: 776: 777: 778: 779: 780: 781: 782: 783: 784: 785: 786: 787: 788: 789: 790: 791: 792: 793: 794: 795: 796: 797: 798: 799: 800: 801: 802: 803: 804: 805: 806: 807: 808: 809: 810: 811: 812: 813: 814: 815: 816: 817: 818: 819: 820: 821: 822: 823: 824: 825: 826: 827: 828: 829: 830: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
    +
    +/**
    + * Item class
    + *
    + * @link    github.com/jekkos/opensourcepos
    + * @since   1.0
    + * @author  N/A
    + */
    +
    +class Item extends CI_Model
    +{
    +    /*
    +    Determines if a given item_id is an item
    +    */
    +    public function exists($item_id, $ignore_deleted = FALSE, $deleted = FALSE)
    +    {
    +        if (ctype_digit($item_id))
    +        {
    +            $this->db->from('items');
    +            $this->db->where('item_id', (int) $item_id);
    +            if ($ignore_deleted == FALSE)
    +            {
    +                $this->db->where('deleted', $deleted);
    +            }
    +
    +            return ($this->db->get()->num_rows() == 1);
    +        }
    +
    +        return FALSE;
    +    }
    +
    +    /*
    +    Determines if a given item_number exists
    +    */
    +    public function item_number_exists($item_number, $item_id = '')
    +    {
    +        $this->db->from('items');
    +        $this->db->where('item_number', (string) $item_number);
    +        if(ctype_digit($item_id))
    +        {
    +            $this->db->where('item_id !=', (int) $item_id);
    +        }
    +
    +        return ($this->db->get()->num_rows() == 1);
    +    }
    +
    +    /*
    +    Gets total of rows
    +    */
    +    public function get_total_rows()
    +    {
    +        $this->db->from('items');
    +        $this->db->where('deleted', 0);
    +
    +        return $this->db->count_all_results();
    +    }
    +
    +    /*
    +    Get number of rows
    +    */
    +    public function get_found_rows($search, $filters)
    +    {
    +        return $this->search($search, $filters)->num_rows();
    +    }
    +
    +    /*
    +    Perform a search on items
    +    */
    +    public function search($search, $filters, $rows = 0, $limit_from = 0, $sort = 'items.name', $order = 'asc')
    +    {
    +        $this->db->select('MAX(items.name) as name');
    +        $this->db->select('MAX(items.category) as category');
    +        $this->db->select('MAX(items.supplier_id) as supplier_id');
    +        $this->db->select('MAX(items.item_number) as item_number');
    +        $this->db->select('MAX(items.description) as description');
    +        $this->db->select('MAX(items.cost_price) as cost_price');
    +        $this->db->select('MAX(items.unit_price) as unit_price');
    +        $this->db->select('MAX(items.reorder_level) as reorder_level');
    +        $this->db->select('MAX(items.receiving_quantity) as receiving_quantity');
    +        $this->db->select('items.item_id as item_id');
    +        $this->db->select('MAX(items.pic_filename) as pic_filename');
    +        $this->db->select('MAX(items.allow_alt_description) as allow_alt_description');
    +        $this->db->select('MAX(items.is_serialized) as is_serialized');
    +        $this->db->select('MAX(items.deleted) as deleted');
    +        $this->db->select('MAX(items.custom1) as custom1');
    +        $this->db->select('MAX(items.custom2) as custom2');
    +        $this->db->select('MAX(items.custom3) as custom3');
    +        $this->db->select('MAX(items.custom4) as custom4');
    +        $this->db->select('MAX(items.custom5) as custom5');
    +        $this->db->select('MAX(items.custom6) as custom6');
    +        $this->db->select('MAX(items.custom7) as custom7');
    +        $this->db->select('MAX(items.custom8) as custom8');
    +        $this->db->select('MAX(items.custom9) as custom9');
    +        $this->db->select('MAX(items.custom10) as custom10');
    +
    +        $this->db->select('MAX(suppliers.person_id) as person_id');
    +        $this->db->select('MAX(suppliers.company_name) as company_name');
    +        $this->db->select('MAX(suppliers.agency_name) as agency_name');
    +        $this->db->select('MAX(suppliers.account_number) as account_number');
    +        $this->db->select('MAX(suppliers.deleted) as deleted');
    +
    +        $this->db->select('MAX(inventory.trans_id) as trans_id');
    +        $this->db->select('MAX(inventory.trans_items) as trans_items');
    +        $this->db->select('MAX(inventory.trans_user) as trans_user');
    +        $this->db->select('MAX(inventory.trans_date) as trans_date');
    +        $this->db->select('MAX(inventory.trans_comment) as trans_comment');
    +        $this->db->select('MAX(inventory.trans_location) as trans_location');
    +        $this->db->select('MAX(inventory.trans_inventory) as trans_inventory');
    +
    +        if($filters['stock_location_id'] > -1)
    +        {
    +            $this->db->select('MAX(item_quantities.item_id) as qty_item_id');
    +            $this->db->select('MAX(item_quantities.location_id) as location_id');
    +            $this->db->select('MAX(item_quantities.quantity) as quantity');
    +        }
    +
    +        $this->db->from('items as items');
    +        $this->db->join('suppliers as suppliers', 'suppliers.person_id = items.supplier_id', 'left');
    +        $this->db->join('inventory as inventory', 'inventory.trans_items = items.item_id');
    +
    +        if($filters['stock_location_id'] > -1)
    +        {
    +            $this->db->join('item_quantities as item_quantities', 'item_quantities.item_id = items.item_id');
    +            $this->db->where('location_id', $filters['stock_location_id']);
             }
     
    -        if(!empty($search))
    +        if(empty($this->config->item('date_or_time_format')))
             {
    -            if($filters['search_custom'] == FALSE)
    -            {
    -                $this->db->group_start();
    -                    $this->db->like('name', $search);
    -                    $this->db->or_like('item_number', $search);
    -                    $this->db->or_like('items.item_id', $search);
    -                    $this->db->or_like('company_name', $search);
    -                    $this->db->or_like('category', $search);
    -                $this->db->group_end();
    -            }
    -            else
    -            {
    -                $this->db->group_start();
    -                    $this->db->like('custom1', $search);
    -                    $this->db->or_like('custom2', $search);
    -                    $this->db->or_like('custom3', $search);
    -                    $this->db->or_like('custom4', $search);
    -                    $this->db->or_like('custom5', $search);
    -                    $this->db->or_like('custom6', $search);
    -                    $this->db->or_like('custom7', $search);
    -                    $this->db->or_like('custom8', $search);
    -                    $this->db->or_like('custom9', $search);
    -                    $this->db->or_like('custom10', $search);
    -                $this->db->group_end();
    -            }
    -        }
    -
    -        $this->db->where('items.deleted', $filters['is_deleted']);
    -
    -        if($filters['empty_upc'] != FALSE)
    -        {
    -            $this->db->where('item_number', NULL);
    -        }
    -        if($filters['low_inventory'] != FALSE)
    -        {
    -            $this->db->where('quantity <=', 'reorder_level');
    -        }
    -        if($filters['is_serialized'] != FALSE)
    -        {
    -            $this->db->where('is_serialized', 1);
    -        }
    -        if($filters['no_description'] != FALSE)
    -        {
    -            $this->db->where('items.description', '');
    -        }
    -
    -        // avoid duplicated entries with same name because of inventory reporting multiple changes on the same item in the same date range
    -        $this->db->group_by('items.item_id');
    -
    -        // order by name of item
    -        $this->db->order_by($sort, $order);
    -
    -        if($rows > 0)
    -        {
    -            $this->db->limit($rows, $limit_from);
    -        }
    -
    -        return $this->db->get();
    -    }
    -
    -    /*
    -    Returns all the items
    -    */
    -    public function get_all($stock_location_id = -1, $rows = 0, $limit_from = 0)
    -    {
    -        $this->db->from('items');
    -        $this->db->join('suppliers', 'suppliers.person_id = items.supplier_id', 'left');
    -
    -        if($stock_location_id > -1)
    -        {
    -            $this->db->join('item_quantities', 'item_quantities.item_id = items.item_id');
    -            $this->db->where('location_id', $stock_location_id);
    -        }
    -
    -        $this->db->where('items.deleted', 0);
    -
    -        // order by name of item
    -        $this->db->order_by('items.name', 'asc');
    -
    -        if($rows > 0)
    -        {
    -            $this->db->limit($rows, $limit_from);
    -        }
    -
    -        return $this->db->get();
    -    }
    -
    -    /*
    -    Gets information about a particular item
    -    */
    -    public function get_info($item_id)
    -    {
    -        $this->db->select('items.*');
    -        $this->db->select('suppliers.company_name');
    -        $this->db->from('items');
    -        $this->db->join('suppliers', 'suppliers.person_id = items.supplier_id', 'left');
    -        $this->db->where('item_id', $item_id);
    -
    -        $query = $this->db->get();
    -
    -        if($query->num_rows() == 1)
    -        {
    -            return $query->row();
    -        }
    -        else
    -        {
    -            //Get empty base parent object, as $item_id is NOT an item
    -            $item_obj = new stdClass();
    +            $this->db->where('DATE_FORMAT(trans_date, "%Y-%m-%d") BETWEEN ' . $this->db->escape($filters['start_date']) . ' AND ' . $this->db->escape($filters['end_date']));
    +        }
    +        else
    +        {
    +            $this->db->where('trans_date BETWEEN ' . $this->db->escape(rawurldecode($filters['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($filters['end_date'])));
    +        }
    +
    +        if(!empty($search))
    +        {
    +            if($filters['search_custom'] == FALSE)
    +            {
    +                $this->db->group_start();
    +                    $this->db->like('name', $search);
    +                    $this->db->or_like('item_number', $search);
    +                    $this->db->or_like('items.item_id', $search);
    +                    $this->db->or_like('company_name', $search);
    +                    $this->db->or_like('category', $search);
    +                $this->db->group_end();
    +            }
    +            else
    +            {
    +                $this->db->group_start();
    +                    $this->db->like('custom1', $search);
    +                    $this->db->or_like('custom2', $search);
    +                    $this->db->or_like('custom3', $search);
    +                    $this->db->or_like('custom4', $search);
    +                    $this->db->or_like('custom5', $search);
    +                    $this->db->or_like('custom6', $search);
    +                    $this->db->or_like('custom7', $search);
    +                    $this->db->or_like('custom8', $search);
    +                    $this->db->or_like('custom9', $search);
    +                    $this->db->or_like('custom10', $search);
    +                $this->db->group_end();
    +            }
    +        }
    +
    +        $this->db->where('items.deleted', $filters['is_deleted']);
    +
    +        if($filters['empty_upc'] != FALSE)
    +        {
    +            $this->db->where('item_number', NULL);
    +        }
    +        if($filters['low_inventory'] != FALSE)
    +        {
    +            $this->db->where('quantity <=', 'reorder_level');
    +        }
    +        if($filters['is_serialized'] != FALSE)
    +        {
    +            $this->db->where('is_serialized', 1);
    +        }
    +        if($filters['no_description'] != FALSE)
    +        {
    +            $this->db->where('items.description', '');
    +        }
    +
    +        // avoid duplicated entries with same name because of inventory reporting multiple changes on the same item in the same date range
    +        $this->db->group_by('items.item_id');
    +
    +        // order by name of item
    +        $this->db->order_by($sort, $order);
    +
    +        if($rows > 0)
    +        {
    +            $this->db->limit($rows, $limit_from);
    +        }
    +
    +        return $this->db->get();
    +    }
    +
    +    /*
    +    Returns all the items
    +    */
    +    public function get_all($stock_location_id = -1, $rows = 0, $limit_from = 0)
    +    {
    +        $this->db->from('items');
    +        $this->db->join('suppliers', 'suppliers.person_id = items.supplier_id', 'left');
    +
    +        if($stock_location_id > -1)
    +        {
    +            $this->db->join('item_quantities', 'item_quantities.item_id = items.item_id');
    +            $this->db->where('location_id', $stock_location_id);
    +        }
    +
    +        $this->db->where('items.deleted', 0);
    +
    +        // order by name of item
    +        $this->db->order_by('items.name', 'asc');
    +
    +        if($rows > 0)
    +        {
    +            $this->db->limit($rows, $limit_from);
    +        }
    +
    +        return $this->db->get();
    +    }
    +
    +    /*
    +    Gets information about a particular item
    +    */
    +    public function get_info($item_id)
    +    {
    +        $this->db->select('items.*');
    +        $this->db->select('suppliers.company_name');
    +        $this->db->from('items');
    +        $this->db->join('suppliers', 'suppliers.person_id = items.supplier_id', 'left');
    +        $this->db->where('item_id', $item_id);
    +
    +        $query = $this->db->get();
     
    -            //Get all the fields from items table
    -            foreach($this->db->list_fields('items') as $field)
    -            {
    -                $item_obj->$field = '';
    -            }
    -
    -            return $item_obj;
    -        }
    -    }
    -
    -    /*
    -    Gets information about a particular item by item id or number
    -    */
    -    public function get_info_by_id_or_number($item_id)
    -    {
    -        $this->db->from('items');
    -
    -        if (ctype_digit($item_id))
    -        {
    -            $this->db->group_start();
    -                $this->db->where('item_id', (int) $item_id);
    -                $this->db->or_where('items.item_number', $item_id);
    -            $this->db->group_end();
    -        }
    -        else
    -        {
    -            $this->db->where('item_number', $item_id);
    -        }
    -
    -        $this->db->where('items.deleted', 0);
    -
    -        $query = $this->db->get();
    -
    -        if($query->num_rows() == 1)
    +        if($query->num_rows() == 1)
    +        {
    +            return $query->row();
    +        }
    +        else
    +        {
    +            //Get empty base parent object, as $item_id is NOT an item
    +            $item_obj = new stdClass();
    +
    +            //Get all the fields from items table
    +            foreach($this->db->list_fields('items') as $field)
    +            {
    +                $item_obj->$field = '';
    +            }
    +
    +            return $item_obj;
    +        }
    +    }
    +
    +    /*
    +    Gets information about a particular item by item id or number
    +    */
    +    public function get_info_by_id_or_number($item_id)
    +    {
    +        $this->db->from('items');
    +
    +        if (ctype_digit($item_id))
    +        {
    +            $this->db->group_start();
    +                $this->db->where('item_id', (int) $item_id);
    +                $this->db->or_where('items.item_number', $item_id);
    +            $this->db->group_end();
    +        }
    +        else
             {
    -            return $query->row();
    +            $this->db->where('item_number', $item_id);
             }
     
    -        return '';
    -    }
    -
    -    /*
    -    Get an item id given an item number
    -    */
    -    public function get_item_id($item_number, $ignore_deleted = FALSE, $deleted = FALSE)
    -    {
    -        $this->db->from('items');
    -        $this->db->join('suppliers', 'suppliers.person_id = items.supplier_id', 'left');
    -        $this->db->where('item_number', $item_number);
    -        if($ignore_deleted == FALSE)
    -        {
    -            $this->db->where('items.deleted', $deleted);
    -        }
    -
    -        $query = $this->db->get();
    -
    -        if($query->num_rows() == 1)
    -        {
    -            return $query->row()->item_id;
    -        }
    -
    -        return FALSE;
    -    }
    -
    -    /*
    -    Gets information about multiple items
    -    */
    -    public function get_multiple_info($item_ids, $location_id)
    -    {
    -        $this->db->from('items');
    -        $this->db->join('suppliers', 'suppliers.person_id = items.supplier_id', 'left');
    -        $this->db->join('item_quantities', 'item_quantities.item_id = items.item_id', 'left');
    -        $this->db->where('location_id', $location_id);
    -        $this->db->where_in('items.item_id', $item_ids);
    -
    -        return $this->db->get();
    -    }
    -
    -    /*
    -    Inserts or updates a item
    -    */
    -    public function save(&$item_data, $item_id = FALSE)
    -    {
    -        if(!$item_id || !$this->exists($item_id, TRUE))
    -        {
    -            if($this->db->insert('items', $item_data))
    -            {
    -                $item_data['item_id'] = $this->db->insert_id();
    -
    -                return TRUE;
    -            }
    -
    -            return FALSE;
    -        }
    -
    -        $this->db->where('item_id', $item_id);
    -
    -        return $this->db->update('items', $item_data);
    -    }
    -
    -    /*
    -    Updates multiple items at once
    -    */
    -    public function update_multiple($item_data, $item_ids)
    -    {
    -        $this->db->where_in('item_id', explode(':', $item_ids));
    -
    -        return $this->db->update('items', $item_data);
    -    }
    -
    -    /*
    -    Deletes one item
    -    */
    -    public function delete($item_id)
    -    {
    -        //Run these queries as a transaction, we want to make sure we do all or nothing
    -        $this->db->trans_start();
    -
    -        // set to 0 quantities
    -        $this->Item_quantity->reset_quantity($item_id);
    -        $this->db->where('item_id', $item_id);
    -        $success = $this->db->update('items', array('deleted'=>1));
    -
    -        $this->db->trans_complete();
    -
    -        $success &= $this->db->trans_status();
    +        $this->db->where('items.deleted', 0);
    +
    +        $query = $this->db->get();
    +
    +        if($query->num_rows() == 1)
    +        {
    +            return $query->row();
    +        }
    +
    +        return '';
    +    }
    +
    +    /*
    +    Get an item id given an item number
    +    */
    +    public function get_item_id($item_number, $ignore_deleted = FALSE, $deleted = FALSE)
    +    {
    +        $this->db->from('items');
    +        $this->db->join('suppliers', 'suppliers.person_id = items.supplier_id', 'left');
    +        $this->db->where('item_number', $item_number);
    +        if($ignore_deleted == FALSE)
    +        {
    +            $this->db->where('items.deleted', $deleted);
    +        }
    +
    +        $query = $this->db->get();
    +
    +        if($query->num_rows() == 1)
    +        {
    +            return $query->row()->item_id;
    +        }
    +
    +        return FALSE;
    +    }
    +
    +    /*
    +    Gets information about multiple items
    +    */
    +    public function get_multiple_info($item_ids, $location_id)
    +    {
    +        $this->db->from('items');
    +        $this->db->join('suppliers', 'suppliers.person_id = items.supplier_id', 'left');
    +        $this->db->join('item_quantities', 'item_quantities.item_id = items.item_id', 'left');
    +        $this->db->where('location_id', $location_id);
    +        $this->db->where_in('items.item_id', $item_ids);
    +
    +        return $this->db->get();
    +    }
    +
    +    /*
    +    Inserts or updates a item
    +    */
    +    public function save(&$item_data, $item_id = FALSE)
    +    {
    +        if(!$item_id || !$this->exists($item_id, TRUE))
    +        {
    +            if($this->db->insert('items', $item_data))
    +            {
    +                $item_data['item_id'] = $this->db->insert_id();
    +
    +                return TRUE;
    +            }
    +
    +            return FALSE;
    +        }
    +
    +        $this->db->where('item_id', $item_id);
    +
    +        return $this->db->update('items', $item_data);
    +    }
    +
    +    /*
    +    Updates multiple items at once
    +    */
    +    public function update_multiple($item_data, $item_ids)
    +    {
    +        $this->db->where_in('item_id', explode(':', $item_ids));
    +
    +        return $this->db->update('items', $item_data);
    +    }
    +
    +    /*
    +    Deletes one item
    +    */
    +    public function delete($item_id)
    +    {
    +        //Run these queries as a transaction, we want to make sure we do all or nothing
    +        $this->db->trans_start();
     
    -        return $success;
    -    }
    -
    -    /*
    -    Undeletes one item
    -    */
    -    public function undelete($item_id)
    -    {
    -        $this->db->where('item_id', $item_id);
    +        // set to 0 quantities
    +        $this->Item_quantity->reset_quantity($item_id);
    +        $this->db->where('item_id', $item_id);
    +        $success = $this->db->update('items', array('deleted'=>1));
    +        $success &= $this->Inventory->reset_quantity($item_id);
    +
    +        $this->db->trans_complete();
    +
    +        $success &= $this->db->trans_status();
     
    -        return $this->db->update('items', array('deleted'=>0));
    +        return $success;
         }
     
         /*
    -    Deletes a list of items
    +    Undeletes one item
         */
    -    public function delete_list($item_ids)
    +    public function undelete($item_id)
         {
    -        //Run these queries as a transaction, we want to make sure we do all or nothing
    -        $this->db->trans_start();
    -
    -        // set to 0 quantities
    -        $this->Item_quantity->reset_quantity_list($item_ids);
    -        $this->db->where_in('item_id', $item_ids);
    -        $success = $this->db->update('items', array('deleted'=>1));
    -
    -        $this->db->trans_complete();
    -
    -        $success &= $this->db->trans_status();
    -
    -        return $success;
    -    }
    -
    -    public function get_search_suggestions($search, $filters = array('is_deleted' => FALSE, 'search_custom' => FALSE), $unique = FALSE, $limit = 25)
    -    {
    -        $suggestions = array();
    -
    -        $this->db->select('item_id, name');
    -        $this->db->from('items');
    -        $this->db->where('deleted', $filters['is_deleted']);
    -        $this->db->where("item_type = '0'"); // standard, exclude kit items since kits will be picked up later
    -        $this->db->like('name', $search);
    -        $this->db->order_by('name', 'asc');
    -        foreach($this->db->get()->result() as $row)
    -        {
    -            $suggestions[] = array('value' => $row->item_id, 'label' => $row->name);
    -        }
    +        $this->db->where('item_id', $item_id);
    +
    +        return $this->db->update('items', array('deleted'=>0));
    +    }
    +
    +    /*
    +    Deletes a list of items
    +    */
    +    public function delete_list($item_ids)
    +    {
    +        //Run these queries as a transaction, we want to make sure we do all or nothing
    +        $this->db->trans_start();
    +
    +        // set to 0 quantities
    +        $this->Item_quantity->reset_quantity_list($item_ids);
    +        $this->db->where_in('item_id', $item_ids);
    +        $success = $this->db->update('items', array('deleted'=>1));
    +
    +        foreach($item_ids as $item_id)
    +        {
    +            $success &= $this->Inventory->reset_quantity($item_id);
    +        }
    +
    +        $this->db->trans_complete();
    +
    +        $success &= $this->db->trans_status();
    +
    +        return $success;
    +    }
     
    -        $this->db->select('item_id, item_number');
    -        $this->db->from('items');
    -        $this->db->where('deleted', $filters['is_deleted']);
    -        $this->db->where("item_type = '0'"); // standard, exclude kit items since kits will be picked up later
    -        $this->db->like('item_number', $search);
    -        $this->db->order_by('item_number', 'asc');
    -        foreach($this->db->get()->result() as $row)
    -        {
    -            $suggestions[] = array('value' => $row->item_id, 'label' => $row->item_number);
    -        }
    -
    -        if(!$unique)
    -        {
    -            //Search by category
    -            $this->db->select('category');
    -            $this->db->from('items');
    -            $this->db->where('deleted', $filters['is_deleted']);
    -            $this->db->where("item_type = '0'"); // standard, exclude kit items since kits will be picked up later
    -            $this->db->distinct();
    -            $this->db->like('category', $search);
    -            $this->db->order_by('category', 'asc');
    -            foreach($this->db->get()->result() as $row)
    -            {
    -                $suggestions[] = array('label' => $row->category);
    -            }
    +    public function get_search_suggestions($search, $filters = array('is_deleted' => FALSE, 'search_custom' => FALSE), $unique = FALSE, $limit = 25)
    +    {
    +        $suggestions = array();
    +
    +        $this->db->select('item_id, name');
    +        $this->db->from('items');
    +        $this->db->where('deleted', $filters['is_deleted']);
    +        $this->db->where("item_type = '0'"); // standard, exclude kit items since kits will be picked up later
    +        $this->db->like('name', $search);
    +        $this->db->order_by('name', 'asc');
    +        foreach($this->db->get()->result() as $row)
    +        {
    +            $suggestions[] = array('value' => $row->item_id, 'label' => $row->name);
    +        }
    +
    +        $this->db->select('item_id, item_number');
    +        $this->db->from('items');
    +        $this->db->where('deleted', $filters['is_deleted']);
    +        $this->db->where("item_type = '0'"); // standard, exclude kit items since kits will be picked up later
    +        $this->db->like('item_number', $search);
    +        $this->db->order_by('item_number', 'asc');
    +        foreach($this->db->get()->result() as $row)
    +        {
    +            $suggestions[] = array('value' => $row->item_id, 'label' => $row->item_number);
    +        }
     
    -            //Search by supplier
    -            $this->db->select('company_name');
    -            $this->db->from('suppliers');
    -            $this->db->like('company_name', $search);
    -            // restrict to non deleted companies only if is_deleted is FALSE
    +        if(!$unique)
    +        {
    +            //Search by category
    +            $this->db->select('category');
    +            $this->db->from('items');
                 $this->db->where('deleted', $filters['is_deleted']);
                 $this->db->where("item_type = '0'"); // standard, exclude kit items since kits will be picked up later
                 $this->db->distinct();
    -            $this->db->order_by('company_name', 'asc');
    -            foreach($this->db->get()->result() as $row)
    -            {
    -                $suggestions[] = array('label' => $row->company_name);
    -            }
    -
    -            //Search by description
    -            $this->db->select('item_id, name, description');
    -            $this->db->from('items');
    -            $this->db->where('deleted', $filters['is_deleted']);
    -            $this->db->where("item_type = '0'"); // standard, exclude kit items since kits will be picked up later
    -            $this->db->like('description', $search);
    -            $this->db->order_by('description', 'asc');
    -            foreach($this->db->get()->result() as $row)
    -            {
    -                $entry = array('value' => $row->item_id, 'label' => $row->name);
    -                if(!array_walk($suggestions, function($value, $label) use ($entry) { return $entry['label'] != $label; } ))
    -                {
    -                    $suggestions[] = $entry;
    -                }
    -            }
    -
    -            //Search by custom fields
    -            if($filters['search_custom'] != FALSE)
    -            {
    -                $this->db->from('items');
    -                $this->db->group_start();
    -                    $this->db->like('custom1', $search);
    -                    $this->db->or_like('custom2', $search);
    -                    $this->db->or_like('custom3', $search);
    -                    $this->db->or_like('custom4', $search);
    -                    $this->db->or_like('custom5', $search);
    -                    $this->db->or_like('custom6', $search);
    -                    $this->db->or_like('custom7', $search);
    -                    $this->db->or_like('custom8', $search);
    -                    $this->db->or_like('custom9', $search);
    -                    $this->db->or_like('custom10', $search);
    -                $this->db->group_end();
    -                $this->db->where('deleted', $filters['is_deleted']);
    -                $this->db->where("item_type = '0'"); // standard, exclude kit items since kits will be picked up later
    -                foreach($this->db->get()->result() as $row)
    -                {
    -                    $suggestions[] = array('value' => $row->item_id, 'label' => $row->name);
    -                }
    -            }
    -        }
    -
    -
    -        //only return $limit suggestions
    -        if(count($suggestions > $limit))
    -        {
    -            $suggestions = array_slice($suggestions, 0,$limit);
    -        }
    -
    -        return $suggestions;
    -    }
    -
    -
    -    public function get_stock_search_suggestions($search, $filters = array('is_deleted' => FALSE, 'search_custom' => FALSE), $unique = FALSE, $limit = 25)
    -    {
    -        $suggestions = array();
    +            $this->db->like('category', $search);
    +            $this->db->order_by('category', 'asc');
    +            foreach($this->db->get()->result() as $row)
    +            {
    +                $suggestions[] = array('label' => $row->category);
    +            }
    +
    +            //Search by supplier
    +            $this->db->select('company_name');
    +            $this->db->from('suppliers');
    +            $this->db->like('company_name', $search);
    +            // restrict to non deleted companies only if is_deleted is FALSE
    +            $this->db->where('deleted', $filters['is_deleted']);
    +            $this->db->where("item_type = '0'"); // standard, exclude kit items since kits will be picked up later
    +            $this->db->distinct();
    +            $this->db->order_by('company_name', 'asc');
    +            foreach($this->db->get()->result() as $row)
    +            {
    +                $suggestions[] = array('label' => $row->company_name);
    +            }
    +
    +            //Search by description
    +            $this->db->select('item_id, name, description');
    +            $this->db->from('items');
    +            $this->db->where('deleted', $filters['is_deleted']);
    +            $this->db->where("item_type = '0'"); // standard, exclude kit items since kits will be picked up later
    +            $this->db->like('description', $search);
    +            $this->db->order_by('description', 'asc');
    +            foreach($this->db->get()->result() as $row)
    +            {
    +                $entry = array('value' => $row->item_id, 'label' => $row->name);
    +                if(!array_walk($suggestions, function($value, $label) use ($entry) { return $entry['label'] != $label; } ))
    +                {
    +                    $suggestions[] = $entry;
    +                }
    +            }
    +
    +            //Search by custom fields
    +            if($filters['search_custom'] != FALSE)
    +            {
    +                $this->db->from('items');
    +                $this->db->group_start();
    +                    $this->db->like('custom1', $search);
    +                    $this->db->or_like('custom2', $search);
    +                    $this->db->or_like('custom3', $search);
    +                    $this->db->or_like('custom4', $search);
    +                    $this->db->or_like('custom5', $search);
    +                    $this->db->or_like('custom6', $search);
    +                    $this->db->or_like('custom7', $search);
    +                    $this->db->or_like('custom8', $search);
    +                    $this->db->or_like('custom9', $search);
    +                    $this->db->or_like('custom10', $search);
    +                $this->db->group_end();
    +                $this->db->where('deleted', $filters['is_deleted']);
    +                $this->db->where("item_type = '0'"); // standard, exclude kit items since kits will be picked up later
    +                foreach($this->db->get()->result() as $row)
    +                {
    +                    $suggestions[] = array('value' => $row->item_id, 'label' => $row->name);
    +                }
    +            }
    +        }
     
    -        $this->db->select('item_id, name');
    -        $this->db->from('items');
    -        $this->db->where('deleted', $filters['is_deleted']);
    -        $this->db->where("item_type = '0'"); // standard, exclude kit items since kits will be picked up later
    -        $this->db->where("stock_type = '0'"); // stocked items only
    -        $this->db->like('name', $search);
    -        $this->db->order_by('name', 'asc');
    -        foreach($this->db->get()->result() as $row)
    -        {
    -            $suggestions[] = array('value' => $row->item_id, 'label' => $row->name);
    -        }
    -
    -        $this->db->select('item_id, item_number');
    -        $this->db->from('items');
    -        $this->db->where('deleted', $filters['is_deleted']);
    -        $this->db->where("item_type = '0'"); // standard, exclude kit items since kits will be picked up later
    -        $this->db->where("stock_type = '0'"); // stocked items only
    -        $this->db->like('item_number', $search);
    -        $this->db->order_by('item_number', 'asc');
    -        foreach($this->db->get()->result() as $row)
    -        {
    -            $suggestions[] = array('value' => $row->item_id, 'label' => $row->item_number);
    -        }
    -
    -        if(!$unique)
    -        {
    -            //Search by category
    -            $this->db->select('category');
    -            $this->db->from('items');
    -            $this->db->where('deleted', $filters['is_deleted']);
    -            $this->db->where("item_type = '0'"); // standard, exclude kit items since kits will be picked up later
    -            $this->db->where("stock_type = '0'"); // stocked items only
    -            $this->db->distinct();
    -            $this->db->like('category', $search);
    -            $this->db->order_by('category', 'asc');
    -            foreach($this->db->get()->result() as $row)
    -            {
    -                $suggestions[] = array('label' => $row->category);
    -            }
    -
    -            //Search by supplier
    -            $this->db->select('company_name');
    -            $this->db->from('suppliers');
    -            $this->db->like('company_name', $search);
    -            // restrict to non deleted companies only if is_deleted is FALSE
    -            $this->db->where('deleted', $filters['is_deleted']);
    -            $this->db->distinct();
    -            $this->db->order_by('company_name', 'asc');
    -            foreach($this->db->get()->result() as $row)
    -            {
    -                $suggestions[] = array('label' => $row->company_name);
    -            }
    -
    -            //Search by description
    -            $this->db->select('item_id, name, description');
    -            $this->db->from('items');
    -            $this->db->where('deleted', $filters['is_deleted']);
    -            $this->db->where("item_type = '0'"); // standard, exclude kit items since kits will be picked up later
    -            $this->db->where("stock_type = '0'"); // stocked items only
    -            $this->db->like('description', $search);
    -            $this->db->order_by('description', 'asc');
    -            foreach($this->db->get()->result() as $row)
    -            {
    -                $entry = array('value' => $row->item_id, 'label' => $row->name);
    -                if(!array_walk($suggestions, function($value, $label) use ($entry) { return $entry['label'] != $label; } ))
    -                {
    -                    $suggestions[] = $entry;
    -                }
    -            }
    -
    -            //Search by custom fields
    -            if($filters['search_custom'] != FALSE)
    -            {
    -                $this->db->from('items');
    -                $this->db->group_start();
    -                $this->db->like('custom1', $search);
    -                $this->db->or_like('custom2', $search);
    -                $this->db->or_like('custom3', $search);
    -                $this->db->or_like('custom4', $search);
    -                $this->db->or_like('custom5', $search);
    -                $this->db->or_like('custom6', $search);
    -                $this->db->or_like('custom7', $search);
    -                $this->db->or_like('custom8', $search);
    -                $this->db->or_like('custom9', $search);
    -                $this->db->or_like('custom10', $search);
    -                $this->db->group_end();
    -                $this->db->where("item_type = '0'"); // standard, exclude kit items since kits will be picked up later
    -                $this->db->where("stock_type = '0'"); // stocked items only
    -                $this->db->where('deleted', $filters['is_deleted']);
    -                foreach($this->db->get()->result() as $row)
    -                {
    -                    $suggestions[] = array('value' => $row->item_id, 'label' => $row->name);
    -                }
    -            }
    -        }
    -
    -
    -        //only return $limit suggestions
    -        if(count($suggestions > $limit))
    -        {
    -            $suggestions = array_slice($suggestions, 0,$limit);
    -        }
    -
    -        return $suggestions;
    -    }
    -
    -    public function get_kit_search_suggestions($search, $filters = array('is_deleted' => FALSE, 'search_custom' => FALSE), $unique = FALSE, $limit = 25)
    -    {
    -        $suggestions = array();
    -
    -        $this->db->select('item_id, name');
    -        $this->db->from('items');
    -        $this->db->where('deleted', $filters['is_deleted']);
    -        $this->db->where("item_type = '1'"); // standard, exclude kit items since kits will be picked up later
    -        $this->db->like('name', $search);
    -        $this->db->order_by('name', 'asc');
    -        foreach($this->db->get()->result() as $row)
    -        {
    -            $suggestions[] = array('value' => $row->item_id, 'label' => $row->name);
    -        }
    +
    +        //only return $limit suggestions
    +        if(count($suggestions > $limit))
    +        {
    +            $suggestions = array_slice($suggestions, 0,$limit);
    +        }
    +
    +        return $suggestions;
    +    }
    +
    +
    +    public function get_stock_search_suggestions($search, $filters = array('is_deleted' => FALSE, 'search_custom' => FALSE), $unique = FALSE, $limit = 25)
    +    {
    +        $suggestions = array();
    +
    +        $this->db->select('item_id, name');
    +        $this->db->from('items');
    +        $this->db->where('deleted', $filters['is_deleted']);
    +        $this->db->where("item_type = '0'"); // standard, exclude kit items since kits will be picked up later
    +        $this->db->where("stock_type = '0'"); // stocked items only
    +        $this->db->like('name', $search);
    +        $this->db->order_by('name', 'asc');
    +        foreach($this->db->get()->result() as $row)
    +        {
    +            $suggestions[] = array('value' => $row->item_id, 'label' => $row->name);
    +        }
    +
    +        $this->db->select('item_id, item_number');
    +        $this->db->from('items');
    +        $this->db->where('deleted', $filters['is_deleted']);
    +        $this->db->where("item_type = '0'"); // standard, exclude kit items since kits will be picked up later
    +        $this->db->where("stock_type = '0'"); // stocked items only
    +        $this->db->like('item_number', $search);
    +        $this->db->order_by('item_number', 'asc');
    +        foreach($this->db->get()->result() as $row)
    +        {
    +            $suggestions[] = array('value' => $row->item_id, 'label' => $row->item_number);
    +        }
    +
    +        if(!$unique)
    +        {
    +            //Search by category
    +            $this->db->select('category');
    +            $this->db->from('items');
    +            $this->db->where('deleted', $filters['is_deleted']);
    +            $this->db->where("item_type = '0'"); // standard, exclude kit items since kits will be picked up later
    +            $this->db->where("stock_type = '0'"); // stocked items only
    +            $this->db->distinct();
    +            $this->db->like('category', $search);
    +            $this->db->order_by('category', 'asc');
    +            foreach($this->db->get()->result() as $row)
    +            {
    +                $suggestions[] = array('label' => $row->category);
    +            }
    +
    +            //Search by supplier
    +            $this->db->select('company_name');
    +            $this->db->from('suppliers');
    +            $this->db->like('company_name', $search);
    +            // restrict to non deleted companies only if is_deleted is FALSE
    +            $this->db->where('deleted', $filters['is_deleted']);
    +            $this->db->distinct();
    +            $this->db->order_by('company_name', 'asc');
    +            foreach($this->db->get()->result() as $row)
    +            {
    +                $suggestions[] = array('label' => $row->company_name);
    +            }
    +
    +            //Search by description
    +            $this->db->select('item_id, name, description');
    +            $this->db->from('items');
    +            $this->db->where('deleted', $filters['is_deleted']);
    +            $this->db->where("item_type = '0'"); // standard, exclude kit items since kits will be picked up later
    +            $this->db->where("stock_type = '0'"); // stocked items only
    +            $this->db->like('description', $search);
    +            $this->db->order_by('description', 'asc');
    +            foreach($this->db->get()->result() as $row)
    +            {
    +                $entry = array('value' => $row->item_id, 'label' => $row->name);
    +                if(!array_walk($suggestions, function($value, $label) use ($entry) { return $entry['label'] != $label; } ))
    +                {
    +                    $suggestions[] = $entry;
    +                }
    +            }
    +
    +            //Search by custom fields
    +            if($filters['search_custom'] != FALSE)
    +            {
    +                $this->db->from('items');
    +                $this->db->group_start();
    +                $this->db->like('custom1', $search);
    +                $this->db->or_like('custom2', $search);
    +                $this->db->or_like('custom3', $search);
    +                $this->db->or_like('custom4', $search);
    +                $this->db->or_like('custom5', $search);
    +                $this->db->or_like('custom6', $search);
    +                $this->db->or_like('custom7', $search);
    +                $this->db->or_like('custom8', $search);
    +                $this->db->or_like('custom9', $search);
    +                $this->db->or_like('custom10', $search);
    +                $this->db->group_end();
    +                $this->db->where("item_type = '0'"); // standard, exclude kit items since kits will be picked up later
    +                $this->db->where("stock_type = '0'"); // stocked items only
    +                $this->db->where('deleted', $filters['is_deleted']);
    +                foreach($this->db->get()->result() as $row)
    +                {
    +                    $suggestions[] = array('value' => $row->item_id, 'label' => $row->name);
    +                }
    +            }
    +        }
    +
    +
    +        //only return $limit suggestions
    +        if(count($suggestions > $limit))
    +        {
    +            $suggestions = array_slice($suggestions, 0,$limit);
    +        }
    +
    +        return $suggestions;
    +    }
     
    -        $this->db->select('item_id, item_number');
    -        $this->db->from('items');
    -        $this->db->where('deleted', $filters['is_deleted']);
    -        $this->db->like('item_number', $search);
    -        $this->db->order_by('item_number', 'asc');
    -        foreach($this->db->get()->result() as $row)
    -        {
    -            $suggestions[] = array('value' => $row->item_id, 'label' => $row->item_number);
    -        }
    -
    -        if(!$unique)
    +    public function get_kit_search_suggestions($search, $filters = array('is_deleted' => FALSE, 'search_custom' => FALSE), $unique = FALSE, $limit = 25)
    +    {
    +        $suggestions = array();
    +
    +        $this->db->select('item_id, name');
    +        $this->db->from('items');
    +        $this->db->where('deleted', $filters['is_deleted']);
    +        $this->db->where("item_type = '1'"); // standard, exclude kit items since kits will be picked up later
    +        $this->db->like('name', $search);
    +        $this->db->order_by('name', 'asc');
    +        foreach($this->db->get()->result() as $row)
             {
    -            //Search by category
    -            $this->db->select('category');
    -            $this->db->from('items');
    -            $this->db->where('deleted', $filters['is_deleted']);
    -            $this->db->distinct();
    -            $this->db->like('category', $search);
    -            $this->db->order_by('category', 'asc');
    -            foreach($this->db->get()->result() as $row)
    -            {
    -                $suggestions[] = array('label' => $row->category);
    -            }
    -
    -            //Search by supplier
    -            $this->db->select('company_name');
    -            $this->db->from('suppliers');
    -            $this->db->like('company_name', $search);
    -            // restrict to non deleted companies only if is_deleted is FALSE
    -            $this->db->where('deleted', $filters['is_deleted']);
    -            $this->db->distinct();
    -            $this->db->order_by('company_name', 'asc');
    -            foreach($this->db->get()->result() as $row)
    -            {
    -                $suggestions[] = array('label' => $row->company_name);
    -            }
    -
    -            //Search by description
    -            $this->db->select('item_id, name, description');
    -            $this->db->from('items');
    -            $this->db->where('deleted', $filters['is_deleted']);
    -            $this->db->like('description', $search);
    -            $this->db->order_by('description', 'asc');
    -            foreach($this->db->get()->result() as $row)
    -            {
    -                $entry = array('value' => $row->item_id, 'label' => $row->name);
    -                if(!array_walk($suggestions, function($value, $label) use ($entry) { return $entry['label'] != $label; } ))
    -                {
    -                    $suggestions[] = $entry;
    -                }
    +            $suggestions[] = array('value' => $row->item_id, 'label' => $row->name);
    +        }
    +
    +        $this->db->select('item_id, item_number');
    +        $this->db->from('items');
    +        $this->db->where('deleted', $filters['is_deleted']);
    +        $this->db->like('item_number', $search);
    +        $this->db->order_by('item_number', 'asc');
    +        foreach($this->db->get()->result() as $row)
    +        {
    +            $suggestions[] = array('value' => $row->item_id, 'label' => $row->item_number);
    +        }
    +
    +        if(!$unique)
    +        {
    +            //Search by category
    +            $this->db->select('category');
    +            $this->db->from('items');
    +            $this->db->where('deleted', $filters['is_deleted']);
    +            $this->db->distinct();
    +            $this->db->like('category', $search);
    +            $this->db->order_by('category', 'asc');
    +            foreach($this->db->get()->result() as $row)
    +            {
    +                $suggestions[] = array('label' => $row->category);
    +            }
    +
    +            //Search by supplier
    +            $this->db->select('company_name');
    +            $this->db->from('suppliers');
    +            $this->db->like('company_name', $search);
    +            // restrict to non deleted companies only if is_deleted is FALSE
    +            $this->db->where('deleted', $filters['is_deleted']);
    +            $this->db->distinct();
    +            $this->db->order_by('company_name', 'asc');
    +            foreach($this->db->get()->result() as $row)
    +            {
    +                $suggestions[] = array('label' => $row->company_name);
                 }
     
    -            //Search by custom fields
    -            if($filters['search_custom'] != FALSE)
    -            {
    -                $this->db->from('items');
    -                $this->db->group_start();
    -                $this->db->like('custom1', $search);
    -                $this->db->or_like('custom2', $search);
    -                $this->db->or_like('custom3', $search);
    -                $this->db->or_like('custom4', $search);
    -                $this->db->or_like('custom5', $search);
    -                $this->db->or_like('custom6', $search);
    -                $this->db->or_like('custom7', $search);
    -                $this->db->or_like('custom8', $search);
    -                $this->db->or_like('custom9', $search);
    -                $this->db->or_like('custom10', $search);
    -                $this->db->group_end();
    -                $this->db->where('deleted', $filters['is_deleted']);
    -                foreach($this->db->get()->result() as $row)
    -                {
    -                    $suggestions[] = array('value' => $row->item_id, 'label' => $row->name);
    -                }
    -            }
    -        }
    -
    -        //only return $limit suggestions
    -        if(count($suggestions > $limit))
    -        {
    -            $suggestions = array_slice($suggestions, 0,$limit);
    -        }
    -
    -        return $suggestions;
    -    }
    -
    -    public function get_category_suggestions($search)
    -    {
    -        $suggestions = array();
    -        $this->db->distinct();
    -        $this->db->select('category');
    -        $this->db->from('items');
    -        $this->db->like('category', $search);
    -        $this->db->where('deleted', 0);
    -        $this->db->order_by('category', 'asc');
    -        foreach($this->db->get()->result() as $row)
    -        {
    -            $suggestions[] = array('label' => $row->category);
    -        }
    -
    -        return $suggestions;
    -    }
    -
    -    public function get_location_suggestions($search)
    -    {
    -        $suggestions = array();
    -        $this->db->distinct();
    -        $this->db->select('location');
    -        $this->db->from('items');
    -        $this->db->like('location', $search);
    -        $this->db->where('deleted', 0);
    -        $this->db->order_by('location', 'asc');
    -        foreach($this->db->get()->result() as $row)
    -        {
    -            $suggestions[] = array('label' => $row->location);
    -        }
    -
    -        return $suggestions;
    -    }
    -
    -    public function get_custom_suggestions($search, $field_no)
    -    {
    -        $suggestions = array();
    -        $this->db->distinct();
    -        $this->db->select('custom'.$field_no);
    -        $this->db->from('items');
    -        $this->db->like('custom'.$field_no, $search);
    -        $this->db->where('deleted', 0);
    -        $this->db->order_by('custom'.$field_no, 'asc');
    -        foreach($this->db->get()->result() as $row)
    -        {
    -            $row_array = (array) $row;
    -            $suggestions[] = array('label' => $row_array['custom'.$field_no]);
    -        }
    +            //Search by description
    +            $this->db->select('item_id, name, description');
    +            $this->db->from('items');
    +            $this->db->where('deleted', $filters['is_deleted']);
    +            $this->db->like('description', $search);
    +            $this->db->order_by('description', 'asc');
    +            foreach($this->db->get()->result() as $row)
    +            {
    +                $entry = array('value' => $row->item_id, 'label' => $row->name);
    +                if(!array_walk($suggestions, function($value, $label) use ($entry) { return $entry['label'] != $label; } ))
    +                {
    +                    $suggestions[] = $entry;
    +                }
    +            }
    +
    +            //Search by custom fields
    +            if($filters['search_custom'] != FALSE)
    +            {
    +                $this->db->from('items');
    +                $this->db->group_start();
    +                $this->db->like('custom1', $search);
    +                $this->db->or_like('custom2', $search);
    +                $this->db->or_like('custom3', $search);
    +                $this->db->or_like('custom4', $search);
    +                $this->db->or_like('custom5', $search);
    +                $this->db->or_like('custom6', $search);
    +                $this->db->or_like('custom7', $search);
    +                $this->db->or_like('custom8', $search);
    +                $this->db->or_like('custom9', $search);
    +                $this->db->or_like('custom10', $search);
    +                $this->db->group_end();
    +                $this->db->where('deleted', $filters['is_deleted']);
    +                foreach($this->db->get()->result() as $row)
    +                {
    +                    $suggestions[] = array('value' => $row->item_id, 'label' => $row->name);
    +                }
    +            }
    +        }
    +
    +        //only return $limit suggestions
    +        if(count($suggestions > $limit))
    +        {
    +            $suggestions = array_slice($suggestions, 0,$limit);
    +        }
    +
    +        return $suggestions;
    +    }
    +
    +    public function get_category_suggestions($search)
    +    {
    +        $suggestions = array();
    +        $this->db->distinct();
    +        $this->db->select('category');
    +        $this->db->from('items');
    +        $this->db->like('category', $search);
    +        $this->db->where('deleted', 0);
    +        $this->db->order_by('category', 'asc');
    +        foreach($this->db->get()->result() as $row)
    +        {
    +            $suggestions[] = array('label' => $row->category);
    +        }
    +
    +        return $suggestions;
    +    }
    +
    +    public function get_location_suggestions($search)
    +    {
    +        $suggestions = array();
    +        $this->db->distinct();
    +        $this->db->select('location');
    +        $this->db->from('items');
    +        $this->db->like('location', $search);
    +        $this->db->where('deleted', 0);
    +        $this->db->order_by('location', 'asc');
    +        foreach($this->db->get()->result() as $row)
    +        {
    +            $suggestions[] = array('label' => $row->location);
    +        }
    +
    +        return $suggestions;
    +    }
     
    -        return $suggestions;
    -    }
    -
    -    public function get_categories()
    -    {
    -        $this->db->select('category');
    -        $this->db->from('items');
    +    public function get_custom_suggestions($search, $field_no)
    +    {
    +        $suggestions = array();
    +        $this->db->distinct();
    +        $this->db->select('custom'.$field_no);
    +        $this->db->from('items');
    +        $this->db->like('custom'.$field_no, $search);
             $this->db->where('deleted', 0);
    -        $this->db->distinct();
    -        $this->db->order_by('category', 'asc');
    -
    -        return $this->db->get();
    -    }
    -
    -    /*
    -     * changes the cost price of a given item
    -     * calculates the average price between received items and items on stock
    -     * $item_id : the item which price should be changed
    -     * $items_received : the amount of new items received
    -     * $new_price : the cost-price for the newly received items
    -     * $old_price (optional) : the current-cost-price
    -     *
    -     * used in receiving-process to update cost-price if changed
    -     * caution: must be used before item_quantities gets updated, otherwise the average price is wrong!
    -     *
    -     */
    -    public function change_cost_price($item_id, $items_received, $new_price, $old_price = null)
    -    {
    -        if($old_price === null)
    -        {
    -            $item_info = $this->get_info($item_id);
    -            $old_price = $item_info->cost_price;
    -        }
    -
    -        $this->db->from('item_quantities');
    -        $this->db->select_sum('quantity');
    -        $this->db->where('item_id', $item_id);
    -        $this->db->join('stock_locations', 'stock_locations.location_id=item_quantities.location_id');
    -        $this->db->where('stock_locations.deleted', 0);
    -        $old_total_quantity = $this->db->get()->row()->quantity;
    -
    -        $total_quantity = $old_total_quantity + $items_received;
    -        $average_price = bcdiv(bcadd(bcmul($items_received, $new_price), bcmul($old_total_quantity, $old_price)), $total_quantity);
    -
    -        $data = array('cost_price' => $average_price);
    -
    -        return $this->save($data, $item_id);
    -    }
    -}
    -?>
    -
    +
    $this->db->order_by('custom'.$field_no, 'asc'); + foreach($this->db->get()->result() as $row) + { + $row_array = (array) $row; + $suggestions[] = array('label' => $row_array['custom'.$field_no]); + } + + return $suggestions; + } + + public function get_categories() + { + $this->db->select('category'); + $this->db->from('items'); + $this->db->where('deleted', 0); + $this->db->distinct(); + $this->db->order_by('category', 'asc'); + + return $this->db->get(); + } + + /* + * changes the cost price of a given item + * calculates the average price between received items and items on stock + * $item_id : the item which price should be changed + * $items_received : the amount of new items received + * $new_price : the cost-price for the newly received items + * $old_price (optional) : the current-cost-price + * + * used in receiving-process to update cost-price if changed + * caution: must be used before item_quantities gets updated, otherwise the average price is wrong! + * + */ + public function change_cost_price($item_id, $items_received, $new_price, $old_price = null) + { + if($old_price === null) + { + $item_info = $this->get_info($item_id); + $old_price = $item_info->cost_price; + } + + $this->db->from('item_quantities'); + $this->db->select_sum('quantity'); + $this->db->where('item_id', $item_id); + $this->db->join('stock_locations', 'stock_locations.location_id=item_quantities.location_id'); + $this->db->where('stock_locations.deleted', 0); + $old_total_quantity = $this->db->get()->row()->quantity; + + $total_quantity = $old_total_quantity + $items_received; + $average_price = bcdiv(bcadd(bcmul($items_received, $new_price), bcmul($old_total_quantity, $old_price)), $total_quantity); + + $data = array('cost_price' => $average_price); + + return $this->save($data, $item_id); + } +} +?> +
    - + diff --git a/docs/source-class-Item_kit.html b/docs/source-class-Item_kit.html index 86efb6942..f4d1cbb10 100644 --- a/docs/source-class-Item_kit.html +++ b/docs/source-class-Item_kit.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,245 +207,254 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 
    -
    <?php
    -class Item_kit extends CI_Model
    -{
    -    /*
    -    Determines if a given item_id is an item kit
    -    */
    -    public function exists($item_kit_id)
    -    {
    -        $this->db->from('item_kits');
    -        $this->db->where('item_kit_id', $item_kit_id);
    -
    -        return ($this->db->get()->num_rows() == 1);
    -    }
    -
    -    /*
    -    Check if a given item_id is an item kit
    -    */
    -    public function is_valid_item_kit($item_kit_id)
    -    {
    -        if(!empty($item_kit_id))
    -        {
    -            //KIT #
    -            $pieces = explode(' ', $item_kit_id);
    -
    -            if(count($pieces) == 2 && preg_match('/(KIT)/i', $pieces[0]))
    -            {
    -                return $this->exists($pieces[1]);
    -            }
    -        }
    -
    -        return FALSE;
    -    }
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
    +
    +/**
    + * Item_kit class
    + *
    + * @link    github.com/jekkos/opensourcepos
    + * @since   1.0
    + * @author  N/A
    + */
    +
    +class Item_kit extends CI_Model
    +{
    +    /*
    +    Determines if a given item_id is an item kit
    +    */
    +    public function exists($item_kit_id)
    +    {
    +        $this->db->from('item_kits');
    +        $this->db->where('item_kit_id', $item_kit_id);
    +
    +        return ($this->db->get()->num_rows() == 1);
    +    }
    +
    +    /*
    +    Check if a given item_id is an item kit
    +    */
    +    public function is_valid_item_kit($item_kit_id)
    +    {
    +        if(!empty($item_kit_id))
    +        {
    +            //KIT #
    +            $pieces = explode(' ', $item_kit_id);
     
    -    /*
    -    Gets total of rows
    -    */
    -    public function get_total_rows()
    -    {
    -        $this->db->from('item_kits');
    -
    -        return $this->db->count_all_results();
    -    }
    -    
    -    /*
    -    Gets information about a particular item kit
    -    */
    -    public function get_info($item_kit_id)
    -    {
    -        $this->db->select('
    -        item_kit_id, 
    -        item_kits.name as name, 
    -        items.name as item_name, 
    -        item_kits.description, 
    -        items.description as item_description, 
    -        item_kits.item_id as kit_item_id, 
    -        kit_discount_percent, 
    -        price_option, 
    -        print_option, 
    -        category, 
    -        supplier_id, 
    -        item_number, 
    -        cost_price, 
    -        unit_price, 
    -        reorder_level, 
    -        receiving_quantity, 
    -        pic_filename, 
    -        allow_alt_description, 
    -        is_serialized, 
    -        deleted, 
    -        custom1, 
    -        custom2, 
    -        custom3, 
    -        custom4, 
    -        custom5, 
    -        custom6, 
    -        custom7, 
    -        custom8, 
    -        custom9, 
    -        custom10,
    -        item_type,
    -        stock_type');
    -
    -        $this->db->from('item_kits');
    -        $this->db->join('items', 'item_kits.item_id = items.item_id', 'left');
    -        $this->db->where('item_kit_id', $item_kit_id);
    -        
    -        $query = $this->db->get();
    -
    -        if($query->num_rows()==1)
    -        {
    -            return $query->row();
    -        }
    -        else
    -        {
    -            //Get empty base parent object, as $item_kit_id is NOT an item kit
    -            $item_obj = new stdClass();
    +            if(count($pieces) == 2 && preg_match('/(KIT)/i', $pieces[0]))
    +            {
    +                return $this->exists($pieces[1]);
    +            }
    +        }
    +
    +        return FALSE;
    +    }
    +
    +    /*
    +    Gets total of rows
    +    */
    +    public function get_total_rows()
    +    {
    +        $this->db->from('item_kits');
    +
    +        return $this->db->count_all_results();
    +    }
    +
    +    /*
    +    Gets information about a particular item kit
    +    */
    +    public function get_info($item_kit_id)
    +    {
    +        $this->db->select('
    +        item_kit_id,
    +        item_kits.name as name,
    +        items.name as item_name,
    +        item_kits.description,
    +        items.description as item_description,
    +        item_kits.item_id as kit_item_id,
    +        kit_discount_percent,
    +        price_option,
    +        print_option,
    +        category,
    +        supplier_id,
    +        item_number,
    +        cost_price,
    +        unit_price,
    +        reorder_level,
    +        receiving_quantity,
    +        pic_filename,
    +        allow_alt_description,
    +        is_serialized,
    +        deleted,
    +        custom1,
    +        custom2,
    +        custom3,
    +        custom4,
    +        custom5,
    +        custom6,
    +        custom7,
    +        custom8,
    +        custom9,
    +        custom10,
    +        item_type,
    +        stock_type');
    +
    +        $this->db->from('item_kits');
    +        $this->db->join('items', 'item_kits.item_id = items.item_id', 'left');
    +        $this->db->where('item_kit_id', $item_kit_id);
    +
    +        $query = $this->db->get();
     
    -            //Get all the fields from items table
    -            foreach($this->db->list_fields('item_kits') as $field)
    -            {
    -                $item_obj->$field = '';
    -            }
    -
    -            return $item_obj;
    -        }
    -    }
    -
    -    /*
    -    Gets information about multiple item kits
    -    */
    -    public function get_multiple_info($item_kit_ids)
    -    {
    -        $this->db->from('item_kits');
    -        $this->db->where_in('item_kit_id', $item_kit_ids);
    -        $this->db->order_by('name', 'asc');
    +        if($query->num_rows()==1)
    +        {
    +            return $query->row();
    +        }
    +        else
    +        {
    +            //Get empty base parent object, as $item_kit_id is NOT an item kit
    +            $item_obj = new stdClass();
    +
    +            //Get all the fields from items table
    +            foreach($this->db->list_fields('item_kits') as $field)
    +            {
    +                $item_obj->$field = '';
    +            }
    +
    +            return $item_obj;
    +        }
    +    }
     
    -        return $this->db->get();
    -    }
    -
    -    /*
    -    Inserts or updates an item kit
    -    */
    -    public function save(&$item_kit_data, $item_kit_id = FALSE)
    -    {
    -        if(!$item_kit_id || !$this->exists($item_kit_id))
    -        {
    -            if($this->db->insert('item_kits', $item_kit_data))
    -            {
    -                $item_kit_data['item_kit_id'] = $this->db->insert_id();
    -
    -                return TRUE;
    -            }
    -
    -            return FALSE;
    -        }
    -
    -        $this->db->where('item_kit_id', $item_kit_id);
    -
    -        return $this->db->update('item_kits', $item_kit_data);
    -    }
    -
    -    /*
    -    Deletes one item kit
    -    */
    -    public function delete($item_kit_id)
    -    {
    -        return $this->db->delete('item_kits', array('item_kit_id' => $id));     
    -    }
    -
    -    /*
    -    Deletes a list of item kits
    -    */
    -    public function delete_list($item_kit_ids)
    -    {
    -        $this->db->where_in('item_kit_id', $item_kit_ids);
    -
    -        return $this->db->delete('item_kits');      
    -    }
    -
    -    public function get_search_suggestions($search, $limit = 25)
    -    {
    -        $suggestions = array();
    -
    -        $this->db->from('item_kits');
    +    /*
    +    Gets information about multiple item kits
    +    */
    +    public function get_multiple_info($item_kit_ids)
    +    {
    +        $this->db->from('item_kits');
    +        $this->db->where_in('item_kit_id', $item_kit_ids);
    +        $this->db->order_by('name', 'asc');
    +
    +        return $this->db->get();
    +    }
    +
    +    /*
    +    Inserts or updates an item kit
    +    */
    +    public function save(&$item_kit_data, $item_kit_id = FALSE)
    +    {
    +        if(!$item_kit_id || !$this->exists($item_kit_id))
    +        {
    +            if($this->db->insert('item_kits', $item_kit_data))
    +            {
    +                $item_kit_data['item_kit_id'] = $this->db->insert_id();
    +
    +                return TRUE;
    +            }
    +
    +            return FALSE;
    +        }
    +
    +        $this->db->where('item_kit_id', $item_kit_id);
    +
    +        return $this->db->update('item_kits', $item_kit_data);
    +    }
    +
    +    /*
    +    Deletes one item kit
    +    */
    +    public function delete($item_kit_id)
    +    {
    +        return $this->db->delete('item_kits', array('item_kit_id' => $id));
    +    }
    +
    +    /*
    +    Deletes a list of item kits
    +    */
    +    public function delete_list($item_kit_ids)
    +    {
    +        $this->db->where_in('item_kit_id', $item_kit_ids);
     
    -        //KIT #
    -        if(stripos($search, 'KIT ') !== FALSE)
    -        {
    -            $this->db->like('item_kit_id', str_ireplace('KIT ', '', $search));
    -            $this->db->order_by('item_kit_id', 'asc');
    -
    -            foreach($this->db->get()->result() as $row)
    -            {
    -                $suggestions[] = array('value' => 'KIT '. $row->item_kit_id, 'label' => 'KIT ' . $row->item_kit_id);
    -            }
    -        }
    -        else
    -        {
    -            $this->db->like('name', $search);
    -            $this->db->order_by('name', 'asc');
    -
    -            foreach($this->db->get()->result() as $row)
    -            {
    -                $suggestions[] = array('value' => 'KIT ' . $row->item_kit_id, 'label' => $row->name);
    -            }
    -        }
    -
    -        //only return $limit suggestions
    -        if(count($suggestions > $limit))
    -        {
    -            $suggestions = array_slice($suggestions, 0, $limit);
    -        }
    -
    -        return $suggestions;
    -    }
    +        return $this->db->delete('item_kits');
    +    }
    +
    +    public function get_search_suggestions($search, $limit = 25)
    +    {
    +        $suggestions = array();
    +
    +        $this->db->from('item_kits');
    +
    +        //KIT #
    +        if(stripos($search, 'KIT ') !== FALSE)
    +        {
    +            $this->db->like('item_kit_id', str_ireplace('KIT ', '', $search));
    +            $this->db->order_by('item_kit_id', 'asc');
    +
    +            foreach($this->db->get()->result() as $row)
    +            {
    +                $suggestions[] = array('value' => 'KIT '. $row->item_kit_id, 'label' => 'KIT ' . $row->item_kit_id);
    +            }
    +        }
    +        else
    +        {
    +            $this->db->like('name', $search);
    +            $this->db->order_by('name', 'asc');
    +
    +            foreach($this->db->get()->result() as $row)
    +            {
    +                $suggestions[] = array('value' => 'KIT ' . $row->item_kit_id, 'label' => $row->name);
    +            }
    +        }
     
    -    /*
    -    Perform a search on items
    -    */
    -    public function search($search, $rows=0, $limit_from=0, $sort='name', $order='asc')
    -    {
    -        $this->db->from('item_kits');
    -        $this->db->like('name', $search);
    -        $this->db->or_like('description', $search);
    +        //only return $limit suggestions
    +        if(count($suggestions > $limit))
    +        {
    +            $suggestions = array_slice($suggestions, 0, $limit);
    +        }
    +
    +        return $suggestions;
    +    }
     
    -        //KIT #
    -        if(stripos($search, 'KIT ') !== FALSE)
    -        {
    -            $this->db->or_like('item_kit_id', str_ireplace('KIT ', '', $search));
    -        }
    -
    -        $this->db->order_by($sort, $order);
    -
    -        if($rows > 0)
    -        {
    -            $this->db->limit($rows, $limit_from);
    -        }
    -
    -        return $this->db->get();    
    -    }
    -    
    -    public function get_found_rows($search)
    -    {
    -        $this->db->from('item_kits');
    -        $this->db->like('name', $search);
    -        $this->db->or_like('description', $search);
    +    /*
    +    Perform a search on items
    +    */
    +    public function search($search, $rows=0, $limit_from=0, $sort='name', $order='asc')
    +    {
    +        $this->db->from('item_kits');
    +        $this->db->like('name', $search);
    +        $this->db->or_like('description', $search);
    +
    +        //KIT #
    +        if(stripos($search, 'KIT ') !== FALSE)
    +        {
    +            $this->db->or_like('item_kit_id', str_ireplace('KIT ', '', $search));
    +        }
    +
    +        $this->db->order_by($sort, $order);
    +
    +        if($rows > 0)
    +        {
    +            $this->db->limit($rows, $limit_from);
    +        }
     
    -        //KIT #
    -        if(stripos($search, 'KIT ') !== FALSE)
    -        {
    -            $this->db->or_like('item_kit_id', str_ireplace('KIT ', '', $search));
    -        }
    -
    -        return $this->db->get()->num_rows();
    -    }
    -}
    -?>
    -
    +
    return $this->db->get(); + } + + public function get_found_rows($search) + { + $this->db->from('item_kits'); + $this->db->like('name', $search); + $this->db->or_like('description', $search); + + //KIT # + if(stripos($search, 'KIT ') !== FALSE) + { + $this->db->or_like('item_kit_id', str_ireplace('KIT ', '', $search)); + } + + return $this->db->get()->num_rows(); + } +} +?> +
    - + diff --git a/docs/source-class-Item_kit_items.html b/docs/source-class-Item_kit_items.html index a12cfb822..967d46464 100644 --- a/docs/source-class-Item_kit_items.html +++ b/docs/source-class-Item_kit_items.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,75 +207,84 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 
    -
    <?php
    -class Item_kit_items extends CI_Model
    -{
    -    /*
    -    Gets item kit items for a particular item kit
    -    */
    -    public function get_info($item_kit_id)
    -    {
    -        $this->db->select('item_kit_id, item_kit_items.item_id, quantity, kit_sequence, unit_price, item_type, stock_type');
    -        $this->db->from('item_kit_items as item_kit_items');
    -        $this->db->join('items as items', 'item_kit_items.item_id = items.item_id');
    -        $this->db->where('item_kit_id', $item_kit_id);
    -        $this->db->order_by('kit_sequence', 'asc');
    -
    -        //return an array of item kit items for an item
    -        return $this->db->get()->result_array();
    -    }
    -
    -    /*
    -    Gets item kit items for a particular item kit
    -    */
    -    public function get_info_for_sale($item_kit_id)
    -    {
    -        $this->db->from('item_kit_items');
    -        $this->db->where('item_kit_id', $item_kit_id);
    -
    -        $this->db->order_by('kit_sequence', 'desc');
    -
    -        //return an array of item kit items for an item
    -        return $this->db->get()->result_array();
    -    }
    -    /*
    -    Inserts or updates an item kit's items
    -    */
    -    public function save(&$item_kit_items_data, $item_kit_id)
    -    {
    -        $success = TRUE;
    -
    -        //Run these queries as a transaction, we want to make sure we do all or nothing
    -
    -        $this->db->trans_start();
    -
    -        $this->delete($item_kit_id);
    -
    -        if ($item_kit_items_data != NULL) {
    -            foreach ($item_kit_items_data as $row) {
    -                $row['item_kit_id'] = $item_kit_id;
    -                $success &= $this->db->insert('item_kit_items', $row);
    -            }
    -        }
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
    +
    +/**
    + * Item_kit_items class
    + *
    + * @link    github.com/jekkos/opensourcepos
    + * @since   1.0
    + * @author  N/A
    + */
    +
    +class Item_kit_items extends CI_Model
    +{
    +    /*
    +    Gets item kit items for a particular item kit
    +    */
    +    public function get_info($item_kit_id)
    +    {
    +        $this->db->select('item_kit_id, item_kit_items.item_id, quantity, kit_sequence, unit_price, item_type, stock_type');
    +        $this->db->from('item_kit_items as item_kit_items');
    +        $this->db->join('items as items', 'item_kit_items.item_id = items.item_id');
    +        $this->db->where('item_kit_id', $item_kit_id);
    +        $this->db->order_by('kit_sequence', 'asc');
    +
    +        //return an array of item kit items for an item
    +        return $this->db->get()->result_array();
    +    }
    +
    +    /*
    +    Gets item kit items for a particular item kit
    +    */
    +    public function get_info_for_sale($item_kit_id)
    +    {
    +        $this->db->from('item_kit_items');
    +        $this->db->where('item_kit_id', $item_kit_id);
    +
    +        $this->db->order_by('kit_sequence', 'desc');
    +
    +        //return an array of item kit items for an item
    +        return $this->db->get()->result_array();
    +    }
    +    /*
    +    Inserts or updates an item kit's items
    +    */
    +    public function save(&$item_kit_items_data, $item_kit_id)
    +    {
    +        $success = TRUE;
    +
    +        //Run these queries as a transaction, we want to make sure we do all or nothing
    +
    +        $this->db->trans_start();
     
    -        $this->db->trans_complete();
    +        $this->delete($item_kit_id);
     
    -        $success &= $this->db->trans_status();
    -
    -        return $success;
    -    }
    -    
    -    /*
    -    Deletes item kit items given an item kit
    -    */
    -    public function delete($item_kit_id)
    -    {
    -        return $this->db->delete('item_kit_items', array('item_kit_id' => $item_kit_id)); 
    -    }
    -}
    -?>
    -
    +
    if ($item_kit_items_data != NULL) { + foreach ($item_kit_items_data as $row) { + $row['item_kit_id'] = $item_kit_id; + $success &= $this->db->insert('item_kit_items', $row); + } + } + + $this->db->trans_complete(); + + $success &= $this->db->trans_status(); + + return $success; + } + + /* + Deletes item kit items given an item kit + */ + public function delete($item_kit_id) + { + return $this->db->delete('item_kit_items', array('item_kit_id' => $item_kit_id)); + } +} +?> +
    - + diff --git a/docs/source-class-Item_kits.html b/docs/source-class-Item_kits.html index 74d816f4b..7f41713bd 100644 --- a/docs/source-class-Item_kits.html +++ b/docs/source-class-Item_kits.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -443,6 +445,6 @@ - + diff --git a/docs/source-class-Item_lib.html b/docs/source-class-Item_lib.html index 763787430..e531a3ca3 100644 --- a/docs/source-class-Item_lib.html +++ b/docs/source-class-Item_lib.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,42 +207,52 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
    -class Item_lib
    -{
    -    private $CI;
    -
    -    public function __construct()
    -    {
    -        $this->CI =& get_instance();
    -    }
    -
    -    public function get_item_location()
    -    {
    -        if(!$this->CI->session->userdata('item_location'))
    -        {
    -            $location_id = $this->CI->Stock_location->get_default_location_id();
    -            $this->set_item_location($location_id);
    -        }
    -
    -        return $this->CI->session->userdata('item_location');
    -    }
    -
    -    public function set_item_location($location)
    -    {
    -        $this->CI->session->set_userdata('item_location',$location);
    -    }
    -
    -    public function clear_item_location()
    -    {
    -        $this->CI->session->unset_userdata('item_location');
    -    }   
    -}
    -
    -?>
    -
    +/** + * Item library + * + * Library with utilities to manage items + * + * @link github.com/jekkos/opensourcepos + * @since 2.x + * @author Jekkos + */ + +class Item_lib +{ + private $CI; + + public function __construct() + { + $this->CI =& get_instance(); + } + + public function get_item_location() + { + if(!$this->CI->session->userdata('item_location')) + { + $location_id = $this->CI->Stock_location->get_default_location_id(); + $this->set_item_location($location_id); + } + + return $this->CI->session->userdata('item_location'); + } + + public function set_item_location($location) + { + $this->CI->session->set_userdata('item_location',$location); + } + + public function clear_item_location() + { + $this->CI->session->unset_userdata('item_location'); + } +} + +?> + - + diff --git a/docs/source-class-Item_quantity.html b/docs/source-class-Item_quantity.html index a5131af93..63f5e3dc1 100644 --- a/docs/source-class-Item_quantity.html +++ b/docs/source-class-Item_quantity.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,90 +207,100 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 
    -
    <?php
    -class Item_quantity extends CI_Model
    -{
    -    public function exists($item_id, $location_id)
    -    {
    -        $this->db->from('item_quantities');
    -        $this->db->where('item_id', $item_id);
    -        $this->db->where('location_id', $location_id);
    -
    -        return ($this->db->get()->num_rows() == 1);
    -    }
    -    
    -    public function save($location_detail, $item_id, $location_id)
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
    +
    +/**
    + * Item_quantity class
    + *
    + * @link    github.com/jekkos/opensourcepos
    + * @since   2.x
    + * @author  Padungsak
    + */
    +
    +class Item_quantity extends CI_Model
    +{
    +    public function exists($item_id, $location_id)
         {
    -        if(!$this->exists($item_id, $location_id))
    -        {
    -            return $this->db->insert('item_quantities', $location_detail);
    -        }
    -
    -        $this->db->where('item_id', $item_id);
    -        $this->db->where('location_id', $location_id);
    -
    -        return $this->db->update('item_quantities', $location_detail);
    -    }
    -    
    -    public function get_item_quantity($item_id, $location_id)
    -    {     
    -        $this->db->from('item_quantities');
    +        $this->db->from('item_quantities');
    +        $this->db->where('item_id', $item_id);
    +        $this->db->where('location_id', $location_id);
    +
    +        return ($this->db->get()->num_rows() == 1);
    +    }
    +
    +    public function save($location_detail, $item_id, $location_id)
    +    {
    +        if(!$this->exists($item_id, $location_id))
    +        {
    +            return $this->db->insert('item_quantities', $location_detail);
    +        }
    +
             $this->db->where('item_id', $item_id);
             $this->db->where('location_id', $location_id);
    -        $result = $this->db->get()->row();
    -        if(empty($result) == TRUE)
    -        {
    -            //Get empty base parent object, as $item_id is NOT an item
    -            $result = new stdClass();
    -
    -            //Get all the fields from items table (TODO to be reviewed)
    -            foreach($this->db->list_fields('item_quantities') as $field)
    -            {
    -                $result->$field = '';
    -            }
    -
    -            $result->quantity = 0;
    -        }
    -        
    -        return $result;   
    -    }
    -    
    -    /*
    -     * changes to quantity of an item according to the given amount.
    -     * if $quantity_change is negative, it will be subtracted,
    -     * if it is positive, it will be added to the current quantity
    -     */
    -    public function change_quantity($item_id, $location_id, $quantity_change)
    -    {
    -        $quantity_old = $this->get_item_quantity($item_id, $location_id);
    -        $quantity_new = $quantity_old->quantity + intval($quantity_change);
    -        $location_detail = array('item_id' => $item_id, 'location_id' => $location_id, 'quantity' => $quantity_new);
    -
    -        return $this->save($location_detail, $item_id, $location_id);
    -    }
    -    
    -    /*
    -    * Set to 0 all quantity in the given item
    -    */
    -    public function reset_quantity($item_id)
    -    {
    -        $this->db->where('item_id', $item_id);
    -
    -        return $this->db->update('item_quantities', array('quantity' => 0));
    -    }
    -    
    -    /*
    -    * Set to 0 all quantity in the given list of items
    -    */
    -    public function reset_quantity_list($item_ids)
    -    {
    -        $this->db->where_in('item_id', $item_ids);
    -
    -        return $this->db->update('item_quantities', array('quantity' => 0));
    -    }
    -}
    -?>
    +
    + return $this->db->update('item_quantities', $location_detail); + } + + public function get_item_quantity($item_id, $location_id) + { + $this->db->from('item_quantities'); + $this->db->where('item_id', $item_id); + $this->db->where('location_id', $location_id); + $result = $this->db->get()->row(); + if(empty($result) == TRUE) + { + //Get empty base parent object, as $item_id is NOT an item + $result = new stdClass(); + + //Get all the fields from items table (TODO to be reviewed) + foreach($this->db->list_fields('item_quantities') as $field) + { + $result->$field = ''; + } + + $result->quantity = 0; + } + + return $result; + } + + /* + * changes to quantity of an item according to the given amount. + * if $quantity_change is negative, it will be subtracted, + * if it is positive, it will be added to the current quantity + */ + public function change_quantity($item_id, $location_id, $quantity_change) + { + $quantity_old = $this->get_item_quantity($item_id, $location_id); + $quantity_new = $quantity_old->quantity + intval($quantity_change); + $location_detail = array('item_id' => $item_id, 'location_id' => $location_id, 'quantity' => $quantity_new); + + return $this->save($location_detail, $item_id, $location_id); + } + + /* + * Set to 0 all quantity in the given item + */ + public function reset_quantity($item_id) + { + $this->db->where('item_id', $item_id); + + return $this->db->update('item_quantities', array('quantity' => 0)); + } + + /* + * Set to 0 all quantity in the given list of items + */ + public function reset_quantity_list($item_ids) + { + $this->db->where_in('item_id', $item_ids); + + return $this->db->update('item_quantities', array('quantity' => 0)); + } +} +?> +
    - + diff --git a/docs/source-class-Item_taxes.html b/docs/source-class-Item_taxes.html index 9864678f8..4328e7f02 100644 --- a/docs/source-class-Item_taxes.html +++ b/docs/source-class-Item_taxes.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,85 +207,94 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 
    -
    <?php
    -class Item_taxes extends CI_Model
    -{
    -    /*
    -    Gets tax info for a particular item
    -    */
    -    public function get_info($item_id)
    -    {
    -        $this->db->from('items_taxes');
    -        $this->db->where('item_id',$item_id);
    -
    -        //return an array of taxes for an item
    -        return $this->db->get()->result_array();
    -    }
    -    
    -    /*
    -    Inserts or updates an item's taxes
    -    */
    -    public function save(&$items_taxes_data, $item_id)
    -    {
    -        $success = TRUE;
    -        
    -        //Run these queries as a transaction, we want to make sure we do all or nothing
    -        $this->db->trans_start();
    -
    -        $this->delete($item_id);
    -
    -        foreach($items_taxes_data as $row)
    -        {
    -            $row['item_id'] = $item_id;
    -            $success &= $this->db->insert('items_taxes', $row);     
    -        }
    -        
    -        $this->db->trans_complete();
    -
    -        $success &= $this->db->trans_status();
    -
    -        return $success;
    -    }
    -
    -    /*
    -    Saves taxes for multiple items
    -    */
    -    public function save_multiple(&$items_taxes_data, $item_ids)
    -    {
    -        $success = TRUE;
    -        
    -        //Run these queries as a transaction, we want to make sure we do all or nothing
    -        $this->db->trans_start();
    -        
    -        foreach(explode(':', $item_ids) as $item_id)
    -        {
    -            $this->delete($item_id);
    -
    -            foreach($items_taxes_data as $row)
    -            {
    -                $row['item_id'] = $item_id;
    -                $success &= $this->db->insert('items_taxes', $row);     
    -            }
    -        }
    -
    -        $this->db->trans_complete();
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
    +
    +/**
    + * Item_taxes class
    + *
    + * @link    github.com/jekkos/opensourcepos
    + * @since   1.0
    + * @author  N/A
    + */
    +
    +class Item_taxes extends CI_Model
    +{
    +    /*
    +    Gets tax info for a particular item
    +    */
    +    public function get_info($item_id)
    +    {
    +        $this->db->from('items_taxes');
    +        $this->db->where('item_id',$item_id);
    +
    +        //return an array of taxes for an item
    +        return $this->db->get()->result_array();
    +    }
    +
    +    /*
    +    Inserts or updates an item's taxes
    +    */
    +    public function save(&$items_taxes_data, $item_id)
    +    {
    +        $success = TRUE;
    +
    +        //Run these queries as a transaction, we want to make sure we do all or nothing
    +        $this->db->trans_start();
    +
    +        $this->delete($item_id);
    +
    +        foreach($items_taxes_data as $row)
    +        {
    +            $row['item_id'] = $item_id;
    +            $success &= $this->db->insert('items_taxes', $row);
    +        }
    +
    +        $this->db->trans_complete();
    +
    +        $success &= $this->db->trans_status();
    +
    +        return $success;
    +    }
    +
    +    /*
    +    Saves taxes for multiple items
    +    */
    +    public function save_multiple(&$items_taxes_data, $item_ids)
    +    {
    +        $success = TRUE;
    +
    +        //Run these queries as a transaction, we want to make sure we do all or nothing
    +        $this->db->trans_start();
    +
    +        foreach(explode(':', $item_ids) as $item_id)
    +        {
    +            $this->delete($item_id);
     
    -        $success &= $this->db->trans_status();
    -
    -        return $success;
    -    }
    -
    -    /*
    -    Deletes taxes given an item
    -    */
    -    public function delete($item_id)
    -    {
    -        return $this->db->delete('items_taxes', array('item_id' => $item_id)); 
    -    }
    -}
    -?>
    -
    +
    foreach($items_taxes_data as $row) + { + $row['item_id'] = $item_id; + $success &= $this->db->insert('items_taxes', $row); + } + } + + $this->db->trans_complete(); + + $success &= $this->db->trans_status(); + + return $success; + } + + /* + Deletes taxes given an item + */ + public function delete($item_id) + { + return $this->db->delete('items_taxes', array('item_id' => $item_id)); + } +} +?> +
    - + diff --git a/docs/source-class-Items.html b/docs/source-class-Items.html index 91178d61d..ba1158ea3 100644 --- a/docs/source-class-Items.html +++ b/docs/source-class-Items.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -402,7 +404,7 @@ $data['default_tax_2_rate'] = $this->config->item('default_tax_2_rate'); $item_info->receiving_quantity = 0; - $item_info->reorder_level = 0; + $item_info->reorder_level = 1; $item_info->item_type = '0'; // standard $item_info->stock_type = '0'; // stock $item_info->tax_category_id = 0; @@ -1069,6 +1071,6 @@ - + diff --git a/docs/source-class-Login.html b/docs/source-class-Login.html index 3ceadacd7..6b3975370 100644 --- a/docs/source-class-Login.html +++ b/docs/source-class-Login.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,86 +207,81 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     
     class Login extends CI_Controller 
     {
    -    public function __construct()
    +    public function index()
         {
    -        parent::__construct();
    -    }
    -
    -    public function index()
    -    {
    -        if($this->Employee->is_logged_in())
    -        {
    -            redirect('home');
    -        }
    -        else
    -        {
    -            $this->form_validation->set_rules('username', 'lang:login_undername', 'callback_login_check');
    -            $this->form_validation->set_error_delimiters('<div class="error">', '</div>');
    -            
    -            if($this->form_validation->run() == FALSE)
    -            {
    -                $this->load->view('login');
    -            }
    -            else
    -            {
    -                if($this->config->item('statistics'))
    -                {
    -                    $this->load->library('tracking_lib');
    -                    
    -                    $this->tracking_lib->track_page('login', 'login');
    -                    
    -                    $this->tracking_lib->track_event('Stats', 'Theme', $this->config->item('theme'));
    -                    $this->tracking_lib->track_event('Stats', 'Language', $this->config->item('language'));
    -                    $this->tracking_lib->track_event('Stats', 'Timezone', $this->config->item('timezone'));
    -                    $this->tracking_lib->track_event('Stats', 'Currency', $this->config->item('currency_symbol'));
    -                    $this->tracking_lib->track_event('Stats', 'Customer Sales Tax Support', $this->config->item('customer_sales_tax_support'));
    -                    $this->tracking_lib->track_event('Stats', 'Tax Included', $this->config->item('tax_included'));
    -                    $this->tracking_lib->track_event('Stats', 'Thousands Separator', $this->config->item('thousands_separator'));
    -                    $this->tracking_lib->track_event('Stats', 'Currency Decimals', $this->config->item('currency_decimals'));
    -                    $this->tracking_lib->track_event('Stats', 'Tax Decimals', $this->config->item('tax_decimals'));
    -                    $this->tracking_lib->track_event('Stats', 'Quantity Decimals', $this->config->item('quantity_decimals'));
    -                    $this->tracking_lib->track_event('Stats', 'Invoice Enable', $this->config->item('invoice_enable'));
    -                    $this->tracking_lib->track_event('Stats', 'Date or Time Format', $this->config->item('date_or_time_format'));
    -                }
    +        if($this->Employee->is_logged_in())
    +        {
    +            redirect('home');
    +        }
    +        else
    +        {
    +            $this->form_validation->set_rules('username', 'lang:login_undername', 'callback_login_check');
    +            $this->form_validation->set_error_delimiters('<div class="error">', '</div>');
    +            
    +            if($this->form_validation->run() == FALSE)
    +            {
    +                $this->load->view('login');
    +            }
    +            else
    +            {
    +                if($this->config->item('statistics'))
    +                {
    +                    $this->load->library('tracking_lib');
    +                    
    +                    $this->tracking_lib->track_page('login', 'login');
    +                    
    +                    $this->tracking_lib->track_event('Stats', 'Theme', $this->config->item('theme'));
    +                    $this->tracking_lib->track_event('Stats', 'Language', $this->config->item('language'));
    +                    $this->tracking_lib->track_event('Stats', 'Timezone', $this->config->item('timezone'));
    +                    $this->tracking_lib->track_event('Stats', 'Currency', $this->config->item('currency_symbol'));
    +                    $this->tracking_lib->track_event('Stats', 'Customer Sales Tax Support', $this->config->item('customer_sales_tax_support'));
    +                    $this->tracking_lib->track_event('Stats', 'Tax Included', $this->config->item('tax_included'));
    +                    $this->tracking_lib->track_event('Stats', 'Thousands Separator', $this->config->item('thousands_separator'));
    +                    $this->tracking_lib->track_event('Stats', 'Currency Decimals', $this->config->item('currency_decimals'));
    +                    $this->tracking_lib->track_event('Stats', 'Tax Decimals', $this->config->item('tax_decimals'));
    +                    $this->tracking_lib->track_event('Stats', 'Quantity Decimals', $this->config->item('quantity_decimals'));
    +                    $this->tracking_lib->track_event('Stats', 'Invoice Enable', $this->config->item('invoice_enable'));
    +                    $this->tracking_lib->track_event('Stats', 'Date or Time Format', $this->config->item('date_or_time_format'));
    +                }
    +
    +                redirect('home');
    +            }
    +        }
    +    }
     
    -                redirect('home');
    -            }
    -        }
    -    }
    -
    -    public function login_check($username)
    -    {
    -        $password = $this->input->post('password');
    -
    -        if($this->_security_check($username, $password))
    -        {
    -            $this->form_validation->set_message('login_check', 'Security check failure');
    -
    -            return FALSE;
    -        }
    -
    -        if(!$this->Employee->login($username, $password))
    -        {
    -            $this->form_validation->set_message('login_check', $this->lang->line('login_invalid_username_and_password'));
    -
    -            return FALSE;
    -        }
    -
    -        return TRUE;        
    +    public function login_check($username)
    +    {
    +        $password = $this->input->post('password');
    +
    +        if($this->_security_check($username, $password))
    +        {
    +            $this->form_validation->set_message('login_check', 'Security check failure');
    +
    +            return FALSE;
    +        }
    +
    +        if(!$this->Employee->login($username, $password))
    +        {
    +            $this->form_validation->set_message('login_check', $this->lang->line('login_invalid_username_and_password'));
    +
    +            return FALSE;
    +        }
    +
    +        return TRUE;        
    +    }
    +    
    +    private function _security_check($username, $password)
    +    {
    +        return preg_match('~\b(Copyright|(c)|©|All rights reserved|Developed|Crafted|Implemented|Made|Powered|Code|Design|unblockUI|blockUI|blockOverlay|hide|opacity)\b~i', file_get_contents(APPPATH . 'views/partial/footer.php'));
         }
    -    
    -    private function _security_check($username, $password)
    -    {
    -        return preg_match('~\b(Copyright|(c)|©|All rights reserved|Developed|Crafted|Implemented|Made|Powered|Code|Design|unblockUI|blockUI|blockOverlay|hide|opacity)\b~i', file_get_contents(APPPATH . 'views/partial/footer.php'));
    -    }
    -}
    -?>
    -
    +
    } +?> + - + diff --git a/docs/source-class-MY_Lang.html b/docs/source-class-MY_Lang.html index 116ebfa42..e754541fd 100644 --- a/docs/source-class-MY_Lang.html +++ b/docs/source-class-MY_Lang.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,102 +207,97 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 
    -
    <?php (defined('BASEPATH')) OR exit('No direct script access allowed');
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
     class MY_Lang extends CI_Lang
     {
    -    public function __construct()
    +    public function switch_to($idiom)
         {
    -        parent::__construct();
    -    }
    -
    -    public function switch_to($idiom)
    -    {
    -        $CI =& get_instance();
    -        if(is_string($idiom))
    -        {
    -            $CI->config->set_item('language', $idiom);
    -            $loaded = $this->is_loaded;
    -            $this->is_loaded = array();
    -                
    -            foreach($loaded as $file)
    -            {
    -                $this->load(strtr($file, '', '_lang.php'));
    -            }
    -        }
    -    }
    -    
    -    /**
    -     * Fetch a single line of text from the language array. Takes variable number
    -     * of arguments and supports wildcards in the form of '%1', '%2', etc.
    -     * Overloaded function.
    -     *
    -     * @access public
    -     * @return mixed false if not found or the language string
    -     */
    -    public function line($line = '', $log_errors = TRUE)
    -    {
    -        //get the arguments passed to the function
    -        $args = func_get_args();
    -        
    -        //count the number of arguments
    -        $c = count($args);
    -        
    -        //if one or more arguments, perform the necessary processing
    -        if($c)
    -        {
    -            //first argument should be the actual language line key
    -            //so remove it from the array (pop from front)
    -            $line = array_shift($args);
    -            
    -            //check to make sure the key is valid and load the line
    -            if($line == '')
    -            {
    -                $line = FALSE;
    -            }
    -            else 
    -            {
    -                if(isset($this->language[$line]))
    -                {
    -                    $line = $this->language[$line];
    -                    //if the line exists and more function arguments remain
    -                    //perform wildcard replacements
    -                    if($args)
    -                    {
    -                        $i = 1;
    -                        foreach($args as $arg)
    -                        {
    -                            $line = preg_replace('/\%'.$i.'/', $arg, $line);
    -                            ++$i;
    -                        }
    -                    }
    -                }
    -                else
    -                {
    -                    // just return label name (with TBD)
    -                    $line = $this->line_tbd($line);
    -                    log_message('error', 'Could not find the language line "'.$line.'"');
    -                }
    -            }
    +        $CI =& get_instance();
    +        if(is_string($idiom))
    +        {
    +            $CI->config->set_item('language', $idiom);
    +            $loaded = $this->is_loaded;
    +            $this->is_loaded = array();
    +                
    +            foreach($loaded as $file)
    +            {
    +                $this->load(strtr($file, '', '_lang.php'));
    +            }
    +        }
    +    }
    +    
    +    /**
    +     * Fetch a single line of text from the language array. Takes variable number
    +     * of arguments and supports wildcards in the form of '%1', '%2', etc.
    +     * Overloaded function.
    +     *
    +     * @access public
    +     * @return mixed false if not found or the language string
    +     */
    +    public function line($line = '', $log_errors = TRUE)
    +    {
    +        //get the arguments passed to the function
    +        $args = func_get_args();
    +        
    +        //count the number of arguments
    +        $c = count($args);
    +        
    +        //if one or more arguments, perform the necessary processing
    +        if($c)
    +        {
    +            //first argument should be the actual language line key
    +            //so remove it from the array (pop from front)
    +            $line = array_shift($args);
    +            
    +            //check to make sure the key is valid and load the line
    +            if($line == '')
    +            {
    +                $line = FALSE;
    +            }
    +            else 
    +            {
    +                if(isset($this->language[$line]) && $this->language[$line] != '')
    +                {
    +                    $line = $this->language[$line];
    +                    //if the line exists and more function arguments remain
    +                    //perform wildcard replacements
    +                    if($args)
    +                    {
    +                        $i = 1;
    +                        foreach($args as $arg)
    +                        {
    +                            $line = preg_replace('/\%'.$i.'/', $arg, $line);
    +                            ++$i;
    +                        }
    +                    }
    +                }
    +                else
    +                {
    +                    // just return label name (with TBD)
    +                    $line = $this->line_tbd($line);
    +                    log_message('error', 'Could not find the language line "'.$line.'"');
    +                }
    +            }
    +        }
    +        else
    +        {
    +            //if no arguments given, no language line available
    +            $line = FALSE;
             }
    -        else
    -        {
    -            //if no arguments given, no language line available
    -            $line = FALSE;
    -        }
    -        
    -        return $line;
    +        
    +        return $line;
    +    }
    +    
    +    public function line_tbd($line = '')
    +    {
    +        return $line . ' (TBD)';
         }
    -    
    -    public function line_tbd($line = '')
    -    {
    -        return $line . ' (TBD)';
    -    }
    -}
    -
    -?>
    -
    +
    } + +?> +
    - + diff --git a/docs/source-class-MailchimpConnector.html b/docs/source-class-MailchimpConnector.html index deec0b448..fba02e019 100644 --- a/docs/source-class-MailchimpConnector.html +++ b/docs/source-class-MailchimpConnector.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,364 +207,373 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
     /**
      * MailChimp API v3 REST client Connector
    - * 
    + *
      * Interface for communicating with the Mailchimp v3 API
      *
    - * Inspired by the work of:
    - *   - Rajitha Bandara: https://github.com/rajitha-bandara/ci-mailchimp-v3-rest-client
    - *   - Stefan Ashwell: https://github.com/stef686/codeigniter-mailchimp-api-v3
    - */
    -
    -class MailchimpConnector
    -{
    -    /**
    -     * API Key
    -     *
    -     * @var string[]
    -     */
    -    private $_api_key = '';
    -
    -    /**
    -     * API Endpoint
    -     *
    -     * @var string[]
    -     */
    -    private $_api_endpoint = 'https://<dc>.api.mailchimp.com/3.0/';
    -
    -    /**
    -     * Constructor
    -     */
    -    public function __construct($api_key = '')
    -    {
    -        $CI =& get_instance();
    -
    -        if(empty($api_key))
    -        {
    -            $this->_api_key = $CI->encryption->decrypt($CI->Appconfig->get('mailchimp_api_key'));
    -        }
    -        else
    + * @link    github.com/jekkos/opensourcepos
    + * @since   3.1
    + * @author  daN4cat (FrancescoUK)
    + *
    + * Inspired by the work of:
    + *   - Rajitha Bandara: https://github.com/rajitha-bandara/ci-mailchimp-v3-rest-client
    + *   - Stefan Ashwell: https://github.com/stef686/codeigniter-mailchimp-api-v3
    + */
    +
    +class MailchimpConnector
    +{
    +    /**
    +     * API Key
    +     *
    +     * @var string[]
    +     */
    +    private $_api_key = '';
    +
    +    /**
    +     * API Endpoint
    +     *
    +     * @var string[]
    +     */
    +    private $_api_endpoint = 'https://<dc>.api.mailchimp.com/3.0/';
    +
    +    /**
    +     * Constructor
    +     */
    +    public function __construct($api_key = '')
    +    {
    +        $CI =& get_instance();
    +
    +        if(empty($api_key))
             {
    -            $this->_api_key = $api_key;
    +            $this->_api_key = $CI->encryption->decrypt($CI->Appconfig->get('mailchimp_api_key'));
             }
    -
    -        if(!empty($this->_api_key))
    -        {
    -            // Replace <dc> with correct datacenter obtained from the last part of the api key
    -            $strings = explode('-', $this->_api_key);
    -            if(is_array($strings) && !empty($strings[1]))
    -            {
    -                $this->_api_endpoint = str_replace('<dc>', $strings[1], $this->_api_endpoint);
    -            }
    -        }
    -    }
    -
    -    /**
    -     * Call an API method. Every request needs the API key
    -     * @param  string $httpVerb The HTTP method to be used
    -     * @param  string $method   The API method to call, e.g. 'lists/list'
    -     * @param  array  $args     An array of arguments to pass to the method. Will be json-encoded for you.
    -     * @return array            Associative array of json decoded API response.
    -     */
    -    public function call($httpVerb = 'POST', $method, $args = array())
    -    {
    -        if(!empty($this->_api_key))
    -        {
    -            return $this->_request($httpVerb, $method, $args);
    -        }
    -        
    -        return FALSE;
    -    }
    -
    -    /**
    -     * Builds the request URL based on request type
    -     * @param  string $httpVerb The HTTP method to be used
    -     * @param  string $method   The API method to be called
    -     * @param  array  $args     Assoc array of parameters to be passed
    -     * @return string           Request URL
    -     */
    -    private function _build_request_url($httpVerb = 'POST', $method, $args = array())
    -    {
    -        if($httpVerb == 'GET')
    -        {
    -            return $this->_api_endpoint . $method . '?' . http_build_query($args);
    -        }
    -
    -        return $this->_api_endpoint . $method;
    -    }
    -
    -    /**
    -     * Performs the underlying HTTP request. 
    -     * @param  string $httpVerb The HTTP method to be used
    -     * @param  string $method   The API method to be called
    -     * @param  array  $args     Assoc array of parameters to be passed
    -     * @return array            Assoc array of decoded result
    -     */
    -    private function _request($httpVerb, $method, $args = array()) 
    -    {
    -        $result = FALSE;
    -
    -        if(($ch = curl_init()) !== FALSE)
    -        {
    -            curl_setopt($ch, CURLOPT_URL, $this->_build_request_url($httpVerb, $method, $args));
    -            curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
    -            curl_setopt($ch, CURLOPT_USERPWD, "user:" . $this->_api_key);
    -            curl_setopt($ch, CURLOPT_USERAGENT, 'PHP-MCAPI/3.0');
    -            curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    -            curl_setopt($ch, CURLOPT_TIMEOUT, 10);
    -            curl_setopt($ch, CURLOPT_POST, TRUE);
    -            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
    -            curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($args));
    -            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $httpVerb);
    -
    -            $result = curl_exec($ch);
    -
    -            curl_close($ch);
    -        }
    -
    -        return $result ? json_decode($result, TRUE) : FALSE;
    -    }
    -}
    +        else
    +        {
    +            $this->_api_key = $api_key;
    +        }
    +
    +        if(!empty($this->_api_key))
    +        {
    +            // Replace <dc> with correct datacenter obtained from the last part of the api key
    +            $strings = explode('-', $this->_api_key);
    +            if(is_array($strings) && !empty($strings[1]))
    +            {
    +                $this->_api_endpoint = str_replace('<dc>', $strings[1], $this->_api_endpoint);
    +            }
    +        }
    +    }
    +
    +    /**
    +     * Call an API method. Every request needs the API key
    +     * @param  string $httpVerb The HTTP method to be used
    +     * @param  string $method   The API method to call, e.g. 'lists/list'
    +     * @param  array  $args     An array of arguments to pass to the method. Will be json-encoded for you.
    +     * @return array            Associative array of json decoded API response.
    +     */
    +    public function call($httpVerb = 'POST', $method, $args = array())
    +    {
    +        if(!empty($this->_api_key))
    +        {
    +            return $this->_request($httpVerb, $method, $args);
    +        }
    +
    +        return FALSE;
    +    }
    +
    +    /**
    +     * Builds the request URL based on request type
    +     * @param  string $httpVerb The HTTP method to be used
    +     * @param  string $method   The API method to be called
    +     * @param  array  $args     Assoc array of parameters to be passed
    +     * @return string           Request URL
    +     */
    +    private function _build_request_url($httpVerb = 'POST', $method, $args = array())
    +    {
    +        if($httpVerb == 'GET')
    +        {
    +            return $this->_api_endpoint . $method . '?' . http_build_query($args);
    +        }
    +
    +        return $this->_api_endpoint . $method;
    +    }
    +
    +    /**
    +     * Performs the underlying HTTP request.
    +     * @param  string $httpVerb The HTTP method to be used
    +     * @param  string $method   The API method to be called
    +     * @param  array  $args     Assoc array of parameters to be passed
    +     * @return array            Assoc array of decoded result
    +     */
    +    private function _request($httpVerb, $method, $args = array())
    +    {
    +        $result = FALSE;
    +
    +        if(($ch = curl_init()) !== FALSE)
    +        {
    +            curl_setopt($ch, CURLOPT_URL, $this->_build_request_url($httpVerb, $method, $args));
    +            curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
    +            curl_setopt($ch, CURLOPT_USERPWD, "user:" . $this->_api_key);
    +            curl_setopt($ch, CURLOPT_USERAGENT, 'PHP-MCAPI/3.0');
    +            curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    +            curl_setopt($ch, CURLOPT_TIMEOUT, 10);
    +            curl_setopt($ch, CURLOPT_POST, TRUE);
    +            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
    +            curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($args));
    +            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $httpVerb);
    +
    +            $result = curl_exec($ch);
    +
    +            curl_close($ch);
    +        }
     
    -
    -/**
    - * Mailchimp library, usable from CI code
    - * 
    - * Library with utility queries to interface Mailchimp v3 API
    - *
    - * Inspired by the work of ThinkShout: https://github.com/thinkshout/mailchimp-api-php
    - */
    -
    -class Mailchimp_lib
    -{
    -    private $_connector;
    -
    -    public function __construct(array $params = array())
    -    {
    -        $api_key = (count($params) > 0 && !empty($params['api_key'])) ? $params['api_key'] : '';
    -        $this->_connector = new MailchimpConnector($api_key);
    -    }
    -    
    -    /**
    -    * Gets information about all lists owned by the authenticated account.
    -    *
    -    * @param array $parameters
    -    *   Associative array of optional request parameters.
    -    *   By the default it places a simple query to list name & id and count of members & merge_fields
    -    *   NOTE: no space between , and next word is allowed. You will not get the filter to work in full but just the first tag
    -    *
    -    * @return object
    -    *
    -    * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/#read-get_lists
    -    */
    -    public function getLists(array $parameters = array('fields' => 'lists.id,lists.name,lists.stats.member_count,lists.stats.merge_field_count'))
    -    {
    -        return $this->_connector->call('GET', '/lists', $parameters);
    -    }
    -
    -    /**
    -    * Gets a MailChimp list.
    -    *
    -    * @param string $list_id
    -    *   The ID of the list.
    -    * @param array $parameters
    -    *   Associative array of optional request parameters.
    -    *
    -    * @return object
    -    *
    -    * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/#read-get_lists_list_id
    -    */
    -    public function getList($list_id, $parameters = array('fields' => 'id,name,stats.member_count,stats.merge_field_count'))
    -    {
    -        return $this->_connector->call('GET', '/lists/' . $list_id, $parameters);
    -    }
    -
    -    /**
    -    * Gets information about all members of a MailChimp list.
    -    *
    -    * @param string $list_id
    -    *   The ID of the list.
    -    * @param array $parameters
    -    *   Associative array of optional request parameters.
    -    *
    -    * @return object
    -    *
    -    * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#read-get_lists_list_id_members
    -    */
    -    public function getMembers($list_id, $count, $offset, $parameters = array('fields' => 'members.id,members.email_address,members.unique_email_id,members.status,members.merge_fields'))
    -    {
    -        $parameters += [
    -            'count' => $count,
    -            'offset' => $offset
    -        ];
    -        
    -        return $this->_connector->call('GET', '/lists/' . $list_id . '/members', $parameters);
    -    }
    -
    -    /**
    -    * Gets information about a member of a MailChimp list.
    -    *
    -    * @param string $list_id
    -    *   The ID of the list.
    -    * @param string $md5id
    -    *   The member's email address md5 hash which is the id.
    -    * @param array $parameters
    -    *   Associative array of optional request parameters.
    -    *
    -    * @return object
    -    *
    -    * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#read-get_lists_list_id_members_subscriber_hash
    -    */
    -    public function getMemberInfoById($list_id, $md5id, $parameters = array('fields' => 'email_address,status,merge_fields'))
    -    {
    -        return $this->_connector->call('GET', '/lists/' . $list_id . '/members/' . $md5id, $parameters);
    -    }
    -
    -    /**
    -    * Gets information about a member of a MailChimp list.
    -    *
    -    * @param string $list_id
    -    *   The ID of the list.
    -    * @param string $email
    -    *   The member's email address.
    -    * @param array $parameters
    -    *   Associative array of optional request parameters.
    -    *
    -    * @return object
    -    *
    -    * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#read-get_lists_list_id_members_subscriber_hash
    -    */
    -    public function getMemberInfo($list_id, $email, $parameters = array())
    -    {
    -        return $this->_connector->call('GET', '/lists/' . $list_id . '/members/' . md5(strtolower($email)), $parameters);
    -    }
    -
    -    /**
    -    * Gets activity related to a member of a MailChimp list.
    -    *
    -    * @param string $list_id
    -    *   The ID of the list.
    -    * @param string $email
    -    *   The member's email address.
    -    * @param array $parameters
    -    *   Associative array of optional request parameters.
    -    *
    -    * @return object
    -    *
    -    * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/activity/#read-get_lists_list_id_members_subscriber_hash_activity
    -    */
    -    public function getMemberActivity($list_id, $email, $parameters = array())
    -    {
    -        return $this->_connector->call('GET', '/lists/' . $list_id . '/members/' . md5(strtolower($email)) . '/activity', $parameters);
    -    }
    -
    -    /**
    -    * Adds a new member to a MailChimp list.
    -    *
    -    * @param string $list_id
    -    *   The ID of the list.
    -    * @param string $email
    -    *   The email address to add.
    -    * @param array $parameters
    -    *   Associative array of optional request parameters.
    -    *
    -    * @return object
    -    *
    -    * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#create-post_lists_list_id_members
    -    */
    -    public function addMember($list_id, $email, $first_name, $last_name, $parameters = array())
    -    {
    -        $parameters += [
    -            'email_address' => $email,
    -            'status' => 'subscribed',
    -            'merge_fields' => array(
    -                'FNAME' => $first_name,
    -                'LNAME' => $last_name
    -            )
    -        ];
    -
    -        return $this->_connector->call('POST', '/lists/' . $list_id . '/members/', $parameters);
    -    }
    -
    -    /**
    -    * Removes a member from a MailChimp list.
    -    *
    -    * @param string $list_id
    -    *   The ID of the list.
    -    * @param string $email
    -    *   The member's email address.
    -    *
    -    * @return object
    -    *
    -    * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#delete-delete_lists_list_id_members_subscriber_hash
    -    */
    -    public function removeMember($list_id, $email)
    -    {
    -        return $this->_connector->call('DELETE', '/lists/' . $list_id . '/members/' . md5(strtolower($email)));
    -    }
    -
    -    /**
    -    * Updates a member of a MailChimp list.
    -    *
    -    * @param string $list_id
    -    *   The ID of the list.
    -    * @param string $email
    -    *   The member's email address.
    -    * @param array $parameters
    -    *   Associative array of optional request parameters.
    -    *
    -    * @return object
    -    *
    -    * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#edit-patch_lists_list_id_members_subscriber_hash
    -    */
    -    public function updateMember($list_id, $email, $first_name, $last_name, $parameters = array())
    -    {
    -        $parameters += [
    -            'status' => 'subscribed',
    -            'merge_fields' => array(
    -                'FNAME' => $first_name,
    -                'LNAME' => $last_name
    -            )
    -        ];
    -
    -        return $this->_connector->call('PATCH', '/lists/' . $list_id . '/members/' . md5(strtolower($email)), $parameters);
    -    }
    -
    -    /**
    -    * Adds a new or update an existing member of a MailChimp list.
    -    *
    -    * @param string $list_id
    -    *   The ID of the list.
    -    * @param string $email
    -    *   The member's email address.
    -    * @param array $parameters
    -    *   Associative array of optional request parameters.
    -    *
    -    * @return object
    -    *
    -    * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#edit-put_lists_list_id_members_subscriber_hash
    -    */
    -    public function addOrUpdateMember($list_id, $email, $first_name, $last_name, $status, $parameters = array())
    -    {
    -        $parameters += [
    -            'email_address' => $email,
    -            'status' => $status,
    -            'status_if_new' => 'subscribed',
    -            'merge_fields' => array(
    -                'FNAME' => $first_name,
    -                'LNAME' => $last_name
    -            )
    -        ];
    -
    -        return $this->_connector->call('PUT', '/lists/' . $list_id . '/members/' . md5(strtolower($email)), $parameters);
    -    }
    -}
    -
    -?>
    + return $result ? json_decode($result, TRUE) : FALSE; + } +} + + +/** + * Mailchimp library, usable from CI code + * + * Library with utility queries to interface Mailchimp v3 API + * + * @link github.com/jekkos/opensourcepos + * @since 3.1 + * @author daN4cat (FrancescoUK) + * + * Inspired by the work of ThinkShout: https://github.com/thinkshout/mailchimp-api-php + */ + +class Mailchimp_lib +{ + private $_connector; + + public function __construct(array $params = array()) + { + $api_key = (count($params) > 0 && !empty($params['api_key'])) ? $params['api_key'] : ''; + $this->_connector = new MailchimpConnector($api_key); + } + + /** + * Gets information about all lists owned by the authenticated account. + * + * @param array $parameters + * Associative array of optional request parameters. + * By the default it places a simple query to list name & id and count of members & merge_fields + * NOTE: no space between , and next word is allowed. You will not get the filter to work in full but just the first tag + * + * @return object + * + * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/#read-get_lists + */ + public function getLists(array $parameters = array('fields' => 'lists.id,lists.name,lists.stats.member_count,lists.stats.merge_field_count')) + { + return $this->_connector->call('GET', '/lists', $parameters); + } + + /** + * Gets a MailChimp list. + * + * @param string $list_id + * The ID of the list. + * @param array $parameters + * Associative array of optional request parameters. + * + * @return object + * + * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/#read-get_lists_list_id + */ + public function getList($list_id, $parameters = array('fields' => 'id,name,stats.member_count,stats.merge_field_count')) + { + return $this->_connector->call('GET', '/lists/' . $list_id, $parameters); + } + + /** + * Gets information about all members of a MailChimp list. + * + * @param string $list_id + * The ID of the list. + * @param array $parameters + * Associative array of optional request parameters. + * + * @return object + * + * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#read-get_lists_list_id_members + */ + public function getMembers($list_id, $count, $offset, $parameters = array('fields' => 'members.id,members.email_address,members.unique_email_id,members.status,members.merge_fields')) + { + $parameters += [ + 'count' => $count, + 'offset' => $offset + ]; + + return $this->_connector->call('GET', '/lists/' . $list_id . '/members', $parameters); + } + + /** + * Gets information about a member of a MailChimp list. + * + * @param string $list_id + * The ID of the list. + * @param string $md5id + * The member's email address md5 hash which is the id. + * @param array $parameters + * Associative array of optional request parameters. + * + * @return object + * + * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#read-get_lists_list_id_members_subscriber_hash + */ + public function getMemberInfoById($list_id, $md5id, $parameters = array('fields' => 'email_address,status,merge_fields')) + { + return $this->_connector->call('GET', '/lists/' . $list_id . '/members/' . $md5id, $parameters); + } + + /** + * Gets information about a member of a MailChimp list. + * + * @param string $list_id + * The ID of the list. + * @param string $email + * The member's email address. + * @param array $parameters + * Associative array of optional request parameters. + * + * @return object + * + * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#read-get_lists_list_id_members_subscriber_hash + */ + public function getMemberInfo($list_id, $email, $parameters = array()) + { + return $this->_connector->call('GET', '/lists/' . $list_id . '/members/' . md5(strtolower($email)), $parameters); + } + + /** + * Gets activity related to a member of a MailChimp list. + * + * @param string $list_id + * The ID of the list. + * @param string $email + * The member's email address. + * @param array $parameters + * Associative array of optional request parameters. + * + * @return object + * + * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/activity/#read-get_lists_list_id_members_subscriber_hash_activity + */ + public function getMemberActivity($list_id, $email, $parameters = array()) + { + return $this->_connector->call('GET', '/lists/' . $list_id . '/members/' . md5(strtolower($email)) . '/activity', $parameters); + } + + /** + * Adds a new member to a MailChimp list. + * + * @param string $list_id + * The ID of the list. + * @param string $email + * The email address to add. + * @param array $parameters + * Associative array of optional request parameters. + * + * @return object + * + * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#create-post_lists_list_id_members + */ + public function addMember($list_id, $email, $first_name, $last_name, $parameters = array()) + { + $parameters += [ + 'email_address' => $email, + 'status' => 'subscribed', + 'merge_fields' => array( + 'FNAME' => $first_name, + 'LNAME' => $last_name + ) + ]; + + return $this->_connector->call('POST', '/lists/' . $list_id . '/members/', $parameters); + } + + /** + * Removes a member from a MailChimp list. + * + * @param string $list_id + * The ID of the list. + * @param string $email + * The member's email address. + * + * @return object + * + * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#delete-delete_lists_list_id_members_subscriber_hash + */ + public function removeMember($list_id, $email) + { + return $this->_connector->call('DELETE', '/lists/' . $list_id . '/members/' . md5(strtolower($email))); + } + + /** + * Updates a member of a MailChimp list. + * + * @param string $list_id + * The ID of the list. + * @param string $email + * The member's email address. + * @param array $parameters + * Associative array of optional request parameters. + * + * @return object + * + * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#edit-patch_lists_list_id_members_subscriber_hash + */ + public function updateMember($list_id, $email, $first_name, $last_name, $parameters = array()) + { + $parameters += [ + 'status' => 'subscribed', + 'merge_fields' => array( + 'FNAME' => $first_name, + 'LNAME' => $last_name + ) + ]; + + return $this->_connector->call('PATCH', '/lists/' . $list_id . '/members/' . md5(strtolower($email)), $parameters); + } + + /** + * Adds a new or update an existing member of a MailChimp list. + * + * @param string $list_id + * The ID of the list. + * @param string $email + * The member's email address. + * @param array $parameters + * Associative array of optional request parameters. + * + * @return object + * + * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#edit-put_lists_list_id_members_subscriber_hash + */ + public function addOrUpdateMember($list_id, $email, $first_name, $last_name, $status, $parameters = array()) + { + $parameters += [ + 'email_address' => $email, + 'status' => $status, + 'status_if_new' => 'subscribed', + 'merge_fields' => array( + 'FNAME' => $first_name, + 'LNAME' => $last_name + ) + ]; + + return $this->_connector->call('PUT', '/lists/' . $list_id . '/members/' . md5(strtolower($email)), $parameters); + } +} + +?> + - + diff --git a/docs/source-class-Mailchimp_lib.html b/docs/source-class-Mailchimp_lib.html index deec0b448..fba02e019 100644 --- a/docs/source-class-Mailchimp_lib.html +++ b/docs/source-class-Mailchimp_lib.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,364 +207,373 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
     /**
      * MailChimp API v3 REST client Connector
    - * 
    + *
      * Interface for communicating with the Mailchimp v3 API
      *
    - * Inspired by the work of:
    - *   - Rajitha Bandara: https://github.com/rajitha-bandara/ci-mailchimp-v3-rest-client
    - *   - Stefan Ashwell: https://github.com/stef686/codeigniter-mailchimp-api-v3
    - */
    -
    -class MailchimpConnector
    -{
    -    /**
    -     * API Key
    -     *
    -     * @var string[]
    -     */
    -    private $_api_key = '';
    -
    -    /**
    -     * API Endpoint
    -     *
    -     * @var string[]
    -     */
    -    private $_api_endpoint = 'https://<dc>.api.mailchimp.com/3.0/';
    -
    -    /**
    -     * Constructor
    -     */
    -    public function __construct($api_key = '')
    -    {
    -        $CI =& get_instance();
    -
    -        if(empty($api_key))
    -        {
    -            $this->_api_key = $CI->encryption->decrypt($CI->Appconfig->get('mailchimp_api_key'));
    -        }
    -        else
    + * @link    github.com/jekkos/opensourcepos
    + * @since   3.1
    + * @author  daN4cat (FrancescoUK)
    + *
    + * Inspired by the work of:
    + *   - Rajitha Bandara: https://github.com/rajitha-bandara/ci-mailchimp-v3-rest-client
    + *   - Stefan Ashwell: https://github.com/stef686/codeigniter-mailchimp-api-v3
    + */
    +
    +class MailchimpConnector
    +{
    +    /**
    +     * API Key
    +     *
    +     * @var string[]
    +     */
    +    private $_api_key = '';
    +
    +    /**
    +     * API Endpoint
    +     *
    +     * @var string[]
    +     */
    +    private $_api_endpoint = 'https://<dc>.api.mailchimp.com/3.0/';
    +
    +    /**
    +     * Constructor
    +     */
    +    public function __construct($api_key = '')
    +    {
    +        $CI =& get_instance();
    +
    +        if(empty($api_key))
             {
    -            $this->_api_key = $api_key;
    +            $this->_api_key = $CI->encryption->decrypt($CI->Appconfig->get('mailchimp_api_key'));
             }
    -
    -        if(!empty($this->_api_key))
    -        {
    -            // Replace <dc> with correct datacenter obtained from the last part of the api key
    -            $strings = explode('-', $this->_api_key);
    -            if(is_array($strings) && !empty($strings[1]))
    -            {
    -                $this->_api_endpoint = str_replace('<dc>', $strings[1], $this->_api_endpoint);
    -            }
    -        }
    -    }
    -
    -    /**
    -     * Call an API method. Every request needs the API key
    -     * @param  string $httpVerb The HTTP method to be used
    -     * @param  string $method   The API method to call, e.g. 'lists/list'
    -     * @param  array  $args     An array of arguments to pass to the method. Will be json-encoded for you.
    -     * @return array            Associative array of json decoded API response.
    -     */
    -    public function call($httpVerb = 'POST', $method, $args = array())
    -    {
    -        if(!empty($this->_api_key))
    -        {
    -            return $this->_request($httpVerb, $method, $args);
    -        }
    -        
    -        return FALSE;
    -    }
    -
    -    /**
    -     * Builds the request URL based on request type
    -     * @param  string $httpVerb The HTTP method to be used
    -     * @param  string $method   The API method to be called
    -     * @param  array  $args     Assoc array of parameters to be passed
    -     * @return string           Request URL
    -     */
    -    private function _build_request_url($httpVerb = 'POST', $method, $args = array())
    -    {
    -        if($httpVerb == 'GET')
    -        {
    -            return $this->_api_endpoint . $method . '?' . http_build_query($args);
    -        }
    -
    -        return $this->_api_endpoint . $method;
    -    }
    -
    -    /**
    -     * Performs the underlying HTTP request. 
    -     * @param  string $httpVerb The HTTP method to be used
    -     * @param  string $method   The API method to be called
    -     * @param  array  $args     Assoc array of parameters to be passed
    -     * @return array            Assoc array of decoded result
    -     */
    -    private function _request($httpVerb, $method, $args = array()) 
    -    {
    -        $result = FALSE;
    -
    -        if(($ch = curl_init()) !== FALSE)
    -        {
    -            curl_setopt($ch, CURLOPT_URL, $this->_build_request_url($httpVerb, $method, $args));
    -            curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
    -            curl_setopt($ch, CURLOPT_USERPWD, "user:" . $this->_api_key);
    -            curl_setopt($ch, CURLOPT_USERAGENT, 'PHP-MCAPI/3.0');
    -            curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    -            curl_setopt($ch, CURLOPT_TIMEOUT, 10);
    -            curl_setopt($ch, CURLOPT_POST, TRUE);
    -            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
    -            curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($args));
    -            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $httpVerb);
    -
    -            $result = curl_exec($ch);
    -
    -            curl_close($ch);
    -        }
    -
    -        return $result ? json_decode($result, TRUE) : FALSE;
    -    }
    -}
    +        else
    +        {
    +            $this->_api_key = $api_key;
    +        }
    +
    +        if(!empty($this->_api_key))
    +        {
    +            // Replace <dc> with correct datacenter obtained from the last part of the api key
    +            $strings = explode('-', $this->_api_key);
    +            if(is_array($strings) && !empty($strings[1]))
    +            {
    +                $this->_api_endpoint = str_replace('<dc>', $strings[1], $this->_api_endpoint);
    +            }
    +        }
    +    }
    +
    +    /**
    +     * Call an API method. Every request needs the API key
    +     * @param  string $httpVerb The HTTP method to be used
    +     * @param  string $method   The API method to call, e.g. 'lists/list'
    +     * @param  array  $args     An array of arguments to pass to the method. Will be json-encoded for you.
    +     * @return array            Associative array of json decoded API response.
    +     */
    +    public function call($httpVerb = 'POST', $method, $args = array())
    +    {
    +        if(!empty($this->_api_key))
    +        {
    +            return $this->_request($httpVerb, $method, $args);
    +        }
    +
    +        return FALSE;
    +    }
    +
    +    /**
    +     * Builds the request URL based on request type
    +     * @param  string $httpVerb The HTTP method to be used
    +     * @param  string $method   The API method to be called
    +     * @param  array  $args     Assoc array of parameters to be passed
    +     * @return string           Request URL
    +     */
    +    private function _build_request_url($httpVerb = 'POST', $method, $args = array())
    +    {
    +        if($httpVerb == 'GET')
    +        {
    +            return $this->_api_endpoint . $method . '?' . http_build_query($args);
    +        }
    +
    +        return $this->_api_endpoint . $method;
    +    }
    +
    +    /**
    +     * Performs the underlying HTTP request.
    +     * @param  string $httpVerb The HTTP method to be used
    +     * @param  string $method   The API method to be called
    +     * @param  array  $args     Assoc array of parameters to be passed
    +     * @return array            Assoc array of decoded result
    +     */
    +    private function _request($httpVerb, $method, $args = array())
    +    {
    +        $result = FALSE;
    +
    +        if(($ch = curl_init()) !== FALSE)
    +        {
    +            curl_setopt($ch, CURLOPT_URL, $this->_build_request_url($httpVerb, $method, $args));
    +            curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
    +            curl_setopt($ch, CURLOPT_USERPWD, "user:" . $this->_api_key);
    +            curl_setopt($ch, CURLOPT_USERAGENT, 'PHP-MCAPI/3.0');
    +            curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    +            curl_setopt($ch, CURLOPT_TIMEOUT, 10);
    +            curl_setopt($ch, CURLOPT_POST, TRUE);
    +            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
    +            curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($args));
    +            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $httpVerb);
    +
    +            $result = curl_exec($ch);
    +
    +            curl_close($ch);
    +        }
     
    -
    -/**
    - * Mailchimp library, usable from CI code
    - * 
    - * Library with utility queries to interface Mailchimp v3 API
    - *
    - * Inspired by the work of ThinkShout: https://github.com/thinkshout/mailchimp-api-php
    - */
    -
    -class Mailchimp_lib
    -{
    -    private $_connector;
    -
    -    public function __construct(array $params = array())
    -    {
    -        $api_key = (count($params) > 0 && !empty($params['api_key'])) ? $params['api_key'] : '';
    -        $this->_connector = new MailchimpConnector($api_key);
    -    }
    -    
    -    /**
    -    * Gets information about all lists owned by the authenticated account.
    -    *
    -    * @param array $parameters
    -    *   Associative array of optional request parameters.
    -    *   By the default it places a simple query to list name & id and count of members & merge_fields
    -    *   NOTE: no space between , and next word is allowed. You will not get the filter to work in full but just the first tag
    -    *
    -    * @return object
    -    *
    -    * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/#read-get_lists
    -    */
    -    public function getLists(array $parameters = array('fields' => 'lists.id,lists.name,lists.stats.member_count,lists.stats.merge_field_count'))
    -    {
    -        return $this->_connector->call('GET', '/lists', $parameters);
    -    }
    -
    -    /**
    -    * Gets a MailChimp list.
    -    *
    -    * @param string $list_id
    -    *   The ID of the list.
    -    * @param array $parameters
    -    *   Associative array of optional request parameters.
    -    *
    -    * @return object
    -    *
    -    * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/#read-get_lists_list_id
    -    */
    -    public function getList($list_id, $parameters = array('fields' => 'id,name,stats.member_count,stats.merge_field_count'))
    -    {
    -        return $this->_connector->call('GET', '/lists/' . $list_id, $parameters);
    -    }
    -
    -    /**
    -    * Gets information about all members of a MailChimp list.
    -    *
    -    * @param string $list_id
    -    *   The ID of the list.
    -    * @param array $parameters
    -    *   Associative array of optional request parameters.
    -    *
    -    * @return object
    -    *
    -    * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#read-get_lists_list_id_members
    -    */
    -    public function getMembers($list_id, $count, $offset, $parameters = array('fields' => 'members.id,members.email_address,members.unique_email_id,members.status,members.merge_fields'))
    -    {
    -        $parameters += [
    -            'count' => $count,
    -            'offset' => $offset
    -        ];
    -        
    -        return $this->_connector->call('GET', '/lists/' . $list_id . '/members', $parameters);
    -    }
    -
    -    /**
    -    * Gets information about a member of a MailChimp list.
    -    *
    -    * @param string $list_id
    -    *   The ID of the list.
    -    * @param string $md5id
    -    *   The member's email address md5 hash which is the id.
    -    * @param array $parameters
    -    *   Associative array of optional request parameters.
    -    *
    -    * @return object
    -    *
    -    * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#read-get_lists_list_id_members_subscriber_hash
    -    */
    -    public function getMemberInfoById($list_id, $md5id, $parameters = array('fields' => 'email_address,status,merge_fields'))
    -    {
    -        return $this->_connector->call('GET', '/lists/' . $list_id . '/members/' . $md5id, $parameters);
    -    }
    -
    -    /**
    -    * Gets information about a member of a MailChimp list.
    -    *
    -    * @param string $list_id
    -    *   The ID of the list.
    -    * @param string $email
    -    *   The member's email address.
    -    * @param array $parameters
    -    *   Associative array of optional request parameters.
    -    *
    -    * @return object
    -    *
    -    * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#read-get_lists_list_id_members_subscriber_hash
    -    */
    -    public function getMemberInfo($list_id, $email, $parameters = array())
    -    {
    -        return $this->_connector->call('GET', '/lists/' . $list_id . '/members/' . md5(strtolower($email)), $parameters);
    -    }
    -
    -    /**
    -    * Gets activity related to a member of a MailChimp list.
    -    *
    -    * @param string $list_id
    -    *   The ID of the list.
    -    * @param string $email
    -    *   The member's email address.
    -    * @param array $parameters
    -    *   Associative array of optional request parameters.
    -    *
    -    * @return object
    -    *
    -    * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/activity/#read-get_lists_list_id_members_subscriber_hash_activity
    -    */
    -    public function getMemberActivity($list_id, $email, $parameters = array())
    -    {
    -        return $this->_connector->call('GET', '/lists/' . $list_id . '/members/' . md5(strtolower($email)) . '/activity', $parameters);
    -    }
    -
    -    /**
    -    * Adds a new member to a MailChimp list.
    -    *
    -    * @param string $list_id
    -    *   The ID of the list.
    -    * @param string $email
    -    *   The email address to add.
    -    * @param array $parameters
    -    *   Associative array of optional request parameters.
    -    *
    -    * @return object
    -    *
    -    * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#create-post_lists_list_id_members
    -    */
    -    public function addMember($list_id, $email, $first_name, $last_name, $parameters = array())
    -    {
    -        $parameters += [
    -            'email_address' => $email,
    -            'status' => 'subscribed',
    -            'merge_fields' => array(
    -                'FNAME' => $first_name,
    -                'LNAME' => $last_name
    -            )
    -        ];
    -
    -        return $this->_connector->call('POST', '/lists/' . $list_id . '/members/', $parameters);
    -    }
    -
    -    /**
    -    * Removes a member from a MailChimp list.
    -    *
    -    * @param string $list_id
    -    *   The ID of the list.
    -    * @param string $email
    -    *   The member's email address.
    -    *
    -    * @return object
    -    *
    -    * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#delete-delete_lists_list_id_members_subscriber_hash
    -    */
    -    public function removeMember($list_id, $email)
    -    {
    -        return $this->_connector->call('DELETE', '/lists/' . $list_id . '/members/' . md5(strtolower($email)));
    -    }
    -
    -    /**
    -    * Updates a member of a MailChimp list.
    -    *
    -    * @param string $list_id
    -    *   The ID of the list.
    -    * @param string $email
    -    *   The member's email address.
    -    * @param array $parameters
    -    *   Associative array of optional request parameters.
    -    *
    -    * @return object
    -    *
    -    * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#edit-patch_lists_list_id_members_subscriber_hash
    -    */
    -    public function updateMember($list_id, $email, $first_name, $last_name, $parameters = array())
    -    {
    -        $parameters += [
    -            'status' => 'subscribed',
    -            'merge_fields' => array(
    -                'FNAME' => $first_name,
    -                'LNAME' => $last_name
    -            )
    -        ];
    -
    -        return $this->_connector->call('PATCH', '/lists/' . $list_id . '/members/' . md5(strtolower($email)), $parameters);
    -    }
    -
    -    /**
    -    * Adds a new or update an existing member of a MailChimp list.
    -    *
    -    * @param string $list_id
    -    *   The ID of the list.
    -    * @param string $email
    -    *   The member's email address.
    -    * @param array $parameters
    -    *   Associative array of optional request parameters.
    -    *
    -    * @return object
    -    *
    -    * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#edit-put_lists_list_id_members_subscriber_hash
    -    */
    -    public function addOrUpdateMember($list_id, $email, $first_name, $last_name, $status, $parameters = array())
    -    {
    -        $parameters += [
    -            'email_address' => $email,
    -            'status' => $status,
    -            'status_if_new' => 'subscribed',
    -            'merge_fields' => array(
    -                'FNAME' => $first_name,
    -                'LNAME' => $last_name
    -            )
    -        ];
    -
    -        return $this->_connector->call('PUT', '/lists/' . $list_id . '/members/' . md5(strtolower($email)), $parameters);
    -    }
    -}
    -
    -?>
    + return $result ? json_decode($result, TRUE) : FALSE; + } +} + + +/** + * Mailchimp library, usable from CI code + * + * Library with utility queries to interface Mailchimp v3 API + * + * @link github.com/jekkos/opensourcepos + * @since 3.1 + * @author daN4cat (FrancescoUK) + * + * Inspired by the work of ThinkShout: https://github.com/thinkshout/mailchimp-api-php + */ + +class Mailchimp_lib +{ + private $_connector; + + public function __construct(array $params = array()) + { + $api_key = (count($params) > 0 && !empty($params['api_key'])) ? $params['api_key'] : ''; + $this->_connector = new MailchimpConnector($api_key); + } + + /** + * Gets information about all lists owned by the authenticated account. + * + * @param array $parameters + * Associative array of optional request parameters. + * By the default it places a simple query to list name & id and count of members & merge_fields + * NOTE: no space between , and next word is allowed. You will not get the filter to work in full but just the first tag + * + * @return object + * + * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/#read-get_lists + */ + public function getLists(array $parameters = array('fields' => 'lists.id,lists.name,lists.stats.member_count,lists.stats.merge_field_count')) + { + return $this->_connector->call('GET', '/lists', $parameters); + } + + /** + * Gets a MailChimp list. + * + * @param string $list_id + * The ID of the list. + * @param array $parameters + * Associative array of optional request parameters. + * + * @return object + * + * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/#read-get_lists_list_id + */ + public function getList($list_id, $parameters = array('fields' => 'id,name,stats.member_count,stats.merge_field_count')) + { + return $this->_connector->call('GET', '/lists/' . $list_id, $parameters); + } + + /** + * Gets information about all members of a MailChimp list. + * + * @param string $list_id + * The ID of the list. + * @param array $parameters + * Associative array of optional request parameters. + * + * @return object + * + * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#read-get_lists_list_id_members + */ + public function getMembers($list_id, $count, $offset, $parameters = array('fields' => 'members.id,members.email_address,members.unique_email_id,members.status,members.merge_fields')) + { + $parameters += [ + 'count' => $count, + 'offset' => $offset + ]; + + return $this->_connector->call('GET', '/lists/' . $list_id . '/members', $parameters); + } + + /** + * Gets information about a member of a MailChimp list. + * + * @param string $list_id + * The ID of the list. + * @param string $md5id + * The member's email address md5 hash which is the id. + * @param array $parameters + * Associative array of optional request parameters. + * + * @return object + * + * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#read-get_lists_list_id_members_subscriber_hash + */ + public function getMemberInfoById($list_id, $md5id, $parameters = array('fields' => 'email_address,status,merge_fields')) + { + return $this->_connector->call('GET', '/lists/' . $list_id . '/members/' . $md5id, $parameters); + } + + /** + * Gets information about a member of a MailChimp list. + * + * @param string $list_id + * The ID of the list. + * @param string $email + * The member's email address. + * @param array $parameters + * Associative array of optional request parameters. + * + * @return object + * + * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#read-get_lists_list_id_members_subscriber_hash + */ + public function getMemberInfo($list_id, $email, $parameters = array()) + { + return $this->_connector->call('GET', '/lists/' . $list_id . '/members/' . md5(strtolower($email)), $parameters); + } + + /** + * Gets activity related to a member of a MailChimp list. + * + * @param string $list_id + * The ID of the list. + * @param string $email + * The member's email address. + * @param array $parameters + * Associative array of optional request parameters. + * + * @return object + * + * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/activity/#read-get_lists_list_id_members_subscriber_hash_activity + */ + public function getMemberActivity($list_id, $email, $parameters = array()) + { + return $this->_connector->call('GET', '/lists/' . $list_id . '/members/' . md5(strtolower($email)) . '/activity', $parameters); + } + + /** + * Adds a new member to a MailChimp list. + * + * @param string $list_id + * The ID of the list. + * @param string $email + * The email address to add. + * @param array $parameters + * Associative array of optional request parameters. + * + * @return object + * + * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#create-post_lists_list_id_members + */ + public function addMember($list_id, $email, $first_name, $last_name, $parameters = array()) + { + $parameters += [ + 'email_address' => $email, + 'status' => 'subscribed', + 'merge_fields' => array( + 'FNAME' => $first_name, + 'LNAME' => $last_name + ) + ]; + + return $this->_connector->call('POST', '/lists/' . $list_id . '/members/', $parameters); + } + + /** + * Removes a member from a MailChimp list. + * + * @param string $list_id + * The ID of the list. + * @param string $email + * The member's email address. + * + * @return object + * + * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#delete-delete_lists_list_id_members_subscriber_hash + */ + public function removeMember($list_id, $email) + { + return $this->_connector->call('DELETE', '/lists/' . $list_id . '/members/' . md5(strtolower($email))); + } + + /** + * Updates a member of a MailChimp list. + * + * @param string $list_id + * The ID of the list. + * @param string $email + * The member's email address. + * @param array $parameters + * Associative array of optional request parameters. + * + * @return object + * + * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#edit-patch_lists_list_id_members_subscriber_hash + */ + public function updateMember($list_id, $email, $first_name, $last_name, $parameters = array()) + { + $parameters += [ + 'status' => 'subscribed', + 'merge_fields' => array( + 'FNAME' => $first_name, + 'LNAME' => $last_name + ) + ]; + + return $this->_connector->call('PATCH', '/lists/' . $list_id . '/members/' . md5(strtolower($email)), $parameters); + } + + /** + * Adds a new or update an existing member of a MailChimp list. + * + * @param string $list_id + * The ID of the list. + * @param string $email + * The member's email address. + * @param array $parameters + * Associative array of optional request parameters. + * + * @return object + * + * @see http://developer.mailchimp.com/documentation/mailchimp/reference/lists/members/#edit-put_lists_list_id_members_subscriber_hash + */ + public function addOrUpdateMember($list_id, $email, $first_name, $last_name, $status, $parameters = array()) + { + $parameters += [ + 'email_address' => $email, + 'status' => $status, + 'status_if_new' => 'subscribed', + 'merge_fields' => array( + 'FNAME' => $first_name, + 'LNAME' => $last_name + ) + ]; + + return $this->_connector->call('PUT', '/lists/' . $list_id . '/members/' . md5(strtolower($email)), $parameters); + } +} + +?> + - + diff --git a/docs/source-class-Messages.html b/docs/source-class-Messages.html index 274260878..4aa9d7ea2 100644 --- a/docs/source-class-Messages.html +++ b/docs/source-class-Messages.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -279,6 +281,6 @@ - + diff --git a/docs/source-class-Migrate.html b/docs/source-class-Migrate.html new file mode 100644 index 000000000..7ff90d163 --- /dev/null +++ b/docs/source-class-Migrate.html @@ -0,0 +1,252 @@ + + + + + + + File controllers/Migrate.php + + + + + + +
    + +
    + +
    + + + + + + diff --git a/docs/source-class-Migration_Sales_Tax_Data.html b/docs/source-class-Migration_Sales_Tax_Data.html new file mode 100644 index 000000000..c6cf8db7e --- /dev/null +++ b/docs/source-class-Migration_Sales_Tax_Data.html @@ -0,0 +1,361 @@ + + + + + + + File migrations/20170502221506_sales_tax_data.php + + + + + + +
    + +
    + +
    + + + + + + diff --git a/docs/source-class-Module.html b/docs/source-class-Module.html index 8976fb1f4..c8c5f6299 100644 --- a/docs/source-class-Module.html +++ b/docs/source-class-Module.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,81 +207,85 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 
    -
    <?php
    -class Module extends CI_Model 
    -{
    -    function __construct()
    -    {
    -        parent::__construct();
    -    }
    -    
    -    public function get_module_name($module_id)
    -    {
    -        $query = $this->db->get_where('modules', array('module_id' => $module_id), 1);
    -        
    -        if($query->num_rows() == 1)
    -        {
    -            $row = $query->row();
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
    +
    +/**
    + * Module class
    + *
    + * @link    github.com/jekkos/opensourcepos
    + * @since   1.0
    + * @author  N/A
    + */
    +
    +class Module extends CI_Model
    +{
    +    public function get_module_name($module_id)
    +    {
    +        $query = $this->db->get_where('modules', array('module_id' => $module_id), 1);
     
    -            return $this->lang->line($row->name_lang_key);
    -        }
    -        
    -        return $this->lang->line('error_unknown');
    -    }
    -    
    -    public function get_module_desc($module_id)
    -    {
    -        $query = $this->db->get_where('modules', array('module_id' => $module_id), 1);
    +        if($query->num_rows() == 1)
    +        {
    +            $row = $query->row();
    +
    +            return $this->lang->line($row->name_lang_key);
    +        }
    +
    +        return $this->lang->line('error_unknown');
    +    }
     
    -        if($query->num_rows() == 1)
    -        {
    -            $row = $query->row();
    +    public function get_module_desc($module_id)
    +    {
    +        $query = $this->db->get_where('modules', array('module_id' => $module_id), 1);
     
    -            return $this->lang->line($row->desc_lang_key);
    -        }
    -    
    -        return $this->lang->line('error_unknown');  
    -    }
    -    
    -    public function get_all_permissions()
    -    {
    -        $this->db->from('permissions');
    +        if($query->num_rows() == 1)
    +        {
    +            $row = $query->row();
    +
    +            return $this->lang->line($row->desc_lang_key);
    +        }
    +
    +        return $this->lang->line('error_unknown');
    +    }
     
    -        return $this->db->get();
    -    }
    -    
    -    public function get_all_subpermissions()
    -    {
    -        $this->db->from('permissions');
    -        $this->db->join('modules', 'modules.module_id = permissions.module_id');
    -        // can't quote the parameters correctly when using different operators..
    -        $this->db->where($this->db->dbprefix('modules') . '.module_id!=', 'permission_id', FALSE);
    -
    -        return $this->db->get();
    -    }
    -    
    -    public function get_all_modules()
    -    {
    -        $this->db->from('modules');
    -        $this->db->order_by('sort', 'asc');
    -
    -        return $this->db->get();        
    -    }
    -    
    -    public function get_allowed_modules($person_id)
    -    {
    -        $this->db->from('modules');
    -        $this->db->join('permissions', 'permissions.permission_id = modules.module_id');
    -        $this->db->join('grants', 'permissions.permission_id = grants.permission_id');
    -        $this->db->where('person_id', $person_id);
    -        $this->db->order_by('sort', 'asc');
    -
    -        return $this->db->get();        
    -    }
    -}
    -?>
    -
    +
    public function get_all_permissions() + { + $this->db->from('permissions'); + + return $this->db->get(); + } + + public function get_all_subpermissions() + { + $this->db->from('permissions'); + $this->db->join('modules', 'modules.module_id = permissions.module_id'); + // can't quote the parameters correctly when using different operators.. + $this->db->where($this->db->dbprefix('modules') . '.module_id!=', 'permission_id', FALSE); + + return $this->db->get(); + } + + public function get_all_modules() + { + $this->db->from('modules'); + $this->db->order_by('sort', 'asc'); + + return $this->db->get(); + } + + public function get_allowed_modules($person_id) + { + $this->db->from('modules'); + $this->db->join('permissions', 'permissions.permission_id = modules.module_id'); + $this->db->join('grants', 'permissions.permission_id = grants.permission_id'); + $this->db->where('person_id', $person_id); + $this->db->order_by('sort', 'asc'); + + return $this->db->get(); + } +} +?> +
    - + diff --git a/docs/source-class-No_Access.html b/docs/source-class-No_Access.html index 2a689579f..5f32aa9be 100644 --- a/docs/source-class-No_Access.html +++ b/docs/source-class-No_Access.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,27 +207,23 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     
     class No_Access extends CI_Controller 
     {
    -    public function __construct()
    +    public function index($module_id = '', $permission_id = '')
         {
    -        parent::__construct();
    -    }
    -    
    -    public function index($module_id = '', $permission_id = '')
    -    {
    -        $data['module_name']   = $this->Module->get_module_name($module_id);
    -        $data['permission_id'] = $permission_id;
    -        
    -        $data = $this->security->xss_clean($data);
    -        
    -        $this->load->view('no_access', $data);
    -    }
    -}
    -?>
    + $data['module_name'] = $this->Module->get_module_name($module_id); + $data['permission_id'] = $permission_id; + + $data = $this->security->xss_clean($data); + + $this->load->view('no_access', $data); + } +} +?> + - + diff --git a/docs/source-class-Person.html b/docs/source-class-Person.html index 41a3d8fea..503bd0a0a 100644 --- a/docs/source-class-Person.html +++ b/docs/source-class-Person.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -206,10 +208,10 @@
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 
    -
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
     /**
    - * Base class for People classes.
    + * Base class for People classes
      *
      * @link    github.com/jekkos/opensourcepos
      * @since   1.0
    @@ -411,6 +413,6 @@
     
     
     
    -
    +
     
     
    diff --git a/docs/source-class-Persons.html b/docs/source-class-Persons.html
    index 886edddc8..ed18c83b9 100644
    --- a/docs/source-class-Persons.html
    +++ b/docs/source-class-Persons.html
    @@ -80,6 +80,8 @@
     				
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,7 +207,7 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     
     require_once("Secure_Controller.php");
    @@ -245,40 +247,23 @@
         }
     
         /*
    -    Capitalize segments of a name, and put the rest into lower case. You can pass the characters you want to use as delimiters.
    -
    -    i.e. <?php echo nameize("john o'grady-smith"); ?>
    +    Capitalize segments of a name, and put the rest into lower case.
    +    You can pass the characters you want to use as delimiters as exceptions.
    +    The function supports UTF-8 string.
     
    -    returns John O'Grady-Smith
    -    */
    -    protected function nameize($str, $a_char = array("'", "-", " "))
    -    {   
    -        // $str contains the complete raw name string
    -        // $a_char is an array containing the characters we use as separators for capitalization. If you don't pass anything, there are three in there as default.
    -        $string = strtolower($str);
    -
    -        foreach($a_char as $temp)
    -        {
    -            $pos = strpos($string, $temp);
    -            if($pos)
    -            {
    -                // we are in the loop because we found one of the special characters in the array, so lets split it up into chunks and capitalize each one.
    -                $mend = '';
    -                $a_split = explode($temp, $string);
    -                foreach($a_split as $temp2)
    -                {
    -                    // capitalize each portion of the string which was separated at a special character
    -                    $mend .= ucfirst($temp2).$temp;
    -                }
    -                $string = substr($mend, 0, -1);
    -            }           
    -        }
    -
    -        return ucfirst($string);
    -    }
    -}
    -?>
    -
    +
    Example: + i.e. <?php echo nameize("john o'grady-smith"); ?> + + returns John O'Grady-Smith + */ + + protected function nameize($string) + { + return str_name_case($string); + } +} +?> +
    - + diff --git a/docs/source-class-Receiving.html b/docs/source-class-Receiving.html index 6e7d7e59d..491cca681 100644 --- a/docs/source-class-Receiving.html +++ b/docs/source-class-Receiving.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,291 +207,300 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 
    -
    <?php
    -class Receiving extends CI_Model
    -{
    -    public function get_info($receiving_id)
    -    {
    -        $this->db->from('receivings');
    -        $this->db->join('people', 'people.person_id = receivings.supplier_id', 'LEFT');
    -        $this->db->join('suppliers', 'suppliers.person_id = receivings.supplier_id', 'LEFT');
    -        $this->db->where('receiving_id', $receiving_id);
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
    +
    +/**
    + * Receiving class
    + *
    + * @link    github.com/jekkos/opensourcepos
    + * @since   1.0
    + * @author  N/A
    + */
     
    -        return $this->db->get();
    -    }
    -
    -    public function get_receiving_by_reference($reference)
    -    {
    -        $this->db->from('receivings');
    -        $this->db->where('reference', $reference);
    -
    -        return $this->db->get();
    -    }
    -
    -    public function is_valid_receipt($receipt_receiving_id)
    -    {
    -        if(!empty($receipt_receiving_id))
    -        {
    -            //RECV #
    -            $pieces = explode(' ', $receipt_receiving_id);
    -
    -            if(count($pieces) == 2 && preg_match('/(RECV|KIT)/', $pieces[0]))
    -            {
    -                return $this->exists($pieces[1]);
    -            }
    -            else
    -            {
    -                return $this->get_receiving_by_reference($receipt_receiving_id)->num_rows() > 0;
    -            }
    -        }
    -
    -        return FALSE;
    -    }
    -
    -    public function exists($receiving_id)
    -    {
    -        $this->db->from('receivings');
    -        $this->db->where('receiving_id', $receiving_id);
    -
    -        return ($this->db->get()->num_rows() == 1);
    -    }
    -
    -    public function update($receiving_data, $receiving_id)
    -    {
    -        $this->db->where('receiving_id', $receiving_id);
    -
    -        return $this->db->update('receivings', $receiving_data);
    -    }
    -
    -    public function save($items, $supplier_id, $employee_id, $comment, $reference, $payment_type, $receiving_id = FALSE)
    -    {
    -        if(count($items) == 0)
    -        {
    -            return -1;
    -        }
    -
    -        $receivings_data = array(
    -            'receiving_time' => date('Y-m-d H:i:s'),
    -            'supplier_id' => $this->Supplier->exists($supplier_id) ? $supplier_id : NULL,
    -            'employee_id' => $employee_id,
    -            'payment_type' => $payment_type,
    -            'comment' => $comment,
    -            'reference' => $reference
    -        );
    +class Receiving extends CI_Model
    +{
    +    public function get_info($receiving_id)
    +    {
    +        $this->db->from('receivings');
    +        $this->db->join('people', 'people.person_id = receivings.supplier_id', 'LEFT');
    +        $this->db->join('suppliers', 'suppliers.person_id = receivings.supplier_id', 'LEFT');
    +        $this->db->where('receiving_id', $receiving_id);
    +
    +        return $this->db->get();
    +    }
    +
    +    public function get_receiving_by_reference($reference)
    +    {
    +        $this->db->from('receivings');
    +        $this->db->where('reference', $reference);
    +
    +        return $this->db->get();
    +    }
    +
    +    public function is_valid_receipt($receipt_receiving_id)
    +    {
    +        if(!empty($receipt_receiving_id))
    +        {
    +            //RECV #
    +            $pieces = explode(' ', $receipt_receiving_id);
    +
    +            if(count($pieces) == 2 && preg_match('/(RECV|KIT)/', $pieces[0]))
    +            {
    +                return $this->exists($pieces[1]);
    +            }
    +            else
    +            {
    +                return $this->get_receiving_by_reference($receipt_receiving_id)->num_rows() > 0;
    +            }
    +        }
    +
    +        return FALSE;
    +    }
    +
    +    public function exists($receiving_id)
    +    {
    +        $this->db->from('receivings');
    +        $this->db->where('receiving_id', $receiving_id);
    +
    +        return ($this->db->get()->num_rows() == 1);
    +    }
    +
    +    public function update($receiving_data, $receiving_id)
    +    {
    +        $this->db->where('receiving_id', $receiving_id);
    +
    +        return $this->db->update('receivings', $receiving_data);
    +    }
    +
    +    public function save($items, $supplier_id, $employee_id, $comment, $reference, $payment_type, $receiving_id = FALSE)
    +    {
    +        if(count($items) == 0)
    +        {
    +            return -1;
    +        }
     
    -        //Run these queries as a transaction, we want to make sure we do all or nothing
    -        $this->db->trans_start();
    -
    -        $this->db->insert('receivings', $receivings_data);
    -        $receiving_id = $this->db->insert_id();
    -
    -        foreach($items as $line=>$item)
    -        {
    -            $cur_item_info = $this->Item->get_info($item['item_id']);
    -
    -            $receivings_items_data = array(
    -                'receiving_id' => $receiving_id,
    -                'item_id' => $item['item_id'],
    -                'line' => $item['line'],
    -                'description' => $item['description'],
    -                'serialnumber' => $item['serialnumber'],
    -                'quantity_purchased' => $item['quantity'],
    -                'receiving_quantity' => $item['receiving_quantity'],
    -                'discount_percent' => $item['discount'],
    -                'item_cost_price' => $cur_item_info->cost_price,
    -                'item_unit_price' => $item['price'],
    -                'item_location' => $item['item_location']
    -            );
    -
    -            $this->db->insert('receivings_items', $receivings_items_data);
    -
    -            $items_received = $item['receiving_quantity'] != 0 ? $item['quantity'] * $item['receiving_quantity'] : $item['quantity'];
    -
    -            // update cost price, if changed AND is set in config as wanted
    -            if($cur_item_info->cost_price != $item['price'] && $this->config->item('receiving_calculate_average_price') != FALSE)
    -            {
    -                $this->Item->change_cost_price($item['item_id'], $items_received, $item['price'], $cur_item_info->cost_price);
    -            }
    -
    -            //Update stock quantity
    -            $item_quantity = $this->Item_quantity->get_item_quantity($item['item_id'], $item['item_location']);
    -            $this->Item_quantity->save(array('quantity' => $item_quantity->quantity + $items_received, 'item_id' => $item['item_id'],
    -                                              'location_id' => $item['item_location']), $item['item_id'], $item['item_location']);
    -
    -            $recv_remarks = 'RECV ' . $receiving_id;
    -            $inv_data = array(
    -                'trans_date' => date('Y-m-d H:i:s'),
    -                'trans_items' => $item['item_id'],
    -                'trans_user' => $employee_id,
    -                'trans_location' => $item['item_location'],
    -                'trans_comment' => $recv_remarks,
    -                'trans_inventory' => $items_received
    -            );
    -
    -            $this->Inventory->insert($inv_data);
    -
    -            $supplier = $this->Supplier->get_info($supplier_id);
    -        }
    -
    -        $this->db->trans_complete();
    -
    -        if($this->db->trans_status() === FALSE)
    -        {
    -            return -1;
    -        }
    -
    -        return $receiving_id;
    -    }
    -
    -    public function delete_list($receiving_ids, $employee_id, $update_inventory = TRUE)
    -    {
    -        $success = TRUE;
    -
    -        // start a transaction to assure data integrity
    -        $this->db->trans_start();
    -
    -        foreach($receiving_ids as $receiving_id)
    -        {
    -            $success &= $this->delete($receiving_id, $employee_id, $update_inventory);
    -        }
    -
    -        // execute transaction
    -        $this->db->trans_complete();
    -
    -        $success &= $this->db->trans_status();
    -
    -        return $success;
    -    }
    -
    -    public function delete($receiving_id, $employee_id, $update_inventory = TRUE)
    -    {
    -        // start a transaction to assure data integrity
    -        $this->db->trans_start();
    -
    -        if($update_inventory)
    -        {
    -            // defect, not all item deletions will be undone??
    -            // get array with all the items involved in the sale to update the inventory tracking
    -            $items = $this->get_receiving_items($receiving_id)->result_array();
    -            foreach($items as $item)
    -            {
    -                // create query to update inventory tracking
    -                $inv_data = array(
    -                    'trans_date' => date('Y-m-d H:i:s'),
    -                    'trans_items' => $item['item_id'],
    -                    'trans_user' => $employee_id,
    -                    'trans_comment' => 'Deleting receiving ' . $receiving_id,
    -                    'trans_location' => $item['item_location'],
    -                    'trans_inventory' => $item['quantity_purchased'] * -1
    -                );
    -                // update inventory
    -                $this->Inventory->insert($inv_data);
    -
    -                // update quantities
    -                $this->Item_quantity->change_quantity($item['item_id'], $item['item_location'], $item['quantity_purchased'] * -1);
    -            }
    -        }
    -
    -        // delete all items
    -        $this->db->delete('receivings_items', array('receiving_id' => $receiving_id));
    -        // delete sale itself
    -        $this->db->delete('receivings', array('receiving_id' => $receiving_id));
    -
    -        // execute transaction
    -        $this->db->trans_complete();
    -    
    -        return $this->db->trans_status();
    -    }
    -
    -    public function get_receiving_items($receiving_id)
    -    {
    -        $this->db->from('receivings_items');
    -        $this->db->where('receiving_id', $receiving_id);
    -
    -        return $this->db->get();
    -    }
    -    
    -    public function get_supplier($receiving_id)
    -    {
    -        $this->db->from('receivings');
    -        $this->db->where('receiving_id', $receiving_id);
    -
    -        return $this->Supplier->get_info($this->db->get()->row()->supplier_id);
    -    }
    -
    -    public function get_payment_options()
    -    {
    -        return array(
    -            $this->lang->line('sales_cash') => $this->lang->line('sales_cash'),
    -            $this->lang->line('sales_check') => $this->lang->line('sales_check'),
    -            $this->lang->line('sales_debit') => $this->lang->line('sales_debit'),
    -            $this->lang->line('sales_credit') => $this->lang->line('sales_credit')
    -        );
    -    }
    -
    -    /*
    -    We create a temp table that allows us to do easy report/receiving queries
    -    */
    -    public function create_temp_table(array $inputs)
    -    {
    -        if(empty($inputs['receiving_id']))
    -        {
    -            if(empty($this->config->item('date_or_time_format')))
    -            {
    -                $where = 'WHERE DATE(receiving_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']);
    -            }
    -            else
    -            {
    -                $where = 'WHERE receiving_time BETWEEN ' . $this->db->escape(rawurldecode($inputs['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($inputs['end_date']));
    -            }
    -        }
    -        else
    -        {
    -            $where = 'WHERE receivings_items.receiving_id = ' . $this->db->escape($inputs['receiving_id']);
    -        }
    -
    -        $this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('receivings_items_temp') .
    -            ' (INDEX(receiving_date), INDEX(receiving_time), INDEX(receiving_id))
    -            (
    -                SELECT 
    -                    MAX(DATE(receiving_time)) AS receiving_date,
    -                    MAX(receiving_time) AS receiving_time,
    -                    receivings_items.receiving_id,
    -                    MAX(comment) AS comment,
    -                    MAX(item_location) AS item_location,
    -                    MAX(reference) AS reference,
    -                    MAX(payment_type) AS payment_type,
    -                    MAX(employee_id) AS employee_id, 
    -                    items.item_id,
    -                    MAX(receivings.supplier_id) AS supplier_id,
    -                    MAX(quantity_purchased) AS quantity_purchased,
    -                    MAX(receivings_items.receiving_quantity) AS receiving_quantity,
    -                    MAX(item_cost_price) AS item_cost_price,
    -                    MAX(item_unit_price) AS item_unit_price,
    -                    MAX(discount_percent) AS discount_percent,
    -                    receivings_items.line,
    -                    MAX(serialnumber) AS serialnumber,
    -                    MAX(receivings_items.description) AS description,
    -                    MAX(item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent / 100) AS subtotal,
    -                    MAX(item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent / 100) AS total,
    -                    MAX((item_unit_price * quantity_purchased - item_unit_price * quantity_purchased * discount_percent / 100) - (item_cost_price * quantity_purchased)) AS profit,
    -                    MAX(item_cost_price * quantity_purchased) AS cost
    -                FROM ' . $this->db->dbprefix('receivings_items') . ' AS receivings_items
    -                INNER JOIN ' . $this->db->dbprefix('receivings') . ' AS receivings
    -                    ON receivings_items.receiving_id = receivings.receiving_id
    -                INNER JOIN ' . $this->db->dbprefix('items') . ' AS items
    -                    ON receivings_items.item_id = items.item_id
    -                ' . "
    -                $where
    -                " . '
    -                GROUP BY receivings_items.receiving_id, items.item_id, receivings_items.line
    -            )'
    -        );
    -    }
    -}
    -?>
    -
    +
    $receivings_data = array( + 'receiving_time' => date('Y-m-d H:i:s'), + 'supplier_id' => $this->Supplier->exists($supplier_id) ? $supplier_id : NULL, + 'employee_id' => $employee_id, + 'payment_type' => $payment_type, + 'comment' => $comment, + 'reference' => $reference + ); + + //Run these queries as a transaction, we want to make sure we do all or nothing + $this->db->trans_start(); + + $this->db->insert('receivings', $receivings_data); + $receiving_id = $this->db->insert_id(); + + foreach($items as $line=>$item) + { + $cur_item_info = $this->Item->get_info($item['item_id']); + + $receivings_items_data = array( + 'receiving_id' => $receiving_id, + 'item_id' => $item['item_id'], + 'line' => $item['line'], + 'description' => $item['description'], + 'serialnumber' => $item['serialnumber'], + 'quantity_purchased' => $item['quantity'], + 'receiving_quantity' => $item['receiving_quantity'], + 'discount_percent' => $item['discount'], + 'item_cost_price' => $cur_item_info->cost_price, + 'item_unit_price' => $item['price'], + 'item_location' => $item['item_location'] + ); + + $this->db->insert('receivings_items', $receivings_items_data); + + $items_received = $item['receiving_quantity'] != 0 ? $item['quantity'] * $item['receiving_quantity'] : $item['quantity']; + + // update cost price, if changed AND is set in config as wanted + if($cur_item_info->cost_price != $item['price'] && $this->config->item('receiving_calculate_average_price') != FALSE) + { + $this->Item->change_cost_price($item['item_id'], $items_received, $item['price'], $cur_item_info->cost_price); + } + + //Update stock quantity + $item_quantity = $this->Item_quantity->get_item_quantity($item['item_id'], $item['item_location']); + $this->Item_quantity->save(array('quantity' => $item_quantity->quantity + $items_received, 'item_id' => $item['item_id'], + 'location_id' => $item['item_location']), $item['item_id'], $item['item_location']); + + $recv_remarks = 'RECV ' . $receiving_id; + $inv_data = array( + 'trans_date' => date('Y-m-d H:i:s'), + 'trans_items' => $item['item_id'], + 'trans_user' => $employee_id, + 'trans_location' => $item['item_location'], + 'trans_comment' => $recv_remarks, + 'trans_inventory' => $items_received + ); + + $this->Inventory->insert($inv_data); + + $supplier = $this->Supplier->get_info($supplier_id); + } + + $this->db->trans_complete(); + + if($this->db->trans_status() === FALSE) + { + return -1; + } + + return $receiving_id; + } + + public function delete_list($receiving_ids, $employee_id, $update_inventory = TRUE) + { + $success = TRUE; + + // start a transaction to assure data integrity + $this->db->trans_start(); + + foreach($receiving_ids as $receiving_id) + { + $success &= $this->delete($receiving_id, $employee_id, $update_inventory); + } + + // execute transaction + $this->db->trans_complete(); + + $success &= $this->db->trans_status(); + + return $success; + } + + public function delete($receiving_id, $employee_id, $update_inventory = TRUE) + { + // start a transaction to assure data integrity + $this->db->trans_start(); + + if($update_inventory) + { + // defect, not all item deletions will be undone?? + // get array with all the items involved in the sale to update the inventory tracking + $items = $this->get_receiving_items($receiving_id)->result_array(); + foreach($items as $item) + { + // create query to update inventory tracking + $inv_data = array( + 'trans_date' => date('Y-m-d H:i:s'), + 'trans_items' => $item['item_id'], + 'trans_user' => $employee_id, + 'trans_comment' => 'Deleting receiving ' . $receiving_id, + 'trans_location' => $item['item_location'], + 'trans_inventory' => $item['quantity_purchased'] * -1 + ); + // update inventory + $this->Inventory->insert($inv_data); + + // update quantities + $this->Item_quantity->change_quantity($item['item_id'], $item['item_location'], $item['quantity_purchased'] * -1); + } + } + + // delete all items + $this->db->delete('receivings_items', array('receiving_id' => $receiving_id)); + // delete sale itself + $this->db->delete('receivings', array('receiving_id' => $receiving_id)); + + // execute transaction + $this->db->trans_complete(); + + return $this->db->trans_status(); + } + + public function get_receiving_items($receiving_id) + { + $this->db->from('receivings_items'); + $this->db->where('receiving_id', $receiving_id); + + return $this->db->get(); + } + + public function get_supplier($receiving_id) + { + $this->db->from('receivings'); + $this->db->where('receiving_id', $receiving_id); + + return $this->Supplier->get_info($this->db->get()->row()->supplier_id); + } + + public function get_payment_options() + { + return array( + $this->lang->line('sales_cash') => $this->lang->line('sales_cash'), + $this->lang->line('sales_check') => $this->lang->line('sales_check'), + $this->lang->line('sales_debit') => $this->lang->line('sales_debit'), + $this->lang->line('sales_credit') => $this->lang->line('sales_credit') + ); + } + + /* + We create a temp table that allows us to do easy report/receiving queries + */ + public function create_temp_table(array $inputs) + { + if(empty($inputs['receiving_id'])) + { + if(empty($this->config->item('date_or_time_format'))) + { + $where = 'WHERE DATE(receiving_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']); + } + else + { + $where = 'WHERE receiving_time BETWEEN ' . $this->db->escape(rawurldecode($inputs['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($inputs['end_date'])); + } + } + else + { + $where = 'WHERE receivings_items.receiving_id = ' . $this->db->escape($inputs['receiving_id']); + } + + $this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('receivings_items_temp') . + ' (INDEX(receiving_date), INDEX(receiving_time), INDEX(receiving_id)) + ( + SELECT + MAX(DATE(receiving_time)) AS receiving_date, + MAX(receiving_time) AS receiving_time, + receivings_items.receiving_id, + MAX(comment) AS comment, + MAX(item_location) AS item_location, + MAX(reference) AS reference, + MAX(payment_type) AS payment_type, + MAX(employee_id) AS employee_id, + items.item_id, + MAX(receivings.supplier_id) AS supplier_id, + MAX(quantity_purchased) AS quantity_purchased, + MAX(receivings_items.receiving_quantity) AS receiving_quantity, + MAX(item_cost_price) AS item_cost_price, + MAX(item_unit_price) AS item_unit_price, + MAX(discount_percent) AS discount_percent, + receivings_items.line, + MAX(serialnumber) AS serialnumber, + MAX(receivings_items.description) AS description, + MAX(item_unit_price * quantity_purchased * receivings_items.receiving_quantity - item_unit_price * quantity_purchased * receivings_items.receiving_quantity * discount_percent / 100) AS subtotal, + MAX(item_unit_price * quantity_purchased * receivings_items.receiving_quantity - item_unit_price * quantity_purchased * receivings_items.receiving_quantity * discount_percent / 100) AS total, + MAX((item_unit_price * quantity_purchased * receivings_items.receiving_quantity - item_unit_price * quantity_purchased * receivings_items.receiving_quantity * discount_percent / 100) - (item_cost_price * quantity_purchased)) AS profit, + MAX(item_cost_price * quantity_purchased * receivings_items.receiving_quantity ) AS cost + FROM ' . $this->db->dbprefix('receivings_items') . ' AS receivings_items + INNER JOIN ' . $this->db->dbprefix('receivings') . ' AS receivings + ON receivings_items.receiving_id = receivings.receiving_id + INNER JOIN ' . $this->db->dbprefix('items') . ' AS items + ON receivings_items.item_id = items.item_id + ' . " + $where + " . ' + GROUP BY receivings_items.receiving_id, items.item_id, receivings_items.line + )' + ); + } +} +?> +
    - + diff --git a/docs/source-class-Receiving_lib.html b/docs/source-class-Receiving_lib.html index f67bf8ffc..d0363e220 100644 --- a/docs/source-class-Receiving_lib.html +++ b/docs/source-class-Receiving_lib.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,356 +207,366 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
    -class Receiving_lib
    -{
    -    private $CI;
    -
    -    public function __construct()
    -    {
    -        $this->CI =& get_instance();
    -    }
    -
    -    public function get_cart()
    -    {
    -        if(!$this->CI->session->userdata('recv_cart'))
    -        {
    -            $this->set_cart(array());
    -        }
    -
    -        return $this->CI->session->userdata('recv_cart');
    +/**
    + * Receiving library
    + *
    + * Library with utilities to manage receivings
    + *
    + * @link    github.com/jekkos/opensourcepos
    + * @since   1.0
    + * @author  N/A
    + */
    +
    +class Receiving_lib
    +{
    +    private $CI;
    +
    +    public function __construct()
    +    {
    +        $this->CI =& get_instance();
         }
     
    -    public function set_cart($cart_data)
    +    public function get_cart()
         {
    -        $this->CI->session->set_userdata('recv_cart', $cart_data);
    -    }
    -
    -    public function empty_cart()
    -    {
    -        $this->CI->session->unset_userdata('recv_cart');
    +        if(!$this->CI->session->userdata('recv_cart'))
    +        {
    +            $this->set_cart(array());
    +        }
    +
    +        return $this->CI->session->userdata('recv_cart');
         }
     
    -    public function get_supplier()
    +    public function set_cart($cart_data)
         {
    -        if(!$this->CI->session->userdata('recv_supplier'))
    -        {
    -            $this->set_supplier(-1);
    -        }
    -
    -        return $this->CI->session->userdata('recv_supplier');
    +        $this->CI->session->set_userdata('recv_cart', $cart_data);
    +    }
    +
    +    public function empty_cart()
    +    {
    +        $this->CI->session->unset_userdata('recv_cart');
         }
     
    -    public function set_supplier($supplier_id)
    +    public function get_supplier()
         {
    -        $this->CI->session->set_userdata('recv_supplier', $supplier_id);
    -    }
    -
    -    public function remove_supplier()
    -    {
    -        $this->CI->session->unset_userdata('recv_supplier');
    +        if(!$this->CI->session->userdata('recv_supplier'))
    +        {
    +            $this->set_supplier(-1);
    +        }
    +
    +        return $this->CI->session->userdata('recv_supplier');
         }
     
    -    public function get_mode()
    +    public function set_supplier($supplier_id)
         {
    -        if(!$this->CI->session->userdata('recv_mode'))
    -        {
    -            $this->set_mode('receive');
    -        }
    -
    -        return $this->CI->session->userdata('recv_mode');
    +        $this->CI->session->set_userdata('recv_supplier', $supplier_id);
    +    }
    +
    +    public function remove_supplier()
    +    {
    +        $this->CI->session->unset_userdata('recv_supplier');
         }
     
    -    public function set_mode($mode)
    +    public function get_mode()
         {
    -        $this->CI->session->set_userdata('recv_mode', $mode);
    -    }
    -    
    -    public function clear_mode()
    -    {
    -        $this->CI->session->unset_userdata('recv_mode');
    +        if(!$this->CI->session->userdata('recv_mode'))
    +        {
    +            $this->set_mode('receive');
    +        }
    +
    +        return $this->CI->session->userdata('recv_mode');
         }
     
    -    public function get_stock_source()
    +    public function set_mode($mode)
         {
    -        if(!$this->CI->session->userdata('recv_stock_source'))
    -        {
    -            $this->set_stock_source($this->CI->Stock_location->get_default_location_id());
    -        }
    -
    -        return $this->CI->session->userdata('recv_stock_source');
    +        $this->CI->session->set_userdata('recv_mode', $mode);
    +    }
    +    
    +    public function clear_mode()
    +    {
    +        $this->CI->session->unset_userdata('recv_mode');
         }
    -    
    -    public function get_comment()
    +
    +    public function get_stock_source()
         {
    -        // avoid returning a NULL that results in a 0 in the comment if nothing is set/available
    -        $comment = $this->CI->session->userdata('recv_comment');
    -
    -        return empty($comment) ? '' : $comment;
    -    }
    -    
    -    public function set_comment($comment)
    -    {
    -        $this->CI->session->set_userdata('recv_comment', $comment);
    -    }
    -    
    -    public function clear_comment()
    -    {
    -        $this->CI->session->unset_userdata('recv_comment');
    +        if(!$this->CI->session->userdata('recv_stock_source'))
    +        {
    +            $this->set_stock_source($this->CI->Stock_location->get_default_location_id());
    +        }
    +
    +        return $this->CI->session->userdata('recv_stock_source');
    +    }
    +    
    +    public function get_comment()
    +    {
    +        // avoid returning a NULL that results in a 0 in the comment if nothing is set/available
    +        $comment = $this->CI->session->userdata('recv_comment');
    +
    +        return empty($comment) ? '' : $comment;
         }
    -   
    -    public function get_reference()
    +    
    +    public function set_comment($comment)
         {
    -        return $this->CI->session->userdata('recv_reference');
    +        $this->CI->session->set_userdata('recv_comment', $comment);
         }
         
    -    public function set_reference($reference)
    +    public function clear_comment()
         {
    -        $this->CI->session->set_userdata('recv_reference', $reference);
    +        $this->CI->session->unset_userdata('recv_comment');
         }
    -    
    -    public function clear_reference()
    +   
    +    public function get_reference()
         {
    -        $this->CI->session->unset_userdata('recv_reference');
    +        return $this->CI->session->userdata('recv_reference');
         }
         
    -    public function is_print_after_sale()
    +    public function set_reference($reference)
         {
    -        return $this->CI->session->userdata('recv_print_after_sale') == 'true' ||
    -                $this->CI->session->userdata('recv_print_after_sale') == '1';
    -    }
    -    
    -    public function set_print_after_sale($print_after_sale)
    -    {
    -        return $this->CI->session->set_userdata('recv_print_after_sale', $print_after_sale);
    -    }
    -    
    -    public function set_stock_source($stock_source)
    -    {
    -        $this->CI->session->set_userdata('recv_stock_source', $stock_source);
    +        $this->CI->session->set_userdata('recv_reference', $reference);
    +    }
    +    
    +    public function clear_reference()
    +    {
    +        $this->CI->session->unset_userdata('recv_reference');
    +    }
    +    
    +    public function is_print_after_sale()
    +    {
    +        return $this->CI->session->userdata('recv_print_after_sale') == 'true' ||
    +                $this->CI->session->userdata('recv_print_after_sale') == '1';
         }
         
    -    public function clear_stock_source()
    +    public function set_print_after_sale($print_after_sale)
         {
    -        $this->CI->session->unset_userdata('recv_stock_source');
    +        return $this->CI->session->set_userdata('recv_print_after_sale', $print_after_sale);
         }
         
    -    public function get_stock_destination()
    +    public function set_stock_source($stock_source)
         {
    -        if(!$this->CI->session->userdata('recv_stock_destination'))
    -        {
    -            $this->set_stock_destination($this->CI->Stock_location->get_default_location_id());
    -        }
    -
    -        return $this->CI->session->userdata('recv_stock_destination');
    +        $this->CI->session->set_userdata('recv_stock_source', $stock_source);
    +    }
    +    
    +    public function clear_stock_source()
    +    {
    +        $this->CI->session->unset_userdata('recv_stock_source');
         }
    -
    -    public function set_stock_destination($stock_destination)
    +    
    +    public function get_stock_destination()
         {
    -        $this->CI->session->set_userdata('recv_stock_destination', $stock_destination);
    -    }
    -    
    -    public function clear_stock_destination()
    -    {
    -        $this->CI->session->unset_userdata('recv_stock_destination');
    +        if(!$this->CI->session->userdata('recv_stock_destination'))
    +        {
    +            $this->set_stock_destination($this->CI->Stock_location->get_default_location_id());
    +        }
    +
    +        return $this->CI->session->userdata('recv_stock_destination');
         }
     
    -    public function add_item($item_id, $quantity = 1, $item_location = NULL, $discount = 0, $price = NULL, $description = NULL, $serialnumber = NULL, $receiving_quantity = NULL, $include_deleted = FALSE)
    +    public function set_stock_destination($stock_destination)
         {
    -        //make sure item exists in database.
    -        if(!$this->CI->Item->exists($item_id, $include_deleted))
    -        {
    -            //try to get item id given an item_number
    -            $item_id = $this->CI->Item->get_item_id($item_id, $include_deleted);
    -
    -            if(!$item_id)
    -            {
    -                return FALSE;
    -            }
    -        }
    -
    -        //Get items in the receiving so far.
    -        $items = $this->get_cart();
    -
    -        //We need to loop through all items in the cart.
    -        //If the item is already there, get it's key($updatekey).
    -        //We also need to get the next key that we are going to use in case we need to add the
    -        //item to the list. Since items can be deleted, we can't use a count. we use the highest key + 1.
    -
    -        $maxkey = 0;                    //Highest key so far
    -        $itemalreadyinsale = FALSE;     //We did not find the item yet.
    -        $insertkey = 0;                 //Key to use for new entry.
    -        $updatekey = 0;                 //Key to use to update(quantity)
    +        $this->CI->session->set_userdata('recv_stock_destination', $stock_destination);
    +    }
    +    
    +    public function clear_stock_destination()
    +    {
    +        $this->CI->session->unset_userdata('recv_stock_destination');
    +    }
    +
    +    public function add_item($item_id, $quantity = 1, $item_location = NULL, $discount = 0, $price = NULL, $description = NULL, $serialnumber = NULL, $receiving_quantity = NULL, $include_deleted = FALSE)
    +    {
    +        //make sure item exists in database.
    +        if(!$this->CI->Item->exists($item_id, $include_deleted))
    +        {
    +            //try to get item id given an item_number
    +            $item_id = $this->CI->Item->get_item_id($item_id, $include_deleted);
    +
    +            if(!$item_id)
    +            {
    +                return FALSE;
    +            }
    +        }
    +
    +        //Get items in the receiving so far.
    +        $items = $this->get_cart();
     
    -        foreach($items as $item)
    -        {
    -            //We primed the loop so maxkey is 0 the first time.
    -            //Also, we have stored the key in the element itself so we can compare.
    -            //There is an array public function to get the associated key for an element, but I like it better
    -            //like that!
    -
    -            if($maxkey <= $item['line'])
    -            {
    -                $maxkey = $item['line'];
    -            }
    -
    -            if($item['item_id'] == $item_id && $item['item_location'] == $item_location)
    -            {
    -                $itemalreadyinsale = TRUE;
    -                $updatekey = $item['line'];
    -            }
    -        }
    -
    -        $insertkey = $maxkey+1;
    -        $item_info = $this->CI->Item->get_info($item_id,$item_location);
    -        //array records are identified by $insertkey and item_id is just another field.
    -        $price = $price != NULL ? $price : $item_info->cost_price;
    -        $item = array($insertkey => array(
    -                'item_id' => $item_id,
    -                'item_location' => $item_location,
    -                'stock_name' => $this->CI->Stock_location->get_location_name($item_location),
    -                'line' => $insertkey,
    -                'name' => $item_info->name,
    -                'description' => $description!=NULL ? $description: $item_info->description,
    -                'serialnumber' => $serialnumber!=NULL ? $serialnumber: '',
    -                'allow_alt_description' => $item_info->allow_alt_description,
    -                'is_serialized' => $item_info->is_serialized,
    -                'quantity' => $quantity,
    -                'discount' => $discount,
    -                'in_stock' => $this->CI->Item_quantity->get_item_quantity($item_id, $item_location)->quantity,
    -                'price' => $price,
    -                'receiving_quantity' => $receiving_quantity!=NULL ? $receiving_quantity : $item_info->receiving_quantity,
    -                'total' => $this->get_item_total($quantity, $price, $discount)
    -            )
    -        );
    -
    -        //Item already exists
    -        if($itemalreadyinsale)
    -        {
    -            $items[$updatekey]['quantity'] += $quantity;
    -            $items[$updatekey]['total'] = $this->get_item_total($items[$updatekey]['quantity'], $price, $discount);
    -        }
    -        else
    -        {
    -            //add to existing array
    -            $items += $item;
    -        }
    -
    -        $this->set_cart($items);
    -
    -        return TRUE;
    -    }
    -
    -    public function edit_item($line, $description, $serialnumber, $quantity, $discount, $price)
    -    {
    -        $items = $this->get_cart();
    -        if(isset($items[$line]))
    -        {
    -            $line = &$items[$line];
    -            $line['description'] = $description;
    -            $line['serialnumber'] = $serialnumber;
    -            $line['quantity'] = $quantity;
    -            $line['discount'] = $discount;
    -            $line['price'] = $price;
    -            $line['total'] = $this->get_item_total($quantity, $price, $discount); 
    -            $this->set_cart($items);
    -        }
    -
    -        return FALSE;
    -    }
    -
    -    public function delete_item($line)
    -    {
    -        $items = $this->get_cart();
    -        unset($items[$line]);
    -        $this->set_cart($items);
    -    }
    +        //We need to loop through all items in the cart.
    +        //If the item is already there, get it's key($updatekey).
    +        //We also need to get the next key that we are going to use in case we need to add the
    +        //item to the list. Since items can be deleted, we can't use a count. we use the highest key + 1.
    +
    +        $maxkey = 0;                    //Highest key so far
    +        $itemalreadyinsale = FALSE;     //We did not find the item yet.
    +        $insertkey = 0;                 //Key to use for new entry.
    +        $updatekey = 0;                 //Key to use to update(quantity)
    +
    +        foreach($items as $item)
    +        {
    +            //We primed the loop so maxkey is 0 the first time.
    +            //Also, we have stored the key in the element itself so we can compare.
    +            //There is an array public function to get the associated key for an element, but I like it better
    +            //like that!
    +
    +            if($maxkey <= $item['line'])
    +            {
    +                $maxkey = $item['line'];
    +            }
    +
    +            if($item['item_id'] == $item_id && $item['item_location'] == $item_location)
    +            {
    +                $itemalreadyinsale = TRUE;
    +                $updatekey = $item['line'];
    +            }
    +        }
    +
    +        $insertkey = $maxkey+1;
    +        $item_info = $this->CI->Item->get_info($item_id,$item_location);
    +        //array records are identified by $insertkey and item_id is just another field.
    +        $price = $price != NULL ? $price : $item_info->cost_price;
    +        $item = array($insertkey => array(
    +                'item_id' => $item_id,
    +                'item_location' => $item_location,
    +                'stock_name' => $this->CI->Stock_location->get_location_name($item_location),
    +                'line' => $insertkey,
    +                'name' => $item_info->name,
    +                'description' => $description!=NULL ? $description: $item_info->description,
    +                'serialnumber' => $serialnumber!=NULL ? $serialnumber: '',
    +                'allow_alt_description' => $item_info->allow_alt_description,
    +                'is_serialized' => $item_info->is_serialized,
    +                'quantity' => $quantity,
    +                'discount' => $discount,
    +                'in_stock' => $this->CI->Item_quantity->get_item_quantity($item_id, $item_location)->quantity,
    +                'price' => $price,
    +                'receiving_quantity' => $receiving_quantity!=NULL ? $receiving_quantity : $item_info->receiving_quantity,
    +                'total' => $this->get_item_total($quantity, $price, $discount, $receiving_quantity)
    +            )
    +        );
    +
    +        //Item already exists
    +        if($itemalreadyinsale)
    +        {
    +            $items[$updatekey]['quantity'] += $quantity;
    +            $items[$updatekey]['total'] = $this->get_item_total($items[$updatekey]['quantity'], $price, $discount);
    +        }
    +        else
    +        {
    +            //add to existing array
    +            $items += $item;
    +        }
    +
    +        $this->set_cart($items);
    +
    +        return TRUE;
    +    }
    +
    +    public function edit_item($line, $description, $serialnumber, $quantity, $discount, $price)
    +    {
    +        $items = $this->get_cart();
    +        if(isset($items[$line]))
    +        {
    +            $line = &$items[$line];
    +            $line['description'] = $description;
    +            $line['serialnumber'] = $serialnumber;
    +            $line['quantity'] = $quantity;
    +            $line['discount'] = $discount;
    +            $line['price'] = $price;
    +            $line['total'] = $this->get_item_total($quantity, $price, $discount); 
    +            $this->set_cart($items);
    +        }
     
    -    public function return_entire_receiving($receipt_receiving_id)
    -    {
    -        //RECV #
    -        $pieces = explode(' ', $receipt_receiving_id);
    -        if(preg_match("/(RECV|KIT)/", $pieces[0]))
    -        {
    -            $receiving_id = $pieces[1];
    -        } 
    -        else 
    -        {
    -            $receiving_id = $this->CI->Receiving->get_receiving_by_reference($receipt_receiving_id)->row()->receiving_id;
    -        }
    -
    -        $this->empty_cart();
    -        $this->remove_supplier();
    -        $this->clear_comment();
    -
    -        foreach($this->CI->Receiving->get_receiving_items($receiving_id)->result() as $row)
    -        {
    -            $this->add_item($row->item_id, -$row->quantity_purchased, $row->item_location, $row->discount_percent, $row->item_unit_price, $row->description, $row->serialnumber, $row->receiving_quantity, TRUE);
    -        }
    -
    -        $this->set_supplier($this->CI->Receiving->get_supplier($receiving_id)->person_id);
    -    }
    -
    -    public function add_item_kit($external_item_kit_id, $item_location)
    -    {
    -        //KIT #
    -        $pieces = explode(' ',$external_item_kit_id);
    -        $item_kit_id = $pieces[1];
    -        
    -        foreach($this->CI->Item_kit_items->get_info($item_kit_id) as $item_kit_item)
    -        {
    -            $this->add_item($item_kit_item['item_id'],$item_kit_item['quantity'], $item_location);
    -        }
    -    }
    -
    -    public function copy_entire_receiving($receiving_id)
    -    {
    -        $this->empty_cart();
    -        $this->remove_supplier();
    -
    -        foreach($this->CI->Receiving->get_receiving_items($receiving_id)->result() as $row)
    -        {
    -            $this->add_item($row->item_id, $row->quantity_purchased, $row->item_location, $row->discount_percent, $row->item_unit_price, $row->description, $row->serialnumber, $row->receiving_quantity, TRUE);
    -        }
    +        return FALSE;
    +    }
    +
    +    public function delete_item($line)
    +    {
    +        $items = $this->get_cart();
    +        unset($items[$line]);
    +        $this->set_cart($items);
    +    }
    +
    +    public function return_entire_receiving($receipt_receiving_id)
    +    {
    +        //RECV #
    +        $pieces = explode(' ', $receipt_receiving_id);
    +        if(preg_match("/(RECV|KIT)/", $pieces[0]))
    +        {
    +            $receiving_id = $pieces[1];
    +        } 
    +        else 
    +        {
    +            $receiving_id = $this->CI->Receiving->get_receiving_by_reference($receipt_receiving_id)->row()->receiving_id;
    +        }
    +
    +        $this->empty_cart();
    +        $this->remove_supplier();
    +        $this->clear_comment();
    +
    +        foreach($this->CI->Receiving->get_receiving_items($receiving_id)->result() as $row)
    +        {
    +            $this->add_item($row->item_id, -$row->quantity_purchased, $row->item_location, $row->discount_percent, $row->item_unit_price, $row->description, $row->serialnumber, $row->receiving_quantity, TRUE);
    +        }
    +
    +        $this->set_supplier($this->CI->Receiving->get_supplier($receiving_id)->person_id);
    +    }
    +
    +    public function add_item_kit($external_item_kit_id, $item_location)
    +    {
    +        //KIT #
    +        $pieces = explode(' ',$external_item_kit_id);
    +        $item_kit_id = $pieces[1];
    +        
    +        foreach($this->CI->Item_kit_items->get_info($item_kit_id) as $item_kit_item)
    +        {
    +            $this->add_item($item_kit_item['item_id'],$item_kit_item['quantity'], $item_location);
    +        }
    +    }
     
    -        $this->set_supplier($this->CI->Receiving->get_supplier($receiving_id)->person_id);
    -        //$this->set_reference($this->CI->Receiving->get_info($receiving_id)->row()->reference);
    -    }
    -
    -    public function clear_all()
    -    {
    -        $this->clear_mode();
    -        $this->empty_cart();
    -        $this->remove_supplier();
    -        $this->clear_comment();
    -        $this->clear_reference();
    -    }
    -
    -    public function get_item_total($quantity, $price, $discount_percentage)
    -    {
    -        $total = bcmul($quantity, $price);
    -        $discount_fraction = bcdiv($discount_percentage, 100);
    -        $discount_amount = bcmul($total, $discount_fraction);
    -
    -        return bcsub($total, $discount_amount);
    -    }
    -
    -    public function get_total()
    -    {
    -        $total = 0;
    -        foreach($this->get_cart() as $item)
    -        {
    -            $total = bcadd($total, $this->get_item_total($item['quantity'], $item['price'], $item['discount']));
    -        }
    -        
    -        return $total;
    -    }
    -}
    -
    -?>
    -
    +
    public function copy_entire_receiving($receiving_id) + { + $this->empty_cart(); + $this->remove_supplier(); + + foreach($this->CI->Receiving->get_receiving_items($receiving_id)->result() as $row) + { + $this->add_item($row->item_id, $row->quantity_purchased, $row->item_location, $row->discount_percent, $row->item_unit_price, $row->description, $row->serialnumber, $row->receiving_quantity, TRUE); + } + + $this->set_supplier($this->CI->Receiving->get_supplier($receiving_id)->person_id); + //$this->set_reference($this->CI->Receiving->get_info($receiving_id)->row()->reference); + } + + public function clear_all() + { + $this->clear_mode(); + $this->empty_cart(); + $this->remove_supplier(); + $this->clear_comment(); + $this->clear_reference(); + } + + public function get_item_total($quantity, $price, $discount_percentage) + { + $total = bcmul($quantity, $price); + $discount_fraction = bcdiv($discount_percentage, 100); + $discount_amount = bcmul($total, $discount_fraction); + + return bcsub($total, $discount_amount); + } + + public function get_total() + { + $total = 0; + foreach($this->get_cart() as $item) + { + $total = bcadd($total, $this->get_item_total(($item['quantity']* $item['receiving_quantity']), $item['price'], $item['discount'])); + } + + return $total; + } +} + +?> +
    - + diff --git a/docs/source-class-Receivings.html b/docs/source-class-Receivings.html index b74e48037..585c94541 100644 --- a/docs/source-class-Receivings.html +++ b/docs/source-class-Receivings.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -617,6 +619,6 @@ - + diff --git a/docs/source-class-Report.html b/docs/source-class-Report.html index 89d28adf2..979b7ab33 100644 --- a/docs/source-class-Report.html +++ b/docs/source-class-Report.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,10 +207,10 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     
    -abstract class Report extends CI_Model 
    +abstract class Report extends CI_Model
     {
         function __construct()
         {
    @@ -223,14 +225,15 @@
     
         // Returns the column names used for the report
         public abstract function getDataColumns();
    -    
    +
         // Returns all the data to be populated into the report
         public abstract function getData(array $inputs);
    -    
    +
         // Returns key=>value pairing of summary data for the report
         public abstract function getSummaryData(array $inputs);
     }
    -?>
    +?> + - + diff --git a/docs/source-class-Reports.html b/docs/source-class-Reports.html index d967340a3..f4c70566f 100644 --- a/docs/source-class-Reports.html +++ b/docs/source-class-Reports.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,7 +207,7 @@ -
       1:    2:    3:    4:    5:    6:    7:    8:    9:   10:   11:   12:   13:   14:   15:   16:   17:   18:   19:   20:   21:   22:   23:   24:   25:   26:   27:   28:   29:   30:   31:   32:   33:   34:   35:   36:   37:   38:   39:   40:   41:   42:   43:   44:   45:   46:   47:   48:   49:   50:   51:   52:   53:   54:   55:   56:   57:   58:   59:   60:   61:   62:   63:   64:   65:   66:   67:   68:   69:   70:   71:   72:   73:   74:   75:   76:   77:   78:   79:   80:   81:   82:   83:   84:   85:   86:   87:   88:   89:   90:   91:   92:   93:   94:   95:   96:   97:   98:   99:  100:  101:  102:  103:  104:  105:  106:  107:  108:  109:  110:  111:  112:  113:  114:  115:  116:  117:  118:  119:  120:  121:  122:  123:  124:  125:  126:  127:  128:  129:  130:  131:  132:  133:  134:  135:  136:  137:  138:  139:  140:  141:  142:  143:  144:  145:  146:  147:  148:  149:  150:  151:  152:  153:  154:  155:  156:  157:  158:  159:  160:  161:  162:  163:  164:  165:  166:  167:  168:  169:  170:  171:  172:  173:  174:  175:  176:  177:  178:  179:  180:  181:  182:  183:  184:  185:  186:  187:  188:  189:  190:  191:  192:  193:  194:  195:  196:  197:  198:  199:  200:  201:  202:  203:  204:  205:  206:  207:  208:  209:  210:  211:  212:  213:  214:  215:  216:  217:  218:  219:  220:  221:  222:  223:  224:  225:  226:  227:  228:  229:  230:  231:  232:  233:  234:  235:  236:  237:  238:  239:  240:  241:  242:  243:  244:  245:  246:  247:  248:  249:  250:  251:  252:  253:  254:  255:  256:  257:  258:  259:  260:  261:  262:  263:  264:  265:  266:  267:  268:  269:  270:  271:  272:  273:  274:  275:  276:  277:  278:  279:  280:  281:  282:  283:  284:  285:  286:  287:  288:  289:  290:  291:  292:  293:  294:  295:  296:  297:  298:  299:  300:  301:  302:  303:  304:  305:  306:  307:  308:  309:  310:  311:  312:  313:  314:  315:  316:  317:  318:  319:  320:  321:  322:  323:  324:  325:  326:  327:  328:  329:  330:  331:  332:  333:  334:  335:  336:  337:  338:  339:  340:  341:  342:  343:  344:  345:  346:  347:  348:  349:  350:  351:  352:  353:  354:  355:  356:  357:  358:  359:  360:  361:  362:  363:  364:  365:  366:  367:  368:  369:  370:  371:  372:  373:  374:  375:  376:  377:  378:  379:  380:  381:  382:  383:  384:  385:  386:  387:  388:  389:  390:  391:  392:  393:  394:  395:  396:  397:  398:  399:  400:  401:  402:  403:  404:  405:  406:  407:  408:  409:  410:  411:  412:  413:  414:  415:  416:  417:  418:  419:  420:  421:  422:  423:  424:  425:  426:  427:  428:  429:  430:  431:  432:  433:  434:  435:  436:  437:  438:  439:  440:  441:  442:  443:  444:  445:  446:  447:  448:  449:  450:  451:  452:  453:  454:  455:  456:  457:  458:  459:  460:  461:  462:  463:  464:  465:  466:  467:  468:  469:  470:  471:  472:  473:  474:  475:  476:  477:  478:  479:  480:  481:  482:  483:  484:  485:  486:  487:  488:  489:  490:  491:  492:  493:  494:  495:  496:  497:  498:  499:  500:  501:  502:  503:  504:  505:  506:  507:  508:  509:  510:  511:  512:  513:  514:  515:  516:  517:  518:  519:  520:  521:  522:  523:  524:  525:  526:  527:  528:  529:  530:  531:  532:  533:  534:  535:  536:  537:  538:  539:  540:  541:  542:  543:  544:  545:  546:  547:  548:  549:  550:  551:  552:  553:  554:  555:  556:  557:  558:  559:  560:  561:  562:  563:  564:  565:  566:  567:  568:  569:  570:  571:  572:  573:  574:  575:  576:  577:  578:  579:  580:  581:  582:  583:  584:  585:  586:  587:  588:  589:  590:  591:  592:  593:  594:  595:  596:  597:  598:  599:  600:  601:  602:  603:  604:  605:  606:  607:  608:  609:  610:  611:  612:  613:  614:  615:  616:  617:  618:  619:  620:  621:  622:  623:  624:  625:  626:  627:  628:  629:  630:  631:  632:  633:  634:  635:  636:  637:  638:  639:  640:  641:  642:  643:  644:  645:  646:  647:  648:  649:  650:  651:  652:  653:  654:  655:  656:  657:  658:  659:  660:  661:  662:  663:  664:  665:  666:  667:  668:  669:  670:  671:  672:  673:  674:  675:  676:  677:  678:  679:  680:  681:  682:  683:  684:  685:  686:  687:  688:  689:  690:  691:  692:  693:  694:  695:  696:  697:  698:  699:  700:  701:  702:  703:  704:  705:  706:  707:  708:  709:  710:  711:  712:  713:  714:  715:  716:  717:  718:  719:  720:  721:  722:  723:  724:  725:  726:  727:  728:  729:  730:  731:  732:  733:  734:  735:  736:  737:  738:  739:  740:  741:  742:  743:  744:  745:  746:  747:  748:  749:  750:  751:  752:  753:  754:  755:  756:  757:  758:  759:  760:  761:  762:  763:  764:  765:  766:  767:  768:  769:  770:  771:  772:  773:  774:  775:  776:  777:  778:  779:  780:  781:  782:  783:  784:  785:  786:  787:  788:  789:  790:  791:  792:  793:  794:  795:  796:  797:  798:  799:  800:  801:  802:  803:  804:  805:  806:  807:  808:  809:  810:  811:  812:  813:  814:  815:  816:  817:  818:  819:  820:  821:  822:  823:  824:  825:  826:  827:  828:  829:  830:  831:  832:  833:  834:  835:  836:  837:  838:  839:  840:  841:  842:  843:  844:  845:  846:  847:  848:  849:  850:  851:  852:  853:  854:  855:  856:  857:  858:  859:  860:  861:  862:  863:  864:  865:  866:  867:  868:  869:  870:  871:  872:  873:  874:  875:  876:  877:  878:  879:  880:  881:  882:  883:  884:  885:  886:  887:  888:  889:  890:  891:  892:  893:  894:  895:  896:  897:  898:  899:  900:  901:  902:  903:  904:  905:  906:  907:  908:  909:  910:  911:  912:  913:  914:  915:  916:  917:  918:  919:  920:  921:  922:  923:  924:  925:  926:  927:  928:  929:  930:  931:  932:  933:  934:  935:  936:  937:  938:  939:  940:  941:  942:  943:  944:  945:  946:  947:  948:  949:  950:  951:  952:  953:  954:  955:  956:  957:  958:  959:  960:  961:  962:  963:  964:  965:  966:  967:  968:  969:  970:  971:  972:  973:  974:  975:  976:  977:  978:  979:  980:  981:  982:  983:  984:  985:  986:  987:  988:  989:  990:  991:  992:  993:  994:  995:  996:  997:  998:  999: 1000: 1001: 1002: 1003: 1004: 1005: 1006: 1007: 1008: 1009: 1010: 1011: 1012: 1013: 1014: 1015: 1016: 1017: 1018: 1019: 1020: 1021: 1022: 1023: 1024: 1025: 1026: 1027: 1028: 1029: 1030: 1031: 1032: 1033: 1034: 1035: 1036: 1037: 1038: 1039: 1040: 1041: 1042: 1043: 1044: 1045: 1046: 1047: 1048: 1049: 1050: 1051: 1052: 1053: 1054: 1055: 1056: 1057: 1058: 1059: 1060: 1061: 1062: 1063: 1064: 1065: 1066: 1067: 1068: 1069: 1070: 1071: 1072: 1073: 1074: 1075: 1076: 1077: 1078: 1079: 1080: 1081: 1082: 1083: 1084: 1085: 1086: 1087: 1088: 1089: 1090: 1091: 1092: 1093: 1094: 1095: 1096: 1097: 1098: 1099: 1100: 1101: 1102: 1103: 1104: 1105: 1106: 1107: 1108: 1109: 1110: 1111: 1112: 1113: 1114: 1115: 1116: 1117: 1118: 1119: 1120: 1121: 1122: 1123: 1124: 1125: 1126: 1127: 1128: 1129: 1130: 1131: 1132: 1133: 1134: 1135: 1136: 1137: 1138: 1139: 1140: 1141: 1142: 1143: 1144: 1145: 1146: 1147: 1148: 1149: 1150: 1151: 1152: 1153: 1154: 1155: 1156: 1157: 1158: 1159: 1160: 1161: 1162: 1163: 1164: 1165: 1166: 1167: 1168: 1169: 1170: 1171: 1172: 1173: 1174: 1175: 1176: 1177: 1178: 1179: 1180: 1181: 1182: 1183: 1184: 1185: 1186: 1187: 1188: 1189: 1190: 1191: 
    +
       1:    2:    3:    4:    5:    6:    7:    8:    9:   10:   11:   12:   13:   14:   15:   16:   17:   18:   19:   20:   21:   22:   23:   24:   25:   26:   27:   28:   29:   30:   31:   32:   33:   34:   35:   36:   37:   38:   39:   40:   41:   42:   43:   44:   45:   46:   47:   48:   49:   50:   51:   52:   53:   54:   55:   56:   57:   58:   59:   60:   61:   62:   63:   64:   65:   66:   67:   68:   69:   70:   71:   72:   73:   74:   75:   76:   77:   78:   79:   80:   81:   82:   83:   84:   85:   86:   87:   88:   89:   90:   91:   92:   93:   94:   95:   96:   97:   98:   99:  100:  101:  102:  103:  104:  105:  106:  107:  108:  109:  110:  111:  112:  113:  114:  115:  116:  117:  118:  119:  120:  121:  122:  123:  124:  125:  126:  127:  128:  129:  130:  131:  132:  133:  134:  135:  136:  137:  138:  139:  140:  141:  142:  143:  144:  145:  146:  147:  148:  149:  150:  151:  152:  153:  154:  155:  156:  157:  158:  159:  160:  161:  162:  163:  164:  165:  166:  167:  168:  169:  170:  171:  172:  173:  174:  175:  176:  177:  178:  179:  180:  181:  182:  183:  184:  185:  186:  187:  188:  189:  190:  191:  192:  193:  194:  195:  196:  197:  198:  199:  200:  201:  202:  203:  204:  205:  206:  207:  208:  209:  210:  211:  212:  213:  214:  215:  216:  217:  218:  219:  220:  221:  222:  223:  224:  225:  226:  227:  228:  229:  230:  231:  232:  233:  234:  235:  236:  237:  238:  239:  240:  241:  242:  243:  244:  245:  246:  247:  248:  249:  250:  251:  252:  253:  254:  255:  256:  257:  258:  259:  260:  261:  262:  263:  264:  265:  266:  267:  268:  269:  270:  271:  272:  273:  274:  275:  276:  277:  278:  279:  280:  281:  282:  283:  284:  285:  286:  287:  288:  289:  290:  291:  292:  293:  294:  295:  296:  297:  298:  299:  300:  301:  302:  303:  304:  305:  306:  307:  308:  309:  310:  311:  312:  313:  314:  315:  316:  317:  318:  319:  320:  321:  322:  323:  324:  325:  326:  327:  328:  329:  330:  331:  332:  333:  334:  335:  336:  337:  338:  339:  340:  341:  342:  343:  344:  345:  346:  347:  348:  349:  350:  351:  352:  353:  354:  355:  356:  357:  358:  359:  360:  361:  362:  363:  364:  365:  366:  367:  368:  369:  370:  371:  372:  373:  374:  375:  376:  377:  378:  379:  380:  381:  382:  383:  384:  385:  386:  387:  388:  389:  390:  391:  392:  393:  394:  395:  396:  397:  398:  399:  400:  401:  402:  403:  404:  405:  406:  407:  408:  409:  410:  411:  412:  413:  414:  415:  416:  417:  418:  419:  420:  421:  422:  423:  424:  425:  426:  427:  428:  429:  430:  431:  432:  433:  434:  435:  436:  437:  438:  439:  440:  441:  442:  443:  444:  445:  446:  447:  448:  449:  450:  451:  452:  453:  454:  455:  456:  457:  458:  459:  460:  461:  462:  463:  464:  465:  466:  467:  468:  469:  470:  471:  472:  473:  474:  475:  476:  477:  478:  479:  480:  481:  482:  483:  484:  485:  486:  487:  488:  489:  490:  491:  492:  493:  494:  495:  496:  497:  498:  499:  500:  501:  502:  503:  504:  505:  506:  507:  508:  509:  510:  511:  512:  513:  514:  515:  516:  517:  518:  519:  520:  521:  522:  523:  524:  525:  526:  527:  528:  529:  530:  531:  532:  533:  534:  535:  536:  537:  538:  539:  540:  541:  542:  543:  544:  545:  546:  547:  548:  549:  550:  551:  552:  553:  554:  555:  556:  557:  558:  559:  560:  561:  562:  563:  564:  565:  566:  567:  568:  569:  570:  571:  572:  573:  574:  575:  576:  577:  578:  579:  580:  581:  582:  583:  584:  585:  586:  587:  588:  589:  590:  591:  592:  593:  594:  595:  596:  597:  598:  599:  600:  601:  602:  603:  604:  605:  606:  607:  608:  609:  610:  611:  612:  613:  614:  615:  616:  617:  618:  619:  620:  621:  622:  623:  624:  625:  626:  627:  628:  629:  630:  631:  632:  633:  634:  635:  636:  637:  638:  639:  640:  641:  642:  643:  644:  645:  646:  647:  648:  649:  650:  651:  652:  653:  654:  655:  656:  657:  658:  659:  660:  661:  662:  663:  664:  665:  666:  667:  668:  669:  670:  671:  672:  673:  674:  675:  676:  677:  678:  679:  680:  681:  682:  683:  684:  685:  686:  687:  688:  689:  690:  691:  692:  693:  694:  695:  696:  697:  698:  699:  700:  701:  702:  703:  704:  705:  706:  707:  708:  709:  710:  711:  712:  713:  714:  715:  716:  717:  718:  719:  720:  721:  722:  723:  724:  725:  726:  727:  728:  729:  730:  731:  732:  733:  734:  735:  736:  737:  738:  739:  740:  741:  742:  743:  744:  745:  746:  747:  748:  749:  750:  751:  752:  753:  754:  755:  756:  757:  758:  759:  760:  761:  762:  763:  764:  765:  766:  767:  768:  769:  770:  771:  772:  773:  774:  775:  776:  777:  778:  779:  780:  781:  782:  783:  784:  785:  786:  787:  788:  789:  790:  791:  792:  793:  794:  795:  796:  797:  798:  799:  800:  801:  802:  803:  804:  805:  806:  807:  808:  809:  810:  811:  812:  813:  814:  815:  816:  817:  818:  819:  820:  821:  822:  823:  824:  825:  826:  827:  828:  829:  830:  831:  832:  833:  834:  835:  836:  837:  838:  839:  840:  841:  842:  843:  844:  845:  846:  847:  848:  849:  850:  851:  852:  853:  854:  855:  856:  857:  858:  859:  860:  861:  862:  863:  864:  865:  866:  867:  868:  869:  870:  871:  872:  873:  874:  875:  876:  877:  878:  879:  880:  881:  882:  883:  884:  885:  886:  887:  888:  889:  890:  891:  892:  893:  894:  895:  896:  897:  898:  899:  900:  901:  902:  903:  904:  905:  906:  907:  908:  909:  910:  911:  912:  913:  914:  915:  916:  917:  918:  919:  920:  921:  922:  923:  924:  925:  926:  927:  928:  929:  930:  931:  932:  933:  934:  935:  936:  937:  938:  939:  940:  941:  942:  943:  944:  945:  946:  947:  948:  949:  950:  951:  952:  953:  954:  955:  956:  957:  958:  959:  960:  961:  962:  963:  964:  965:  966:  967:  968:  969:  970:  971:  972:  973:  974:  975:  976:  977:  978:  979:  980:  981:  982:  983:  984:  985:  986:  987:  988:  989:  990:  991:  992:  993:  994:  995:  996:  997:  998:  999: 1000: 1001: 1002: 1003: 1004: 1005: 1006: 1007: 1008: 1009: 1010: 1011: 1012: 1013: 1014: 1015: 1016: 1017: 1018: 1019: 1020: 1021: 1022: 1023: 1024: 1025: 1026: 1027: 1028: 1029: 1030: 1031: 1032: 1033: 1034: 1035: 1036: 1037: 1038: 1039: 1040: 1041: 1042: 1043: 1044: 1045: 1046: 1047: 1048: 1049: 1050: 1051: 1052: 1053: 1054: 1055: 1056: 1057: 1058: 1059: 1060: 1061: 1062: 1063: 1064: 1065: 1066: 1067: 1068: 1069: 1070: 1071: 1072: 1073: 1074: 1075: 1076: 1077: 1078: 1079: 1080: 1081: 1082: 1083: 1084: 1085: 1086: 1087: 1088: 1089: 1090: 1091: 1092: 1093: 1094: 1095: 1096: 1097: 1098: 1099: 1100: 1101: 1102: 1103: 1104: 1105: 1106: 1107: 1108: 1109: 1110: 1111: 1112: 1113: 1114: 1115: 1116: 1117: 1118: 1119: 1120: 1121: 1122: 1123: 1124: 1125: 1126: 1127: 1128: 1129: 1130: 1131: 1132: 1133: 1134: 1135: 1136: 1137: 1138: 1139: 1140: 1141: 1142: 1143: 1144: 1145: 1146: 1147: 1148: 1149: 1150: 1151: 1152: 1153: 1154: 1155: 1156: 1157: 1158: 1159: 1160: 1161: 1162: 1163: 1164: 1165: 1166: 1167: 1168: 1169: 1170: 1171: 1172: 1173: 1174: 1175: 1176: 1177: 1178: 1179: 1180: 1181: 1182: 1183: 1184: 1185: 1186: 1187: 1188: 1189: 1190: 1191: 1192: 1193: 1194: 1195: 1196: 1197: 1198: 1199: 1200: 1201: 1202: 1203: 1204: 1205: 1206: 1207: 1208: 1209: 1210: 1211: 1212: 1213: 1214: 1215: 1216: 
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     
     require_once('Secure_Controller.php');
    @@ -958,445 +960,470 @@
                 {
                     $details_data[$row['sale_id']][] = $this->xss_clean(array($drow['name'], $drow['category'], $drow['serialnumber'], $drow['description'], to_quantity_decimals($drow['quantity_purchased']), to_currency($drow['subtotal']), to_currency($drow['tax']), to_currency($drow['total']), to_currency($drow['cost']), to_currency($drow['profit']), $drow['discount_percent'].'%'));
                 }
    -            if(isset($report_data['rewards'][$key])){
    -                foreach($report_data['rewards'][$key] as $drow)
    -                {
    -                    $details_data_rewards[$row['sale_id']][] = $this->xss_clean(array($drow['used'], $drow['earned']));
    -                }
    -            }
    -        }
    -
    -        $customer_info = $this->Customer->get_info($customer_id);
    -        $data = array(
    -            'title' => $this->xss_clean($customer_info->first_name . ' ' . $customer_info->last_name . ' ' . $this->lang->line('reports_report')),
    -            'subtitle' => $this->_get_subtitle_report(array('start_date' => $start_date, 'end_date' => $end_date)),
    -            'headers' => $headers,
    -            'summary_data' => $summary_data,
    -            'details_data' => $details_data,
    -            'details_data_rewards' => $details_data_rewards,
    -            'overall_summary_data' => $this->xss_clean($model->getSummaryData($inputs))
    -        );
    -
    -        $this->load->view('reports/tabular_details', $data);
    -    }
    -
    -    public function specific_employee_input()
    -    {
    -        $data = array();
    -        $data['specific_input_name'] = $this->lang->line('reports_employee');
    -
    -        $employees = array();
    -        foreach($this->Employee->get_all()->result() as $employee)
    -        {
    -            $employees[$employee->person_id] = $this->xss_clean($employee->first_name . ' ' . $employee->last_name);
    -        }
    -        $data['specific_input_data'] = $employees;
    -
    -        $this->load->view('reports/specific_input', $data);
    -    }
    -
    -    public function specific_employee($start_date, $end_date, $employee_id, $sale_type)
    -    {
    -        $inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'employee_id' => $employee_id, 'sale_type' => $sale_type);
    -
    -        $this->load->model('reports/Specific_employee');
    -        $model = $this->Specific_employee;
    -
    -        $model->create($inputs);
    +
    +            if(isset($report_data['rewards'][$key]))
    +            {
    +                foreach($report_data['rewards'][$key] as $drow)
    +                {
    +                    $details_data_rewards[$row['sale_id']][] = $this->xss_clean(array($drow['used'], $drow['earned']));
    +                }
    +            }
    +        }
    +
    +        $customer_info = $this->Customer->get_info($customer_id);
    +        $data = array(
    +            'title' => $this->xss_clean($customer_info->first_name . ' ' . $customer_info->last_name . ' ' . $this->lang->line('reports_report')),
    +            'subtitle' => $this->_get_subtitle_report(array('start_date' => $start_date, 'end_date' => $end_date)),
    +            'headers' => $headers,
    +            'summary_data' => $summary_data,
    +            'details_data' => $details_data,
    +            'details_data_rewards' => $details_data_rewards,
    +            'overall_summary_data' => $this->xss_clean($model->getSummaryData($inputs))
    +        );
    +
    +        $this->load->view('reports/tabular_details', $data);
    +    }
    +
    +    public function specific_employee_input()
    +    {
    +        $data = array();
    +        $data['specific_input_name'] = $this->lang->line('reports_employee');
    +
    +        $employees = array();
    +        foreach($this->Employee->get_all()->result() as $employee)
    +        {
    +            $employees[$employee->person_id] = $this->xss_clean($employee->first_name . ' ' . $employee->last_name);
    +        }
    +        $data['specific_input_data'] = $employees;
    +
    +        $this->load->view('reports/specific_input', $data);
    +    }
    +
    +    public function specific_employee($start_date, $end_date, $employee_id, $sale_type)
    +    {
    +        $inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'employee_id' => $employee_id, 'sale_type' => $sale_type);
    +
    +        $this->load->model('reports/Specific_employee');
    +        $model = $this->Specific_employee;
     
    -        $headers = $this->xss_clean($model->getDataColumns());
    -        $report_data = $model->getData($inputs);
    -
    -        $summary_data = array();
    -        $details_data = array();
    -
    -        foreach($report_data['summary'] as $key => $row)
    -        {
    -            $summary_data[] = $this->xss_clean(array(
    -                'id' => anchor('sales/receipt/'.$row['sale_id'], 'POS '.$row['sale_id'], array('target'=>'_blank')),
    -                'sale_date' => $row['sale_date'],
    -                'quantity' => to_quantity_decimals($row['items_purchased']),
    -                'customer_name' => $row['customer_name'],
    -                'subtotal' => to_currency($row['subtotal']),
    -                'tax' => to_currency($row['tax']),
    -                'total' => to_currency($row['total']),
    -                'cost' => to_currency($row['cost']),
    -                'profit' => to_currency($row['profit']),
    -                'payment_type' => $row['payment_type'],
    -                'comment' => $row['comment']));
    -
    -            foreach($report_data['details'][$key] as $drow)
    -            {
    -                $details_data[$row['sale_id']][] = $this->xss_clean(array($drow['name'], $drow['category'], $drow['serialnumber'], $drow['description'], to_quantity_decimals($drow['quantity_purchased']), to_currency($drow['subtotal']), to_currency($drow['tax']), to_currency($drow['total']), to_currency($drow['cost']), to_currency($drow['profit']), $drow['discount_percent'].'%'));
    -            }
    -        }
    -
    -        $employee_info = $this->Employee->get_info($employee_id);
    -        $data = array(
    -            'title' => $this->xss_clean($employee_info->first_name . ' ' . $employee_info->last_name . ' ' . $this->lang->line('reports_report')),
    -            'subtitle' => $this->_get_subtitle_report(array('start_date' => $start_date, 'end_date' => $end_date)),
    -            'headers' => $headers,
    -            'summary_data' => $summary_data,
    -            'details_data' => $details_data,
    -            'overall_summary_data' => $this->xss_clean($model->getSummaryData($inputs))
    -        );
    -
    -        $this->load->view('reports/tabular_details', $data);
    -    }
    -
    -    public function specific_discount_input()
    -    {
    -        $data = array();
    -        $data['specific_input_name'] = $this->lang->line('reports_discount');
    -
    -        $discounts = array();
    -        for ($i = 0; $i <= 100; $i += 10)
    -        {
    -            $discounts[$i] = $i . '%';
    -        }
    -        $data['specific_input_data'] = $discounts;
    -        
    -        $data = $this->xss_clean($data);
    -
    -        $this->load->view('reports/specific_input', $data);
    -    }
    +        $model->create($inputs);
    +
    +        $headers = $this->xss_clean($model->getDataColumns());
    +        $report_data = $model->getData($inputs);
    +
    +        $summary_data = array();
    +        $details_data = array();
    +        $details_data_rewards = array();
    +
    +        foreach($report_data['summary'] as $key => $row)
    +        {
    +            $summary_data[] = $this->xss_clean(array(
    +                'id' => anchor('sales/receipt/'.$row['sale_id'], 'POS '.$row['sale_id'], array('target'=>'_blank')),
    +                'sale_date' => $row['sale_date'],
    +                'quantity' => to_quantity_decimals($row['items_purchased']),
    +                'customer_name' => $row['customer_name'],
    +                'subtotal' => to_currency($row['subtotal']),
    +                'tax' => to_currency($row['tax']),
    +                'total' => to_currency($row['total']),
    +                'cost' => to_currency($row['cost']),
    +                'profit' => to_currency($row['profit']),
    +                'payment_type' => $row['payment_type'],
    +                'comment' => $row['comment']));
    +
    +            foreach($report_data['details'][$key] as $drow)
    +            {
    +                $details_data[$row['sale_id']][] = $this->xss_clean(array($drow['name'], $drow['category'], $drow['serialnumber'], $drow['description'], to_quantity_decimals($drow['quantity_purchased']), to_currency($drow['subtotal']), to_currency($drow['tax']), to_currency($drow['total']), to_currency($drow['cost']), to_currency($drow['profit']), $drow['discount_percent'].'%'));
    +            }
    +
    +            if(isset($report_data['rewards'][$key]))
    +            {
    +                foreach($report_data['rewards'][$key] as $drow)
    +                {
    +                    $details_data_rewards[$row['sale_id']][] = $this->xss_clean(array($drow['used'], $drow['earned']));
    +                }
    +            }
    +        }
    +
    +        $employee_info = $this->Employee->get_info($employee_id);
    +        $data = array(
    +            'title' => $this->xss_clean($employee_info->first_name . ' ' . $employee_info->last_name . ' ' . $this->lang->line('reports_report')),
    +            'subtitle' => $this->_get_subtitle_report(array('start_date' => $start_date, 'end_date' => $end_date)),
    +            'headers' => $headers,
    +            'summary_data' => $summary_data,
    +            'details_data' => $details_data,
    +            'details_data_rewards' => $details_data_rewards,
    +            'overall_summary_data' => $this->xss_clean($model->getSummaryData($inputs))
    +        );
    +
    +        $this->load->view('reports/tabular_details', $data);
    +    }
    +
    +    public function specific_discount_input()
    +    {
    +        $data = array();
    +        $data['specific_input_name'] = $this->lang->line('reports_discount');
     
    -    public function specific_discount($start_date, $end_date, $discount, $sale_type)
    -    {
    -        $inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'discount' => $discount, 'sale_type' => $sale_type);
    -        
    -        $this->load->model('reports/Specific_discount');
    -        $model = $this->Specific_discount;
    -
    -        $model->create($inputs);
    +        $discounts = array();
    +        for ($i = 0; $i <= 100; $i += 10)
    +        {
    +            $discounts[$i] = $i . '%';
    +        }
    +        $data['specific_input_data'] = $discounts;
    +        
    +        $data = $this->xss_clean($data);
     
    -        $headers = $this->xss_clean($model->getDataColumns());
    -        $report_data = $model->getData($inputs);
    +        $this->load->view('reports/specific_input', $data);
    +    }
     
    -        $summary_data = array();
    -        $details_data = array();
    -
    -        foreach($report_data['summary'] as $key => $row)
    -        {
    -            $summary_data[] = $this->xss_clean(array(
    -                'id' => anchor('sales/receipt/'.$row['sale_id'], 'POS '.$row['sale_id'], array('target'=>'_blank')),
    -                'sale_date' => $row['sale_date'],
    -                'quantity' => to_quantity_decimals($row['items_purchased']),
    -                'customer_name' => $row['customer_name'],
    -                'subtotal' => to_currency($row['subtotal']),
    -                'tax' => to_currency($row['tax']),
    -                'total' => to_currency($row['total']),
    -                'profit' => to_currency($row['profit']),
    -                'payment_type' => $row['payment_type'],
    -                'comment' => $row['comment']
    -            ));
    -
    -            foreach($report_data['details'][$key] as $drow)
    -            {
    -                $details_data[$row['sale_id']][] = $this->xss_clean(array($drow['name'], $drow['category'], $drow['serialnumber'], $drow['description'], to_quantity_decimals($drow['quantity_purchased']), to_currency($drow['subtotal']), to_currency($drow['tax']), to_currency($drow['total']), to_currency($drow['profit']), $drow['discount_percent'].'%'));
    -            }
    -        }
    -
    -        $data = array(
    -            'title' => $discount . '% ' . $this->lang->line('reports_discount') . ' ' . $this->lang->line('reports_report'),
    -            'subtitle' => $this->_get_subtitle_report(array('start_date' => $start_date, 'end_date' => $end_date)),
    -            'headers' => $headers,
    -            'summary_data' => $summary_data,
    -            'details_data' => $details_data,
    -            'overall_summary_data' => $this->xss_clean($model->getSummaryData($inputs))
    -        );
    -
    -        $this->load->view('reports/tabular_details', $data);
    -    }
    +    public function specific_discount($start_date, $end_date, $discount, $sale_type)
    +    {
    +        $inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'discount' => $discount, 'sale_type' => $sale_type);
    +        
    +        $this->load->model('reports/Specific_discount');
    +        $model = $this->Specific_discount;
    +
    +        $model->create($inputs);
    +
    +        $headers = $this->xss_clean($model->getDataColumns());
    +        $report_data = $model->getData($inputs);
    +
    +        $summary_data = array();
    +        $details_data = array();
    +        $details_data_rewards = array();
    +
    +        foreach($report_data['summary'] as $key => $row)
    +        {
    +            $summary_data[] = $this->xss_clean(array(
    +                'id' => anchor('sales/receipt/'.$row['sale_id'], 'POS '.$row['sale_id'], array('target'=>'_blank')),
    +                'sale_date' => $row['sale_date'],
    +                'quantity' => to_quantity_decimals($row['items_purchased']),
    +                'customer_name' => $row['customer_name'],
    +                'subtotal' => to_currency($row['subtotal']),
    +                'tax' => to_currency($row['tax']),
    +                'total' => to_currency($row['total']),
    +                'profit' => to_currency($row['profit']),
    +                'payment_type' => $row['payment_type'],
    +                'comment' => $row['comment']
    +            ));
    +
    +            foreach($report_data['details'][$key] as $drow)
    +            {
    +                $details_data[$row['sale_id']][] = $this->xss_clean(array($drow['name'], $drow['category'], $drow['serialnumber'], $drow['description'], to_quantity_decimals($drow['quantity_purchased']), to_currency($drow['subtotal']), to_currency($drow['tax']), to_currency($drow['total']), to_currency($drow['profit']), $drow['discount_percent'].'%'));
    +            }
     
    -    public function get_detailed_sales_row($sale_id)
    -    {
    -        $inputs = array('sale_id' => $sale_id);
    -        
    -        $this->load->model('reports/Detailed_sales');
    -        $model = $this->Detailed_sales;
    -
    -        $model->create($inputs);
    +            if(isset($report_data['rewards'][$key]))
    +            {
    +                foreach($report_data['rewards'][$key] as $drow)
    +                {
    +                    $details_data_rewards[$row['sale_id']][] = $this->xss_clean(array($drow['used'], $drow['earned']));
    +                }
    +            }
    +        }
     
    -        $report_data = $model->getDataBySaleId($sale_id);
    -
    -        $summary_data = $this->xss_clean(array(
    -            'sale_id' => $report_data['sale_id'],
    -            'sale_date' => $report_data['sale_date'],
    -            'quantity' => to_quantity_decimals($report_data['items_purchased']),
    -            'employee_name' => $report_data['employee_name'],
    -            'customer_name' => $report_data['customer_name'],
    -            'subtotal' => to_currency($report_data['subtotal']),
    -            'tax' => to_currency($report_data['tax']),
    -            'total' => to_currency($report_data['total']),
    -            'cost' => to_currency($report_data['cost']),
    -            'profit' => to_currency($report_data['profit']),
    -            'payment_type' => $report_data['payment_type'],
    -            'comment' => $report_data['comment'],
    -            'edit' => anchor('sales/edit/'. $report_data['sale_id'], '<span class="glyphicon glyphicon-edit"></span>',
    -                array('class'=>'modal-dlg print_hide', 'data-btn-delete' => $this->lang->line('common_delete'), 'data-btn-submit' => $this->lang->line('common_submit'), 'title' => $this->lang->line('sales_update'))
    -            )
    -        ));
    +        $data = array(
    +            'title' => $discount . '% ' . $this->lang->line('reports_discount') . ' ' . $this->lang->line('reports_report'),
    +            'subtitle' => $this->_get_subtitle_report(array('start_date' => $start_date, 'end_date' => $end_date)),
    +            'headers' => $headers,
    +            'summary_data' => $summary_data,
    +            'details_data' => $details_data,
    +            'details_data_rewards' => $details_data_rewards,
    +            'overall_summary_data' => $this->xss_clean($model->getSummaryData($inputs))
    +        );
    +
    +        $this->load->view('reports/tabular_details', $data);
    +    }
    +
    +    public function get_detailed_sales_row($sale_id)
    +    {
    +        $inputs = array('sale_id' => $sale_id);
    +        
    +        $this->load->model('reports/Detailed_sales');
    +        $model = $this->Detailed_sales;
     
    -        echo json_encode(array($sale_id => $summary_data));
    -    }
    -
    -    public function detailed_sales($start_date, $end_date, $sale_type, $location_id = 'all')
    -    {
    -        $inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id);
    -        
    -        $this->load->model('reports/Detailed_sales');
    -        $model = $this->Detailed_sales;
    -
    -        $model->create($inputs);
    -
    -        $headers = $this->xss_clean($model->getDataColumns());
    -
    -        $report_data = $model->getData($inputs);
    -
    -        $summary_data = array();
    -        $details_data = array();
    -        $details_data_rewards = array();
    -
    -        $show_locations = $this->xss_clean($this->Stock_location->multiple_locations());
    +        $model->create($inputs);
    +
    +        $report_data = $model->getDataBySaleId($sale_id);
    +
    +        $summary_data = $this->xss_clean(array(
    +            'sale_id' => $report_data['sale_id'],
    +            'sale_date' => $report_data['sale_date'],
    +            'quantity' => to_quantity_decimals($report_data['items_purchased']),
    +            'employee_name' => $report_data['employee_name'],
    +            'customer_name' => $report_data['customer_name'],
    +            'subtotal' => to_currency($report_data['subtotal']),
    +            'tax' => to_currency($report_data['tax']),
    +            'total' => to_currency($report_data['total']),
    +            'cost' => to_currency($report_data['cost']),
    +            'profit' => to_currency($report_data['profit']),
    +            'payment_type' => $report_data['payment_type'],
    +            'comment' => $report_data['comment'],
    +            'edit' => anchor('sales/edit/'. $report_data['sale_id'], '<span class="glyphicon glyphicon-edit"></span>',
    +                array('class'=>'modal-dlg print_hide', 'data-btn-delete' => $this->lang->line('common_delete'), 'data-btn-submit' => $this->lang->line('common_submit'), 'title' => $this->lang->line('sales_update'))
    +            )
    +        ));
     
    -        foreach($report_data['summary'] as $key => $row)
    -        {
    -            $summary_data[] = $this->xss_clean(array(
    -                'id' => $row['sale_id'],
    -                'sale_date' => $row['sale_date'],
    -                'quantity' => to_quantity_decimals($row['items_purchased']),
    -                'employee_name' => $row['employee_name'],
    -                'customer_name' => $row['customer_name'],
    -                'subtotal' => to_currency($row['subtotal']),
    -                'tax' => to_currency($row['tax']),
    -                'total' => to_currency($row['total']),
    -                'cost' => to_currency($row['cost']),
    -                'profit' => to_currency($row['profit']),
    -                'payment_type' => $row['payment_type'],
    -                'comment' => $row['comment'],
    -                'edit' => anchor('sales/edit/'.$row['sale_id'], '<span class="glyphicon glyphicon-edit"></span>',
    -                    array('class' => 'modal-dlg print_hide', 'data-btn-delete' => $this->lang->line('common_delete'), 'data-btn-submit' => $this->lang->line('common_submit'), 'title' => $this->lang->line('sales_update'))
    -                )
    -            ));
    +        echo json_encode(array($sale_id => $summary_data));
    +    }
    +
    +    public function detailed_sales($start_date, $end_date, $sale_type, $location_id = 'all')
    +    {
    +        $inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'sale_type' => $sale_type, 'location_id' => $location_id);
    +        
    +        $this->load->model('reports/Detailed_sales');
    +        $model = $this->Detailed_sales;
    +
    +        $model->create($inputs);
    +
    +        $headers = $this->xss_clean($model->getDataColumns());
    +
    +        $report_data = $model->getData($inputs);
    +
    +        $summary_data = array();
    +        $details_data = array();
    +        $details_data_rewards = array();
     
    -            foreach($report_data['details'][$key] as $drow)
    -            {
    -                $quantity_purchased = to_quantity_decimals($drow['quantity_purchased']);
    -                if($show_locations)
    -                {
    -                    $quantity_purchased .= ' [' . $this->Stock_location->get_location_name($drow['item_location']) . ']';
    -                }
    -                $details_data[$row['sale_id']][] = $this->xss_clean(array($drow['name'], $drow['category'], $drow['serialnumber'], $drow['description'], $quantity_purchased, to_currency($drow['subtotal']), to_currency($drow['tax']), to_currency($drow['total']), to_currency($drow['cost']), to_currency($drow['profit']), $drow['discount_percent'].'%'));
    -            }
    -            if(isset($report_data['rewards'][$key])){
    -                foreach($report_data['rewards'][$key] as $drow)
    -                {
    -                    $details_data_rewards[$row['sale_id']][] = $this->xss_clean(array($drow['used'], $drow['earned']));
    -                }
    -            }
    -        }
    -
    -        $data = array(
    -            'title' => $this->lang->line('reports_detailed_sales_report'),
    -            'subtitle' => $this->_get_subtitle_report(array('start_date' => $start_date, 'end_date' => $end_date)),
    -            'headers' => $headers,
    -            'editable' => 'sales',
    -            'summary_data' => $summary_data,
    -            'details_data' => $details_data,
    -            'details_data_rewards' => $details_data_rewards,
    -            'overall_summary_data' => $this->xss_clean($model->getSummaryData($inputs))
    -        );
    -        $this->load->view('reports/tabular_details', $data);
    -    }
    -
    -    public function get_detailed_receivings_row($receiving_id)
    -    {
    -        $inputs = array('receiving_id' => $receiving_id);
    -
    -        $this->load->model('reports/Detailed_receivings');
    -        $model = $this->Detailed_receivings;
    -        
    -        $model->create($inputs);
    -
    -        $report_data = $model->getDataByReceivingId($receiving_id);
    +        $show_locations = $this->xss_clean($this->Stock_location->multiple_locations());
    +
    +        foreach($report_data['summary'] as $key => $row)
    +        {
    +            $summary_data[] = $this->xss_clean(array(
    +                'id' => $row['sale_id'],
    +                'sale_date' => $row['sale_date'],
    +                'quantity' => to_quantity_decimals($row['items_purchased']),
    +                'employee_name' => $row['employee_name'],
    +                'customer_name' => $row['customer_name'],
    +                'subtotal' => to_currency($row['subtotal']),
    +                'tax' => to_currency($row['tax']),
    +                'total' => to_currency($row['total']),
    +                'cost' => to_currency($row['cost']),
    +                'profit' => to_currency($row['profit']),
    +                'payment_type' => $row['payment_type'],
    +                'comment' => $row['comment'],
    +                'edit' => anchor('sales/edit/'.$row['sale_id'], '<span class="glyphicon glyphicon-edit"></span>',
    +                    array('class' => 'modal-dlg print_hide', 'data-btn-delete' => $this->lang->line('common_delete'), 'data-btn-submit' => $this->lang->line('common_submit'), 'title' => $this->lang->line('sales_update'))
    +                )
    +            ));
    +
    +            foreach($report_data['details'][$key] as $drow)
    +            {
    +                $quantity_purchased = to_quantity_decimals($drow['quantity_purchased']);
    +                if($show_locations)
    +                {
    +                    $quantity_purchased .= ' [' . $this->Stock_location->get_location_name($drow['item_location']) . ']';
    +                }
    +                $details_data[$row['sale_id']][] = $this->xss_clean(array($drow['name'], $drow['category'], $drow['serialnumber'], $drow['description'], $quantity_purchased, to_currency($drow['subtotal']), to_currency($drow['tax']), to_currency($drow['total']), to_currency($drow['cost']), to_currency($drow['profit']), $drow['discount_percent'].'%'));
    +            }
    +
    +            if(isset($report_data['rewards'][$key]))
    +            {
    +                foreach($report_data['rewards'][$key] as $drow)
    +                {
    +                    $details_data_rewards[$row['sale_id']][] = $this->xss_clean(array($drow['used'], $drow['earned']));
    +                }
    +            }
    +        }
     
    -        $summary_data = $this->xss_clean(array(
    -            'receiving_id' => $report_data['receiving_id'],
    -            'receiving_date' => $report_data['receiving_date'],
    -            'quantity' => to_quantity_decimals($report_data['items_purchased']),
    -            'employee_name' => $report_data['employee_name'],
    -            'supplier_name' => $report_data['supplier_name'],
    -            'total' => to_currency($report_data['total']),
    -            'payment_type' => $report_data['payment_type'],
    -            'reference' => $report_data['reference'],
    -            'comment' => $report_data['comment'],
    -            'edit' => anchor('receivings/edit/'. $report_data['receiving_id'], '<span class="glyphicon glyphicon-edit"></span>',
    -                array('class'=>'modal-dlg print_hide', 'data-btn-submit' => $this->lang->line('common_submit'), 'data-btn-delete' => $this->lang->line('common_delete'), 'title' => $this->lang->line('receivings_update'))
    -            )
    -        ));
    -
    -        echo json_encode(array($receiving_id => $summary_data));
    -    }
    -
    -    public function detailed_receivings($start_date, $end_date, $receiving_type, $location_id = 'all')
    -    {
    -        $inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'receiving_type' => $receiving_type, 'location_id' => $location_id);
    -        
    -        $this->load->model('reports/Detailed_receivings');
    -        $model = $this->Detailed_receivings;
    -        
    -        $model->create($inputs);
    -
    -        $headers = $this->xss_clean($model->getDataColumns());
    -        $report_data = $model->getData($inputs);
    -
    -        $summary_data = array();
    -        $details_data = array();
    -
    -        $show_locations = $this->xss_clean($this->Stock_location->multiple_locations());
    -
    -        foreach($report_data['summary'] as $key => $row)
    -        {
    -            $summary_data[] = $this->xss_clean(array(
    -                'id' => $row['receiving_id'],
    -                'receiving_date' => $row['receiving_date'],
    -                'quantity' => to_quantity_decimals($row['items_purchased']),
    -                'employee_name' => $row['employee_name'],
    -                'supplier_name' => $row['supplier_name'],
    -                'total' => to_currency($row['total']),
    -                'profit' => to_currency($row['profit']),
    -                'payment_type' => $row['payment_type'],
    -                'reference' => $row['reference'],
    -                'comment' => $row['comment'],
    -                'edit' => anchor('receivings/edit/' . $row['receiving_id'], '<span class="glyphicon glyphicon-edit"></span>',
    -                    array('class' => 'modal-dlg print_hide', 'data-btn-delete' => $this->lang->line('common_delete'), 'data-btn-submit' => $this->lang->line('common_submit'), 'title' => $this->lang->line('receivings_update'))
    -                )
    -            ));
    -
    -            foreach($report_data['details'][$key] as $drow)
    -            {
    -                $quantity_purchased = $drow['receiving_quantity'] > 1 ? to_quantity_decimals($drow['quantity_purchased']) . ' x ' . to_quantity_decimals($drow['receiving_quantity']) : to_quantity_decimals($drow['quantity_purchased']);
    -                if ($show_locations)
    -                {
    -                    $quantity_purchased .= ' [' . $this->Stock_location->get_location_name($drow['item_location']) . ']';
    -                }
    -                $details_data[$row['receiving_id']][] = $this->xss_clean(array($drow['item_number'], $drow['name'], $drow['category'], $quantity_purchased, to_currency($drow['total']), $drow['discount_percent'].'%'));
    -            }
    -        }
    -
    -        $data = array(
    -            'title' => $this->lang->line('reports_detailed_receivings_report'),
    -            'subtitle' => $this->_get_subtitle_report(array('start_date' => $start_date, 'end_date' => $end_date)),
    -            'headers' => $headers,
    -            'editable' => 'receivings',
    -            'summary_data' => $summary_data,
    -            'details_data' => $details_data,
    -            'overall_summary_data' => $this->xss_clean($model->getSummaryData($inputs))
    -        );
    -
    -        $this->load->view('reports/tabular_details', $data);
    -    }
    +        $data = array(
    +            'title' => $this->lang->line('reports_detailed_sales_report'),
    +            'subtitle' => $this->_get_subtitle_report(array('start_date' => $start_date, 'end_date' => $end_date)),
    +            'headers' => $headers,
    +            'editable' => 'sales',
    +            'summary_data' => $summary_data,
    +            'details_data' => $details_data,
    +            'details_data_rewards' => $details_data_rewards,
    +            'overall_summary_data' => $this->xss_clean($model->getSummaryData($inputs))
    +        );
    +        $this->load->view('reports/tabular_details', $data);
    +    }
    +
    +    public function get_detailed_receivings_row($receiving_id)
    +    {
    +        $inputs = array('receiving_id' => $receiving_id);
    +
    +        $this->load->model('reports/Detailed_receivings');
    +        $model = $this->Detailed_receivings;
    +        
    +        $model->create($inputs);
    +
    +        $report_data = $model->getDataByReceivingId($receiving_id);
    +
    +        $summary_data = $this->xss_clean(array(
    +            'receiving_id' => $report_data['receiving_id'],
    +            'receiving_date' => $report_data['receiving_date'],
    +            'quantity' => to_quantity_decimals($report_data['items_purchased']),
    +            'employee_name' => $report_data['employee_name'],
    +            'supplier_name' => $report_data['supplier_name'],
    +            'total' => to_currency($report_data['total']),
    +            'payment_type' => $report_data['payment_type'],
    +            'reference' => $report_data['reference'],
    +            'comment' => $report_data['comment'],
    +            'edit' => anchor('receivings/edit/'. $report_data['receiving_id'], '<span class="glyphicon glyphicon-edit"></span>',
    +                array('class'=>'modal-dlg print_hide', 'data-btn-submit' => $this->lang->line('common_submit'), 'data-btn-delete' => $this->lang->line('common_delete'), 'title' => $this->lang->line('receivings_update'))
    +            )
    +        ));
    +
    +        echo json_encode(array($receiving_id => $summary_data));
    +    }
    +
    +    public function detailed_receivings($start_date, $end_date, $receiving_type, $location_id = 'all')
    +    {
    +        $inputs = array('start_date' => $start_date, 'end_date' => $end_date, 'receiving_type' => $receiving_type, 'location_id' => $location_id);
    +        
    +        $this->load->model('reports/Detailed_receivings');
    +        $model = $this->Detailed_receivings;
    +        
    +        $model->create($inputs);
    +
    +        $headers = $this->xss_clean($model->getDataColumns());
    +        $report_data = $model->getData($inputs);
    +
    +        $summary_data = array();
    +        $details_data = array();
    +
    +        $show_locations = $this->xss_clean($this->Stock_location->multiple_locations());
    +
    +        foreach($report_data['summary'] as $key => $row)
    +        {
    +            $summary_data[] = $this->xss_clean(array(
    +                'id' => $row['receiving_id'],
    +                'receiving_date' => $row['receiving_date'],
    +                'quantity' => to_quantity_decimals($row['items_purchased']),
    +                'employee_name' => $row['employee_name'],
    +                'supplier_name' => $row['supplier_name'],
    +                'total' => to_currency($row['total']),
    +                'profit' => to_currency($row['profit']),
    +                'payment_type' => $row['payment_type'],
    +                'reference' => $row['reference'],
    +                'comment' => $row['comment'],
    +                'edit' => anchor('receivings/edit/' . $row['receiving_id'], '<span class="glyphicon glyphicon-edit"></span>',
    +                    array('class' => 'modal-dlg print_hide', 'data-btn-delete' => $this->lang->line('common_delete'), 'data-btn-submit' => $this->lang->line('common_submit'), 'title' => $this->lang->line('receivings_update'))
    +                )
    +            ));
     
    -    public function inventory_low()
    -    {
    -        $inputs = array();
    -
    -        $this->load->model('reports/Inventory_low');
    -        $model = $this->Inventory_low;
    -
    -        $report_data = $model->getData($inputs);
    -        
    -        $tabular_data = array();
    -        foreach($report_data as $row)
    -        {
    -            $tabular_data[] = $this->xss_clean(array(
    -                'item_name' => $row['name'],
    -                'item_number' => $row['item_number'],
    -                'quantity' => to_quantity_decimals($row['quantity']),
    -                'reorder_level' => to_quantity_decimals($row['reorder_level']),
    -                'location_name' => $row['location_name']
    -            ));
    -        }
    +            foreach($report_data['details'][$key] as $drow)
    +            {
    +                $quantity_purchased = $drow['receiving_quantity'] > 1 ? to_quantity_decimals($drow['quantity_purchased']) . ' x ' . to_quantity_decimals($drow['receiving_quantity']) : to_quantity_decimals($drow['quantity_purchased']);
    +                if ($show_locations)
    +                {
    +                    $quantity_purchased .= ' [' . $this->Stock_location->get_location_name($drow['item_location']) . ']';
    +                }
    +                $details_data[$row['receiving_id']][] = $this->xss_clean(array($drow['item_number'], $drow['name'], $drow['category'], $quantity_purchased, to_currency($drow['total']), $drow['discount_percent'].'%'));
    +            }
    +        }
    +
    +        $data = array(
    +            'title' => $this->lang->line('reports_detailed_receivings_report'),
    +            'subtitle' => $this->_get_subtitle_report(array('start_date' => $start_date, 'end_date' => $end_date)),
    +            'headers' => $headers,
    +            'editable' => 'receivings',
    +            'summary_data' => $summary_data,
    +            'details_data' => $details_data,
    +            'overall_summary_data' => $this->xss_clean($model->getSummaryData($inputs))
    +        );
     
    -        $data = array(
    -            'title' => $this->lang->line('reports_inventory_low_report'),
    -            'subtitle' => '',
    -            'headers' => $this->xss_clean($model->getDataColumns()),
    -            'data' => $tabular_data,
    -            'summary_data' => $this->xss_clean($model->getSummaryData($inputs))
    -        );
    -
    -        $this->load->view('reports/tabular', $data);
    -    }
    -
    -    public function inventory_summary_input()
    -    {
    -        $this->load->model('reports/Inventory_summary');
    -        $model = $this->Inventory_summary;
    -        
    -        $data = array();
    -        $data['item_count'] = $model->getItemCountDropdownArray();
    -
    -        $stock_locations = $this->xss_clean($this->Stock_location->get_allowed_locations());
    -        $stock_locations['all'] = $this->lang->line('reports_all');
    -        $data['stock_locations'] = array_reverse($stock_locations, TRUE);
    -
    -        $this->load->view('reports/inventory_summary_input', $data);
    -    }
    -
    -    public function inventory_summary($location_id = 'all', $item_count = 'all')
    -    {
    -        $inputs = array('location_id' => $location_id, 'item_count' => $item_count);
    -        
    -        $this->load->model('reports/Inventory_summary');
    -        $model = $this->Inventory_summary;
    -
    -        $report_data = $model->getData($inputs);
    +        $this->load->view('reports/tabular_details', $data);
    +    }
    +
    +    public function inventory_low()
    +    {
    +        $inputs = array();
    +
    +        $this->load->model('reports/Inventory_low');
    +        $model = $this->Inventory_low;
    +
    +        $report_data = $model->getData($inputs);
    +        
    +        $tabular_data = array();
    +        foreach($report_data as $row)
    +        {
    +            $tabular_data[] = $this->xss_clean(array(
    +                'item_name' => $row['name'],
    +                'item_number' => $row['item_number'],
    +                'quantity' => to_quantity_decimals($row['quantity']),
    +                'reorder_level' => to_quantity_decimals($row['reorder_level']),
    +                'location_name' => $row['location_name']
    +            ));
    +        }
    +
    +        $data = array(
    +            'title' => $this->lang->line('reports_inventory_low_report'),
    +            'subtitle' => '',
    +            'headers' => $this->xss_clean($model->getDataColumns()),
    +            'data' => $tabular_data,
    +            'summary_data' => $this->xss_clean($model->getSummaryData($inputs))
    +        );
    +
    +        $this->load->view('reports/tabular', $data);
    +    }
     
    -        $tabular_data = array();
    -        foreach($report_data as $row)
    -        {
    -            $tabular_data[] = $this->xss_clean(array(
    -                'item_name' => $row['name'],
    -                'item_number' => $row['item_number'],
    -                'quantity' => to_quantity_decimals($row['quantity']),
    -                'reorder_level' => to_quantity_decimals($row['reorder_level']),
    -                'location_name' => $row['location_name'],
    -                'cost_price' => to_currency($row['cost_price']),
    -                'unit_price' => to_currency($row['unit_price']),
    -                'subtotal' => to_currency($row['sub_total_value'])
    -            ));
    -        }
    +    public function inventory_summary_input()
    +    {
    +        $this->load->model('reports/Inventory_summary');
    +        $model = $this->Inventory_summary;
    +        
    +        $data = array();
    +        $data['item_count'] = $model->getItemCountDropdownArray();
    +
    +        $stock_locations = $this->xss_clean($this->Stock_location->get_allowed_locations());
    +        $stock_locations['all'] = $this->lang->line('reports_all');
    +        $data['stock_locations'] = array_reverse($stock_locations, TRUE);
    +
    +        $this->load->view('reports/inventory_summary_input', $data);
    +    }
     
    -        $data = array(
    -            'title' => $this->lang->line('reports_inventory_summary_report'),
    -            'subtitle' => '',
    -            'headers' => $this->xss_clean($model->getDataColumns()),
    -            'data' => $tabular_data,
    -            'summary_data' => $this->xss_clean($model->getSummaryData($report_data))
    -        );
    -
    -        $this->load->view('reports/tabular', $data);
    -    }
    -    //  Returns subtitle for the reports
    -    private function _get_subtitle_report($inputs)
    -    {
    -        $subtitle = '';
    -
    -        if(empty($this->config->item('date_or_time_format')))
    -        {
    -            $subtitle .= date($this->config->item('dateformat'), strtotime($inputs['start_date'])) . ' - ' .date($this->config->item('dateformat'), strtotime($inputs['end_date']));
    -        }
    -        else
    -        {
    -            $subtitle .= date($this->config->item('dateformat').' '.$this->config->item('timeformat'), strtotime(rawurldecode($inputs['start_date']))) . ' - ' . date($this->config->item('dateformat').' '.$this->config->item('timeformat'), strtotime(rawurldecode($inputs['end_date'])));
    +    public function inventory_summary($location_id = 'all', $item_count = 'all')
    +    {
    +        $inputs = array('location_id' => $location_id, 'item_count' => $item_count);
    +        
    +        $this->load->model('reports/Inventory_summary');
    +        $model = $this->Inventory_summary;
    +
    +        $report_data = $model->getData($inputs);
    +
    +        $tabular_data = array();
    +        foreach($report_data as $row)
    +        {
    +            $tabular_data[] = $this->xss_clean(array(
    +                'item_name' => $row['name'],
    +                'item_number' => $row['item_number'],
    +                'quantity' => to_quantity_decimals($row['quantity']),
    +                'reorder_level' => to_quantity_decimals($row['reorder_level']),
    +                'location_name' => $row['location_name'],
    +                'cost_price' => to_currency($row['cost_price']),
    +                'unit_price' => to_currency($row['unit_price']),
    +                'subtotal' => to_currency($row['sub_total_value'])
    +            ));
             }
    -        
    -        return $subtitle;
    -    }
    -}
    -?>
    + + $data = array( + 'title' => $this->lang->line('reports_inventory_summary_report'), + 'subtitle' => '', + 'headers' => $this->xss_clean($model->getDataColumns()), + 'data' => $tabular_data, + 'summary_data' => $this->xss_clean($model->getSummaryData($report_data)) + ); + + $this->load->view('reports/tabular', $data); + } + // Returns subtitle for the reports + private function _get_subtitle_report($inputs) + { + $subtitle = ''; + + if(empty($this->config->item('date_or_time_format'))) + { + $subtitle .= date($this->config->item('dateformat'), strtotime($inputs['start_date'])) . ' - ' .date($this->config->item('dateformat'), strtotime($inputs['end_date'])); + } + else + { + $subtitle .= date($this->config->item('dateformat').' '.$this->config->item('timeformat'), strtotime(rawurldecode($inputs['start_date']))) . ' - ' . date($this->config->item('dateformat').' '.$this->config->item('timeformat'), strtotime(rawurldecode($inputs['end_date']))); + } + + return $subtitle; + } +} +?> + - + diff --git a/docs/source-class-Rewards.html b/docs/source-class-Rewards.html index 2828fb5c8..2e792e45d 100644 --- a/docs/source-class-Rewards.html +++ b/docs/source-class-Rewards.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,34 +207,43 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 
    -
    <?php
    -class Rewards extends CI_Model
    -{
    -    /*
    -    Inserts or updates a rewards
    -    */
    -    public function save(&$rewards_data, $id = -1)
    -    {
    -        if($id == -1 || !$this->exists($id))
    -        {
    -            if($this->db->insert('sales_reward_points', $rewards_data))
    -            {
    -                $rewards_data['id'] = $this->db->insert_id();
    -
    -                return TRUE;
    -            }
    -
    -            return FALSE;
    -        }
    -
    -        $this->db->where('id', $id);
    -
    -        return $this->db->update('sales_reward_points', $rewards_data);
    -    }
    -}
    -?>
    -
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
    +
    +/**
    + * Rewards class
    + *
    + * @link    github.com/jekkos/opensourcepos
    + * @since   3.1
    + * @author  joshua1234511
    + */
    +
    +class Rewards extends CI_Model
    +{
    +    /*
    +    Inserts or updates a rewards
    +    */
    +    public function save(&$rewards_data, $id = -1)
    +    {
    +        if($id == -1 || !$this->exists($id))
    +        {
    +            if($this->db->insert('sales_reward_points', $rewards_data))
    +            {
    +                $rewards_data['id'] = $this->db->insert_id();
    +
    +                return TRUE;
    +            }
    +
    +            return FALSE;
    +        }
    +
    +        $this->db->where('id', $id);
    +
    +        return $this->db->update('sales_reward_points', $rewards_data);
    +    }
    +}
    +?>
    +
    - + diff --git a/docs/source-class-Rounding_code.html b/docs/source-class-Rounding_code.html index 524f14d06..a3c4074cc 100644 --- a/docs/source-class-Rounding_code.html +++ b/docs/source-class-Rounding_code.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,87 +207,96 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 
    -
    <?php
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 
    +
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     
    -class Rounding_code
    -{
    -    const HALF_UP = 0;
    -    const HALF_DOWN = 1;
    -    const HALF_EVEN = 2;
    -    const HALF_ODD = 3;
    -    const ROUND_UP = 4;
    -    const ROUND_DOWN = 5;
    -    const HALF_FIVE = 6;
    -
    -    public static function get_rounding_options()
    -    {
    -        $CI =& get_instance();
    -        $CI->load->helper('language');
    -        return array(
    -            Rounding_code::HALF_UP => lang('enum_half_up'),
    -            Rounding_code::HALF_DOWN => lang('enum_half_down'),
    -            Rounding_code::HALF_EVEN => lang('enum_half_even'),
    -            Rounding_code::HALF_ODD => lang('enum_half_odd'),
    -            Rounding_code::ROUND_UP => lang('enum_round_up'),
    -            Rounding_code::ROUND_DOWN => lang('enum_round_down'),
    -            Rounding_code::HALF_FIVE => lang('enum_half_five')
    -        );
    -    }
    -
    -    public static function get_rounding_code_name($rounding_code)
    -    {
    -        $CI =& get_instance();
    -        $CI->load->helper('language');
    -        if($rounding_code == Rounding_code::HALF_UP)
    -        {
    -            return lang('enum_half_up');
    -        }
    -        elseif($rounding_code == Rounding_code::HALF_DOWN)
    -        {
    -            return lang('enum_half_down');
    -        }
    -        elseif($rounding_code == Rounding_code::HALF_EVEN)
    +/**
    + * Rounding_code class
    + *
    + * @link    github.com/jekkos/opensourcepos
    + * @since   3.1
    + * @author  SteveIreland
    + */
    +
    +class Rounding_code
    +{
    +    const HALF_UP = 0;
    +    const HALF_DOWN = 1;
    +    const HALF_EVEN = 2;
    +    const HALF_ODD = 3;
    +    const ROUND_UP = 4;
    +    const ROUND_DOWN = 5;
    +    const HALF_FIVE = 6;
    +
    +    public static function get_rounding_options()
    +    {
    +        $CI =& get_instance();
    +        $CI->load->helper('language');
    +        return array(
    +            Rounding_code::HALF_UP => lang('enum_half_up'),
    +            Rounding_code::HALF_DOWN => lang('enum_half_down'),
    +            Rounding_code::HALF_EVEN => lang('enum_half_even'),
    +            Rounding_code::HALF_ODD => lang('enum_half_odd'),
    +            Rounding_code::ROUND_UP => lang('enum_round_up'),
    +            Rounding_code::ROUND_DOWN => lang('enum_round_down'),
    +            Rounding_code::HALF_FIVE => lang('enum_half_five')
    +        );
    +    }
    +
    +    public static function get_rounding_code_name($rounding_code)
    +    {
    +        $CI =& get_instance();
    +        $CI->load->helper('language');
    +        if($rounding_code == Rounding_code::HALF_UP)
             {
    -            return lang('enum_half_even');
    +            return lang('enum_half_up');
             }
    -        elseif($rounding_code == Rounding_code::HALF_ODD)
    +        elseif($rounding_code == Rounding_code::HALF_DOWN)
             {
    -            return lang('enum_half_odd');
    +            return lang('enum_half_down');
             }
    -        elseif($rounding_code == Rounding_code::ROUND_UP)
    +        elseif($rounding_code == Rounding_code::HALF_EVEN)
             {
    -            return lang('enum_round_up');
    +            return lang('enum_half_even');
             }
    -        elseif($rounding_code == Rounding_code::ROUND_DOWN)
    +        elseif($rounding_code == Rounding_code::HALF_ODD)
             {
    -            return lang('enum_round_down');
    +            return lang('enum_half_odd');
             }
    -        elseif($rounding_code == Rounding_code::HALF_FIVE)
    +        elseif($rounding_code == Rounding_code::ROUND_UP)
             {
    -            return lang('enum_half_five');
    +            return lang('enum_round_up');
             }
    -        else
    +        elseif($rounding_code == Rounding_code::ROUND_DOWN)
             {
    -            return lang('common_unknown');
    +            return lang('enum_round_down');
             }
    -    }
    -
    -    public static function get_html_rounding_options()
    -    {
    -        $CI =& get_instance();
    -        $CI->load->helper('language');
    -        $x = "<option value='0' selected='selected'>".lang('enum_half_up')."</option>" .
    -        "<option value='1'>".lang('enum_half_down')."</option>" .
    -        "<option value='2'>".lang('enum_half_even')."</option>" .
    -        "<option value='3'>".lang('enum_half_odd')."</option>" .
    -        "<option value='4'>".lang('enum_round_up')."</option>" .
    -        "<option value='5'>".lang('enum_round_down')."</option>" .
    -        "<option value='6'>".lang('enum_half_five')."</option>";
    -
    -        return $x;
    -    }
    -}
    +
    elseif($rounding_code == Rounding_code::HALF_FIVE) + { + return lang('enum_half_five'); + } + else + { + return lang('common_unknown'); + } + } + + public static function get_html_rounding_options() + { + $CI =& get_instance(); + $CI->load->helper('language'); + $x = "<option value='0' selected='selected'>".lang('enum_half_up')."</option>" . + "<option value='1'>".lang('enum_half_down')."</option>" . + "<option value='2'>".lang('enum_half_even')."</option>" . + "<option value='3'>".lang('enum_half_odd')."</option>" . + "<option value='4'>".lang('enum_round_up')."</option>" . + "<option value='5'>".lang('enum_round_down')."</option>" . + "<option value='6'>".lang('enum_half_five')."</option>"; + + return $x; + } +} +
    - + diff --git a/docs/source-class-Sale.html b/docs/source-class-Sale.html index b42c602f9..68202677b 100644 --- a/docs/source-class-Sale.html +++ b/docs/source-class-Sale.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,1217 +207,1337 @@ -
       1:    2:    3:    4:    5:    6:    7:    8:    9:   10:   11:   12:   13:   14:   15:   16:   17:   18:   19:   20:   21:   22:   23:   24:   25:   26:   27:   28:   29:   30:   31:   32:   33:   34:   35:   36:   37:   38:   39:   40:   41:   42:   43:   44:   45:   46:   47:   48:   49:   50:   51:   52:   53:   54:   55:   56:   57:   58:   59:   60:   61:   62:   63:   64:   65:   66:   67:   68:   69:   70:   71:   72:   73:   74:   75:   76:   77:   78:   79:   80:   81:   82:   83:   84:   85:   86:   87:   88:   89:   90:   91:   92:   93:   94:   95:   96:   97:   98:   99:  100:  101:  102:  103:  104:  105:  106:  107:  108:  109:  110:  111:  112:  113:  114:  115:  116:  117:  118:  119:  120:  121:  122:  123:  124:  125:  126:  127:  128:  129:  130:  131:  132:  133:  134:  135:  136:  137:  138:  139:  140:  141:  142:  143:  144:  145:  146:  147:  148:  149:  150:  151:  152:  153:  154:  155:  156:  157:  158:  159:  160:  161:  162:  163:  164:  165:  166:  167:  168:  169:  170:  171:  172:  173:  174:  175:  176:  177:  178:  179:  180:  181:  182:  183:  184:  185:  186:  187:  188:  189:  190:  191:  192:  193:  194:  195:  196:  197:  198:  199:  200:  201:  202:  203:  204:  205:  206:  207:  208:  209:  210:  211:  212:  213:  214:  215:  216:  217:  218:  219:  220:  221:  222:  223:  224:  225:  226:  227:  228:  229:  230:  231:  232:  233:  234:  235:  236:  237:  238:  239:  240:  241:  242:  243:  244:  245:  246:  247:  248:  249:  250:  251:  252:  253:  254:  255:  256:  257:  258:  259:  260:  261:  262:  263:  264:  265:  266:  267:  268:  269:  270:  271:  272:  273:  274:  275:  276:  277:  278:  279:  280:  281:  282:  283:  284:  285:  286:  287:  288:  289:  290:  291:  292:  293:  294:  295:  296:  297:  298:  299:  300:  301:  302:  303:  304:  305:  306:  307:  308:  309:  310:  311:  312:  313:  314:  315:  316:  317:  318:  319:  320:  321:  322:  323:  324:  325:  326:  327:  328:  329:  330:  331:  332:  333:  334:  335:  336:  337:  338:  339:  340:  341:  342:  343:  344:  345:  346:  347:  348:  349:  350:  351:  352:  353:  354:  355:  356:  357:  358:  359:  360:  361:  362:  363:  364:  365:  366:  367:  368:  369:  370:  371:  372:  373:  374:  375:  376:  377:  378:  379:  380:  381:  382:  383:  384:  385:  386:  387:  388:  389:  390:  391:  392:  393:  394:  395:  396:  397:  398:  399:  400:  401:  402:  403:  404:  405:  406:  407:  408:  409:  410:  411:  412:  413:  414:  415:  416:  417:  418:  419:  420:  421:  422:  423:  424:  425:  426:  427:  428:  429:  430:  431:  432:  433:  434:  435:  436:  437:  438:  439:  440:  441:  442:  443:  444:  445:  446:  447:  448:  449:  450:  451:  452:  453:  454:  455:  456:  457:  458:  459:  460:  461:  462:  463:  464:  465:  466:  467:  468:  469:  470:  471:  472:  473:  474:  475:  476:  477:  478:  479:  480:  481:  482:  483:  484:  485:  486:  487:  488:  489:  490:  491:  492:  493:  494:  495:  496:  497:  498:  499:  500:  501:  502:  503:  504:  505:  506:  507:  508:  509:  510:  511:  512:  513:  514:  515:  516:  517:  518:  519:  520:  521:  522:  523:  524:  525:  526:  527:  528:  529:  530:  531:  532:  533:  534:  535:  536:  537:  538:  539:  540:  541:  542:  543:  544:  545:  546:  547:  548:  549:  550:  551:  552:  553:  554:  555:  556:  557:  558:  559:  560:  561:  562:  563:  564:  565:  566:  567:  568:  569:  570:  571:  572:  573:  574:  575:  576:  577:  578:  579:  580:  581:  582:  583:  584:  585:  586:  587:  588:  589:  590:  591:  592:  593:  594:  595:  596:  597:  598:  599:  600:  601:  602:  603:  604:  605:  606:  607:  608:  609:  610:  611:  612:  613:  614:  615:  616:  617:  618:  619:  620:  621:  622:  623:  624:  625:  626:  627:  628:  629:  630:  631:  632:  633:  634:  635:  636:  637:  638:  639:  640:  641:  642:  643:  644:  645:  646:  647:  648:  649:  650:  651:  652:  653:  654:  655:  656:  657:  658:  659:  660:  661:  662:  663:  664:  665:  666:  667:  668:  669:  670:  671:  672:  673:  674:  675:  676:  677:  678:  679:  680:  681:  682:  683:  684:  685:  686:  687:  688:  689:  690:  691:  692:  693:  694:  695:  696:  697:  698:  699:  700:  701:  702:  703:  704:  705:  706:  707:  708:  709:  710:  711:  712:  713:  714:  715:  716:  717:  718:  719:  720:  721:  722:  723:  724:  725:  726:  727:  728:  729:  730:  731:  732:  733:  734:  735:  736:  737:  738:  739:  740:  741:  742:  743:  744:  745:  746:  747:  748:  749:  750:  751:  752:  753:  754:  755:  756:  757:  758:  759:  760:  761:  762:  763:  764:  765:  766:  767:  768:  769:  770:  771:  772:  773:  774:  775:  776:  777:  778:  779:  780:  781:  782:  783:  784:  785:  786:  787:  788:  789:  790:  791:  792:  793:  794:  795:  796:  797:  798:  799:  800:  801:  802:  803:  804:  805:  806:  807:  808:  809:  810:  811:  812:  813:  814:  815:  816:  817:  818:  819:  820:  821:  822:  823:  824:  825:  826:  827:  828:  829:  830:  831:  832:  833:  834:  835:  836:  837:  838:  839:  840:  841:  842:  843:  844:  845:  846:  847:  848:  849:  850:  851:  852:  853:  854:  855:  856:  857:  858:  859:  860:  861:  862:  863:  864:  865:  866:  867:  868:  869:  870:  871:  872:  873:  874:  875:  876:  877:  878:  879:  880:  881:  882:  883:  884:  885:  886:  887:  888:  889:  890:  891:  892:  893:  894:  895:  896:  897:  898:  899:  900:  901:  902:  903:  904:  905:  906:  907:  908:  909:  910:  911:  912:  913:  914:  915:  916:  917:  918:  919:  920:  921:  922:  923:  924:  925:  926:  927:  928:  929:  930:  931:  932:  933:  934:  935:  936:  937:  938:  939:  940:  941:  942:  943:  944:  945:  946:  947:  948:  949:  950:  951:  952:  953:  954:  955:  956:  957:  958:  959:  960:  961:  962:  963:  964:  965:  966:  967:  968:  969:  970:  971:  972:  973:  974:  975:  976:  977:  978:  979:  980:  981:  982:  983:  984:  985:  986:  987:  988:  989:  990:  991:  992:  993:  994:  995:  996:  997:  998:  999: 1000: 1001: 1002: 1003: 1004: 1005: 1006: 1007: 1008: 1009: 1010: 1011: 1012: 1013: 1014: 1015: 1016: 1017: 1018: 1019: 1020: 1021: 1022: 1023: 1024: 1025: 1026: 1027: 1028: 1029: 1030: 1031: 1032: 1033: 1034: 1035: 1036: 1037: 1038: 1039: 1040: 1041: 1042: 1043: 1044: 1045: 1046: 1047: 1048: 1049: 1050: 1051: 1052: 1053: 1054: 1055: 1056: 1057: 1058: 1059: 1060: 1061: 1062: 1063: 1064: 1065: 1066: 1067: 1068: 1069: 1070: 1071: 1072: 1073: 1074: 1075: 1076: 1077: 1078: 1079: 1080: 1081: 1082: 1083: 1084: 1085: 1086: 1087: 1088: 1089: 1090: 1091: 1092: 1093: 1094: 1095: 1096: 1097: 1098: 1099: 1100: 1101: 1102: 1103: 1104: 1105: 1106: 1107: 1108: 1109: 1110: 1111: 1112: 1113: 1114: 1115: 1116: 1117: 1118: 1119: 1120: 1121: 1122: 1123: 1124: 1125: 1126: 1127: 1128: 1129: 1130: 1131: 1132: 1133: 1134: 1135: 1136: 1137: 1138: 1139: 1140: 1141: 1142: 1143: 1144: 1145: 1146: 1147: 1148: 1149: 1150: 1151: 1152: 1153: 1154: 1155: 1156: 1157: 1158: 1159: 1160: 1161: 1162: 1163: 1164: 1165: 1166: 1167: 1168: 1169: 1170: 1171: 1172: 1173: 1174: 1175: 1176: 1177: 1178: 1179: 1180: 1181: 1182: 1183: 1184: 1185: 1186: 1187: 1188: 1189: 1190: 1191: 1192: 1193: 1194: 1195: 1196: 1197: 1198: 1199: 1200: 1201: 1202: 1203: 1204: 1205: 1206: 1207: 1208: 1209: 1210: 
    -
    <?php
    -class Sale extends CI_Model
    -{
    -    public function get_info($sale_id)
    -    {
    -        // NOTE: temporary tables are created to speed up searches due to the fact that they are ortogonal to the main query
    -        // create a temporary table to contain all the payments per sale
    -        $this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_payments_temp') .
    -            '(
    -                SELECT payments.sale_id AS sale_id,
    -                    IFNULL(SUM(payments.payment_amount), 0) AS sale_payment_amount,
    -                    GROUP_CONCAT(CONCAT(payments.payment_type, " ", payments.payment_amount) SEPARATOR ", ") AS payment_type
    -                FROM ' . $this->db->dbprefix('sales_payments') . ' AS payments
    -                INNER JOIN ' . $this->db->dbprefix('sales') . ' AS sales
    -                    ON sales.sale_id = payments.sale_id
    -                WHERE sales.sale_id = ' . $this->db->escape($sale_id) . '
    -                GROUP BY sale_id
    -            )'
    -        );
    -
    -        $sale_price = 'sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100)';
    -
    -        if($this->config->item('tax_included'))
    -        {
    -            $sale_total = 'SUM(' . $sale_price . ')';
    -            $sale_subtotal = 'SUM(' . $sale_price . ' - sales_items_taxes.tax)';
    -            $sale_tax = 'SUM(' . $sale_price . ' * (1 - 100 / (100 + sales_items_taxes.percent)))';
    -        }
    -        else
    -        {
    -            $sale_total = 'SUM(' . $sale_price . ' + sales_items_taxes.tax)';
    -            $sale_subtotal = 'SUM(' . $sale_price . ')';
    -            $sale_tax = 'SUM(' . $sale_price . ' * (sales_items_taxes.percent / 100))';
    -        }
    -
    -        $sale_cost = 'SUM(sales_items.item_cost_price * sales_items.quantity_purchased)';
    -
    -        $decimals = totals_decimals();
    -
    -        // create a temporary table to contain all the sum of taxes per sale item
    -        $this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_items_taxes_temp') .
    -            '(
    -                SELECT sales_items_taxes.sale_id AS sale_id,
    -                    sales_items_taxes.item_id AS item_id,
    -                    sales_items_taxes.line AS line,
    -                    ' . "
    -                    IFNULL(ROUND($sale_tax, $decimals), 0) AS tax
    -                    " . '
    -                FROM ' . $this->db->dbprefix('sales_items_taxes') . ' AS sales_items_taxes
    -                INNER JOIN ' . $this->db->dbprefix('sales') . ' AS sales
    -                    ON sales.sale_id = sales_items_taxes.sale_id
    -                INNER JOIN ' . $this->db->dbprefix('sales_items') . ' AS sales_items
    -                    ON sales_items.sale_id = sales_items_taxes.sale_id AND sales_items.line = sales_items_taxes.line
    -                WHERE sales.sale_id = ' . $this->db->escape($sale_id) . '
    -                GROUP BY sale_id, item_id, line
    -            )'
    -        );
    -
    -        $this->db->select('
    -                sales.sale_id AS sale_id,
    -                MAX(DATE(sales.sale_time)) AS sale_date,
    -                MAX(sales.sale_time) AS sale_time,
    -                MAX(sales.comment) AS comment,
    -                MAX(sales.sale_status) AS sale_status,
    -                MAX(sales.invoice_number) AS invoice_number,
    -                MAX(sales.quote_number) AS quote_number,
    -                MAX(sales.employee_id) AS employee_id,
    -                MAX(sales.customer_id) AS customer_id,
    -                MAX(CONCAT(customer_p.first_name, " ", customer_p.last_name)) AS customer_name,
    -                MAX(customer_p.first_name) AS first_name,
    -                MAX(customer_p.last_name) AS last_name,
    -                MAX(customer_p.email) AS email,
    -                MAX(customer_p.comments) AS comments,
    -                ' . "
    -                IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals)) AS amount_due,
    -                MAX(payments.sale_payment_amount) AS amount_tendered,
    -                (MAX(payments.sale_payment_amount) - IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals))) AS change_due,
    -                " . '
    -                MAX(payments.payment_type) AS payment_type
    -        ');
    -
    -        $this->db->from('sales_items AS sales_items');
    -        $this->db->join('sales AS sales', 'sales_items.sale_id = sales.sale_id', 'inner');
    -        $this->db->join('people AS customer_p', 'sales.customer_id = customer_p.person_id', 'left');
    -        $this->db->join('customers AS customer', 'sales.customer_id = customer.person_id', 'left');
    -        $this->db->join('sales_payments_temp AS payments', 'sales.sale_id = payments.sale_id', 'left outer');
    -        $this->db->join('sales_items_taxes_temp AS sales_items_taxes',
    -            'sales_items.sale_id = sales_items_taxes.sale_id AND sales_items.item_id = sales_items_taxes.item_id AND sales_items.line = sales_items_taxes.line',
    -            'left outer');
    -
    -        $this->db->where('sales.sale_id', $sale_id);
    -
    -        $this->db->group_by('sale_id');
    -        $this->db->order_by('sale_time', 'asc');
    -
    -        return $this->db->get();
    -    }
    +
       1:    2:    3:    4:    5:    6:    7:    8:    9:   10:   11:   12:   13:   14:   15:   16:   17:   18:   19:   20:   21:   22:   23:   24:   25:   26:   27:   28:   29:   30:   31:   32:   33:   34:   35:   36:   37:   38:   39:   40:   41:   42:   43:   44:   45:   46:   47:   48:   49:   50:   51:   52:   53:   54:   55:   56:   57:   58:   59:   60:   61:   62:   63:   64:   65:   66:   67:   68:   69:   70:   71:   72:   73:   74:   75:   76:   77:   78:   79:   80:   81:   82:   83:   84:   85:   86:   87:   88:   89:   90:   91:   92:   93:   94:   95:   96:   97:   98:   99:  100:  101:  102:  103:  104:  105:  106:  107:  108:  109:  110:  111:  112:  113:  114:  115:  116:  117:  118:  119:  120:  121:  122:  123:  124:  125:  126:  127:  128:  129:  130:  131:  132:  133:  134:  135:  136:  137:  138:  139:  140:  141:  142:  143:  144:  145:  146:  147:  148:  149:  150:  151:  152:  153:  154:  155:  156:  157:  158:  159:  160:  161:  162:  163:  164:  165:  166:  167:  168:  169:  170:  171:  172:  173:  174:  175:  176:  177:  178:  179:  180:  181:  182:  183:  184:  185:  186:  187:  188:  189:  190:  191:  192:  193:  194:  195:  196:  197:  198:  199:  200:  201:  202:  203:  204:  205:  206:  207:  208:  209:  210:  211:  212:  213:  214:  215:  216:  217:  218:  219:  220:  221:  222:  223:  224:  225:  226:  227:  228:  229:  230:  231:  232:  233:  234:  235:  236:  237:  238:  239:  240:  241:  242:  243:  244:  245:  246:  247:  248:  249:  250:  251:  252:  253:  254:  255:  256:  257:  258:  259:  260:  261:  262:  263:  264:  265:  266:  267:  268:  269:  270:  271:  272:  273:  274:  275:  276:  277:  278:  279:  280:  281:  282:  283:  284:  285:  286:  287:  288:  289:  290:  291:  292:  293:  294:  295:  296:  297:  298:  299:  300:  301:  302:  303:  304:  305:  306:  307:  308:  309:  310:  311:  312:  313:  314:  315:  316:  317:  318:  319:  320:  321:  322:  323:  324:  325:  326:  327:  328:  329:  330:  331:  332:  333:  334:  335:  336:  337:  338:  339:  340:  341:  342:  343:  344:  345:  346:  347:  348:  349:  350:  351:  352:  353:  354:  355:  356:  357:  358:  359:  360:  361:  362:  363:  364:  365:  366:  367:  368:  369:  370:  371:  372:  373:  374:  375:  376:  377:  378:  379:  380:  381:  382:  383:  384:  385:  386:  387:  388:  389:  390:  391:  392:  393:  394:  395:  396:  397:  398:  399:  400:  401:  402:  403:  404:  405:  406:  407:  408:  409:  410:  411:  412:  413:  414:  415:  416:  417:  418:  419:  420:  421:  422:  423:  424:  425:  426:  427:  428:  429:  430:  431:  432:  433:  434:  435:  436:  437:  438:  439:  440:  441:  442:  443:  444:  445:  446:  447:  448:  449:  450:  451:  452:  453:  454:  455:  456:  457:  458:  459:  460:  461:  462:  463:  464:  465:  466:  467:  468:  469:  470:  471:  472:  473:  474:  475:  476:  477:  478:  479:  480:  481:  482:  483:  484:  485:  486:  487:  488:  489:  490:  491:  492:  493:  494:  495:  496:  497:  498:  499:  500:  501:  502:  503:  504:  505:  506:  507:  508:  509:  510:  511:  512:  513:  514:  515:  516:  517:  518:  519:  520:  521:  522:  523:  524:  525:  526:  527:  528:  529:  530:  531:  532:  533:  534:  535:  536:  537:  538:  539:  540:  541:  542:  543:  544:  545:  546:  547:  548:  549:  550:  551:  552:  553:  554:  555:  556:  557:  558:  559:  560:  561:  562:  563:  564:  565:  566:  567:  568:  569:  570:  571:  572:  573:  574:  575:  576:  577:  578:  579:  580:  581:  582:  583:  584:  585:  586:  587:  588:  589:  590:  591:  592:  593:  594:  595:  596:  597:  598:  599:  600:  601:  602:  603:  604:  605:  606:  607:  608:  609:  610:  611:  612:  613:  614:  615:  616:  617:  618:  619:  620:  621:  622:  623:  624:  625:  626:  627:  628:  629:  630:  631:  632:  633:  634:  635:  636:  637:  638:  639:  640:  641:  642:  643:  644:  645:  646:  647:  648:  649:  650:  651:  652:  653:  654:  655:  656:  657:  658:  659:  660:  661:  662:  663:  664:  665:  666:  667:  668:  669:  670:  671:  672:  673:  674:  675:  676:  677:  678:  679:  680:  681:  682:  683:  684:  685:  686:  687:  688:  689:  690:  691:  692:  693:  694:  695:  696:  697:  698:  699:  700:  701:  702:  703:  704:  705:  706:  707:  708:  709:  710:  711:  712:  713:  714:  715:  716:  717:  718:  719:  720:  721:  722:  723:  724:  725:  726:  727:  728:  729:  730:  731:  732:  733:  734:  735:  736:  737:  738:  739:  740:  741:  742:  743:  744:  745:  746:  747:  748:  749:  750:  751:  752:  753:  754:  755:  756:  757:  758:  759:  760:  761:  762:  763:  764:  765:  766:  767:  768:  769:  770:  771:  772:  773:  774:  775:  776:  777:  778:  779:  780:  781:  782:  783:  784:  785:  786:  787:  788:  789:  790:  791:  792:  793:  794:  795:  796:  797:  798:  799:  800:  801:  802:  803:  804:  805:  806:  807:  808:  809:  810:  811:  812:  813:  814:  815:  816:  817:  818:  819:  820:  821:  822:  823:  824:  825:  826:  827:  828:  829:  830:  831:  832:  833:  834:  835:  836:  837:  838:  839:  840:  841:  842:  843:  844:  845:  846:  847:  848:  849:  850:  851:  852:  853:  854:  855:  856:  857:  858:  859:  860:  861:  862:  863:  864:  865:  866:  867:  868:  869:  870:  871:  872:  873:  874:  875:  876:  877:  878:  879:  880:  881:  882:  883:  884:  885:  886:  887:  888:  889:  890:  891:  892:  893:  894:  895:  896:  897:  898:  899:  900:  901:  902:  903:  904:  905:  906:  907:  908:  909:  910:  911:  912:  913:  914:  915:  916:  917:  918:  919:  920:  921:  922:  923:  924:  925:  926:  927:  928:  929:  930:  931:  932:  933:  934:  935:  936:  937:  938:  939:  940:  941:  942:  943:  944:  945:  946:  947:  948:  949:  950:  951:  952:  953:  954:  955:  956:  957:  958:  959:  960:  961:  962:  963:  964:  965:  966:  967:  968:  969:  970:  971:  972:  973:  974:  975:  976:  977:  978:  979:  980:  981:  982:  983:  984:  985:  986:  987:  988:  989:  990:  991:  992:  993:  994:  995:  996:  997:  998:  999: 1000: 1001: 1002: 1003: 1004: 1005: 1006: 1007: 1008: 1009: 1010: 1011: 1012: 1013: 1014: 1015: 1016: 1017: 1018: 1019: 1020: 1021: 1022: 1023: 1024: 1025: 1026: 1027: 1028: 1029: 1030: 1031: 1032: 1033: 1034: 1035: 1036: 1037: 1038: 1039: 1040: 1041: 1042: 1043: 1044: 1045: 1046: 1047: 1048: 1049: 1050: 1051: 1052: 1053: 1054: 1055: 1056: 1057: 1058: 1059: 1060: 1061: 1062: 1063: 1064: 1065: 1066: 1067: 1068: 1069: 1070: 1071: 1072: 1073: 1074: 1075: 1076: 1077: 1078: 1079: 1080: 1081: 1082: 1083: 1084: 1085: 1086: 1087: 1088: 1089: 1090: 1091: 1092: 1093: 1094: 1095: 1096: 1097: 1098: 1099: 1100: 1101: 1102: 1103: 1104: 1105: 1106: 1107: 1108: 1109: 1110: 1111: 1112: 1113: 1114: 1115: 1116: 1117: 1118: 1119: 1120: 1121: 1122: 1123: 1124: 1125: 1126: 1127: 1128: 1129: 1130: 1131: 1132: 1133: 1134: 1135: 1136: 1137: 1138: 1139: 1140: 1141: 1142: 1143: 1144: 1145: 1146: 1147: 1148: 1149: 1150: 1151: 1152: 1153: 1154: 1155: 1156: 1157: 1158: 1159: 1160: 1161: 1162: 1163: 1164: 1165: 1166: 1167: 1168: 1169: 1170: 1171: 1172: 1173: 1174: 1175: 1176: 1177: 1178: 1179: 1180: 1181: 1182: 1183: 1184: 1185: 1186: 1187: 1188: 1189: 1190: 1191: 1192: 1193: 1194: 1195: 1196: 1197: 1198: 1199: 1200: 1201: 1202: 1203: 1204: 1205: 1206: 1207: 1208: 1209: 1210: 1211: 1212: 1213: 1214: 1215: 1216: 1217: 1218: 1219: 1220: 1221: 1222: 1223: 1224: 1225: 1226: 1227: 1228: 1229: 1230: 1231: 1232: 1233: 1234: 1235: 1236: 1237: 1238: 1239: 1240: 1241: 1242: 1243: 1244: 1245: 1246: 1247: 1248: 1249: 1250: 1251: 1252: 1253: 1254: 1255: 1256: 1257: 1258: 1259: 1260: 1261: 1262: 1263: 1264: 1265: 1266: 1267: 1268: 1269: 1270: 1271: 1272: 1273: 1274: 1275: 1276: 1277: 1278: 1279: 1280: 1281: 1282: 1283: 1284: 1285: 1286: 1287: 1288: 1289: 1290: 1291: 1292: 1293: 1294: 1295: 1296: 1297: 1298: 1299: 1300: 1301: 1302: 1303: 1304: 1305: 1306: 1307: 1308: 1309: 1310: 1311: 1312: 1313: 1314: 1315: 1316: 1317: 1318: 1319: 1320: 1321: 1322: 1323: 1324: 1325: 1326: 1327: 1328: 1329: 1330: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
    +
    +/**
    + * Sale class
    + *
    + * @link    github.com/jekkos/opensourcepos
    + * @since   1.0
    + * @author  N/A
    + */
    +
    +class Sale extends CI_Model
    +{
    +    /**
    +     * Get sale info
    +     */
    +    public function get_info($sale_id)
    +    {
    +        // NOTE: temporary tables are created to speed up searches due to the fact that they are ortogonal to the main query
    +        // create a temporary table to contain all the payments per sale
    +        $this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_payments_temp') .
    +            '(
    +                SELECT payments.sale_id AS sale_id,
    +                    IFNULL(SUM(payments.payment_amount), 0) AS sale_payment_amount,
    +                    GROUP_CONCAT(CONCAT(payments.payment_type, " ", payments.payment_amount) SEPARATOR ", ") AS payment_type
    +                FROM ' . $this->db->dbprefix('sales_payments') . ' AS payments
    +                INNER JOIN ' . $this->db->dbprefix('sales') . ' AS sales
    +                    ON sales.sale_id = payments.sale_id
    +                WHERE sales.sale_id = ' . $this->db->escape($sale_id) . '
    +                GROUP BY sale_id
    +            )'
    +        );
    +
    +        $sale_price = 'sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100)';
    +
    +        if($this->config->item('tax_included'))
    +        {
    +            $sale_total = 'SUM(' . $sale_price . ')';
    +            $sale_subtotal = 'SUM(' . $sale_price . ' - sales_items_taxes.tax)';
    +        }
    +        else
    +        {
    +            $sale_total = 'SUM(' . $sale_price . ' + sales_items_taxes.tax)';
    +            $sale_subtotal = 'SUM(' . $sale_price . ')';
    +        }
    +
    +        $sale_cost = 'SUM(sales_items.item_cost_price * sales_items.quantity_purchased)';
    +
    +        $decimals = totals_decimals();
    +
    +        // create a temporary table to contain all the sum of taxes per sale item
    +        $this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_items_taxes_temp') .
    +            '(
    +                SELECT sales_items_taxes.sale_id AS sale_id,
    +                    sales_items_taxes.item_id AS item_id,
    +                    sales_items_taxes.line AS line,
    +                    SUM(sales_items_taxes.item_tax_amount) AS tax
    +                FROM ' . $this->db->dbprefix('sales_items_taxes') . ' AS sales_items_taxes
    +                INNER JOIN ' . $this->db->dbprefix('sales') . ' AS sales
    +                    ON sales.sale_id = sales_items_taxes.sale_id
    +                INNER JOIN ' . $this->db->dbprefix('sales_items') . ' AS sales_items
    +                    ON sales_items.sale_id = sales_items_taxes.sale_id AND sales_items.line = sales_items_taxes.line
    +                WHERE sales.sale_id = ' . $this->db->escape($sale_id) . '
    +                GROUP BY sale_id, item_id, line
    +            )'
    +        );
    +
    +        $this->db->select('
    +                sales.sale_id AS sale_id,
    +                MAX(DATE(sales.sale_time)) AS sale_date,
    +                MAX(sales.sale_time) AS sale_time,
    +                MAX(sales.comment) AS comment,
    +                MAX(sales.sale_status) AS sale_status,
    +                MAX(sales.invoice_number) AS invoice_number,
    +                MAX(sales.quote_number) AS quote_number,
    +                MAX(sales.employee_id) AS employee_id,
    +                MAX(sales.customer_id) AS customer_id,
    +                MAX(CONCAT(customer_p.first_name, " ", customer_p.last_name)) AS customer_name,
    +                MAX(customer_p.first_name) AS first_name,
    +                MAX(customer_p.last_name) AS last_name,
    +                MAX(customer_p.email) AS email,
    +                MAX(customer_p.comments) AS comments,
    +                ' . "
    +                IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals)) AS amount_due,
    +                MAX(payments.sale_payment_amount) AS amount_tendered,
    +                (MAX(payments.sale_payment_amount) - IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals))) AS change_due,
    +                " . '
    +                MAX(payments.payment_type) AS payment_type
    +        ');
    +
    +        $this->db->from('sales_items AS sales_items');
    +        $this->db->join('sales AS sales', 'sales_items.sale_id = sales.sale_id', 'inner');
    +        $this->db->join('people AS customer_p', 'sales.customer_id = customer_p.person_id', 'left');
    +        $this->db->join('customers AS customer', 'sales.customer_id = customer.person_id', 'left');
    +        $this->db->join('sales_payments_temp AS payments', 'sales.sale_id = payments.sale_id', 'left outer');
    +        $this->db->join('sales_items_taxes_temp AS sales_items_taxes',
    +            'sales_items.sale_id = sales_items_taxes.sale_id AND sales_items.item_id = sales_items_taxes.item_id AND sales_items.line = sales_items_taxes.line',
    +            'left outer');
     
    -    /*
    -     Get number of rows for the takings (sales/manage) view
    -    */
    -    public function get_found_rows($search, $filters)
    -    {
    -        return $this->search($search, $filters)->num_rows();
    +        $this->db->where('sales.sale_id', $sale_id);
    +
    +        $this->db->group_by('sale_id');
    +        $this->db->order_by('sale_time', 'asc');
    +
    +        return $this->db->get();
         }
     
    -    /*
    -     Get the sales data for the takings (sales/manage) view
    -    */
    -    public function search($search, $filters, $rows = 0, $limit_from = 0, $sort = 'sale_time', $order = 'desc')
    +    /**
    +     * Get number of rows for the takings (sales/manage) view
    +     */
    +    public function get_found_rows($search, $filters)
         {
    -        $where = '';
    -
    -        if(empty($this->config->item('date_or_time_format')))
    -        {
    -            $where .= 'DATE(sales.sale_time) BETWEEN ' . $this->db->escape($filters['start_date']) . ' AND ' . $this->db->escape($filters['end_date']) . ' AND sales.sale_status = 0 ';
    -        }
    -        else
    -        {
    -            $where .= 'sales.sale_time BETWEEN ' . $this->db->escape(rawurldecode($filters['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($filters['end_date'])) . ' AND sales.sale_status = 0 ';
    -        }
    -
    -        // NOTE: temporary tables are created to speed up searches due to the fact that they are ortogonal to the main query
    -        // create a temporary table to contain all the payments per sale item
    -        $this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_payments_temp') .
    -            ' (PRIMARY KEY(sale_id), INDEX(sale_id))
    -            (
    -                SELECT payments.sale_id AS sale_id,
    -                    IFNULL(SUM(payments.payment_amount), 0) AS sale_payment_amount,
    -                    GROUP_CONCAT(CONCAT(payments.payment_type, " ", payments.payment_amount) SEPARATOR ", ") AS payment_type
    -                FROM ' . $this->db->dbprefix('sales_payments') . ' AS payments
    -                INNER JOIN ' . $this->db->dbprefix('sales') . ' AS sales
    -                    ON sales.sale_id = payments.sale_id
    -                WHERE ' . $where . '
    -                GROUP BY sale_id
    -            )'
    -        );
    -
    -        $sale_price = 'sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100)';
    -
    -        if($this->config->item('tax_included'))
    -        {
    -            $sale_total = 'SUM(' . $sale_price . ')';
    -            $sale_subtotal = 'SUM(' . $sale_price . ' - sales_items_taxes.tax)';
    -            $sale_tax = 'SUM(' . $sale_price . ' * (1 - 100 / (100 + sales_items_taxes.percent)))';
    -        }
    -        else
    -        {
    -            $sale_total = 'SUM(' . $sale_price . ' + sales_items_taxes.tax)';
    -            $sale_subtotal = 'SUM(' . $sale_price . ')';
    -            $sale_tax = 'SUM(' . $sale_price . ' * (sales_items_taxes.percent / 100))';
    -        }
    -
    -        $sale_cost = 'SUM(sales_items.item_cost_price * sales_items.quantity_purchased)';
    -
    -        $decimals = totals_decimals();
    -
    -        // create a temporary table to contain all the sum of taxes per sale item
    -        $this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_items_taxes_temp') .
    -            ' (INDEX(sale_id), INDEX(item_id))
    -            (
    -                SELECT sales_items_taxes.sale_id AS sale_id,
    -                    sales_items_taxes.item_id AS item_id,
    -                    sales_items_taxes.line AS line,
    -                    ' . "
    -                    IFNULL(ROUND($sale_tax, $decimals), 0) AS tax
    -                    " . '
    -                FROM ' . $this->db->dbprefix('sales_items_taxes') . ' AS sales_items_taxes
    -                INNER JOIN ' . $this->db->dbprefix('sales') . ' AS sales
    -                    ON sales.sale_id = sales_items_taxes.sale_id
    -                INNER JOIN ' . $this->db->dbprefix('sales_items') . ' AS sales_items
    -                    ON sales_items.sale_id = sales_items_taxes.sale_id AND sales_items.line = sales_items_taxes.line
    -                WHERE ' . $where . '
    -                GROUP BY sale_id, item_id, line
    -            )'
    -        );
    -
    -        $this->db->select('
    -                sales.sale_id AS sale_id,
    -                MAX(DATE(sales.sale_time)) AS sale_date,
    -                MAX(sales.sale_time) AS sale_time,
    -                MAX(sales.invoice_number) AS invoice_number,
    -                MAX(sales.quote_number) AS quote_number,
    -                SUM(sales_items.quantity_purchased) AS items_purchased,
    -                MAX(CONCAT(customer_p.first_name, " ", customer_p.last_name)) AS customer_name,
    -                MAX(customer.company_name) AS company_name,
    -                ' . "
    -                IFNULL(ROUND($sale_subtotal, $decimals), ROUND($sale_total - IFNULL(SUM(sales_items_taxes.tax), 0), $decimals)) AS subtotal,
    -                IFNULL(ROUND(SUM(sales_items_taxes.tax), $decimals), 0) AS tax,
    -                IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals)) AS total,
    -                IFNULL(ROUND($sale_cost, $decimals), 0) AS cost,
    -                IFNULL(ROUND($sale_total - IFNULL(SUM(sales_items_taxes.tax), 0) - $sale_cost, $decimals), ROUND($sale_subtotal - $sale_cost, $decimals)) AS profit,
    -                IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals)) AS amount_due,
    -                MAX(payments.sale_payment_amount) AS amount_tendered,
    -                (MAX(payments.sale_payment_amount) - IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals))) AS change_due,
    -                " . '
    -                MAX(payments.payment_type) AS payment_type
    -        ');
    -
    -        $this->db->from('sales_items AS sales_items');
    -        $this->db->join('sales AS sales', 'sales_items.sale_id = sales.sale_id', 'inner');
    -        $this->db->join('people AS customer_p', 'sales.customer_id = customer_p.person_id', 'left');
    -        $this->db->join('customers AS customer', 'sales.customer_id = customer.person_id', 'left');
    -        $this->db->join('sales_payments_temp AS payments', 'sales.sale_id = payments.sale_id', 'left outer');
    -        $this->db->join('sales_items_taxes_temp AS sales_items_taxes',
    -            'sales_items.sale_id = sales_items_taxes.sale_id AND sales_items.item_id = sales_items_taxes.item_id AND sales_items.line = sales_items_taxes.line',
    -            'left outer');
    -
    -        $this->db->where($where);
    -
    -        if(!empty($search))
    -        {
    -            if($filters['is_valid_receipt'] != FALSE)
    -            {
    -                $pieces = explode(' ', $search);
    -                $this->db->where('sales.sale_id', $pieces[1]);
    -            }
    -            else
    -            {
    -                $this->db->group_start();
    -                    // customer last name
    -                    $this->db->like('customer_p.last_name', $search);
    -                    // customer first name
    -                    $this->db->or_like('customer_p.first_name', $search);
    -                    // customer first and last name
    -                    $this->db->or_like('CONCAT(customer_p.first_name, " ", customer_p.last_name)', $search);
    -                    // customer company name
    -                    $this->db->or_like('customer.company_name', $search);
    -                $this->db->group_end();
    -            }
    -        }
    -
    -        if($filters['location_id'] != 'all')
    -        {
    -            $this->db->where('sales_items.item_location', $filters['location_id']);
    -        }
    -
    -        if($filters['sale_type'] == 'sales')
    -        {
    -            $this->db->where('sales_items.quantity_purchased > 0');
    -        }
    -        elseif($filters['sale_type'] == 'returns')
    +        return $this->search($search, $filters)->num_rows();
    +    }
    +
    +    /**
    +     * Get the sales data for the takings (sales/manage) view
    +     */
    +    public function search($search, $filters, $rows = 0, $limit_from = 0, $sort = 'sale_time', $order = 'desc')
    +    {
    +        $where = '';
    +
    +        if(empty($this->config->item('date_or_time_format')))
    +        {
    +            $where .= 'DATE(sales.sale_time) BETWEEN ' . $this->db->escape($filters['start_date']) . ' AND ' . $this->db->escape($filters['end_date']) . ' AND sales.sale_status = 0 ';
    +        }
    +        else
    +        {
    +            $where .= 'sales.sale_time BETWEEN ' . $this->db->escape(rawurldecode($filters['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($filters['end_date'])) . ' AND sales.sale_status = 0 ';
    +        }
    +
    +        // NOTE: temporary tables are created to speed up searches due to the fact that they are ortogonal to the main query
    +        // create a temporary table to contain all the payments per sale item
    +        $this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_payments_temp') .
    +            ' (PRIMARY KEY(sale_id), INDEX(sale_id))
    +            (
    +                SELECT payments.sale_id AS sale_id,
    +                    IFNULL(SUM(payments.payment_amount), 0) AS sale_payment_amount,
    +                    GROUP_CONCAT(CONCAT(payments.payment_type, " ", payments.payment_amount) SEPARATOR ", ") AS payment_type
    +                FROM ' . $this->db->dbprefix('sales_payments') . ' AS payments
    +                INNER JOIN ' . $this->db->dbprefix('sales') . ' AS sales
    +                    ON sales.sale_id = payments.sale_id
    +                WHERE ' . $where . '
    +                GROUP BY sale_id
    +            )'
    +        );
    +
    +        $sale_price = 'sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100)';
    +
    +        if($this->config->item('tax_included'))
    +        {
    +            $sale_total = 'SUM(' . $sale_price . ')';
    +            $sale_subtotal = 'SUM(' . $sale_price . ' - sales_items_taxes.tax)';
    +        }
    +        else
    +        {
    +            $sale_total = 'SUM(' . $sale_price . ' + sales_items_taxes.tax)';
    +            $sale_subtotal = 'SUM(' . $sale_price . ')';
    +        }
    +
    +        $sale_cost = 'SUM(sales_items.item_cost_price * sales_items.quantity_purchased)';
    +
    +        $decimals = totals_decimals();
    +
    +        // create a temporary table to contain all the sum of taxes per sale item
    +        $this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_items_taxes_temp') .
    +            ' (INDEX(sale_id), INDEX(item_id))
    +            (
    +                SELECT sales_items_taxes.sale_id AS sale_id,
    +                    sales_items_taxes.item_id AS item_id,
    +                    sales_items_taxes.line AS line,
    +                    SUM(sales_items_taxes.item_tax_amount) as tax
    +                FROM ' . $this->db->dbprefix('sales_items_taxes') . ' AS sales_items_taxes
    +                INNER JOIN ' . $this->db->dbprefix('sales') . ' AS sales
    +                    ON sales.sale_id = sales_items_taxes.sale_id
    +                INNER JOIN ' . $this->db->dbprefix('sales_items') . ' AS sales_items
    +                    ON sales_items.sale_id = sales_items_taxes.sale_id AND sales_items.line = sales_items_taxes.line
    +                WHERE ' . $where . '
    +                GROUP BY sale_id, item_id, line
    +            )'
    +        );
    +
    +        $this->db->select('
    +                sales.sale_id AS sale_id,
    +                MAX(DATE(sales.sale_time)) AS sale_date,
    +                MAX(sales.sale_time) AS sale_time,
    +                MAX(sales.invoice_number) AS invoice_number,
    +                MAX(sales.quote_number) AS quote_number,
    +                SUM(sales_items.quantity_purchased) AS items_purchased,
    +                MAX(CONCAT(customer_p.first_name, " ", customer_p.last_name)) AS customer_name,
    +                MAX(customer.company_name) AS company_name,
    +                ' . "
    +                IFNULL(ROUND($sale_subtotal, $decimals), ROUND($sale_total - IFNULL(SUM(sales_items_taxes.tax), 0), $decimals)) AS subtotal,
    +                IFNULL(ROUND(SUM(sales_items_taxes.tax), $decimals), 0) AS tax,
    +                IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals)) AS total,
    +                IFNULL(ROUND($sale_cost, $decimals), 0) AS cost,
    +                IFNULL(ROUND($sale_total - IFNULL(SUM(sales_items_taxes.tax), 0) - $sale_cost, $decimals), ROUND($sale_subtotal - $sale_cost, $decimals)) AS profit,
    +                IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals)) AS amount_due,
    +                MAX(payments.sale_payment_amount) AS amount_tendered,
    +                (MAX(payments.sale_payment_amount) - IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals))) AS change_due,
    +                " . '
    +                MAX(payments.payment_type) AS payment_type
    +        ');
    +
    +        $this->db->from('sales_items AS sales_items');
    +        $this->db->join('sales AS sales', 'sales_items.sale_id = sales.sale_id', 'inner');
    +        $this->db->join('people AS customer_p', 'sales.customer_id = customer_p.person_id', 'left');
    +        $this->db->join('customers AS customer', 'sales.customer_id = customer.person_id', 'left');
    +        $this->db->join('sales_payments_temp AS payments', 'sales.sale_id = payments.sale_id', 'left outer');
    +        $this->db->join('sales_items_taxes_temp AS sales_items_taxes',
    +            'sales_items.sale_id = sales_items_taxes.sale_id AND sales_items.item_id = sales_items_taxes.item_id AND sales_items.line = sales_items_taxes.line',
    +            'left outer');
    +
    +        $this->db->where($where);
    +
    +        if(!empty($search))
    +        {
    +            if($filters['is_valid_receipt'] != FALSE)
    +            {
    +                $pieces = explode(' ', $search);
    +                $this->db->where('sales.sale_id', $pieces[1]);
    +            }
    +            else
    +            {
    +                $this->db->group_start();
    +                    // customer last name
    +                    $this->db->like('customer_p.last_name', $search);
    +                    // customer first name
    +                    $this->db->or_like('customer_p.first_name', $search);
    +                    // customer first and last name
    +                    $this->db->or_like('CONCAT(customer_p.first_name, " ", customer_p.last_name)', $search);
    +                    // customer company name
    +                    $this->db->or_like('customer.company_name', $search);
    +                $this->db->group_end();
    +            }
    +        }
    +
    +        if($filters['location_id'] != 'all')
    +        {
    +            $this->db->where('sales_items.item_location', $filters['location_id']);
    +        }
    +
    +        if($filters['sale_type'] == 'sales')
             {
    -            $this->db->where('sales_items.quantity_purchased < 0');
    +            $this->db->where('sales_items.quantity_purchased > 0');
             }
    -
    -        if($filters['only_invoices'] != FALSE)
    -        {
    -            $this->db->where('sales.invoice_number IS NOT NULL');
    -        }
    -
    -        if($filters['only_cash'] != FALSE)
    -        {
    -            $this->db->group_start();
    -                $this->db->like('payments.payment_type', $this->lang->line('sales_cash'), 'after');
    -                $this->db->or_where('payments.payment_type IS NULL');
    -            $this->db->group_end();
    -        }
    -
    -        if($filters['only_check'] != FALSE)
    -        {
    -            $this->db->like('payments.payment_type', $this->lang->line('sales_check'), 'after');
    -        }
    -
    -        $this->db->group_by('sale_id');
    -        $this->db->order_by($sort, $order);
    -
    -        if($rows > 0)
    -        {
    -            $this->db->limit($rows, $limit_from);
    -        }
    -
    -        return $this->db->get();
    -    }
    -
    -    /*
    -     Get the payment summary for the takings (sales/manage) view
    -    */
    -    public function get_payments_summary($search, $filters)
    -    {
    -        // get payment summary
    -        $this->db->select('payment_type, count(*) AS count, SUM(payment_amount) AS payment_amount');
    -        $this->db->from('sales AS sales');
    -        $this->db->join('sales_payments', 'sales_payments.sale_id = sales.sale_id');
    -        $this->db->join('people AS customer_p', 'sales.customer_id = customer_p.person_id', 'left');
    -        $this->db->join('customers AS customer', 'sales.customer_id = customer.person_id', 'left');
    -
    -        if(empty($this->config->item('date_or_time_format')))
    -        {
    -            $this->db->where('DATE(sales.sale_time) BETWEEN ' . $this->db->escape($filters['start_date']) . ' AND ' . $this->db->escape($filters['end_date']));
    -        }
    -        else
    +        elseif($filters['sale_type'] == 'returns')
    +        {
    +            $this->db->where('sales_items.quantity_purchased < 0');
    +        }
    +
    +        if($filters['only_invoices'] != FALSE)
    +        {
    +            $this->db->where('sales.invoice_number IS NOT NULL');
    +        }
    +
    +        if($filters['only_cash'] != FALSE)
    +        {
    +            $this->db->group_start();
    +                $this->db->like('payments.payment_type', $this->lang->line('sales_cash'));
    +                $this->db->or_where('payments.payment_type IS NULL');
    +            $this->db->group_end();
    +        }
    +
    +        if($filters['only_check'] != FALSE)
    +        {
    +            $this->db->like('payments.payment_type', $this->lang->line('sales_check'));
    +        }
    +
    +        $this->db->group_by('sale_id');
    +        $this->db->order_by($sort, $order);
    +
    +        if($rows > 0)
    +        {
    +            $this->db->limit($rows, $limit_from);
    +        }
    +
    +        return $this->db->get();
    +    }
    +
    +    /**
    +     * Get the payment summary for the takings (sales/manage) view
    +     */
    +    public function get_payments_summary($search, $filters)
    +    {
    +        // get payment summary
    +        $this->db->select('payment_type, count(*) AS count, SUM(payment_amount) AS payment_amount');
    +        $this->db->from('sales AS sales');
    +        $this->db->join('sales_payments', 'sales_payments.sale_id = sales.sale_id');
    +        $this->db->join('people AS customer_p', 'sales.customer_id = customer_p.person_id', 'left');
    +        $this->db->join('customers AS customer', 'sales.customer_id = customer.person_id', 'left');
    +
    +        if(empty($this->config->item('date_or_time_format')))
             {
    -            $this->db->where('sales.sale_time BETWEEN ' . $this->db->escape(rawurldecode($filters['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($filters['end_date'])));
    +            $this->db->where('DATE(sales.sale_time) BETWEEN ' . $this->db->escape($filters['start_date']) . ' AND ' . $this->db->escape($filters['end_date']));
             }
    -
    -        if(!empty($search))
    -        {
    -            if($filters['is_valid_receipt'] != FALSE)
    -            {
    -                $pieces = explode(' ',$search);
    -                $this->db->where('sales.sale_id', $pieces[1]);
    -            }
    -            else
    -            {
    -                $this->db->group_start();
    -                    // customer last name
    -                    $this->db->like('customer_p.last_name', $search);
    -                    // customer first name
    -                    $this->db->or_like('customer_p.first_name', $search);
    -                    // customer first and last name
    -                    $this->db->or_like('CONCAT(customer_p.first_name, " ", customer_p.last_name)', $search);
    -                    // customer company name
    -                    $this->db->or_like('customer.company_name', $search);
    -                $this->db->group_end();
    -            }
    -        }
    -
    -        if($filters['sale_type'] == 'sales')
    -        {
    -            $this->db->where('payment_amount > 0');
    -        }
    -        elseif($filters['sale_type'] == 'returns')
    +        else
    +        {
    +            $this->db->where('sales.sale_time BETWEEN ' . $this->db->escape(rawurldecode($filters['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($filters['end_date'])));
    +        }
    +
    +        if(!empty($search))
    +        {
    +            if($filters['is_valid_receipt'] != FALSE)
    +            {
    +                $pieces = explode(' ',$search);
    +                $this->db->where('sales.sale_id', $pieces[1]);
    +            }
    +            else
    +            {
    +                $this->db->group_start();
    +                    // customer last name
    +                    $this->db->like('customer_p.last_name', $search);
    +                    // customer first name
    +                    $this->db->or_like('customer_p.first_name', $search);
    +                    // customer first and last name
    +                    $this->db->or_like('CONCAT(customer_p.first_name, " ", customer_p.last_name)', $search);
    +                    // customer company name
    +                    $this->db->or_like('customer.company_name', $search);
    +                $this->db->group_end();
    +            }
    +        }
    +
    +        if($filters['sale_type'] == 'sales')
             {
    -            $this->db->where('payment_amount < 0');
    +            $this->db->where('payment_amount > 0');
             }
    -
    -        if($filters['only_invoices'] != FALSE)
    -        {
    -            $this->db->where('invoice_number IS NOT NULL');
    -        }
    -
    -        if($filters['only_cash'] != FALSE)
    -        {
    -            $this->db->like('payment_type', $this->lang->line('sales_cash'), 'after');
    -        }
    -
    -        if($filters['only_check'] != FALSE)
    -        {
    -            $this->db->like('payment_type', $this->lang->line('sales_check'), 'after');
    -        }
    -
    -        $this->db->group_by('payment_type');
    -
    -        $payments = $this->db->get()->result_array();
    +        elseif($filters['sale_type'] == 'returns')
    +        {
    +            $this->db->where('payment_amount < 0');
    +        }
    +
    +        if($filters['only_invoices'] != FALSE)
    +        {
    +            $this->db->where('invoice_number IS NOT NULL');
    +        }
    +
    +        if($filters['only_cash'] != FALSE)
    +        {
    +            $this->db->like('payment_type', $this->lang->line('sales_cash'));
    +        }
    +
    +        if($filters['only_check'] != FALSE)
    +        {
    +            $this->db->like('payment_type', $this->lang->line('sales_check'));
    +        }
     
    -        // consider Gift Card as only one type of payment and do not show "Gift Card: 1, Gift Card: 2, etc." in the total
    -        $gift_card_count = 0;
    -        $gift_card_amount = 0;
    -        foreach($payments as $key=>$payment)
    -        {
    -            if( strstr($payment['payment_type'], $this->lang->line('sales_giftcard')) != FALSE )
    -            {
    -                $gift_card_count  += $payment['count'];
    -                $gift_card_amount += $payment['payment_amount'];
    -
    -                // remove the "Gift Card: 1", "Gift Card: 2", etc. payment string
    -                unset($payments[$key]);
    -            }
    -        }
    -
    -        if($gift_card_count > 0)
    -        {
    -            $payments[] = array('payment_type' => $this->lang->line('sales_giftcard'), 'count' => $gift_card_count, 'payment_amount' => $gift_card_amount);
    -        }
    -
    -        return $payments;
    -    }
    -
    -    /*
    -    Gets total of rows
    -    */
    -    public function get_total_rows()
    -    {
    -        $this->db->from('sales');
    -
    -        return $this->db->count_all_results();
    -    }
    -
    -    public function get_search_suggestions($search, $limit = 25)
    -    {
    -        $suggestions = array();
    +        $this->db->group_by('payment_type');
    +
    +        $payments = $this->db->get()->result_array();
    +
    +        // consider Gift Card as only one type of payment and do not show "Gift Card: 1, Gift Card: 2, etc." in the total
    +        $gift_card_count = 0;
    +        $gift_card_amount = 0;
    +        foreach($payments as $key=>$payment)
    +        {
    +            if( strstr($payment['payment_type'], $this->lang->line('sales_giftcard')) != FALSE )
    +            {
    +                $gift_card_count  += $payment['count'];
    +                $gift_card_amount += $payment['payment_amount'];
    +
    +                // remove the "Gift Card: 1", "Gift Card: 2", etc. payment string
    +                unset($payments[$key]);
    +            }
    +        }
    +
    +        if($gift_card_count > 0)
    +        {
    +            $payments[] = array('payment_type' => $this->lang->line('sales_giftcard'), 'count' => $gift_card_count, 'payment_amount' => $gift_card_amount);
    +        }
    +
    +        return $payments;
    +    }
    +
    +    /**
    +     * Gets total of rows
    +     */
    +    public function get_total_rows()
    +    {
    +        $this->db->from('sales');
    +
    +        return $this->db->count_all_results();
    +    }
     
    -        if(!$this->is_valid_receipt($search))
    -        {
    -            $this->db->distinct();
    -            $this->db->select('first_name, last_name');
    -            $this->db->from('sales');
    -            $this->db->join('people', 'people.person_id = sales.customer_id');
    -            $this->db->like('last_name', $search);
    -            $this->db->or_like('first_name', $search);
    -            $this->db->or_like('CONCAT(first_name, " ", last_name)', $search);
    -            $this->db->or_like('company_name', $search);
    -            $this->db->order_by('last_name', 'asc');
    -
    -            foreach($this->db->get()->result_array() as $result)
    -            {
    -                $suggestions[] = array('label' => $result['first_name'] . ' ' . $result['last_name']);
    -            }
    -        }
    -        else
    -        {
    -            $suggestions[] = array('label' => $search);
    -        }
    -
    -        return $suggestions;
    -    }
    -
    -    /*
    -    Gets total of invoice rows
    -    */
    -    public function get_invoice_count()
    -    {
    -        $this->db->from('sales');
    -        $this->db->where('invoice_number IS NOT NULL');
    -
    -        return $this->db->count_all_results();
    -    }
    -
    -    public function get_sale_by_invoice_number($invoice_number)
    -    {
    -        $this->db->from('sales');
    -        $this->db->where('invoice_number', $invoice_number);
    -
    -        return $this->db->get();
    -    }
    -
    -    public function get_invoice_number_for_year($year = '', $start_from = 0)
    -    {
    -        $year = $year == '' ? date('Y') : $year;
    -        $this->db->select('COUNT( 1 ) AS invoice_number_year');
    +    /**
    +     * Gets search suggestions
    +     */
    +    public function get_search_suggestions($search, $limit = 25)
    +    {
    +        $suggestions = array();
    +
    +        if(!$this->is_valid_receipt($search))
    +        {
    +            $this->db->distinct();
    +            $this->db->select('first_name, last_name');
    +            $this->db->from('sales');
    +            $this->db->join('people', 'people.person_id = sales.customer_id');
    +            $this->db->like('last_name', $search);
    +            $this->db->or_like('first_name', $search);
    +            $this->db->or_like('CONCAT(first_name, " ", last_name)', $search);
    +            $this->db->or_like('company_name', $search);
    +            $this->db->order_by('last_name', 'asc');
    +
    +            foreach($this->db->get()->result_array() as $result)
    +            {
    +                $suggestions[] = array('label' => $result['first_name'] . ' ' . $result['last_name']);
    +            }
    +        }
    +        else
    +        {
    +            $suggestions[] = array('label' => $search);
    +        }
    +
    +        return $suggestions;
    +    }
    +
    +    /**
    +     * Gets total of invoice rows
    +     */
    +    public function get_invoice_count()
    +    {
    +        $this->db->from('sales');
    +        $this->db->where('invoice_number IS NOT NULL');
    +
    +        return $this->db->count_all_results();
    +    }
    +
    +    /**
    +     * Gets sale by invoice number
    +     */
    +    public function get_sale_by_invoice_number($invoice_number)
    +    {
             $this->db->from('sales');
    -        $this->db->where('DATE_FORMAT(sale_time, "%Y" ) = ', $year);
    -        $this->db->where('invoice_number IS NOT NULL');
    -        $result = $this->db->get()->row_array();
    -
    -        return ($start_from + $result['invoice_number_year']);
    -    }
    -
    -    public function is_valid_receipt(&$receipt_sale_id)
    -    {
    -        if(!empty($receipt_sale_id))
    -        {
    -            //POS #
    -            $pieces = explode(' ', $receipt_sale_id);
    -
    -            if(count($pieces) == 2 && preg_match('/(POS)/i', $pieces[0]))
    -            {
    -                return $this->exists($pieces[1]);
    -            }
    -            elseif($this->config->item('invoice_enable') == TRUE)
    -            {
    -                $sale_info = $this->get_sale_by_invoice_number($receipt_sale_id);
    -                if($sale_info->num_rows() > 0)
    -                {
    -                    $receipt_sale_id = 'POS ' . $sale_info->row()->sale_id;
    -
    -                    return TRUE;
    -                }
    -            }
    -        }
    +        $this->db->where('invoice_number', $invoice_number);
    +
    +        return $this->db->get();
    +    }
    +
    +    /**
    +     * Gets invoice number by year
    +     */
    +    public function get_invoice_number_for_year($year = '', $start_from = 0)
    +    {
    +        $year = $year == '' ? date('Y') : $year;
    +        $this->db->select('COUNT( 1 ) AS invoice_number_year');
    +        $this->db->from('sales');
    +        $this->db->where('DATE_FORMAT(sale_time, "%Y" ) = ', $year);
    +        $this->db->where('invoice_number IS NOT NULL');
    +        $result = $this->db->get()->row_array();
    +
    +        return ($start_from + $result['invoice_number_year']);
    +    }
    +
    +    /**
    +     * Checks if valid receipt
    +     */
    +    public function is_valid_receipt(&$receipt_sale_id)
    +    {
    +        if(!empty($receipt_sale_id))
    +        {
    +            //POS #
    +            $pieces = explode(' ', $receipt_sale_id);
     
    -        return FALSE;
    -    }
    -
    -    public function exists($sale_id)
    -    {
    -        $this->db->from('sales');
    -        $this->db->where('sale_id', $sale_id);
    -
    -        return ($this->db->get()->num_rows()==1);
    -    }
    +            if(count($pieces) == 2 && preg_match('/(POS)/i', $pieces[0]))
    +            {
    +                return $this->exists($pieces[1]);
    +            }
    +            elseif($this->config->item('invoice_enable') == TRUE)
    +            {
    +                $sale_info = $this->get_sale_by_invoice_number($receipt_sale_id);
    +                if($sale_info->num_rows() > 0)
    +                {
    +                    $receipt_sale_id = 'POS ' . $sale_info->row()->sale_id;
     
    -    public function update($sale_id, $sale_data, $payments)
    -    {
    -        $this->db->where('sale_id', $sale_id);
    -        $success = $this->db->update('sales', $sale_data);
    +                    return TRUE;
    +                }
    +            }
    +        }
     
    -        // touch payment only if update sale is successful and there is a payments object otherwise the result would be to delete all the payments associated to the sale
    -        if($success && !empty($payments))
    -        {
    -            //Run these queries as a transaction, we want to make sure we do all or nothing
    -            $this->db->trans_start();
    -
    -            // first delete all payments
    -            $this->db->delete('sales_payments', array('sale_id' => $sale_id));
    -
    -            // add new payments
    -            foreach($payments as $payment)
    -            {
    -                $sales_payments_data = array(
    -                    'sale_id' => $sale_id,
    -                    'payment_type' => $payment['payment_type'],
    -                    'payment_amount' => $payment['payment_amount']
    -                );
    -
    -                $success = $this->db->insert('sales_payments', $sales_payments_data);
    -            }
    -
    -            $this->db->trans_complete();
    -
    -            $success &= $this->db->trans_status();
    -        }
    -
    -        return $success;
    -    }
    -
    -
    -    /*
    -     * Save the sale information after the sales is complete but before the final document is printed
    -     * The sales_taxes variable needs to be initialized to an empty array before calling
    -     */
    -    public function save(&$sale_status, &$items, $customer_id, $employee_id, $comment, $invoice_number, $quote_number, $payments, $dinner_table, &$sales_taxes, $sale_id = FALSE)
    -    {
    -        $tax_decimals = $this->config->item('tax_decimals');
    -
    -        if(count($items) == 0)
    -        {
    -            return -1;
    -        }
    +        return FALSE;
    +    }
    +
    +    /**
    +     * Checks if sale exists
    +     */
    +    public function exists($sale_id)
    +    {
    +        $this->db->from('sales');
    +        $this->db->where('sale_id', $sale_id);
    +
    +        return ($this->db->get()->num_rows()==1);
    +    }
    +
    +    /**
    +     * Update sale
    +     */
    +    public function update($sale_id, $sale_data, $payments)
    +    {
    +        $this->db->where('sale_id', $sale_id);
    +        $success = $this->db->update('sales', $sale_data);
    +
    +        // touch payment only if update sale is successful and there is a payments object otherwise the result would be to delete all the payments associated to the sale
    +        if($success && !empty($payments))
    +        {
    +            //Run these queries as a transaction, we want to make sure we do all or nothing
    +            $this->db->trans_start();
    +
    +            // first delete all payments
    +            $this->db->delete('sales_payments', array('sale_id' => $sale_id));
    +
    +            // add new payments
    +            foreach($payments as $payment)
    +            {
    +                $sales_payments_data = array(
    +                    'sale_id' => $sale_id,
    +                    'payment_type' => $payment['payment_type'],
    +                    'payment_amount' => $payment['payment_amount']
    +                );
    +
    +                $success = $this->db->insert('sales_payments', $sales_payments_data);
    +            }
     
    -        $sales_data = array(
    -            'sale_time'      => date('Y-m-d H:i:s'),
    -            'customer_id'    => $this->Customer->exists($customer_id) ? $customer_id : null,
    -            'employee_id'    => $employee_id,
    -            'comment'        => $comment,
    -            'invoice_number' => $invoice_number,
    -            'quote_number' => $quote_number,
    -            'dinner_table_id'=> $dinner_table,
    -            'sale_status'    => $sale_status
    -        );
    -
    -        // Run these queries as a transaction, we want to make sure we do all or nothing
    -        $this->db->trans_start();
    -
    -        $this->db->insert('sales', $sales_data);
    -        $sale_id = $this->db->insert_id();
    -        $total_amount = 0;
    -        $total_amount_used = 0;
    -        foreach($payments as $payment_id=>$payment)
    -        {
    -            if( substr( $payment['payment_type'], 0, strlen( $this->lang->line('sales_giftcard') ) ) == $this->lang->line('sales_giftcard') )
    -            {
    -                // We have a gift card and we have to deduct the used value from the total value of the card.
    -                $splitpayment = explode( ':', $payment['payment_type'] );
    -                $cur_giftcard_value = $this->Giftcard->get_giftcard_value( $splitpayment[1] );
    -                $this->Giftcard->update_giftcard_value( $splitpayment[1], $cur_giftcard_value - $payment['payment_amount'] );
    -            }
    -
    -            if( substr( $payment['payment_type'], 0, strlen( $this->lang->line('sales_rewards') ) ) == $this->lang->line('sales_rewards') )
    +            $this->db->trans_complete();
    +
    +            $success &= $this->db->trans_status();
    +        }
    +
    +        return $success;
    +    }
    +
    +
    +    /**
    +     * Save the sale information after the sales is complete but before the final document is printed
    +     * The sales_taxes variable needs to be initialized to an empty array before calling
    +     */
    +    public function save(&$sale_status, &$items, $customer_id, $employee_id, $comment, $invoice_number, $quote_number, $payments, $dinner_table, &$sales_taxes, $sale_id = FALSE)
    +    {
    +        $tax_decimals = $this->config->item('tax_decimals');
    +
    +        if(count($items) == 0)
    +        {
    +            return -1;
    +        }
    +
    +        if($sale_status == '1') //suspend sales
    +        {
    +            if($dinner_table > 2)   //not delivery or take away
    +            {
    +                $table_status = 1;
    +            }
    +            else
                 {
    -
    -                $cur_rewards_value = $this->Customer->get_info($customer_id)->points;
    -                $this->Customer->update_reward_points_value($customer_id, $cur_rewards_value - $payment['payment_amount'] );
    -                $total_amount_used = floatval($total_amount_used) + floatval($payment['payment_amount']);
    -            }
    -
    -            $sales_payments_data = array(
    -                'sale_id'        => $sale_id,
    -                'payment_type'   => $payment['payment_type'],
    -                'payment_amount' => $payment['payment_amount']
    -            );
    -            $this->db->insert('sales_payments', $sales_payments_data);
    -            $total_amount = floatval($total_amount) + floatval($payment['payment_amount']);
    -        }
    -
    -        if(!empty($customer_id) && $this->config->item('customer_reward_enable') == TRUE)
    -        {
    -            $package_id = $this->Customer->get_info($customer_id)->package_id;
    +                $table_status = 0;
    +            }
    +        }
    +        else
    +        {
    +            $table_status = 0;
    +        }
    +
    +        $sales_data = array(
    +            'sale_time'      => date('Y-m-d H:i:s'),
    +            'customer_id'    => $this->Customer->exists($customer_id) ? $customer_id : null,
    +            'employee_id'    => $employee_id,
    +            'comment'        => $comment,
    +            'invoice_number' => $invoice_number,
    +            'quote_number' => $quote_number,
    +            'dinner_table_id'=> $dinner_table,
    +            'sale_status'    => $sale_status
    +        );
     
    -            if(!empty($package_id))
    -            {
    -                $points_percent = $this->Customer_rewards->get_points_percent($package_id);
    -                $points = $this->Customer->get_info($customer_id)->points;
    -                $points = ($points==NULL ? 0 : $points);
    -                $points_percent = ($points_percent==NULL ? 0 : $points_percent);
    -                $total_amount_earned = ($total_amount*$points_percent/100);
    -                $points = $points + $total_amount_earned;
    -                $this->Customer->update_reward_points_value($customer_id, $points);
    -                $rewards_data = array('sale_id'=>$sale_id, 'earned'=>$total_amount_earned, 'used'=>$total_amount_used);
    -                $this->Rewards->save($rewards_data);
    -            }
    -        }
    -
    -        $customer = $this->Customer->get_info($customer_id);
    -
    -        $sales_taxes = array();
    -
    -        foreach($items as $line=>$item)
    -        {
    -            $cur_item_info = $this->Item->get_info($item['item_id']);
    -
    -            $sales_items_data = array(
    -                'sale_id'           => $sale_id,
    -                'item_id'           => $item['item_id'],
    -                'line'              => $item['line'],
    -                'description'       => character_limiter($item['description'], 30),
    -                'serialnumber'      => character_limiter($item['serialnumber'], 30),
    -                'quantity_purchased'=> $item['quantity'],
    -                'discount_percent'  => $item['discount'],
    -                'item_cost_price'   => $cur_item_info->cost_price,
    -                'item_unit_price'   => $item['price'],
    -                'item_location'     => $item['item_location'],
    -                'print_option'      => $item['print_option']
    -            );
    -
    -            $this->db->insert('sales_items', $sales_items_data);
    +        // Run these queries as a transaction, we want to make sure we do all or nothing
    +        $this->db->trans_start();
    +
    +        $this->db->insert('sales', $sales_data);
    +        $sale_id = $this->db->insert_id();
    +        $total_amount = 0;
    +        $total_amount_used = 0;
    +        foreach($payments as $payment_id=>$payment)
    +        {
    +            if( substr( $payment['payment_type'], 0, strlen( $this->lang->line('sales_giftcard') ) ) == $this->lang->line('sales_giftcard') )
    +            {
    +                // We have a gift card and we have to deduct the used value from the total value of the card.
    +                $splitpayment = explode( ':', $payment['payment_type'] );
    +                $cur_giftcard_value = $this->Giftcard->get_giftcard_value( $splitpayment[1] );
    +                $this->Giftcard->update_giftcard_value( $splitpayment[1], $cur_giftcard_value - $payment['payment_amount'] );
    +            }
    +
    +            if( substr( $payment['payment_type'], 0, strlen( $this->lang->line('sales_rewards') ) ) == $this->lang->line('sales_rewards') )
    +            {
    +
    +                $cur_rewards_value = $this->Customer->get_info($customer_id)->points;
    +                $this->Customer->update_reward_points_value($customer_id, $cur_rewards_value - $payment['payment_amount'] );
    +                $total_amount_used = floatval($total_amount_used) + floatval($payment['payment_amount']);
    +            }
    +
    +            $sales_payments_data = array(
    +                'sale_id'        => $sale_id,
    +                'payment_type'   => $payment['payment_type'],
    +                'payment_amount' => $payment['payment_amount']
    +            );
    +            $this->db->insert('sales_payments', $sales_payments_data);
    +            $total_amount = floatval($total_amount) + floatval($payment['payment_amount']);
    +        }
    +
    +        if(!empty($customer_id) && $this->config->item('customer_reward_enable') == TRUE)
    +        {
    +            $package_id = $this->Customer->get_info($customer_id)->package_id;
     
    -            if($cur_item_info->stock_type === '0')
    +            if(!empty($package_id))
                 {
    -                // Update stock quantity if item type is not non-stock
    -                $item_quantity = $this->Item_quantity->get_item_quantity($item['item_id'], $item['item_location']);
    -                $this->Item_quantity->save(array('quantity'     => $item_quantity->quantity - $item['quantity'],
    -                    'item_id'       => $item['item_id'],
    -                    'location_id'   => $item['item_location']), $item['item_id'], $item['item_location']);
    -            }
    -
    -            // if an items was deleted but later returned it's restored with this rule
    -
    -            if($item['quantity'] < 0)
    -            {
    -                $this->Item->undelete($item['item_id']);
    -            }
    +                $points_percent = $this->Customer_rewards->get_points_percent($package_id);
    +                $points = $this->Customer->get_info($customer_id)->points;
    +                $points = ($points==NULL ? 0 : $points);
    +                $points_percent = ($points_percent==NULL ? 0 : $points_percent);
    +                $total_amount_earned = ($total_amount*$points_percent/100);
    +                $points = $points + $total_amount_earned;
    +                $this->Customer->update_reward_points_value($customer_id, $points);
    +                $rewards_data = array('sale_id'=>$sale_id, 'earned'=>$total_amount_earned, 'used'=>$total_amount_used);
    +                $this->Rewards->save($rewards_data);
    +            }
    +        }
    +
    +        $customer = $this->Customer->get_info($customer_id);
     
    -            // Inventory Count Details
    -            $sale_remarks = 'POS '.$sale_id;
    -            $inv_data = array(
    -                'trans_date'        => date('Y-m-d H:i:s'),
    -                'trans_items'       => $item['item_id'],
    -                'trans_user'        => $employee_id,
    -                'trans_location'    => $item['item_location'],
    -                'trans_comment'     => $sale_remarks,
    -                'trans_inventory'   => -$item['quantity']
    -            );
    -            $this->Inventory->insert($inv_data);
    -
    -            // Calculate taxes and save the tax information for the sale.  Return the result for printing
    -
    -            if($customer_id == -1 || $customer->taxable)
    -            {
    -                if($this->config->item('tax_included'))
    -                {
    -                    $tax_type = Tax_lib::TAX_TYPE_VAT;
    -                }
    -                else
    -                {
    -                    $tax_type = Tax_lib::TAX_TYPE_SALES;
    -                }
    -                $rounding_code = Rounding_code::HALF_UP; // half adjust
    -                $tax_group_sequence = 0;
    -                $item_total = $this->sale_lib->get_item_total($item['quantity'], $item['price'], $item['discount'], TRUE);
    -                $tax_basis = $item_total;
    -                $item_tax_amount = 0;
    +        $sales_taxes = array();
    +
    +        foreach($items as $line=>$item)
    +        {
    +            $cur_item_info = $this->Item->get_info($item['item_id']);
    +
    +            $sales_items_data = array(
    +                'sale_id'           => $sale_id,
    +                'item_id'           => $item['item_id'],
    +                'line'              => $item['line'],
    +                'description'       => character_limiter($item['description'], 30),
    +                'serialnumber'      => character_limiter($item['serialnumber'], 30),
    +                'quantity_purchased'=> $item['quantity'],
    +                'discount_percent'  => $item['discount'],
    +                'item_cost_price'   => $cur_item_info->cost_price,
    +                'item_unit_price'   => $item['price'],
    +                'item_location'     => $item['item_location'],
    +                'print_option'      => $item['print_option']
    +            );
    +
    +            $this->db->insert('sales_items', $sales_items_data);
    +
    +            if($cur_item_info->stock_type === '0' && $sale_status === '0')
    +            {
    +                // Update stock quantity if item type is a standard stock item and the sale is a standard sale
    +                $item_quantity = $this->Item_quantity->get_item_quantity($item['item_id'], $item['item_location']);
    +                $this->Item_quantity->save(array('quantity'     => $item_quantity->quantity - $item['quantity'],
    +                    'item_id'       => $item['item_id'],
    +                    'location_id'   => $item['item_location']), $item['item_id'], $item['item_location']);
     
    -                foreach($this->Item_taxes->get_info($item['item_id']) as $row)
    -                {
    -
    -                    $sales_items_taxes = array(
    -                        'sale_id'           => $sale_id,
    -                        'item_id'           => $item['item_id'],
    -                        'line'              => $item['line'],
    -                        'name'              => character_limiter($row['name'], 255),
    -                        'percent'           => $row['percent'],
    -                        'tax_type'          => $tax_type,
    -                        'rounding_code'     => $rounding_code,
    -                        'cascade_tax'       => 0,
    -                        'cascade_sequence'  => 0,
    -                        'item_tax_amount'   => 0
    -                    );
    -
    -                    // This computes tax for each line item and adds it to the tax type total
    -                    $tax_group = (float)$row['percent'] . '% ' . $row['name'];
    -                    $tax_basis = $this->sale_lib->get_item_total($item['quantity'], $item['price'], $item['discount'], TRUE);
    +                // if an items was deleted but later returned it's restored with this rule
    +
    +                if($item['quantity'] < 0)
    +                {
    +                    $this->Item->undelete($item['item_id']);
    +                }
    +
    +                // Inventory Count Details
    +                $sale_remarks = 'POS '.$sale_id;
    +                $inv_data = array(
    +                    'trans_date'        => date('Y-m-d H:i:s'),
    +                    'trans_items'       => $item['item_id'],
    +                    'trans_user'        => $employee_id,
    +                    'trans_location'    => $item['item_location'],
    +                    'trans_comment'     => $sale_remarks,
    +                    'trans_inventory'   => -$item['quantity']
    +                );
    +                $this->Inventory->insert($inv_data);
    +            }
     
    -                    if($this->config->item('tax_included'))
    -                    {
    -                        $tax_type = Tax_lib::TAX_TYPE_VAT;
    -                        $item_tax_amount = $this->sale_lib->get_item_tax($item['quantity'], $item['price'], $item['discount'],$row['percent']);
    -                    }
    -                    elseif($this->config->item('customer_sales_tax_support') == '0')
    -                    {
    -                        $tax_type = Tax_lib::TAX_TYPE_SALES;
    -                        $item_tax_amount = $this->tax_lib->get_sales_tax_for_amount($tax_basis, $row['percent'], '0', $tax_decimals);
    -                    }
    -                    else
    -                    {
    -                        $tax_type = Tax_lib::TAX_TYPE_SALES;
    -                    }
    -
    -                    $sales_items_taxes['item_tax_amount'] = $item_tax_amount;
    -                    if($item_tax_amount != 0)
    -                    {
    -                        $this->db->insert('sales_items_taxes', $sales_items_taxes);
    -                        $this->tax_lib->update_sales_taxes($sales_taxes, $tax_type, $tax_group, $row['percent'], $tax_basis, $item_tax_amount, $tax_group_sequence, $rounding_code, $sale_id,  $row['name'], '');
    -                        $tax_group_sequence += 1;
    -                    }
    -
    -                }
    -
    -                if($this->config->item('customer_sales_tax_support') == '1')
    -                {
    -                    $this->save_sales_item_tax($customer, $sale_id, $item, $item_total, $sales_taxes, $sequence, $cur_item_info->tax_category_id);
    -                }
    -            }
    -        }
    -
    -        if($customer_id == -1 || $customer->taxable)
    -        {
    -            $this->tax_lib->round_sales_taxes($sales_taxes);
    -            $this->save_sales_tax($sales_taxes);
    -        }
    +            // Calculate taxes and save the tax information for the sale.  Return the result for printing
    +
    +            if($customer_id == -1 || $customer->taxable)
    +            {
    +                if($this->config->item('tax_included'))
    +                {
    +                    $tax_type = Tax_lib::TAX_TYPE_VAT;
    +                }
    +                else
    +                {
    +                    $tax_type = Tax_lib::TAX_TYPE_SALES;
    +                }
    +                $rounding_code = Rounding_code::HALF_UP; // half adjust
    +                $tax_group_sequence = 0;
    +                $item_total = $this->sale_lib->get_item_total($item['quantity'], $item['price'], $item['discount'], TRUE);
    +                $tax_basis = $item_total;
    +                $item_tax_amount = 0;
    +
    +                foreach($this->Item_taxes->get_info($item['item_id']) as $row)
    +                {
    +
    +                    $sales_items_taxes = array(
    +                        'sale_id'           => $sale_id,
    +                        'item_id'           => $item['item_id'],
    +                        'line'              => $item['line'],
    +                        'name'              => character_limiter($row['name'], 255),
    +                        'percent'           => $row['percent'],
    +                        'tax_type'          => $tax_type,
    +                        'rounding_code'     => $rounding_code,
    +                        'cascade_tax'       => 0,
    +                        'cascade_sequence'  => 0,
    +                        'item_tax_amount'   => 0
    +                    );
    +
    +                    // This computes tax for each line item and adds it to the tax type total
    +                    $tax_group = (float)$row['percent'] . '% ' . $row['name'];
    +                    $tax_basis = $this->sale_lib->get_item_total($item['quantity'], $item['price'], $item['discount'], TRUE);
     
    -        $this->db->trans_complete();
    -
    -        if($this->db->trans_status() === FALSE)
    -        {
    -            return -1;
    -        }
    -
    -        return $sale_id;
    -    }
    -
    -    /**
    -     * Apply customer sales tax if the customer sales tax is enabledl
    -     * The original tax is still supported if the user configures it,
    -     * but it won't make sense unless it's used exclusively for the purpose
    -     * of VAT tax which becomes a price component.  VAT taxes must still be reported
    -     * as a separate tax entry on the invoice.
    -     */
    -    public function save_sales_item_tax(&$customer, &$sale_id, &$item, $tax_basis, &$sales_taxes, &$sequence, $tax_category_id)
    -    {
    -        // if customer sales tax is enabled then update  sales_items_taxes with the
    -        if($this->config->item('customer_sales_tax_support') == '1')
    -        {
    -            $register_mode = $this->config->item('default_register_mode');
    -            $tax_details = $this->tax_lib->apply_sales_tax($item, $customer->city, $customer->state, $customer->sales_tax_code, $register_mode, $sale_id, $sales_taxes);
    +                    if($this->config->item('tax_included'))
    +                    {
    +                        $tax_type = Tax_lib::TAX_TYPE_VAT;
    +                        $item_tax_amount = $this->sale_lib->get_item_tax($item['quantity'], $item['price'], $item['discount'],$row['percent']);
    +                    }
    +                    elseif($this->config->item('customer_sales_tax_support') == '0')
    +                    {
    +                        $tax_type = Tax_lib::TAX_TYPE_SALES;
    +                        $item_tax_amount = $this->tax_lib->get_sales_tax_for_amount($tax_basis, $row['percent'], '0', $tax_decimals);
    +                    }
    +                    else
    +                    {
    +                        $tax_type = Tax_lib::TAX_TYPE_SALES;
    +                    }
    +
    +                    $sales_items_taxes['item_tax_amount'] = $item_tax_amount;
    +                    if($item_tax_amount != 0)
    +                    {
    +                        $this->db->insert('sales_items_taxes', $sales_items_taxes);
    +                        $this->tax_lib->update_sales_taxes($sales_taxes, $tax_type, $tax_group, $row['percent'], $tax_basis, $item_tax_amount, $tax_group_sequence, $rounding_code, $sale_id,  $row['name'], '');
    +                        $tax_group_sequence += 1;
    +                    }
    +
    +                }
     
    -            $sales_items_taxes = array(
    -                'sale_id'           => $sale_id,
    -                'item_id'           => $item['item_id'],
    -                'line'              => $item['line'],
    -                'name'              => $tax_details['tax_name'],
    -                'percent'           => $tax_details['tax_rate'],
    -                'tax_type'          => Tax_lib::TAX_TYPE_SALES,
    -                'rounding_code'     => $tax_details['rounding_code'],
    -                'cascade_tax'       => 0,
    -                'cascade_sequence'  => 0,
    -                'item_tax_amount'   => $tax_details['item_tax_amount']
    -            );
    +                if($this->config->item('customer_sales_tax_support') == '1')
    +                {
    +                    $this->save_sales_item_tax($customer, $sale_id, $item, $item_total, $sales_taxes, $sequence, $cur_item_info->tax_category_id);
    +                }
    +            }
    +        }
    +
    +        if($customer_id == -1 || $customer->taxable)
    +        {
    +            $this->tax_lib->round_sales_taxes($sales_taxes);
    +            $this->save_sales_tax($sales_taxes);
    +        }
     
    -            $this->db->insert('sales_items_taxes', $sales_items_taxes);
    -        }
    -    }
    +        $dinner_table_data = array(
    +            'status' => $table_status
    +        );
     
    -    private function save_sales_tax(&$sales_taxes)
    -    {
    -        foreach($sales_taxes as $line=>$sales_tax)
    -        {
    -            $this->db->insert('sales_taxes', $sales_tax);
    -        }
    -    }
    -
    -    public function delete_list($sale_ids, $employee_id, $update_inventory = TRUE)
    -    {
    -        $result = TRUE;
    -
    -        foreach($sale_ids as $sale_id)
    -        {
    -            $result &= $this->delete($sale_id, $employee_id, $update_inventory);
    -        }
    -
    -        return $result;
    -    }
    -
    -    public function delete($sale_id, $employee_id, $update_inventory = TRUE)
    +        $this->db->where('dinner_table_id',$dinner_table);
    +        $this->db->update('dinner_tables', $dinner_table_data);
    +
    +        $this->db->trans_complete();
    +
    +        if($this->db->trans_status() === FALSE)
    +        {
    +            return -1;
    +        }
    +
    +        return $sale_id;
    +    }
    +
    +    /**
    +     * Apply customer sales tax if the customer sales tax is enabledl
    +     * The original tax is still supported if the user configures it,
    +     * but it won't make sense unless it's used exclusively for the purpose
    +     * of VAT tax which becomes a price component.  VAT taxes must still be reported
    +     * as a separate tax entry on the invoice.
    +     */
    +    public function save_sales_item_tax(&$customer, &$sale_id, &$item, $tax_basis, &$sales_taxes, &$sequence, $tax_category_id)
         {
    -        // start a transaction to assure data integrity
    -        $this->db->trans_start();
    -
    -        // first delete all payments
    -        $this->db->delete('sales_payments', array('sale_id' => $sale_id));
    -        // then delete all taxes on items
    -        $this->db->delete('sales_items_taxes', array('sale_id' => $sale_id));
    -
    -        if($update_inventory)
    -        {
    -            // defect, not all item deletions will be undone??
    -            // get array with all the items involved in the sale to update the inventory tracking
    -            $items = $this->get_sale_items($sale_id)->result_array();
    -            foreach($items as $item)
    -            {
    -                $cur_item_info = $this->Item->get_info($item['item_id']);
    -
    -                if($cur_item_info->stock_type === '0') {
    -                    // create query to update inventory tracking
    -                    $inv_data = array(
    -                        'trans_date' => date('Y-m-d H:i:s'),
    -                        'trans_items' => $item['item_id'],
    -                        'trans_user' => $employee_id,
    -                        'trans_comment' => 'Deleting sale ' . $sale_id,
    -                        'trans_location' => $item['item_location'],
    -                        'trans_inventory' => $item['quantity_purchased']
    -                    );
    -                    // update inventory
    -                    $this->Inventory->insert($inv_data);
    -
    -                    // update quantities
    -                    $this->Item_quantity->change_quantity($item['item_id'], $item['item_location'], $item['quantity_purchased']);
    -                }
    -            }
    -        }
    -
    -        // delete all items
    -        $this->db->delete('sales_items', array('sale_id' => $sale_id));
    -        // delete sale itself
    -        $this->db->delete('sales', array('sale_id' => $sale_id));
    +        // if customer sales tax is enabled then update  sales_items_taxes with the
    +        if($this->config->item('customer_sales_tax_support') == '1')
    +        {
    +            $register_mode = $this->config->item('default_register_mode');
    +            $tax_details = $this->tax_lib->apply_sales_tax($item, $customer->city, $customer->state, $customer->sales_tax_code, $register_mode, $sale_id, $sales_taxes);
    +
    +            $sales_items_taxes = array(
    +                'sale_id'           => $sale_id,
    +                'item_id'           => $item['item_id'],
    +                'line'              => $item['line'],
    +                'name'              => $tax_details['tax_name'],
    +                'percent'           => $tax_details['tax_rate'],
    +                'tax_type'          => Tax_lib::TAX_TYPE_SALES,
    +                'rounding_code'     => $tax_details['rounding_code'],
    +                'cascade_tax'       => 0,
    +                'cascade_sequence'  => 0,
    +                'item_tax_amount'   => $tax_details['item_tax_amount']
    +            );
    +
    +            $this->db->insert('sales_items_taxes', $sales_items_taxes);
    +        }
    +    }
    +
    +    /**
    +     * Saves sale tax
    +     */
    +    public function save_sales_tax(&$sales_taxes)
    +    {
    +        foreach($sales_taxes as $line=>$sales_tax)
    +        {
    +            $this->db->insert('sales_taxes', $sales_tax);
    +        }
    +    }
    +
    +    /**
    +     * Deletes list of sales
    +     */
    +    public function delete_list($sale_ids, $employee_id, $update_inventory = TRUE)
    +    {
    +        $result = TRUE;
     
    -        // execute transaction
    -        $this->db->trans_complete();
    -
    -        return $this->db->trans_status();
    -    }
    -
    -    public function get_sale_items($sale_id)
    -    {
    -        $this->db->from('sales_items');
    -        $this->db->where('sale_id', $sale_id);
    -
    -        return $this->db->get();
    -    }
    -
    -    /*
    -     * Used by the invoice and receipt programs
    -     */
    -    public function get_sale_items_ordered($sale_id)
    -    {
    -        $this->db->select('
    -            sale_id,
    -            sales_items.item_id,
    -            sales_items.description,
    -            serialnumber,
    -            line,
    -            quantity_purchased,
    -            item_cost_price,
    -            item_unit_price,
    -            discount_percent,
    -            item_location,
    -            print_option,
    -            items.name as name,
    -            category,
    -            item_type,
    -            stock_type');
    -        $this->db->from('sales_items as sales_items');
    -        $this->db->join('items as items', 'sales_items.item_id = items.item_id');
    -        $this->db->where('sale_id', $sale_id);
    -
    -        // Entry sequence (this will render kits in the expected sequence)
    -        if($this->config->item('line_sequence') == '0')
    -        {
    -            $this->db->order_by('line', 'asc');
    -        }
    -        // Group by Stock Type (nonstock first - type 1, stock next - type 0)
    -        elseif($this->config->item('line_sequence') == '1')
    -        {
    -            $this->db->order_by('stock_type', 'desc');
    -            $this->db->order_by('sales_items.description', 'asc');
    -            $this->db->order_by('items.name', 'asc');
    -        }
    -        // Group by Item Category
    -        elseif($this->config->item('line_sequence') == '2')
    -        {
    -            $this->db->order_by('category', 'asc');
    -            $this->db->order_by('sales_items.description', 'asc');
    -            $this->db->order_by('items.name', 'asc');
    -        }
    -        // Group by entry sequence in descending sequence (the Standard)
    -        else
    -        {
    -            $this->db->order_by('line', 'desc');
    -        }
    -
    -        return $this->db->get();
    -    }
    -
    -    public function get_sale_payments($sale_id)
    -    {
    -        $this->db->from('sales_payments');
    -        $this->db->where('sale_id', $sale_id);
    -
    -        return $this->db->get();
    -    }
    -
    -    public function get_payment_options($giftcard = TRUE, $reward_points = FALSE)
    -    {
    -        $payments = array();
    -
    -        if($this->config->item('payment_options_order') == 'debitcreditcash')
    -        {
    -            $payments[$this->lang->line('sales_debit')] = $this->lang->line('sales_debit');
    -            $payments[$this->lang->line('sales_credit')] = $this->lang->line('sales_credit');
    -            $payments[$this->lang->line('sales_cash')] = $this->lang->line('sales_cash');
    -        }
    -        elseif($this->config->item('payment_options_order') == 'debitcashcredit')
    -        {
    -            $payments[$this->lang->line('sales_debit')] = $this->lang->line('sales_debit');
    -            $payments[$this->lang->line('sales_cash')] = $this->lang->line('sales_cash');
    -            $payments[$this->lang->line('sales_credit')] = $this->lang->line('sales_credit');
    -        }
    -        else // default: if($this->config->item('payment_options_order') == 'cashdebitcredit')
    -        {
    -            $payments[$this->lang->line('sales_cash')] = $this->lang->line('sales_cash');
    -            $payments[$this->lang->line('sales_debit')] = $this->lang->line('sales_debit');
    -            $payments[$this->lang->line('sales_credit')] = $this->lang->line('sales_credit');
    -        }
    -
    -        $payments[$this->lang->line('sales_check')] = $this->lang->line('sales_check');
    -
    -        if($giftcard)
    -        {
    -            $payments[$this->lang->line('sales_giftcard')] = $this->lang->line('sales_giftcard');
    -        }
    -
    -        if($reward_points)
    -        {
    -            $payments[$this->lang->line('sales_rewards')] = $this->lang->line('sales_rewards');
    -        }
    -
    -        return $payments;
    -    }
    -
    -    public function get_customer($sale_id)
    -    {
    -        $this->db->from('sales');
    -        $this->db->where('sale_id', $sale_id);
    -
    -        return $this->Customer->get_info($this->db->get()->row()->customer_id);
    -    }
    +        foreach($sale_ids as $sale_id)
    +        {
    +            $result &= $this->delete($sale_id, $employee_id, $update_inventory);
    +        }
    +
    +        return $result;
    +    }
    +
    +    /**
    +     * Delete sale
    +     */
    +    public function delete($sale_id, $employee_id, $update_inventory = TRUE)
    +    {
    +        // start a transaction to assure data integrity
    +        $this->db->trans_start();
    +
    +        // first delete all payments
    +        $this->db->delete('sales_payments', array('sale_id' => $sale_id));
    +        // then delete all taxes on items
    +        $this->db->delete('sales_items_taxes', array('sale_id' => $sale_id));
    +
    +        if($update_inventory)
    +        {
    +            // defect, not all item deletions will be undone??
    +            // get array with all the items involved in the sale to update the inventory tracking
    +            $items = $this->get_sale_items($sale_id)->result_array();
    +            foreach($items as $item)
    +            {
    +                $cur_item_info = $this->Item->get_info($item['item_id']);
    +
    +                if($cur_item_info->stock_type === '0') {
    +                    // create query to update inventory tracking
    +                    $inv_data = array(
    +                        'trans_date' => date('Y-m-d H:i:s'),
    +                        'trans_items' => $item['item_id'],
    +                        'trans_user' => $employee_id,
    +                        'trans_comment' => 'Deleting sale ' . $sale_id,
    +                        'trans_location' => $item['item_location'],
    +                        'trans_inventory' => $item['quantity_purchased']
    +                    );
    +                    // update inventory
    +                    $this->Inventory->insert($inv_data);
    +
    +                    // update quantities
    +                    $this->Item_quantity->change_quantity($item['item_id'], $item['item_location'], $item['quantity_purchased']);
    +                }
    +            }
    +        }
    +
    +        // delete all items
    +        $this->db->delete('sales_items', array('sale_id' => $sale_id));
    +        // delete sale itself
    +        $this->db->delete('sales', array('sale_id' => $sale_id));
    +
    +        // execute transaction
    +        $this->db->trans_complete();
    +
    +        return $this->db->trans_status();
    +    }
    +
    +    /**
    +     * Gets sale item
    +     */
    +    public function get_sale_items($sale_id)
    +    {
    +        $this->db->from('sales_items');
    +        $this->db->where('sale_id', $sale_id);
    +
    +        return $this->db->get();
    +    }
    +
    +    /**
    +     * Used by the invoice and receipt programs
    +     */
    +    public function get_sale_items_ordered($sale_id)
    +    {
    +        $this->db->select('
    +            sale_id,
    +            sales_items.item_id,
    +            sales_items.description,
    +            serialnumber,
    +            line,
    +            quantity_purchased,
    +            item_cost_price,
    +            item_unit_price,
    +            discount_percent,
    +            item_location,
    +            print_option,
    +            items.name as name,
    +            category,
    +            item_type,
    +            stock_type');
    +        $this->db->from('sales_items as sales_items');
    +        $this->db->join('items as items', 'sales_items.item_id = items.item_id');
    +        $this->db->where('sale_id', $sale_id);
    +
    +        // Entry sequence (this will render kits in the expected sequence)
    +        if($this->config->item('line_sequence') == '0')
    +        {
    +            $this->db->order_by('line', 'asc');
    +        }
    +        // Group by Stock Type (nonstock first - type 1, stock next - type 0)
    +        elseif($this->config->item('line_sequence') == '1')
    +        {
    +            $this->db->order_by('stock_type', 'desc');
    +            $this->db->order_by('sales_items.description', 'asc');
    +            $this->db->order_by('items.name', 'asc');
    +        }
    +        // Group by Item Category
    +        elseif($this->config->item('line_sequence') == '2')
    +        {
    +            $this->db->order_by('category', 'asc');
    +            $this->db->order_by('sales_items.description', 'asc');
    +            $this->db->order_by('items.name', 'asc');
    +        }
    +        // Group by entry sequence in descending sequence (the Standard)
    +        else
    +        {
    +            $this->db->order_by('line', 'desc');
    +        }
     
    -    public function get_employee($sale_id)
    -    {
    -        $this->db->from('sales');
    -        $this->db->where('sale_id', $sale_id);
    -
    -        return $this->Employee->get_info($this->db->get()->row()->employee_id);
    -    }
    -
    -    // TODO change to use new quote_number field
    -    public function check_quote_number_exists($quote_number, $sale_id = '')
    -    {
    -        $this->db->from('sales');
    -        $this->db->where('quote_number', $quote_number);
    -        if(!empty($sale_id))
    -        {
    -            $this->db->where('sale_id !=', $sale_id);
    -        }
    -
    -        return ($this->db->get()->num_rows() == 1);
    -    }
    +        return $this->db->get();
    +    }
    +
    +    /**
    +     * Gets sale payments
    +     */
    +    public function get_sale_payments($sale_id)
    +    {
    +        $this->db->from('sales_payments');
    +        $this->db->where('sale_id', $sale_id);
    +
    +        return $this->db->get();
    +    }
    +
    +    /**
    +     * Gets sale payment options
    +     */
    +    public function get_payment_options($giftcard = TRUE, $reward_points = FALSE)
    +    {
    +        $payments = array();
     
    -    public function check_invoice_number_exists($invoice_number, $sale_id = '')
    -    {
    -        $this->db->from('sales');
    -        $this->db->where('invoice_number', $invoice_number);
    -        if(!empty($sale_id))
    -        {
    -            $this->db->where('sale_id !=', $sale_id);
    -        }
    -
    -        return ($this->db->get()->num_rows() == 1);
    -    }
    -
    -    public function get_giftcard_value($giftcardNumber)
    -    {
    -        if(!$this->Giftcard->exists($this->Giftcard->get_giftcard_id($giftcardNumber)))
    -        {
    -            return 0;
    +        if($this->config->item('payment_options_order') == 'debitcreditcash')
    +        {
    +            $payments[$this->lang->line('sales_debit')] = $this->lang->line('sales_debit');
    +            $payments[$this->lang->line('sales_credit')] = $this->lang->line('sales_credit');
    +            $payments[$this->lang->line('sales_cash')] = $this->lang->line('sales_cash');
    +        }
    +        elseif($this->config->item('payment_options_order') == 'debitcashcredit')
    +        {
    +            $payments[$this->lang->line('sales_debit')] = $this->lang->line('sales_debit');
    +            $payments[$this->lang->line('sales_cash')] = $this->lang->line('sales_cash');
    +            $payments[$this->lang->line('sales_credit')] = $this->lang->line('sales_credit');
    +        }
    +        else // default: if($this->config->item('payment_options_order') == 'cashdebitcredit')
    +        {
    +            $payments[$this->lang->line('sales_cash')] = $this->lang->line('sales_cash');
    +            $payments[$this->lang->line('sales_debit')] = $this->lang->line('sales_debit');
    +            $payments[$this->lang->line('sales_credit')] = $this->lang->line('sales_credit');
             }
     
    -        $this->db->from('giftcards');
    -        $this->db->where('giftcard_number', $giftcardNumber);
    -
    -        return $this->db->get()->row()->value;
    -    }
    -
    -    //We create a temp table that allows us to do easy report/sales queries
    -    public function create_temp_table(array $inputs)
    -    {
    -        if(empty($inputs['sale_id']))
    -        {
    -            if(empty($this->config->item('date_or_time_format')))
    -            {
    -                $where = 'DATE(sales.sale_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']);
    -            }
    -            else
    -            {
    -                $where = 'sales.sale_time BETWEEN ' . $this->db->escape(rawurldecode($inputs['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($inputs['end_date']));
    -            }
    -        }
    -        else
    -        {
    -            $where = 'sales.sale_id = ' . $this->db->escape($inputs['sale_id']);
    -        }
    -
    -        $sale_price = 'sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100)';
    -
    -        if($this->config->item('tax_included'))
    -        {
    -            $sale_total = 'SUM(' . $sale_price . ')';
    -            $sale_subtotal = 'SUM(' . $sale_price . ' - sales_items_taxes.tax)';
    -            $sale_tax = 'SUM(' . $sale_price . ' * (1 - 100 / (100 + sales_items_taxes.percent)))';
    -        }
    -        else
    -        {
    -            $sale_total = 'SUM(' . $sale_price . ' + sales_items_taxes.tax)';
    -            $sale_subtotal = 'SUM(' . $sale_price . ')';
    -            $sale_tax = 'SUM(' . $sale_price . ' * (sales_items_taxes.percent / 100))';
    -        }
    -
    -        $sale_cost = 'SUM(sales_items.item_cost_price * sales_items.quantity_purchased)';
    -
    -        $decimals = totals_decimals();
    -
    -        // create a temporary table to contain all the sum of taxes per sale item
    -        $this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_items_taxes_temp') .
    -            ' (INDEX(sale_id), INDEX(item_id))
    -            (
    -                SELECT sales_items_taxes.sale_id AS sale_id,
    -                    sales_items_taxes.item_id AS item_id,
    -                    sales_items_taxes.line AS line,
    -                    ' . "
    -                    IFNULL(ROUND($sale_tax, $decimals), 0) AS tax
    -                    " . '
    -                FROM ' . $this->db->dbprefix('sales_items_taxes') . ' AS sales_items_taxes
    -                INNER JOIN ' . $this->db->dbprefix('sales') . ' AS sales
    -                    ON sales.sale_id = sales_items_taxes.sale_id
    -                INNER JOIN ' . $this->db->dbprefix('sales_items') . ' AS sales_items
    -                    ON sales_items.sale_id = sales_items_taxes.sale_id AND sales_items.line = sales_items_taxes.line
    -                WHERE sales.sale_status = 0 AND ' . $where . '
    -                GROUP BY sale_id, item_id, line
    -            )'
    -        );
    -
    -        // create a temporary table to contain all the payment types and amount
    -        $this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_payments_temp') .
    -            ' (PRIMARY KEY(sale_id), INDEX(sale_id))
    -            (
    -                SELECT payments.sale_id AS sale_id,
    -                    IFNULL(SUM(payments.payment_amount), 0) AS sale_payment_amount,
    -                    GROUP_CONCAT(CONCAT(payments.payment_type, " ", payments.payment_amount) SEPARATOR ", ") AS payment_type
    -                FROM ' . $this->db->dbprefix('sales_payments') . ' AS payments
    -                INNER JOIN ' . $this->db->dbprefix('sales') . ' AS sales
    -                    ON sales.sale_id = payments.sale_id
    -                WHERE sales.sale_status = 0 AND ' . $where . '
    -                GROUP BY payments.sale_id
    -            )'
    -        );
    -
    -        $this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_items_temp') .
    -            ' (INDEX(sale_date), INDEX(sale_time), INDEX(sale_id))
    -            (
    -                SELECT
    -                    MAX(DATE(sales.sale_time)) AS sale_date,
    -                    MAX(sales.sale_time) AS sale_time,
    -                    sales.sale_id AS sale_id,
    -                    MAX(sales.comment) AS comment,
    -                    MAX(sales.invoice_number) AS invoice_number,
    -                    MAX(sales.quote_number) AS quote_number,
    -                    MAX(sales.customer_id) AS customer_id,
    -                    MAX(CONCAT(customer_p.first_name, " ", customer_p.last_name)) AS customer_name,
    -                    MAX(customer_p.first_name) AS customer_first_name,
    -                    MAX(customer_p.last_name) AS customer_last_name,
    -                    MAX(customer_p.email) AS customer_email,
    -                    MAX(customer_p.comments) AS customer_comments,
    -                    MAX(customer.company_name) AS customer_company_name,
    -                    MAX(sales.employee_id) AS employee_id,
    -                    MAX(CONCAT(employee.first_name, " ", employee.last_name)) AS employee_name,
    -                    items.item_id AS item_id,
    -                    MAX(items.name) AS name,
    -                    MAX(items.category) AS category,
    -                    MAX(items.supplier_id) AS supplier_id,
    -                    MAX(sales_items.quantity_purchased) AS quantity_purchased,
    -                    MAX(sales_items.item_cost_price) AS item_cost_price,
    -                    MAX(sales_items.item_unit_price) AS item_unit_price,
    -                    MAX(sales_items.discount_percent) AS discount_percent,
    -                    sales_items.line AS line,
    -                    MAX(sales_items.serialnumber) AS serialnumber,
    -                    MAX(sales_items.item_location) AS item_location,
    -                    MAX(sales_items.description) AS description,
    -                    MAX(payments.payment_type) AS payment_type,
    -                    MAX(payments.sale_payment_amount) AS sale_payment_amount,
    -                    ' . "
    -                    IFNULL(ROUND($sale_subtotal, $decimals), ROUND($sale_total - IFNULL(SUM(sales_items_taxes.tax), 0), $decimals)) AS subtotal,
    -                    IFNULL(ROUND(SUM(sales_items_taxes.tax), $decimals), 0) AS tax,
    -                    IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals)) AS total,
    -                    IFNULL(ROUND($sale_cost, $decimals), 0) AS cost,
    -                    IFNULL(ROUND($sale_total - IFNULL(SUM(sales_items_taxes.tax), 0) - $sale_cost, $decimals), ROUND($sale_subtotal - $sale_cost, $decimals)) AS profit
    -                    " . '
    -                FROM ' . $this->db->dbprefix('sales_items') . ' AS sales_items
    -                INNER JOIN ' . $this->db->dbprefix('sales') . ' AS sales
    -                    ON sales_items.sale_id = sales.sale_id
    -                INNER JOIN ' . $this->db->dbprefix('items') . ' AS items
    -                    ON sales_items.item_id = items.item_id
    -                LEFT OUTER JOIN ' . $this->db->dbprefix('sales_payments_temp') . ' AS payments
    -                    ON sales_items.sale_id = payments.sale_id
    -                LEFT OUTER JOIN ' . $this->db->dbprefix('suppliers') . ' AS supplier
    -                    ON items.supplier_id = supplier.person_id
    -                LEFT OUTER JOIN ' . $this->db->dbprefix('people') . ' AS customer_p
    -                    ON sales.customer_id = customer_p.person_id
    -                LEFT OUTER JOIN ' . $this->db->dbprefix('customers') . ' AS customer
    -                    ON sales.customer_id = customer.person_id
    -                LEFT OUTER JOIN ' . $this->db->dbprefix('people') . ' AS employee
    -                    ON sales.employee_id = employee.person_id
    -                LEFT OUTER JOIN ' . $this->db->dbprefix('sales_items_taxes_temp') . ' AS sales_items_taxes
    -                    ON sales_items.sale_id = sales_items_taxes.sale_id AND sales_items.item_id = sales_items_taxes.item_id AND sales_items.line = sales_items_taxes.line
    +        $payments[$this->lang->line('sales_check')] = $this->lang->line('sales_check');
    +
    +        if($giftcard)
    +        {
    +            $payments[$this->lang->line('sales_giftcard')] = $this->lang->line('sales_giftcard');
    +        }
    +
    +        if($reward_points)
    +        {
    +            $payments[$this->lang->line('sales_rewards')] = $this->lang->line('sales_rewards');
    +        }
    +
    +        return $payments;
    +    }
    +
    +    /**
    +     * Gets sale customer name
    +     */
    +    public function get_customer($sale_id)
    +    {
    +        $this->db->from('sales');
    +        $this->db->where('sale_id', $sale_id);
    +
    +        return $this->Customer->get_info($this->db->get()->row()->customer_id);
    +    }
    +
    +    /**
    +     * Gets sale employee name
    +     */
    +    public function get_employee($sale_id)
    +    {
    +        $this->db->from('sales');
    +        $this->db->where('sale_id', $sale_id);
    +
    +        return $this->Employee->get_info($this->db->get()->row()->employee_id);
    +    }
    +
    +    /**
    +     * Checks if quote number exists
    +     */
    +    // TODO change to use new quote_number field
    +    public function check_quote_number_exists($quote_number, $sale_id = '')
    +    {
    +        $this->db->from('sales');
    +        $this->db->where('quote_number', $quote_number);
    +        if(!empty($sale_id))
    +        {
    +            $this->db->where('sale_id !=', $sale_id);
    +        }
    +
    +        return ($this->db->get()->num_rows() == 1);
    +    }
    +
    +    /**
    +     * Checks if invoice number exists
    +     */
    +    public function check_invoice_number_exists($invoice_number, $sale_id = '')
    +    {
    +        $this->db->from('sales');
    +        $this->db->where('invoice_number', $invoice_number);
    +        if(!empty($sale_id))
    +        {
    +            $this->db->where('sale_id !=', $sale_id);
    +        }
    +
    +        return ($this->db->get()->num_rows() == 1);
    +    }
    +
    +    /**
    +     * Gets Giftcard value
    +     */
    +    public function get_giftcard_value($giftcardNumber)
    +    {
    +        if(!$this->Giftcard->exists($this->Giftcard->get_giftcard_id($giftcardNumber)))
    +        {
    +            return 0;
    +        }
    +
    +        $this->db->from('giftcards');
    +        $this->db->where('giftcard_number', $giftcardNumber);
    +
    +        return $this->db->get()->row()->value;
    +    }
    +
    +    /**
    +     * Creates sales temporary dimentional table
    +     * We create a temp table that allows us to do easy report/sales queries
    +     */
    +    public function create_temp_table(array $inputs)
    +    {
    +        if(empty($inputs['sale_id']))
    +        {
    +            if(empty($this->config->item('date_or_time_format')))
    +            {
    +                $where = 'DATE(sales.sale_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']);
    +            }
    +            else
    +            {
    +                $where = 'sales.sale_time BETWEEN ' . $this->db->escape(rawurldecode($inputs['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($inputs['end_date']));
    +            }
    +        }
    +        else
    +        {
    +            $where = 'sales.sale_id = ' . $this->db->escape($inputs['sale_id']);
    +        }
    +
    +        $sale_price = 'sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100)';
    +
    +        if($this->config->item('tax_included'))
    +        {
    +            $sale_total = 'SUM(' . $sale_price . ')';
    +            $sale_subtotal = 'SUM(' . $sale_price . ' - sales_items_taxes.tax)';
    +        }
    +        else
    +        {
    +            $sale_total = 'SUM(' . $sale_price . ' + sales_items_taxes.tax)';
    +            $sale_subtotal = 'SUM(' . $sale_price . ')';
    +        }
    +
    +        $sale_cost = 'SUM(sales_items.item_cost_price * sales_items.quantity_purchased)';
    +
    +        $decimals = totals_decimals();
    +
    +        // create a temporary table to contain all the sum of taxes per sale item
    +        $this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_items_taxes_temp') .
    +            ' (INDEX(sale_id), INDEX(item_id))
    +            (
    +                SELECT sales_items_taxes.sale_id AS sale_id,
    +                    sales_items_taxes.item_id AS item_id,
    +                    sales_items_taxes.line AS line,
    +                    SUM(sales_items_taxes.item_tax_amount) as tax
    +                FROM ' . $this->db->dbprefix('sales_items_taxes') . ' AS sales_items_taxes
    +                INNER JOIN ' . $this->db->dbprefix('sales') . ' AS sales
    +                    ON sales.sale_id = sales_items_taxes.sale_id
    +                INNER JOIN ' . $this->db->dbprefix('sales_items') . ' AS sales_items
    +                    ON sales_items.sale_id = sales_items_taxes.sale_id AND sales_items.line = sales_items_taxes.line
                     WHERE sales.sale_status = 0 AND ' . $where . '
                     GROUP BY sale_id, item_id, line
                 )'
             );
     
    -        // drop the temporary table to contain memory consumption as it's no longer required
    -        $this->db->query('DROP TEMPORARY TABLE IF EXISTS ' . $this->db->dbprefix('sales_payments_temp'));
    -        $this->db->query('DROP TEMPORARY TABLE IF EXISTS ' . $this->db->dbprefix('sales_items_taxes_temp'));
    -    }
    -
    -    /*
    -     * Retrieves all sales that are in a suspended state
    -     */
    -    public function get_all_suspended($customer_id = NULL)
    -    {
    -        if($customer_id == -1)
    -        {
    -            $query = $this->db->query('select sale_id, sale_id as suspended_sale_id, sale_status, sale_time, dinner_table_id, customer_id, comment from '
    -                . $this->db->dbprefix('sales') . ' where sale_status = 1 '
    -                . ' union select sale_id, sale_id*-1 as suspended_sale_id, 2 as sale_status, sale_time, dinner_table_id, customer_id, comment from '
    -                . $this->db->dbprefix('sales_suspended'));
    -        }
    -        else
    -        {
    -            $query = $this->db->query('select sale_id, sale_id as suspended_sale_id, sale_status, sale_time, dinner_table_id, customer_id, comment from '
    -                . $this->db->dbprefix('sales') . ' where sale_status = 1 and customer_id = ' . $customer_id
    -                . ' union select sale_id, sale_id*-1 as suspended_sale_id, 2 as sale_status, sale_time, dinner_table_id, customer_id, comment from '
    -                . $this->db->dbprefix('sales_suspended') . ' where customer_id = ' . $customer_id);
    -        }
    -
    -        return $query->result_array();
    -
    -    }
    -
    -    /*
    -     * get the dinner table for the selected sale
    -     */
    -    public function get_dinner_table($sale_id)
    -    {
    -        $this->db->from('sales');
    -        $this->db->where('sale_id', $sale_id);
    -
    -        return $this->db->get()->row()->dinner_table_id;
    -    }
    -
    -    /*
    -    * Gets total of suspended invoices rows
    -    */
    -    public function get_suspended_invoice_count()
    -    {
    -        $this->db->from('sales');
    -        $this->db->where('invoice_number IS NOT NULL');
    -        $this->db->where('sale_status', '1');
    -
    -        return $this->db->count_all_results();
    -    }
    -
    -    /*
    -     * This will remove a selected sale from the sales table.
    -     * This function should only be called for suspended sales that are being restored to the current cart
    -     */
    -    public function delete_suspended_sale($sale_id)
    -    {
    -        //Run these queries as a transaction, we want to make sure we do all or nothing
    -        $this->db->trans_start();
    -
    -        $dinner_table = $this->get_dinner_table($sale_id);
    -        $dinner_table_data = array(
    -            'status' => 0
    -        );
    -
    -        $this->db->where('dinner_table_id',$dinner_table);
    -        $this->db->update('dinner_tables', $dinner_table_data);
    -
    -        $this->db->delete('sales_payments', array('sale_id' => $sale_id));
    -        $this->db->delete('sales_items_taxes', array('sale_id' => $sale_id));
    -        $this->db->delete('sales_items', array('sale_id' => $sale_id));
    -        $this->db->delete('sales_taxes', array('sale_id' => $sale_id));
    -        $this->db->delete('sales', array('sale_id' => $sale_id));
    -
    -        $this->db->trans_complete();
    +        // create a temporary table to contain all the payment types and amount
    +        $this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_payments_temp') .
    +            ' (PRIMARY KEY(sale_id), INDEX(sale_id))
    +            (
    +                SELECT payments.sale_id AS sale_id,
    +                    IFNULL(SUM(payments.payment_amount), 0) AS sale_payment_amount,
    +                    GROUP_CONCAT(CONCAT(payments.payment_type, " ", payments.payment_amount) SEPARATOR ", ") AS payment_type
    +                FROM ' . $this->db->dbprefix('sales_payments') . ' AS payments
    +                INNER JOIN ' . $this->db->dbprefix('sales') . ' AS sales
    +                    ON sales.sale_id = payments.sale_id
    +                WHERE sales.sale_status = 0 AND ' . $where . '
    +                GROUP BY payments.sale_id
    +            )'
    +        );
    +
    +        $this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_items_temp') .
    +            ' (INDEX(sale_date), INDEX(sale_time), INDEX(sale_id))
    +            (
    +                SELECT
    +                    MAX(DATE(sales.sale_time)) AS sale_date,
    +                    MAX(sales.sale_time) AS sale_time,
    +                    sales.sale_id AS sale_id,
    +                    MAX(sales.comment) AS comment,
    +                    MAX(sales.invoice_number) AS invoice_number,
    +                    MAX(sales.quote_number) AS quote_number,
    +                    MAX(sales.customer_id) AS customer_id,
    +                    MAX(CONCAT(customer_p.first_name, " ", customer_p.last_name)) AS customer_name,
    +                    MAX(customer_p.first_name) AS customer_first_name,
    +                    MAX(customer_p.last_name) AS customer_last_name,
    +                    MAX(customer_p.email) AS customer_email,
    +                    MAX(customer_p.comments) AS customer_comments,
    +                    MAX(customer.company_name) AS customer_company_name,
    +                    MAX(sales.employee_id) AS employee_id,
    +                    MAX(CONCAT(employee.first_name, " ", employee.last_name)) AS employee_name,
    +                    items.item_id AS item_id,
    +                    MAX(items.name) AS name,
    +                    MAX(items.category) AS category,
    +                    MAX(items.supplier_id) AS supplier_id,
    +                    MAX(sales_items.quantity_purchased) AS quantity_purchased,
    +                    MAX(sales_items.item_cost_price) AS item_cost_price,
    +                    MAX(sales_items.item_unit_price) AS item_unit_price,
    +                    MAX(sales_items.discount_percent) AS discount_percent,
    +                    sales_items.line AS line,
    +                    MAX(sales_items.serialnumber) AS serialnumber,
    +                    MAX(sales_items.item_location) AS item_location,
    +                    MAX(sales_items.description) AS description,
    +                    MAX(payments.payment_type) AS payment_type,
    +                    MAX(payments.sale_payment_amount) AS sale_payment_amount,
    +                    ' . "
    +                    IFNULL(ROUND($sale_subtotal, $decimals), ROUND($sale_total - IFNULL(SUM(sales_items_taxes.tax), 0), $decimals)) AS subtotal,
    +                    IFNULL(ROUND(SUM(sales_items_taxes.tax), $decimals), 0) AS tax,
    +                    IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals)) AS total,
    +                    IFNULL(ROUND($sale_cost, $decimals), 0) AS cost,
    +                    IFNULL(ROUND($sale_total - IFNULL(SUM(sales_items_taxes.tax), 0) - $sale_cost, $decimals), ROUND($sale_subtotal - $sale_cost, $decimals)) AS profit
    +                    " . '
    +                FROM ' . $this->db->dbprefix('sales_items') . ' AS sales_items
    +                INNER JOIN ' . $this->db->dbprefix('sales') . ' AS sales
    +                    ON sales_items.sale_id = sales.sale_id
    +                INNER JOIN ' . $this->db->dbprefix('items') . ' AS items
    +                    ON sales_items.item_id = items.item_id
    +                LEFT OUTER JOIN ' . $this->db->dbprefix('sales_payments_temp') . ' AS payments
    +                    ON sales_items.sale_id = payments.sale_id
    +                LEFT OUTER JOIN ' . $this->db->dbprefix('suppliers') . ' AS supplier
    +                    ON items.supplier_id = supplier.person_id
    +                LEFT OUTER JOIN ' . $this->db->dbprefix('people') . ' AS customer_p
    +                    ON sales.customer_id = customer_p.person_id
    +                LEFT OUTER JOIN ' . $this->db->dbprefix('customers') . ' AS customer
    +                    ON sales.customer_id = customer.person_id
    +                LEFT OUTER JOIN ' . $this->db->dbprefix('people') . ' AS employee
    +                    ON sales.employee_id = employee.person_id
    +                LEFT OUTER JOIN ' . $this->db->dbprefix('sales_items_taxes_temp') . ' AS sales_items_taxes
    +                    ON sales_items.sale_id = sales_items_taxes.sale_id AND sales_items.item_id = sales_items_taxes.item_id AND sales_items.line = sales_items_taxes.line
    +                WHERE sales.sale_status = 0 AND ' . $where . '
    +                GROUP BY sale_id, item_id, line
    +            )'
    +        );
     
    -        return $this->db->trans_status();
    -    }
    -
    -    public function get_suspended_sale_info($sale_id)
    -    {
    -        $this->db->from('sales');
    -        $this->db->where('sale_id', $sale_id);
    -        $this->db->join('people', 'people.person_id = sales_suspended.customer_id', 'LEFT');
    -
    -        return $this->db->get();
    -    }
    -}
    -?>
    -
    +
    // drop the temporary table to contain memory consumption as it's no longer required + $this->db->query('DROP TEMPORARY TABLE IF EXISTS ' . $this->db->dbprefix('sales_payments_temp')); + $this->db->query('DROP TEMPORARY TABLE IF EXISTS ' . $this->db->dbprefix('sales_items_taxes_temp')); + } + + /** + * Retrieves all sales that are in a suspended state + */ + public function get_all_suspended($customer_id = NULL) + { + if($customer_id == -1) + { + $query = $this->db->query('select sale_id, sale_id as suspended_sale_id, sale_status, sale_time, dinner_table_id, customer_id, comment from ' + . $this->db->dbprefix('sales') . ' where sale_status = 1 ' + . ' union select sale_id, sale_id*-1 as suspended_sale_id, 2 as sale_status, sale_time, dinner_table_id, customer_id, comment from ' + . $this->db->dbprefix('sales_suspended')); + } + else + { + $query = $this->db->query('select sale_id, sale_id as suspended_sale_id, sale_status, sale_time, dinner_table_id, customer_id, comment from ' + . $this->db->dbprefix('sales') . ' where sale_status = 1 and customer_id = ' . $customer_id + . ' union select sale_id, sale_id*-1 as suspended_sale_id, 2 as sale_status, sale_time, dinner_table_id, customer_id, comment from ' + . $this->db->dbprefix('sales_suspended') . ' where customer_id = ' . $customer_id); + } + + return $query->result_array(); + + } + + /** + * Gets the dinner table for the selected sale + */ + public function get_dinner_table($sale_id) + { + $this->db->from('sales'); + $this->db->where('sale_id', $sale_id); + + return $this->db->get()->row()->dinner_table_id; + } + + /** + * Gets the quote_number for the selected sale + */ + public function get_quote_number($sale_id) + { + $this->db->from('sales'); + $this->db->where('sale_id', $sale_id); + + $row = $this->db->get()->row(); + + if($row != NULL) + { + return $row->quote_number; + } + else + { + return NULL; + } + } + + /** + * Gets the quote_number for the selected sale + */ + public function get_comment($sale_id) + { + $this->db->from('sales'); + $this->db->where('sale_id', $sale_id); + + $row = $this->db->get()->row(); + + if($row != NULL) + { + return $row->comment; + } + else + { + return NULL; + } + } + + /** + * Gets total of suspended invoices rows + */ + public function get_suspended_invoice_count() + { + $this->db->from('sales'); + $this->db->where('invoice_number IS NOT NULL'); + $this->db->where('sale_status', '1'); + + return $this->db->count_all_results(); + } + + /** + * Removes a selected sale from the sales table. + * This function should only be called for suspended sales that are being restored to the current cart + */ + public function delete_suspended_sale($sale_id) + { + //Run these queries as a transaction, we want to make sure we do all or nothing + $this->db->trans_start(); + + $dinner_table = $this->get_dinner_table($sale_id); + $dinner_table_data = array( + 'status' => 0 + ); + + $this->db->where('dinner_table_id',$dinner_table); + $this->db->update('dinner_tables', $dinner_table_data); + + $this->db->delete('sales_payments', array('sale_id' => $sale_id)); + $this->db->delete('sales_items_taxes', array('sale_id' => $sale_id)); + $this->db->delete('sales_items', array('sale_id' => $sale_id)); + $this->db->delete('sales_taxes', array('sale_id' => $sale_id)); + $this->db->delete('sales', array('sale_id' => $sale_id)); + + $this->db->trans_complete(); + + return $this->db->trans_status(); + } + + /** + * Gets suspended sale info + */ + public function get_suspended_sale_info($sale_id) + { + $this->db->from('sales'); + $this->db->where('sale_id', $sale_id); + $this->db->join('people', 'people.person_id = sales_suspended.customer_id', 'LEFT'); + + return $this->db->get(); + } +} +?> +
    - + diff --git a/docs/source-class-Sale_lib.html b/docs/source-class-Sale_lib.html index b0970ffee..fd2ec940c 100644 --- a/docs/source-class-Sale_lib.html +++ b/docs/source-class-Sale_lib.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,1235 +207,1274 @@ -
       1:    2:    3:    4:    5:    6:    7:    8:    9:   10:   11:   12:   13:   14:   15:   16:   17:   18:   19:   20:   21:   22:   23:   24:   25:   26:   27:   28:   29:   30:   31:   32:   33:   34:   35:   36:   37:   38:   39:   40:   41:   42:   43:   44:   45:   46:   47:   48:   49:   50:   51:   52:   53:   54:   55:   56:   57:   58:   59:   60:   61:   62:   63:   64:   65:   66:   67:   68:   69:   70:   71:   72:   73:   74:   75:   76:   77:   78:   79:   80:   81:   82:   83:   84:   85:   86:   87:   88:   89:   90:   91:   92:   93:   94:   95:   96:   97:   98:   99:  100:  101:  102:  103:  104:  105:  106:  107:  108:  109:  110:  111:  112:  113:  114:  115:  116:  117:  118:  119:  120:  121:  122:  123:  124:  125:  126:  127:  128:  129:  130:  131:  132:  133:  134:  135:  136:  137:  138:  139:  140:  141:  142:  143:  144:  145:  146:  147:  148:  149:  150:  151:  152:  153:  154:  155:  156:  157:  158:  159:  160:  161:  162:  163:  164:  165:  166:  167:  168:  169:  170:  171:  172:  173:  174:  175:  176:  177:  178:  179:  180:  181:  182:  183:  184:  185:  186:  187:  188:  189:  190:  191:  192:  193:  194:  195:  196:  197:  198:  199:  200:  201:  202:  203:  204:  205:  206:  207:  208:  209:  210:  211:  212:  213:  214:  215:  216:  217:  218:  219:  220:  221:  222:  223:  224:  225:  226:  227:  228:  229:  230:  231:  232:  233:  234:  235:  236:  237:  238:  239:  240:  241:  242:  243:  244:  245:  246:  247:  248:  249:  250:  251:  252:  253:  254:  255:  256:  257:  258:  259:  260:  261:  262:  263:  264:  265:  266:  267:  268:  269:  270:  271:  272:  273:  274:  275:  276:  277:  278:  279:  280:  281:  282:  283:  284:  285:  286:  287:  288:  289:  290:  291:  292:  293:  294:  295:  296:  297:  298:  299:  300:  301:  302:  303:  304:  305:  306:  307:  308:  309:  310:  311:  312:  313:  314:  315:  316:  317:  318:  319:  320:  321:  322:  323:  324:  325:  326:  327:  328:  329:  330:  331:  332:  333:  334:  335:  336:  337:  338:  339:  340:  341:  342:  343:  344:  345:  346:  347:  348:  349:  350:  351:  352:  353:  354:  355:  356:  357:  358:  359:  360:  361:  362:  363:  364:  365:  366:  367:  368:  369:  370:  371:  372:  373:  374:  375:  376:  377:  378:  379:  380:  381:  382:  383:  384:  385:  386:  387:  388:  389:  390:  391:  392:  393:  394:  395:  396:  397:  398:  399:  400:  401:  402:  403:  404:  405:  406:  407:  408:  409:  410:  411:  412:  413:  414:  415:  416:  417:  418:  419:  420:  421:  422:  423:  424:  425:  426:  427:  428:  429:  430:  431:  432:  433:  434:  435:  436:  437:  438:  439:  440:  441:  442:  443:  444:  445:  446:  447:  448:  449:  450:  451:  452:  453:  454:  455:  456:  457:  458:  459:  460:  461:  462:  463:  464:  465:  466:  467:  468:  469:  470:  471:  472:  473:  474:  475:  476:  477:  478:  479:  480:  481:  482:  483:  484:  485:  486:  487:  488:  489:  490:  491:  492:  493:  494:  495:  496:  497:  498:  499:  500:  501:  502:  503:  504:  505:  506:  507:  508:  509:  510:  511:  512:  513:  514:  515:  516:  517:  518:  519:  520:  521:  522:  523:  524:  525:  526:  527:  528:  529:  530:  531:  532:  533:  534:  535:  536:  537:  538:  539:  540:  541:  542:  543:  544:  545:  546:  547:  548:  549:  550:  551:  552:  553:  554:  555:  556:  557:  558:  559:  560:  561:  562:  563:  564:  565:  566:  567:  568:  569:  570:  571:  572:  573:  574:  575:  576:  577:  578:  579:  580:  581:  582:  583:  584:  585:  586:  587:  588:  589:  590:  591:  592:  593:  594:  595:  596:  597:  598:  599:  600:  601:  602:  603:  604:  605:  606:  607:  608:  609:  610:  611:  612:  613:  614:  615:  616:  617:  618:  619:  620:  621:  622:  623:  624:  625:  626:  627:  628:  629:  630:  631:  632:  633:  634:  635:  636:  637:  638:  639:  640:  641:  642:  643:  644:  645:  646:  647:  648:  649:  650:  651:  652:  653:  654:  655:  656:  657:  658:  659:  660:  661:  662:  663:  664:  665:  666:  667:  668:  669:  670:  671:  672:  673:  674:  675:  676:  677:  678:  679:  680:  681:  682:  683:  684:  685:  686:  687:  688:  689:  690:  691:  692:  693:  694:  695:  696:  697:  698:  699:  700:  701:  702:  703:  704:  705:  706:  707:  708:  709:  710:  711:  712:  713:  714:  715:  716:  717:  718:  719:  720:  721:  722:  723:  724:  725:  726:  727:  728:  729:  730:  731:  732:  733:  734:  735:  736:  737:  738:  739:  740:  741:  742:  743:  744:  745:  746:  747:  748:  749:  750:  751:  752:  753:  754:  755:  756:  757:  758:  759:  760:  761:  762:  763:  764:  765:  766:  767:  768:  769:  770:  771:  772:  773:  774:  775:  776:  777:  778:  779:  780:  781:  782:  783:  784:  785:  786:  787:  788:  789:  790:  791:  792:  793:  794:  795:  796:  797:  798:  799:  800:  801:  802:  803:  804:  805:  806:  807:  808:  809:  810:  811:  812:  813:  814:  815:  816:  817:  818:  819:  820:  821:  822:  823:  824:  825:  826:  827:  828:  829:  830:  831:  832:  833:  834:  835:  836:  837:  838:  839:  840:  841:  842:  843:  844:  845:  846:  847:  848:  849:  850:  851:  852:  853:  854:  855:  856:  857:  858:  859:  860:  861:  862:  863:  864:  865:  866:  867:  868:  869:  870:  871:  872:  873:  874:  875:  876:  877:  878:  879:  880:  881:  882:  883:  884:  885:  886:  887:  888:  889:  890:  891:  892:  893:  894:  895:  896:  897:  898:  899:  900:  901:  902:  903:  904:  905:  906:  907:  908:  909:  910:  911:  912:  913:  914:  915:  916:  917:  918:  919:  920:  921:  922:  923:  924:  925:  926:  927:  928:  929:  930:  931:  932:  933:  934:  935:  936:  937:  938:  939:  940:  941:  942:  943:  944:  945:  946:  947:  948:  949:  950:  951:  952:  953:  954:  955:  956:  957:  958:  959:  960:  961:  962:  963:  964:  965:  966:  967:  968:  969:  970:  971:  972:  973:  974:  975:  976:  977:  978:  979:  980:  981:  982:  983:  984:  985:  986:  987:  988:  989:  990:  991:  992:  993:  994:  995:  996:  997:  998:  999: 1000: 1001: 1002: 1003: 1004: 1005: 1006: 1007: 1008: 1009: 1010: 1011: 1012: 1013: 1014: 1015: 1016: 1017: 1018: 1019: 1020: 1021: 1022: 1023: 1024: 1025: 1026: 1027: 1028: 1029: 1030: 1031: 1032: 1033: 1034: 1035: 1036: 1037: 1038: 1039: 1040: 1041: 1042: 1043: 1044: 1045: 1046: 1047: 1048: 1049: 1050: 1051: 1052: 1053: 1054: 1055: 1056: 1057: 1058: 1059: 1060: 1061: 1062: 1063: 1064: 1065: 1066: 1067: 1068: 1069: 1070: 1071: 1072: 1073: 1074: 1075: 1076: 1077: 1078: 1079: 1080: 1081: 1082: 1083: 1084: 1085: 1086: 1087: 1088: 1089: 1090: 1091: 1092: 1093: 1094: 1095: 1096: 1097: 1098: 1099: 1100: 1101: 1102: 1103: 1104: 1105: 1106: 1107: 1108: 1109: 1110: 1111: 1112: 1113: 1114: 1115: 1116: 1117: 1118: 1119: 1120: 1121: 1122: 1123: 1124: 1125: 1126: 1127: 1128: 1129: 1130: 1131: 1132: 1133: 1134: 1135: 1136: 1137: 1138: 1139: 1140: 1141: 1142: 1143: 1144: 1145: 1146: 1147: 1148: 1149: 1150: 1151: 1152: 1153: 1154: 1155: 1156: 1157: 1158: 1159: 1160: 1161: 1162: 1163: 1164: 1165: 1166: 1167: 1168: 1169: 1170: 1171: 1172: 1173: 1174: 1175: 1176: 1177: 1178: 1179: 1180: 1181: 1182: 1183: 1184: 1185: 1186: 1187: 1188: 1189: 1190: 1191: 1192: 1193: 1194: 1195: 1196: 1197: 1198: 1199: 1200: 1201: 1202: 1203: 1204: 1205: 1206: 1207: 1208: 1209: 1210: 1211: 1212: 1213: 1214: 1215: 1216: 1217: 1218: 1219: 1220: 1221: 1222: 1223: 1224: 1225: 1226: 1227: 1228: 
    +
       1:    2:    3:    4:    5:    6:    7:    8:    9:   10:   11:   12:   13:   14:   15:   16:   17:   18:   19:   20:   21:   22:   23:   24:   25:   26:   27:   28:   29:   30:   31:   32:   33:   34:   35:   36:   37:   38:   39:   40:   41:   42:   43:   44:   45:   46:   47:   48:   49:   50:   51:   52:   53:   54:   55:   56:   57:   58:   59:   60:   61:   62:   63:   64:   65:   66:   67:   68:   69:   70:   71:   72:   73:   74:   75:   76:   77:   78:   79:   80:   81:   82:   83:   84:   85:   86:   87:   88:   89:   90:   91:   92:   93:   94:   95:   96:   97:   98:   99:  100:  101:  102:  103:  104:  105:  106:  107:  108:  109:  110:  111:  112:  113:  114:  115:  116:  117:  118:  119:  120:  121:  122:  123:  124:  125:  126:  127:  128:  129:  130:  131:  132:  133:  134:  135:  136:  137:  138:  139:  140:  141:  142:  143:  144:  145:  146:  147:  148:  149:  150:  151:  152:  153:  154:  155:  156:  157:  158:  159:  160:  161:  162:  163:  164:  165:  166:  167:  168:  169:  170:  171:  172:  173:  174:  175:  176:  177:  178:  179:  180:  181:  182:  183:  184:  185:  186:  187:  188:  189:  190:  191:  192:  193:  194:  195:  196:  197:  198:  199:  200:  201:  202:  203:  204:  205:  206:  207:  208:  209:  210:  211:  212:  213:  214:  215:  216:  217:  218:  219:  220:  221:  222:  223:  224:  225:  226:  227:  228:  229:  230:  231:  232:  233:  234:  235:  236:  237:  238:  239:  240:  241:  242:  243:  244:  245:  246:  247:  248:  249:  250:  251:  252:  253:  254:  255:  256:  257:  258:  259:  260:  261:  262:  263:  264:  265:  266:  267:  268:  269:  270:  271:  272:  273:  274:  275:  276:  277:  278:  279:  280:  281:  282:  283:  284:  285:  286:  287:  288:  289:  290:  291:  292:  293:  294:  295:  296:  297:  298:  299:  300:  301:  302:  303:  304:  305:  306:  307:  308:  309:  310:  311:  312:  313:  314:  315:  316:  317:  318:  319:  320:  321:  322:  323:  324:  325:  326:  327:  328:  329:  330:  331:  332:  333:  334:  335:  336:  337:  338:  339:  340:  341:  342:  343:  344:  345:  346:  347:  348:  349:  350:  351:  352:  353:  354:  355:  356:  357:  358:  359:  360:  361:  362:  363:  364:  365:  366:  367:  368:  369:  370:  371:  372:  373:  374:  375:  376:  377:  378:  379:  380:  381:  382:  383:  384:  385:  386:  387:  388:  389:  390:  391:  392:  393:  394:  395:  396:  397:  398:  399:  400:  401:  402:  403:  404:  405:  406:  407:  408:  409:  410:  411:  412:  413:  414:  415:  416:  417:  418:  419:  420:  421:  422:  423:  424:  425:  426:  427:  428:  429:  430:  431:  432:  433:  434:  435:  436:  437:  438:  439:  440:  441:  442:  443:  444:  445:  446:  447:  448:  449:  450:  451:  452:  453:  454:  455:  456:  457:  458:  459:  460:  461:  462:  463:  464:  465:  466:  467:  468:  469:  470:  471:  472:  473:  474:  475:  476:  477:  478:  479:  480:  481:  482:  483:  484:  485:  486:  487:  488:  489:  490:  491:  492:  493:  494:  495:  496:  497:  498:  499:  500:  501:  502:  503:  504:  505:  506:  507:  508:  509:  510:  511:  512:  513:  514:  515:  516:  517:  518:  519:  520:  521:  522:  523:  524:  525:  526:  527:  528:  529:  530:  531:  532:  533:  534:  535:  536:  537:  538:  539:  540:  541:  542:  543:  544:  545:  546:  547:  548:  549:  550:  551:  552:  553:  554:  555:  556:  557:  558:  559:  560:  561:  562:  563:  564:  565:  566:  567:  568:  569:  570:  571:  572:  573:  574:  575:  576:  577:  578:  579:  580:  581:  582:  583:  584:  585:  586:  587:  588:  589:  590:  591:  592:  593:  594:  595:  596:  597:  598:  599:  600:  601:  602:  603:  604:  605:  606:  607:  608:  609:  610:  611:  612:  613:  614:  615:  616:  617:  618:  619:  620:  621:  622:  623:  624:  625:  626:  627:  628:  629:  630:  631:  632:  633:  634:  635:  636:  637:  638:  639:  640:  641:  642:  643:  644:  645:  646:  647:  648:  649:  650:  651:  652:  653:  654:  655:  656:  657:  658:  659:  660:  661:  662:  663:  664:  665:  666:  667:  668:  669:  670:  671:  672:  673:  674:  675:  676:  677:  678:  679:  680:  681:  682:  683:  684:  685:  686:  687:  688:  689:  690:  691:  692:  693:  694:  695:  696:  697:  698:  699:  700:  701:  702:  703:  704:  705:  706:  707:  708:  709:  710:  711:  712:  713:  714:  715:  716:  717:  718:  719:  720:  721:  722:  723:  724:  725:  726:  727:  728:  729:  730:  731:  732:  733:  734:  735:  736:  737:  738:  739:  740:  741:  742:  743:  744:  745:  746:  747:  748:  749:  750:  751:  752:  753:  754:  755:  756:  757:  758:  759:  760:  761:  762:  763:  764:  765:  766:  767:  768:  769:  770:  771:  772:  773:  774:  775:  776:  777:  778:  779:  780:  781:  782:  783:  784:  785:  786:  787:  788:  789:  790:  791:  792:  793:  794:  795:  796:  797:  798:  799:  800:  801:  802:  803:  804:  805:  806:  807:  808:  809:  810:  811:  812:  813:  814:  815:  816:  817:  818:  819:  820:  821:  822:  823:  824:  825:  826:  827:  828:  829:  830:  831:  832:  833:  834:  835:  836:  837:  838:  839:  840:  841:  842:  843:  844:  845:  846:  847:  848:  849:  850:  851:  852:  853:  854:  855:  856:  857:  858:  859:  860:  861:  862:  863:  864:  865:  866:  867:  868:  869:  870:  871:  872:  873:  874:  875:  876:  877:  878:  879:  880:  881:  882:  883:  884:  885:  886:  887:  888:  889:  890:  891:  892:  893:  894:  895:  896:  897:  898:  899:  900:  901:  902:  903:  904:  905:  906:  907:  908:  909:  910:  911:  912:  913:  914:  915:  916:  917:  918:  919:  920:  921:  922:  923:  924:  925:  926:  927:  928:  929:  930:  931:  932:  933:  934:  935:  936:  937:  938:  939:  940:  941:  942:  943:  944:  945:  946:  947:  948:  949:  950:  951:  952:  953:  954:  955:  956:  957:  958:  959:  960:  961:  962:  963:  964:  965:  966:  967:  968:  969:  970:  971:  972:  973:  974:  975:  976:  977:  978:  979:  980:  981:  982:  983:  984:  985:  986:  987:  988:  989:  990:  991:  992:  993:  994:  995:  996:  997:  998:  999: 1000: 1001: 1002: 1003: 1004: 1005: 1006: 1007: 1008: 1009: 1010: 1011: 1012: 1013: 1014: 1015: 1016: 1017: 1018: 1019: 1020: 1021: 1022: 1023: 1024: 1025: 1026: 1027: 1028: 1029: 1030: 1031: 1032: 1033: 1034: 1035: 1036: 1037: 1038: 1039: 1040: 1041: 1042: 1043: 1044: 1045: 1046: 1047: 1048: 1049: 1050: 1051: 1052: 1053: 1054: 1055: 1056: 1057: 1058: 1059: 1060: 1061: 1062: 1063: 1064: 1065: 1066: 1067: 1068: 1069: 1070: 1071: 1072: 1073: 1074: 1075: 1076: 1077: 1078: 1079: 1080: 1081: 1082: 1083: 1084: 1085: 1086: 1087: 1088: 1089: 1090: 1091: 1092: 1093: 1094: 1095: 1096: 1097: 1098: 1099: 1100: 1101: 1102: 1103: 1104: 1105: 1106: 1107: 1108: 1109: 1110: 1111: 1112: 1113: 1114: 1115: 1116: 1117: 1118: 1119: 1120: 1121: 1122: 1123: 1124: 1125: 1126: 1127: 1128: 1129: 1130: 1131: 1132: 1133: 1134: 1135: 1136: 1137: 1138: 1139: 1140: 1141: 1142: 1143: 1144: 1145: 1146: 1147: 1148: 1149: 1150: 1151: 1152: 1153: 1154: 1155: 1156: 1157: 1158: 1159: 1160: 1161: 1162: 1163: 1164: 1165: 1166: 1167: 1168: 1169: 1170: 1171: 1172: 1173: 1174: 1175: 1176: 1177: 1178: 1179: 1180: 1181: 1182: 1183: 1184: 1185: 1186: 1187: 1188: 1189: 1190: 1191: 1192: 1193: 1194: 1195: 1196: 1197: 1198: 1199: 1200: 1201: 1202: 1203: 1204: 1205: 1206: 1207: 1208: 1209: 1210: 1211: 1212: 1213: 1214: 1215: 1216: 1217: 1218: 1219: 1220: 1221: 1222: 1223: 1224: 1225: 1226: 1227: 1228: 1229: 1230: 1231: 1232: 1233: 1234: 1235: 1236: 1237: 1238: 1239: 1240: 1241: 1242: 1243: 1244: 1245: 1246: 1247: 1248: 1249: 1250: 1251: 1252: 1253: 1254: 1255: 1256: 1257: 1258: 1259: 1260: 1261: 1262: 1263: 1264: 1265: 1266: 1267: 
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
    -class Sale_lib
    -{
    -    private $CI;
    -
    -    public function __construct()
    -    {
    -        $this->CI =& get_instance();
    -        $this->CI->load->library('tax_lib');
    -        $this->CI->load->model('enums/Rounding_code');
    +/**
    + * Sale library
    + *
    + * Library with utilities to manage sales
    + *
    + * @link    github.com/jekkos/opensourcepos
    + * @since   1.0
    + * @author  N/A
    + */
     
    -    }
    -
    -    public function get_line_sequence_options()
    -    {
    -        return array(
    -            '0' => $this->CI->lang->line('sales_entry'),
    -            '1' => $this->CI->lang->line('sales_group_by_type'),
    -            '2' => $this->CI->lang->line('sales_group_by_category')
    -        );
    +class Sale_lib
    +{
    +    private $CI;
    +
    +    public function __construct()
    +    {
    +        $this->CI =& get_instance();
    +        $this->CI->load->library('tax_lib');
    +        $this->CI->load->model('enums/Rounding_code');
         }
     
    -    public function get_register_mode_options()
    +    public function get_line_sequence_options()
         {
             return array(
    -            'sale' => $this->CI->lang->line('sales_receipt'),
    -            'sale_invoice' => $this->CI->lang->line('sales_invoice'),
    -            'sale_quote' => $this->CI->lang->line('sales_quote')
    +            '0' => $this->CI->lang->line('sales_entry'),
    +            '1' => $this->CI->lang->line('sales_group_by_type'),
    +            '2' => $this->CI->lang->line('sales_group_by_category')
             );
         }
     
    -    public function get_cart()
    +    public function get_register_mode_options()
         {
    -        if(!$this->CI->session->userdata('sales_cart'))
    -        {
    -            $this->set_cart(array());
    -        }
    -
    -        return $this->CI->session->userdata('sales_cart');
    -    }
    -
    -    public function sort_and_filter_cart($cart)
    -    {
    -        if(empty($cart))
    -        {
    -            return $cart;
    -        }
    -
    -        $filtered_cart = array();
    +        return array(
    +            'sale' => $this->CI->lang->line('sales_receipt'),
    +            'sale_invoice' => $this->CI->lang->line('sales_invoice'),
    +            'sale_quote' => $this->CI->lang->line('sales_quote')
    +        );
    +    }
    +
    +    public function get_cart()
    +    {
    +        if(!$this->CI->session->userdata('sales_cart'))
    +        {
    +            $this->set_cart(array());
    +        }
    +
    +        return $this->CI->session->userdata('sales_cart');
    +    }
     
    -        foreach($cart as $k=>$v)
    -        {
    -            if($v['print_option'] == '0')
    -            {
    -                $filtered_cart[] = $v;
    -            }
    -        }
    -
    -        // Entry sequence (this will render kits in the expected sequence)
    -        if($this->CI->config->item('line_sequence') == '0')
    +    public function sort_and_filter_cart($cart)
    +    {
    +        if(empty($cart))
    +        {
    +            return $cart;
    +        }
    +
    +        $filtered_cart = array();
    +
    +        foreach($cart as $k=>$v)
             {
    -            $sort = array();
    -            foreach($filtered_cart as $k=>$v)
    -            {
    -                $sort['line'][$k] = $v['line'];
    -            }
    -            array_multisort($sort['line'], SORT_ASC, $filtered_cart);
    -        }
    -        // Group by Stock Type (nonstock first - type 1, stock next - type 0)
    -        elseif($this->CI->config->item('line_sequence') == '1')
    -        {
    -            $sort = array();
    -            foreach($filtered_cart as $k=>$v)
    -            {
    -                $sort['stock_type'][$k] = $v['stock_type'];
    -                $sort['description'][$k] = $v['description'];
    -                $sort['name'][$k] = $v['name'];
    -            }
    -            array_multisort($sort['stock_type'], SORT_DESC, $sort['description'], SORT_ASC, $sort['name'], SORT_ASC. $filtered_cart);
    -        }
    -        // Group by Item Category
    -        elseif($this->CI->config->item('line_sequence') == '2')
    -        {
    -            $sort = array();
    -            foreach($filtered_cart as $k=>$v)
    -            {
    -                $sort['category'][$k] = $v['stock_type'];
    -                $sort['description'][$k] = $v['description'];
    -                $sort['name'][$k] = $v['name'];
    -            }
    -            array_multisort($sort['category'], SORT_DESC, $sort['description'], SORT_ASC, $sort['name'], SORT_ASC, $filtered_cart);
    -        }
    -        // Group by entry sequence in descending sequence (the Standard)
    -        else
    -        {
    -            $sort = array();
    -            foreach($filtered_cart as $k=>$v)
    -            {
    -                $sort['line'][$k] = $v['line'];
    -            }
    -            array_multisort($sort['line'], SORT_ASC, $filtered_cart);
    -        }
    -
    -        return $filtered_cart;
    -    }
    -
    -    public function set_cart($cart_data)
    -    {
    -        $this->CI->session->set_userdata('sales_cart', $cart_data);
    -    }
    -
    -    public function empty_cart()
    -    {
    -        $this->CI->session->unset_userdata('sales_cart');
    -    }
    -    
    -    public function get_comment() 
    -    {
    -        // avoid returning a NULL that results in a 0 in the comment if nothing is set/available
    -        $comment = $this->CI->session->userdata('sales_comment');
    -
    -        return empty($comment) ? '' : $comment;
    -    }
    -
    -    public function set_comment($comment) 
    -    {
    -        $this->CI->session->set_userdata('sales_comment', $comment);
    -    }
    -
    -    public function clear_comment()     
    -    {
    -        $this->CI->session->unset_userdata('sales_comment');
    -    }
    -    
    -    public function get_invoice_number()
    -    {
    -        return $this->CI->session->userdata('sales_invoice_number');
    -    }
    -
    -    public function get_quote_number()
    -    {
    -        return $this->CI->session->userdata('sales_quote_number');
    -    }
    -
    -    public function set_invoice_number($invoice_number, $keep_custom = FALSE)
    -    {
    -        $current_invoice_number = $this->CI->session->userdata('sales_invoice_number');
    -        if(!$keep_custom || empty($current_invoice_number))
    -        {
    -            $this->CI->session->set_userdata('sales_invoice_number', $invoice_number);
    -        }
    +            if($v['print_option'] == '0')
    +            {
    +                $filtered_cart[] = $v;
    +            }
    +        }
    +
    +        // Entry sequence (this will render kits in the expected sequence)
    +        if($this->CI->config->item('line_sequence') == '0')
    +        {
    +            $sort = array();
    +            foreach($filtered_cart as $k=>$v)
    +            {
    +                $sort['line'][$k] = $v['line'];
    +            }
    +            array_multisort($sort['line'], SORT_ASC, $filtered_cart);
    +        }
    +        // Group by Stock Type (nonstock first - type 1, stock next - type 0)
    +        elseif($this->CI->config->item('line_sequence') == '1')
    +        {
    +            $sort = array();
    +            foreach($filtered_cart as $k=>$v)
    +            {
    +                $sort['stock_type'][$k] = $v['stock_type'];
    +                $sort['description'][$k] = $v['description'];
    +                $sort['name'][$k] = $v['name'];
    +            }
    +            array_multisort($sort['stock_type'], SORT_DESC, $sort['description'], SORT_ASC, $sort['name'], SORT_ASC. $filtered_cart);
    +        }
    +        // Group by Item Category
    +        elseif($this->CI->config->item('line_sequence') == '2')
    +        {
    +            $sort = array();
    +            foreach($filtered_cart as $k=>$v)
    +            {
    +                $sort['category'][$k] = $v['stock_type'];
    +                $sort['description'][$k] = $v['description'];
    +                $sort['name'][$k] = $v['name'];
    +            }
    +            array_multisort($sort['category'], SORT_DESC, $sort['description'], SORT_ASC, $sort['name'], SORT_ASC, $filtered_cart);
    +        }
    +        // Group by entry sequence in descending sequence (the Standard)
    +        else
    +        {
    +            $sort = array();
    +            foreach($filtered_cart as $k=>$v)
    +            {
    +                $sort['line'][$k] = $v['line'];
    +            }
    +            array_multisort($sort['line'], SORT_ASC, $filtered_cart);
    +        }
    +
    +        return $filtered_cart;
    +    }
    +
    +    public function set_cart($cart_data)
    +    {
    +        $this->CI->session->set_userdata('sales_cart', $cart_data);
    +    }
    +
    +    public function empty_cart()
    +    {
    +        $this->CI->session->unset_userdata('sales_cart');
    +    }
    +
    +    public function get_comment()
    +    {
    +        // avoid returning a NULL that results in a 0 in the comment if nothing is set/available
    +        $comment = $this->CI->session->userdata('sales_comment');
    +
    +        return empty($comment) ? '' : $comment;
    +    }
    +
    +    public function set_comment($comment)
    +    {
    +        $this->CI->session->set_userdata('sales_comment', $comment);
    +    }
    +
    +    public function clear_comment()
    +    {
    +        $this->CI->session->unset_userdata('sales_comment');
    +    }
    +
    +    public function get_invoice_number()
    +    {
    +        return $this->CI->session->userdata('sales_invoice_number');
    +    }
    +
    +    public function get_quote_number()
    +    {
    +        return $this->CI->session->userdata('sales_quote_number');
         }
     
    -    public function set_quote_number($quote_number, $keep_custom = FALSE)
    +    public function set_invoice_number($invoice_number, $keep_custom = FALSE)
         {
    -        $current_quote_number = $this->CI->session->userdata('sales_quote_number');
    -        if(!$keep_custom || empty($current_quote_number))
    +        $current_invoice_number = $this->CI->session->userdata('sales_invoice_number');
    +        if(!$keep_custom || empty($current_invoice_number))
             {
    -            $this->CI->session->set_userdata('sales_quote_number', $quote_number);
    +            $this->CI->session->set_userdata('sales_invoice_number', $invoice_number);
             }
         }
     
    -    public function clear_invoice_number()
    +    public function set_quote_number($quote_number, $keep_custom = FALSE)
         {
    -        $this->CI->session->unset_userdata('sales_invoice_number');
    -    }
    -
    -    public function clear_quote_number()
    -    {
    -        $this->CI->session->unset_userdata('sales_quote_number');
    -    }
    -
    -    public function set_suspended_id($suspended_id)
    -    {
    -        $this->CI->session->set_userdata('suspended_id', $suspended_id);
    -    }
    -
    -    public function get_suspended_id()
    -    {
    -        return $this->CI->session->userdata('suspended_id');
    -    }
    -
    -    public function is_invoice_mode()
    -    {
    -        return ($this->CI->session->userdata('sales_invoice_number_enabled') == 'true' ||
    -                $this->CI->session->userdata('sales_mode') == 'sale_invoice' ||
    -                ($this->CI->session->userdata('sales_invoice_number_enabled') == '1') &&
    -                    $this->CI->config->item('invoice_enable') == TRUE);
    -    }
    -
    -    public function is_sale_by_receipt_mode()
    -    {
    -        return ($this->CI->session->userdata('sales_mode') == 'sale');
    -    }
    -
    -    public function is_quote_mode()
    -    {
    -        return ($this->CI->session->userdata('sales_mode') == 'sale_quote');
    -    }
    -
    -    public function set_invoice_number_enabled($invoice_number_enabled)
    -    {
    -        return $this->CI->session->set_userdata('sales_invoice_number_enabled', $invoice_number_enabled);
    -    }
    -    
    -    public function is_print_after_sale() 
    -    {
    -        return ($this->CI->session->userdata('sales_print_after_sale') == 'true' ||
    -                $this->CI->session->userdata('sales_print_after_sale') == '1');
    -    }
    -    
    -    public function set_print_after_sale($print_after_sale)
    -    {
    -        return $this->CI->session->set_userdata('sales_print_after_sale', $print_after_sale);
    -    }
    -    
    -    public function get_email_receipt() 
    -    {
    -        return $this->CI->session->userdata('sales_email_receipt');
    -    }
    -
    -    public function set_email_receipt($email_receipt) 
    -    {
    -        $this->CI->session->set_userdata('sales_email_receipt', $email_receipt);
    -    }
    -
    -    public function clear_email_receipt()   
    -    {
    -        $this->CI->session->unset_userdata('sales_email_receipt');
    -    }
    -
    -    // Multiple Payments
    -    public function get_payments()
    -    {
    -        if(!$this->CI->session->userdata('sales_payments'))
    -        {
    -            $this->set_payments(array());
    -        }
    -
    -        return $this->CI->session->userdata('sales_payments');
    -    }
    -
    -    // Multiple Payments
    -    public function set_payments($payments_data)
    -    {
    -        $this->CI->session->set_userdata('sales_payments', $payments_data);
    -    }
    +        $current_quote_number = $this->CI->session->userdata('sales_quote_number');
    +        if(!$keep_custom || empty($current_quote_number))
    +        {
    +            $this->CI->session->set_userdata('sales_quote_number', $quote_number);
    +        }
    +    }
    +
    +    public function clear_invoice_number()
    +    {
    +        $this->CI->session->unset_userdata('sales_invoice_number');
    +    }
    +
    +    public function clear_quote_number()
    +    {
    +        $this->CI->session->unset_userdata('sales_quote_number');
    +    }
    +
    +    public function set_suspended_id($suspended_id)
    +    {
    +        $this->CI->session->set_userdata('suspended_id', $suspended_id);
    +    }
    +
    +    public function get_suspended_id()
    +    {
    +        return $this->CI->session->userdata('suspended_id');
    +    }
    +
    +    public function is_invoice_mode()
    +    {
    +        return ($this->CI->session->userdata('sales_invoice_number_enabled') == 'true' ||
    +                $this->CI->session->userdata('sales_mode') == 'sale_invoice' ||
    +                ($this->CI->session->userdata('sales_invoice_number_enabled') == '1') &&
    +                    $this->CI->config->item('invoice_enable') == TRUE);
    +    }
    +
    +    public function is_sale_by_receipt_mode()
    +    {
    +        return ($this->CI->session->userdata('sales_mode') == 'sale');
    +    }
    +
    +    public function is_quote_mode()
    +    {
    +        return ($this->CI->session->userdata('sales_mode') == 'sale_quote');
    +    }
    +
    +    public function set_invoice_number_enabled($invoice_number_enabled)
    +    {
    +        return $this->CI->session->set_userdata('sales_invoice_number_enabled', $invoice_number_enabled);
    +    }
    +
    +    public function is_print_after_sale()
    +    {
    +        return ($this->CI->session->userdata('sales_print_after_sale') == 'true' ||
    +                $this->CI->session->userdata('sales_print_after_sale') == '1');
    +    }
    +
    +    public function set_print_after_sale($print_after_sale)
    +    {
    +        return $this->CI->session->set_userdata('sales_print_after_sale', $print_after_sale);
    +    }
    +
    +    public function get_email_receipt()
    +    {
    +        return $this->CI->session->userdata('sales_email_receipt');
    +    }
    +
    +    public function set_email_receipt($email_receipt)
    +    {
    +        $this->CI->session->set_userdata('sales_email_receipt', $email_receipt);
    +    }
    +
    +    public function clear_email_receipt()
    +    {
    +        $this->CI->session->unset_userdata('sales_email_receipt');
    +    }
    +
    +    // Multiple Payments
    +    public function get_payments()
    +    {
    +        if(!$this->CI->session->userdata('sales_payments'))
    +        {
    +            $this->set_payments(array());
    +        }
     
    -    // Multiple Payments
    -    public function add_payment($payment_id, $payment_amount)
    -    {
    -        $payments = $this->get_payments();
    -        if(isset($payments[$payment_id]))
    -        {
    -            //payment_method already exists, add to payment_amount
    -            $payments[$payment_id]['payment_amount'] = bcadd($payments[$payment_id]['payment_amount'], $payment_amount);
    -        }
    -        else
    -        {
    -            //add to existing array
    -            $payment = array($payment_id => array('payment_type' => $payment_id, 'payment_amount' => $payment_amount));
    -            
    -            $payments += $payment;
    -        }
    -
    -        $this->set_payments($payments);
    -    }
    -
    -    // Multiple Payments
    -    public function edit_payment($payment_id, $payment_amount)
    -    {
    -        $payments = $this->get_payments();
    -        if(isset($payments[$payment_id]))
    -        {
    -            $payments[$payment_id]['payment_type'] = $payment_id;
    -            $payments[$payment_id]['payment_amount'] = $payment_amount;
    -            $this->set_payments($payments);
    -
    -            return TRUE;
    -        }
    -
    -        return FALSE;
    -    }
    -
    -    // Multiple Payments
    -    public function delete_payment($payment_id)
    -    {
    -        $payments = $this->get_payments();
    -        unset($payments[urldecode($payment_id)]);
    -        $this->set_payments($payments);
    -    }
    -
    -    // Multiple Payments
    -    public function empty_payments()
    -    {
    -        $this->CI->session->unset_userdata('sales_payments');
    -    }
    -
    -    // Multiple Payments
    -    public function get_payments_total()
    -    {
    -        $subtotal = 0;
    -        $this->reset_cash_flags();
    -        foreach($this->get_payments() as $payments)
    -        {
    -            $subtotal = bcadd($payments['payment_amount'], $subtotal);
    -            if($this->CI->session->userdata('cash_rounding') && $this->CI->lang->line('sales_cash') != $payments['payment_type'])
    -            {
    -                $this->CI->session->set_userdata('cash_rounding', 0);
    -            }
    -        }
    -
    -        return $subtotal;
    -    }
    -
    -    public function get_cash_rounding()
    -    {
    -
    -    }
    -
    -    /*
    -     * Returns 'subtotal', 'total', 'cash_total', 'payment_total', 'amount_due', 'cash_amount_due', 'paid_in_full'
    -     * 'subtotal', 'discounted_subtotal', 'tax_exclusive_subtotal'
    -     */
    -    public function get_totals()
    +        return $this->CI->session->userdata('sales_payments');
    +    }
    +
    +    // Multiple Payments
    +    public function set_payments($payments_data)
    +    {
    +        $this->CI->session->set_userdata('sales_payments', $payments_data);
    +    }
    +
    +    // Multiple Payments
    +    public function add_payment($payment_id, $payment_amount)
    +    {
    +        $payments = $this->get_payments();
    +        if(isset($payments[$payment_id]))
    +        {
    +            //payment_method already exists, add to payment_amount
    +            $payments[$payment_id]['payment_amount'] = bcadd($payments[$payment_id]['payment_amount'], $payment_amount);
    +        }
    +        else
    +        {
    +            //add to existing array
    +            $payment = array($payment_id => array('payment_type' => $payment_id, 'payment_amount' => $payment_amount));
    +
    +            $payments += $payment;
    +        }
    +
    +        $this->set_payments($payments);
    +    }
    +
    +    // Multiple Payments
    +    public function edit_payment($payment_id, $payment_amount)
    +    {
    +        $payments = $this->get_payments();
    +        if(isset($payments[$payment_id]))
    +        {
    +            $payments[$payment_id]['payment_type'] = $payment_id;
    +            $payments[$payment_id]['payment_amount'] = $payment_amount;
    +            $this->set_payments($payments);
    +
    +            return TRUE;
    +        }
    +
    +        return FALSE;
    +    }
    +
    +    // Multiple Payments
    +    public function delete_payment($payment_id)
    +    {
    +        $payments = $this->get_payments();
    +        unset($payments[urldecode($payment_id)]);
    +        $this->set_payments($payments);
    +    }
    +
    +    // Multiple Payments
    +    public function empty_payments()
    +    {
    +        $this->CI->session->unset_userdata('sales_payments');
    +    }
    +
    +    // Multiple Payments
    +    public function get_payments_total()
    +    {
    +        $subtotal = 0;
    +        $this->reset_cash_flags();
    +        foreach($this->get_payments() as $payments)
    +        {
    +            $subtotal = bcadd($payments['payment_amount'], $subtotal);
    +            if($this->CI->session->userdata('cash_rounding') && $this->CI->lang->line('sales_cash') != $payments['payment_type'])
    +            {
    +                $this->CI->session->set_userdata('cash_rounding', 0);
    +            }
    +        }
    +
    +        return $subtotal;
    +    }
    +
    +    public function get_cash_rounding()
         {
    -        $cash_rounding = $this->CI->session->userdata('cash_rounding');
    -
    -        $totals = array();
    -
    -        $subtotal = 0;
    -        $discounted_subtotal = 0;
    -        $tax_exclusive_subtotal = 0;
    -        foreach($this->get_cart() as $item)
    -        {
    -            $subtotal = bcadd($subtotal, $this->get_item_total($item['quantity'], $item['price'], $item['discount'], FALSE));
    -            $discounted_subtotal = bcadd($discounted_subtotal, $this->get_item_total($item['quantity'], $item['price'], $item['discount'], TRUE));
    -            if($this->CI->config->config['tax_included'])
    -            {
    -                $tax_exclusive_subtotal = bcadd($tax_exclusive_subtotal, $this->get_item_total_tax_exclusive($item['item_id'], $item['quantity'], $item['price'], $item['discount'], TRUE));
    -            }
    -        }
    -
    -        $totals['subtotal'] = $subtotal;
    -        $totals['discounted_subtotal'] = $discounted_subtotal;
    -        $totals['tax_exclusive_subtotal'] = $tax_exclusive_subtotal;
    -
    -        $total = $discounted_subtotal;
    -        if ($this->CI->config->config['tax_included'])
    -        {
    -            $totals['total'] = $total;
    -        }
    -        else
    -        {
    -            foreach($this->get_taxes() as $sales_tax)
    +
    +    }
    +
    +    /*
    +     * Returns 'subtotal', 'total', 'cash_total', 'payment_total', 'amount_due', 'cash_amount_due', 'paid_in_full'
    +     * 'subtotal', 'discounted_subtotal', 'tax_exclusive_subtotal'
    +     */
    +    public function get_totals()
    +    {
    +        $cash_rounding = $this->CI->session->userdata('cash_rounding');
    +
    +        $totals = array();
    +
    +        $prediscount_subtotal = 0;
    +        $subtotal = 0;
    +        $total = 0;
    +        $total_discount = 0;
    +
    +        foreach($this->get_cart() as $item)
    +        {
    +            $discount_amount = $this->get_item_discount($item['quantity'], $item['price'], $item['discount']);
    +            $total_discount = bcadd($total_discount, $discount_amount);
    +
    +            $extended_amount = $this->get_extended_amount($item['quantity'], $item['price']);
    +            $extended_discounted_amount = $this->get_extended_amount($item['quantity'], $item['price'], $discount_amount);
    +            $prediscount_subtotal= bcadd($prediscount_subtotal, $extended_amount);
    +            $total = bcadd($total, $extended_discounted_amount);
    +
    +            if($this->CI->config->item('tax_included'))
                 {
    -                $total = bcadd($total, $sales_tax['sale_tax_amount']);
    +                $subtotal = bcadd($subtotal, $this->get_extended_total_tax_exclusive($item['item_id'], $extended_discounted_amount, $item['quantity'], $item['price'], $item['discount']));
                 }
    -            $totals['total'] = $total;
    -        }
    -
    -        if($cash_rounding)
    -        {
    -            $cash_total = $this->check_for_cash_rounding($total);
    -            $totals['cash_total'] = $cash_total;
    -        }
    -        else
    -        {
    -            $cash_total = $total;
    -        }
    -
    -        $totals['cash_total'] = $cash_total;
    -
    -        $payment_total = $this->get_payments_total();
    -        $totals['payment_total'] = $payment_total;
    -
    -        $amount_due = bcsub($total, $payment_total);
    -        $totals['amount_due'] = $amount_due;
    -
    -        $cash_amount_due = bcsub($cash_total, $payment_total);
    -        $totals['cash_amount_due'] = $cash_amount_due;
    -
    -        if($cash_rounding)
    -        {
    -            $current_due = $cash_amount_due;
    +            else
    +            {
    +                $subtotal =bcadd($subtotal, $extended_discounted_amount);
    +            }
    +        }
    +
    +        $totals['prediscount_subtotal'] = $prediscount_subtotal;
    +        $totals['total_discount'] = $total_discount;
    +        $totals['subtotal'] = $subtotal;
    +
    +        if ($this->CI->config->item('tax_included'))
    +        {
    +            $totals['total'] = $total;
    +        }
    +        else
    +        {
    +            foreach($this->get_taxes() as $sales_tax)
    +            {
    +                $total = bcadd($total, $sales_tax['sale_tax_amount']);
    +            }
    +            $totals['total'] = $total;
    +        }
    +
    +        if($cash_rounding)
    +        {
    +            $cash_total = $this->check_for_cash_rounding($total);
    +            $totals['cash_total'] = $cash_total;
             }
             else
             {
    -            $current_due = $amount_due;
    -        }
    +            $cash_total = $total;
    +            $totals['cash_total'] = $cash_total;
     
    -        if($this->get_mode() == 'return')
    -        {
    -            $totals['payments_cover_total'] = $current_due >= 0;
    -        }
    -        else
    -        {
    -            $totals['payments_cover_total'] =  $current_due <= 0;
    -        }
    -
    -        return $totals;
    -    }
    -
    -
    -    // Multiple Payments
    -    public function get_amount_due()
    -    {
    -        // Payment totals need to be identified first so that we know whether or not there is a non-cash payment involved
    -        $payment_total = $this->get_payments_total();
    -        $sales_total = $this->get_total();
    -        $amount_due = bcsub($sales_total, $payment_total);
    -        $precision = $this->CI->config->item('currency_decimals');
    -        $rounded_due = bccomp(round($amount_due, $precision, PHP_ROUND_HALF_EVEN), 0, $precision);
    -        // take care of rounding error introduced by round tripping payment amount to the browser
    -        return $rounded_due == 0 ? 0 : $amount_due;
    -    }
    -
    -    public function is_payment_covering_total()
    -    {
    +        }
    +
    +        $payment_total = $this->get_payments_total();
    +        $totals['payment_total'] = $payment_total;
    +
    +        $amount_due = bcsub($total, $payment_total);
    +        $totals['amount_due'] = $amount_due;
    +
    +        $cash_amount_due = bcsub($cash_total, $payment_total);
    +        $totals['cash_amount_due'] = $cash_amount_due;
    +
    +        if($cash_rounding)
    +        {
    +            $current_due = $cash_amount_due;
    +        }
    +        else
    +        {
    +            $current_due = $amount_due;
    +        }
    +
    +        if($this->get_mode() == 'return')
    +        {
    +            $totals['payments_cover_total'] = $current_due >= 0;
    +        }
    +        else
    +        {
    +            $totals['payments_cover_total'] =  $current_due <= 0;
    +        }
     
    -        if($this->get_mode() == 'return')
    -        {
    -            return $this->get_amount_due() >= 0;
    -        }
    -        else
    -        {
    -            return $this->get_amount_due() <= 0;
    -        }
    -    }
    -
    -    public function get_customer()
    -    {
    -        if(!$this->CI->session->userdata('sales_customer'))
    -        {
    -            $this->set_customer(-1);
    -        }
    +        return $totals;
    +    }
    +
    +
    +    // Multiple Payments
    +    public function get_amount_due()
    +    {
    +        // Payment totals need to be identified first so that we know whether or not there is a non-cash payment involved
    +        $payment_total = $this->get_payments_total();
    +        $sales_total = $this->get_total();
    +        $amount_due = bcsub($sales_total, $payment_total);
    +        $precision = $this->CI->config->item('currency_decimals');
    +        $rounded_due = bccomp(round($amount_due, $precision, PHP_ROUND_HALF_EVEN), 0, $precision);
    +        // take care of rounding error introduced by round tripping payment amount to the browser
    +        return $rounded_due == 0 ? 0 : $amount_due;
    +    }
     
    -        return $this->CI->session->userdata('sales_customer');
    -    }
    +    public function is_payment_covering_total()
    +    {
     
    -    public function set_customer($customer_id)
    -    {
    -        $this->CI->session->set_userdata('sales_customer', $customer_id);
    -    }
    -
    -    public function remove_customer()
    -    {
    -        $this->CI->session->unset_userdata('sales_customer');
    +        if($this->get_mode() == 'return')
    +        {
    +            return $this->get_amount_due() >= 0;
    +        }
    +        else
    +        {
    +            return $this->get_amount_due() <= 0;
    +        }
         }
    -    
    -    public function get_employee()
    +
    +    public function get_customer()
         {
    -        if(!$this->CI->session->userdata('sales_employee'))
    +        if(!$this->CI->session->userdata('sales_customer'))
             {
    -            $this->set_employee(-1);
    +            $this->set_customer(-1);
             }
     
    -        return $this->CI->session->userdata('sales_employee');
    +        return $this->CI->session->userdata('sales_customer');
         }
     
    -    public function set_employee($employee_id)
    +    public function set_customer($customer_id)
         {
    -        $this->CI->session->set_userdata('sales_employee', $employee_id);
    +        $this->CI->session->set_userdata('sales_customer', $customer_id);
         }
     
    -    public function remove_employee()
    +    public function remove_customer()
         {
    -        $this->CI->session->unset_userdata('sales_employee');
    +        $this->CI->session->unset_userdata('sales_customer');
         }
     
    -    public function get_mode()
    +    public function get_employee()
         {
    -        if(!$this->CI->session->userdata('sales_mode'))
    +        if(!$this->CI->session->userdata('sales_employee'))
             {
    -            if($this->CI->config->config['invoice_enable'] == '1')
    -            {
    -                $this->set_mode($this->CI->config->config['default_register_mode']);
    -            }
    -            else{
    -                $this->set_mode('sale');
    -            }
    -        }
    -
    -        return $this->CI->session->userdata('sales_mode');
    -    }
    -
    -    public function set_mode($mode)
    -    {
    -        $this->CI->session->set_userdata('sales_mode', $mode);
    -    }
    -
    -    public function clear_mode()
    -    {
    -        $this->CI->session->unset_userdata('sales_mode');
    -    }
    -
    -    public function get_dinner_table()
    -    {
    -        if(!$this->CI->session->userdata('dinner_table'))
    -        {
    -            if($this->CI->config->item('dinner_table_enable') == TRUE)
    -            {
    -                $this->set_dinner_table(1);
    -            }
    -        }
    +            $this->set_employee(-1);
    +        }
    +
    +        return $this->CI->session->userdata('sales_employee');
    +    }
    +
    +    public function set_employee($employee_id)
    +    {
    +        $this->CI->session->set_userdata('sales_employee', $employee_id);
    +    }
    +
    +    public function remove_employee()
    +    {
    +        $this->CI->session->unset_userdata('sales_employee');
    +    }
    +
    +    public function get_mode()
    +    {
    +        if(!$this->CI->session->userdata('sales_mode'))
    +        {
    +            if($this->CI->config->item('invoice_enable') == '1')
    +            {
    +                $this->set_mode($this->CI->config->item('default_register_mode'));
    +            }
    +            else{
    +                $this->set_mode('sale');
    +            }
    +        }
    +
    +        return $this->CI->session->userdata('sales_mode');
    +    }
     
    -        return $this->CI->session->userdata('dinner_table');
    -    }
    -
    -    public function set_dinner_table($dinner_table)
    -    {
    -        $this->CI->session->set_userdata('dinner_table', $dinner_table);
    -    }
    -
    -    public function clear_table()
    -    {
    -        $this->CI->session->unset_userdata('dinner_table');
    -    }
    -
    -    public function get_sale_location()
    -    {
    -        if(!$this->CI->session->userdata('sales_location'))
    -        {
    -            $this->set_sale_location($this->CI->Stock_location->get_default_location_id());
    +    public function set_mode($mode)
    +    {
    +        $this->CI->session->set_userdata('sales_mode', $mode);
    +    }
    +
    +    public function clear_mode()
    +    {
    +        $this->CI->session->unset_userdata('sales_mode');
    +    }
    +
    +    public function get_dinner_table()
    +    {
    +        if(!$this->CI->session->userdata('dinner_table'))
    +        {
    +            if($this->CI->config->item('dinner_table_enable') == TRUE)
    +            {
    +                $this->set_dinner_table(1);
    +            }
             }
     
    -        return $this->CI->session->userdata('sales_location');
    +        return $this->CI->session->userdata('dinner_table');
         }
     
    -    public function set_sale_location($location)
    +    public function set_dinner_table($dinner_table)
         {
    -        $this->CI->session->set_userdata('sales_location', $location);
    +        $this->CI->session->set_userdata('dinner_table', $dinner_table);
         }
     
    -    public function set_payment_type($payment_type)
    +    public function clear_table()
         {
    -        $this->CI->session->set_userdata('payment_type', $payment_type);
    +        $this->CI->session->unset_userdata('dinner_table');
         }
     
    -    public function get_payment_type()
    +    public function get_sale_location()
         {
    -        return $this->CI->session->userdata('payment_type');
    -    }
    -
    -    public function clear_sale_location()
    -    {
    -        $this->CI->session->unset_userdata('sales_location');
    +        if(!$this->CI->session->userdata('sales_location'))
    +        {
    +            $this->set_sale_location($this->CI->Stock_location->get_default_location_id());
    +        }
    +
    +        return $this->CI->session->userdata('sales_location');
         }
     
    -    public function set_giftcard_remainder($value)
    +    public function set_sale_location($location)
         {
    -        $this->CI->session->set_userdata('sales_giftcard_remainder', $value);
    +        $this->CI->session->set_userdata('sales_location', $location);
         }
     
    -    public function get_giftcard_remainder()
    +    public function set_payment_type($payment_type)
         {
    -        return $this->CI->session->userdata('sales_giftcard_remainder');
    +        $this->CI->session->set_userdata('payment_type', $payment_type);
         }
     
    -    public function clear_giftcard_remainder()
    +    public function get_payment_type()
         {
    -        $this->CI->session->unset_userdata('sales_giftcard_remainder');
    +        return $this->CI->session->userdata('payment_type');
         }
     
    -    public function set_rewards_remainder($value)
    +    public function clear_sale_location()
         {
    -        $this->CI->session->set_userdata('sales_rewards_remainder', $value);
    +        $this->CI->session->unset_userdata('sales_location');
         }
     
    -    public function get_rewards_remainder()
    +    public function set_giftcard_remainder($value)
         {
    -        return $this->CI->session->userdata('sales_rewards_remainder');
    +        $this->CI->session->set_userdata('sales_giftcard_remainder', $value);
         }
     
    -    public function clear_rewards_remainder()
    +    public function get_giftcard_remainder()
         {
    -        $this->CI->session->unset_userdata('sales_rewards_remainder');
    +        return $this->CI->session->userdata('sales_giftcard_remainder');
         }
     
    -    public function add_item(&$item_id, $quantity = 1, $item_location, $discount = 0, $price = NULL, $description = NULL, $serialnumber = NULL, $include_deleted = FALSE, $print_option = '0', $stock_type = '0')
    +    public function clear_giftcard_remainder()
         {
    -        $item_info = $this->CI->Item->get_info_by_id_or_number($item_id);
    -
    -        //make sure item exists     
    -        if(empty($item_info))
    -        {
    -            $item_id = -1;
    -            return FALSE;
    -        }
    -
    -        $item_id = $item_info->item_id;
    -
    -        // Serialization and Description
    +        $this->CI->session->unset_userdata('sales_giftcard_remainder');
    +    }
    +
    +    public function set_rewards_remainder($value)
    +    {
    +        $this->CI->session->set_userdata('sales_rewards_remainder', $value);
    +    }
    +
    +    public function get_rewards_remainder()
    +    {
    +        return $this->CI->session->userdata('sales_rewards_remainder');
    +    }
     
    -        //Get all items in the cart so far...
    -        $items = $this->get_cart();
    -
    -        //We need to loop through all items in the cart.
    -        //If the item is already there, get it's key($updatekey).
    -        //We also need to get the next key that we are going to use in case we need to add the
    -        //item to the cart. Since items can be deleted, we can't use a count. we use the highest key + 1.
    -
    -        $maxkey = 0;                       //Highest key so far
    -        $itemalreadyinsale = FALSE;        //We did not find the item yet.
    -        $insertkey = 0;                    //Key to use for new entry.
    -        $updatekey = 0;                    //Key to use to update(quantity)
    -
    -        foreach($items as $item)
    -        {
    -            //We primed the loop so maxkey is 0 the first time.
    -            //Also, we have stored the key in the element itself so we can compare.
    +    public function clear_rewards_remainder()
    +    {
    +        $this->CI->session->unset_userdata('sales_rewards_remainder');
    +    }
    +
    +    public function add_item(&$item_id, $quantity = 1, $item_location, $discount = 0, $price = NULL, $description = NULL, $serialnumber = NULL, $include_deleted = FALSE, $print_option = '0', $stock_type = '0')
    +    {
    +        $item_info = $this->CI->Item->get_info_by_id_or_number($item_id);
    +
    +        //make sure item exists
    +        if(empty($item_info))
    +        {
    +            $item_id = -1;
    +            return FALSE;
    +        }
    +
    +        $item_id = $item_info->item_id;
     
    -            if($maxkey <= $item['line'])
    -            {
    -                $maxkey = $item['line'];
    -            }
    +        // Serialization and Description
    +
    +        //Get all items in the cart so far...
    +        $items = $this->get_cart();
     
    -            if($item['item_id'] == $item_id && $item['item_location'] == $item_location)
    -            {
    -                $itemalreadyinsale = TRUE;
    -                $updatekey = $item['line'];
    -                if(!$item_info->is_serialized)
    -                {
    -                    $quantity = bcadd($quantity, $items[$updatekey]['quantity']);
    -                }
    -            }
    -        }
    -
    -        $insertkey = $maxkey + 1;
    -        //array/cart records are identified by $insertkey and item_id is just another field.
    -
    -        if(is_null($price))
    -        {
    -            $price = $item_info->unit_price;
    -        }
    -        elseif($price == 0)
    -        {
    -            $price = 0.00;
    -            $discount = 0.00;
    -        }
    -
    -        // For print purposes this simpifies line selection
    -        // 0 will print, 2 will not print.   The decision about 1 is made here
    -        if($print_option =='1')
    -        {
    -            if($price == 0)
    -            {
    -                $print_option = '2';
    -            }
    -            else
    -            {
    -                $print_option = '0';
    -            }
    -        }
    -
    -        $total = $this->get_item_total($quantity, $price, $discount);
    -        $discounted_total = $this->get_item_total($quantity, $price, $discount, TRUE);
    -        //Item already exists and is not serialized, add to quantity
    -        if(!$itemalreadyinsale || $item_info->is_serialized)
    -        {
    -            $item = array($insertkey => array(
    -                    'item_id' => $item_id,
    -                    'item_location' => $item_location,
    -                    'stock_name' => $this->CI->Stock_location->get_location_name($item_location),
    -                    'line' => $insertkey,
    -                    'name' => $item_info->name,
    -                    'item_number' => $item_info->item_number,
    -                    'description' => $description != NULL ? $description : $item_info->description,
    -                    'serialnumber' => $serialnumber != NULL ? $serialnumber : '',
    -                    'allow_alt_description' => $item_info->allow_alt_description,
    -                    'is_serialized' => $item_info->is_serialized,
    -                    'quantity' => $quantity,
    -                    'discount' => $discount,
    -                    'in_stock' => $this->CI->Item_quantity->get_item_quantity($item_id, $item_location)->quantity,
    -                    'price' => $price,
    -                    'total' => $total,
    -                    'discounted_total' => $discounted_total,
    -                    'print_option' => $print_option,
    -                    'stock_type' => $stock_type,
    -                    'tax_category_id' => $item_info->tax_category_id
    -                )
    -            );
    -            //add to existing array
    -            $items += $item;
    -        }
    -        else
    -        {
    -            $line = &$items[$updatekey];
    -            $line['quantity'] = $quantity;
    -            $line['total'] = $total;
    -            $line['discounted_total'] = $discounted_total;
    -        }
    -
    -        $this->set_cart($items);
    -
    -        return TRUE;
    -    }
    -    
    -    public function out_of_stock($item_id, $item_location)
    -    {
    -        //make sure item exists     
    -        if($item_id != -1)
    -        {
    -            $item_info = $this->CI->Item->get_info_by_id_or_number($item_id);
    -
    -            if($item_info->stock_type == '0')
    -            {
    -                $item_quantity = $this->CI->Item_quantity->get_item_quantity($item_id, $item_location)->quantity;
    -                $quantity_added = $this->get_quantity_already_added($item_id, $item_location);
    -
    -                if($item_quantity - $quantity_added < 0)
    -                {
    -                    return $this->CI->lang->line('sales_quantity_less_than_zero');
    -                }
    -                elseif($item_quantity - $quantity_added < $item_info->reorder_level)
    -                {
    -                    return $this->CI->lang->line('sales_quantity_less_than_reorder_level');
    -                }
    -            }
    -        }
    -
    -        return '';
    -    }
    -    
    -    public function get_quantity_already_added($item_id, $item_location)
    -    {
    -        $items = $this->get_cart();
    -        $quanity_already_added = 0;
    -        foreach($items as $item)
    -        {
    -            if($item['item_id'] == $item_id && $item['item_location'] == $item_location)
    -            {
    -                $quanity_already_added+=$item['quantity'];
    -            }
    -        }
    -        
    -        return $quanity_already_added;
    -    }
    -    
    -    public function get_item_id($line_to_get)
    -    {
    -        $items = $this->get_cart();
    -
    -        foreach($items as $line=>$item)
    -        {
    -            if($line == $line_to_get)
    -            {
    -                return $item['item_id'];
    -            }
    -        }
    -        
    -        return -1;
    -    }
    -
    -    public function edit_item($line, $description, $serialnumber, $quantity, $discount, $price)
    -    {
    -        $items = $this->get_cart();
    -        if(isset($items[$line]))    
    -        {
    -            $line = &$items[$line];
    -            $line['description'] = $description;
    -            $line['serialnumber'] = $serialnumber;
    -            $line['quantity'] = $quantity;
    -            $line['discount'] = $discount;
    -            $line['price'] = $price;
    -            $line['total'] = $this->get_item_total($quantity, $price, $discount);
    -            $line['discounted_total'] = $this->get_item_total($quantity, $price, $discount, TRUE);
    -            $this->set_cart($items);
    -        }
    -
    -        return FALSE;
    -    }
    -
    -    public function delete_item($line)
    -    {
    -        $items = $this->get_cart();
    -        unset($items[$line]);
    -        $this->set_cart($items);
    -    }
    -
    -    public function return_entire_sale($receipt_sale_id)
    -    {
    -        //POS #
    -        $pieces = explode(' ', $receipt_sale_id);
    -        $sale_id = $pieces[1];
    -
    -        $this->empty_cart();
    -        $this->remove_customer();
    -
    -        foreach($this->CI->Sale->get_sale_items_ordered($sale_id)->result() as $row)
    -        {
    -            $this->add_item($row->item_id, -$row->quantity_purchased, $row->item_location, $row->discount_percent, $row->item_unit_price, $row->description, $row->serialnumber, TRUE, $row->print_option, $row->print_option);
    -        }
    -
    -        $this->set_customer($this->CI->Sale->get_customer($sale_id)->person_id);
    -    }
    -    
    -    public function add_item_kit($external_item_kit_id, $item_location, $discount, $price_option, $kit_print_option, &$stock_warning)
    -    {
    -        //KIT #
    -        $pieces = explode(' ', $external_item_kit_id);
    -        $item_kit_id = $pieces[1];
    -        $result = TRUE;
    -
    -        foreach($this->CI->Item_kit_items->get_info($item_kit_id) as $item_kit_item)
    -        {
    -            if($price_option == '0') // all
    -            {
    -                $price = null;
    -            }
    -            elseif($price_option == '1') // item kit only
    -            {
    -                $price = 0;
    -            }
    -            elseif($price_option == '2') // item kit plus stock items (assuming materials)
    -            {
    -                if($item_kit_item['stock_type'] == 0) // stock item
    -                {
    -                    $price = null;
    -                }
    -                else
    -                {
    -                    $price = 0;
    -                }
    -            }
    -
    -            if($kit_print_option == '0') // all
    +        //We need to loop through all items in the cart.
    +        //If the item is already there, get it's key($updatekey).
    +        //We also need to get the next key that we are going to use in case we need to add the
    +        //item to the cart. Since items can be deleted, we can't use a count. we use the highest key + 1.
    +
    +        $maxkey = 0;                       //Highest key so far
    +        $itemalreadyinsale = FALSE;        //We did not find the item yet.
    +        $insertkey = 0;                    //Key to use for new entry.
    +        $updatekey = 0;                    //Key to use to update(quantity)
    +
    +        foreach($items as $item)
    +        {
    +            //We primed the loop so maxkey is 0 the first time.
    +            //Also, we have stored the key in the element itself so we can compare.
    +
    +            if($maxkey <= $item['line'])
    +            {
    +                $maxkey = $item['line'];
    +            }
    +
    +            if($item['item_id'] == $item_id && $item['item_location'] == $item_location)
    +            {
    +                $itemalreadyinsale = TRUE;
    +                $updatekey = $item['line'];
    +                if(!$item_info->is_serialized)
    +                {
    +                    $quantity = bcadd($quantity, $items[$updatekey]['quantity']);
    +                }
    +            }
    +        }
    +
    +        $insertkey = $maxkey + 1;
    +        //array/cart records are identified by $insertkey and item_id is just another field.
    +
    +        if(is_null($price))
    +        {
    +            $price = $item_info->unit_price;
    +        }
    +        elseif($price == 0)
    +        {
    +            $price = 0.00;
    +            $discount = 0.00;
    +        }
    +
    +        // For print purposes this simpifies line selection
    +        // 0 will print, 2 will not print.   The decision about 1 is made here
    +        if($print_option =='1')
    +        {
    +            if($price == 0)
    +            {
    +                $print_option = '2';
    +            }
    +            else
    +            {
    +                $print_option = '0';
    +            }
    +        }
    +
    +        $total = $this->get_item_total($quantity, $price, $discount);
    +        $discounted_total = $this->get_item_total($quantity, $price, $discount, TRUE);
    +        //Item already exists and is not serialized, add to quantity
    +        if(!$itemalreadyinsale || $item_info->is_serialized)
    +        {
    +            $item = array($insertkey => array(
    +                    'item_id' => $item_id,
    +                    'item_location' => $item_location,
    +                    'stock_name' => $this->CI->Stock_location->get_location_name($item_location),
    +                    'line' => $insertkey,
    +                    'name' => $item_info->name,
    +                    'item_number' => $item_info->item_number,
    +                    'description' => $description != NULL ? $description : $item_info->description,
    +                    'serialnumber' => $serialnumber != NULL ? $serialnumber : '',
    +                    'allow_alt_description' => $item_info->allow_alt_description,
    +                    'is_serialized' => $item_info->is_serialized,
    +                    'quantity' => $quantity,
    +                    'discount' => $discount,
    +                    'in_stock' => $this->CI->Item_quantity->get_item_quantity($item_id, $item_location)->quantity,
    +                    'price' => $price,
    +                    'total' => $total,
    +                    'discounted_total' => $discounted_total,
    +                    'print_option' => $print_option,
    +                    'stock_type' => $stock_type,
    +                    'tax_category_id' => $item_info->tax_category_id
    +                )
    +            );
    +            //add to existing array
    +            $items += $item;
    +        }
    +        else
    +        {
    +            $line = &$items[$updatekey];
    +            $line['quantity'] = $quantity;
    +            $line['total'] = $total;
    +            $line['discounted_total'] = $discounted_total;
    +        }
    +
    +        $this->set_cart($items);
    +
    +        return TRUE;
    +    }
    +
    +    public function out_of_stock($item_id, $item_location)
    +    {
    +        //make sure item exists
    +        if($item_id != -1)
    +        {
    +            $item_info = $this->CI->Item->get_info_by_id_or_number($item_id);
    +
    +            if($item_info->stock_type == '0')
    +            {
    +                $item_quantity = $this->CI->Item_quantity->get_item_quantity($item_id, $item_location)->quantity;
    +                $quantity_added = $this->get_quantity_already_added($item_id, $item_location);
    +
    +                if($item_quantity - $quantity_added < 0)
    +                {
    +                    return $this->CI->lang->line('sales_quantity_less_than_zero');
    +                }
    +                elseif($item_quantity - $quantity_added < $item_info->reorder_level)
    +                {
    +                    return $this->CI->lang->line('sales_quantity_less_than_reorder_level');
    +                }
    +            }
    +        }
    +
    +        return '';
    +    }
    +
    +    public function get_quantity_already_added($item_id, $item_location)
    +    {
    +        $items = $this->get_cart();
    +        $quanity_already_added = 0;
    +        foreach($items as $item)
    +        {
    +            if($item['item_id'] == $item_id && $item['item_location'] == $item_location)
    +            {
    +                $quanity_already_added+=$item['quantity'];
    +            }
    +        }
    +
    +        return $quanity_already_added;
    +    }
    +
    +    public function get_item_id($line_to_get)
    +    {
    +        $items = $this->get_cart();
    +
    +        foreach($items as $line=>$item)
    +        {
    +            if($line == $line_to_get)
    +            {
    +                return $item['item_id'];
    +            }
    +        }
    +
    +        return -1;
    +    }
    +
    +    public function edit_item($line, $description, $serialnumber, $quantity, $discount, $price)
    +    {
    +        $items = $this->get_cart();
    +        if(isset($items[$line]))
    +        {
    +            $line = &$items[$line];
    +            $line['description'] = $description;
    +            $line['serialnumber'] = $serialnumber;
    +            $line['quantity'] = $quantity;
    +            $line['discount'] = $discount;
    +            $line['price'] = $price;
    +            $line['total'] = $this->get_item_total($quantity, $price, $discount);
    +            $line['discounted_total'] = $this->get_item_total($quantity, $price, $discount, TRUE);
    +            $this->set_cart($items);
    +        }
    +
    +        return FALSE;
    +    }
    +
    +    public function delete_item($line)
    +    {
    +        $items = $this->get_cart();
    +        unset($items[$line]);
    +        $this->set_cart($items);
    +    }
    +
    +    public function return_entire_sale($receipt_sale_id)
    +    {
    +        //POS #
    +        $pieces = explode(' ', $receipt_sale_id);
    +        $sale_id = $pieces[1];
    +
    +        $this->empty_cart();
    +        $this->remove_customer();
    +
    +        foreach($this->CI->Sale->get_sale_items_ordered($sale_id)->result() as $row)
    +        {
    +            $this->add_item($row->item_id, -$row->quantity_purchased, $row->item_location, $row->discount_percent, $row->item_unit_price, $row->description, $row->serialnumber, TRUE, $row->print_option, $row->print_option);
    +        }
    +
    +        $this->set_customer($this->CI->Sale->get_customer($sale_id)->person_id);
    +    }
    +
    +    public function add_item_kit($external_item_kit_id, $item_location, $discount, $price_option, $kit_print_option, &$stock_warning)
    +    {
    +        //KIT #
    +        $pieces = explode(' ', $external_item_kit_id);
    +        $item_kit_id = $pieces[1];
    +        $result = TRUE;
    +
    +        foreach($this->CI->Item_kit_items->get_info($item_kit_id) as $item_kit_item)
    +        {
    +            if($price_option == '0') // all
                 {
    -                $print_option = '0'; // print always
    +                $price = null;
                 }
    -            elseif($kit_print_option == '1') // priced
    +            elseif($price_option == '1') // item kit only
                 {
    -                $print_option = '1'; // print if price not zero
    +                $price = 0;
                 }
    -            elseif($kit_print_option == '2') // kit only if price is not zero
    +            elseif($price_option == '2') // item kit plus stock items (assuming materials)
                 {
    -                $print_option = '2'; // Do not include in list
    -            }
    -
    -            $result &= $this->add_item($item_kit_item['item_id'], $item_kit_item['quantity'], $item_location, $discount, $price, null, null, null, $print_option, $item_kit_item['stock_type']);
    -
    -            if($stock_warning == null)
    -            {
    -                $stock_warning = $this->out_of_stock($item_kit_item['item_id'], $item_location);
    +                if($item_kit_item['stock_type'] == 0) // stock item
    +                {
    +                    $price = null;
    +                }
    +                else
    +                {
    +                    $price = 0;
    +                }
                 }
    -        }
    -        
    -        return $result;
    -    }
    -
    -    public function copy_entire_sale($sale_id)
    -    {
    -        $this->empty_cart();
    -        $this->remove_customer();
    -
    -        foreach($this->CI->Sale->get_sale_items_ordered($sale_id)->result() as $row)
    -        {
    -            $this->add_item($row->item_id, $row->quantity_purchased, $row->item_location, $row->discount_percent, $row->item_unit_price, $row->description, $row->serialnumber, TRUE, $row->print_option);
    -        }
    -
    -        foreach($this->CI->Sale->get_sale_payments($sale_id)->result() as $row)
    -        {
    -            $this->add_payment($row->payment_type, $row->payment_amount);
    -        }
    -
    -        $this->set_customer($this->CI->Sale->get_customer($sale_id)->person_id);
    -        $this->set_employee($this->CI->Sale->get_employee($sale_id)->person_id);
    -    }
    -
    -    public function get_cart_reordered($sale_id)
    -    {
    -        $this->empty_cart();
    -        foreach($this->CI->Sale->get_sale_items_ordered($sale_id)->result() as $row)
    -        {
    -            $this->add_item($row->item_id, $row->quantity_purchased, $row->item_location, $row->discount_percent, $row->item_unit_price,
    -                $row->description, $row->serialnumber, TRUE, $row->print_option, $row->stock_type);
    -        }
    -
    -        return $this->CI->session->userdata('sales_cart');
    -    }
    -    
    -    public function copy_entire_suspended_sale($sale_id)
    -    {
    -        $this->empty_cart();
    -        $this->remove_customer();
    -
    -        foreach($this->CI->Sale->get_sale_items($sale_id)->result() as $row)
    -        {
    -            $this->add_item($row->item_id, $row->quantity_purchased, $row->item_location, $row->discount_percent, $row->item_unit_price,
    -                $row->description, $row->serialnumber, TRUE, $row->print_option, $row->stock_type);
    -        }
    +
    +            if($kit_print_option == '0') // all
    +            {
    +                $print_option = '0'; // print always
    +            }
    +            elseif($kit_print_option == '1') // priced
    +            {
    +                $print_option = '1'; // print if price not zero
    +            }
    +            elseif($kit_print_option == '2') // kit only if price is not zero
    +            {
    +                $print_option = '2'; // Do not include in list
    +            }
    +
    +            $result &= $this->add_item($item_kit_item['item_id'], $item_kit_item['quantity'], $item_location, $discount, $price, null, null, null, $print_option, $item_kit_item['stock_type']);
    +
    +            if($stock_warning == null)
    +            {
    +                $stock_warning = $this->out_of_stock($item_kit_item['item_id'], $item_location);
    +            }
    +        }
    +
    +        return $result;
    +    }
    +
    +    public function copy_entire_sale($sale_id)
    +    {
    +        $this->empty_cart();
    +        $this->remove_customer();
    +
    +        foreach($this->CI->Sale->get_sale_items_ordered($sale_id)->result() as $row)
    +        {
    +            $this->add_item($row->item_id, $row->quantity_purchased, $row->item_location, $row->discount_percent, $row->item_unit_price, $row->description, $row->serialnumber, TRUE, $row->print_option);
    +        }
    +
    +        foreach($this->CI->Sale->get_sale_payments($sale_id)->result() as $row)
    +        {
    +            $this->add_payment($row->payment_type, $row->payment_amount);
    +        }
    +
    +        $this->set_customer($this->CI->Sale->get_customer($sale_id)->person_id);
    +        $this->set_employee($this->CI->Sale->get_employee($sale_id)->person_id);
    +        $this->set_quote_number($this->CI->Sale->get_quote_number($sale_id));
    +        $this->set_comment($this->CI->Sale->get_comment($sale_id));
    +        $this->set_dinner_table($this->CI->Sale->get_dinner_table($sale_id));
    +    }
     
    -        foreach($this->CI->Sale->get_sale_payments($sale_id)->result() as $row)
    -        {
    -            $this->add_payment($row->payment_type, $row->payment_amount);
    -        }
    -
    -        $suspended_sale_info = $this->CI->Sale->get_info($sale_id)->row();
    -        $this->set_customer($suspended_sale_info->person_id);
    -        $this->set_comment($suspended_sale_info->comment);
    +    public function get_cart_reordered($sale_id)
    +    {
    +        $this->empty_cart();
    +        foreach($this->CI->Sale->get_sale_items_ordered($sale_id)->result() as $row)
    +        {
    +            $this->add_item($row->item_id, $row->quantity_purchased, $row->item_location, $row->discount_percent, $row->item_unit_price,
    +                $row->description, $row->serialnumber, TRUE, $row->print_option, $row->stock_type);
    +        }
     
    -        $this->set_invoice_number($suspended_sale_info->invoice_number);
    -        $this->set_quote_number($suspended_sale_info->quote_number);
    -        $this->set_dinner_table($suspended_sale_info->dinner_table_id);
    -    }
    -
    -    public function copy_entire_suspended_tables_sale($sale_id)
    -    {
    -        $this->empty_cart();
    -        $this->remove_customer();
    -
    -        foreach($this->CI->Sale_suspended->get_sale_items($sale_id)->result() as $row)
    -        {
    -            $this->add_item($row->item_id, $row->quantity_purchased, $row->item_location, $row->discount_percent, $row->item_unit_price,
    -                $row->description, $row->serialnumber, TRUE, $row->print_option, $row->stock_type);
    -        }
    -
    -        foreach($this->CI->Sale_suspended->get_sale_payments($sale_id)->result() as $row)
    -        {
    -            $this->add_payment($row->payment_type, $row->payment_amount);
    -        }
    -
    -        $suspended_sale_info = $this->CI->Sale_suspended->get_info($sale_id)->row();
    -        $this->set_customer($suspended_sale_info->person_id);
    -        $this->set_comment($suspended_sale_info->comment);
    -
    -        $this->set_invoice_number($suspended_sale_info->invoice_number);
    -        $this->set_quote_number($suspended_sale_info->quote_number);
    -        $this->set_dinner_table($suspended_sale_info->dinner_table_id);
    -    }
    -
    -    public function clear_all()
    -    {
    -        $this->set_invoice_number_enabled(FALSE);
    -        $this->clear_table();
    -        $this->empty_cart();
    -        $this->clear_comment();
    -        $this->clear_email_receipt();
    -        $this->clear_invoice_number();
    -        $this->clear_quote_number();
    -        $this->clear_giftcard_remainder();
    -        $this->empty_payments();
    -        $this->remove_customer();
    -        $this->clear_cash_flags();
    -    }
    -
    -    public function clear_cash_flags()
    -    {
    -        $this->CI->session->unset_userdata('cash_rounding');
    -        $this->CI->session->unset_userdata('cash_mode');
    -        $this->CI->session->unset_userdata('payment_type');
    +        return $this->CI->session->userdata('sales_cart');
    +    }
    +
    +    public function copy_entire_suspended_sale($sale_id)
    +    {
    +        $this->empty_cart();
    +        $this->remove_customer();
    +
    +        foreach($this->CI->Sale->get_sale_items($sale_id)->result() as $row)
    +        {
    +            $this->add_item($row->item_id, $row->quantity_purchased, $row->item_location, $row->discount_percent, $row->item_unit_price,
    +                $row->description, $row->serialnumber, TRUE, $row->print_option, $row->stock_type);
    +        }
    +
    +        foreach($this->CI->Sale->get_sale_payments($sale_id)->result() as $row)
    +        {
    +            $this->add_payment($row->payment_type, $row->payment_amount);
    +        }
    +
    +        $suspended_sale_info = $this->CI->Sale->get_info($sale_id)->row();
    +        $this->set_customer($suspended_sale_info->person_id);
    +        $this->set_comment($suspended_sale_info->comment);
    +        $this->set_invoice_number($suspended_sale_info->invoice_number);
    +        $this->set_quote_number($suspended_sale_info->quote_number);
    +        $this->set_dinner_table($suspended_sale_info->dinner_table_id);
    +    }
    +
    +    public function copy_entire_suspended_tables_sale($sale_id)
    +    {
    +        $this->empty_cart();
    +        $this->remove_customer();
    +
    +        foreach($this->CI->Sale_suspended->get_sale_items($sale_id)->result() as $row)
    +        {
    +            $this->add_item($row->item_id, $row->quantity_purchased, $row->item_location, $row->discount_percent, $row->item_unit_price,
    +                $row->description, $row->serialnumber, TRUE, $row->print_option, $row->stock_type);
    +        }
    +
    +        foreach($this->CI->Sale_suspended->get_sale_payments($sale_id)->result() as $row)
    +        {
    +            $this->add_payment($row->payment_type, $row->payment_amount);
    +        }
    +
    +        $suspended_sale_info = $this->CI->Sale_suspended->get_info($sale_id)->row();
    +        $this->set_customer($suspended_sale_info->person_id);
    +        $this->set_comment($suspended_sale_info->comment);
    +
    +        $this->set_invoice_number($suspended_sale_info->invoice_number);
    +        $this->set_quote_number($suspended_sale_info->quote_number);
    +        $this->set_dinner_table($suspended_sale_info->dinner_table_id);
         }
     
    -    public function reset_cash_flags()
    +    public function clear_all()
         {
    -        if($this->CI->lang->line('payment_options_order') != 'cashdebitcredit')
    -        {
    -            $cash_mode = 1;
    -        }
    -        else
    -        {
    -            $cash_mode = 0;
    -        }
    -        $this->CI->session->set_userdata('cash_mode', $cash_mode);
    -
    -        if($this->CI->config->config['cash_decimals'] < $this->CI->config->config['currency_decimals'])
    -        {
    -            $cash_rounding = 1;
    -        }
    -        else
    -        {
    -            $cash_rounding = 0;
    -        }
    -        $this->CI->session->set_userdata('cash_rounding', $cash_rounding);
    -    }
    -    
    -    public function is_customer_taxable()
    -    {
    -        $customer_id = $this->get_customer();
    -        $customer = $this->CI->Customer->get_info($customer_id);
    -        
    -        //Do not charge sales tax if we have a customer that is not taxable
    -        return $customer->taxable or $customer_id == -1;
    -    }
    -
    -    /*
    -     * This returns taxes for VAT taxes and for pre 3.1.0 sales taxes.
    -     */
    -    public function get_taxes()
    -    {
    -        $register_mode = $this->CI->config->config['default_register_mode'];
    -        $tax_decimals = $this->CI->config->config['tax_decimals'];
    -        $customer_id = $this->get_customer();
    -        $customer = $this->CI->Customer->get_info($customer_id);
    -        $sales_taxes = array();
    -        //Do not charge sales tax if we have a customer that is not taxable
    -        if($customer->taxable or $customer_id == -1)
    -        {
    -            foreach($this->get_cart() as $line => $item)
    -            {
    -                // Start of current VAT tax apply
    -
    -                $tax_info = $this->CI->Item_taxes->get_info($item['item_id']);
    -                $tax_group_sequence = 0;
    -                foreach($tax_info as $tax)
    -                {
    -                    // This computes tax for each line item and adds it to the tax type total
    -                    $tax_group = (float)$tax['percent'] . '% ' . $tax['name'];
    -                    $tax_type = Tax_lib::TAX_TYPE_VAT;
    -                    $tax_basis = $this->get_item_total($item['quantity'], $item['price'], $item['discount'], TRUE);
    -                    $tax_amount = 0;
    -
    -                    if($this->CI->config->config['tax_included'])
    -                    {
    -                        $tax_amount = $this->get_item_tax($item['quantity'], $item['price'], $item['discount'], $tax['percent']);
    -                    }
    -                    elseif($this->CI->config->config['customer_sales_tax_support'] == '0')
    -                    {
    -                        $tax_amount = $this->CI->tax_lib->get_sales_tax_for_amount($tax_basis, $tax['percent'], '0', $tax_decimals);
    -                    }
    -
    -                    if($tax_amount <> 0)
    -                    {
    -                        $this->CI->tax_lib->update_sales_taxes($sales_taxes, $tax_type, $tax_group, $tax['percent'], $tax_basis, $tax_amount, $tax_group_sequence, '0', -1);
    -                        $tax_group_sequence += 1;
    -                    }
    -                }
    -
    -                $tax_category = '';
    -                $tax_rate = '';
    -                $rounding_code = Rounding_code::HALF_UP;
    -                $tax_group_sequence = 0;
    -                $tax_code = '';
    -
    -                if($this->CI->config->config['customer_sales_tax_support'] == '1')
    -                {
    -                    // Now calculate what the sales taxes should be (storing them in the $sales_taxes array
    -                    $this->CI->tax_lib->apply_sales_tax($item, $customer->city, $customer->state, $customer->sales_tax_code, $register_mode, 0, $sales_taxes, $tax_category, $tax_rate, $rounding_code, $tax_group_sequence, $tax_code);
    -                }
    -
    -            }
    +        $this->set_invoice_number_enabled(FALSE);
    +        $this->clear_table();
    +        $this->empty_cart();
    +        $this->clear_comment();
    +        $this->clear_email_receipt();
    +        $this->clear_invoice_number();
    +        $this->clear_quote_number();
    +        $this->clear_giftcard_remainder();
    +        $this->empty_payments();
    +        $this->remove_customer();
    +        $this->clear_cash_flags();
    +    }
    +
    +    public function clear_cash_flags()
    +    {
    +        $this->CI->session->unset_userdata('cash_rounding');
    +        $this->CI->session->unset_userdata('cash_mode');
    +        $this->CI->session->unset_userdata('payment_type');
    +    }
    +
    +    public function reset_cash_flags()
    +    {
    +        if($this->CI->lang->line('payment_options_order') != 'cashdebitcredit')
    +        {
    +            $cash_mode = 1;
    +        }
    +        else
    +        {
    +            $cash_mode = 0;
    +        }
    +        $this->CI->session->set_userdata('cash_mode', $cash_mode);
    +
    +        if($this->CI->config->item('cash_decimals') < $this->CI->config->item('currency_decimals'))
    +        {
    +            $cash_rounding = 1;
    +        }
    +        else
    +        {
    +            $cash_rounding = 0;
    +        }
    +        $this->CI->session->set_userdata('cash_rounding', $cash_rounding);
    +    }
    +
    +    public function is_customer_taxable()
    +    {
    +        $customer_id = $this->get_customer();
    +        $customer = $this->CI->Customer->get_info($customer_id);
    +
    +        //Do not charge sales tax if we have a customer that is not taxable
    +        return $customer->taxable or $customer_id == -1;
    +    }
    +
    +    /*
    +     * This returns taxes for VAT taxes and for pre 3.1.0 sales taxes.
    +     */
    +    public function get_taxes()
    +    {
    +        $register_mode = $this->CI->config->item('default_register_mode');
    +        $tax_decimals = $this->CI->config->item('tax_decimals');
    +        $customer_id = $this->get_customer();
    +        $customer = $this->CI->Customer->get_info($customer_id);
    +        $sales_taxes = array();
    +        //Do not charge sales tax if we have a customer that is not taxable
    +        if($customer->taxable or $customer_id == -1)
    +        {
    +            foreach($this->get_cart() as $line => $item)
    +            {
    +                // Start of current VAT tax apply
    +                $tax_info = $this->CI->Item_taxes->get_info($item['item_id']);
    +                $tax_group_sequence = 0;
    +                foreach($tax_info as $tax)
    +                {
    +                    // This computes tax for each line item and adds it to the tax type total
    +                    $tax_group = (float)$tax['percent'] . '% ' . $tax['name'];
    +                    $tax_type = Tax_lib::TAX_TYPE_VAT;
    +                    $tax_basis = $this->get_item_total($item['quantity'], $item['price'], $item['discount'], TRUE);
    +                    $tax_amount = 0;
    +
    +                    if($this->CI->config->item('tax_included'))
    +                    {
    +                        $tax_amount = $this->get_item_tax($item['quantity'], $item['price'], $item['discount'], $tax['percent']);
    +                    }
    +                    elseif($this->CI->config->item('customer_sales_tax_support') == '0')
    +                    {
    +                        $tax_amount = $this->CI->tax_lib->get_sales_tax_for_amount($tax_basis, $tax['percent'], '0', $tax_decimals);
    +                    }
     
    -            $this->CI->tax_lib->round_sales_taxes($sales_taxes);
    -
    -        }
    -
    -        return $sales_taxes;
    -    }
    +                    if($tax_amount <> 0)
    +                    {
    +                        $this->CI->tax_lib->update_sales_taxes($sales_taxes, $tax_type, $tax_group, $tax['percent'], $tax_basis, $tax_amount, $tax_group_sequence, '0', -1);
    +                        $tax_group_sequence += 1;
    +                    }
    +                }
     
    -    public function apply_customer_discount($discount_percent)
    -    {   
    -        // Get all items in the cart so far...
    -        $items = $this->get_cart();
    -        
    -        foreach($items as &$item)
    -        {
    -            $quantity = $item['quantity'];
    -            $price = $item['price'];
    -
    -            // set a new discount only if the current one is 0
    -            if($item['discount'] == 0)
    -            {
    -                $item['discount'] = $discount_percent;
    -                $item['total'] = $this->get_item_total($quantity, $price, $discount_percent);
    -                $item['discounted_total'] = $this->get_item_total($quantity, $price, $discount_percent, TRUE);
    -            }
    -        }
    -
    -        $this->set_cart($items);
    -    }
    -    
    -    public function get_discount()
    -    {
    -        $discount = 0;
    -        foreach($this->get_cart() as $item)
    -        {
    -            if($item['discount'] > 0)
    -            {
    -                $item_discount = $this->get_item_discount($item['quantity'], $item['price'], $item['discount']);
    -                $discount = bcadd($discount, $item_discount);
    -            }
    -        }
    -
    -        return $discount;
    -    }
    -
    -    public function get_subtotal($include_discount = FALSE, $exclude_tax = FALSE)
    -    {
    -        return $this->calculate_subtotal($include_discount, $exclude_tax);
    -    }
    -    
    -    public function get_item_total_tax_exclusive($item_id, $quantity, $price, $discount_percentage, $include_discount = FALSE) 
    -    {
    -        $tax_info = $this->CI->Item_taxes->get_info($item_id);
    -        $item_price = $this->get_item_total($quantity, $price, $discount_percentage, $include_discount);
    -        // only additive tax here
    -        foreach($tax_info as $tax)
    -        {
    -            $tax_percentage = $tax['percent'];
    -            $item_price = bcsub($item_price, $this->get_item_tax($quantity, $price, $discount_percentage, $tax_percentage));
    -        }
    -        
    -        return $item_price;
    -    }
    -    
    -    public function get_item_total($quantity, $price, $discount_percentage, $include_discount = FALSE)  
    -    {
    -        $total = bcmul($quantity, $price);
    -        if($include_discount)
    -        {
    -            $discount_amount = $this->get_item_discount($quantity, $price, $discount_percentage);
    +                $tax_category = '';
    +                $tax_rate = '';
    +                $rounding_code = Rounding_code::HALF_UP;
    +                $tax_group_sequence = 0;
    +                $tax_code = '';
    +
    +                if($this->CI->config->item('customer_sales_tax_support') == '1')
    +                {
    +                    // Now calculate what the sales taxes should be (storing them in the $sales_taxes array
    +                    $this->CI->tax_lib->apply_sales_tax($item, $customer->city, $customer->state, $customer->sales_tax_code, $register_mode, 0, $sales_taxes, $tax_category, $tax_rate, $rounding_code, $tax_group_sequence, $tax_code);
    +                }
    +
    +            }
    +
    +            $this->CI->tax_lib->round_sales_taxes($sales_taxes);
    +
    +        }
    +
    +        return $sales_taxes;
    +    }
    +
    +    public function apply_customer_discount($discount_percent)
    +    {
    +        // Get all items in the cart so far...
    +        $items = $this->get_cart();
    +
    +        foreach($items as &$item)
    +        {
    +            $quantity = $item['quantity'];
    +            $price = $item['price'];
    +
    +            // set a new discount only if the current one is 0
    +            if($item['discount'] == 0)
    +            {
    +                $item['discount'] = $discount_percent;
    +                $item['total'] = $this->get_item_total($quantity, $price, $discount_percent);
    +                $item['discounted_total'] = $this->get_item_total($quantity, $price, $discount_percent, TRUE);
    +            }
    +        }
    +
    +        $this->set_cart($items);
    +    }
    +
    +    public function get_discount()
    +    {
    +        $discount = 0;
    +        foreach($this->get_cart() as $item)
    +        {
    +            if($item['discount'] > 0)
    +            {
    +                $item_discount = $this->get_item_discount($item['quantity'], $item['price'], $item['discount']);
    +                $discount = bcadd($discount, $item_discount);
    +            }
    +        }
    +
    +        return $discount;
    +    }
    +
    +    public function get_subtotal($include_discount = FALSE, $exclude_tax = FALSE)
    +    {
    +        return $this->calculate_subtotal($include_discount, $exclude_tax);
    +    }
     
    -            return bcsub($total, $discount_amount);
    -        }
    -
    -        return $total;
    -    }
    -    
    -    public function get_item_discount($quantity, $price, $discount_percentage)
    -    {
    -        $total = bcmul($quantity, $price);
    -        $discount_fraction = bcdiv($discount_percentage, 100);
    +    public function get_item_total_tax_exclusive($item_id, $quantity, $price, $discount_percentage, $include_discount = FALSE)
    +    {
    +        $tax_info = $this->CI->Item_taxes->get_info($item_id);
    +        $item_total = $this->get_item_total($quantity, $price, $discount_percentage, $include_discount);
    +        // only additive tax here
    +        foreach($tax_info as $tax)
    +        {
    +            $tax_percentage = $tax['percent'];
    +            $item_total = bcsub($item_total, $this->get_item_tax($quantity, $price, $discount_percentage, $tax_percentage));
    +        }
     
    -        return bcmul($total, $discount_fraction);
    +        return $item_total;
         }
    -    
    -    public function get_item_tax($quantity, $price, $discount_percentage, $tax_percentage) 
    +
    +    public function get_extended_total_tax_exclusive($item_id, $discounted_extended_amount, $quantity, $price, $discount_percentage = 0)
         {
    -        $price = $this->get_item_total($quantity, $price, $discount_percentage, TRUE);
    -        if($this->CI->config->config['tax_included'])
    -        {
    -            $tax_fraction = bcadd(100, $tax_percentage);
    -            $tax_fraction = bcdiv($tax_fraction, 100);
    -            $price_tax_excl = bcdiv($price, $tax_fraction);
    -
    -            return bcsub($price, $price_tax_excl);
    -        }
    -        $tax_fraction = bcdiv($tax_percentage, 100);
    -
    -        return bcmul($price, $tax_fraction);
    -    }
    -
    -    public function calculate_subtotal($include_discount = FALSE, $exclude_tax = FALSE)
    -    {
    -        $subtotal = 0;
    -        foreach($this->get_cart() as $item)
    -        {
    -            if($exclude_tax && $this->CI->config->config['tax_included'])
    -            {
    -                $subtotal = bcadd($subtotal, $this->get_item_total_tax_exclusive($item['item_id'], $item['quantity'], $item['price'], $item['discount'], $include_discount));
    -            }
    -            else 
    -            {
    -                $subtotal = bcadd($subtotal, $this->get_item_total($item['quantity'], $item['price'], $item['discount'], $include_discount));
    -            }
    -        }
    +        $tax_info = $this->CI->Item_taxes->get_info($item_id);
    +        // only additive tax here
    +        foreach($tax_info as $tax)
    +        {
    +            $tax_percentage = $tax['percent'];
    +            $discounted_extended_amount = bcsub($discounted_extended_amount, $this->get_item_tax($quantity, $price, $discount_percentage, $tax_percentage));
    +        }
    +
    +        return $discounted_extended_amount;
    +    }
    +    public function get_item_total($quantity, $price, $discount_percentage, $include_discount = FALSE)
    +    {
    +        $total = bcmul($quantity, $price);
    +        if($include_discount)
    +        {
    +            $discount_amount = $this->get_item_discount($quantity, $price, $discount_percentage);
    +
    +            return bcsub($total, $discount_amount);
    +        }
    +
    +        return $total;
    +    }
    +
    +    public function get_extended_amount($quantity, $price, $discount_amount = 0)
    +    {
    +        $extended_amount = bcmul($quantity, $price);
    +        return bcsub($extended_amount, $discount_amount);
    +    }
     
    -        return $subtotal;
    -    }
    -
    -    public function get_total()
    -    {
    -        $total = $this->calculate_subtotal(TRUE);
    -
    -        $cash_rounding = $this->CI->session->userdata('cash_rounding');
    -
    -        foreach($this->get_taxes() as $sales_tax)
    -        {
    -            $total = bcadd($total, $sales_tax['sale_tax_amount']);
    -        }
    -
    -        if($cash_rounding)
    -        {
    -            $rounded_total = $this->check_for_cash_rounding($total);
    -            return $rounded_total;
    +    public function get_item_discount($quantity, $price, $discount_percentage)
    +    {
    +        $total = bcmul($quantity, $price);
    +        $discount_fraction = bcdiv($discount_percentage, 100);
    +
    +        return bcmul($total, $discount_fraction);
    +    }
    +
    +    public function get_item_tax($quantity, $price, $discount_percentage, $tax_percentage)
    +    {
    +        $price = $this->get_item_total($quantity, $price, $discount_percentage, TRUE);
    +        if($this->CI->config->item('tax_included'))
    +        {
    +            $tax_fraction = bcadd(100, $tax_percentage);
    +            $tax_fraction = bcdiv($tax_fraction, 100);
    +            $price_tax_excl = bcdiv($price, $tax_fraction);
    +
    +            return bcsub($price, $price_tax_excl);
             }
    -        return $total;
    -    }
    -
    -    public function get_empty_tables()
    -    {
    -        return $this->CI->Dinner_table->get_empty_tables();     
    -    }
    -
    -    public function check_for_cash_rounding($total)
    -    {
    -        $cash_decimals = $this->CI->config->config['cash_decimals'];
    -        $cash_rounding_code = $this->CI->config->config['cash_rounding_code'];
    -        $rounded_total = $total;
    -
    -        if($cash_rounding_code == Rounding_code::HALF_UP)
    -        {
    -            $rounded_total = round ( $total, $cash_decimals, PHP_ROUND_HALF_UP);
    -        }
    -        elseif($cash_rounding_code == Rounding_code::HALF_DOWN)
    -        {
    -            $rounded_total = round ( $total, $cash_decimals, PHP_ROUND_HALF_DOWN);
    -        }
    -        elseif($cash_rounding_code == Rounding_code::HALF_EVEN)
    -        {
    -            $rounded_total = round ( $total, $cash_decimals, PHP_ROUND_HALF_EVEN);
    -        }
    -        elseif($cash_rounding_code == Rounding_code::HALF_ODD)
    -        {
    -            $rounded_total = round ( $total, $cash_decimals, PHP_ROUND_HALF_UP);
    -        }
    -        elseif($cash_rounding_code == Rounding_code::ROUND_UP)
    -        {
    -            $fig = (int) str_pad('1', $cash_decimals, '0');
    -            $rounded_total = (ceil($total * $fig) / $fig);
    -        }
    -        elseif($cash_rounding_code == Rounding_code::ROUND_DOWN)
    -        {
    -            $fig = (int) str_pad('1', $cash_decimals, '0');
    -            $rounded_total = (floor($total * $fig) / $fig);
    -        }
    -        elseif($cash_rounding_code == Rounding_code::HALF_FIVE)
    -        {
    -            $rounded_total = round($total / 5) * 5;
    -        }
    -
    -        return $rounded_total;
    -    }
    -}
    -
    -?>
    -
    + $tax_fraction = bcdiv($tax_percentage, 100); + + return bcmul($price, $tax_fraction); + } + + public function calculate_subtotal($include_discount = FALSE, $exclude_tax = FALSE) + { + $subtotal = 0; + foreach($this->get_cart() as $item) + { + if($exclude_tax && $this->CI->config->item('tax_included')) + { + $subtotal = bcadd($subtotal, $this->get_item_total_tax_exclusive($item['item_id'], $item['quantity'], $item['price'], $item['discount'], $include_discount)); + } + else + { + $subtotal = bcadd($subtotal, $this->get_item_total($item['quantity'], $item['price'], $item['discount'], $include_discount)); + } + } + + return $subtotal; + } + + public function get_total() + { + $total = $this->calculate_subtotal(TRUE); + + $cash_rounding = $this->CI->session->userdata('cash_rounding'); + + foreach($this->get_taxes() as $sales_tax) + { + $total = bcadd($total, $sales_tax['sale_tax_amount']); + } + + if($cash_rounding) + { + $rounded_total = $this->check_for_cash_rounding($total); + return $rounded_total; + } + return $total; + } + + public function get_empty_tables() + { + return $this->CI->Dinner_table->get_empty_tables(); + } + + public function check_for_cash_rounding($total) + { + $cash_decimals = $this->CI->config->item('cash_decimals'); + $cash_rounding_code = $this->CI->config->item('cash_rounding_code'); + $rounded_total = $total; + + if($cash_rounding_code == Rounding_code::HALF_UP) + { + $rounded_total = round ( $total, $cash_decimals, PHP_ROUND_HALF_UP); + } + elseif($cash_rounding_code == Rounding_code::HALF_DOWN) + { + $rounded_total = round ( $total, $cash_decimals, PHP_ROUND_HALF_DOWN); + } + elseif($cash_rounding_code == Rounding_code::HALF_EVEN) + { + $rounded_total = round ( $total, $cash_decimals, PHP_ROUND_HALF_EVEN); + } + elseif($cash_rounding_code == Rounding_code::HALF_ODD) + { + $rounded_total = round ( $total, $cash_decimals, PHP_ROUND_HALF_UP); + } + elseif($cash_rounding_code == Rounding_code::ROUND_UP) + { + $fig = (int) str_pad('1', $cash_decimals, '0'); + $rounded_total = (ceil($total * $fig) / $fig); + } + elseif($cash_rounding_code == Rounding_code::ROUND_DOWN) + { + $fig = (int) str_pad('1', $cash_decimals, '0'); + $rounded_total = (floor($total * $fig) / $fig); + } + elseif($cash_rounding_code == Rounding_code::HALF_FIVE) + { + $rounded_total = round($total / 5) * 5; + } + + return $rounded_total; + } +} + +?> + - + diff --git a/docs/source-class-Sale_suspended.html b/docs/source-class-Sale_suspended.html index ee6194082..ba53a2e47 100644 --- a/docs/source-class-Sale_suspended.html +++ b/docs/source-class-Sale_suspended.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,229 +207,238 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 
    -
    <?php
    -class Sale_suspended extends CI_Model
    -{
    -    public function get_all()
    -    {
    -        $this->db->from('sales_suspended');
    -        $this->db->order_by('sale_id');
    -
    -        return $this->db->get();
    -    }
    -    
    -    public function get_info($sale_id)
    -    {
    -        $this->db->from('sales_suspended');
    -        $this->db->where('sale_id', $sale_id);
    -        $this->db->join('people', 'people.person_id = sales_suspended.customer_id', 'LEFT');
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
    +
    +/**
    + * Sale_suspended class
    + *
    + * @link    github.com/jekkos/opensourcepos
    + * @since   1.0
    + * @author  N/A
    + */
    +
    +class Sale_suspended extends CI_Model
    +{
    +    public function get_all()
    +    {
    +        $this->db->from('sales_suspended');
    +        $this->db->order_by('sale_id');
     
             return $this->db->get();
         }
     
    -    /*
    -    Gets total of invocie rows
    -    */
    -    public function get_invoice_count()
    -    {
    -        $this->db->from('sales_suspended');
    -        $this->db->where('invoice_number IS NOT NULL');
    -
    -        return $this->db->count_all_results();
    -    }
    -    
    -    public function get_sale_by_invoice_number($invoice_number)
    -    {
    -        $this->db->from('sales_suspended');
    -        $this->db->where('invoice_number', $invoice_number);
    -
    -        return $this->db->get();
    -    }
    -
    -    public function exists($sale_id)
    -    {
    -        $this->db->from('sales_suspended');
    -        $this->db->where('sale_id', $sale_id);
    -
    -        return ($this->db->get()->num_rows() == 1);
    -    }
    -    
    -    public function update($sale_data, $sale_id)
    -    {
    -        $this->db->where('sale_id', $sale_id);
    -
    -        return $this->db->update('sales_suspended', $sale_data);
    -    }
    -    
    -    public function save($items, $customer_id, $employee_id, $comment, $invoice_number, $quote_number, $payments, $dinner_table, $sale_id = FALSE)
    -    {
    -        if(count($items) == 0)
    -        {
    -            return -1;
    -        }
    -
    -        if($dinner_table > 2)   //not delivery or take away
    -        {
    -            $table_status = 1;
    -        }
    -        else
    +    public function get_info($sale_id)
    +    {
    +        $this->db->from('sales_suspended');
    +        $this->db->where('sale_id', $sale_id);
    +        $this->db->join('people', 'people.person_id = sales_suspended.customer_id', 'LEFT');
    +
    +        return $this->db->get();
    +    }
    +
    +    /*
    +    Gets total of invocie rows
    +    */
    +    public function get_invoice_count()
    +    {
    +        $this->db->from('sales_suspended');
    +        $this->db->where('invoice_number IS NOT NULL');
    +
    +        return $this->db->count_all_results();
    +    }
    +
    +    public function get_sale_by_invoice_number($invoice_number)
    +    {
    +        $this->db->from('sales_suspended');
    +        $this->db->where('invoice_number', $invoice_number);
    +
    +        return $this->db->get();
    +    }
    +
    +    public function exists($sale_id)
    +    {
    +        $this->db->from('sales_suspended');
    +        $this->db->where('sale_id', $sale_id);
    +
    +        return ($this->db->get()->num_rows() == 1);
    +    }
    +
    +    public function update($sale_data, $sale_id)
    +    {
    +        $this->db->where('sale_id', $sale_id);
    +
    +        return $this->db->update('sales_suspended', $sale_data);
    +    }
    +
    +    public function save($items, $customer_id, $employee_id, $comment, $invoice_number, $quote_number, $payments, $dinner_table, $sale_id = FALSE)
    +    {
    +        if(count($items) == 0)
             {
    -            $table_status = 0;
    +            return -1;
             }
     
    -        $sales_data = array(
    -            'sale_time'      => date('Y-m-d H:i:s'),
    -            'customer_id'    => $this->Customer->exists($customer_id) ? $customer_id : null,
    -            'employee_id'    => $employee_id,
    -            'comment'        => $comment,
    -            'invoice_number' => $invoice_number,
    -            'quote_number'  => $quote_number,
    -            'dinner_table_id'   => $dinner_table
    -        );
    -
    -        //Run these queries as a transaction, we want to make sure we do all or nothing
    -        $this->db->trans_start();
    -
    -        $this->db->insert('sales_suspended', $sales_data);
    -        $sale_id = $this->db->insert_id();
    -
    -        foreach($payments as $payment_id=>$payment)
    -        {
    -            $sales_payments_data = array(
    -                'sale_id'        => $sale_id,
    -                'payment_type'   => $payment['payment_type'],
    -                'payment_amount' => $payment['payment_amount']
    -            );
    -
    -            $this->db->insert('sales_suspended_payments', $sales_payments_data);
    -        }
    -
    -        foreach($items as $line=>$item)
    -        {
    -            $cur_item_info = $this->Item->get_info($item['item_id']);
    -
    -            $sales_items_data = array(
    -                'sale_id'            => $sale_id,
    -                'item_id'            => $item['item_id'],
    -                'line'               => $item['line'],
    -                'description'        => character_limiter($item['description'], 30),
    -                'serialnumber'       => character_limiter($item['serialnumber'], 30),
    -                'quantity_purchased' => $item['quantity'],
    -                'discount_percent'   => $item['discount'],
    -                'item_cost_price'    => $cur_item_info->cost_price,
    -                'item_unit_price'    => $item['price'],
    -                'item_location'      => $item['item_location']
    -            );
    -
    -            $this->db->insert('sales_suspended_items', $sales_items_data);
    -
    -            $customer = $this->Customer->get_info($customer_id);
    -            if($customer_id == -1 || $customer->taxable)
    -            {
    -                foreach($this->Item_taxes->get_info($item['item_id']) as $row)
    -                {
    -                    $sales_items_taxes = array(
    -                        'sale_id' => $sale_id,
    -                        'item_id' => $item['item_id'],
    -                        'line'    => $item['line'],
    -                        'name'    => $row['name'],
    -                        'percent' => $row['percent']
    -                    );
    -                    
    -                    $this->db->insert('sales_suspended_items_taxes', $sales_items_taxes);
    -                }
    -            }
    -        }
    -
    -        $dinner_table_data = array(
    -            'status' => $table_status
    -        );
    +        if($dinner_table > 2)   //not delivery or take away
    +        {
    +            $table_status = 1;
    +        }
    +        else
    +        {
    +            $table_status = 0;
    +        }
    +
    +        $sales_data = array(
    +            'sale_time'      => date('Y-m-d H:i:s'),
    +            'customer_id'    => $this->Customer->exists($customer_id) ? $customer_id : null,
    +            'employee_id'    => $employee_id,
    +            'comment'        => $comment,
    +            'invoice_number' => $invoice_number,
    +            'quote_number'  => $quote_number,
    +            'dinner_table_id'   => $dinner_table
    +        );
    +
    +        //Run these queries as a transaction, we want to make sure we do all or nothing
    +        $this->db->trans_start();
    +
    +        $this->db->insert('sales_suspended', $sales_data);
    +        $sale_id = $this->db->insert_id();
    +
    +        foreach($payments as $payment_id=>$payment)
    +        {
    +            $sales_payments_data = array(
    +                'sale_id'        => $sale_id,
    +                'payment_type'   => $payment['payment_type'],
    +                'payment_amount' => $payment['payment_amount']
    +            );
    +
    +            $this->db->insert('sales_suspended_payments', $sales_payments_data);
    +        }
    +
    +        foreach($items as $line=>$item)
    +        {
    +            $cur_item_info = $this->Item->get_info($item['item_id']);
    +
    +            $sales_items_data = array(
    +                'sale_id'            => $sale_id,
    +                'item_id'            => $item['item_id'],
    +                'line'               => $item['line'],
    +                'description'        => character_limiter($item['description'], 30),
    +                'serialnumber'       => character_limiter($item['serialnumber'], 30),
    +                'quantity_purchased' => $item['quantity'],
    +                'discount_percent'   => $item['discount'],
    +                'item_cost_price'    => $cur_item_info->cost_price,
    +                'item_unit_price'    => $item['price'],
    +                'item_location'      => $item['item_location']
    +            );
    +
    +            $this->db->insert('sales_suspended_items', $sales_items_data);
    +
    +            $customer = $this->Customer->get_info($customer_id);
    +            if($customer_id == -1 || $customer->taxable)
    +            {
    +                foreach($this->Item_taxes->get_info($item['item_id']) as $row)
    +                {
    +                    $sales_items_taxes = array(
    +                        'sale_id' => $sale_id,
    +                        'item_id' => $item['item_id'],
    +                        'line'    => $item['line'],
    +                        'name'    => $row['name'],
    +                        'percent' => $row['percent']
    +                    );
     
    -        $this->db->where('dinner_table_id',$dinner_table);
    -        $this->db->update('dinner_tables', $dinner_table_data);
    -
    -        $this->db->trans_complete();
    -        
    -        if($this->db->trans_status() === FALSE)
    -        {
    -            return -1;
    -        }
    -        
    -        return $sale_id;
    -    }
    -    
    -    public function delete($sale_id)
    -    {
    -        //Run these queries as a transaction, we want to make sure we do all or nothing
    -        $this->db->trans_start();
    -        
    -        $dinner_table = $this->get_dinner_table($sale_id);
    -        $dinner_table_data = array(
    -            'status' => 0
    -        );
    -
    -        $this->db->where('dinner_table_id',$dinner_table);
    -        $this->db->update('dinner_tables', $dinner_table_data);
    -        
    -        $this->db->delete('sales_suspended_payments', array('sale_id' => $sale_id)); 
    -        $this->db->delete('sales_suspended_items_taxes', array('sale_id' => $sale_id)); 
    -        $this->db->delete('sales_suspended_items', array('sale_id' => $sale_id)); 
    -        $this->db->delete('sales_suspended', array('sale_id' => $sale_id)); 
    -        
    -        $this->db->trans_complete();
    -                
    -        return $this->db->trans_status();
    -    }
    -
    -    public function get_sale_items($sale_id)
    -    {
    -        $this->db->select('
    -        sale_id,
    -        sales_suspended_items.item_id,
    -        sales_suspended_items.description,
    -        serialnumber,
    -        line,
    -        quantity_purchased,
    -        item_cost_price,
    -        item_unit_price,
    -        discount_percent,
    -        item_location,
    -        print_option,
    -        stock_type');
    -        $this->db->from('sales_suspended_items');
    -        $this->db->join('items as items', 'sales_suspended_items.item_id = items.item_id');
    -        $this->db->where('sale_id', $sale_id);
    -
    -        return $this->db->get();
    -    }
    -
    -    public function get_sale_payments($sale_id)
    -    {
    -        $this->db->from('sales_suspended_payments');
    -        $this->db->where('sale_id', $sale_id);
    -
    -        return $this->db->get();
    -    }
    -
    -    public function get_comment($sale_id)
    -    {
    -        $this->db->from('sales_suspended');
    -        $this->db->where('sale_id', $sale_id);
    -
    -        return $this->db->get()->row()->comment;
    -    }
    -
    -    public function get_dinner_table($sale_id)
    -    {
    -        $this->db->from('sales_suspended');
    -        $this->db->where('sale_id', $sale_id);
    -
    -        return $this->db->get()->row()->dinner_table_id;
    -    }
    -}
    -?>
    -
    +
    $this->db->insert('sales_suspended_items_taxes', $sales_items_taxes); + } + } + } + + $dinner_table_data = array( + 'status' => $table_status + ); + + $this->db->where('dinner_table_id',$dinner_table); + $this->db->update('dinner_tables', $dinner_table_data); + + $this->db->trans_complete(); + + if($this->db->trans_status() === FALSE) + { + return -1; + } + + return $sale_id; + } + + public function delete($sale_id) + { + //Run these queries as a transaction, we want to make sure we do all or nothing + $this->db->trans_start(); + + $dinner_table = $this->get_dinner_table($sale_id); + $dinner_table_data = array( + 'status' => 0 + ); + + $this->db->where('dinner_table_id',$dinner_table); + $this->db->update('dinner_tables', $dinner_table_data); + + $this->db->delete('sales_suspended_payments', array('sale_id' => $sale_id)); + $this->db->delete('sales_suspended_items_taxes', array('sale_id' => $sale_id)); + $this->db->delete('sales_suspended_items', array('sale_id' => $sale_id)); + $this->db->delete('sales_suspended', array('sale_id' => $sale_id)); + + $this->db->trans_complete(); + + return $this->db->trans_status(); + } + + public function get_sale_items($sale_id) + { + $this->db->select(' + sale_id, + sales_suspended_items.item_id, + sales_suspended_items.description, + serialnumber, + line, + quantity_purchased, + item_cost_price, + item_unit_price, + discount_percent, + item_location, + print_option, + stock_type'); + $this->db->from('sales_suspended_items'); + $this->db->join('items as items', 'sales_suspended_items.item_id = items.item_id'); + $this->db->where('sale_id', $sale_id); + + return $this->db->get(); + } + + public function get_sale_payments($sale_id) + { + $this->db->from('sales_suspended_payments'); + $this->db->where('sale_id', $sale_id); + + return $this->db->get(); + } + + public function get_comment($sale_id) + { + $this->db->from('sales_suspended'); + $this->db->where('sale_id', $sale_id); + + return $this->db->get()->row()->comment; + } + + public function get_dinner_table($sale_id) + { + $this->db->from('sales_suspended'); + $this->db->where('sale_id', $sale_id); + + return $this->db->get()->row()->dinner_table_id; + } +} +?> +
    - + diff --git a/docs/source-class-Sales.html b/docs/source-class-Sales.html index b74b23833..52e724493 100644 --- a/docs/source-class-Sales.html +++ b/docs/source-class-Sales.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,7 +207,7 @@ -
       1:    2:    3:    4:    5:    6:    7:    8:    9:   10:   11:   12:   13:   14:   15:   16:   17:   18:   19:   20:   21:   22:   23:   24:   25:   26:   27:   28:   29:   30:   31:   32:   33:   34:   35:   36:   37:   38:   39:   40:   41:   42:   43:   44:   45:   46:   47:   48:   49:   50:   51:   52:   53:   54:   55:   56:   57:   58:   59:   60:   61:   62:   63:   64:   65:   66:   67:   68:   69:   70:   71:   72:   73:   74:   75:   76:   77:   78:   79:   80:   81:   82:   83:   84:   85:   86:   87:   88:   89:   90:   91:   92:   93:   94:   95:   96:   97:   98:   99:  100:  101:  102:  103:  104:  105:  106:  107:  108:  109:  110:  111:  112:  113:  114:  115:  116:  117:  118:  119:  120:  121:  122:  123:  124:  125:  126:  127:  128:  129:  130:  131:  132:  133:  134:  135:  136:  137:  138:  139:  140:  141:  142:  143:  144:  145:  146:  147:  148:  149:  150:  151:  152:  153:  154:  155:  156:  157:  158:  159:  160:  161:  162:  163:  164:  165:  166:  167:  168:  169:  170:  171:  172:  173:  174:  175:  176:  177:  178:  179:  180:  181:  182:  183:  184:  185:  186:  187:  188:  189:  190:  191:  192:  193:  194:  195:  196:  197:  198:  199:  200:  201:  202:  203:  204:  205:  206:  207:  208:  209:  210:  211:  212:  213:  214:  215:  216:  217:  218:  219:  220:  221:  222:  223:  224:  225:  226:  227:  228:  229:  230:  231:  232:  233:  234:  235:  236:  237:  238:  239:  240:  241:  242:  243:  244:  245:  246:  247:  248:  249:  250:  251:  252:  253:  254:  255:  256:  257:  258:  259:  260:  261:  262:  263:  264:  265:  266:  267:  268:  269:  270:  271:  272:  273:  274:  275:  276:  277:  278:  279:  280:  281:  282:  283:  284:  285:  286:  287:  288:  289:  290:  291:  292:  293:  294:  295:  296:  297:  298:  299:  300:  301:  302:  303:  304:  305:  306:  307:  308:  309:  310:  311:  312:  313:  314:  315:  316:  317:  318:  319:  320:  321:  322:  323:  324:  325:  326:  327:  328:  329:  330:  331:  332:  333:  334:  335:  336:  337:  338:  339:  340:  341:  342:  343:  344:  345:  346:  347:  348:  349:  350:  351:  352:  353:  354:  355:  356:  357:  358:  359:  360:  361:  362:  363:  364:  365:  366:  367:  368:  369:  370:  371:  372:  373:  374:  375:  376:  377:  378:  379:  380:  381:  382:  383:  384:  385:  386:  387:  388:  389:  390:  391:  392:  393:  394:  395:  396:  397:  398:  399:  400:  401:  402:  403:  404:  405:  406:  407:  408:  409:  410:  411:  412:  413:  414:  415:  416:  417:  418:  419:  420:  421:  422:  423:  424:  425:  426:  427:  428:  429:  430:  431:  432:  433:  434:  435:  436:  437:  438:  439:  440:  441:  442:  443:  444:  445:  446:  447:  448:  449:  450:  451:  452:  453:  454:  455:  456:  457:  458:  459:  460:  461:  462:  463:  464:  465:  466:  467:  468:  469:  470:  471:  472:  473:  474:  475:  476:  477:  478:  479:  480:  481:  482:  483:  484:  485:  486:  487:  488:  489:  490:  491:  492:  493:  494:  495:  496:  497:  498:  499:  500:  501:  502:  503:  504:  505:  506:  507:  508:  509:  510:  511:  512:  513:  514:  515:  516:  517:  518:  519:  520:  521:  522:  523:  524:  525:  526:  527:  528:  529:  530:  531:  532:  533:  534:  535:  536:  537:  538:  539:  540:  541:  542:  543:  544:  545:  546:  547:  548:  549:  550:  551:  552:  553:  554:  555:  556:  557:  558:  559:  560:  561:  562:  563:  564:  565:  566:  567:  568:  569:  570:  571:  572:  573:  574:  575:  576:  577:  578:  579:  580:  581:  582:  583:  584:  585:  586:  587:  588:  589:  590:  591:  592:  593:  594:  595:  596:  597:  598:  599:  600:  601:  602:  603:  604:  605:  606:  607:  608:  609:  610:  611:  612:  613:  614:  615:  616:  617:  618:  619:  620:  621:  622:  623:  624:  625:  626:  627:  628:  629:  630:  631:  632:  633:  634:  635:  636:  637:  638:  639:  640:  641:  642:  643:  644:  645:  646:  647:  648:  649:  650:  651:  652:  653:  654:  655:  656:  657:  658:  659:  660:  661:  662:  663:  664:  665:  666:  667:  668:  669:  670:  671:  672:  673:  674:  675:  676:  677:  678:  679:  680:  681:  682:  683:  684:  685:  686:  687:  688:  689:  690:  691:  692:  693:  694:  695:  696:  697:  698:  699:  700:  701:  702:  703:  704:  705:  706:  707:  708:  709:  710:  711:  712:  713:  714:  715:  716:  717:  718:  719:  720:  721:  722:  723:  724:  725:  726:  727:  728:  729:  730:  731:  732:  733:  734:  735:  736:  737:  738:  739:  740:  741:  742:  743:  744:  745:  746:  747:  748:  749:  750:  751:  752:  753:  754:  755:  756:  757:  758:  759:  760:  761:  762:  763:  764:  765:  766:  767:  768:  769:  770:  771:  772:  773:  774:  775:  776:  777:  778:  779:  780:  781:  782:  783:  784:  785:  786:  787:  788:  789:  790:  791:  792:  793:  794:  795:  796:  797:  798:  799:  800:  801:  802:  803:  804:  805:  806:  807:  808:  809:  810:  811:  812:  813:  814:  815:  816:  817:  818:  819:  820:  821:  822:  823:  824:  825:  826:  827:  828:  829:  830:  831:  832:  833:  834:  835:  836:  837:  838:  839:  840:  841:  842:  843:  844:  845:  846:  847:  848:  849:  850:  851:  852:  853:  854:  855:  856:  857:  858:  859:  860:  861:  862:  863:  864:  865:  866:  867:  868:  869:  870:  871:  872:  873:  874:  875:  876:  877:  878:  879:  880:  881:  882:  883:  884:  885:  886:  887:  888:  889:  890:  891:  892:  893:  894:  895:  896:  897:  898:  899:  900:  901:  902:  903:  904:  905:  906:  907:  908:  909:  910:  911:  912:  913:  914:  915:  916:  917:  918:  919:  920:  921:  922:  923:  924:  925:  926:  927:  928:  929:  930:  931:  932:  933:  934:  935:  936:  937:  938:  939:  940:  941:  942:  943:  944:  945:  946:  947:  948:  949:  950:  951:  952:  953:  954:  955:  956:  957:  958:  959:  960:  961:  962:  963:  964:  965:  966:  967:  968:  969:  970:  971:  972:  973:  974:  975:  976:  977:  978:  979:  980:  981:  982:  983:  984:  985:  986:  987:  988:  989:  990:  991:  992:  993:  994:  995:  996:  997:  998:  999: 1000: 1001: 1002: 1003: 1004: 1005: 1006: 1007: 1008: 1009: 1010: 1011: 1012: 1013: 1014: 1015: 1016: 1017: 1018: 1019: 1020: 1021: 1022: 1023: 1024: 1025: 1026: 1027: 1028: 1029: 1030: 1031: 1032: 1033: 1034: 1035: 1036: 1037: 1038: 1039: 1040: 1041: 1042: 1043: 1044: 1045: 1046: 1047: 1048: 1049: 1050: 1051: 1052: 1053: 1054: 1055: 1056: 1057: 1058: 1059: 1060: 1061: 1062: 1063: 1064: 1065: 1066: 1067: 1068: 1069: 1070: 1071: 1072: 1073: 1074: 1075: 1076: 1077: 1078: 1079: 1080: 1081: 1082: 1083: 1084: 1085: 1086: 1087: 1088: 1089: 1090: 1091: 1092: 1093: 1094: 1095: 1096: 1097: 1098: 1099: 1100: 1101: 1102: 1103: 1104: 1105: 1106: 1107: 1108: 1109: 1110: 1111: 1112: 1113: 1114: 1115: 1116: 1117: 1118: 1119: 1120: 1121: 1122: 1123: 1124: 1125: 1126: 1127: 1128: 1129: 1130: 1131: 1132: 1133: 1134: 1135: 1136: 1137: 1138: 1139: 1140: 1141: 1142: 1143: 1144: 1145: 1146: 1147: 1148: 1149: 1150: 1151: 1152: 1153: 1154: 1155: 1156: 1157: 1158: 1159: 1160: 1161: 1162: 1163: 1164: 1165: 1166: 1167: 1168: 1169: 1170: 1171: 1172: 1173: 1174: 1175: 1176: 1177: 1178: 1179: 1180: 1181: 1182: 1183: 1184: 1185: 1186: 1187: 1188: 1189: 1190: 1191: 1192: 1193: 1194: 1195: 1196: 1197: 1198: 1199: 1200: 1201: 1202: 1203: 1204: 1205: 1206: 1207: 1208: 1209: 1210: 1211: 1212: 1213: 1214: 1215: 1216: 1217: 1218: 1219: 1220: 1221: 1222: 1223: 1224: 1225: 1226: 1227: 1228: 1229: 1230: 1231: 1232: 1233: 1234: 1235: 1236: 1237: 1238: 1239: 1240: 1241: 1242: 1243: 1244: 1245: 1246: 1247: 1248: 1249: 1250: 1251: 1252: 1253: 1254: 1255: 1256: 1257: 1258: 1259: 1260: 1261: 1262: 1263: 1264: 1265: 1266: 1267: 1268: 1269: 1270: 1271: 1272: 1273: 1274: 1275: 1276: 1277: 1278: 1279: 1280: 1281: 1282: 1283: 1284: 
    +
       1:    2:    3:    4:    5:    6:    7:    8:    9:   10:   11:   12:   13:   14:   15:   16:   17:   18:   19:   20:   21:   22:   23:   24:   25:   26:   27:   28:   29:   30:   31:   32:   33:   34:   35:   36:   37:   38:   39:   40:   41:   42:   43:   44:   45:   46:   47:   48:   49:   50:   51:   52:   53:   54:   55:   56:   57:   58:   59:   60:   61:   62:   63:   64:   65:   66:   67:   68:   69:   70:   71:   72:   73:   74:   75:   76:   77:   78:   79:   80:   81:   82:   83:   84:   85:   86:   87:   88:   89:   90:   91:   92:   93:   94:   95:   96:   97:   98:   99:  100:  101:  102:  103:  104:  105:  106:  107:  108:  109:  110:  111:  112:  113:  114:  115:  116:  117:  118:  119:  120:  121:  122:  123:  124:  125:  126:  127:  128:  129:  130:  131:  132:  133:  134:  135:  136:  137:  138:  139:  140:  141:  142:  143:  144:  145:  146:  147:  148:  149:  150:  151:  152:  153:  154:  155:  156:  157:  158:  159:  160:  161:  162:  163:  164:  165:  166:  167:  168:  169:  170:  171:  172:  173:  174:  175:  176:  177:  178:  179:  180:  181:  182:  183:  184:  185:  186:  187:  188:  189:  190:  191:  192:  193:  194:  195:  196:  197:  198:  199:  200:  201:  202:  203:  204:  205:  206:  207:  208:  209:  210:  211:  212:  213:  214:  215:  216:  217:  218:  219:  220:  221:  222:  223:  224:  225:  226:  227:  228:  229:  230:  231:  232:  233:  234:  235:  236:  237:  238:  239:  240:  241:  242:  243:  244:  245:  246:  247:  248:  249:  250:  251:  252:  253:  254:  255:  256:  257:  258:  259:  260:  261:  262:  263:  264:  265:  266:  267:  268:  269:  270:  271:  272:  273:  274:  275:  276:  277:  278:  279:  280:  281:  282:  283:  284:  285:  286:  287:  288:  289:  290:  291:  292:  293:  294:  295:  296:  297:  298:  299:  300:  301:  302:  303:  304:  305:  306:  307:  308:  309:  310:  311:  312:  313:  314:  315:  316:  317:  318:  319:  320:  321:  322:  323:  324:  325:  326:  327:  328:  329:  330:  331:  332:  333:  334:  335:  336:  337:  338:  339:  340:  341:  342:  343:  344:  345:  346:  347:  348:  349:  350:  351:  352:  353:  354:  355:  356:  357:  358:  359:  360:  361:  362:  363:  364:  365:  366:  367:  368:  369:  370:  371:  372:  373:  374:  375:  376:  377:  378:  379:  380:  381:  382:  383:  384:  385:  386:  387:  388:  389:  390:  391:  392:  393:  394:  395:  396:  397:  398:  399:  400:  401:  402:  403:  404:  405:  406:  407:  408:  409:  410:  411:  412:  413:  414:  415:  416:  417:  418:  419:  420:  421:  422:  423:  424:  425:  426:  427:  428:  429:  430:  431:  432:  433:  434:  435:  436:  437:  438:  439:  440:  441:  442:  443:  444:  445:  446:  447:  448:  449:  450:  451:  452:  453:  454:  455:  456:  457:  458:  459:  460:  461:  462:  463:  464:  465:  466:  467:  468:  469:  470:  471:  472:  473:  474:  475:  476:  477:  478:  479:  480:  481:  482:  483:  484:  485:  486:  487:  488:  489:  490:  491:  492:  493:  494:  495:  496:  497:  498:  499:  500:  501:  502:  503:  504:  505:  506:  507:  508:  509:  510:  511:  512:  513:  514:  515:  516:  517:  518:  519:  520:  521:  522:  523:  524:  525:  526:  527:  528:  529:  530:  531:  532:  533:  534:  535:  536:  537:  538:  539:  540:  541:  542:  543:  544:  545:  546:  547:  548:  549:  550:  551:  552:  553:  554:  555:  556:  557:  558:  559:  560:  561:  562:  563:  564:  565:  566:  567:  568:  569:  570:  571:  572:  573:  574:  575:  576:  577:  578:  579:  580:  581:  582:  583:  584:  585:  586:  587:  588:  589:  590:  591:  592:  593:  594:  595:  596:  597:  598:  599:  600:  601:  602:  603:  604:  605:  606:  607:  608:  609:  610:  611:  612:  613:  614:  615:  616:  617:  618:  619:  620:  621:  622:  623:  624:  625:  626:  627:  628:  629:  630:  631:  632:  633:  634:  635:  636:  637:  638:  639:  640:  641:  642:  643:  644:  645:  646:  647:  648:  649:  650:  651:  652:  653:  654:  655:  656:  657:  658:  659:  660:  661:  662:  663:  664:  665:  666:  667:  668:  669:  670:  671:  672:  673:  674:  675:  676:  677:  678:  679:  680:  681:  682:  683:  684:  685:  686:  687:  688:  689:  690:  691:  692:  693:  694:  695:  696:  697:  698:  699:  700:  701:  702:  703:  704:  705:  706:  707:  708:  709:  710:  711:  712:  713:  714:  715:  716:  717:  718:  719:  720:  721:  722:  723:  724:  725:  726:  727:  728:  729:  730:  731:  732:  733:  734:  735:  736:  737:  738:  739:  740:  741:  742:  743:  744:  745:  746:  747:  748:  749:  750:  751:  752:  753:  754:  755:  756:  757:  758:  759:  760:  761:  762:  763:  764:  765:  766:  767:  768:  769:  770:  771:  772:  773:  774:  775:  776:  777:  778:  779:  780:  781:  782:  783:  784:  785:  786:  787:  788:  789:  790:  791:  792:  793:  794:  795:  796:  797:  798:  799:  800:  801:  802:  803:  804:  805:  806:  807:  808:  809:  810:  811:  812:  813:  814:  815:  816:  817:  818:  819:  820:  821:  822:  823:  824:  825:  826:  827:  828:  829:  830:  831:  832:  833:  834:  835:  836:  837:  838:  839:  840:  841:  842:  843:  844:  845:  846:  847:  848:  849:  850:  851:  852:  853:  854:  855:  856:  857:  858:  859:  860:  861:  862:  863:  864:  865:  866:  867:  868:  869:  870:  871:  872:  873:  874:  875:  876:  877:  878:  879:  880:  881:  882:  883:  884:  885:  886:  887:  888:  889:  890:  891:  892:  893:  894:  895:  896:  897:  898:  899:  900:  901:  902:  903:  904:  905:  906:  907:  908:  909:  910:  911:  912:  913:  914:  915:  916:  917:  918:  919:  920:  921:  922:  923:  924:  925:  926:  927:  928:  929:  930:  931:  932:  933:  934:  935:  936:  937:  938:  939:  940:  941:  942:  943:  944:  945:  946:  947:  948:  949:  950:  951:  952:  953:  954:  955:  956:  957:  958:  959:  960:  961:  962:  963:  964:  965:  966:  967:  968:  969:  970:  971:  972:  973:  974:  975:  976:  977:  978:  979:  980:  981:  982:  983:  984:  985:  986:  987:  988:  989:  990:  991:  992:  993:  994:  995:  996:  997:  998:  999: 1000: 1001: 1002: 1003: 1004: 1005: 1006: 1007: 1008: 1009: 1010: 1011: 1012: 1013: 1014: 1015: 1016: 1017: 1018: 1019: 1020: 1021: 1022: 1023: 1024: 1025: 1026: 1027: 1028: 1029: 1030: 1031: 1032: 1033: 1034: 1035: 1036: 1037: 1038: 1039: 1040: 1041: 1042: 1043: 1044: 1045: 1046: 1047: 1048: 1049: 1050: 1051: 1052: 1053: 1054: 1055: 1056: 1057: 1058: 1059: 1060: 1061: 1062: 1063: 1064: 1065: 1066: 1067: 1068: 1069: 1070: 1071: 1072: 1073: 1074: 1075: 1076: 1077: 1078: 1079: 1080: 1081: 1082: 1083: 1084: 1085: 1086: 1087: 1088: 1089: 1090: 1091: 1092: 1093: 1094: 1095: 1096: 1097: 1098: 1099: 1100: 1101: 1102: 1103: 1104: 1105: 1106: 1107: 1108: 1109: 1110: 1111: 1112: 1113: 1114: 1115: 1116: 1117: 1118: 1119: 1120: 1121: 1122: 1123: 1124: 1125: 1126: 1127: 1128: 1129: 1130: 1131: 1132: 1133: 1134: 1135: 1136: 1137: 1138: 1139: 1140: 1141: 1142: 1143: 1144: 1145: 1146: 1147: 1148: 1149: 1150: 1151: 1152: 1153: 1154: 1155: 1156: 1157: 1158: 1159: 1160: 1161: 1162: 1163: 1164: 1165: 1166: 1167: 1168: 1169: 1170: 1171: 1172: 1173: 1174: 1175: 1176: 1177: 1178: 1179: 1180: 1181: 1182: 1183: 1184: 1185: 1186: 1187: 1188: 1189: 1190: 1191: 1192: 1193: 1194: 1195: 1196: 1197: 1198: 1199: 1200: 1201: 1202: 1203: 1204: 1205: 1206: 1207: 1208: 1209: 1210: 1211: 1212: 1213: 1214: 1215: 1216: 1217: 1218: 1219: 1220: 1221: 1222: 1223: 1224: 1225: 1226: 1227: 1228: 1229: 1230: 1231: 1232: 1233: 1234: 1235: 1236: 1237: 1238: 1239: 1240: 1241: 1242: 1243: 1244: 1245: 1246: 1247: 1248: 1249: 1250: 1251: 1252: 1253: 1254: 1255: 1256: 1257: 1258: 1259: 1260: 1261: 1262: 1263: 1264: 1265: 1266: 1267: 1268: 1269: 1270: 1271: 1272: 1273: 1274: 1275: 1276: 1277: 1278: 1279: 
    <?php if(!defined('BASEPATH')) exit('No direct script access allowed');
     
     require_once("Secure_Controller.php");
    @@ -676,121 +678,121 @@
             $data["invoice_number"] = $this->sale_lib->get_invoice_number();
             $data["quote_number"] = $this->sale_lib->get_quote_number();
             $customer_info = $this->_load_customer_data($customer_id, $data);
    -
    -        $data['taxes'] = $this->sale_lib->get_taxes();
    -        $data['discount'] = $this->sale_lib->get_discount();
    -        $data['payments'] = $this->sale_lib->get_payments();
    -
    -        // Returns 'subtotal', 'total', 'cash_total', 'payment_total', 'amount_due', 'cash_amount_due', 'payments_cover_total'
    -        $totals = $this->sale_lib->get_totals();
    -        $data['subtotal'] = $totals['discounted_subtotal'];
    -        $data['cash_total'] = $totals['cash_total'];
    -        $data['cash_amount_due'] = $totals['cash_amount_due'];
    -        $data['non_cash_total'] =$totals['total'];
    -        $data['non_cash_amount_due'] =$totals['amount_due'];
    +        if($customer_info != NULL)
    +        {
    +            $data["customer_comments"] = $customer_info->comments;
    +        }
    +        $data['taxes'] = $this->sale_lib->get_taxes();
    +        $data['discount'] = $this->sale_lib->get_discount();
    +        $data['payments'] = $this->sale_lib->get_payments();
    +
    +        // Returns 'subtotal', 'total', 'cash_total', 'payment_total', 'amount_due', 'cash_amount_due', 'payments_cover_total'
    +        $totals = $this->sale_lib->get_totals();
    +        $data['subtotal'] = $totals['subtotal'];
    +        $data['total'] = $totals['total'];
             $data['payments_total'] = $totals['payment_total'];
             $data['payments_cover_total'] = $totals['payments_cover_total'];
             $data['cash_rounding'] = $this->session->userdata('cash_rounding');
    -
    -        $data['discounted_subtotal'] = $totals['discounted_subtotal'];
    -        $data['tax_exclusive_subtotal'] = $totals['tax_exclusive_subtotal'];
    -
    -        if($data['cash_rounding'])
    -        {
    -            $data['total'] = $totals['cash_total'];
    -            $data['amount_due'] = $totals['cash_amount_due'];
    -        }
    -        else
    -        {
    -            $data['total'] = $totals['total'];
    -            $data['amount_due'] = $totals['amount_due'];
    -        }
    -        $data['amount_change'] = $data['amount_due'] * -1;
    -
    -        if($this->sale_lib->is_invoice_mode() || $data['invoice_number_enabled'] == TRUE)
    -        {
    -            // generate final invoice number (if using the invoice in sales by receipt mode then the invoice number can be manually entered or altered in some way
    -            if($this->sale_lib->is_sale_by_receipt_mode())
    -            {
    -                $this->sale_lib->set_invoice_number($this->input->post('invoice_number'), $keep_custom = TRUE);
    -                $invoice_format = $this->sale_lib->get_invoice_number();
    -                if(empty($invoice_format))
    -                {
    -                    $invoice_format = $this->config->item('sales_invoice_format');
    -                }
    -            }
    -            else
    -            {
    -                $invoice_format = $this->config->item('sales_invoice_format');
    -            }
    -            $invoice_number = $this->token_lib->render($invoice_format);
    -
    -            // TODO If duplicate invoice then determine the number of employees and repeat until until success or tried the number of employees (if QSEQ was used).
    -            if($this->Sale->check_invoice_number_exists($invoice_number))
    -            {
    -                $data['error'] = $this->lang->line('sales_invoice_number_duplicate');
    -                $this->_reload($data);
    -            }
    -            else
    -            {
    -                $data['invoice_number'] = $invoice_number;
    -                $data['sale_status'] = '0'; // Complete
    -
    -                // Save the data to the sales table
    -                $data['sale_id_num'] = $this->Sale->save($data['sale_status'], $data['cart'], $customer_id, $employee_id, $data['comments'], $invoice_number, $data["quote_number"], $data['payments'], $data['dinner_table'], $data['taxes']);
    -                $data['sale_id'] = 'POS ' . $data['sale_id_num'];
    -
    -                // Resort and filter cart lines for printing
    -                $data['cart'] = $this->sale_lib->sort_and_filter_cart($data['cart']);
    -
    -                $data = $this->xss_clean($data);
    +        $data['prediscount_subtotal'] = $totals['prediscount_subtotal'];
    +        $data['cash_total'] = $totals['cash_total'];
    +        $data['non_cash_total'] = $totals['total'];
    +        $data['cash_amount_due'] = $totals['cash_amount_due'];
    +        $data['non_cash_amount_due'] = $totals['amount_due'];
    +
    +        if($data['cash_rounding'])
    +        {
    +            $data['total'] = $totals['cash_total'];
    +            $data['amount_due'] = $totals['cash_amount_due'];
    +        }
    +        else
    +        {
    +            $data['total'] = $totals['total'];
    +            $data['amount_due'] = $totals['amount_due'];
    +        }
    +        $data['amount_change'] = $data['amount_due'] * -1;
    +
    +        if($this->sale_lib->is_invoice_mode() || $data['invoice_number_enabled'] == TRUE)
    +        {
    +            // generate final invoice number (if using the invoice in sales by receipt mode then the invoice number can be manually entered or altered in some way
    +            if($this->sale_lib->is_sale_by_receipt_mode())
    +            {
    +                $this->sale_lib->set_invoice_number($this->input->post('invoice_number'), $keep_custom = TRUE);
    +                $invoice_format = $this->sale_lib->get_invoice_number();
    +                if(empty($invoice_format))
    +                {
    +                    $invoice_format = $this->config->item('sales_invoice_format');
    +                }
    +            }
    +            else
    +            {
    +                $invoice_format = $this->config->item('sales_invoice_format');
    +            }
    +            $invoice_number = $this->token_lib->render($invoice_format);
    +
    +            // TODO If duplicate invoice then determine the number of employees and repeat until until success or tried the number of employees (if QSEQ was used).
    +            if($this->Sale->check_invoice_number_exists($invoice_number))
    +            {
    +                $data['error'] = $this->lang->line('sales_invoice_number_duplicate');
    +                $this->_reload($data);
    +            }
    +            else
    +            {
    +                $data['invoice_number'] = $invoice_number;
    +                $data['sale_status'] = '0'; // Complete
    +
    +                // Save the data to the sales table
    +                $data['sale_id_num'] = $this->Sale->save($data['sale_status'], $data['cart'], $customer_id, $employee_id, $data['comments'], $invoice_number, $data["quote_number"], $data['payments'], $data['dinner_table'], $data['taxes']);
    +                $data['sale_id'] = 'POS ' . $data['sale_id_num'];
    +
    +                // Resort and filter cart lines for printing
    +                $data['cart'] = $this->sale_lib->sort_and_filter_cart($data['cart']);
     
    -                if($data['sale_id_num'] == -1)
    -                {
    -                    $data['error_message'] = $this->lang->line('sales_transaction_failed');
    -                }
    -                else
    -                {
    -                    $data['barcode'] = $this->barcode_lib->generate_receipt_barcode($data['sale_id']);
    -                    $this->load->view('sales/invoice', $data);
    -                    $this->sale_lib->clear_all();
    -                }
    -            }
    -        }
    -        elseif($this->sale_lib->is_quote_mode())
    -        {
    -            $invoice_number = NULL;
    -            $quote_number = $this->sale_lib->get_quote_number();
    -
    -            if($quote_number == NULL)
    -            {
    -                // generate quote number
    -                $quote_format = $this->config->item('sales_quote_format');
    -                $quote_number = $this->token_lib->render($quote_format);
    -            }
    -
    -            // TODO If duplicate quote then determine the number of employees and repeat until until success or tried the number of employees (if QSEQ was used).
    -            if($this->Sale->check_quote_number_exists($quote_number))
    -            {
    -                $data['error'] = $this->lang->line('sales_quote_number_duplicate');
    -                $this->_reload($data);
    -            }
    -            else
    -            {
    -                $data['invoice_number'] = $invoice_number;
    -                $data['quote_number'] = $quote_number;
    -                $data['sale_status'] = '1'; // Suspended
    -
    -                $data['sale_id_num'] = $this->Sale->save($data['sale_status'], $data['cart'], $customer_id, $employee_id, $data['comments'], $invoice_number, $quote_number, $data['payments'], $data['dinner_table'], $data['taxes']);
    +                $data = $this->xss_clean($data);
    +
    +                if($data['sale_id_num'] == -1)
    +                {
    +                    $data['error_message'] = $this->lang->line('sales_transaction_failed');
    +                }
    +                else
    +                {
    +                    $data['barcode'] = $this->barcode_lib->generate_receipt_barcode($data['sale_id']);
    +                    $this->load->view('sales/invoice', $data);
    +                    $this->sale_lib->clear_all();
    +                }
    +            }
    +        }
    +        elseif($this->sale_lib->is_quote_mode())
    +        {
    +            $invoice_number = NULL;
    +            $quote_number = $this->sale_lib->get_quote_number();
    +
    +            if($quote_number == NULL)
    +            {
    +                // generate quote number
    +                $quote_format = $this->config->item('sales_quote_format');
    +                $quote_number = $this->token_lib->render($quote_format);
    +            }
    +
    +            // TODO If duplicate quote then determine the number of employees and repeat until until success or tried the number of employees (if QSEQ was used).
    +            if($this->Sale->check_quote_number_exists($quote_number))
    +            {
    +                $data['error'] = $this->lang->line('sales_quote_number_duplicate');
    +                $this->_reload($data);
    +            }
    +            else
    +            {
    +                $data['invoice_number'] = $invoice_number;
    +                $data['quote_number'] = $quote_number;
    +                $data['sale_status'] = '1'; // Suspended
     
    -                $data['cart'] = $this->sale_lib->sort_and_filter_cart($data['cart']);
    -
    -                $data = $this->xss_clean($data);
    -
    +                $data['sale_id_num'] = $this->Sale->save($data['sale_status'], $data['cart'], $customer_id, $employee_id, $data['comments'], $invoice_number, $quote_number, $data['payments'], $data['dinner_table'], $data['taxes']);
    +                $this->sale_lib->set_suspended_id($data['sale_id_num']);
    +
    +                $data['cart'] = $this->sale_lib->sort_and_filter_cart($data['cart']);
     
    -                $data['barcode'] = NULL;
    +                $data = $this->xss_clean($data);
     
    -//              $this->suspend_quote($quote_number);
    +                $data['barcode'] = NULL;
     
                     $this->load->view('sales/quote', $data);
                     $this->sale_lib->clear_mode();
    @@ -1071,425 +1073,420 @@
             $data['payments'] = $this->sale_lib->get_payments();
             $data['selected_payment_type'] = $this->sale_lib->get_payment_type();
     
    -//      $data['subtotal'] = $this->sale_lib->get_subtotal();
    -//      $data['discounted_subtotal'] = $this->sale_lib->get_subtotal(TRUE);
    -//      $data['tax_exclusive_subtotal'] = $this->sale_lib->get_subtotal(TRUE, TRUE);
    -//      $data['amount_due'] = $this->sale_lib->get_amount_due();
    -//      $data['amount_change'] = $this->sale_lib->get_amount_due() * -1;
    -//      $data['total'] = $this->sale_lib->get_total();
    +        $data['taxes'] = $this->sale_lib->get_taxes();
    +        $data['discount'] = $this->sale_lib->get_discount();
    +        $data['receipt_title'] = $this->lang->line('sales_receipt');
    +        $data['transaction_time'] = date($this->config->item('dateformat') . ' ' . $this->config->item('timeformat'), strtotime($sale_info['sale_time']));
    +        $data['transaction_date'] = date($this->config->item('dateformat'), strtotime($sale_info['sale_time']));
    +        $data['show_stock_locations'] = $this->Stock_location->show_locations('sales');
     
    -        $data['taxes'] = $this->sale_lib->get_taxes();
    -        $data['discount'] = $this->sale_lib->get_discount();
    -        $data['receipt_title'] = $this->lang->line('sales_receipt');
    -        $data['transaction_time'] = date($this->config->item('dateformat') . ' ' . $this->config->item('timeformat'), strtotime($sale_info['sale_time']));
    -        $data['transaction_date'] = date($this->config->item('dateformat'), strtotime($sale_info['sale_time']));
    -        $data['show_stock_locations'] = $this->Stock_location->show_locations('sales');
    -
    -
    -        // Returns 'subtotal', 'total', 'cash_total', 'payment_total', 'amount_due', 'cash_amount_due', 'payments_cover_total'
    -        $totals = $this->sale_lib->get_totals();
    -        $data['subtotal'] = $totals['subtotal'];
    -        $data['discounted_subtotal'] = $totals['discounted_subtotal'];
    -        $data['tax_exclusive_subtotal'] = $totals['tax_exclusive_subtotal'];
    -        $data['cash_total'] = $totals['cash_total'];
    -        $data['cash_amount_due'] = $totals['cash_amount_due'];
    -        $data['non_cash_total'] = $totals['total'];
    -        $data['non_cash_amount_due'] = $totals['amount_due'];
    -        $data['payments_total'] = $totals['payment_total'];
    -        $data['payments_cover_total'] = $totals['payments_cover_total'];
    -
    -        if($this->session->userdata('cash_rounding'))
    -        {
    -            $data['total'] = $totals['cash_total'];
    -            $data['amount_due'] = $totals['cash_amount_due'];
    -        }
    -        else
    -        {
    -            $data['total'] = $totals['total'];
    -            $data['amount_due'] = $totals['amount_due'];
    -        }
    -        $data['amount_change'] = $data['amount_due'] * -1;
    -
    -        $employee_info = $this->Employee->get_info($this->sale_lib->get_employee());
    -        $data['employee'] = $employee_info->first_name . ' ' . $employee_info->last_name[0];
    -        $this->_load_customer_data($this->sale_lib->get_customer(), $data);
    -
    -        $data['sale_id_num'] = $sale_id;
    -        $data['sale_id'] = 'POS ' . $sale_id;
    -        $data['comments'] = $sale_info['comment'];
    -        $data['invoice_number'] = $sale_info['invoice_number'];
    -        $data['quote_number'] = $sale_info['quote_number'];
    -        $data['sale_status'] = $sale_info['sale_status'];
    -        $data['company_info'] = implode("\n", array(
    -            $this->config->item('address'),
    -            $this->config->item('phone'),
    -            $this->config->item('account_number')
    -        ));
    -        $data['barcode'] = $this->barcode_lib->generate_receipt_barcode($data['sale_id']);
    -        $data['print_after_sale'] = FALSE;
    -        if($this->sale_lib->get_mode() == 'sale_invoice')
    -        {
    -            $data['mode_label'] = $this->lang->line('sales_invoice');
    -        }
    -        elseif($this->sale_lib->get_mode() == 'sale_quote')
    -        {
    -            $data['mode_label'] = $this->lang->line('sales_quote');
    -        }
    -
    -        return $this->xss_clean($data);
    -    }
    -
    -    private function _reload($data = array())
    -    {
    -        $data['cart'] = $this->sale_lib->get_cart();
    -        $customer_info = $this->_load_customer_data($this->sale_lib->get_customer(), $data, TRUE);
    -
    -        if($this->config->item('invoice_enable') == '0')
    +
    +        // Returns 'subtotal', 'total', 'cash_total', 'payment_total', 'amount_due', 'cash_amount_due', 'payments_cover_total'
    +        $totals = $this->sale_lib->get_totals();
    +        $data['subtotal'] = $totals['subtotal'];
    +        $data['total'] = $totals['total'];
    +        $data['payments_total'] = $totals['payment_total'];
    +        $data['payments_cover_total'] = $totals['payments_cover_total'];
    +        $data['cash_rounding'] = $this->session->userdata('cash_rounding');
    +        $data['prediscount_subtotal'] = $totals['prediscount_subtotal'];
    +        $data['cash_total'] = $totals['cash_total'];
    +        $data['non_cash_total'] = $totals['total'];
    +        $data['cash_amount_due'] = $totals['cash_amount_due'];
    +        $data['non_cash_amount_due'] = $totals['amount_due'];
    +
    +        if($this->session->userdata('cash_rounding'))
    +        {
    +            $data['total'] = $totals['cash_total'];
    +            $data['amount_due'] = $totals['cash_amount_due'];
    +        }
    +        else
    +        {
    +            $data['total'] = $totals['total'];
    +            $data['amount_due'] = $totals['amount_due'];
    +        }
    +        $data['amount_change'] = $data['amount_due'] * -1;
    +
    +        $employee_info = $this->Employee->get_info($this->sale_lib->get_employee());
    +        $data['employee'] = $employee_info->first_name . ' ' . $employee_info->last_name[0];
    +        $this->_load_customer_data($this->sale_lib->get_customer(), $data);
    +
    +        $data['sale_id_num'] = $sale_id;
    +        $data['sale_id'] = 'POS ' . $sale_id;
    +        $data['comments'] = $sale_info['comment'];
    +        $data['invoice_number'] = $sale_info['invoice_number'];
    +        $data['quote_number'] = $sale_info['quote_number'];
    +        $data['sale_status'] = $sale_info['sale_status'];
    +        $data['company_info'] = implode("\n", array(
    +            $this->config->item('address'),
    +            $this->config->item('phone'),
    +            $this->config->item('account_number')
    +        ));
    +        $data['barcode'] = $this->barcode_lib->generate_receipt_barcode($data['sale_id']);
    +        $data['print_after_sale'] = FALSE;
    +        if($this->sale_lib->get_mode() == 'sale_invoice')
    +        {
    +            $data['mode_label'] = $this->lang->line('sales_invoice');
    +        }
    +        elseif($this->sale_lib->get_mode() == 'sale_quote')
    +        {
    +            $data['mode_label'] = $this->lang->line('sales_quote');
    +        }
    +
    +        return $this->xss_clean($data);
    +    }
    +
    +    private function _reload($data = array())
    +    {
    +        $data['cart'] = $this->sale_lib->get_cart();
    +        $customer_info = $this->_load_customer_data($this->sale_lib->get_customer(), $data, TRUE);
    +
    +        if($this->config->item('invoice_enable') == '0')
    +        {
    +            $data['modes'] = array(
    +                'sale' => $this->lang->line('sales_sale'),
    +                'return' => $this->lang->line('sales_return'));
    +        }
    +        else
             {
                 $data['modes'] = array(
                     'sale' => $this->lang->line('sales_sale'),
    -                'return' => $this->lang->line('sales_return'));
    -        }
    -        else
    -        {
    -            $data['modes'] = array(
    -                'sale' => $this->lang->line('sales_sale'),
    -                'sale_invoice' => $this->lang->line('sales_sale_by_invoice'),
    -                'sale_quote' => $this->lang->line('sales_quote'),
    -                'return' => $this->lang->line('sales_return'));
    -        }
    -        $data['mode'] = $this->sale_lib->get_mode();
    -        $data['empty_tables'] = $this->sale_lib->get_empty_tables();
    -        $data['selected_table'] = $this->sale_lib->get_dinner_table();
    -        $data['stock_locations'] = $this->Stock_location->get_allowed_locations('sales');
    -        $data['stock_location'] = $this->sale_lib->get_sale_location();
    -        $data['tax_exclusive_subtotal'] = $this->sale_lib->get_subtotal(TRUE, TRUE);
    -
    -        $data['taxes'] = $this->sale_lib->get_taxes();
    -        $data['discount'] = $this->sale_lib->get_discount();
    -        $data['payments'] = $this->sale_lib->get_payments();
    -
    -        // Returns 'subtotal', 'total', 'cash_total', 'payment_total', 'amount_due', 'cash_amount_due', 'payments_cover_total'
    -        $totals = $this->sale_lib->get_totals();
    -        $data['subtotal'] = $totals['discounted_subtotal'];
    -        $data['cash_total'] = $totals['cash_total'];
    -        $data['cash_amount_due'] = $totals['cash_amount_due'];
    -        $data['non_cash_total'] =$totals['total'];
    -        $data['non_cash_amount_due'] =$totals['amount_due'];
    -        $data['payments_total'] = $totals['payment_total'];
    -        $data['payments_cover_total'] = $totals['payments_cover_total'];
    -        $data['cash_rounding'] = $this->session->userdata('cash_rounding');
    -
    -        if($data['cash_rounding'])
    +                'sale_invoice' => $this->lang->line('sales_sale_by_invoice'),
    +                'sale_quote' => $this->lang->line('sales_quote'),
    +                'return' => $this->lang->line('sales_return'));
    +        }
    +        $data['mode'] = $this->sale_lib->get_mode();
    +        $data['empty_tables'] = $this->sale_lib->get_empty_tables();
    +        $data['selected_table'] = $this->sale_lib->get_dinner_table();
    +        $data['stock_locations'] = $this->Stock_location->get_allowed_locations('sales');
    +        $data['stock_location'] = $this->sale_lib->get_sale_location();
    +        $data['tax_exclusive_subtotal'] = $this->sale_lib->get_subtotal(TRUE, TRUE);
    +        $data['taxes'] = $this->sale_lib->get_taxes();
    +        $data['discount'] = $this->sale_lib->get_discount();
    +        $data['payments'] = $this->sale_lib->get_payments();
    +
    +        // Returns 'subtotal', 'total', 'cash_total', 'payment_total', 'amount_due', 'cash_amount_due', 'payments_cover_total'
    +        $totals = $this->sale_lib->get_totals();
    +        $data['subtotal'] = $totals['subtotal'];
    +        $data['total'] = $totals['total'];
    +        $data['payments_total'] = $totals['payment_total'];
    +        $data['payments_cover_total'] = $totals['payments_cover_total'];
    +        $data['cash_rounding'] = $this->session->userdata('cash_rounding');
    +        $data['prediscount_subtotal'] = $totals['prediscount_subtotal'];
    +        $data['cash_total'] = $totals['cash_total'];
    +        $data['non_cash_total'] = $totals['total'];
    +        $data['cash_amount_due'] = $totals['cash_amount_due'];
    +        $data['non_cash_amount_due'] = $totals['amount_due'];
    +
    +        if($data['cash_rounding'])
    +        {
    +            $data['total'] = $totals['cash_total'];
    +            $data['amount_due'] = $totals['cash_amount_due'];
    +        }
    +        else
             {
    -            $data['total'] = $totals['cash_total'];
    -            $data['amount_due'] = $totals['cash_amount_due'];
    +            $data['total'] = $totals['total'];
    +            $data['amount_due'] = $totals['amount_due'];
             }
    -        else
    -        {
    -            $data['total'] = $totals['total'];
    -            $data['amount_due'] = $totals['amount_due'];
    -        }
    -        $data['amount_change'] = $data['amount_due'] * -1;
    -
    -        $data['comment'] = $this->sale_lib->get_comment();
    -        $data['email_receipt'] = $this->sale_lib->get_email_receipt();
    -        $data['selected_payment_type'] = $this->sale_lib->get_payment_type();
    -        if($customer_info && $this->config->item('customer_reward_enable') == TRUE)
    -        {
    -            $data['payment_options'] = $this->Sale->get_payment_options(TRUE, TRUE);
    -        }
    -        else
    +        $data['amount_change'] = $data['amount_due'] * -1;
    +
    +        $data['comment'] = $this->sale_lib->get_comment();
    +        $data['email_receipt'] = $this->sale_lib->get_email_receipt();
    +        $data['selected_payment_type'] = $this->sale_lib->get_payment_type();
    +        if($customer_info && $this->config->item('customer_reward_enable') == TRUE)
    +        {
    +            $data['payment_options'] = $this->Sale->get_payment_options(TRUE, TRUE);
    +        }
    +        else
    +        {
    +            $data['payment_options'] = $this->Sale->get_payment_options();
    +        }
    +        $quote_number = $this->sale_lib->get_quote_number();
    +        if($quote_number != NULL)
             {
    -            $data['payment_options'] = $this->Sale->get_payment_options();
    +            $data['quote_number'] = $quote_number;
             }
    -        $quote_number = $this->sale_lib->get_quote_number();
    -        if($quote_number != NULL)
    -        {
    -            $data['quote_number'] = $quote_number;
    -        }
    +
    +        $data['items_module_allowed'] = $this->Employee->has_grant('items', $this->Employee->get_logged_in_employee_info()->person_id);
    +
    +        $invoice_format = $this->config->item('sales_invoice_format');
    +        $data['invoice_format'] = $invoice_format;
     
    -        $data['items_module_allowed'] = $this->Employee->has_grant('items', $this->Employee->get_logged_in_employee_info()->person_id);
    -
    -        $invoice_format = $this->config->item('sales_invoice_format');
    -        $data['invoice_format'] = $invoice_format;
    -
    -        $this->set_invoice_number($invoice_format);
    -        $data['invoice_number'] = $invoice_format;
    -
    -        $data['invoice_number_enabled'] = $this->sale_lib->is_invoice_mode();
    -        $data['print_after_sale'] = $this->sale_lib->is_print_after_sale();
    -        $data['quote_or_invoice_mode'] = $data['mode'] == 'sale_invoice' || $data['mode'] == 'sale_quote';
    -        $data['sales_or_return_mode'] = $data['mode'] == 'sale' || $data['mode'] == 'return';
    -        if($this->sale_lib->get_mode() == 'sale_invoice')
    -        {
    -            $data['mode_label'] = $this->lang->line('sales_invoice');
    -        }
    -        elseif($this->sale_lib->get_mode() == 'sale_quote')
    -        {
    -            $data['mode_label'] = $this->lang->line('sales_quote');
    -        }
    -        else
    -        {
    -            $data['mode_label'] = $this->lang->line('sales_receipt');
    -        }
    -        $data = $this->xss_clean($data);
    -
    -        $this->load->view("sales/register", $data);
    -    }
    -
    -    public function receipt($sale_id)
    -    {
    -        $data = $this->_load_sale_data($sale_id);
    -        $this->load->view('sales/receipt', $data);
    -        $this->sale_lib->clear_all();
    -    }
    -
    -    public function invoice($sale_id)
    -    {
    -        $data = $this->_load_sale_data($sale_id);
    -        $this->load->view('sales/invoice', $data);
    -        $this->sale_lib->clear_all();
    -    }
    -
    -    public function edit($sale_id)
    -    {
    -        $data = array();
    -
    -        $data['employees'] = array();
    -        foreach($this->Employee->get_all()->result() as $employee)
    -        {
    -            foreach(get_object_vars($employee) as $property => $value)
    -            {
    -                $employee->$property = $this->xss_clean($value);
    -            }
    -
    -            $data['employees'][$employee->person_id] = $employee->first_name . ' ' . $employee->last_name;
    -        }
    +        $this->set_invoice_number($invoice_format);
    +        $data['invoice_number'] = $invoice_format;
    +
    +        $data['invoice_number_enabled'] = $this->sale_lib->is_invoice_mode();
    +        $data['print_after_sale'] = $this->sale_lib->is_print_after_sale();
    +        $data['quote_or_invoice_mode'] = $data['mode'] == 'sale_invoice' || $data['mode'] == 'sale_quote';
    +        $data['sales_or_return_mode'] = $data['mode'] == 'sale' || $data['mode'] == 'return';
    +        if($this->sale_lib->get_mode() == 'sale_invoice')
    +        {
    +            $data['mode_label'] = $this->lang->line('sales_invoice');
    +        }
    +        elseif($this->sale_lib->get_mode() == 'sale_quote')
    +        {
    +            $data['mode_label'] = $this->lang->line('sales_quote');
    +        }
    +        else
    +        {
    +            $data['mode_label'] = $this->lang->line('sales_receipt');
    +        }
    +        $data = $this->xss_clean($data);
    +
    +        $this->load->view("sales/register", $data);
    +    }
    +
    +    public function receipt($sale_id)
    +    {
    +        $data = $this->_load_sale_data($sale_id);
    +        $this->load->view('sales/receipt', $data);
    +        $this->sale_lib->clear_all();
    +    }
    +
    +    public function invoice($sale_id)
    +    {
    +        $data = $this->_load_sale_data($sale_id);
    +        $this->load->view('sales/invoice', $data);
    +        $this->sale_lib->clear_all();
    +    }
    +
    +    public function edit($sale_id)
    +    {
    +        $data = array();
    +
    +        $data['employees'] = array();
    +        foreach($this->Employee->get_all()->result() as $employee)
    +        {
    +            foreach(get_object_vars($employee) as $property => $value)
    +            {
    +                $employee->$property = $this->xss_clean($value);
    +            }
    +
    +            $data['employees'][$employee->person_id] = $employee->first_name . ' ' . $employee->last_name;
    +        }
    +
    +        $sale_info = $this->xss_clean($this->Sale->get_info($sale_id)->row_array());
    +        $data['selected_customer_name'] = $sale_info['customer_name'];
    +        $data['selected_customer_id'] = $sale_info['customer_id'];
    +        $data['sale_info'] = $sale_info;
     
    -        $sale_info = $this->xss_clean($this->Sale->get_info($sale_id)->row_array());
    -        $data['selected_customer_name'] = $sale_info['customer_name'];
    -        $data['selected_customer_id'] = $sale_info['customer_id'];
    -        $data['sale_info'] = $sale_info;
    -
    -        $data['payments'] = array();
    -        foreach($this->Sale->get_sale_payments($sale_id)->result() as $payment)
    -        {
    -            foreach(get_object_vars($payment) as $property => $value)
    -            {
    -                $payment->$property = $this->xss_clean($value);
    -            }
    -            $data['payments'][] = $payment;
    -        }
    +        $data['payments'] = array();
    +        foreach($this->Sale->get_sale_payments($sale_id)->result() as $payment)
    +        {
    +            foreach(get_object_vars($payment) as $property => $value)
    +            {
    +                $payment->$property = $this->xss_clean($value);
    +            }
    +            $data['payments'][] = $payment;
    +        }
    +
    +        // don't allow gift card to be a payment option in a sale transaction edit because it's a complex change
    +        $data['payment_options'] = $this->xss_clean($this->Sale->get_payment_options(FALSE));
    +        $this->load->view('sales/form', $data);
    +    }
     
    -        // don't allow gift card to be a payment option in a sale transaction edit because it's a complex change
    -        $data['payment_options'] = $this->xss_clean($this->Sale->get_payment_options(FALSE));
    -        $this->load->view('sales/form', $data);
    -    }
    +    public function delete($sale_id = -1, $update_inventory = TRUE)
    +    {
    +        $employee_id = $this->Employee->get_logged_in_employee_info()->person_id;
    +        $sale_ids = $sale_id == -1 ? $this->input->post('ids') : array($sale_id);
     
    -    public function delete($sale_id = -1, $update_inventory = TRUE)
    -    {
    -        $employee_id = $this->Employee->get_logged_in_employee_info()->person_id;
    -        $sale_ids = $sale_id == -1 ? $this->input->post('ids') : array($sale_id);
    -
    -        if($this->Sale->delete_list($sale_ids, $employee_id, $update_inventory))
    +        if($this->Sale->delete_list($sale_ids, $employee_id, $update_inventory))
    +        {
    +            echo json_encode(array('success' => TRUE, 'message' => $this->lang->line('sales_successfully_deleted') . ' ' .
    +                count($sale_ids) . ' ' . $this->lang->line('sales_one_or_multiple'), 'ids' => $sale_ids));
    +        }
    +        else
             {
    -            echo json_encode(array('success' => TRUE, 'message' => $this->lang->line('sales_successfully_deleted') . ' ' .
    -                count($sale_ids) . ' ' . $this->lang->line('sales_one_or_multiple'), 'ids' => $sale_ids));
    -        }
    -        else
    -        {
    -            echo json_encode(array('success' => FALSE, 'message' => $this->lang->line('sales_unsuccessfully_deleted')));
    -        }
    -    }
    -
    -    public function save($sale_id = -1)
    -    {
    -        $newdate = $this->input->post('date');
    -        $date_formatter = date_create_from_format($this->config->item('dateformat') . ' ' . $this->config->item('timeformat'), $newdate);
    -        $sale_data = array(
    -            'sale_time' => $date_formatter->format('Y-m-d H:i:s'),
    -            'customer_id' => $this->input->post('customer_id') != '' ? $this->input->post('customer_id') : NULL,
    -            'employee_id' => $this->input->post('employee_id'),
    -            'comment' => $this->input->post('comment'),
    -            'invoice_number' => $this->input->post('invoice_number') != '' ? $this->input->post('invoice_number') : NULL
    -        );
    -
    -        // go through all the payment type input from the form, make sure the form matches the name and iterator number
    -        $payments = array();
    -        $number_of_payments = $this->input->post('number_of_payments');
    -        for($i = 0; $i < $number_of_payments; ++$i)
    -        {
    -            $payment_amount = $this->input->post('payment_amount_' . $i);
    -            $payment_type = $this->input->post('payment_type_' . $i);
    -            // remove any 0 payment if by mistake any was introduced at sale time
    -            if($payment_amount != 0)
    -            {
    -                // search for any payment of the same type that was already added, if that's the case add up the new payment amount
    -                $key = FALSE;
    -                if(!empty($payments))
    -                {
    -                    // search in the multi array the key of the entry containing the current payment_type
    -                    // NOTE: in PHP5.5 the array_map could be replaced by an array_column
    -                    $key = array_search($payment_type, array_map(function ($v)
    -                    {
    -                        return $v['payment_type'];
    -                    }, $payments));
    -                }
    -
    -                // if no previous payment is found add a new one
    -                if($key === FALSE)
    -                {
    -                    $payments[] = array('payment_type' => $payment_type, 'payment_amount' => $payment_amount);
    +            echo json_encode(array('success' => FALSE, 'message' => $this->lang->line('sales_unsuccessfully_deleted')));
    +        }
    +    }
    +
    +    public function save($sale_id = -1)
    +    {
    +        $newdate = $this->input->post('date');
    +        $date_formatter = date_create_from_format($this->config->item('dateformat') . ' ' . $this->config->item('timeformat'), $newdate);
    +        $sale_data = array(
    +            'sale_time' => $date_formatter->format('Y-m-d H:i:s'),
    +            'customer_id' => $this->input->post('customer_id') != '' ? $this->input->post('customer_id') : NULL,
    +            'employee_id' => $this->input->post('employee_id'),
    +            'comment' => $this->input->post('comment'),
    +            'invoice_number' => $this->input->post('invoice_number') != '' ? $this->input->post('invoice_number') : NULL
    +        );
    +
    +        // go through all the payment type input from the form, make sure the form matches the name and iterator number
    +        $payments = array();
    +        $number_of_payments = $this->input->post('number_of_payments');
    +        for($i = 0; $i < $number_of_payments; ++$i)
    +        {
    +            $payment_amount = $this->input->post('payment_amount_' . $i);
    +            $payment_type = $this->input->post('payment_type_' . $i);
    +            // remove any 0 payment if by mistake any was introduced at sale time
    +            if($payment_amount != 0)
    +            {
    +                // search for any payment of the same type that was already added, if that's the case add up the new payment amount
    +                $key = FALSE;
    +                if(!empty($payments))
    +                {
    +                    // search in the multi array the key of the entry containing the current payment_type
    +                    // NOTE: in PHP5.5 the array_map could be replaced by an array_column
    +                    $key = array_search($payment_type, array_map(function ($v)
    +                    {
    +                        return $v['payment_type'];
    +                    }, $payments));
    +                }
    +
    +                // if no previous payment is found add a new one
    +                if($key === FALSE)
    +                {
    +                    $payments[] = array('payment_type' => $payment_type, 'payment_amount' => $payment_amount);
    +                }
    +                else
    +                {
    +                    // add up the new payment amount to an existing payment type
    +                    $payments[$key]['payment_amount'] += $payment_amount;
                     }
    -                else
    -                {
    -                    // add up the new payment amount to an existing payment type
    -                    $payments[$key]['payment_amount'] += $payment_amount;
    -                }
    -            }
    +            }
    +        }
    +
    +        if($this->Sale->update($sale_id, $sale_data, $payments))
    +        {
    +            echo json_encode(array('success' => TRUE, 'message' => $this->lang->line('sales_successfully_updated'), 'id' => $sale_id));
             }
    -
    -        if($this->Sale->update($sale_id, $sale_data, $payments))
    -        {
    -            echo json_encode(array('success' => TRUE, 'message' => $this->lang->line('sales_successfully_updated'), 'id' => $sale_id));
    -        }
    -        else
    -        {
    -            echo json_encode(array('success' => FALSE, 'message' => $this->lang->line('sales_unsuccessfully_updated'), 'id' => $sale_id));
    -        }
    -    }
    -
    -    public function cancel()
    -    {
    -        $this->sale_lib->clear_all();
    -        $this->_reload();
    -    }
    -
    -    public function discard_quote()
    -    {
    -        $suspended_id = $this->sale_lib->get_suspended_id();
    -        $this->sale_lib->clear_all();
    -        $this->Sale->delete_suspended_sale($suspended_id);
    -        $this->_reload();
    -    }
    -
    -    public function suspend()
    -    {
    -        $dinner_table = $this->sale_lib->get_dinner_table();
    -        $cart = $this->sale_lib->get_cart();
    -        $payments = $this->sale_lib->get_payments();
    -        $employee_id = $this->Employee->get_logged_in_employee_info()->person_id;
    -        $customer_id = $this->sale_lib->get_customer();
    -        $customer_info = $this->Customer->get_info($customer_id);
    -        $invoice_number = $this->_is_custom_invoice_number($customer_info) ? $this->sale_lib->get_invoice_number() : NULL;
    -        $quote_number = $this->sale_lib->get_quote_number();
    -        $comment = $this->sale_lib->get_comment();
    -        $sale_status = '1';
    -
    -        $data = array();
    -        $sales_taxes = array();
    -        if($this->Sale->save($sale_status, $cart, $customer_id, $employee_id, $comment, $invoice_number, $quote_number, $payments, $dinner_table, $sales_taxes) == '-1')
    -        {
    -            $data['error'] = $this->lang->line('sales_unsuccessfully_suspended_sale');
    -        }
    -        else
    -        {
    -            $data['success'] = $this->lang->line('sales_successfully_suspended_sale');
    -        }
    -
    -        $this->sale_lib->clear_all();
    -        $this->_reload($data);
    -    }
    -
    -    public function suspend_quote($quote_number)
    -    {
    -        $cart = $this->sale_lib->get_cart();
    -        $payments = $this->sale_lib->get_payments();
    -        $employee_id = $this->Employee->get_logged_in_employee_info()->person_id;
    -        $customer_id = $this->sale_lib->get_customer();
    -        $customer_info = $this->Customer->get_info($customer_id);
    -        $dinner_table = $this->sale_lib->get_dinner_table();
    -        $invoice_number = $this->_is_custom_invoice_number($customer_info) ? $this->sale_lib->get_invoice_number() : NULL;
    -        $comment = $this->sale_lib->get_comment();
    -        $sale_status = '2'; // Suspend
    -
    -        $data = array();
    -        $sales_taxes = array();
    -        if($this->Sale->save($sale_status, $cart, $customer_id, $employee_id, $comment, $invoice_number, $quote_number, $payments, $dinner_table, $sales_taxes) == '-1')
    -        {
    -            $data['error'] = $this->lang->line('sales_unsuccessfully_suspended_sale');
    -        }
    -        else
    -        {
    -            $data['success'] = $this->lang->line('sales_successfully_suspended_sale');
    -        }
    -    }
    -
    -    public function suspended()
    -    {
    -        $customer_id = $this->sale_lib->get_customer();
    -        $data = array();
    -        $data['suspended_sales'] = $this->xss_clean($this->Sale->get_all_suspended($customer_id));
    -        $data['dinner_table_enable'] = $this->config->item('dinner_table_enable');
    -        $this->load->view('sales/suspended', $data);
    -    }
    -
    -    /*
    -     * We will eventually drop the current set of "suspended" tables since suspended sales
    -     * are now stored in the sales tables with a sale_status value of suspended.
    -     */
    -    public function unsuspend()
    -    {
    -        $sale_id = $this->input->post('suspended_sale_id');
    -        $this->sale_lib->clear_all();
    -
    -        if($sale_id > 0)
    +        else
    +        {
    +            echo json_encode(array('success' => FALSE, 'message' => $this->lang->line('sales_unsuccessfully_updated'), 'id' => $sale_id));
    +        }
    +    }
    +
    +    public function cancel()
    +    {
    +        $this->sale_lib->clear_all();
    +        $this->_reload();
    +    }
    +
    +    public function discard_quote()
    +    {
    +        $suspended_id = $this->sale_lib->get_suspended_id();
    +        $this->sale_lib->clear_all();
    +        $this->Sale->delete_suspended_sale($suspended_id);
    +        $this->_reload();
    +    }
    +
    +    public function suspend()
    +    {
    +        $dinner_table = $this->sale_lib->get_dinner_table();
    +        $cart = $this->sale_lib->get_cart();
    +        $payments = $this->sale_lib->get_payments();
    +        $employee_id = $this->Employee->get_logged_in_employee_info()->person_id;
    +        $customer_id = $this->sale_lib->get_customer();
    +        $customer_info = $this->Customer->get_info($customer_id);
    +        $invoice_number = $this->_is_custom_invoice_number($customer_info) ? $this->sale_lib->get_invoice_number() : NULL;
    +        $quote_number = $this->sale_lib->get_quote_number();
    +        $comment = $this->sale_lib->get_comment();
    +        $sale_status = '1';
    +
    +        $data = array();
    +        $sales_taxes = array();
    +        if($this->Sale->save($sale_status, $cart, $customer_id, $employee_id, $comment, $invoice_number, $quote_number, $payments, $dinner_table, $sales_taxes) == '-1')
    +        {
    +            $data['error'] = $this->lang->line('sales_unsuccessfully_suspended_sale');
    +        }
    +        else
    +        {
    +            $data['success'] = $this->lang->line('sales_successfully_suspended_sale');
    +        }
    +
    +        $this->sale_lib->clear_all();
    +        $this->_reload($data);
    +    }
    +
    +    public function suspend_quote($quote_number)
    +    {
    +        $cart = $this->sale_lib->get_cart();
    +        $payments = $this->sale_lib->get_payments();
    +        $employee_id = $this->Employee->get_logged_in_employee_info()->person_id;
    +        $customer_id = $this->sale_lib->get_customer();
    +        $customer_info = $this->Customer->get_info($customer_id);
    +        $dinner_table = $this->sale_lib->get_dinner_table();
    +        $invoice_number = $this->_is_custom_invoice_number($customer_info) ? $this->sale_lib->get_invoice_number() : NULL;
    +        $comment = $this->sale_lib->get_comment();
    +        $sale_status = '2'; // Suspend
    +
    +        $data = array();
    +        $sales_taxes = array();
    +        if($this->Sale->save($sale_status, $cart, $customer_id, $employee_id, $comment, $invoice_number, $quote_number, $payments, $dinner_table, $sales_taxes) == '-1')
    +        {
    +            $data['error'] = $this->lang->line('sales_unsuccessfully_suspended_sale');
    +        }
    +        else
    +        {
    +            $data['success'] = $this->lang->line('sales_successfully_suspended_sale');
    +        }
    +    }
    +
    +    public function suspended()
    +    {
    +        $customer_id = $this->sale_lib->get_customer();
    +        $data = array();
    +        $data['suspended_sales'] = $this->xss_clean($this->Sale->get_all_suspended($customer_id));
    +        $data['dinner_table_enable'] = $this->config->item('dinner_table_enable');
    +        $this->load->view('sales/suspended', $data);
    +    }
    +
    +    /*
    +     * We will eventually drop the current set of "suspended" tables since suspended sales
    +     * are now stored in the sales tables with a sale_status value of suspended.
    +     */
    +    public function unsuspend()
    +    {
    +        $sale_id = $this->input->post('suspended_sale_id');
    +        $this->sale_lib->clear_all();
    +
    +        if($sale_id > 0)
    +        {
    +            $this->sale_lib->copy_entire_sale($sale_id);
    +            $this->Sale->delete_suspended_sale($sale_id);
    +        }
    +        else
             {
    -            $this->sale_lib->copy_entire_sale($sale_id);
    -            $this->Sale->delete_suspended_sale($sale_id);
    -        }
    -        else
    -        {
    -            // This will unsuspended older suspended sales
    -            $sale_id = $sale_id * -1;
    -            $this->sale_lib->copy_entire_suspended_tables_sale($sale_id);
    -            $this->Sale_suspended->delete($sale_id);
    -        }
    -
    -        $this->_reload();
    -    }
    -
    -    public function check_invoice_number()
    -    {
    -        $sale_id = $this->input->post('sale_id');
    -        $invoice_number = $this->input->post('invoice_number');
    -        $exists = !empty($invoice_number) && $this->Sale->check_invoice_number_exists($invoice_number, $sale_id);
    -        echo !$exists ? 'true' : 'false';
    -    }
    -
    -    public function get_filtered($cart)
    -    {
    -        $filtered_cart = array();
    -        foreach($cart as $id => $item)
    -        {
    -            if($item['print_option'] == '0') // always include
    -            {
    -                $filtered_cart[$id] = $item;
    -            }
    -            elseif($item['print_option'] == '1' && $item['price'] != 0)  // include only if the price is not zero
    -            {
    -                $filtered_cart[$id] = $item;
    -            }
    -            // print_option 2 is never included
    -        }
    -
    -        return $filtered_cart;
    -    }
    -}
    -
    -?>
    -
    + // This will unsuspended older suspended sales + $sale_id = $sale_id * -1; + $this->sale_lib->copy_entire_suspended_tables_sale($sale_id); + $this->Sale_suspended->delete($sale_id); + } + + $this->_reload(); + } + + public function check_invoice_number() + { + $sale_id = $this->input->post('sale_id'); + $invoice_number = $this->input->post('invoice_number'); + $exists = !empty($invoice_number) && $this->Sale->check_invoice_number_exists($invoice_number, $sale_id); + echo !$exists ? 'true' : 'false'; + } + + public function get_filtered($cart) + { + $filtered_cart = array(); + foreach($cart as $id => $item) + { + if($item['print_option'] == '0') // always include + { + $filtered_cart[$id] = $item; + } + elseif($item['print_option'] == '1' && $item['price'] != 0) // include only if the price is not zero + { + $filtered_cart[$id] = $item; + } + // print_option 2 is never included + } + + return $filtered_cart; + } +} + +?> + - + diff --git a/docs/source-class-Secure_Controller.html b/docs/source-class-Secure_Controller.html index b691edccd..c8e0ed3b0 100644 --- a/docs/source-class-Secure_Controller.html +++ b/docs/source-class-Secure_Controller.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -322,6 +324,6 @@ - + diff --git a/docs/source-class-Sms_lib.html b/docs/source-class-Sms_lib.html index af3c12d67..dbde79646 100644 --- a/docs/source-class-Sms_lib.html +++ b/docs/source-class-Sms_lib.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,70 +207,80 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
    - 
    -class Sms_lib
    -{
    -    private $CI;
    -
    -    public function __construct()
    -    {
    -        $this->CI =& get_instance();
    -    }
    -    
    -    /*
    -     * SMS sending function
    -     * Example of use: $response = sendSMS('4477777777', 'My test message');
    -     */
    -    public function sendSMS($phone, $message)
    -    {
    -        $username   = $this->CI->config->item('msg_uid');
    -        $password   = $this->CI->encryption->decrypt($this->CI->config->item('msg_pwd'));
    -        $originator = $this->CI->config->item('msg_src');
    -        
    -        $response = FALSE;
    -        
    -        // if any of the parameters is empty return with a FALSE
    -        if(empty($username) || empty($password) || empty($phone) || empty($message) || empty($originator))
    -        {
    -            //echo $username . ' ' . $password . ' ' . $phone . ' ' . $message . ' ' . $originator;
    -        }
    -        else
    -        {   
    -            $response = TRUE;
    -            
    -            // make sure passed string is url encoded
    -            $message = rawurlencode($message);
    -            
    -            // add call to send a message via 3rd party API here
    -            // Some examples
    -
    -            /*
    -            $url = "http://xxx.xxx.xxx.xxx/send_sms?username=$username&password=$password&src=$originator&dst=$phone&msg=$message&dr=1";
    -             
    -            $c = curl_init(); 
    -            curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); 
    -            curl_setopt($c, CURLOPT_URL, $url); 
    -            $response = curl_exec($c); 
    -            curl_close($c);
    -            */
    -            
    -            // This is a textmarketer.co.uk API call, see: http://wiki.textmarketer.co.uk/display/DevDoc/Text+Marketer+Developer+Documentation+-+Wiki+Home
    -            /*
    -            $url = 'https://api.textmarketer.co.uk/gateway/'."?username=$username&password=$password&option=xml";
    -            $url .= "&to=$phone&message=".urlencode($message).'&orig='.urlencode($originator);
    -            $fp = fopen($url, 'r');
    -            $response = fread($fp, 1024);
    -            */
    -        }
    -
    -        return $response;
    -    }
    -}
    -
    -?>
    -
    + +/** + * SMS library + * + * Library with utilities to send texts via SMS Gateway (requires proxy implementation) + * + * @link github.com/jekkos/opensourcepos + * @since 3.0 + * @author RamkrishnaMondal, daN4cat (FrancescoUK) + */ + +class Sms_lib +{ + private $CI; + + public function __construct() + { + $this->CI =& get_instance(); + } + + /* + * SMS sending function + * Example of use: $response = sendSMS('4477777777', 'My test message'); + */ + public function sendSMS($phone, $message) + { + $username = $this->CI->config->item('msg_uid'); + $password = $this->CI->encryption->decrypt($this->CI->config->item('msg_pwd')); + $originator = $this->CI->config->item('msg_src'); + + $response = FALSE; + + // if any of the parameters is empty return with a FALSE + if(empty($username) || empty($password) || empty($phone) || empty($message) || empty($originator)) + { + //echo $username . ' ' . $password . ' ' . $phone . ' ' . $message . ' ' . $originator; + } + else + { + $response = TRUE; + + // make sure passed string is url encoded + $message = rawurlencode($message); + + // add call to send a message via 3rd party API here + // Some examples + + /* + $url = "http://xxx.xxx.xxx.xxx/send_sms?username=$username&password=$password&src=$originator&dst=$phone&msg=$message&dr=1"; + + $c = curl_init(); + curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($c, CURLOPT_URL, $url); + $response = curl_exec($c); + curl_close($c); + */ + + // This is a textmarketer.co.uk API call, see: http://wiki.textmarketer.co.uk/display/DevDoc/Text+Marketer+Developer+Documentation+-+Wiki+Home + /* + $url = 'https://api.textmarketer.co.uk/gateway/'."?username=$username&password=$password&option=xml"; + $url .= "&to=$phone&message=".urlencode($message).'&orig='.urlencode($originator); + $fp = fopen($url, 'r'); + $response = fread($fp, 1024); + */ + } + + return $response; + } +} + +?> + - + diff --git a/docs/source-class-Specific_customer.html b/docs/source-class-Specific_customer.html index b69b63345..7b90b157d 100644 --- a/docs/source-class-Specific_customer.html +++ b/docs/source-class-Specific_customer.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,114 +207,120 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     
     require_once("Report.php");
     
     class Specific_customer extends Report
     {
    -    function __construct()
    +    public function create(array $inputs)
         {
    -        parent::__construct();
    -    }
    -
    -    public function create(array $inputs)
    -    {
    -        //Create our temp tables to work with the data in our report
    -        $this->Sale->create_temp_table($inputs);
    -    }
    -
    -    public function getDataColumns()
    -    {
    -        return array(
    -            'summary' => array(
    -                array('id' => $this->lang->line('reports_sale_id')),
    -                array('sale_date' => $this->lang->line('reports_date')),
    -                array('quantity' => $this->lang->line('reports_quantity')),
    -                array('sold_by' => $this->lang->line('reports_sold_by')),
    -                array('subtotal' => $this->lang->line('reports_subtotal'), 'sorter' => 'number_sorter'),
    -                array('tax' => $this->lang->line('reports_tax'), 'sorter' => 'number_sorter'),
    -                array('total' => $this->lang->line('reports_total'), 'sorter' => 'number_sorter'),
    -                array('cost' => $this->lang->line('reports_cost'), 'sorter' => 'number_sorter'),
    -                array('profit' => $this->lang->line('reports_profit'), 'sorter' => 'number_sorter'),
    -                array('payment_type' => $this->lang->line('reports_payment_type')),
    -                array('comments' => $this->lang->line('reports_comments'))),
    -            'details' => array(
    -                $this->lang->line('reports_name'),
    -                $this->lang->line('reports_category'),
    -                $this->lang->line('reports_serial_number'),
    -                $this->lang->line('reports_description'),
    -                $this->lang->line('reports_quantity'),
    -                $this->lang->line('reports_subtotal'),
    -                $this->lang->line('reports_tax'),
    -                $this->lang->line('reports_total'),
    -                $this->lang->line('reports_cost'),
    -                $this->lang->line('reports_profit'),
    -                $this->lang->line('reports_discount')),
    -            'details_rewards' => array(
    -                $this->lang->line('reports_used'),
    -                $this->lang->line('reports_earned'))
    -        );
    -    }
    -
    -    public function getData(array $inputs)
    -    {
    -        $this->db->select('sale_id, MAX(sale_date) AS sale_date, SUM(quantity_purchased) AS items_purchased, MAX(employee_name) AS employee_name, SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit, MAX(payment_type) AS payment_type, MAX(comment) AS comment');
    -        $this->db->from('sales_items_temp');
    -        $this->db->where('customer_id', $inputs['customer_id']);
    -
    -        if ($inputs['sale_type'] == 'sales')
    -        {
    -            $this->db->where('quantity_purchased > 0');
    -        }
    -        elseif ($inputs['sale_type'] == 'returns')
    -        {
    -            $this->db->where('quantity_purchased < 0');
    -        }
    -
    -        $this->db->group_by('sale_id');
    -        $this->db->order_by('MAX(sale_date)');
    -
    -        $data = array();
    -        $data['summary'] = $this->db->get()->result_array();
    -        $data['details'] = array();
    -
    -        foreach($data['summary'] as $key=>$value)
    -        {
    -            $this->db->select('name, category, serialnumber, description, quantity_purchased, subtotal, tax, total, cost, profit, discount_percent');
    -            $this->db->from('sales_items_temp');
    -            $this->db->where('sale_id', $value['sale_id']);
    -            $data['details'][$key] = $this->db->get()->result_array();
    -            $this->db->select('used, earned');
    -            $this->db->from('sales_reward_points');
    -            $this->db->where('sale_id', $value['sale_id']);
    -            $data['rewards'][$key] = $this->db->get()->result_array();
    -        }
    -
    -        return $data;
    -    }
    -
    -    public function getSummaryData(array $inputs)
    -    {
    -        $this->db->select('SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit');
    -        $this->db->from('sales_items_temp');
    -        $this->db->where('customer_id', $inputs['customer_id']);
    +        //Create our temp tables to work with the data in our report
    +        $this->Sale->create_temp_table($inputs);
    +    }
    +
    +    public function getDataColumns()
    +    {
    +        return array(
    +            'summary' => array(
    +                array('id' => $this->lang->line('reports_sale_id')),
    +                array('sale_date' => $this->lang->line('reports_date')),
    +                array('quantity' => $this->lang->line('reports_quantity')),
    +                array('employee_name' => $this->lang->line('reports_sold_by')),
    +                array('subtotal' => $this->lang->line('reports_subtotal'), 'sorter' => 'number_sorter'),
    +                array('tax' => $this->lang->line('reports_tax'), 'sorter' => 'number_sorter'),
    +                array('total' => $this->lang->line('reports_total'), 'sorter' => 'number_sorter'),
    +                array('cost' => $this->lang->line('reports_cost'), 'sorter' => 'number_sorter'),
    +                array('profit' => $this->lang->line('reports_profit'), 'sorter' => 'number_sorter'),
    +                array('payment_type' => $this->lang->line('reports_payment_type')),
    +                array('comment' => $this->lang->line('reports_comments'))),
    +            'details' => array(
    +                $this->lang->line('reports_name'),
    +                $this->lang->line('reports_category'),
    +                $this->lang->line('reports_serial_number'),
    +                $this->lang->line('reports_description'),
    +                $this->lang->line('reports_quantity'),
    +                $this->lang->line('reports_subtotal'),
    +                $this->lang->line('reports_tax'),
    +                $this->lang->line('reports_total'),
    +                $this->lang->line('reports_cost'),
    +                $this->lang->line('reports_profit'),
    +                $this->lang->line('reports_discount')),
    +            'details_rewards' => array(
    +                $this->lang->line('reports_used'),
    +                $this->lang->line('reports_earned'))
    +        );
    +    }
    +
    +    public function getData(array $inputs)
    +    {
    +        $this->db->select('sale_id,
    +            MAX(sale_date) AS sale_date,
    +            SUM(quantity_purchased) AS items_purchased,
    +            MAX(employee_name) AS employee_name,
    +            SUM(subtotal) AS subtotal,
    +            SUM(tax) AS tax,
    +            SUM(total) AS total,
    +            SUM(cost) AS cost,
    +            SUM(profit) AS profit,
    +            MAX(payment_type) AS payment_type,
    +            MAX(comment) AS comment');
    +        $this->db->from('sales_items_temp');
    +        $this->db->where('customer_id', $inputs['customer_id']);
    +
    +        if($inputs['sale_type'] == 'sales')
    +        {
    +            $this->db->where('quantity_purchased > 0');
    +        }
    +        elseif($inputs['sale_type'] == 'returns')
    +        {
    +            $this->db->where('quantity_purchased < 0');
    +        }
    +
    +        $this->db->group_by('sale_id');
    +        $this->db->order_by('MAX(sale_date)');
    +
    +        $data = array();
    +        $data['summary'] = $this->db->get()->result_array();
    +        $data['details'] = array();
    +        $data['rewards'] = array();
    +
    +        foreach($data['summary'] as $key=>$value)
    +        {
    +            $this->db->select('name, category, serialnumber, description, quantity_purchased, subtotal, tax, total, cost, profit, discount_percent');
    +            $this->db->from('sales_items_temp');
    +            $this->db->where('sale_id', $value['sale_id']);
    +            $data['details'][$key] = $this->db->get()->result_array();
    +            $this->db->select('used, earned');
    +            $this->db->from('sales_reward_points');
    +            $this->db->where('sale_id', $value['sale_id']);
    +            $data['rewards'][$key] = $this->db->get()->result_array();
    +        }
    +
    +        return $data;
    +    }
     
    -        if ($inputs['sale_type'] == 'sales')
    -        {
    -            $this->db->where('quantity_purchased > 0');
    -        }
    -        elseif ($inputs['sale_type'] == 'returns')
    -        {
    -            $this->db->where('quantity_purchased < 0');
    -        }
    -
    -        return $this->db->get()->row_array();
    -    }
    -}
    -?>
    -
    + public function getSummaryData(array $inputs) + { + $this->db->select('SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit'); + $this->db->from('sales_items_temp'); + $this->db->where('customer_id', $inputs['customer_id']); + + if($inputs['sale_type'] == 'sales') + { + $this->db->where('quantity_purchased > 0'); + } + elseif($inputs['sale_type'] == 'returns') + { + $this->db->where('quantity_purchased < 0'); + } + + return $this->db->get()->row_array(); + } +} +?> + - + diff --git a/docs/source-class-Specific_discount.html b/docs/source-class-Specific_discount.html index 1bfe82691..090d63b1e 100644 --- a/docs/source-class-Specific_discount.html +++ b/docs/source-class-Specific_discount.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,104 +207,118 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     
     require_once("Report.php");
     
     class Specific_discount extends Report
     {
    -    function __construct()
    +    public function create(array $inputs)
         {
    -        parent::__construct();
    -    }
    -
    -    public function create(array $inputs)
    -    {
    -        //Create our temp tables to work with the data in our report
    -        $this->Sale->create_temp_table($inputs);
    -    }
    -
    -    public function getDataColumns()
    -    {
    -        return array(
    -            'summary' => array(
    -                array('id' => $this->lang->line('reports_sale_id')),
    -                array('sale_date' => $this->lang->line('reports_date')),
    -                array('quantity' => $this->lang->line('reports_quantity')),
    -                array('customer_name' => $this->lang->line('reports_sold_to')),
    -                array('subtotal' => $this->lang->line('reports_subtotal'), 'sorter' => 'number_sorter'),
    -                array('tax' => $this->lang->line('reports_tax'), 'sorter' => 'number_sorter'),
    -                array('total' => $this->lang->line('reports_total'), 'sorter' => 'number_sorter'),
    -                array('profit' => $this->lang->line('reports_profit'), 'sorter' => 'number_sorter'),
    -                array('payment_type' => $this->lang->line('reports_payment_type')),
    -                array('comments' => $this->lang->line('reports_comments'))),
    -            'details' => array(
    -                $this->lang->line('reports_name'),
    -                $this->lang->line('reports_category'),
    -                $this->lang->line('reports_serial_number'),
    -                $this->lang->line('reports_description'),
    -                $this->lang->line('reports_quantity'),
    -                $this->lang->line('reports_subtotal'),
    -                $this->lang->line('reports_total'),
    -                $this->lang->line('reports_tax'),
    -                $this->lang->line('reports_profit'),
    -                $this->lang->line('reports_discount'))
    -        );
    -    }
    -
    -    public function getData(array $inputs)
    -    {
    -        $this->db->select('sale_id, MAX(sale_date) AS sales_date, SUM(quantity_purchased) AS items_purchased, MAX(customer_name) AS customer_name, SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit, MAX(payment_type) AS payment_type, MAX(comment) AS comment');
    -        $this->db->from('sales_items_temp');
    -        $this->db->where('discount_percent >=', $inputs['discount']);
    -
    -        if ($inputs['sale_type'] == 'sales')
    -        {
    -            $this->db->where('quantity_purchased > 0');
    -        }
    -        elseif ($inputs['sale_type'] == 'returns')
    -        {
    -            $this->db->where('quantity_purchased < 0');
    -        }
    -
    -        $this->db->group_by('sale_id');
    -        $this->db->order_by('MAX(sale_date)');
    -
    -        $data = array();
    -        $data['summary'] = $this->db->get()->result_array();
    -        $data['details'] = array();
    -
    -        foreach($data['summary'] as $key=>$value)
    -        {
    -            $this->db->select('name, serialnumber, category, description, quantity_purchased, subtotal, tax, total, cost, profit, discount_percent');
    -            $this->db->from('sales_items_temp');
    -            $this->db->where('sale_id', $value['sale_id']);
    -            $data['details'][$key] = $this->db->get()->result_array();
    -        }
    -
    -        return $data;
    -    }
    -
    -    public function getSummaryData(array $inputs)
    -    {
    -        $this->db->select('SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit');
    -        $this->db->from('sales_items_temp');
    -        $this->db->where('discount_percent >=', $inputs['discount']);
    -
    -        if ($inputs['sale_type'] == 'sales')
    -        {
    -            $this->db->where('quantity_purchased > 0');
    -        }
    -        elseif ($inputs['sale_type'] == 'returns')
    -        {
    -            $this->db->where('quantity_purchased < 0');
    -        }
    -
    -        return $this->db->get()->row_array();
    -    }
    -}
    -?>
    + //Create our temp tables to work with the data in our report + $this->Sale->create_temp_table($inputs); + } + + public function getDataColumns() + { + return array( + 'summary' => array( + array('id' => $this->lang->line('reports_sale_id')), + array('sale_date' => $this->lang->line('reports_date')), + array('quantity' => $this->lang->line('reports_quantity')), + array('customer_name' => $this->lang->line('reports_sold_to')), + array('subtotal' => $this->lang->line('reports_subtotal'), 'sorter' => 'number_sorter'), + array('tax' => $this->lang->line('reports_tax'), 'sorter' => 'number_sorter'), + array('total' => $this->lang->line('reports_total'), 'sorter' => 'number_sorter'), + array('profit' => $this->lang->line('reports_profit'), 'sorter' => 'number_sorter'), + array('payment_type' => $this->lang->line('reports_payment_type')), + array('comment' => $this->lang->line('reports_comments'))), + 'details' => array( + $this->lang->line('reports_name'), + $this->lang->line('reports_category'), + $this->lang->line('reports_serial_number'), + $this->lang->line('reports_description'), + $this->lang->line('reports_quantity'), + $this->lang->line('reports_subtotal'), + $this->lang->line('reports_total'), + $this->lang->line('reports_tax'), + $this->lang->line('reports_profit'), + $this->lang->line('reports_discount')), + 'details_rewards' => array( + $this->lang->line('reports_used'), + $this->lang->line('reports_earned')) + ); + } + + public function getData(array $inputs) + { + $this->db->select('sale_id, + MAX(sale_date) AS sale_date, + SUM(quantity_purchased) AS items_purchased, + MAX(customer_name) AS customer_name, + SUM(subtotal) AS subtotal, + SUM(tax) AS tax, + SUM(total) AS total, + SUM(cost) AS cost, + SUM(profit) AS profit, + MAX(payment_type) AS payment_type, + MAX(comment) AS comment'); + $this->db->from('sales_items_temp'); + $this->db->where('discount_percent >=', $inputs['discount']); + + if($inputs['sale_type'] == 'sales') + { + $this->db->where('quantity_purchased > 0'); + } + elseif($inputs['sale_type'] == 'returns') + { + $this->db->where('quantity_purchased < 0'); + } + + $this->db->group_by('sale_id'); + $this->db->order_by('MAX(sale_date)'); + + $data = array(); + $data['summary'] = $this->db->get()->result_array(); + $data['details'] = array(); + $data['rewards'] = array(); + + foreach($data['summary'] as $key=>$value) + { + $this->db->select('name, category, serialnumber, description, quantity_purchased, subtotal, tax, total, cost, profit, discount_percent'); + $this->db->from('sales_items_temp'); + $this->db->where('sale_id', $value['sale_id']); + $data['details'][$key] = $this->db->get()->result_array(); + $this->db->select('used, earned'); + $this->db->from('sales_reward_points'); + $this->db->where('sale_id', $value['sale_id']); + $data['rewards'][$key] = $this->db->get()->result_array(); + } + + return $data; + } + + public function getSummaryData(array $inputs) + { + $this->db->select('SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit'); + $this->db->from('sales_items_temp'); + $this->db->where('discount_percent >=', $inputs['discount']); + + if($inputs['sale_type'] == 'sales') + { + $this->db->where('quantity_purchased > 0'); + } + elseif($inputs['sale_type'] == 'returns') + { + $this->db->where('quantity_purchased < 0'); + } + + return $this->db->get()->row_array(); + } +} +?> + - + diff --git a/docs/source-class-Specific_employee.html b/docs/source-class-Specific_employee.html index 9d65df888..43d2c532e 100644 --- a/docs/source-class-Specific_employee.html +++ b/docs/source-class-Specific_employee.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,107 +207,120 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     
     require_once("Report.php");
     
     class Specific_employee extends Report
     {
    -    function __construct()
    +    public function create(array $inputs)
         {
    -        parent::__construct();
    -    }
    -
    -    public function create(array $inputs)
    -    {
    -        //Create our temp tables to work with the data in our report
    -        $this->Sale->create_temp_table($inputs);
    -    }
    -
    -    public function getDataColumns()
    -    {
    -        return array(
    -            'summary' => array(
    -                array('id' => $this->lang->line('reports_sale_id')),
    -                array('sale_date' => $this->lang->line('reports_date')),
    -                array('quantity' => $this->lang->line('reports_quantity')),
    -                array('customer_name' => $this->lang->line('reports_sold_to')),
    -                array('subtotal' => $this->lang->line('reports_subtotal'), 'sorter' => 'number_sorter'),
    -                array('tax' => $this->lang->line('reports_tax'), 'sorter' => 'number_sorter'),
    -                array('total' => $this->lang->line('reports_total'), 'sorter' => 'number_sorter'),
    -                array('cost' => $this->lang->line('reports_cost'), 'sorter' => 'number_sorter'),
    -                array('profit' => $this->lang->line('reports_profit'), 'sorter' => 'number_sorter'),
    -                array('payment_type' => $this->lang->line('reports_payment_type')),
    -                array('comments' => $this->lang->line('reports_comments'))),
    -            'details' => array(
    -                $this->lang->line('reports_name'),
    -                $this->lang->line('reports_category'),
    -                $this->lang->line('reports_serial_number'),
    -                $this->lang->line('reports_description'),
    -                $this->lang->line('reports_quantity'),
    -                $this->lang->line('reports_subtotal'),
    -                $this->lang->line('reports_tax'),
    -                $this->lang->line('reports_total'),
    -                $this->lang->line('reports_cost'),
    -                $this->lang->line('reports_profit'),
    -                $this->lang->line('reports_discount'))
    -        );
    -    }
    -
    -    public function getData(array $inputs)
    -    {
    -        $this->db->select('sale_id, MAX(sale_date) AS sale_date, SUM(quantity_purchased) AS items_purchased, MAX(customer_name) AS customer_name, SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit, MAX(payment_type) AS payment_type, MAX(comment) AS comment');
    -        $this->db->from('sales_items_temp');
    -        $this->db->where('employee_id', $inputs['employee_id']);
    -
    -        if ($inputs['sale_type'] == 'sales')
    -        {
    -            $this->db->where('quantity_purchased > 0');
    -        }
    -        elseif ($inputs['sale_type'] == 'returns')
    -        {
    -            $this->db->where('quantity_purchased < 0');
    -        }
    -
    -        $this->db->group_by('sale_id');
    -        $this->db->order_by('MAX(sale_date)');
    -
    -        $data = array();
    -        $data['summary'] = $this->db->get()->result_array();
    -        $data['details'] = array();
    -
    -        foreach($data['summary'] as $key=>$value)
    -        {
    -            $this->db->select('name, category, serialnumber, description, quantity_purchased, subtotal, tax, total, cost, profit, discount_percent');
    -            $this->db->from('sales_items_temp');
    -            $this->db->where('sale_id', $value['sale_id']);
    -            $data['details'][$key] = $this->db->get()->result_array();
    -        }
    -
    -        return $data;
    -    }
    -
    -    public function getSummaryData(array $inputs)
    -    {
    -        $this->db->select('SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit');
    -        $this->db->from('sales_items_temp');
    -        $this->db->where('employee_id', $inputs['employee_id']);
    -
    -        if ($inputs['sale_type'] == 'sales')
    -        {
    -            $this->db->where('quantity_purchased > 0');
    -        }
    -        elseif ($inputs['sale_type'] == 'returns')
    -        {
    -            $this->db->where('quantity_purchased < 0');
    -        }
    -
    -        return $this->db->get()->row_array();
    -    }
    -}
    -?>
    -
    + //Create our temp tables to work with the data in our report + $this->Sale->create_temp_table($inputs); + } + + public function getDataColumns() + { + return array( + 'summary' => array( + array('id' => $this->lang->line('reports_sale_id')), + array('sale_date' => $this->lang->line('reports_date')), + array('quantity' => $this->lang->line('reports_quantity')), + array('customer_name' => $this->lang->line('reports_sold_to')), + array('subtotal' => $this->lang->line('reports_subtotal'), 'sorter' => 'number_sorter'), + array('tax' => $this->lang->line('reports_tax'), 'sorter' => 'number_sorter'), + array('total' => $this->lang->line('reports_total'), 'sorter' => 'number_sorter'), + array('cost' => $this->lang->line('reports_cost'), 'sorter' => 'number_sorter'), + array('profit' => $this->lang->line('reports_profit'), 'sorter' => 'number_sorter'), + array('payment_type' => $this->lang->line('reports_payment_type')), + array('comment' => $this->lang->line('reports_comments'))), + 'details' => array( + $this->lang->line('reports_name'), + $this->lang->line('reports_category'), + $this->lang->line('reports_serial_number'), + $this->lang->line('reports_description'), + $this->lang->line('reports_quantity'), + $this->lang->line('reports_subtotal'), + $this->lang->line('reports_tax'), + $this->lang->line('reports_total'), + $this->lang->line('reports_cost'), + $this->lang->line('reports_profit'), + $this->lang->line('reports_discount')), + 'details_rewards' => array( + $this->lang->line('reports_used'), + $this->lang->line('reports_earned')) + ); + } + + public function getData(array $inputs) + { + $this->db->select('sale_id, + MAX(sale_date) AS sale_date, + SUM(quantity_purchased) AS items_purchased, + MAX(customer_name) AS customer_name, + SUM(subtotal) AS subtotal, + SUM(tax) AS tax, + SUM(total) AS total, + SUM(cost) AS cost, + SUM(profit) AS profit, + MAX(payment_type) AS payment_type, + MAX(comment) AS comment'); + $this->db->from('sales_items_temp'); + $this->db->where('employee_id', $inputs['employee_id']); + + if($inputs['sale_type'] == 'sales') + { + $this->db->where('quantity_purchased > 0'); + } + elseif($inputs['sale_type'] == 'returns') + { + $this->db->where('quantity_purchased < 0'); + } + + $this->db->group_by('sale_id'); + $this->db->order_by('MAX(sale_date)'); + + $data = array(); + $data['summary'] = $this->db->get()->result_array(); + $data['details'] = array(); + $data['rewards'] = array(); + + foreach($data['summary'] as $key=>$value) + { + $this->db->select('name, category, serialnumber, description, quantity_purchased, subtotal, tax, total, cost, profit, discount_percent'); + $this->db->from('sales_items_temp'); + $this->db->where('sale_id', $value['sale_id']); + $data['details'][$key] = $this->db->get()->result_array(); + $this->db->select('used, earned'); + $this->db->from('sales_reward_points'); + $this->db->where('sale_id', $value['sale_id']); + $data['rewards'][$key] = $this->db->get()->result_array(); + } + + return $data; + } + + public function getSummaryData(array $inputs) + { + $this->db->select('SUM(subtotal) AS subtotal, SUM(tax) AS tax, SUM(total) AS total, SUM(cost) AS cost, SUM(profit) AS profit'); + $this->db->from('sales_items_temp'); + $this->db->where('employee_id', $inputs['employee_id']); + + if($inputs['sale_type'] == 'sales') + { + $this->db->where('quantity_purchased > 0'); + } + elseif($inputs['sale_type'] == 'returns') + { + $this->db->where('quantity_purchased < 0'); + } + + return $this->db->get()->row_array(); + } +} +?> + - + diff --git a/docs/source-class-Stock_location.html b/docs/source-class-Stock_location.html index 1f2b6ed2b..5d8fd00e6 100644 --- a/docs/source-class-Stock_location.html +++ b/docs/source-class-Stock_location.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,167 +207,177 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 
    -
    <?php
    -class Stock_location extends CI_Model
    -{
    -    public function exists($location_name = '')
    -    {
    -        $this->db->from('stock_locations');  
    -        $this->db->where('location_name', $location_name);
    -        
    -        return ($this->db->get()->num_rows() >= 1);
    -    }
    -    
    -    public function get_all($limit = 10000, $offset = 0)
    -    {
    -        $this->db->from('stock_locations');
    -        $this->db->limit($limit);
    -        $this->db->offset($offset);
    -    
    -        return $this->db->get();
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
    +
    +/**
    + * Stock_location class
    + *
    + * @link    github.com/jekkos/opensourcepos
    + * @since   2.x
    + * @author  Padungsak
    + */
    +
    +class Stock_location extends CI_Model
    +{
    +    public function exists($location_name = '')
    +    {
    +        $this->db->from('stock_locations');
    +        $this->db->where('location_name', $location_name);
    +
    +        return ($this->db->get()->num_rows() >= 1);
         }
    -    
    -    public function get_undeleted_all($module_id = 'items')
    +
    +    public function get_all($limit = 10000, $offset = 0)
         {
             $this->db->from('stock_locations');
    -        $this->db->join('permissions', 'permissions.location_id = stock_locations.location_id');
    -        $this->db->join('grants', 'grants.permission_id = permissions.permission_id');
    -        $this->db->where('person_id', $this->session->userdata('person_id'));
    -        $this->db->like('permissions.permission_id', $module_id, 'after');
    -        $this->db->where('deleted', 0);
    +        $this->db->limit($limit);
    +        $this->db->offset($offset);
    +
    +        return $this->db->get();
    +    }
     
    -        return $this->db->get();
    -    }
    -
    -    public function show_locations($module_id = 'items')
    -    {
    -        $stock_locations = $this->get_allowed_locations($module_id);
    -
    -        return count($stock_locations) > 1;
    -    }
    -
    -    public function multiple_locations()
    -    {
    -        return $this->get_all()->num_rows() > 1;
    -    }
    -
    -    public function get_allowed_locations($module_id = 'items')
    -    {
    -        $stock = $this->get_undeleted_all($module_id)->result_array();
    -        $stock_locations = array();
    -        foreach($stock as $location_data)
    -        {
    -            $stock_locations[$location_data['location_id']] = $location_data['location_name'];
    -        }
    +    public function get_undeleted_all($module_id = 'items')
    +    {
    +        $this->db->from('stock_locations');
    +        $this->db->join('permissions', 'permissions.location_id = stock_locations.location_id');
    +        $this->db->join('grants', 'grants.permission_id = permissions.permission_id');
    +        $this->db->where('person_id', $this->session->userdata('person_id'));
    +        $this->db->like('permissions.permission_id', $module_id, 'after');
    +        $this->db->where('deleted', 0);
    +
    +        return $this->db->get();
    +    }
    +
    +    public function show_locations($module_id = 'items')
    +    {
    +        $stock_locations = $this->get_allowed_locations($module_id);
    +
    +        return count($stock_locations) > 1;
    +    }
    +
    +    public function multiple_locations()
    +    {
    +        return $this->get_all()->num_rows() > 1;
    +    }
     
    -        return $stock_locations;
    -    }
    -
    -    public function is_allowed_location($location_id, $module_id = 'items')
    -    {
    -        $this->db->from('stock_locations');
    -        $this->db->join('permissions', 'permissions.location_id = stock_locations.location_id');
    -        $this->db->join('grants', 'grants.permission_id = permissions.permission_id');
    -        $this->db->where('person_id', $this->session->userdata('person_id'));
    -        $this->db->like('permissions.permission_id', $module_id, 'after');
    -        $this->db->where('deleted', 0);
    -        $this->db->where('stock_locations.location_id', $location_id);
    -
    -        return ($this->db->get()->num_rows() == 1);
    -    }
    -    
    -    public function get_default_location_id()
    -    {
    -        $this->db->from('stock_locations');
    -        $this->db->join('permissions', 'permissions.location_id = stock_locations.location_id');
    -        $this->db->join('grants', 'grants.permission_id = permissions.permission_id');
    -        $this->db->where('person_id', $this->session->userdata('person_id'));
    -        $this->db->where('deleted', 0);
    -        $this->db->limit(1);
    +    public function get_allowed_locations($module_id = 'items')
    +    {
    +        $stock = $this->get_undeleted_all($module_id)->result_array();
    +        $stock_locations = array();
    +        foreach($stock as $location_data)
    +        {
    +            $stock_locations[$location_data['location_id']] = $location_data['location_name'];
    +        }
    +
    +        return $stock_locations;
    +    }
    +
    +    public function is_allowed_location($location_id, $module_id = 'items')
    +    {
    +        $this->db->from('stock_locations');
    +        $this->db->join('permissions', 'permissions.location_id = stock_locations.location_id');
    +        $this->db->join('grants', 'grants.permission_id = permissions.permission_id');
    +        $this->db->where('person_id', $this->session->userdata('person_id'));
    +        $this->db->like('permissions.permission_id', $module_id, 'after');
    +        $this->db->where('deleted', 0);
    +        $this->db->where('stock_locations.location_id', $location_id);
    +
    +        return ($this->db->get()->num_rows() == 1);
    +    }
     
    -        return $this->db->get()->row()->location_id;
    -    }
    -    
    -    public function get_location_name($location_id) 
    -    {
    -        $this->db->from('stock_locations');
    -        $this->db->where('location_id', $location_id);
    -
    -        return $this->db->get()->row()->location_name;
    -    }
    -    
    -    public function save(&$location_data, $location_id) 
    -    {
    -        $location_name = $location_data['location_name'];
    -
    -        if(!$this->exists($location_name))
    -        {
    -            $this->db->trans_start();
    -
    -            $location_data = array('location_name'=>$location_name, 'deleted'=>0);
    -            $this->db->insert('stock_locations', $location_data);
    -            $location_id = $this->db->insert_id();
    -             
    -            $this->_insert_new_permission('items', $location_id, $location_name);
    -            $this->_insert_new_permission('sales', $location_id, $location_name);
    -            $this->_insert_new_permission('receivings', $location_id, $location_name);
    -            
    -            // insert quantities for existing items
    -            $items = $this->Item->get_all();
    -            foreach($items->result_array() as $item)
    -            {
    -                $quantity_data = array('item_id' => $item['item_id'], 'location_id' => $location_id, 'quantity' => 0);
    -                $this->db->insert('item_quantities', $quantity_data);
    -            }
    -
    -            $this->db->trans_complete();
    -            
    -            return $this->db->trans_status();
    -        }
    -        else 
    -        {
    -            $this->db->where('location_id', $location_id);
    -
    -            return $this->db->update('stock_locations', $location_data);
    -        }
    -    }
    -        
    -    private function _insert_new_permission($module, $location_id, $location_name)
    -    {
    -        // insert new permission for stock location
    -        $permission_id = $module . '_' . $location_name;
    -        $permission_data = array('permission_id' => $permission_id, 'module_id' => $module, 'location_id' => $location_id);
    -        $this->db->insert('permissions', $permission_data);
    -        
    -        // insert grants for new permission
    -        $employees = $this->Employee->get_all();
    -        foreach($employees->result_array() as $employee)
    -        {
    -            $grants_data = array('permission_id' => $permission_id, 'person_id' => $employee['person_id']);
    -            $this->db->insert('grants', $grants_data);
    -        }
    -    }
    -    
    -    /*
    -     Deletes one item
    -    */
    -    public function delete($location_id)
    -    {
    -        $this->db->trans_start();
    -
    -        $this->db->where('location_id', $location_id);
    -        $this->db->update('stock_locations', array('deleted' => 1));
    -        
    -        $this->db->where('location_id', $location_id);
    -        $this->db->delete('permissions');
    -
    -        $this->db->trans_complete();
    -        
    -        return $this->db->trans_status();
    -    }
    -}
    -?>
    +
    public function get_default_location_id() + { + $this->db->from('stock_locations'); + $this->db->join('permissions', 'permissions.location_id = stock_locations.location_id'); + $this->db->join('grants', 'grants.permission_id = permissions.permission_id'); + $this->db->where('person_id', $this->session->userdata('person_id')); + $this->db->where('deleted', 0); + $this->db->limit(1); + + return $this->db->get()->row()->location_id; + } + + public function get_location_name($location_id) + { + $this->db->from('stock_locations'); + $this->db->where('location_id', $location_id); + + return $this->db->get()->row()->location_name; + } + + public function save(&$location_data, $location_id) + { + $location_name = $location_data['location_name']; + + if(!$this->exists($location_name)) + { + $this->db->trans_start(); + + $location_data = array('location_name'=>$location_name, 'deleted'=>0); + $this->db->insert('stock_locations', $location_data); + $location_id = $this->db->insert_id(); + + $this->_insert_new_permission('items', $location_id, $location_name); + $this->_insert_new_permission('sales', $location_id, $location_name); + $this->_insert_new_permission('receivings', $location_id, $location_name); + + // insert quantities for existing items + $items = $this->Item->get_all(); + foreach($items->result_array() as $item) + { + $quantity_data = array('item_id' => $item['item_id'], 'location_id' => $location_id, 'quantity' => 0); + $this->db->insert('item_quantities', $quantity_data); + } + + $this->db->trans_complete(); + + return $this->db->trans_status(); + } + else + { + $this->db->where('location_id', $location_id); + + return $this->db->update('stock_locations', $location_data); + } + } + + private function _insert_new_permission($module, $location_id, $location_name) + { + // insert new permission for stock location + $permission_id = $module . '_' . $location_name; + $permission_data = array('permission_id' => $permission_id, 'module_id' => $module, 'location_id' => $location_id); + $this->db->insert('permissions', $permission_data); + + // insert grants for new permission + $employees = $this->Employee->get_all(); + foreach($employees->result_array() as $employee) + { + $grants_data = array('permission_id' => $permission_id, 'person_id' => $employee['person_id']); + $this->db->insert('grants', $grants_data); + } + } + + /* + Deletes one item + */ + public function delete($location_id) + { + $this->db->trans_start(); + + $this->db->where('location_id', $location_id); + $this->db->update('stock_locations', array('deleted' => 1)); + + $this->db->where('location_id', $location_id); + $this->db->delete('permissions'); + + $this->db->trans_complete(); + + return $this->db->trans_status(); + } +} +?> +
    - + diff --git a/docs/source-class-Summary_categories.html b/docs/source-class-Summary_categories.html index 024ed24c6..fe388e88c 100644 --- a/docs/source-class-Summary_categories.html +++ b/docs/source-class-Summary_categories.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,55 +207,50 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     
     require_once("Summary_report.php");
     
     class Summary_categories extends Summary_report
     {
    -    function __construct()
    +    protected function _get_data_columns()
         {
    -        parent::__construct();
    -    }
    -
    -    protected function _get_data_columns()
    -    {
    -        return array(
    -            array('category' => $this->lang->line('reports_category')),
    -            array('quantity' => $this->lang->line('reports_quantity')),
    -            array('subtotal' => $this->lang->line('reports_subtotal'), 'sorter' => 'number_sorter'),
    -            array('tax' => $this->lang->line('reports_tax'), 'sorter' => 'number_sorter'),
    -            array('total' => $this->lang->line('reports_total'), 'sorter' => 'number_sorter'),
    -            array('cost' => $this->lang->line('reports_cost'), 'sorter' => 'number_sorter'),
    -            array('profit' => $this->lang->line('reports_profit'), 'sorter' => 'number_sorter'));
    -    }
    -
    -    protected function _select(array $inputs)
    -    {
    -        parent::_select($inputs);
    -
    -        $this->db->select('
    -                items.category AS category,
    -                SUM(sales_items.quantity_purchased) AS quantity_purchased
    -        ');
    -    }
    -
    -    protected function _from()
    -    {
    -        parent::_from();
    -
    -        $this->db->join('items AS items', 'sales_items.item_id = items.item_id', 'inner');
    -    }
    -
    -    protected function _group_order()
    -    {
    -        $this->db->group_by('category');
    -        $this->db->order_by('category');
    -    }
    -}
    -?>
    -
    + return array( + array('category' => $this->lang->line('reports_category')), + array('quantity' => $this->lang->line('reports_quantity')), + array('subtotal' => $this->lang->line('reports_subtotal'), 'sorter' => 'number_sorter'), + array('tax' => $this->lang->line('reports_tax'), 'sorter' => 'number_sorter'), + array('total' => $this->lang->line('reports_total'), 'sorter' => 'number_sorter'), + array('cost' => $this->lang->line('reports_cost'), 'sorter' => 'number_sorter'), + array('profit' => $this->lang->line('reports_profit'), 'sorter' => 'number_sorter')); + } + + protected function _select(array $inputs) + { + parent::_select($inputs); + + $this->db->select(' + items.category AS category, + SUM(sales_items.quantity_purchased) AS quantity_purchased + '); + } + + protected function _from() + { + parent::_from(); + + $this->db->join('items AS items', 'sales_items.item_id = items.item_id', 'inner'); + } + + protected function _group_order() + { + $this->db->group_by('category'); + $this->db->order_by('category'); + } +} +?> + - + diff --git a/docs/source-class-Summary_customers.html b/docs/source-class-Summary_customers.html index c524db35f..5fdca6e82 100644 --- a/docs/source-class-Summary_customers.html +++ b/docs/source-class-Summary_customers.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,55 +207,50 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     
     require_once("Summary_report.php");
     
     class Summary_customers extends Summary_report
     {
    -    function __construct()
    +    protected function _get_data_columns()
         {
    -        parent::__construct();
    -    }
    -
    -    protected function _get_data_columns()
    -    {
    -        return array(
    -            array('customer_name' => $this->lang->line('reports_customer')),
    -            array('quantity' => $this->lang->line('reports_quantity')),
    -            array('subtotal' => $this->lang->line('reports_subtotal'), 'sorter' => 'number_sorter'),
    -            array('tax' => $this->lang->line('reports_tax'), 'sorter' => 'number_sorter'),
    -            array('total' => $this->lang->line('reports_total'), 'sorter' => 'number_sorter'),
    -            array('cost' => $this->lang->line('reports_cost'), 'sorter' => 'number_sorter'),
    -            array('profit' => $this->lang->line('reports_profit'), 'sorter' => 'number_sorter'));
    -    }
    -
    -    protected function _select(array $inputs)
    -    {
    -        parent::_select($inputs);
    -
    -        $this->db->select('
    -                CONCAT(customer_p.first_name, " ", customer_p.last_name) AS customer,
    -                SUM(sales_items.quantity_purchased) AS quantity_purchased
    -        ');
    -    }
    -
    -    protected function _from()
    -    {
    -        parent::_from();
    -
    -        $this->db->join('people AS customer_p', 'sales.customer_id = customer_p.person_id');
    -    }
    -
    -    protected function _group_order()
    -    {
    -        $this->db->group_by('sales.customer_id');
    -        $this->db->order_by('customer_p.last_name');
    -    }
    -}
    -?>
    -
    + return array( + array('customer_name' => $this->lang->line('reports_customer')), + array('quantity' => $this->lang->line('reports_quantity')), + array('subtotal' => $this->lang->line('reports_subtotal'), 'sorter' => 'number_sorter'), + array('tax' => $this->lang->line('reports_tax'), 'sorter' => 'number_sorter'), + array('total' => $this->lang->line('reports_total'), 'sorter' => 'number_sorter'), + array('cost' => $this->lang->line('reports_cost'), 'sorter' => 'number_sorter'), + array('profit' => $this->lang->line('reports_profit'), 'sorter' => 'number_sorter')); + } + + protected function _select(array $inputs) + { + parent::_select($inputs); + + $this->db->select(' + CONCAT(customer_p.first_name, " ", customer_p.last_name) AS customer, + SUM(sales_items.quantity_purchased) AS quantity_purchased + '); + } + + protected function _from() + { + parent::_from(); + + $this->db->join('people AS customer_p', 'sales.customer_id = customer_p.person_id'); + } + + protected function _group_order() + { + $this->db->group_by('sales.customer_id'); + $this->db->order_by('customer_p.last_name'); + } +} +?> + - + diff --git a/docs/source-class-Summary_discounts.html b/docs/source-class-Summary_discounts.html index 6a7ebe013..7b13dd8d4 100644 --- a/docs/source-class-Summary_discounts.html +++ b/docs/source-class-Summary_discounts.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,43 +207,38 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     
     require_once("Summary_report.php");
     
     class Summary_discounts extends Summary_report
     {
    -    function __construct()
    +    protected function _get_data_columns()
         {
    -        parent::__construct();
    -    }
    -
    -    protected function _get_data_columns()
    -    {
    -        return array(
    -            array('discount' => $this->lang->line('reports_discount_percent'), 'sorter' => 'number_sorter'),
    -            array('count' => $this->lang->line('reports_count')));
    -    }
    -
    -    public function getData(array $inputs)
    -    {
    -        $this->db->select('MAX(CONCAT(sales_items.discount_percent, "%")) AS discount_percent, count(*) AS count');
    -        $this->db->from('sales_items AS sales_items');
    -        $this->db->join('sales AS sales', 'sales_items.sale_id = sales.sale_id', 'inner');
    -
    -        $this->db->where('discount_percent > 0');
    +        return array(
    +            array('discount' => $this->lang->line('reports_discount_percent'), 'sorter' => 'number_sorter'),
    +            array('count' => $this->lang->line('reports_count')));
    +    }
    +
    +    public function getData(array $inputs)
    +    {
    +        $this->db->select('MAX(CONCAT(sales_items.discount_percent, "%")) AS discount_percent, count(*) AS count');
    +        $this->db->from('sales_items AS sales_items');
    +        $this->db->join('sales AS sales', 'sales_items.sale_id = sales.sale_id', 'inner');
    +
    +        $this->db->where('discount_percent > 0');
    +
    +        $this->_where($inputs);
    +
    +        $this->db->group_by('sales_items.discount_percent');
    +        $this->db->order_by('sales_items.discount_percent');
     
    -        $this->_where($inputs);
    -
    -        $this->db->group_by('sales_items.discount_percent');
    -        $this->db->order_by('sales_items.discount_percent');
    -
    -        return $this->db->get()->result_array();
    -    }
    -}
    -?>
    -
    + return $this->db->get()->result_array(); + } +} +?> + - + diff --git a/docs/source-class-Summary_employees.html b/docs/source-class-Summary_employees.html index bd1856b50..b497333d8 100644 --- a/docs/source-class-Summary_employees.html +++ b/docs/source-class-Summary_employees.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,55 +207,50 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     
     require_once("Summary_report.php");
     
     class Summary_employees extends Summary_report
     {
    -    function __construct()
    +    protected function _get_data_columns()
         {
    -        parent::__construct();
    -    }
    -
    -    protected function _get_data_columns()
    -    {
    -        return array(
    -            array('employee_name' => $this->lang->line('reports_employee')),
    -            array('quantity' => $this->lang->line('reports_quantity')),
    -            array('subtotal' => $this->lang->line('reports_subtotal'), 'sorter' => 'number_sorter'),
    -            array('tax' => $this->lang->line('reports_tax'), 'sorter' => 'number_sorter'),
    -            array('total' => $this->lang->line('reports_total'), 'sorter' => 'number_sorter'),
    -            array('cost' => $this->lang->line('reports_cost'), 'sorter' => 'number_sorter'),
    -            array('profit' => $this->lang->line('reports_profit'), 'sorter' => 'number_sorter'));
    -    }
    -
    -    protected function _select(array $inputs)
    -    {
    -        parent::_select($inputs);
    -
    -        $this->db->select('
    -                MAX(CONCAT(employee_p.first_name, " ", employee_p.last_name)) AS employee,
    -                SUM(sales_items.quantity_purchased) AS quantity_purchased
    -        ');
    -    }
    -
    -    protected function _from()
    -    {
    -        parent::_from();
    -
    -        $this->db->join('people AS employee_p', 'sales.employee_id = employee_p.person_id');
    -    }
    -
    -    protected function _group_order()
    -    {
    -        $this->db->group_by('sales.employee_id');
    -        $this->db->order_by('employee_p.last_name');
    -    }
    -}
    -?>
    -
    + return array( + array('employee_name' => $this->lang->line('reports_employee')), + array('quantity' => $this->lang->line('reports_quantity')), + array('subtotal' => $this->lang->line('reports_subtotal'), 'sorter' => 'number_sorter'), + array('tax' => $this->lang->line('reports_tax'), 'sorter' => 'number_sorter'), + array('total' => $this->lang->line('reports_total'), 'sorter' => 'number_sorter'), + array('cost' => $this->lang->line('reports_cost'), 'sorter' => 'number_sorter'), + array('profit' => $this->lang->line('reports_profit'), 'sorter' => 'number_sorter')); + } + + protected function _select(array $inputs) + { + parent::_select($inputs); + + $this->db->select(' + MAX(CONCAT(employee_p.first_name, " ", employee_p.last_name)) AS employee, + SUM(sales_items.quantity_purchased) AS quantity_purchased + '); + } + + protected function _from() + { + parent::_from(); + + $this->db->join('people AS employee_p', 'sales.employee_id = employee_p.person_id'); + } + + protected function _group_order() + { + $this->db->group_by('sales.employee_id'); + $this->db->order_by('employee_p.last_name'); + } +} +?> + - + diff --git a/docs/source-class-Summary_items.html b/docs/source-class-Summary_items.html index 6f72d4a69..17a8e3eaa 100644 --- a/docs/source-class-Summary_items.html +++ b/docs/source-class-Summary_items.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,55 +207,50 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     
     require_once("Summary_report.php");
     
     class Summary_items extends Summary_report
     {
    -    function __construct()
    +    protected function _get_data_columns()
         {
    -        parent::__construct();
    -    }
    -
    -    protected function _get_data_columns()
    -    {
    -        return array(
    -            array('item_name' => $this->lang->line('reports_item')),
    -            array('quantity' => $this->lang->line('reports_quantity')),
    -            array('subtotal' => $this->lang->line('reports_subtotal'), 'sorter' => 'number_sorter'),
    -            array('tax' => $this->lang->line('reports_tax'), 'sorter' => 'number_sorter'),
    -            array('total' => $this->lang->line('reports_total'), 'sorter' => 'number_sorter'),
    -            array('cost' => $this->lang->line('reports_cost'), 'sorter' => 'number_sorter'),
    -            array('profit' => $this->lang->line('reports_profit'), 'sorter' => 'number_sorter'));
    -    }
    -
    -    protected function _select(array $inputs)
    -    {
    -        parent::_select($inputs);
    -
    -        $this->db->select('
    -                MAX(items.name) AS name,
    -                SUM(sales_items.quantity_purchased) AS quantity_purchased
    -        ');
    -    }
    -
    -    protected function _from()
    -    {
    -        parent::_from();
    -
    -        $this->db->join('items AS items', 'sales_items.item_id = items.item_id', 'inner');
    -    }
    -
    -    protected function _group_order()
    -    {
    -        $this->db->group_by('items.item_id');
    -        $this->db->order_by('name');
    -    }
    -}
    -?>
    -
    + return array( + array('item_name' => $this->lang->line('reports_item')), + array('quantity' => $this->lang->line('reports_quantity')), + array('subtotal' => $this->lang->line('reports_subtotal'), 'sorter' => 'number_sorter'), + array('tax' => $this->lang->line('reports_tax'), 'sorter' => 'number_sorter'), + array('total' => $this->lang->line('reports_total'), 'sorter' => 'number_sorter'), + array('cost' => $this->lang->line('reports_cost'), 'sorter' => 'number_sorter'), + array('profit' => $this->lang->line('reports_profit'), 'sorter' => 'number_sorter')); + } + + protected function _select(array $inputs) + { + parent::_select($inputs); + + $this->db->select(' + MAX(items.name) AS name, + SUM(sales_items.quantity_purchased) AS quantity_purchased + '); + } + + protected function _from() + { + parent::_from(); + + $this->db->join('items AS items', 'sales_items.item_id = items.item_id', 'inner'); + } + + protected function _group_order() + { + $this->db->group_by('items.item_id'); + $this->db->order_by('name'); + } +} +?> + - + diff --git a/docs/source-class-Summary_payments.html b/docs/source-class-Summary_payments.html index bf8a8e8cb..18fbc7763 100644 --- a/docs/source-class-Summary_payments.html +++ b/docs/source-class-Summary_payments.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,75 +207,70 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     
     require_once("Summary_report.php");
     
     class Summary_payments extends Summary_report
     {
    -    function __construct()
    +    protected function _get_data_columns()
         {
    -        parent::__construct();
    -    }
    -    
    -    protected function _get_data_columns()
    -    {
    -        return array(
    -            array('payment_type' => $this->lang->line('reports_payment_type')),
    -            array('report_count' => $this->lang->line('reports_count')),
    -            array('amount_tendered' => $this->lang->line('sales_amount_tendered'), 'sorter' => 'number_sorter'));
    -    }
    -
    -    protected function _where(array $inputs)
    -    {
    -        if(empty($this->config->item('date_or_time_format')))
    -        {
    -            $this->db->where('DATE(sales.sale_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']));
    -        }
    -        else
    -        {
    -            $this->db->where('sales.sale_time BETWEEN ' . $this->db->escape(rawurldecode($inputs['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($inputs['end_date'])));
    -        }
    -    }
    -
    -    public function getData(array $inputs)
    -    {
    -        $this->db->select('sales_payments.payment_type, count(*) AS count, SUM(sales_payments.payment_amount) AS payment_amount');
    -        $this->db->from('sales_payments AS sales_payments');
    -        $this->db->join('sales AS sales', 'sales.sale_id = sales_payments.sale_id');
    -
    -        $this->_where($inputs);
    -
    -        $this->db->group_by("payment_type");
    -
    -        $payments = $this->db->get()->result_array();
    -
    -        // consider Gift Card as only one type of payment and do not show "Gift Card: 1, Gift Card: 2, etc." in the total
    -        $gift_card_count = 0;
    -        $gift_card_amount = 0;
    -        foreach($payments as $key=>$payment)
    -        {
    -            if(strstr($payment['payment_type'], $this->lang->line('sales_giftcard')) != FALSE)
    -            {
    -                $gift_card_count  += $payment['count'];
    -                $gift_card_amount += $payment['payment_amount'];
    +        return array(
    +            array('payment_type' => $this->lang->line('reports_payment_type')),
    +            array('report_count' => $this->lang->line('reports_count')),
    +            array('amount_tendered' => $this->lang->line('sales_amount_tendered'), 'sorter' => 'number_sorter'));
    +    }
    +
    +    protected function _where(array $inputs)
    +    {
    +        if(empty($this->config->item('date_or_time_format')))
    +        {
    +            $this->db->where('DATE(sales.sale_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']));
    +        }
    +        else
    +        {
    +            $this->db->where('sales.sale_time BETWEEN ' . $this->db->escape(rawurldecode($inputs['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($inputs['end_date'])));
    +        }
    +    }
    +
    +    public function getData(array $inputs)
    +    {
    +        $this->db->select('sales_payments.payment_type, count(*) AS count, SUM(sales_payments.payment_amount) AS payment_amount');
    +        $this->db->from('sales_payments AS sales_payments');
    +        $this->db->join('sales AS sales', 'sales.sale_id = sales_payments.sale_id');
    +
    +        $this->_where($inputs);
    +
    +        $this->db->group_by("payment_type");
    +
    +        $payments = $this->db->get()->result_array();
    +
    +        // consider Gift Card as only one type of payment and do not show "Gift Card: 1, Gift Card: 2, etc." in the total
    +        $gift_card_count = 0;
    +        $gift_card_amount = 0;
    +        foreach($payments as $key=>$payment)
    +        {
    +            if(strstr($payment['payment_type'], $this->lang->line('sales_giftcard')) != FALSE)
    +            {
    +                $gift_card_count  += $payment['count'];
    +                $gift_card_amount += $payment['payment_amount'];
    +
    +                // remove the "Gift Card: 1", "Gift Card: 2", etc. payment string
    +                unset($payments[$key]);
    +            }
    +        }
     
    -                // remove the "Gift Card: 1", "Gift Card: 2", etc. payment string
    -                unset($payments[$key]);
    -            }
    +        if($gift_card_count > 0)
    +        {
    +            $payments[] = array('payment_type' => $this->lang->line('sales_giftcard'), 'count' => $gift_card_count, 'payment_amount' => $gift_card_amount);
             }
     
    -        if($gift_card_count > 0)
    -        {
    -            $payments[] = array('payment_type' => $this->lang->line('sales_giftcard'), 'count' => $gift_card_count, 'payment_amount' => $gift_card_amount);
    -        }
    -
    -        return $payments;
    -    }
    -}
    -?>
    -
    + return $payments; + } +} +?> + - + diff --git a/docs/source-class-Summary_report.html b/docs/source-class-Summary_report.html index 92db773ca..9e179408f 100644 --- a/docs/source-class-Summary_report.html +++ b/docs/source-class-Summary_report.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,170 +207,159 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     
     require_once("Report.php");
     
     abstract class Summary_report extends Report
     {
    -    function __construct()
    -    {
    -        parent::__construct();
    -    }
    -
    -    /*
    -
    -    Private interface
    -
    -    */
    -
    -    private function _common_select(array $inputs)
    -    {
    -        $where = '';
    -
    -        if(empty($this->config->item('date_or_time_format')))
    -        {
    -            $where .= 'DATE(sale_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']);
    -        }
    -        else
    +    /*
    +    Private interface
    +    */
    +
    +    private function _common_select(array $inputs)
    +    {
    +        $where = '';
    +
    +        if(empty($this->config->item('date_or_time_format')))
    +        {
    +            $where .= 'DATE(sale_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']);
    +        }
    +        else
    +        {
    +            $where .= 'sale_time BETWEEN ' . $this->db->escape(rawurldecode($inputs['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($inputs['end_date']));
    +        }
    +
    +        $sale_price = 'sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100)';
    +
    +        if($this->config->item('tax_included'))
             {
    -            $where .= 'sale_time BETWEEN ' . $this->db->escape(rawurldecode($inputs['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($inputs['end_date']));
    -        }
    -
    -        $sale_price = 'sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100)';
    -
    -        if($this->config->item('tax_included'))
    -        {
    -            $sale_total = 'SUM(' . $sale_price . ')';
    -            $sale_subtotal = 'SUM(' . $sale_price . ' - sales_items_taxes.tax)';
    -            $sale_tax = 'SUM(' . $sale_price . ' * (1 - 100 / (100 + sales_items_taxes.percent)))';
    -        }
    -        else
    -        {
    -            $sale_total = 'SUM(' . $sale_price . ' + sales_items_taxes.tax)';
    -            $sale_subtotal = 'SUM(' . $sale_price . ')';
    -            $sale_tax = 'SUM(' . $sale_price . ' * (sales_items_taxes.percent / 100))';
    -        }
    -
    -        $sale_cost = 'SUM(sales_items.item_cost_price * sales_items.quantity_purchased)';
    -
    -        $decimals = totals_decimals();
    -
    -        // create a temporary table to contain all the sum of taxes per sale item
    -        $this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_items_taxes_temp') .
    -            ' (INDEX(sale_id), INDEX(item_id))
    -            (
    -                SELECT sales_items_taxes.sale_id AS sale_id,
    -                    sales_items_taxes.item_id AS item_id,
    -                    sales_items_taxes.line AS line,
    -                    ' . "
    -                    IFNULL(ROUND($sale_tax, $decimals), 0) AS tax
    -                    " . '
    -                FROM ' . $this->db->dbprefix('sales_items_taxes') . ' AS sales_items_taxes
    -                INNER JOIN ' . $this->db->dbprefix('sales') . ' AS sales
    -                    ON sales.sale_id = sales_items_taxes.sale_id
    -                INNER JOIN ' . $this->db->dbprefix('sales_items') . ' AS sales_items
    -                    ON sales_items.sale_id = sales_items_taxes.sale_id AND sales_items.line = sales_items_taxes.line
    -                WHERE sale_status = 0 AND ' . $where . '
    -                GROUP BY sale_id, item_id, line
    -            )'
    -        );
    -
    -        $this->db->select("
    -                IFNULL(ROUND($sale_subtotal, $decimals), ROUND($sale_total - IFNULL(SUM(sales_items_taxes.tax), 0), $decimals)) AS subtotal,
    -                IFNULL(ROUND(SUM(sales_items_taxes.tax), $decimals), 0) AS tax,
    -                IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals)) AS total,
    -                IFNULL(ROUND($sale_cost, $decimals), 0) AS cost,
    -                IFNULL(ROUND($sale_total - IFNULL(SUM(sales_items_taxes.tax), 0) - $sale_cost, $decimals), ROUND($sale_subtotal - $sale_cost, $decimals)) AS profit
    -        ");
    -    }
    -
    -    private function _common_from()
    -    {
    -        $this->db->from('sales_items AS sales_items');
    -        $this->db->join('sales AS sales', 'sales_items.sale_id = sales.sale_id', 'inner');
    -        $this->db->join('sales_items_taxes_temp AS sales_items_taxes',
    -            'sales_items.sale_id = sales_items_taxes.sale_id AND sales_items.item_id = sales_items_taxes.item_id AND sales_items.line = sales_items_taxes.line',
    -            'left outer');
    -    }
    +            $sale_total = 'SUM(' . $sale_price . ')';
    +            $sale_subtotal = 'SUM(' . $sale_price . ' - sales_items_taxes.tax)';
    +        }
    +        else
    +        {
    +            $sale_total = 'SUM(' . $sale_price . ' + sales_items_taxes.tax)';
    +            $sale_subtotal = 'SUM(' . $sale_price . ')';
    +        }
    +
    +        $sale_cost = 'SUM(sales_items.item_cost_price * sales_items.quantity_purchased)';
    +
    +        $decimals = totals_decimals();
    +
    +        // create a temporary table to contain all the sum of taxes per sale item
    +        $this->db->query('CREATE TEMPORARY TABLE IF NOT EXISTS ' . $this->db->dbprefix('sales_items_taxes_temp') .
    +            ' (INDEX(sale_id), INDEX(item_id))
    +            (
    +                SELECT sales_items_taxes.sale_id AS sale_id,
    +                    sales_items_taxes.item_id AS item_id,
    +                    sales_items_taxes.line AS line,
    +                    SUM(sales_items_taxes.item_tax_amount) AS tax
    +                FROM ' . $this->db->dbprefix('sales_items_taxes') . ' AS sales_items_taxes
    +                INNER JOIN ' . $this->db->dbprefix('sales') . ' AS sales
    +                    ON sales.sale_id = sales_items_taxes.sale_id
    +                INNER JOIN ' . $this->db->dbprefix('sales_items') . ' AS sales_items
    +                    ON sales_items.sale_id = sales_items_taxes.sale_id AND sales_items.line = sales_items_taxes.line
    +                WHERE sale_status = 0 AND ' . $where . '
    +                GROUP BY sale_id, item_id, line
    +            )'
    +        );
    +
    +        $this->db->select("
    +                IFNULL(ROUND($sale_subtotal, $decimals), ROUND($sale_total - IFNULL(SUM(sales_items_taxes.tax), 0), $decimals)) AS subtotal,
    +                IFNULL(ROUND(SUM(sales_items_taxes.tax), $decimals), 0) AS tax,
    +                IFNULL(ROUND($sale_total, $decimals), ROUND($sale_subtotal, $decimals)) AS total,
    +                IFNULL(ROUND($sale_cost, $decimals), 0) AS cost,
    +                IFNULL(ROUND($sale_total - IFNULL(SUM(sales_items_taxes.tax), 0) - $sale_cost, $decimals), ROUND($sale_subtotal - $sale_cost, $decimals)) AS profit
    +        ");
    +    }
    +
    +    private function _common_from()
    +    {
    +        $this->db->from('sales_items AS sales_items');
    +        $this->db->join('sales AS sales', 'sales_items.sale_id = sales.sale_id', 'inner');
    +        $this->db->join('sales_items_taxes_temp AS sales_items_taxes',
    +            'sales_items.sale_id = sales_items_taxes.sale_id AND sales_items.item_id = sales_items_taxes.item_id AND sales_items.line = sales_items_taxes.line',
    +            'left outer');
    +    }
    +
    +    private function _common_where(array $inputs)
    +    {
    +        if(empty($this->config->item('date_or_time_format')))
    +        {
    +            $this->db->where('DATE(sales.sale_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']));
    +        }
    +        else
    +        {
    +            $this->db->where('sales.sale_time BETWEEN ' . $this->db->escape(rawurldecode($inputs['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($inputs['end_date'])));
    +        }
     
    -    private function _common_where(array $inputs)
    -    {
    -        if(empty($this->config->item('date_or_time_format')))
    -        {
    -            $this->db->where('DATE(sales.sale_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']));
    -        }
    -        else
    -        {
    -            $this->db->where('sales.sale_time BETWEEN ' . $this->db->escape(rawurldecode($inputs['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($inputs['end_date'])));
    -        }
    -
    -        if($inputs['location_id'] != 'all')
    -        {
    -            $this->db->where('sales_items.item_location', $inputs['location_id']);
    -        }
    -
    -        if($inputs['sale_type'] == 'sales')
    -        {
    -            $this->db->where('sales_items.quantity_purchased >= 0');
    -        }
    -        elseif($inputs['sale_type'] == 'returns')
    -        {
    -            $this->db->where('sales_items.quantity_purchased < 0');
    -        }
    -    }
    -
    -    /*
    -
    -    Protected class interface implemented by derived classes
    +        if($inputs['location_id'] != 'all')
    +        {
    +            $this->db->where('sales_items.item_location', $inputs['location_id']);
    +        }
    +
    +        if($inputs['sale_type'] == 'sales')
    +        {
    +            $this->db->where('sales_items.quantity_purchased >= 0');
    +        }
    +        elseif($inputs['sale_type'] == 'returns')
    +        {
    +            $this->db->where('sales_items.quantity_purchased < 0');
    +        }
    +    }
    +
    +    /*
    +
    +    Protected class interface implemented by derived classes
    +
    +    */
    +
    +    abstract protected function _get_data_columns();
    +
    +    protected function _select(array $inputs)   { $this->_common_select($inputs); }
    +    protected function _from()                  { $this->_common_from(); }
    +    protected function _where(array $inputs)    { $this->_common_where($inputs); }
    +    protected function _group_order()           {}
    +
    +    /*
     
    -    */
    -
    -    abstract protected function _get_data_columns();
    +    Public interface implementing the base abstract class, in general it should not be extended unless there is a valid reason
    +
    +    */
     
    -    protected function _select(array $inputs)   { $this->_common_select($inputs); }
    -    protected function _from()                  { $this->_common_from(); }
    -    protected function _where(array $inputs)    { $this->_common_where($inputs); }
    -    protected function _group_order()           {}
    +    public function getDataColumns()
    +    {
    +        return $this->_get_data_columns();
    +    }
     
    -    /*
    -
    -    Public interface implementing the base abstract class, in general it should not be extended unless there is a valid reason
    -
    -    */
    +    public function getData(array $inputs)
    +    {
    +        $this->_select($inputs);
    +
    +        $this->_from();
     
    -    public function getDataColumns()
    -    {
    -        return $this->_get_data_columns();
    -    }
    -
    -    public function getData(array $inputs)
    -    {
    -        $this->_select($inputs);
    -
    -        $this->_from();
    +        $this->_where($inputs);
    +
    +        $this->_group_order();
    +
    +        return $this->db->get()->result_array();
    +    }
    +
    +    public function getSummaryData(array $inputs)
    +    {
    +        $this->_common_select($inputs);
     
    -        $this->_where($inputs);
    +        $this->_common_from();
     
    -        $this->_group_order();
    +        $this->_where($inputs);
     
    -        return $this->db->get()->result_array();
    +        return $this->db->get()->row_array();
         }
    -
    -    public function getSummaryData(array $inputs)
    -    {
    -        $this->_common_select($inputs);
    -
    -        $this->_common_from();
    -
    -        $this->_where($inputs);
    -
    -        return $this->db->get()->row_array();
    -    }
    -}
    -?>
    -
    +} +?> + - + diff --git a/docs/source-class-Summary_sales.html b/docs/source-class-Summary_sales.html index 917d318e0..bdce1a2d8 100644 --- a/docs/source-class-Summary_sales.html +++ b/docs/source-class-Summary_sales.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,48 +207,43 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     
     require_once("Summary_report.php");
     
     class Summary_sales extends Summary_report
     {
    -    function __construct()
    +    protected function _get_data_columns()
         {
    -        parent::__construct();
    -    }
    -
    -    protected function _get_data_columns()
    -    {
    -        return array(
    -            array('sale_date' => $this->lang->line('reports_date')),
    -            array('quantity' => $this->lang->line('reports_quantity')),
    -            array('subtotal' => $this->lang->line('reports_subtotal'), 'sorter' => 'number_sorter'),
    -            array('tax' => $this->lang->line('reports_tax'), 'sorter' => 'number_sorter'),
    -            array('total' => $this->lang->line('reports_total'), 'sorter' => 'number_sorter'),
    -            array('cost' => $this->lang->line('reports_cost'), 'sorter' => 'number_sorter'),
    -            array('profit' => $this->lang->line('reports_profit'), 'sorter' => 'number_sorter'));
    -    }
    -
    -    protected function _select(array $inputs)
    -    {
    -        parent::_select($inputs);
    -
    -        $this->db->select('
    -                DATE(sales.sale_time) AS sale_date, 
    -                SUM(sales_items.quantity_purchased) AS quantity_purchased
    -        ');
    -    }
    -
    -    protected function _group_order()
    -    {
    -        $this->db->group_by('sale_date');
    -        $this->db->order_by('sale_date');
    -    }
    -}
    -?>
    -
    + return array( + array('sale_date' => $this->lang->line('reports_date')), + array('quantity' => $this->lang->line('reports_quantity')), + array('subtotal' => $this->lang->line('reports_subtotal'), 'sorter' => 'number_sorter'), + array('tax' => $this->lang->line('reports_tax'), 'sorter' => 'number_sorter'), + array('total' => $this->lang->line('reports_total'), 'sorter' => 'number_sorter'), + array('cost' => $this->lang->line('reports_cost'), 'sorter' => 'number_sorter'), + array('profit' => $this->lang->line('reports_profit'), 'sorter' => 'number_sorter')); + } + + protected function _select(array $inputs) + { + parent::_select($inputs); + + $this->db->select(' + DATE(sales.sale_time) AS sale_date, + SUM(sales_items.quantity_purchased) AS quantity_purchased + '); + } + + protected function _group_order() + { + $this->db->group_by('sale_date'); + $this->db->order_by('sale_date'); + } +} +?> + - + diff --git a/docs/source-class-Summary_suppliers.html b/docs/source-class-Summary_suppliers.html index d83a1d352..bec559300 100644 --- a/docs/source-class-Summary_suppliers.html +++ b/docs/source-class-Summary_suppliers.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,57 +207,52 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     
     require_once("Summary_report.php");
     
     class Summary_suppliers extends Summary_report
     {
    -    function __construct()
    +    protected function _get_data_columns()
         {
    -        parent::__construct();
    -    }
    -
    -    protected function _get_data_columns()
    -    {
    -        return array(
    -            array('supplier_name' => $this->lang->line('reports_supplier')),
    -            array('quantity' => $this->lang->line('reports_quantity')),
    -            array('subtotal' => $this->lang->line('reports_subtotal'), 'sorter' => 'number_sorter'),
    -            array('tax' => $this->lang->line('reports_tax'), 'sorter' => 'number_sorter'),
    -            array('total' => $this->lang->line('reports_total'), 'sorter' => 'number_sorter'),
    -            array('cost' => $this->lang->line('reports_cost'), 'sorter' => 'number_sorter'),
    -            array('profit' => $this->lang->line('reports_profit'), 'sorter' => 'number_sorter'));
    -    }
    -
    -    protected function _select(array $inputs)
    -    {
    -        parent::_select($inputs);
    -
    -        $this->db->select('
    -                MAX(CONCAT(supplier_c.company_name, " (", supplier_p.first_name, " ", supplier_p.last_name, ")")) AS supplier,
    -                SUM(sales_items.quantity_purchased) AS quantity_purchased
    -        ');
    -    }
    -
    -    protected function _from()
    -    {
    -        parent::_from();
    +        return array(
    +            array('supplier_name' => $this->lang->line('reports_supplier')),
    +            array('quantity' => $this->lang->line('reports_quantity')),
    +            array('subtotal' => $this->lang->line('reports_subtotal'), 'sorter' => 'number_sorter'),
    +            array('tax' => $this->lang->line('reports_tax'), 'sorter' => 'number_sorter'),
    +            array('total' => $this->lang->line('reports_total'), 'sorter' => 'number_sorter'),
    +            array('cost' => $this->lang->line('reports_cost'), 'sorter' => 'number_sorter'),
    +            array('profit' => $this->lang->line('reports_profit'), 'sorter' => 'number_sorter'));
    +    }
    +
    +    protected function _select(array $inputs)
    +    {
    +        parent::_select($inputs);
    +
    +        $this->db->select('
    +                MAX(CONCAT(supplier_c.company_name, " (", supplier_p.first_name, " ", supplier_p.last_name, ")")) AS supplier,
    +                SUM(sales_items.quantity_purchased) AS quantity_purchased
    +        ');
    +    }
    +
    +    protected function _from()
    +    {
    +        parent::_from();
    +
    +        $this->db->join('items AS items', 'sales_items.item_id = items.item_id');
    +        $this->db->join('suppliers AS supplier_c', 'items.supplier_id = supplier_c.person_id ');
    +        $this->db->join('people AS supplier_p', 'items.supplier_id = supplier_p.person_id');
    +    }
     
    -        $this->db->join('items AS items', 'sales_items.item_id = items.item_id');
    -        $this->db->join('suppliers AS supplier_c', 'items.supplier_id = supplier_c.person_id ');
    -        $this->db->join('people AS supplier_p', 'items.supplier_id = supplier_p.person_id');
    -    }
    -
    -    protected function _group_order()
    -    {
    -        $this->db->group_by('items.supplier_id');
    -        $this->db->order_by('MAX(CONCAT(supplier_c.company_name, " (", supplier_p.first_name, " ", supplier_p.last_name, ")"))');
    -    }
    -}
    -?>
    -
    + protected function _group_order() + { + $this->db->group_by('items.supplier_id'); + $this->db->order_by('MAX(CONCAT(supplier_c.company_name, " (", supplier_p.first_name, " ", supplier_p.last_name, ")"))'); + } +} +?> + - + diff --git a/docs/source-class-Summary_taxes.html b/docs/source-class-Summary_taxes.html index bb1e1f926..66088bed3 100644 --- a/docs/source-class-Summary_taxes.html +++ b/docs/source-class-Summary_taxes.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,90 +207,83 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     
     require_once("Summary_report.php");
     
     class Summary_taxes extends Summary_report
     {
    -    function __construct()
    +    protected function _get_data_columns()
         {
    -        parent::__construct();
    -    }
    -
    -    protected function _get_data_columns()
    -    {
    -        return array(
    -            array('tax_percent' => $this->lang->line('reports_tax_percent'), 'sorter' => 'number_sorter'),
    -            array('report_count' => $this->lang->line('reports_count')),
    -            array('subtotal' => $this->lang->line('reports_subtotal'), 'sorter' => 'number_sorter'),
    -            array('tax' => $this->lang->line('reports_tax'), 'sorter' => 'number_sorter'),
    -            array('total' => $this->lang->line('reports_total'), 'sorter' => 'number_sorter'));
    -    }
    -
    -    protected function _where(array $inputs)
    -    {
    -        if(empty($this->config->item('date_or_time_format')))
    -        {
    -            $this->db->where('sale_status = 0 AND DATE(sales.sale_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']));
    -        }
    -        else
    -        {
    -            $this->db->where('sale_status = 0 AND sales.sale_time BETWEEN ' . $this->db->escape(rawurldecode($inputs['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($inputs['end_date'])));
    -        }
    -    }
    -
    -    public function getData(array $inputs)
    -    {
    -        $where = '';
    -
    -        if(empty($this->config->item('date_or_time_format')))
    -        {
    -            $where .= 'WHERE sale_status = 0 AND DATE(sale_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']);
    -        }
    -        else
    +        return array(
    +            array('tax_percent' => $this->lang->line('reports_tax_percent'), 'sorter' => 'number_sorter'),
    +            array('report_count' => $this->lang->line('reports_count')),
    +            array('subtotal' => $this->lang->line('reports_subtotal'), 'sorter' => 'number_sorter'),
    +            array('tax' => $this->lang->line('reports_tax'), 'sorter' => 'number_sorter'),
    +            array('total' => $this->lang->line('reports_total'), 'sorter' => 'number_sorter'));
    +    }
    +
    +    protected function _where(array $inputs)
    +    {
    +        if(empty($this->config->item('date_or_time_format')))
    +        {
    +            $this->db->where('sale_status = 0 AND DATE(sales.sale_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']));
    +        }
    +        else
    +        {
    +            $this->db->where('sale_status = 0 AND sales.sale_time BETWEEN ' . $this->db->escape(rawurldecode($inputs['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($inputs['end_date'])));
    +        }
    +    }
    +
    +    public function getData(array $inputs)
    +    {
    +        $where = '';
    +
    +        if(empty($this->config->item('date_or_time_format')))
    +        {
    +            $where .= 'WHERE sale_status = 0 AND DATE(sale_time) BETWEEN ' . $this->db->escape($inputs['start_date']) . ' AND ' . $this->db->escape($inputs['end_date']);
    +        }
    +        else
    +        {
    +            $where .= 'WHERE sale_status = 0 AND sale_time BETWEEN ' . $this->db->escape(rawurldecode($inputs['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($inputs['end_date']));
    +        }
    +
    +        if($this->config->item('tax_included'))
             {
    -            $where .= 'WHERE sale_status = 0 AND sale_time BETWEEN ' . $this->db->escape(rawurldecode($inputs['start_date'])) . ' AND ' . $this->db->escape(rawurldecode($inputs['end_date']));
    -        }
    -
    -        if($this->config->item('tax_included'))
    +            $sale_total = '(sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100))';
    +            $sale_subtotal = '(sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100) * (100 / (100 + sales_items_taxes.percent)))';
    +        }
    +        else
             {
    -            $sale_total = '(sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100))';
    -            $sale_subtotal = '(sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100) * (100 / (100 + sales_items_taxes.percent)))';
    -            $sale_tax = '(sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100) * (1 - 100 / (100 + sales_items_taxes.percent)))';
    -        }
    -        else
    -        {
    -            $sale_total = '(sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100) * (1 + (sales_items_taxes.percent / 100)))';
    -            $sale_subtotal = '(sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100))';
    -            $sale_tax = '(sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100) * (sales_items_taxes.percent / 100))';
    -        }
    -
    -        $decimals = totals_decimals();
    -
    -        $query = $this->db->query("SELECT percent, count(*) AS count, ROUND(SUM(subtotal), $decimals) AS subtotal, ROUND(SUM(tax), $decimals) AS tax, ROUND(SUM(total), $decimals) AS total
    -            FROM (
    -                SELECT
    -                    CONCAT(IFNULL(ROUND(percent, $decimals), 0), '%') AS percent,
    -                    $sale_subtotal AS subtotal,
    -                    IFNULL($sale_tax, 0) AS tax,
    -                    IFNULL($sale_total, $sale_subtotal) AS total
    -                    FROM " . $this->db->dbprefix('sales_items') . ' AS sales_items
    -                    INNER JOIN ' . $this->db->dbprefix('sales') . ' AS sales
    -                        ON sales_items.sale_id = sales.sale_id
    -                    LEFT OUTER JOIN ' . $this->db->dbprefix('sales_items_taxes') . ' AS sales_items_taxes
    -                        ON sales_items.sale_id = sales_items_taxes.sale_id AND sales_items.item_id = sales_items_taxes.item_id AND sales_items.line = sales_items_taxes.line
    -                    ' . $where . '
    -                ) AS temp_taxes
    -            GROUP BY percent'
    -        );
    -
    -        return $query->result_array();
    -    }
    -}
    -?>
    -
    + $sale_total = '(sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100) * (1 + (sales_items_taxes.percent / 100)))'; + $sale_subtotal = '(sales_items.item_unit_price * sales_items.quantity_purchased * (1 - sales_items.discount_percent / 100))'; + } + + $decimals = totals_decimals(); + + $query = $this->db->query("SELECT percent, count(*) AS count, ROUND(SUM(subtotal), $decimals) AS subtotal, ROUND(SUM(tax), $decimals) AS tax, ROUND(SUM(total), $decimals) AS total + FROM ( + SELECT + CONCAT(IFNULL(ROUND(percent, $decimals), 0), '%') AS percent, + $sale_subtotal AS subtotal, + IFNULL(sales_items_taxes.item_tax_amount, 0) AS tax, + IFNULL($sale_total, $sale_subtotal) AS total + FROM " . $this->db->dbprefix('sales_items') . ' AS sales_items + INNER JOIN ' . $this->db->dbprefix('sales') . ' AS sales + ON sales_items.sale_id = sales.sale_id + LEFT OUTER JOIN ' . $this->db->dbprefix('sales_items_taxes') . ' AS sales_items_taxes + ON sales_items.sale_id = sales_items_taxes.sale_id AND sales_items.item_id = sales_items_taxes.item_id AND sales_items.line = sales_items_taxes.line + ' . $where . ' + ) AS temp_taxes + GROUP BY percent' + ); + + return $query->result_array(); + } +} +?> + - + diff --git a/docs/source-class-Supplier.html b/docs/source-class-Supplier.html index f405d4154..85f58f54d 100644 --- a/docs/source-class-Supplier.html +++ b/docs/source-class-Supplier.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -206,7 +208,7 @@
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 
    -
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
     /**
      * Supplier class
    @@ -497,6 +499,6 @@
     
     
     
    -
    +
     
     
    diff --git a/docs/source-class-Suppliers.html b/docs/source-class-Suppliers.html
    index a1251c810..e05acbb3e 100644
    --- a/docs/source-class-Suppliers.html
    +++ b/docs/source-class-Suppliers.html
    @@ -80,6 +80,8 @@
     				
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -381,6 +383,6 @@ - + diff --git a/docs/source-class-Tax.html b/docs/source-class-Tax.html index 9c291421e..a6a30573b 100644 --- a/docs/source-class-Tax.html +++ b/docs/source-class-Tax.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,394 +207,403 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 
    -
    <?php
    -class Tax extends CI_Model
    -{
    -    /*
    -    Determines if a given tax_code is on file
    -    */
    -    public function exists($tax_code)
    -    {
    -        $this->db->from('tax_codes');
    -        $this->db->where('tax_code', $tax_code);
    -
    -        return ($this->db->get()->num_rows() == 1);
    -    }
    -
    -    public function tax_rate_exists($tax_code, $tax_category_id)
    -    {
    -        $this->db->from('tax_code_rates');
    -        $this->db->where('rate_tax_code', $tax_code);
    -        $this->db->where('rate_tax_category_id', $tax_category_id);
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
    +
    +/**
    + * Tax class
    + *
    + * @link    github.com/jekkos/opensourcepos
    + * @since   3.1
    + * @author  SteveIreland
    + */
    +
    +class Tax extends CI_Model
    +{
    +    /*
    +    Determines if a given tax_code is on file
    +    */
    +    public function exists($tax_code)
    +    {
    +        $this->db->from('tax_codes');
    +        $this->db->where('tax_code', $tax_code);
     
             return ($this->db->get()->num_rows() == 1);
         }
     
    -    /*
    -    Gets total of rows
    -    */
    -    public function get_total_rows()
    -    {
    -        $this->db->from('tax_codes');
    -
    -        return $this->db->count_all_results();
    -    }
    -
    -    /*
    -    Gets information about a particular tax_code
    -    */
    -    public function get_info($tax_code)
    -    {
    -        $this->db->from('tax_codes');
    -        $this->db->join('tax_code_rates',
    -            'tax_code = rate_tax_code and rate_tax_category_id = 0', 'LEFT');
    -        $this->db->join('tax_categories',
    -            'rate_tax_category_id = tax_category_id');
    -        $this->db->where('tax_code', $tax_code);
    -
    -        $query = $this->db->get();
    -
    -        if($query->num_rows() == 1)
    -        {
    -            return $query->row();
    -        }
    -        else
    -        {
    -            //Get empty base parent object
    -            $tax_code_obj = new stdClass();
    +    public function tax_rate_exists($tax_code, $tax_category_id)
    +    {
    +        $this->db->from('tax_code_rates');
    +        $this->db->where('rate_tax_code', $tax_code);
    +        $this->db->where('rate_tax_category_id', $tax_category_id);
    +
    +        return ($this->db->get()->num_rows() == 1);
    +    }
    +
    +    /*
    +    Gets total of rows
    +    */
    +    public function get_total_rows()
    +    {
    +        $this->db->from('tax_codes');
    +
    +        return $this->db->count_all_results();
    +    }
    +
    +    /*
    +    Gets information about a particular tax_code
    +    */
    +    public function get_info($tax_code)
    +    {
    +        $this->db->from('tax_codes');
    +        $this->db->join('tax_code_rates',
    +            'tax_code = rate_tax_code and rate_tax_category_id = 0', 'LEFT');
    +        $this->db->join('tax_categories',
    +            'rate_tax_category_id = tax_category_id');
    +        $this->db->where('tax_code', $tax_code);
    +
    +        $query = $this->db->get();
     
    -            //Get all the fields from tax_codes table
    -            foreach($this->db->list_fields('tax_codes') as $field)
    -            {
    -                $tax_code_obj->$field = '';
    -            }
    -            foreach($this->db->list_fields('tax_code_rates') as $field)
    -            {
    -                $tax_code_obj->$field = '';
    -            }
    -
    -            return $tax_code_obj;
    -        }
    -    }
    -
    -    /*
    -Gets information about a particular tax_code
    -*/
    -    public function get_rate_info($tax_code, $tax_category_id)
    -    {
    -        $this->db->from('tax_code_rates');
    -        $this->db->join('tax_categories',
    -            'rate_tax_category_id = tax_category_id');
    -        $this->db->where('rate_tax_code', $tax_code);
    -        $this->db->where('rate_tax_category_id', $tax_category_id);
    -
    -        $query = $this->db->get();
    -
    -        if($query->num_rows() == 1)
    -        {
    -            return $query->row();
    -        }
    -        else
    -        {
    -            //Get empty base parent object
    -            $tax_rate_obj = new stdClass();
    +        if($query->num_rows() == 1)
    +        {
    +            return $query->row();
    +        }
    +        else
    +        {
    +            //Get empty base parent object
    +            $tax_code_obj = new stdClass();
    +
    +            //Get all the fields from tax_codes table
    +            foreach($this->db->list_fields('tax_codes') as $field)
    +            {
    +                $tax_code_obj->$field = '';
    +            }
    +            foreach($this->db->list_fields('tax_code_rates') as $field)
    +            {
    +                $tax_code_obj->$field = '';
    +            }
    +
    +            return $tax_code_obj;
    +        }
    +    }
    +
    +    /*
    +    Gets information about a particular tax_code
    +    */
    +    public function get_rate_info($tax_code, $tax_category_id)
    +    {
    +        $this->db->from('tax_code_rates');
    +        $this->db->join('tax_categories',
    +            'rate_tax_category_id = tax_category_id');
    +        $this->db->where('rate_tax_code', $tax_code);
    +        $this->db->where('rate_tax_category_id', $tax_category_id);
    +
    +        $query = $this->db->get();
     
    -            //Get all the fields from tax_codes table
    -            foreach($this->db->list_fields('tax_code_rates') as $field)
    -            {
    -                $tax_rate_obj->$field = '';
    -            }
    -            //Get all the fields from tax_code_rates table
    -            foreach($this->db->list_fields('tax_categories') as $field)
    -            {
    -                $tax_rate_obj->$field = '';
    -            }
    -
    -            return $tax_rate_obj;
    -        }
    -    }
    -
    -    /*
    -     * Gets the tax code to use for a given customer
    -     */
    -    public function get_sales_tax_code($city = '', $state = '')
    -    {
    -        // if tax code using both city and state cannot be found then  try again using just the state
    -        // if the state tax code cannot be found then try again using blanks for both
    -        $this->db->from('tax_codes');
    -        $this->db->where('city', $city);
    -        $this->db->where('state', $state);
    -        $this->db->where('tax_code_type', '0'); // sales tax
    -
    -        $query = $this->db->get();
    -
    -        if($query->num_rows() == 1)
    -        {
    -            return $query->row()->tax_code;
    -        }
    -        else
    -        {
    -            $this->db->from('tax_codes');
    -            $this->db->where('city', '');
    -            $this->db->where('state', $state);
    -            $this->db->where('tax_code_type', '0'); // sales tax
    -
    -            $query = $this->db->get();
    -
    -            if($query->num_rows() == 1)
    -            {
    -                return $query->row()->tax_code;
    -            }
    -            else
    -            {
    -                return $this->config->item('default_origin_tax_code');
    -            }
    -        }
    -
    -        return FALSE;
    -    }
    -
    -    /*
    -    Inserts or updates a tax_codes entry
    -    */
    -    public function save(&$tax_code_data, $tax_rate_data, $tax_code = -1)
    -    {
    -        if(!$this->exists($tax_code))
    -        {
    -            if($this->db->insert('tax_codes', $tax_code_data))
    -            {
    -                $this->save_tax_rates($tax_rate_data, $tax_code);
    -                return TRUE;
    -            }
    -
    -            return FALSE;
    -        }
    -
    -        $this->db->where('tax_code', $tax_code);
    -        if ($this->db->update('tax_codes', $tax_code_data))
    -        {
    -            $this->save_tax_rates($tax_rate_data, $tax_code);
    -            return TRUE;
    -        }
    -        else
    -        {
    -            return  FALSE;
    -        }
    -    }
    -
    -    public function save_tax_rates(&$tax_rate_data, $tax_code)
    -    {
    -        if(!$this->tax_rate_exists($tax_code, $tax_rate_data['rate_tax_category_id']))
    -        {
    -            if($this->db->insert('tax_code_rates', $tax_rate_data))
    -            {
    -                return TRUE;
    -            }
    +        if($query->num_rows() == 1)
    +        {
    +            return $query->row();
    +        }
    +        else
    +        {
    +            //Get empty base parent object
    +            $tax_rate_obj = new stdClass();
    +
    +            //Get all the fields from tax_codes table
    +            foreach($this->db->list_fields('tax_code_rates') as $field)
    +            {
    +                $tax_rate_obj->$field = '';
    +            }
    +            //Get all the fields from tax_code_rates table
    +            foreach($this->db->list_fields('tax_categories') as $field)
    +            {
    +                $tax_rate_obj->$field = '';
    +            }
    +
    +            return $tax_rate_obj;
    +        }
    +    }
    +
    +    /*
    +    Gets the tax code to use for a given customer
    +    */
    +    public function get_sales_tax_code($city = '', $state = '')
    +    {
    +        // if tax code using both city and state cannot be found then  try again using just the state
    +        // if the state tax code cannot be found then try again using blanks for both
    +        $this->db->from('tax_codes');
    +        $this->db->where('city', $city);
    +        $this->db->where('state', $state);
    +        $this->db->where('tax_code_type', '0'); // sales tax
    +
    +        $query = $this->db->get();
    +
    +        if($query->num_rows() == 1)
    +        {
    +            return $query->row()->tax_code;
    +        }
    +        else
    +        {
    +            $this->db->from('tax_codes');
    +            $this->db->where('city', '');
    +            $this->db->where('state', $state);
    +            $this->db->where('tax_code_type', '0'); // sales tax
    +
    +            $query = $this->db->get();
    +
    +            if($query->num_rows() == 1)
    +            {
    +                return $query->row()->tax_code;
    +            }
    +            else
    +            {
    +                return $this->config->item('default_origin_tax_code');
    +            }
    +        }
    +
    +        return FALSE;
    +    }
    +
    +    /*
    +    Inserts or updates a tax_codes entry
    +    */
    +    public function save(&$tax_code_data, $tax_rate_data, $tax_code = -1)
    +    {
    +        if(!$this->exists($tax_code))
    +        {
    +            if($this->db->insert('tax_codes', $tax_code_data))
    +            {
    +                $this->save_tax_rates($tax_rate_data, $tax_code);
    +                return TRUE;
    +            }
    +
    +            return FALSE;
    +        }
    +
    +        $this->db->where('tax_code', $tax_code);
    +        if ($this->db->update('tax_codes', $tax_code_data))
    +        {
    +            $this->save_tax_rates($tax_rate_data, $tax_code);
    +            return TRUE;
    +        }
    +        else
    +        {
    +            return  FALSE;
    +        }
    +    }
     
    -            return FALSE;
    -        }
    -
    -        $this->db->where('rate_tax_code', $tax_code);
    -        $this->db->where('rate_tax_category_id', $tax_rate_data['rate_tax_category_id']);
    -
    -        return $this->db->update('tax_code_rates', $tax_rate_data);
    -    }
    +    public function save_tax_rates(&$tax_rate_data, $tax_code)
    +    {
    +        if(!$this->tax_rate_exists($tax_code, $tax_rate_data['rate_tax_category_id']))
    +        {
    +            if($this->db->insert('tax_code_rates', $tax_rate_data))
    +            {
    +                return TRUE;
    +            }
     
    -    /*
    -    Inserts or updates an item kit's items
    -    */
    -    public function save_tax_rate_exceptions(&$tax_rate_data, $tax_code)
    -    {
    -        $success = TRUE;
    -
    -        //Run these queries as a transaction, we want to make sure we do all or nothing
    +            return FALSE;
    +        }
    +
    +        $this->db->where('rate_tax_code', $tax_code);
    +        $this->db->where('rate_tax_category_id', $tax_rate_data['rate_tax_category_id']);
    +
    +        return $this->db->update('tax_code_rates', $tax_rate_data);
    +    }
     
    -        $this->db->trans_start();
    -
    -        // Delete all exceptions for the given tax_code
    -        $this->delete_tax_rate_exceptions($tax_code);
    -
    -        if ($tax_rate_data != NULL)
    -        {
    -            foreach ($tax_rate_data as $row) 
    -            {
    -                $row['rate_tax_code'] = $tax_code;
    -                $success &= $this->db->insert('tax_code_rates', $row);
    -            }
    -        }
    +    /*
    +    Inserts or updates an item kit's items
    +    */
    +    public function save_tax_rate_exceptions(&$tax_rate_data, $tax_code)
    +    {
    +        $success = TRUE;
    +
    +        //Run these queries as a transaction, we want to make sure we do all or nothing
    +
    +        $this->db->trans_start();
    +
    +        // Delete all exceptions for the given tax_code
    +        $this->delete_tax_rate_exceptions($tax_code);
     
    -        $this->db->trans_complete();
    -
    -        $success &= $this->db->trans_status();
    -
    -        return $success;
    -    }
    -
    -    /*
    -    Deletes one tax_codes entry
    -    */
    -    public function delete($tax_code)
    -    {
    -        return $this->db->delete('tax_codes', array('tax_code' => $tax_code));
    -    }
    -
    -    /*
    -    Deletes a list of tax codes
    -    */
    -    public function delete_list($tax_codes)
    -    {
    -        $this->db->where_in('tax_code', $tax_codes);
    -
    -        return $this->db->delete('tax_codes');
    -    }
    -
    -
    -    /*
    -    Deletes all tax_rate_exceptions for given tax codes
    -    */
    -    public function delete_tax_rate_exceptions($tax_code)
    -    {
    -        $this->db->where('rate_tax_code', $tax_code);
    -        $this->db->where('rate_tax_category_id !=', 0);
    +        if ($tax_rate_data != NULL)
    +        {
    +            foreach ($tax_rate_data as $row)
    +            {
    +                $row['rate_tax_code'] = $tax_code;
    +                $success &= $this->db->insert('tax_code_rates', $row);
    +            }
    +        }
    +
    +        $this->db->trans_complete();
    +
    +        $success &= $this->db->trans_status();
    +
    +        return $success;
    +    }
    +
    +    /*
    +    Deletes one tax_codes entry
    +    */
    +    public function delete($tax_code)
    +    {
    +        return $this->db->delete('tax_codes', array('tax_code' => $tax_code));
    +    }
    +
    +    /*
    +    Deletes a list of tax codes
    +    */
    +    public function delete_list($tax_codes)
    +    {
    +        $this->db->where_in('tax_code', $tax_codes);
    +
    +        return $this->db->delete('tax_codes');
    +    }
     
    -        return $this->db->delete('tax_code_rates');
    -    }
    -
    -    /*
    -    Performs a search on tax_codes
    -    */
    -    public function search($search, $rows = 0, $limit_from = 0, $sort = 'tax_code', $order = 'asc')
    -    {
    -        $this->db->from('tax_codes');
    -        $this->db->join('tax_code_rates',
    -            'tax_code = rate_tax_code and rate_tax_category_id = 0', 'LEFT');
    -        if (!empty($search))
    -        {
    -            $this->db->like('tax_code', $search);
    -            $this->db->or_like('tax_code_name', $search);
    -        }
    -        $this->db->order_by($sort, $order);
    -
    -        if($rows > 0)
    -        {
    -            $this->db->limit($rows, $limit_from);
    -        }
    -
    -        return $this->db->get();
    -    }
    -
    -    /*
    -    Gets tax_codes
    -    */
    -    public function get_found_rows($search)
    -    {
    -        $this->db->from('tax_codes');
    -        if (!empty($search))
    -        {
    -            $this->db->like('tax_code', $search);
    -            $this->db->or_like('tax_code_name', $search);
    -        }
    -
    -        return $this->db->get()->num_rows();
    -    }
    -
    -    public function get_tax_code_type_name($tax_code_type) {
    -        if ($tax_code_type == '0')
    -        {
    -            return $this->lang->line('taxes_sales_tax');
    +
    +    /*
    +    Deletes all tax_rate_exceptions for given tax codes
    +    */
    +    public function delete_tax_rate_exceptions($tax_code)
    +    {
    +        $this->db->where('rate_tax_code', $tax_code);
    +        $this->db->where('rate_tax_category_id !=', 0);
    +
    +        return $this->db->delete('tax_code_rates');
    +    }
    +
    +    /*
    +    Performs a search on tax_codes
    +    */
    +    public function search($search, $rows = 0, $limit_from = 0, $sort = 'tax_code', $order = 'asc')
    +    {
    +        $this->db->from('tax_codes');
    +        $this->db->join('tax_code_rates',
    +            'tax_code = rate_tax_code and rate_tax_category_id = 0', 'LEFT');
    +        if (!empty($search))
    +        {
    +            $this->db->like('tax_code', $search);
    +            $this->db->or_like('tax_code_name', $search);
    +        }
    +        $this->db->order_by($sort, $order);
    +
    +        if($rows > 0)
    +        {
    +            $this->db->limit($rows, $limit_from);
    +        }
    +
    +        return $this->db->get();
    +    }
    +
    +    /*
    +    Gets tax_codes
    +    */
    +    public function get_found_rows($search)
    +    {
    +        $this->db->from('tax_codes');
    +        if (!empty($search))
    +        {
    +            $this->db->like('tax_code', $search);
    +            $this->db->or_like('tax_code_name', $search);
             }
    -        else
    -        {
    -            return $this->lang->line('taxes_vat_tax');
    -        }
    -    }
    -
    -    public function get_sales_tax_codes_search_suggestions($search, $limit = 25)
    -    {
    -
    -        $suggestions = array();
    -
    -        $this->db->from('tax_codes');
    -        if (!empty($search))
    -        {
    -            $this->db->like('tax_code', $search);
    -            $this->db->or_like('tax_code_name', $search);
    -        }
    -        $this->db->order_by('tax_code_name', 'asc');
    -
    -        foreach($this->db->get()->result() as $row)
    -        {
    -            $suggestions[] = array('value' => $row->tax_code, 'label' => ($row->tax_code . ' ' . $row->tax_code_name));
    -        }
    -
    -        //only return $limit suggestions
    -        if(count($suggestions > $limit))
    -        {
    -            $suggestions = array_slice($suggestions, 0,$limit);
    -        }
    -
    -        return $suggestions;
    -    }
    +
    +        return $this->db->get()->num_rows();
    +    }
    +
    +    public function get_tax_code_type_name($tax_code_type)
    +    {
    +        if ($tax_code_type == '0')
    +        {
    +            return $this->lang->line('taxes_sales_tax');
    +        }
    +        else
    +        {
    +            return $this->lang->line('taxes_vat_tax');
    +        }
    +    }
    +
    +    public function get_sales_tax_codes_search_suggestions($search, $limit = 25)
    +    {
    +        $suggestions = array();
    +
    +        $this->db->from('tax_codes');
    +        if (!empty($search))
    +        {
    +            $this->db->like('tax_code', $search);
    +            $this->db->or_like('tax_code_name', $search);
    +        }
    +        $this->db->order_by('tax_code_name', 'asc');
    +
    +        foreach($this->db->get()->result() as $row)
    +        {
    +            $suggestions[] = array('value' => $row->tax_code, 'label' => ($row->tax_code . ' ' . $row->tax_code_name));
    +        }
     
    -    public function get_tax_category_suggestions($search)
    -    {
    -        $suggestions = array();
    -
    -        $this->db->from('tax_categories');
    -        $this->db->where('tax_category_id !=', 0);
    -        if (!empty($search))
    -        {
    -            $this->db->like('tax_category', '%'.$search.'%');
    -        }
    -        $this->db->order_by('tax_category', 'asc');
    -
    -        foreach($this->db->get()->result() as $row)
    -        {
    -            $suggestions[] = array('value' => $row->tax_category_id, 'label' => $row->tax_category);
    -        }
    -
    -        return $suggestions;
    -    }
    -
    -    public function get_tax_category($tax_category_id)
    -    {
    -        $this->db->select('tax_category');
    -        $this->db->from('tax_categories');
    -        $this->db->where('tax_category_id', $tax_category_id);
    +        //only return $limit suggestions
    +        if(count($suggestions > $limit))
    +        {
    +            $suggestions = array_slice($suggestions, 0,$limit);
    +        }
    +
    +        return $suggestions;
    +    }
    +
    +    public function get_tax_category_suggestions($search)
    +    {
    +        $suggestions = array();
    +
    +        $this->db->from('tax_categories');
    +        $this->db->where('tax_category_id !=', 0);
    +        if (!empty($search))
    +        {
    +            $this->db->like('tax_category', '%'.$search.'%');
    +        }
    +        $this->db->order_by('tax_category', 'asc');
    +
    +        foreach($this->db->get()->result() as $row)
    +        {
    +            $suggestions[] = array('value' => $row->tax_category_id, 'label' => $row->tax_category);
    +        }
     
    -        return $this->db->get()->row()->tax_category;
    +        return $suggestions;
         }
     
    -    public function get_all_tax_categories()
    +    public function get_tax_category($tax_category_id)
         {
    -        $this->db->from('tax_categories');
    -        $this->db->order_by('tax_category_id');
    -
    -        return $this->db->get();
    -    }
    -
    -    public function get_tax_category_id($tax_category)
    -    {
    -        $this->db->select('tax_category_id');
    +        $this->db->select('tax_category');
    +        $this->db->from('tax_categories');
    +        $this->db->where('tax_category_id', $tax_category_id);
    +
    +        return $this->db->get()->row()->tax_category;
    +    }
    +
    +    public function get_all_tax_categories()
    +    {
             $this->db->from('tax_categories');
    -
    -        return $this->db->get()->row()->tax_category_id;
    -    }
    -
    -    public function get_tax_code_rate_exceptions($tax_code)
    -    {
    -        $this->db->from('tax_code_rates');
    -        $this->db->join('tax_categories', 'rate_tax_category_id = tax_category_id');
    -        $this->db->where('rate_tax_code', $tax_code);
    -        $this->db->where('rate_tax_category_id !=', 0);
    -        $this->db->order_by('tax_category', 'asc');
    -
    -        return $this->db->get()->result_array();
    -    }
    -}
    -?>
    -
    +
    $this->db->order_by('tax_category_id'); + + return $this->db->get(); + } + + public function get_tax_category_id($tax_category) + { + $this->db->select('tax_category_id'); + $this->db->from('tax_categories'); + + return $this->db->get()->row()->tax_category_id; + } + + public function get_tax_code_rate_exceptions($tax_code) + { + $this->db->from('tax_code_rates'); + $this->db->join('tax_categories', 'rate_tax_category_id = tax_category_id'); + $this->db->where('rate_tax_code', $tax_code); + $this->db->where('rate_tax_category_id !=', 0); + $this->db->order_by('tax_category', 'asc'); + + return $this->db->get()->result_array(); + } +} +?> +
    - + diff --git a/docs/source-class-Tax_lib.html b/docs/source-class-Tax_lib.html index 9bd6c586f..7c5358ce4 100644 --- a/docs/source-class-Tax_lib.html +++ b/docs/source-class-Tax_lib.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,331 +207,338 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
    -class Tax_lib
    -{
    -    const TAX_TYPE_SALES = 1;
    -    const TAX_TYPE_SALES_BY_INVOICE = 2;
    -    const TAX_TYPE_VAT = 0;
    -
    -    private $CI;
    -
    -    public function __construct()
    -    {
    -        $this->CI =& get_instance();
    -        $this->CI->load->library('sale_lib');
    -    }
    -
    -    public function get_tax_types()
    -    {
    -        return array(
    -            TAX_TYPE_SALES => $this->CI->lang->line('taxes_sales_tax'),
    -            TAX_TYPE_SALES_BY_INVOICE => $this->CI->lang->line('taxes_sales_tax_by_invoice'),
    -            TAX_TYPE_VAT => $this->CI->lang->line('taxes_vat_tax')
    -        );
    -    }
    -
    -    /*
    -     * Compute the tax basis and returns the tax amount
    -     */
    -    public function get_item_sales_tax($quantity, $price, $discount_percentage, $tax_percentage, $rounding_code)
    -    {
    -        $tax_decimals = $this->CI->config->config['tax_decimals'];
    -
    -        // The tax basis should be returned at the currency scale
    -        $tax_basis = $this->CI->sale_lib->get_item_total($quantity, $price, $discount_percentage, TRUE);
    +/**
    + * Tax library
    + *
    + * Library with utilities to manage taxes
    + *
    + * @link    github.com/jekkos/opensourcepos
    + * @since   3.1
    + * @author  SteveIreland
    + */
    +
    +class Tax_lib
    +{
    +    const TAX_TYPE_SALES = 1;
    +    const TAX_TYPE_SALES_BY_INVOICE = 2;
    +    const TAX_TYPE_VAT = 0;
    +
    +    private $CI;
    +
    +    public function __construct()
    +    {
    +        $this->CI =& get_instance();
    +        $this->CI->load->library('sale_lib');
    +    }
    +
    +    public function get_tax_types()
    +    {
    +        return array(
    +            TAX_TYPE_SALES => $this->CI->lang->line('taxes_sales_tax'),
    +            TAX_TYPE_SALES_BY_INVOICE => $this->CI->lang->line('taxes_sales_tax_by_invoice'),
    +            TAX_TYPE_VAT => $this->CI->lang->line('taxes_vat_tax')
    +        );
    +    }
     
    -        return $this->get_sales_tax_for_amount($tax_basis, $tax_percentage, $rounding_code, $tax_decimals);
    -    }
    -
    -    /*
    -     * Computes the item level sales tax amount for a given tax basis
    -     */
    -    public function get_sales_tax_for_amount($tax_basis, $tax_percentage, $rounding_code, $decimals)
    -    {
    -
    -        $tax_fraction = bcdiv($tax_percentage, 100);
    -
    -        $tax_amount = bcmul($tax_basis, $tax_fraction);
    -        $rounded_tax_amount = $tax_amount;
    -
    -        if($rounding_code == Rounding_code::HALF_UP)
    -        {
    -            $rounded_tax_amount = round ( $tax_amount, $decimals, PHP_ROUND_HALF_UP);
    -        }
    -        elseif($rounding_code == Rounding_code::HALF_DOWN)
    -        {
    -            $rounded_tax_amount = round ( $tax_amount, $decimals, PHP_ROUND_HALF_DOWN);
    -        }
    -        elseif($rounding_code == Rounding_code::HALF_EVEN)
    -        {
    -            $rounded_tax_amount = round ( $tax_amount, $decimals, PHP_ROUND_HALF_EVEN);
    -        }
    -        elseif($rounding_code == Rounding_code::HALF_ODD)
    -        {
    -            $rounded_tax_amount = round ( $tax_amount, $decimals, PHP_ROUND_HALF_UP);
    -        }
    -        elseif($rounding_code == Rounding_code::ROUND_UP) // ROUND_UP
    -        {
    -            $fig = (int) str_pad('1', $decimals, '0');
    -            $rounded_tax_amount = (ceil($tax_amount * $fig) / $fig);
    -        }
    -        elseif($rounding_code == Rounding_code::ROUND_DOWN) // ROUND_DOWN
    -        {
    -            $fig = (int) str_pad('1', $decimals, '0');
    -            $rounded_tax_amount = (floor($tax_amount * $fig) / $fig);
    +    /*
    +     * Compute the tax basis and returns the tax amount
    +     */
    +    public function get_item_sales_tax($quantity, $price, $discount_percentage, $tax_percentage, $rounding_code)
    +    {
    +        $tax_decimals = $this->CI->config->config['tax_decimals'];
    +
    +        // The tax basis should be returned at the currency scale
    +        $tax_basis = $this->CI->sale_lib->get_item_total($quantity, $price, $discount_percentage, TRUE);
    +
    +        return $this->get_sales_tax_for_amount($tax_basis, $tax_percentage, $rounding_code, $tax_decimals);
    +    }
    +
    +    /*
    +     * Computes the item level sales tax amount for a given tax basis
    +     */
    +    public function get_sales_tax_for_amount($tax_basis, $tax_percentage, $rounding_code, $decimals)
    +    {
    +
    +        $tax_fraction = bcdiv($tax_percentage, 100);
    +
    +        $tax_amount = bcmul($tax_basis, $tax_fraction);
    +        $rounded_tax_amount = $tax_amount;
    +
    +        if($rounding_code == Rounding_code::HALF_UP)
    +        {
    +            $rounded_tax_amount = round ( $tax_amount, $decimals, PHP_ROUND_HALF_UP);
    +        }
    +        elseif($rounding_code == Rounding_code::HALF_DOWN)
    +        {
    +            $rounded_tax_amount = round ( $tax_amount, $decimals, PHP_ROUND_HALF_DOWN);
    +        }
    +        elseif($rounding_code == Rounding_code::HALF_EVEN)
    +        {
    +            $rounded_tax_amount = round ( $tax_amount, $decimals, PHP_ROUND_HALF_EVEN);
    +        }
    +        elseif($rounding_code == Rounding_code::HALF_ODD)
    +        {
    +            $rounded_tax_amount = round ( $tax_amount, $decimals, PHP_ROUND_HALF_UP);
             }
    -        elseif($rounding_code == Rounding_code::HALF_FIVE)
    +        elseif($rounding_code == Rounding_code::ROUND_UP) // ROUND_UP
             {
    -            $rounded_tax_amount = round($tax_amount / 5) * 5;
    -        }
    -
    -        return $rounded_tax_amount;
    -    }
    -
    -    /*
    -    * Updates the sales_tax array which is later saved to the `sales_taxes` table and used for printing taxes on receipts and invoices
    -    */
    -    public function update_sales_taxes(&$sales_taxes, $tax_type, $tax_group, $tax_rate, $tax_basis, $item_tax_amount, $tax_group_sequence, $rounding_code, $sale_id, $name='', $tax_code='')
    -    {
    -
    -        $tax_group_index = $this->clean('X'.$tax_group);
    -
    -        if ($item_tax_amount != 0)
    -        {
    -            if(!array_key_exists($tax_group_index, $sales_taxes))
    -            {
    -                $insertkey = $tax_group_index;
    -
    -                $sales_tax = array($insertkey => array(
    -                    'sale_id' => $sale_id,
    -                    'tax_type' => $tax_type,
    -                    'tax_group' => $tax_group,
    -                    'sale_tax_basis' => $tax_basis,
    -                    'sale_tax_amount' => $item_tax_amount,
    -                    'print_sequence' => $tax_group_sequence,
    -                    'name' => $name,
    -                    'tax_rate' => $tax_rate,
    -                    'sales_tax_code' => $tax_code,
    -                    'rounding_code' => $rounding_code
    -                ));
    -
    -                //add to existing array
    -                $sales_taxes += $sales_tax;
    -            }
    -            else
    -            {
    -                // Important ... the sales amounts are accumulated for the group at the maximum configurable scale value of 4
    -                // but the scale will in reality be the scale specified by the tax_decimal configuration value  used for sales_items_taxes
    -                $sales_taxes[$tax_group_index]['sale_tax_basis'] = bcadd($sales_taxes[$tax_group_index]['sale_tax_basis'], $tax_basis, 4);
    -                $sales_taxes[$tax_group_index]['sale_tax_amount'] = bcadd($sales_taxes[$tax_group_index]['sale_tax_amount'], $item_tax_amount, 4);
    -            }
    +            $fig = (int) str_pad('1', $decimals, '0');
    +            $rounded_tax_amount = (ceil($tax_amount * $fig) / $fig);
    +        }
    +        elseif($rounding_code == Rounding_code::ROUND_DOWN) // ROUND_DOWN
    +        {
    +            $fig = (int) str_pad('1', $decimals, '0');
    +            $rounded_tax_amount = (floor($tax_amount * $fig) / $fig);
    +        }
    +        elseif($rounding_code == Rounding_code::HALF_FIVE)
    +        {
    +            $rounded_tax_amount = round($tax_amount / 5) * 5;
    +        }
    +
    +        return $rounded_tax_amount;
    +    }
    +
    +    /*
    +    * Updates the sales_tax array which is later saved to the `sales_taxes` table and used for printing taxes on receipts and invoices
    +    */
    +    public function update_sales_taxes(&$sales_taxes, $tax_type, $tax_group, $tax_rate, $tax_basis, $item_tax_amount, $tax_group_sequence, $rounding_code, $sale_id, $name='', $tax_code='')
    +    {
    +
    +        $tax_group_index = $this->clean('X'.$tax_group);
    +
    +        if(!array_key_exists($tax_group_index, $sales_taxes))
    +        {
    +            $insertkey = $tax_group_index;
    +
    +            $sales_tax = array($insertkey => array(
    +                'sale_id' => $sale_id,
    +                'tax_type' => $tax_type,
    +                'tax_group' => $tax_group,
    +                'sale_tax_basis' => $tax_basis,
    +                'sale_tax_amount' => $item_tax_amount,
    +                'print_sequence' => $tax_group_sequence,
    +                'name' => $name,
    +                'tax_rate' => $tax_rate,
    +                'sales_tax_code' => $tax_code,
    +                'rounding_code' => $rounding_code
    +            ));
    +
    +            //add to existing array
    +            $sales_taxes += $sales_tax;
             }
    -    }
    -
    -    /*
    -    * If invoice taxing (as opposed to invoice_item_taxing) rules apply then recalculate the sales tax after tax group totals are final
    -    */
    -    public function apply_invoice_taxing(&$sales_taxes)
    -    {
    -        if(!empty($sales_taxes))
    -        {
    -            $sort = array();
    -            foreach($sales_taxes as $k => $v)
    -            {
    -                $sort['print_sequence'][$k] = $v['print_sequence'];
    -            }
    -            array_multisort($sort['print_sequence'], SORT_ASC, $sales_taxes);
    -        }
    -
    -        $currency_decimals = $this->CI->config->config['currency_decimals'];
    -
    -        foreach($sales_taxes as $row_number => $sales_tax)
    -        {
    -            $sales_tax['sale_tax_amount'] = get_sales_tax_for_amount($sales_tax['sale_tax_basis'], $sales_tax['sale_tax_rate'], $sales_tax['rounding_code'], $currency_decimals);
    +        else
    +        {
    +            // Important ... the sales amounts are accumulated for the group at the maximum configurable scale value of 4
    +            // but the scale will in reality be the scale specified by the tax_decimal configuration value  used for sales_items_taxes
    +            $sales_taxes[$tax_group_index]['sale_tax_basis'] = bcadd($sales_taxes[$tax_group_index]['sale_tax_basis'], $tax_basis, 4);
    +            $sales_taxes[$tax_group_index]['sale_tax_amount'] = bcadd($sales_taxes[$tax_group_index]['sale_tax_amount'], $item_tax_amount, 4);
    +        }
    +    }
    +
    +    /*
    +    * If invoice taxing (as opposed to invoice_item_taxing) rules apply then recalculate the sales tax after tax group totals are final
    +    */
    +    public function apply_invoice_taxing(&$sales_taxes)
    +    {
    +        if(!empty($sales_taxes))
    +        {
    +            $sort = array();
    +            foreach($sales_taxes as $k => $v)
    +            {
    +                $sort['print_sequence'][$k] = $v['print_sequence'];
    +            }
    +            array_multisort($sort['print_sequence'], SORT_ASC, $sales_taxes);
             }
    -    }
    -
    -    /*
    -     * Apply rounding rules to the accumulated sales tax amounts
    -     */
    -    public function round_sales_taxes(&$sales_taxes)
    -    {
    -        if(!empty($sales_taxes))
    -        {
    -            $sort = array();
    -            foreach($sales_taxes as $k=>$v)
    -            {
    -                $sort['print_sequence'][$k] = $v['print_sequence'];
    -            }
    -            array_multisort($sort['print_sequence'], SORT_ASC, $sales_taxes);
    -        }
    -
    -        $currency_decimals = $this->CI->config->config['currency_decimals'];
    -
    -        foreach($sales_taxes as $row_number => $sales_tax)
    -        {
    -            $sale_tax_amount = $sales_tax['sale_tax_amount'];
    -            $rounding_code = $sales_tax['rounding_code'];
    -            $rounded_sale_tax_amount = $sale_tax_amount;
    -
    -            if ($rounding_code == Rounding_code::HALF_UP)
    -            {
    -                $rounded_sale_tax_amount = round ( $sale_tax_amount, $currency_decimals, PHP_ROUND_HALF_UP);
    -            }
    -            elseif($rounding_code == Rounding_code::HALF_DOWN)
    -            {
    -                $rounded_sale_tax_amount = round ( $sale_tax_amount, $currency_decimals, PHP_ROUND_HALF_DOWN);
    -            }
    -            elseif($rounding_code == Rounding_code::HALF_EVEN)
    -            {
    -                $rounded_sale_tax_amount = round ( $sale_tax_amount, $currency_decimals, PHP_ROUND_HALF_EVEN);
    -            }
    -            elseif($rounding_code == Rounding_code::HALF_ODD)
    -            {
    -                $rounded_sale_tax_amount = round ( $sale_tax_amount, $currency_decimals, PHP_ROUND_HALF_UP);
    -            }
    -            elseif($rounding_code == Rounding_code::ROUND_UP)
    -            {
    -                $fig = (int) str_pad('1', $currency_decimals, '0');
    -                $rounded_sale_tax_amount = (ceil($sale_tax_amount * $fig) / $fig);
    -            }
    -            elseif($rounding_code == Rounding_code::ROUND_DOWN)
    -            {
    -                $fig = (int) str_pad('1', $currency_decimals, '0');
    -                $rounded_sale_tax_amount = (floor($sale_tax_amount * $fig) / $fig);
    -            }
    -            elseif($rounding_code == Rounding_code::HALF_FIVE)
    -            {
    -                $rounded_sale_tax_amount = round($sale_tax_amount / 5) * 5;
    -            }
    -
    -            $sales_taxes[$row_number]['sale_tax_amount'] = $rounded_sale_tax_amount;
    -        }
    -    }
    -
    -
    -    /**
    -     * Determine the applicable tax code and then determine the tax amount to be applied.
    -     * If a tax amount was identified then accumulate into the sales_taxes array
    -     */
    -    public function apply_sales_tax(&$item, &$city, &$state, &$sales_tax_code, $register_mode, $sale_id, &$sales_taxes)
    -    {
    -        $tax_code = $this->get_applicable_tax_mode($register_mode, $city, $state, $sales_tax_code);
    -
    -        // If tax code cannot be determined or the price is zero then skip this item
    -        if($tax_code != '' && $item['price'] != 0)
    -        {
    -            $tax_rate = 0.0000;
    -            $rounding_code = Rounding_code::HALF_UP;
    -
    -            $tax_code_obj = $this->CI->Tax->get_info($tax_code);
    -            $tax_category_id = $item['tax_category_id'];
    -
    -            if($tax_category_id != 0)
    -            {
    -                $tax_rate_info = $this->CI->Tax->get_rate_info($tax_code, $tax_category_id);
    -                if ($tax_rate_info)
    -                {
    -                    $tax_rate = $tax_rate_info->tax_rate;
    -                    $rounding_code = $tax_rate_info->rounding_code;
    -                }
    -                else
    -                {
    -                    $tax_rate = $tax_code_obj->tax_rate;
    -                    $rounding_code = $tax_code_obj->rounding_code;
    -                }
    -            }
    -
    -            if($tax_category_id != 0)
    -            {
    -                $tax_rate_info = $this->CI->Tax->get_rate_info($tax_code, $tax_category_id);
    -                $tax_rate = $tax_rate_info->tax_rate;
    -                $rounding_code = $tax_rate_info->rounding_code;
    -                $tax_group_sequence = $tax_rate_info->tax_group_sequence;
    -                $tax_category = $tax_rate_info->tax_category;
    -            }
    -            else
    -            {
    -                $tax_rate = $tax_code_obj->tax_rate;
    -                $rounding_code = $tax_code_obj->rounding_code;
    -                $tax_group_sequence = $tax_code_obj->tax_group_sequence;
    -                $tax_category = $tax_code_obj->tax_category;
    +
    +        $currency_decimals = $this->CI->config->config['currency_decimals'];
    +
    +        foreach($sales_taxes as $row_number => $sales_tax)
    +        {
    +            $sales_taxes[$row_number]['sale_tax_amount'] = $this->get_sales_tax_for_amount($sales_tax['sale_tax_basis'], $sales_tax['tax_rate'], $sales_tax['rounding_code'], $currency_decimals);
    +        }
    +    }
    +
    +    /*
    +     * Apply rounding rules to the accumulated sales tax amounts
    +     */
    +    public function round_sales_taxes(&$sales_taxes)
    +    {
    +        if(!empty($sales_taxes))
    +        {
    +            $sort = array();
    +            foreach($sales_taxes as $k=>$v)
    +            {
    +                $sort['print_sequence'][$k] = $v['print_sequence'];
    +            }
    +            array_multisort($sort['print_sequence'], SORT_ASC, $sales_taxes);
    +        }
    +
    +        $currency_decimals = $this->CI->config->config['currency_decimals'];
    +
    +        foreach($sales_taxes as $row_number => $sales_tax)
    +        {
    +            $sale_tax_amount = $sales_tax['sale_tax_amount'];
    +            $rounding_code = $sales_tax['rounding_code'];
    +            $rounded_sale_tax_amount = $sale_tax_amount;
    +
    +            if ($rounding_code == Rounding_code::HALF_UP)
    +            {
    +                $rounded_sale_tax_amount = round ( $sale_tax_amount, $currency_decimals, PHP_ROUND_HALF_UP);
    +            }
    +            elseif($rounding_code == Rounding_code::HALF_DOWN)
    +            {
    +                $rounded_sale_tax_amount = round ( $sale_tax_amount, $currency_decimals, PHP_ROUND_HALF_DOWN);
    +            }
    +            elseif($rounding_code == Rounding_code::HALF_EVEN)
    +            {
    +                $rounded_sale_tax_amount = round ( $sale_tax_amount, $currency_decimals, PHP_ROUND_HALF_EVEN);
    +            }
    +            elseif($rounding_code == Rounding_code::HALF_ODD)
    +            {
    +                $rounded_sale_tax_amount = round ( $sale_tax_amount, $currency_decimals, PHP_ROUND_HALF_UP);
    +            }
    +            elseif($rounding_code == Rounding_code::ROUND_UP)
    +            {
    +                $fig = (int) str_pad('1', $currency_decimals, '0');
    +                $rounded_sale_tax_amount = (ceil($sale_tax_amount * $fig) / $fig);
    +            }
    +            elseif($rounding_code == Rounding_code::ROUND_DOWN)
    +            {
    +                $fig = (int) str_pad('1', $currency_decimals, '0');
    +                $rounded_sale_tax_amount = (floor($sale_tax_amount * $fig) / $fig);
    +            }
    +            elseif($rounding_code == Rounding_code::HALF_FIVE)
    +            {
    +                $rounded_sale_tax_amount = round($sale_tax_amount / 5) * 5;
    +            }
    +
    +            $sales_taxes[$row_number]['sale_tax_amount'] = $rounded_sale_tax_amount;
    +        }
    +    }
    +
    +
    +    /**
    +     * Determine the applicable tax code and then determine the tax amount to be applied.
    +     * If a tax amount was identified then accumulate into the sales_taxes array
    +     */
    +    public function apply_sales_tax(&$item, &$city, &$state, &$sales_tax_code, $register_mode, $sale_id, &$sales_taxes)
    +    {
    +        $tax_code = $this->get_applicable_tax_mode($register_mode, $city, $state, $sales_tax_code);
    +
    +        // If tax code cannot be determined or the price is zero then skip this item
    +        if($tax_code != '' && $item['price'] != 0)
    +        {
    +            $tax_rate = 0.0000;
    +            $rounding_code = Rounding_code::HALF_UP;
    +
    +            $tax_code_obj = $this->CI->Tax->get_info($tax_code);
    +            $tax_category_id = $item['tax_category_id'];
    +
    +            if($tax_category_id != 0)
    +            {
    +                $tax_rate_info = $this->CI->Tax->get_rate_info($tax_code, $tax_category_id);
    +                if ($tax_rate_info)
    +                {
    +                    $tax_rate = $tax_rate_info->tax_rate;
    +                    $rounding_code = $tax_rate_info->rounding_code;
    +                }
    +                else
    +                {
    +                    $tax_rate = $tax_code_obj->tax_rate;
    +                    $rounding_code = $tax_code_obj->rounding_code;
    +                }
    +            }
    +
    +            if($tax_category_id != 0)
    +            {
    +                $tax_rate_info = $this->CI->Tax->get_rate_info($tax_code, $tax_category_id);
    +                $tax_rate = $tax_rate_info->tax_rate;
    +                $rounding_code = $tax_rate_info->rounding_code;
    +                $tax_group_sequence = $tax_rate_info->tax_group_sequence;
    +                $tax_category = $tax_rate_info->tax_category;
                 }
    -
    -            $tax_decimals = $this->CI->config->config['tax_decimals'];
    -
    -            // The tax basis should be returned at the currency scale
    -            $tax_basis = $this->CI->sale_lib->get_item_total($item['quantity'], $item['price'], $item['discount'], TRUE);
    -            $tax_amount = $this->get_sales_tax_for_amount($tax_basis, $tax_rate, $rounding_code, $tax_decimals);
    -
    -            $tax_group = (float)$tax_rate . '% ' . $tax_category;
    -            $tax_type = Tax_lib::TAX_TYPE_SALES;
    +            else
    +            {
    +                $tax_rate = $tax_code_obj->tax_rate;
    +                $rounding_code = $tax_code_obj->rounding_code;
    +                $tax_group_sequence = $tax_code_obj->tax_group_sequence;
    +                $tax_category = $tax_code_obj->tax_category;
    +            }
    +
    +            $tax_decimals = $this->CI->config->config['tax_decimals'];
     
    -            if($tax_amount != 0)
    -            {
    -                $this->update_sales_taxes($sales_taxes, $tax_type, $tax_group, $tax_rate, $tax_basis, $tax_amount, $tax_group_sequence, $rounding_code, $sale_id, $tax_category, $tax_code);
    -            }
    -
    -            // input : register_mode
    -            // input : city
    -            // input : state
    -            // input : sales_tax_code
    -            // input : $item['price']
    -            // input : $item['tax_category_id']
    -            // input : $item['quantity']
    -            // input : $item['price']
    -            // input : $item['discount']
    -            // both : $sales_taxes
    -            // output : tax_details['tax_rate']
    -            // output : tax_details['rounding_code']
    -            // output : tax_details['tax_group_sequence']
    -            // output : tax_details['tax_code']
    -
    -            $tax_details = array('item_tax_amount' => $tax_amount, 'tax_group' => $tax_group, 'tax_name' => $tax_category, 'tax_rate' => $tax_rate, 'rounding_code' => $rounding_code, 'tax_group_sequence' => $tax_group_sequence, 'tax_code' => $tax_code);
    -
    -            return $tax_details;
    -        }
    -        else
    -        {
    -            $tax_details = array('item_tax_amount' => 0.0000, 'tax_group' => '', 'tax_name' => '', 'tax_rate' => 0.0000, 'rounding_code' => '0', 'tax_group_sequence' => '0', 'tax_code' => '');
    -            return $tax_details;
    -        }
    -    }
    -
    -    public function get_applicable_tax_mode($register_mode, $city, $state, $sales_tax_code)
    -    {
    -        if ($register_mode == "SALE")
    -        {
    -            $tax_code = $this->CI->config->config['default_origin_tax_code']; // overrides customer assigned code
    -        }
    -        else
    -        {
    -            if ($sales_tax_code == '')
    -            {
    -                $tax_code = $this->CI->Tax->get_sales_tax_code($city, $state);
    -            }
    -            else
    -            {
    -                // Use the customer assigned tax rate code
    -                $tax_code = $sales_tax_code;
    -            }
    -        }
    -
    -        return $tax_code;
    -    }
    -
    -    function clean($string) {
    -        $string = str_replace(' ', '-', $string); // Replaces all spaces with hyphens.
    -
    -        return preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars.
    -    }
    -}
    +            // The tax basis should be returned at the currency scale
    +            $tax_basis = $this->CI->sale_lib->get_item_total($item['quantity'], $item['price'], $item['discount'], TRUE);
    +            $tax_amount = $this->get_sales_tax_for_amount($tax_basis, $tax_rate, $rounding_code, $tax_decimals);
    +
    +            $tax_group = (float)$tax_rate . '% ' . $tax_category;
    +            $tax_type = Tax_lib::TAX_TYPE_SALES;
    +
    +            if($tax_amount != 0)
    +            {
    +                $this->update_sales_taxes($sales_taxes, $tax_type, $tax_group, $tax_rate, $tax_basis, $tax_amount, $tax_group_sequence, $rounding_code, $sale_id, $tax_category, $tax_code);
    +            }
    +
    +            // input : register_mode
    +            // input : city
    +            // input : state
    +            // input : sales_tax_code
    +            // input : $item['price']
    +            // input : $item['tax_category_id']
    +            // input : $item['quantity']
    +            // input : $item['price']
    +            // input : $item['discount']
    +            // both : $sales_taxes
    +            // output : tax_details['tax_rate']
    +            // output : tax_details['rounding_code']
    +            // output : tax_details['tax_group_sequence']
    +            // output : tax_details['tax_code']
    +
    +            $tax_details = array('item_tax_amount' => $tax_amount, 'tax_group' => $tax_group, 'tax_name' => $tax_category, 'tax_rate' => $tax_rate, 'rounding_code' => $rounding_code, 'tax_group_sequence' => $tax_group_sequence, 'tax_code' => $tax_code);
    +
    +            return $tax_details;
    +        }
    +        else
    +        {
    +            $tax_details = array('item_tax_amount' => 0.0000, 'tax_group' => '', 'tax_name' => '', 'tax_rate' => 0.0000, 'rounding_code' => '0', 'tax_group_sequence' => '0', 'tax_code' => '');
    +            return $tax_details;
    +        }
    +    }
    +
    +    public function get_applicable_tax_mode($register_mode, $city, $state, $sales_tax_code)
    +    {
    +        if ($register_mode == "SALE")
    +        {
    +            $tax_code = $this->CI->config->config['default_origin_tax_code']; // overrides customer assigned code
    +        }
    +        else
    +        {
    +            if ($sales_tax_code == '')
    +            {
    +                $tax_code = $this->CI->Tax->get_sales_tax_code($city, $state);
    +            }
    +            else
    +            {
    +                // Use the customer assigned tax rate code
    +                $tax_code = $sales_tax_code;
    +            }
    +        }
    +
    +        return $tax_code;
    +    }
     
    -?>
    -
    +
    public function clean($string) + { + $string = str_replace(' ', '-', $string); // Replaces all spaces with hyphens. + + return preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars. + } +} +?> +
    - + diff --git a/docs/source-class-Taxes.html b/docs/source-class-Taxes.html index 9e9d7e83b..89f340925 100644 --- a/docs/source-class-Taxes.html +++ b/docs/source-class-Taxes.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -440,6 +442,6 @@ - + diff --git a/docs/source-class-Token.html b/docs/source-class-Token.html index bcf0f1a78..4137e98e0 100644 --- a/docs/source-class-Token.html +++ b/docs/source-class-Token.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,8 +207,8 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 
    -
    <?php
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 
    +
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     
     require_once(APPPATH . 'libraries/tokens/Token.php');
     require_once(APPPATH . 'libraries/tokens/Token_customer.php');
    @@ -216,54 +218,63 @@
     require_once(APPPATH . 'libraries/tokens/Token_suspended_invoice_count.php');
     require_once(APPPATH . 'libraries/tokens/Token_year_invoice_count.php');
     
    -class Token
    -{
    -    private $CI;
    -
    -    public function __construct()
    -    {
    -        $this->CI =& get_instance();
    -    }
    -
    -    public function replace($token_id)
    -    {
    -        if($token_id == 'CU')
    -        {
    -            return (new Token_customer())->get_value();
    -        }
    -        elseif($token_id == 'CO')
    -        {
    -            return (new Token_invoice_count())->get_value();
    -        }
    -        elseif($token_id == 'ISEQ')
    +/**
    + * Token class
    + *
    + * @link    github.com/jekkos/opensourcepos
    + * @since   3.1
    + * @author  SteveIreland
    + */
    +
    +class Token
    +{
    +    protected $CI;
    +
    +    public function __construct()
    +    {
    +        $this->CI =& get_instance();
    +    }
    +
    +    public function replace($token_id)
    +    {
    +        if($token_id == 'CU')
             {
    -            return (new Token_invoice_sequence())->get_value();
    +            return (new Token_customer())->get_value();
             }
    -        elseif($token_id == 'ISEQ')
    +        elseif($token_id == 'CO')
             {
    -            return (new Token_invoice_sequence())->get_value();
    +            return (new Token_invoice_count())->get_value();
             }
    -        elseif($token_id == 'QSEQ')
    +        elseif($token_id == 'ISEQ')
             {
    -            return (new Token_quote_sequence())->get_value();
    +            return (new Token_invoice_sequence())->get_value();
             }
    -        elseif($token_id == 'SCO')
    +        elseif($token_id == 'ISEQ')
             {
    -            return (new Token_suspended_invoice_count())->get_value();
    +            return (new Token_invoice_sequence())->get_value();
             }
    -        elseif($token_id == 'YCO')
    +        elseif($token_id == 'QSEQ')
             {
    -            return (new Token_year_invoice_count())->get_value();
    +            return (new Token_quote_sequence())->get_value();
             }
    -        return '';
    -    }
    -
    -    function get_value(){
    -        return '';
    -    }
    -}
    -
    -?>
    +
    elseif($token_id == 'SCO') + { + return (new Token_suspended_invoice_count())->get_value(); + } + elseif($token_id == 'YCO') + { + return (new Token_year_invoice_count())->get_value(); + } + return ''; + } + + public function get_value() + { + return ''; + } +} +?> +
    - + diff --git a/docs/source-class-Token_customer.html b/docs/source-class-Token_customer.html index cfe1dcac8..e9a11dcdf 100644 --- a/docs/source-class-Token_customer.html +++ b/docs/source-class-Token_customer.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,38 +207,44 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 
    -
    <?php
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 
    +
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     
    -class Token_customer extends Token
    -{
    -    private $CI;
    -
    -    public function __construct()
    -    {
    -        parent::__construct();
    -        $this->CI =& get_instance();
    -        $this->CI->load->library('sale_lib');
    -    }
    -
    -    public function get_value()
    -    {
    -        // substitute customer info
    -        $customer_id = $this->CI->sale_lib->get_customer();
    -        if($customer_id != -1)
    -        {
    -            $customer_info = $this->CI->Customer->get_info($customer_id);
    -            if($customer_info != '')
    -            {
    -                return trim($customer_info->first_name . ' ' . $customer_info->last_name);
    -            }
    -        }
    -
    -        return '';
    -
    -    }
    -
    -}
    +
    /** + * Token_customer class + * + * @link github.com/jekkos/opensourcepos + * @since 3.1 + * @author SteveIreland + */ + +class Token_customer extends Token +{ + public function __construct() + { + parent::__construct(); + + $this->CI->load->library('sale_lib'); + } + + public function get_value() + { + // substitute customer info + $customer_id = $this->CI->sale_lib->get_customer(); + if($customer_id != -1) + { + $customer_info = $this->CI->Customer->get_info($customer_id); + if($customer_info != '') + { + return trim($customer_info->first_name . ' ' . $customer_info->last_name); + } + } + + return ''; + } +} +?> +
    - + diff --git a/docs/source-class-Token_invoice_count.html b/docs/source-class-Token_invoice_count.html index 1b0c2996e..3de459135 100644 --- a/docs/source-class-Token_invoice_count.html +++ b/docs/source-class-Token_invoice_count.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,25 +207,33 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 
    -
    <?php
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 
    +
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     
    -class Token_invoice_count extends Token
    -{
    -    private $CI;
    -
    -    public function __construct()
    -    {
    -        parent::__construct();
    -        $this->CI =& get_instance();
    -        $this->CI->load->model('Sale');
    -    }
    -
    -    public function get_value()
    -    {
    -        return $this->CI->Sale->get_invoice_count();
    -    }
    -}
    +
    /** + * Token_invoice_count class + * + * @link github.com/jekkos/opensourcepos + * @since 3.1 + * @author SteveIreland + */ + +class Token_invoice_count extends Token +{ + public function __construct() + { + parent::__construct(); + + $this->CI->load->model('Sale'); + } + + public function get_value() + { + return $this->CI->Sale->get_invoice_count(); + } +} +?> +
    - + diff --git a/docs/source-class-Token_invoice_sequence.html b/docs/source-class-Token_invoice_sequence.html index f4ec1cf8c..bc170daca 100644 --- a/docs/source-class-Token_invoice_sequence.html +++ b/docs/source-class-Token_invoice_sequence.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,24 +207,26 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 
    -
    <?php
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 
    +
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     
    -class Token_invoice_sequence extends Token
    -{
    -    private $CI;
    -
    -    public function __construct()
    -    {
    -        parent::__construct();
    -        $this->CI =& get_instance();
    -    }
    -
    +/**
    + * Token_invoice_sequence class
    + *
    + * @link    github.com/jekkos/opensourcepos
    + * @since   3.1
    + * @author  SteveIreland
    + */
    +
    +class Token_invoice_sequence extends Token
    +{
         public function get_value()
         {
             return $this->CI->Appconfig->acquire_save_next_invoice_sequence();
         }
    -}
    +
    } +?> +
    - + diff --git a/docs/source-class-Token_lib.html b/docs/source-class-Token_lib.html index 20416a483..21f74f34b 100644 --- a/docs/source-class-Token_lib.html +++ b/docs/source-class-Token_lib.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,116 +207,126 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
     require_once(APPPATH . 'libraries/tokens/Token.php');
     
    -class Token_lib
    -{
    -    private $CI;
    -
    -    public function __construct()
    -    {
    -        $this->CI =& get_instance();
    -    }
    -
    -    /**
    -     * Expands all of the tokens found in a given text string and returns the results.
    -     */
    -    public function render($tokened_text)
    -    {
    -
    -        // Transform legacy "$" tokens to their brace token equivalent
    -        if(strpos($tokened_text, '$') !== FALSE)
    -        {
    -            $tokened_text = str_replace('$YCO', '{YCO}', $tokened_text);
    -            $tokened_text = str_replace('$CO', '{CO}', $tokened_text);
    -            $tokened_text = str_replace('$SCO', '{SCO}', $tokened_text);
    -            $tokened_text = str_replace('$CU', '{CU}', $tokened_text);
    -        }
    -
    -        // Apply the transformation for the "%" tokens if any are used
    -        if(strpos($tokened_text, '%') !== FALSE)
    -        {
    -            $tokened_text = strftime($tokened_text);
    -        }
    -
    -        // Call scan to build an array of all of the tokens used in the text to be transformed
    -        $token_tree = $this->scan($tokened_text);
    -
    -        if(empty($token_tree))
    -        {
    -            if(strpos($tokened_text, '%') !== FALSE)
    -            {
    -                return strftime($tokened_text);
    -            }
    -            else
    -            {
    -                return $tokened_text;
    -            }
    -        }
    -
    -        $token_values = array();
    -        $tokens_to_replace = array();
    -        $this->generate($token_tree, $tokens_to_replace, $token_values);
    -
    -        return str_replace($tokens_to_replace, $token_values, $tokened_text);
    -    }
    -
    -    /**
    -     * Parses out the all of the tokens enclosed in braces {} and subparses on the colon : character where supplied
    -     */
    -    public function scan($text)
    -    {
    -        // Matches tokens with the following pattern: [$token:$length]
    -        preg_match_all('/
    -      \{             # [ - pattern start
    -      ([^\s\{\}:]+)  # match $token not containing whitespace : { or }
    -      (?:
    -      :              # : - separator
    -      ([^\s\{\}:]+)     # match $length not containing whitespace : { or }
    -      )?
    -      \}             # ] - pattern end
    -      /x', $text, $matches);
    -
    -        $tokens = $matches[1];
    -        $lengths = $matches[2];
    -
    -        $token_tree = array();
    -        for($i = 0; $i < count($tokens); $i++) {
    -            $token_tree[$tokens[$i]][$lengths[$i]] = $matches[0][$i];
    -        }
    -
    -        return $token_tree;
    -    }
    -
    -    public function generate($used_tokens, &$tokens_to_replace, &$token_values)
    -    {
    -        foreach($used_tokens as $token_code => $token_info)
    -        {
    -            // Generate value here based on the key value
    -            $token_value = (new Token())->replace($token_code);
    +/**
    + * Token library
    + *
    + * Library with utilities to manage tokens
    + *
    + * @link    github.com/jekkos/opensourcepos
    + * @since   3.1
    + * @author  SteveIreland
    + */
    +
    +class Token_lib
    +{
    +    private $CI;
    +
    +    public function __construct()
    +    {
    +        $this->CI =& get_instance();
    +    }
    +
    +    /**
    +     * Expands all of the tokens found in a given text string and returns the results.
    +     */
    +    public function render($tokened_text)
    +    {
    +
    +        // Transform legacy "$" tokens to their brace token equivalent
    +        if(strpos($tokened_text, '$') !== FALSE)
    +        {
    +            $tokened_text = str_replace('$YCO', '{YCO}', $tokened_text);
    +            $tokened_text = str_replace('$CO', '{CO}', $tokened_text);
    +            $tokened_text = str_replace('$SCO', '{SCO}', $tokened_text);
    +            $tokened_text = str_replace('$CU', '{CU}', $tokened_text);
    +        }
    +
    +        // Apply the transformation for the "%" tokens if any are used
    +        if(strpos($tokened_text, '%') !== FALSE)
    +        {
    +            $tokened_text = strftime($tokened_text);
    +        }
    +
    +        // Call scan to build an array of all of the tokens used in the text to be transformed
    +        $token_tree = $this->scan($tokened_text);
    +
    +        if(empty($token_tree))
    +        {
    +            if(strpos($tokened_text, '%') !== FALSE)
    +            {
    +                return strftime($tokened_text);
    +            }
    +            else
    +            {
    +                return $tokened_text;
    +            }
    +        }
    +
    +        $token_values = array();
    +        $tokens_to_replace = array();
    +        $this->generate($token_tree, $tokens_to_replace, $token_values);
    +
    +        return str_replace($tokens_to_replace, $token_values, $tokened_text);
    +    }
    +
    +    /**
    +     * Parses out the all of the tokens enclosed in braces {} and subparses on the colon : character where supplied
    +     */
    +    public function scan($text)
    +    {
    +        // Matches tokens with the following pattern: [$token:$length]
    +        preg_match_all('/
    +      \{             # [ - pattern start
    +      ([^\s\{\}:]+)  # match $token not containing whitespace : { or }
    +      (?:
    +      :              # : - separator
    +      ([^\s\{\}:]+)     # match $length not containing whitespace : { or }
    +      )?
    +      \}             # ] - pattern end
    +      /x', $text, $matches);
    +
    +        $tokens = $matches[1];
    +        $lengths = $matches[2];
    +
    +        $token_tree = array();
    +        for($i = 0; $i < count($tokens); $i++) {
    +            $token_tree[$tokens[$i]][$lengths[$i]] = $matches[0][$i];
    +        }
     
    -            foreach($token_info as $length => $token_spec)
    -            {
    -                $tokens_to_replace[] = $token_spec;
    -                if(!empty($length))
    -                {
    -                    $token_values[] = str_pad($token_value, $length, '0', STR_PAD_LEFT);
    -                }
    -                else
    -                {
    -                    $token_values[] = $token_value;
    -                }
    -            }
    -        }
    -        return $token_values;
    -    }
    -}
    -
    -?>
    -
    +
    return $token_tree; + } + + public function generate($used_tokens, &$tokens_to_replace, &$token_values) + { + foreach($used_tokens as $token_code => $token_info) + { + // Generate value here based on the key value + $token_value = (new Token())->replace($token_code); + + foreach($token_info as $length => $token_spec) + { + $tokens_to_replace[] = $token_spec; + if(!empty($length)) + { + $token_values[] = str_pad($token_value, $length, '0', STR_PAD_LEFT); + } + else + { + $token_values[] = $token_value; + } + } + } + return $token_values; + } +} + +?> +
    - + diff --git a/docs/source-class-Token_quote_sequence.html b/docs/source-class-Token_quote_sequence.html index 91699126b..93c59944b 100644 --- a/docs/source-class-Token_quote_sequence.html +++ b/docs/source-class-Token_quote_sequence.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,24 +207,26 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 
    -
    <?php
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 
    +
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     
    -class Token_quote_sequence extends Token
    -{
    -    private $CI;
    -
    -    public function __construct()
    -    {
    -        parent::__construct();
    -        $this->CI =& get_instance();
    -    }
    -
    +/**
    + * Token_quote_sequence class
    + *
    + * @link    github.com/jekkos/opensourcepos
    + * @since   3.1
    + * @author  SteveIreland
    + */
    +
    +class Token_quote_sequence extends Token
    +{
         public function get_value()
         {
             return $this->CI->Appconfig->acquire_save_next_quote_sequence();
         }
    -}
    +
    } +?> +
    - + diff --git a/docs/source-class-Token_suspended_invoice_count.html b/docs/source-class-Token_suspended_invoice_count.html index e5c199aec..329bd8018 100644 --- a/docs/source-class-Token_suspended_invoice_count.html +++ b/docs/source-class-Token_suspended_invoice_count.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,27 +207,33 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 
    -
    <?php
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 
    +
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     
    -class Token_suspended_invoice_count extends Token
    -{
    -    private $CI;
    -
    -    public function __construct()
    -    {
    -        parent::__construct();
    -        $this->CI =& get_instance();
    -        $this->CI->load->model('Sale');
    -    }
    -
    -    public function get_value()
    -    {
    -        return $this->CI->Sale->get_suspended_invoice_count();
    -    }
    -}
    +/**
    + * Token_suspended_invoice_count class
    + *
    + * @link    github.com/jekkos/opensourcepos
    + * @since   3.1
    + * @author  SteveIreland
    + */
    +
    +class Token_suspended_invoice_count extends Token
    +{
    +    public function __construct()
    +    {
    +        parent::__construct();
    +
    +        $this->CI->load->model('Sale');
    +    }
     
    -?>
    +
    public function get_value() + { + return $this->CI->Sale->get_suspended_invoice_count(); + } +} +?> +
    - + diff --git a/docs/source-class-Token_year_invoice_count.html b/docs/source-class-Token_year_invoice_count.html index f4a2a1a92..b7818e418 100644 --- a/docs/source-class-Token_year_invoice_count.html +++ b/docs/source-class-Token_year_invoice_count.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,25 +207,33 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 
    -
    <?php
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 
    +
    <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
     
    -class Token_year_invoice_count extends Token
    -{
    -    private $CI;
    -
    -    public function __construct()
    -    {
    -        parent::__construct();
    -        $this->CI =& get_instance();
    -        $this->CI->load->model('Sale');
    -    }
    -
    -    public function get_value()
    -    {
    -        return $this->CI->Sale->get_invoice_number_for_year();
    -    }
    -}
    +
    /** + * Token_year_invoice_count class + * + * @link github.com/jekkos/opensourcepos + * @since 3.1 + * @author SteveIreland + */ + +class Token_year_invoice_count extends Token +{ + public function __construct() + { + parent::__construct(); + + $this->CI->load->model('Sale'); + } + + public function get_value() + { + return $this->CI->Sale->get_invoice_number_for_year(); + } +} +?> +
    - + diff --git a/docs/source-class-Tracking_lib.html b/docs/source-class-Tracking_lib.html index c91b0b064..004a84f52 100644 --- a/docs/source-class-Tracking_lib.html +++ b/docs/source-class-Tracking_lib.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,104 +207,114 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
    -class Tracking_lib
    -{
    -    private $CI;
    -    private $tracking;
    -
    -    public function __construct()
    -    {
    -        $this->CI =& get_instance();
    -
    -        $clientId = $this->CI->Appconfig->get('client_id');
    -
    -        // some old beta-3.0.0 time client IDs are wrong so clean them up
    -        // this statement should be removed eventually
    -        if(!empty($clientId) && strlen($clientId) < 30)
    -        {
    -            $clientId = NULL;
    -        }
    -
    -        /**
    -         * Setup the class
    -         * optional
    -         */
    -        $options = array(
    -            'client_create_random_id' => TRUE, // create a random client id when the class can't fetch the current cliend id or none is provided by "client_id"
    -            'client_fallback_id' => 555, // fallback client id when cid was not found and random client id is off
    -            'client_id' => $clientId, // override client id
    -            'user_id' => NULL,  // determine current user id
    -            // adapter options
    -            'adapter' => array(
    -                'async' => TRUE, // requests to google are async - don't wait for google server response
    -                'ssl' => FALSE // use ssl connection to google server
    -            )
    -        );
    -
    -        $this->tracking = new \Racecore\GATracking\GATracking('UA-82359828-2', $options);
    -
    -        if(empty($clientId))
    -        {
    -            $clientId = $this->tracking->getClientId();
    -
    -            $this->CI->Appconfig->batch_save(array('client_id' => $clientId));
    -        }
    -    }
    -    
    -    /*
    -     * Track Event function
    -     */
    -    public function track_event($category, $action, $label = NULL, $value = NULL)
    -    {
    -        try
    -        {
    -            /** @var Tracking/Event $event */
    -            $event = $this->tracking->createTracking('Event');
    -            $event->setAsNonInteractionHit(TRUE);
    -            $event->setEventCategory($category);
    -            $event->setEventAction($action);
    -            $event->setEventLabel($label);
    -            $event->setEventValue($value);
    -
    -            return $this->tracking->sendTracking($event);
    -        }
    -        catch(Exception $e)
    -        {
    -            error_log($e->getMessage());
    -        }
    -    }
    -    
    -    /*
    -     * Track Page function
    -     */
    -    public function track_page($path, $title, $description = ' ')
    -    {
    -        try
    -        {
    -            /** @var Tracking/Factory $event */
    -            $event = $this->tracking->createTracking('Factory', array(
    -                'an' => 'OSPOS',
    -                'av' => $this->CI->config->item('application_version') . ' - ' . substr($this->CI->config->item('commit_sha1'), 5, 12),
    -                'ul' => current_language_code(),
    -                'dp' => $path,
    -                'dt' => $title,
    -                'cd' => $description
    -            ));
    -
    -            return $this->tracking->sendTracking($event);
    -        }
    -        catch(Exception $e)
    -        {
    -            error_log($e->getMessage());
    -        }
    -    }
    -}
    -
    -?>
    -
    +/** + * Tracking library + * + * Library with utilities to manage statistics + * + * @link github.com/jekkos/opensourcepos + * @since 3.0 + * @author daN4cat (FrancescoUK) + */ + +class Tracking_lib +{ + private $CI; + private $tracking; + + public function __construct() + { + $this->CI =& get_instance(); + + $clientId = $this->CI->Appconfig->get('client_id'); + + // some old beta-3.0.0 time client IDs are wrong so clean them up + // this statement should be removed eventually + if(!empty($clientId) && strlen($clientId) < 30) + { + $clientId = NULL; + } + + /** + * Setup the class + * optional + */ + $options = array( + 'client_create_random_id' => TRUE, // create a random client id when the class can't fetch the current cliend id or none is provided by "client_id" + 'client_fallback_id' => 555, // fallback client id when cid was not found and random client id is off + 'client_id' => $clientId, // override client id + 'user_id' => NULL, // determine current user id + // adapter options + 'adapter' => array( + 'async' => TRUE, // requests to google are async - don't wait for google server response + 'ssl' => FALSE // use ssl connection to google server + ) + ); + + $this->tracking = new \Racecore\GATracking\GATracking('UA-82359828-2', $options); + + if(empty($clientId)) + { + $clientId = $this->tracking->getClientId(); + + $this->CI->Appconfig->batch_save(array('client_id' => $clientId)); + } + } + + /* + * Track Event function + */ + public function track_event($category, $action, $label = NULL, $value = NULL) + { + try + { + /** @var Tracking/Event $event */ + $event = $this->tracking->createTracking('Event'); + $event->setAsNonInteractionHit(TRUE); + $event->setEventCategory($category); + $event->setEventAction($action); + $event->setEventLabel($label); + $event->setEventValue($value); + + return $this->tracking->sendTracking($event); + } + catch(Exception $e) + { + error_log($e->getMessage()); + } + } + + /* + * Track Page function + */ + public function track_page($path, $title, $description = ' ') + { + try + { + /** @var Tracking/Factory $event */ + $event = $this->tracking->createTracking('Factory', array( + 'an' => 'OSPOS', + 'av' => $this->CI->config->item('application_version') . ' - ' . substr($this->CI->config->item('commit_sha1'), 5, 12), + 'ul' => current_language_code(), + 'dp' => $path, + 'dt' => $title, + 'cd' => $description + )); + + return $this->tracking->sendTracking($event); + } + catch(Exception $e) + { + error_log($e->getMessage()); + } + } +} + +?> + - + diff --git a/docs/source-class-emberlabs.Barcode.BarcodeBase.html b/docs/source-class-emberlabs.Barcode.BarcodeBase.html index 234cc3a86..8ffc1ca72 100644 --- a/docs/source-class-emberlabs.Barcode.BarcodeBase.html +++ b/docs/source-class-emberlabs.Barcode.BarcodeBase.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -430,6 +432,6 @@ - + diff --git a/docs/source-class-emberlabs.Barcode.Code128.html b/docs/source-class-emberlabs.Barcode.Code128.html index ff8e7a0fb..dad9f7371 100644 --- a/docs/source-class-emberlabs.Barcode.Code128.html +++ b/docs/source-class-emberlabs.Barcode.Code128.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -538,6 +540,6 @@ - + diff --git a/docs/source-class-emberlabs.Barcode.Code39.html b/docs/source-class-emberlabs.Barcode.Code39.html index 609a626a8..2f69adc8d 100644 --- a/docs/source-class-emberlabs.Barcode.Code39.html +++ b/docs/source-class-emberlabs.Barcode.Code39.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -397,6 +399,6 @@ - + diff --git a/docs/source-class-emberlabs.Barcode.Ean13.html b/docs/source-class-emberlabs.Barcode.Ean13.html index b446e7e74..c8b8ee800 100644 --- a/docs/source-class-emberlabs.Barcode.Ean13.html +++ b/docs/source-class-emberlabs.Barcode.Ean13.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -583,6 +585,6 @@ - + diff --git a/docs/source-class-emberlabs.Barcode.Ean8.html b/docs/source-class-emberlabs.Barcode.Ean8.html index 461e997b8..3665291dc 100644 --- a/docs/source-class-emberlabs.Barcode.Ean8.html +++ b/docs/source-class-emberlabs.Barcode.Ean8.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -582,6 +584,6 @@ - + diff --git a/docs/source-function-currency_side.html b/docs/source-function-currency_side.html index 16a7ac207..dda627123 100644 --- a/docs/source-function-currency_side.html +++ b/docs/source-function-currency_side.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -206,10 +208,10 @@
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 
    -
    <?php
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
    -/*
    - * Currency locale
    +/**
    + * Currency locale helper
      */
     
     function current_language_code()
    @@ -260,7 +262,7 @@
         {
             return $number;
         }
    -    
    +
         return to_decimals($number, 'tax_decimals');
     }
     
    @@ -277,7 +279,7 @@
         {
             return $number;
         }
    -    
    +
         $config = get_instance()->config;
         $fmt = new \NumberFormatter($config->item('number_locale'), $type);
         $fmt->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, $config->item($decimals));
    @@ -406,6 +408,6 @@
     
     
     
    -
    +
     
     
    diff --git a/docs/source-function-current_language.html b/docs/source-function-current_language.html
    index 16a7ac207..dda627123 100644
    --- a/docs/source-function-current_language.html
    +++ b/docs/source-function-current_language.html
    @@ -80,6 +80,8 @@
     				
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -206,10 +208,10 @@
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 
    -
    <?php
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
    -/*
    - * Currency locale
    +/**
    + * Currency locale helper
      */
     
     function current_language_code()
    @@ -260,7 +262,7 @@
         {
             return $number;
         }
    -    
    +
         return to_decimals($number, 'tax_decimals');
     }
     
    @@ -277,7 +279,7 @@
         {
             return $number;
         }
    -    
    +
         $config = get_instance()->config;
         $fmt = new \NumberFormatter($config->item('number_locale'), $type);
         $fmt->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, $config->item($decimals));
    @@ -406,6 +408,6 @@
     
     
     
    -
    +
     
     
    diff --git a/docs/source-function-current_language_code.html b/docs/source-function-current_language_code.html
    index 16a7ac207..dda627123 100644
    --- a/docs/source-function-current_language_code.html
    +++ b/docs/source-function-current_language_code.html
    @@ -80,6 +80,8 @@
     				
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -206,10 +208,10 @@
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 
    -
    <?php
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
    -/*
    - * Currency locale
    +/**
    + * Currency locale helper
      */
     
     function current_language_code()
    @@ -260,7 +262,7 @@
         {
             return $number;
         }
    -    
    +
         return to_decimals($number, 'tax_decimals');
     }
     
    @@ -277,7 +279,7 @@
         {
             return $number;
         }
    -    
    +
         $config = get_instance()->config;
         $fmt = new \NumberFormatter($config->item('number_locale'), $type);
         $fmt->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, $config->item($decimals));
    @@ -406,6 +408,6 @@
     
     
     
    -
    +
     
     
    diff --git a/docs/source-function-dateformat_bootstrap.html b/docs/source-function-dateformat_bootstrap.html
    index 16a7ac207..dda627123 100644
    --- a/docs/source-function-dateformat_bootstrap.html
    +++ b/docs/source-function-dateformat_bootstrap.html
    @@ -80,6 +80,8 @@
     				
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -206,10 +208,10 @@
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 
    -
    <?php
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
    -/*
    - * Currency locale
    +/**
    + * Currency locale helper
      */
     
     function current_language_code()
    @@ -260,7 +262,7 @@
         {
             return $number;
         }
    -    
    +
         return to_decimals($number, 'tax_decimals');
     }
     
    @@ -277,7 +279,7 @@
         {
             return $number;
         }
    -    
    +
         $config = get_instance()->config;
         $fmt = new \NumberFormatter($config->item('number_locale'), $type);
         $fmt->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, $config->item($decimals));
    @@ -406,6 +408,6 @@
     
     
     
    -
    +
     
     
    diff --git a/docs/source-function-dateformat_momentjs.html b/docs/source-function-dateformat_momentjs.html
    index 16a7ac207..dda627123 100644
    --- a/docs/source-function-dateformat_momentjs.html
    +++ b/docs/source-function-dateformat_momentjs.html
    @@ -80,6 +80,8 @@
     				
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -206,10 +208,10 @@
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 
    -
    <?php
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
    -/*
    - * Currency locale
    +/**
    + * Currency locale helper
      */
     
     function current_language_code()
    @@ -260,7 +262,7 @@
         {
             return $number;
         }
    -    
    +
         return to_decimals($number, 'tax_decimals');
     }
     
    @@ -277,7 +279,7 @@
         {
             return $number;
         }
    -    
    +
         $config = get_instance()->config;
         $fmt = new \NumberFormatter($config->item('number_locale'), $type);
         $fmt->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, $config->item($decimals));
    @@ -406,6 +408,6 @@
     
     
     
    -
    +
     
     
    diff --git a/docs/source-function-db_log_queries.html b/docs/source-function-db_log_queries.html
    index 3e3765f46..ea53951f0 100644
    --- a/docs/source-function-db_log_queries.html
    +++ b/docs/source-function-db_log_queries.html
    @@ -80,6 +80,8 @@
     				
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -242,6 +244,6 @@ - + diff --git a/docs/source-function-get_customer_data_row.html b/docs/source-function-get_customer_data_row.html index 4100d2280..eb9fb0a7f 100644 --- a/docs/source-function-get_customer_data_row.html +++ b/docs/source-function-get_customer_data_row.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,8 +207,8 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 
    -
    <?php
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
     function get_sales_manage_table_headers()
     {
    @@ -221,7 +223,7 @@
             array('change_due' => $CI->lang->line('sales_change_due')),
             array('payment_type' => $CI->lang->line('sales_payment_type'))
         );
    -    
    +
         if($CI->config->item('invoice_enable') == TRUE)
         {
             $headers[] = array('invoice_number' => $CI->lang->line('sales_invoice_number'));
    @@ -378,7 +380,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -393,7 +395,7 @@
             'first_name' => $person->first_name,
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -417,7 +419,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -433,7 +435,7 @@
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
             'total' => to_currency($stats->total),
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -475,7 +477,7 @@
             'first_name' => $supplier->first_name,
             'email' => empty($supplier->email) ? '' : mailto($supplier->email, $supplier->email),
             'phone_number' => $supplier->phone_number,
    -        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$supplier->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update')))
    @@ -658,9 +660,8 @@
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
             ));
     }
    -
    -?>
    -
    +
    ?> +
    - + diff --git a/docs/source-function-get_customer_manage_table_headers.html b/docs/source-function-get_customer_manage_table_headers.html index 4100d2280..eb9fb0a7f 100644 --- a/docs/source-function-get_customer_manage_table_headers.html +++ b/docs/source-function-get_customer_manage_table_headers.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,8 +207,8 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 
    -
    <?php
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
     function get_sales_manage_table_headers()
     {
    @@ -221,7 +223,7 @@
             array('change_due' => $CI->lang->line('sales_change_due')),
             array('payment_type' => $CI->lang->line('sales_payment_type'))
         );
    -    
    +
         if($CI->config->item('invoice_enable') == TRUE)
         {
             $headers[] = array('invoice_number' => $CI->lang->line('sales_invoice_number'));
    @@ -378,7 +380,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -393,7 +395,7 @@
             'first_name' => $person->first_name,
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -417,7 +419,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -433,7 +435,7 @@
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
             'total' => to_currency($stats->total),
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -475,7 +477,7 @@
             'first_name' => $supplier->first_name,
             'email' => empty($supplier->email) ? '' : mailto($supplier->email, $supplier->email),
             'phone_number' => $supplier->phone_number,
    -        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$supplier->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update')))
    @@ -658,9 +660,8 @@
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
             ));
     }
    -
    -?>
    -
    +
    ?> +
    - + diff --git a/docs/source-function-get_giftcard_data_row.html b/docs/source-function-get_giftcard_data_row.html index 4100d2280..eb9fb0a7f 100644 --- a/docs/source-function-get_giftcard_data_row.html +++ b/docs/source-function-get_giftcard_data_row.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,8 +207,8 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 
    -
    <?php
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
     function get_sales_manage_table_headers()
     {
    @@ -221,7 +223,7 @@
             array('change_due' => $CI->lang->line('sales_change_due')),
             array('payment_type' => $CI->lang->line('sales_payment_type'))
         );
    -    
    +
         if($CI->config->item('invoice_enable') == TRUE)
         {
             $headers[] = array('invoice_number' => $CI->lang->line('sales_invoice_number'));
    @@ -378,7 +380,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -393,7 +395,7 @@
             'first_name' => $person->first_name,
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -417,7 +419,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -433,7 +435,7 @@
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
             'total' => to_currency($stats->total),
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -475,7 +477,7 @@
             'first_name' => $supplier->first_name,
             'email' => empty($supplier->email) ? '' : mailto($supplier->email, $supplier->email),
             'phone_number' => $supplier->phone_number,
    -        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$supplier->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update')))
    @@ -658,9 +660,8 @@
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
             ));
     }
    -
    -?>
    -
    +
    ?> +
    - + diff --git a/docs/source-function-get_giftcards_manage_table_headers.html b/docs/source-function-get_giftcards_manage_table_headers.html index 4100d2280..eb9fb0a7f 100644 --- a/docs/source-function-get_giftcards_manage_table_headers.html +++ b/docs/source-function-get_giftcards_manage_table_headers.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,8 +207,8 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 
    -
    <?php
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
     function get_sales_manage_table_headers()
     {
    @@ -221,7 +223,7 @@
             array('change_due' => $CI->lang->line('sales_change_due')),
             array('payment_type' => $CI->lang->line('sales_payment_type'))
         );
    -    
    +
         if($CI->config->item('invoice_enable') == TRUE)
         {
             $headers[] = array('invoice_number' => $CI->lang->line('sales_invoice_number'));
    @@ -378,7 +380,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -393,7 +395,7 @@
             'first_name' => $person->first_name,
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -417,7 +419,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -433,7 +435,7 @@
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
             'total' => to_currency($stats->total),
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -475,7 +477,7 @@
             'first_name' => $supplier->first_name,
             'email' => empty($supplier->email) ? '' : mailto($supplier->email, $supplier->email),
             'phone_number' => $supplier->phone_number,
    -        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$supplier->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update')))
    @@ -658,9 +660,8 @@
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
             ));
     }
    -
    -?>
    -
    +
    ?> +
    - + diff --git a/docs/source-function-get_item_data_row.html b/docs/source-function-get_item_data_row.html index 4100d2280..eb9fb0a7f 100644 --- a/docs/source-function-get_item_data_row.html +++ b/docs/source-function-get_item_data_row.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,8 +207,8 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 
    -
    <?php
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
     function get_sales_manage_table_headers()
     {
    @@ -221,7 +223,7 @@
             array('change_due' => $CI->lang->line('sales_change_due')),
             array('payment_type' => $CI->lang->line('sales_payment_type'))
         );
    -    
    +
         if($CI->config->item('invoice_enable') == TRUE)
         {
             $headers[] = array('invoice_number' => $CI->lang->line('sales_invoice_number'));
    @@ -378,7 +380,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -393,7 +395,7 @@
             'first_name' => $person->first_name,
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -417,7 +419,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -433,7 +435,7 @@
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
             'total' => to_currency($stats->total),
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -475,7 +477,7 @@
             'first_name' => $supplier->first_name,
             'email' => empty($supplier->email) ? '' : mailto($supplier->email, $supplier->email),
             'phone_number' => $supplier->phone_number,
    -        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$supplier->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update')))
    @@ -658,9 +660,8 @@
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
             ));
     }
    -
    -?>
    -
    +
    ?> +
    - + diff --git a/docs/source-function-get_item_kit_data_row.html b/docs/source-function-get_item_kit_data_row.html index 4100d2280..eb9fb0a7f 100644 --- a/docs/source-function-get_item_kit_data_row.html +++ b/docs/source-function-get_item_kit_data_row.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,8 +207,8 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 
    -
    <?php
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
     function get_sales_manage_table_headers()
     {
    @@ -221,7 +223,7 @@
             array('change_due' => $CI->lang->line('sales_change_due')),
             array('payment_type' => $CI->lang->line('sales_payment_type'))
         );
    -    
    +
         if($CI->config->item('invoice_enable') == TRUE)
         {
             $headers[] = array('invoice_number' => $CI->lang->line('sales_invoice_number'));
    @@ -378,7 +380,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -393,7 +395,7 @@
             'first_name' => $person->first_name,
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -417,7 +419,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -433,7 +435,7 @@
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
             'total' => to_currency($stats->total),
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -475,7 +477,7 @@
             'first_name' => $supplier->first_name,
             'email' => empty($supplier->email) ? '' : mailto($supplier->email, $supplier->email),
             'phone_number' => $supplier->phone_number,
    -        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$supplier->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update')))
    @@ -658,9 +660,8 @@
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
             ));
     }
    -
    -?>
    -
    +
    ?> +
    - + diff --git a/docs/source-function-get_item_kits_manage_table_headers.html b/docs/source-function-get_item_kits_manage_table_headers.html index 4100d2280..eb9fb0a7f 100644 --- a/docs/source-function-get_item_kits_manage_table_headers.html +++ b/docs/source-function-get_item_kits_manage_table_headers.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,8 +207,8 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 
    -
    <?php
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
     function get_sales_manage_table_headers()
     {
    @@ -221,7 +223,7 @@
             array('change_due' => $CI->lang->line('sales_change_due')),
             array('payment_type' => $CI->lang->line('sales_payment_type'))
         );
    -    
    +
         if($CI->config->item('invoice_enable') == TRUE)
         {
             $headers[] = array('invoice_number' => $CI->lang->line('sales_invoice_number'));
    @@ -378,7 +380,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -393,7 +395,7 @@
             'first_name' => $person->first_name,
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -417,7 +419,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -433,7 +435,7 @@
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
             'total' => to_currency($stats->total),
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -475,7 +477,7 @@
             'first_name' => $supplier->first_name,
             'email' => empty($supplier->email) ? '' : mailto($supplier->email, $supplier->email),
             'phone_number' => $supplier->phone_number,
    -        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$supplier->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update')))
    @@ -658,9 +660,8 @@
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
             ));
     }
    -
    -?>
    -
    +
    ?> +
    - + diff --git a/docs/source-function-get_items_manage_table_headers.html b/docs/source-function-get_items_manage_table_headers.html index 4100d2280..eb9fb0a7f 100644 --- a/docs/source-function-get_items_manage_table_headers.html +++ b/docs/source-function-get_items_manage_table_headers.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,8 +207,8 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 
    -
    <?php
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
     function get_sales_manage_table_headers()
     {
    @@ -221,7 +223,7 @@
             array('change_due' => $CI->lang->line('sales_change_due')),
             array('payment_type' => $CI->lang->line('sales_payment_type'))
         );
    -    
    +
         if($CI->config->item('invoice_enable') == TRUE)
         {
             $headers[] = array('invoice_number' => $CI->lang->line('sales_invoice_number'));
    @@ -378,7 +380,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -393,7 +395,7 @@
             'first_name' => $person->first_name,
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -417,7 +419,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -433,7 +435,7 @@
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
             'total' => to_currency($stats->total),
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -475,7 +477,7 @@
             'first_name' => $supplier->first_name,
             'email' => empty($supplier->email) ? '' : mailto($supplier->email, $supplier->email),
             'phone_number' => $supplier->phone_number,
    -        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$supplier->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update')))
    @@ -658,9 +660,8 @@
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
             ));
     }
    -
    -?>
    -
    +
    ?> +
    - + diff --git a/docs/source-function-get_people_manage_table_headers.html b/docs/source-function-get_people_manage_table_headers.html index 4100d2280..eb9fb0a7f 100644 --- a/docs/source-function-get_people_manage_table_headers.html +++ b/docs/source-function-get_people_manage_table_headers.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,8 +207,8 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 
    -
    <?php
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
     function get_sales_manage_table_headers()
     {
    @@ -221,7 +223,7 @@
             array('change_due' => $CI->lang->line('sales_change_due')),
             array('payment_type' => $CI->lang->line('sales_payment_type'))
         );
    -    
    +
         if($CI->config->item('invoice_enable') == TRUE)
         {
             $headers[] = array('invoice_number' => $CI->lang->line('sales_invoice_number'));
    @@ -378,7 +380,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -393,7 +395,7 @@
             'first_name' => $person->first_name,
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -417,7 +419,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -433,7 +435,7 @@
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
             'total' => to_currency($stats->total),
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -475,7 +477,7 @@
             'first_name' => $supplier->first_name,
             'email' => empty($supplier->email) ? '' : mailto($supplier->email, $supplier->email),
             'phone_number' => $supplier->phone_number,
    -        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$supplier->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update')))
    @@ -658,9 +660,8 @@
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
             ));
     }
    -
    -?>
    -
    +
    ?> +
    - + diff --git a/docs/source-function-get_person_data_row.html b/docs/source-function-get_person_data_row.html index 4100d2280..eb9fb0a7f 100644 --- a/docs/source-function-get_person_data_row.html +++ b/docs/source-function-get_person_data_row.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,8 +207,8 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 
    -
    <?php
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
     function get_sales_manage_table_headers()
     {
    @@ -221,7 +223,7 @@
             array('change_due' => $CI->lang->line('sales_change_due')),
             array('payment_type' => $CI->lang->line('sales_payment_type'))
         );
    -    
    +
         if($CI->config->item('invoice_enable') == TRUE)
         {
             $headers[] = array('invoice_number' => $CI->lang->line('sales_invoice_number'));
    @@ -378,7 +380,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -393,7 +395,7 @@
             'first_name' => $person->first_name,
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -417,7 +419,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -433,7 +435,7 @@
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
             'total' => to_currency($stats->total),
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -475,7 +477,7 @@
             'first_name' => $supplier->first_name,
             'email' => empty($supplier->email) ? '' : mailto($supplier->email, $supplier->email),
             'phone_number' => $supplier->phone_number,
    -        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$supplier->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update')))
    @@ -658,9 +660,8 @@
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
             ));
     }
    -
    -?>
    -
    +
    ?> +
    - + diff --git a/docs/source-function-get_sale_data_last_row.html b/docs/source-function-get_sale_data_last_row.html index 4100d2280..eb9fb0a7f 100644 --- a/docs/source-function-get_sale_data_last_row.html +++ b/docs/source-function-get_sale_data_last_row.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,8 +207,8 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 
    -
    <?php
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
     function get_sales_manage_table_headers()
     {
    @@ -221,7 +223,7 @@
             array('change_due' => $CI->lang->line('sales_change_due')),
             array('payment_type' => $CI->lang->line('sales_payment_type'))
         );
    -    
    +
         if($CI->config->item('invoice_enable') == TRUE)
         {
             $headers[] = array('invoice_number' => $CI->lang->line('sales_invoice_number'));
    @@ -378,7 +380,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -393,7 +395,7 @@
             'first_name' => $person->first_name,
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -417,7 +419,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -433,7 +435,7 @@
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
             'total' => to_currency($stats->total),
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -475,7 +477,7 @@
             'first_name' => $supplier->first_name,
             'email' => empty($supplier->email) ? '' : mailto($supplier->email, $supplier->email),
             'phone_number' => $supplier->phone_number,
    -        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$supplier->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update')))
    @@ -658,9 +660,8 @@
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
             ));
     }
    -
    -?>
    -
    +
    ?> +
    - + diff --git a/docs/source-function-get_sale_data_row.html b/docs/source-function-get_sale_data_row.html index 4100d2280..eb9fb0a7f 100644 --- a/docs/source-function-get_sale_data_row.html +++ b/docs/source-function-get_sale_data_row.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,8 +207,8 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 
    -
    <?php
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
     function get_sales_manage_table_headers()
     {
    @@ -221,7 +223,7 @@
             array('change_due' => $CI->lang->line('sales_change_due')),
             array('payment_type' => $CI->lang->line('sales_payment_type'))
         );
    -    
    +
         if($CI->config->item('invoice_enable') == TRUE)
         {
             $headers[] = array('invoice_number' => $CI->lang->line('sales_invoice_number'));
    @@ -378,7 +380,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -393,7 +395,7 @@
             'first_name' => $person->first_name,
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -417,7 +419,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -433,7 +435,7 @@
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
             'total' => to_currency($stats->total),
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -475,7 +477,7 @@
             'first_name' => $supplier->first_name,
             'email' => empty($supplier->email) ? '' : mailto($supplier->email, $supplier->email),
             'phone_number' => $supplier->phone_number,
    -        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$supplier->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update')))
    @@ -658,9 +660,8 @@
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
             ));
     }
    -
    -?>
    -
    +
    ?> +
    - + diff --git a/docs/source-function-get_sales_manage_payments_summary.html b/docs/source-function-get_sales_manage_payments_summary.html index 4100d2280..eb9fb0a7f 100644 --- a/docs/source-function-get_sales_manage_payments_summary.html +++ b/docs/source-function-get_sales_manage_payments_summary.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,8 +207,8 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 
    -
    <?php
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
     function get_sales_manage_table_headers()
     {
    @@ -221,7 +223,7 @@
             array('change_due' => $CI->lang->line('sales_change_due')),
             array('payment_type' => $CI->lang->line('sales_payment_type'))
         );
    -    
    +
         if($CI->config->item('invoice_enable') == TRUE)
         {
             $headers[] = array('invoice_number' => $CI->lang->line('sales_invoice_number'));
    @@ -378,7 +380,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -393,7 +395,7 @@
             'first_name' => $person->first_name,
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -417,7 +419,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -433,7 +435,7 @@
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
             'total' => to_currency($stats->total),
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -475,7 +477,7 @@
             'first_name' => $supplier->first_name,
             'email' => empty($supplier->email) ? '' : mailto($supplier->email, $supplier->email),
             'phone_number' => $supplier->phone_number,
    -        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$supplier->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update')))
    @@ -658,9 +660,8 @@
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
             ));
     }
    -
    -?>
    -
    +
    ?> +
    - + diff --git a/docs/source-function-get_sales_manage_table_headers.html b/docs/source-function-get_sales_manage_table_headers.html index 4100d2280..eb9fb0a7f 100644 --- a/docs/source-function-get_sales_manage_table_headers.html +++ b/docs/source-function-get_sales_manage_table_headers.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,8 +207,8 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 
    -
    <?php
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
     function get_sales_manage_table_headers()
     {
    @@ -221,7 +223,7 @@
             array('change_due' => $CI->lang->line('sales_change_due')),
             array('payment_type' => $CI->lang->line('sales_payment_type'))
         );
    -    
    +
         if($CI->config->item('invoice_enable') == TRUE)
         {
             $headers[] = array('invoice_number' => $CI->lang->line('sales_invoice_number'));
    @@ -378,7 +380,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -393,7 +395,7 @@
             'first_name' => $person->first_name,
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -417,7 +419,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -433,7 +435,7 @@
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
             'total' => to_currency($stats->total),
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -475,7 +477,7 @@
             'first_name' => $supplier->first_name,
             'email' => empty($supplier->email) ? '' : mailto($supplier->email, $supplier->email),
             'phone_number' => $supplier->phone_number,
    -        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$supplier->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update')))
    @@ -658,9 +660,8 @@
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
             ));
     }
    -
    -?>
    -
    +
    ?> +
    - + diff --git a/docs/source-function-get_supplier_data_row.html b/docs/source-function-get_supplier_data_row.html index 4100d2280..eb9fb0a7f 100644 --- a/docs/source-function-get_supplier_data_row.html +++ b/docs/source-function-get_supplier_data_row.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,8 +207,8 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 
    -
    <?php
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
     function get_sales_manage_table_headers()
     {
    @@ -221,7 +223,7 @@
             array('change_due' => $CI->lang->line('sales_change_due')),
             array('payment_type' => $CI->lang->line('sales_payment_type'))
         );
    -    
    +
         if($CI->config->item('invoice_enable') == TRUE)
         {
             $headers[] = array('invoice_number' => $CI->lang->line('sales_invoice_number'));
    @@ -378,7 +380,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -393,7 +395,7 @@
             'first_name' => $person->first_name,
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -417,7 +419,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -433,7 +435,7 @@
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
             'total' => to_currency($stats->total),
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -475,7 +477,7 @@
             'first_name' => $supplier->first_name,
             'email' => empty($supplier->email) ? '' : mailto($supplier->email, $supplier->email),
             'phone_number' => $supplier->phone_number,
    -        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$supplier->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update')))
    @@ -658,9 +660,8 @@
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
             ));
     }
    -
    -?>
    -
    +
    ?> +
    - + diff --git a/docs/source-function-get_suppliers_manage_table_headers.html b/docs/source-function-get_suppliers_manage_table_headers.html index 4100d2280..eb9fb0a7f 100644 --- a/docs/source-function-get_suppliers_manage_table_headers.html +++ b/docs/source-function-get_suppliers_manage_table_headers.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,8 +207,8 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 
    -
    <?php
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
     function get_sales_manage_table_headers()
     {
    @@ -221,7 +223,7 @@
             array('change_due' => $CI->lang->line('sales_change_due')),
             array('payment_type' => $CI->lang->line('sales_payment_type'))
         );
    -    
    +
         if($CI->config->item('invoice_enable') == TRUE)
         {
             $headers[] = array('invoice_number' => $CI->lang->line('sales_invoice_number'));
    @@ -378,7 +380,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -393,7 +395,7 @@
             'first_name' => $person->first_name,
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -417,7 +419,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -433,7 +435,7 @@
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
             'total' => to_currency($stats->total),
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -475,7 +477,7 @@
             'first_name' => $supplier->first_name,
             'email' => empty($supplier->email) ? '' : mailto($supplier->email, $supplier->email),
             'phone_number' => $supplier->phone_number,
    -        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$supplier->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update')))
    @@ -658,9 +660,8 @@
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
             ));
     }
    -
    -?>
    -
    +
    ?> +
    - + diff --git a/docs/source-function-get_tax_data_row.html b/docs/source-function-get_tax_data_row.html index 4100d2280..eb9fb0a7f 100644 --- a/docs/source-function-get_tax_data_row.html +++ b/docs/source-function-get_tax_data_row.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,8 +207,8 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 
    -
    <?php
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
     function get_sales_manage_table_headers()
     {
    @@ -221,7 +223,7 @@
             array('change_due' => $CI->lang->line('sales_change_due')),
             array('payment_type' => $CI->lang->line('sales_payment_type'))
         );
    -    
    +
         if($CI->config->item('invoice_enable') == TRUE)
         {
             $headers[] = array('invoice_number' => $CI->lang->line('sales_invoice_number'));
    @@ -378,7 +380,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -393,7 +395,7 @@
             'first_name' => $person->first_name,
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -417,7 +419,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -433,7 +435,7 @@
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
             'total' => to_currency($stats->total),
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -475,7 +477,7 @@
             'first_name' => $supplier->first_name,
             'email' => empty($supplier->email) ? '' : mailto($supplier->email, $supplier->email),
             'phone_number' => $supplier->phone_number,
    -        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$supplier->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update')))
    @@ -658,9 +660,8 @@
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
             ));
     }
    -
    -?>
    -
    +
    ?> +
    - + diff --git a/docs/source-function-get_taxes_manage_table_headers.html b/docs/source-function-get_taxes_manage_table_headers.html index 4100d2280..eb9fb0a7f 100644 --- a/docs/source-function-get_taxes_manage_table_headers.html +++ b/docs/source-function-get_taxes_manage_table_headers.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,8 +207,8 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 
    -
    <?php
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
     function get_sales_manage_table_headers()
     {
    @@ -221,7 +223,7 @@
             array('change_due' => $CI->lang->line('sales_change_due')),
             array('payment_type' => $CI->lang->line('sales_payment_type'))
         );
    -    
    +
         if($CI->config->item('invoice_enable') == TRUE)
         {
             $headers[] = array('invoice_number' => $CI->lang->line('sales_invoice_number'));
    @@ -378,7 +380,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -393,7 +395,7 @@
             'first_name' => $person->first_name,
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -417,7 +419,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -433,7 +435,7 @@
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
             'total' => to_currency($stats->total),
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -475,7 +477,7 @@
             'first_name' => $supplier->first_name,
             'email' => empty($supplier->email) ? '' : mailto($supplier->email, $supplier->email),
             'phone_number' => $supplier->phone_number,
    -        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$supplier->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update')))
    @@ -658,9 +660,8 @@
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
             ));
     }
    -
    -?>
    -
    +
    ?> +
    - + diff --git a/docs/source-function-load_config.html b/docs/source-function-load_config.html index 00974e88f..ab9487849 100644 --- a/docs/source-function-load_config.html +++ b/docs/source-function-load_config.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -271,6 +273,6 @@ - + diff --git a/docs/source-function-load_language_files.html b/docs/source-function-load_language_files.html index 00974e88f..ab9487849 100644 --- a/docs/source-function-load_language_files.html +++ b/docs/source-function-load_language_files.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -271,6 +273,6 @@ - + diff --git a/docs/source-function-load_stats.html b/docs/source-function-load_stats.html index 66be9ac25..2de622e74 100644 --- a/docs/source-function-load_stats.html +++ b/docs/source-function-load_stats.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -271,6 +273,6 @@ - + diff --git a/docs/source-function-parse_decimals.html b/docs/source-function-parse_decimals.html index 16a7ac207..dda627123 100644 --- a/docs/source-function-parse_decimals.html +++ b/docs/source-function-parse_decimals.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -206,10 +208,10 @@
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 
    -
    <?php
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
    -/*
    - * Currency locale
    +/**
    + * Currency locale helper
      */
     
     function current_language_code()
    @@ -260,7 +262,7 @@
         {
             return $number;
         }
    -    
    +
         return to_decimals($number, 'tax_decimals');
     }
     
    @@ -277,7 +279,7 @@
         {
             return $number;
         }
    -    
    +
         $config = get_instance()->config;
         $fmt = new \NumberFormatter($config->item('number_locale'), $type);
         $fmt->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, $config->item($decimals));
    @@ -406,6 +408,6 @@
     
     
     
    -
    +
     
     
    diff --git a/docs/source-function-pdf_create.html b/docs/source-function-pdf_create.html
    index 1658db5ea..57fa4d236 100644
    --- a/docs/source-function-pdf_create.html
    +++ b/docs/source-function-pdf_create.html
    @@ -80,6 +80,8 @@
     				
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,10 +207,10 @@ -
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 
    +
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
    -function pdf_create($html, $filename = '') 
    +function pdf_create($html, $filename = '')
     {
         // need to enable magic quotes for the
         $magic_quotes_enabled = get_magic_quotes_runtime();
    @@ -236,7 +238,8 @@
             return $dompdf->output();
         }
     }
    -?>  
    +
    ?> +
    - + diff --git a/docs/source-function-quantity_decimals.html b/docs/source-function-quantity_decimals.html index 16a7ac207..dda627123 100644 --- a/docs/source-function-quantity_decimals.html +++ b/docs/source-function-quantity_decimals.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -206,10 +208,10 @@
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 
    -
    <?php
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
    -/*
    - * Currency locale
    +/**
    + * Currency locale helper
      */
     
     function current_language_code()
    @@ -260,7 +262,7 @@
         {
             return $number;
         }
    -    
    +
         return to_decimals($number, 'tax_decimals');
     }
     
    @@ -277,7 +279,7 @@
         {
             return $number;
         }
    -    
    +
         $config = get_instance()->config;
         $fmt = new \NumberFormatter($config->item('number_locale'), $type);
         $fmt->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, $config->item($decimals));
    @@ -406,6 +408,6 @@
     
     
     
    -
    +
     
     
    diff --git a/docs/source-function-show_report.html b/docs/source-function-show_report.html
    index 4847cddd3..3b5300643 100644
    --- a/docs/source-function-show_report.html
    +++ b/docs/source-function-show_report.html
    @@ -80,6 +80,8 @@
     				
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -206,13 +208,13 @@
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 
    -
    <?php
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
     function show_report_if_allowed($report_prefix, $report_name, $person_id, $permission_id = '')
     {
         $CI =& get_instance();
     
    -    $permission_id = empty($permission_id) ? 'reports_' . $report_name : $permission_id;    
    +    $permission_id = empty($permission_id) ? 'reports_' . $report_name : $permission_id;
         if($CI->Employee->has_grant($permission_id, $person_id))
         {
             show_report($report_prefix, $report_name, $permission_id);
    @@ -231,11 +233,11 @@
         {
             ?>
                 <a class="list-group-item" href="<?php echo site_url('reports/' . $report_prefix . preg_replace('/reports_(.*)/', '$1', $report_name));?>"><?php echo $report_label; ?></a>
    -        <?php 
    +        <?php
         }
     }
    -
    -?>
    +
    ?> +
    - + diff --git a/docs/source-function-show_report_if_allowed.html b/docs/source-function-show_report_if_allowed.html index 4847cddd3..3b5300643 100644 --- a/docs/source-function-show_report_if_allowed.html +++ b/docs/source-function-show_report_if_allowed.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -206,13 +208,13 @@
     1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 
    -
    <?php
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
     function show_report_if_allowed($report_prefix, $report_name, $person_id, $permission_id = '')
     {
         $CI =& get_instance();
     
    -    $permission_id = empty($permission_id) ? 'reports_' . $report_name : $permission_id;    
    +    $permission_id = empty($permission_id) ? 'reports_' . $report_name : $permission_id;
         if($CI->Employee->has_grant($permission_id, $person_id))
         {
             show_report($report_prefix, $report_name, $permission_id);
    @@ -231,11 +233,11 @@
         {
             ?>
                 <a class="list-group-item" href="<?php echo site_url('reports/' . $report_prefix . preg_replace('/reports_(.*)/', '$1', $report_name));?>"><?php echo $report_label; ?></a>
    -        <?php 
    +        <?php
         }
     }
    -
    -?>
    +
    ?> +
    - + diff --git a/docs/source-function-to_currency.html b/docs/source-function-to_currency.html index 16a7ac207..dda627123 100644 --- a/docs/source-function-to_currency.html +++ b/docs/source-function-to_currency.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -206,10 +208,10 @@
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 
    -
    <?php
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
    -/*
    - * Currency locale
    +/**
    + * Currency locale helper
      */
     
     function current_language_code()
    @@ -260,7 +262,7 @@
         {
             return $number;
         }
    -    
    +
         return to_decimals($number, 'tax_decimals');
     }
     
    @@ -277,7 +279,7 @@
         {
             return $number;
         }
    -    
    +
         $config = get_instance()->config;
         $fmt = new \NumberFormatter($config->item('number_locale'), $type);
         $fmt->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, $config->item($decimals));
    @@ -406,6 +408,6 @@
     
     
     
    -
    +
     
     
    diff --git a/docs/source-function-to_currency_no_money.html b/docs/source-function-to_currency_no_money.html
    index 16a7ac207..dda627123 100644
    --- a/docs/source-function-to_currency_no_money.html
    +++ b/docs/source-function-to_currency_no_money.html
    @@ -80,6 +80,8 @@
     				
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -206,10 +208,10 @@
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 
    -
    <?php
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
    -/*
    - * Currency locale
    +/**
    + * Currency locale helper
      */
     
     function current_language_code()
    @@ -260,7 +262,7 @@
         {
             return $number;
         }
    -    
    +
         return to_decimals($number, 'tax_decimals');
     }
     
    @@ -277,7 +279,7 @@
         {
             return $number;
         }
    -    
    +
         $config = get_instance()->config;
         $fmt = new \NumberFormatter($config->item('number_locale'), $type);
         $fmt->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, $config->item($decimals));
    @@ -406,6 +408,6 @@
     
     
     
    -
    +
     
     
    diff --git a/docs/source-function-to_decimals.html b/docs/source-function-to_decimals.html
    index 16a7ac207..dda627123 100644
    --- a/docs/source-function-to_decimals.html
    +++ b/docs/source-function-to_decimals.html
    @@ -80,6 +80,8 @@
     				
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -206,10 +208,10 @@
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 
    -
    <?php
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
    -/*
    - * Currency locale
    +/**
    + * Currency locale helper
      */
     
     function current_language_code()
    @@ -260,7 +262,7 @@
         {
             return $number;
         }
    -    
    +
         return to_decimals($number, 'tax_decimals');
     }
     
    @@ -277,7 +279,7 @@
         {
             return $number;
         }
    -    
    +
         $config = get_instance()->config;
         $fmt = new \NumberFormatter($config->item('number_locale'), $type);
         $fmt->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, $config->item($decimals));
    @@ -406,6 +408,6 @@
     
     
     
    -
    +
     
     
    diff --git a/docs/source-function-to_quantity_decimals.html b/docs/source-function-to_quantity_decimals.html
    index 16a7ac207..dda627123 100644
    --- a/docs/source-function-to_quantity_decimals.html
    +++ b/docs/source-function-to_quantity_decimals.html
    @@ -80,6 +80,8 @@
     				
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -206,10 +208,10 @@
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 
    -
    <?php
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
    -/*
    - * Currency locale
    +/**
    + * Currency locale helper
      */
     
     function current_language_code()
    @@ -260,7 +262,7 @@
         {
             return $number;
         }
    -    
    +
         return to_decimals($number, 'tax_decimals');
     }
     
    @@ -277,7 +279,7 @@
         {
             return $number;
         }
    -    
    +
         $config = get_instance()->config;
         $fmt = new \NumberFormatter($config->item('number_locale'), $type);
         $fmt->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, $config->item($decimals));
    @@ -406,6 +408,6 @@
     
     
     
    -
    +
     
     
    diff --git a/docs/source-function-to_tax_decimals.html b/docs/source-function-to_tax_decimals.html
    index 16a7ac207..dda627123 100644
    --- a/docs/source-function-to_tax_decimals.html
    +++ b/docs/source-function-to_tax_decimals.html
    @@ -80,6 +80,8 @@
     				
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -206,10 +208,10 @@
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 
    -
    <?php
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
    -/*
    - * Currency locale
    +/**
    + * Currency locale helper
      */
     
     function current_language_code()
    @@ -260,7 +262,7 @@
         {
             return $number;
         }
    -    
    +
         return to_decimals($number, 'tax_decimals');
     }
     
    @@ -277,7 +279,7 @@
         {
             return $number;
         }
    -    
    +
         $config = get_instance()->config;
         $fmt = new \NumberFormatter($config->item('number_locale'), $type);
         $fmt->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, $config->item($decimals));
    @@ -406,6 +408,6 @@
     
     
     
    -
    +
     
     
    diff --git a/docs/source-function-totals_decimals.html b/docs/source-function-totals_decimals.html
    index 16a7ac207..dda627123 100644
    --- a/docs/source-function-totals_decimals.html
    +++ b/docs/source-function-totals_decimals.html
    @@ -80,6 +80,8 @@
     				
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -206,10 +208,10 @@
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 
    -
    <?php
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
    -/*
    - * Currency locale
    +/**
    + * Currency locale helper
      */
     
     function current_language_code()
    @@ -260,7 +262,7 @@
         {
             return $number;
         }
    -    
    +
         return to_decimals($number, 'tax_decimals');
     }
     
    @@ -277,7 +279,7 @@
         {
             return $number;
         }
    -    
    +
         $config = get_instance()->config;
         $fmt = new \NumberFormatter($config->item('number_locale'), $type);
         $fmt->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, $config->item($decimals));
    @@ -406,6 +408,6 @@
     
     
     
    -
    +
     
     
    diff --git a/docs/source-function-transform_headers.html b/docs/source-function-transform_headers.html
    index 4100d2280..eb9fb0a7f 100644
    --- a/docs/source-function-transform_headers.html
    +++ b/docs/source-function-transform_headers.html
    @@ -80,6 +80,8 @@
     				
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,8 +207,8 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 
    -
    <?php
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
     function get_sales_manage_table_headers()
     {
    @@ -221,7 +223,7 @@
             array('change_due' => $CI->lang->line('sales_change_due')),
             array('payment_type' => $CI->lang->line('sales_payment_type'))
         );
    -    
    +
         if($CI->config->item('invoice_enable') == TRUE)
         {
             $headers[] = array('invoice_number' => $CI->lang->line('sales_invoice_number'));
    @@ -378,7 +380,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -393,7 +395,7 @@
             'first_name' => $person->first_name,
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -417,7 +419,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -433,7 +435,7 @@
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
             'total' => to_currency($stats->total),
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -475,7 +477,7 @@
             'first_name' => $supplier->first_name,
             'email' => empty($supplier->email) ? '' : mailto($supplier->email, $supplier->email),
             'phone_number' => $supplier->phone_number,
    -        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$supplier->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update')))
    @@ -658,9 +660,8 @@
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
             ));
     }
    -
    -?>
    -
    +
    ?> +
    - + diff --git a/docs/source-function-transform_headers_readonly.html b/docs/source-function-transform_headers_readonly.html index 4100d2280..eb9fb0a7f 100644 --- a/docs/source-function-transform_headers_readonly.html +++ b/docs/source-function-transform_headers_readonly.html @@ -80,6 +80,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,8 +207,8 @@ -
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 
    -
    <?php
    +
      1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 
    +
    <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
     
     function get_sales_manage_table_headers()
     {
    @@ -221,7 +223,7 @@
             array('change_due' => $CI->lang->line('sales_change_due')),
             array('payment_type' => $CI->lang->line('sales_payment_type'))
         );
    -    
    +
         if($CI->config->item('invoice_enable') == TRUE)
         {
             $headers[] = array('invoice_number' => $CI->lang->line('sales_invoice_number'));
    @@ -378,7 +380,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -393,7 +395,7 @@
             'first_name' => $person->first_name,
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -417,7 +419,7 @@
         {
             $headers[] = array('messages' => '', 'sortable' => FALSE);
         }
    -    
    +
         return transform_headers($headers);
     }
     
    @@ -433,7 +435,7 @@
             'email' => empty($person->email) ? '' : mailto($person->email, $person->email),
             'phone_number' => $person->phone_number,
             'total' => to_currency($stats->total),
    -        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($person->phone_number) ? '' : anchor("Messages/view/$person->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$person->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
    @@ -475,7 +477,7 @@
             'first_name' => $supplier->first_name,
             'email' => empty($supplier->email) ? '' : mailto($supplier->email, $supplier->email),
             'phone_number' => $supplier->phone_number,
    -        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>', 
    +        'messages' => empty($supplier->phone_number) ? '' : anchor("Messages/view/$supplier->person_id", '<span class="glyphicon glyphicon-phone"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line('messages_sms_send'))),
             'edit' => anchor($controller_name."/view/$supplier->person_id", '<span class="glyphicon glyphicon-edit"></span>',
                 array('class'=>"modal-dlg", 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update')))
    @@ -658,9 +660,8 @@
                 array('class'=>'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title'=>$CI->lang->line($controller_name.'_update'))
             ));
     }
    -
    -?>
    -
    +
    ?> +
    - +
    Methods summary
    - public - - - - -
    - # - __construct( ) - -
    - -
    - - -
    @@ -282,7 +263,7 @@ CI_Model
    # - get_module_name( $module_id ) + get_module_name( $module_id )
    @@ -312,7 +293,7 @@ CI_Model
    # - get_module_desc( $module_id ) + get_module_desc( $module_id )
    @@ -342,7 +323,7 @@ CI_Model
    # - get_all_permissions( ) + get_all_permissions( )
    @@ -372,7 +353,7 @@ CI_Model
    # - get_all_subpermissions( ) + get_all_subpermissions( )
    @@ -402,7 +383,7 @@ CI_Model
    # - get_all_modules( ) + get_all_modules( )
    @@ -432,7 +413,7 @@ CI_Model
    # - get_allowed_modules( $person_id ) + get_allowed_modules( $person_id )
    diff --git a/docs/class-No_Access.html b/docs/class-No_Access.html index d1db1c451..e85c04220 100644 --- a/docs/class-No_Access.html +++ b/docs/class-No_Access.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -232,7 +234,7 @@ CI_Controller - Located at controllers/No_access.php + Located at controllers/No_access.php
    @@ -240,36 +242,6 @@ CI_Controller - - - - - - + + + + + + @@ -680,14 +723,14 @@ as a separate tax entry on the invoice.

    + + + + + + + + + + + + + + + + + + + + + + + + - + - + @@ -224,7 +226,7 @@ - + @@ -240,11 +242,11 @@ - + - + @@ -256,7 +258,7 @@ - + @@ -268,7 +270,7 @@ - + @@ -280,15 +282,15 @@ - + - + - + @@ -296,15 +298,15 @@ - + - + - + @@ -327,9 +329,17 @@ - + + + + + + + + + @@ -340,7 +350,7 @@ - + @@ -348,11 +358,11 @@ - + - + @@ -368,23 +378,23 @@ - + - + - + - + - + @@ -396,7 +406,7 @@ - + @@ -412,7 +422,7 @@ - + @@ -464,11 +474,11 @@ - + - + @@ -476,39 +486,39 @@ - + - + - + - + - + - + - + - + - +
    Methods summary
    - public - - - - -
    - # - __construct( ) - -
    - -
    - - -
    @@ -282,7 +254,7 @@ CI_Controller
    # - index( $module_id = '', $permission_id = '' ) + index( $module_id = '', $permission_id = '' )
    diff --git a/docs/class-Person.html b/docs/class-Person.html index 75dafedd6..b0d0e86d9 100644 --- a/docs/class-Person.html +++ b/docs/class-Person.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -205,7 +207,7 @@
    -

    Base class for People classes.

    +

    Base class for People classes

    diff --git a/docs/class-Persons.html b/docs/class-Persons.html index 6139e531c..5df205e43 100644 --- a/docs/class-Persons.html +++ b/docs/class-Persons.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -245,7 +247,7 @@ CI_Controller - Located at controllers/Persons.php + Located at controllers/Persons.php
    @@ -389,7 +391,7 @@ CI_Controller
    # - nameize( $str, $a_char = array("'", "-", " ") ) + nameize( $string )
    diff --git a/docs/class-Receiving.html b/docs/class-Receiving.html index 3e3a2c759..4c832868a 100644 --- a/docs/class-Receiving.html +++ b/docs/class-Receiving.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -204,6 +206,9 @@

    Class Receiving

    +
    +

    Receiving class

    +
    @@ -232,7 +237,13 @@ CI_Model - Located at models/Receiving.php + Author: + N/A
    + Since: + 1.0
    + Link: + github.com/jekkos/opensourcepos
    + Located at models/Receiving.php
    @@ -252,7 +263,7 @@ CI_Model
    # - get_info( $receiving_id ) + get_info( $receiving_id )
    @@ -282,7 +293,7 @@ CI_Model
    # - get_receiving_by_reference( $reference ) + get_receiving_by_reference( $reference )
    @@ -312,7 +323,7 @@ CI_Model
    # - is_valid_receipt( $receipt_receiving_id ) + is_valid_receipt( $receipt_receiving_id )
    @@ -342,7 +353,7 @@ CI_Model
    # - exists( $receiving_id ) + exists( $receiving_id )
    @@ -372,7 +383,7 @@ CI_Model
    # - update( $receiving_data, $receiving_id ) + update( $receiving_data, $receiving_id )
    @@ -402,7 +413,7 @@ CI_Model
    # - save( $items, $supplier_id, $employee_id, $comment, $reference, $payment_type, $receiving_id = FALSE ) + save( $items, $supplier_id, $employee_id, $comment, $reference, $payment_type, $receiving_id = FALSE )
    @@ -432,7 +443,7 @@ CI_Model
    # - delete_list( $receiving_ids, $employee_id, $update_inventory = TRUE ) + delete_list( $receiving_ids, $employee_id, $update_inventory = TRUE )
    @@ -462,7 +473,7 @@ CI_Model
    # - delete( $receiving_id, $employee_id, $update_inventory = TRUE ) + delete( $receiving_id, $employee_id, $update_inventory = TRUE )
    @@ -492,7 +503,7 @@ CI_Model
    # - get_receiving_items( $receiving_id ) + get_receiving_items( $receiving_id )
    @@ -522,7 +533,7 @@ CI_Model
    # - get_supplier( $receiving_id ) + get_supplier( $receiving_id )
    @@ -552,7 +563,7 @@ CI_Model
    # - get_payment_options( ) + get_payment_options( )
    @@ -582,7 +593,7 @@ CI_Model
    # - create_temp_table( array $inputs ) + create_temp_table( array $inputs )
    diff --git a/docs/class-Receiving_lib.html b/docs/class-Receiving_lib.html index d74f1e1c6..f1c74be6d 100644 --- a/docs/class-Receiving_lib.html +++ b/docs/class-Receiving_lib.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -204,6 +206,11 @@

    Class Receiving_lib

    +
    +

    Receiving library

    + +

    Library with utilities to manage receivings

    +
    @@ -219,7 +226,13 @@ - Located at libraries/Receiving_lib.php + Author: + N/A
    + Since: + 1.0
    + Link: + github.com/jekkos/opensourcepos
    + Located at libraries/Receiving_lib.php
    @@ -239,7 +252,7 @@
    # - __construct( ) + __construct( )
    @@ -269,7 +282,7 @@
    # - get_cart( ) + get_cart( )
    @@ -299,7 +312,7 @@
    # - set_cart( $cart_data ) + set_cart( $cart_data )
    @@ -329,7 +342,7 @@
    # - empty_cart( ) + empty_cart( )
    @@ -359,7 +372,7 @@
    # - get_supplier( ) + get_supplier( )
    @@ -389,7 +402,7 @@
    # - set_supplier( $supplier_id ) + set_supplier( $supplier_id )
    @@ -419,7 +432,7 @@
    # - remove_supplier( ) + remove_supplier( )
    @@ -449,7 +462,7 @@
    # - get_mode( ) + get_mode( )
    @@ -479,7 +492,7 @@
    # - set_mode( $mode ) + set_mode( $mode )
    @@ -509,7 +522,7 @@
    # - clear_mode( ) + clear_mode( )
    @@ -539,7 +552,7 @@
    # - get_stock_source( ) + get_stock_source( )
    @@ -569,7 +582,7 @@
    # - get_comment( ) + get_comment( )
    @@ -599,7 +612,7 @@
    # - set_comment( $comment ) + set_comment( $comment )
    @@ -629,7 +642,7 @@
    # - clear_comment( ) + clear_comment( )
    @@ -659,7 +672,7 @@
    # - get_reference( ) + get_reference( )
    @@ -689,7 +702,7 @@
    # - set_reference( $reference ) + set_reference( $reference )
    @@ -719,7 +732,7 @@
    # - clear_reference( ) + clear_reference( )
    @@ -749,7 +762,7 @@
    # - is_print_after_sale( ) + is_print_after_sale( )
    @@ -779,7 +792,7 @@
    # - set_print_after_sale( $print_after_sale ) + set_print_after_sale( $print_after_sale )
    @@ -809,7 +822,7 @@
    # - set_stock_source( $stock_source ) + set_stock_source( $stock_source )
    @@ -839,7 +852,7 @@
    # - clear_stock_source( ) + clear_stock_source( )
    @@ -869,7 +882,7 @@
    # - get_stock_destination( ) + get_stock_destination( )
    @@ -899,7 +912,7 @@
    # - set_stock_destination( $stock_destination ) + set_stock_destination( $stock_destination )
    @@ -929,7 +942,7 @@
    # - clear_stock_destination( ) + clear_stock_destination( )
    @@ -959,7 +972,7 @@
    # - add_item( $item_id, $quantity = 1, $item_location = NULL, $discount = 0, $price = NULL, $description = NULL, $serialnumber = NULL, $receiving_quantity = NULL, $include_deleted = FALSE ) + add_item( $item_id, $quantity = 1, $item_location = NULL, $discount = 0, $price = NULL, $description = NULL, $serialnumber = NULL, $receiving_quantity = NULL, $include_deleted = FALSE )
    @@ -989,7 +1002,7 @@
    # - edit_item( $line, $description, $serialnumber, $quantity, $discount, $price ) + edit_item( $line, $description, $serialnumber, $quantity, $discount, $price )
    @@ -1019,7 +1032,7 @@
    # - delete_item( $line ) + delete_item( $line )
    @@ -1049,7 +1062,7 @@
    # - return_entire_receiving( $receipt_receiving_id ) + return_entire_receiving( $receipt_receiving_id )
    @@ -1079,7 +1092,7 @@
    # - add_item_kit( $external_item_kit_id, $item_location ) + add_item_kit( $external_item_kit_id, $item_location )
    @@ -1109,7 +1122,7 @@
    # - copy_entire_receiving( $receiving_id ) + copy_entire_receiving( $receiving_id )
    @@ -1139,7 +1152,7 @@
    # - clear_all( ) + clear_all( )
    @@ -1169,7 +1182,7 @@
    # - get_item_total( $quantity, $price, $discount_percentage ) + get_item_total( $quantity, $price, $discount_percentage )
    @@ -1199,7 +1212,7 @@
    # - get_total( ) + get_total( )
    diff --git a/docs/class-Receivings.html b/docs/class-Receivings.html index 3614bcda9..c74525ce8 100644 --- a/docs/class-Receivings.html +++ b/docs/class-Receivings.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • diff --git a/docs/class-Report.html b/docs/class-Report.html index 3a54ccab6..fa68ee2c9 100644 --- a/docs/class-Report.html +++ b/docs/class-Report.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • diff --git a/docs/class-Reports.html b/docs/class-Reports.html index b6d249dd8..d80aec2ff 100644 --- a/docs/class-Reports.html +++ b/docs/class-Reports.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -239,7 +241,7 @@ CI_Controller - Located at controllers/Reports.php + Located at controllers/Reports.php
    @@ -983,7 +985,7 @@ CI_Controller
    # - specific_customer( $start_date, $end_date, $customer_id, $sale_type ) + specific_customer( $start_date, $end_date, $customer_id, $sale_type )
    @@ -1013,7 +1015,7 @@ CI_Controller
    # - specific_employee_input( ) + specific_employee_input( )
    @@ -1043,7 +1045,7 @@ CI_Controller
    # - specific_employee( $start_date, $end_date, $employee_id, $sale_type ) + specific_employee( $start_date, $end_date, $employee_id, $sale_type )
    @@ -1073,7 +1075,7 @@ CI_Controller
    # - specific_discount_input( ) + specific_discount_input( )
    @@ -1103,7 +1105,7 @@ CI_Controller
    # - specific_discount( $start_date, $end_date, $discount, $sale_type ) + specific_discount( $start_date, $end_date, $discount, $sale_type )
    @@ -1133,7 +1135,7 @@ CI_Controller
    # - get_detailed_sales_row( $sale_id ) + get_detailed_sales_row( $sale_id )
    @@ -1163,7 +1165,7 @@ CI_Controller
    # - detailed_sales( $start_date, $end_date, $sale_type, $location_id = 'all' ) + detailed_sales( $start_date, $end_date, $sale_type, $location_id = 'all' )
    @@ -1193,7 +1195,7 @@ CI_Controller
    # - get_detailed_receivings_row( $receiving_id ) + get_detailed_receivings_row( $receiving_id )
    @@ -1223,7 +1225,7 @@ CI_Controller
    # - detailed_receivings( $start_date, $end_date, $receiving_type, $location_id = 'all' ) + detailed_receivings( $start_date, $end_date, $receiving_type, $location_id = 'all' )
    @@ -1253,7 +1255,7 @@ CI_Controller
    # - inventory_low( ) + inventory_low( )
    @@ -1283,7 +1285,7 @@ CI_Controller
    # - inventory_summary_input( ) + inventory_summary_input( )
    @@ -1313,7 +1315,7 @@ CI_Controller
    # - inventory_summary( $location_id = 'all', $item_count = 'all' ) + inventory_summary( $location_id = 'all', $item_count = 'all' )
    diff --git a/docs/class-Rewards.html b/docs/class-Rewards.html index b6b5513b4..8241416b6 100644 --- a/docs/class-Rewards.html +++ b/docs/class-Rewards.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -204,6 +206,9 @@

    Class Rewards

    +
    +

    Rewards class

    +
    @@ -232,7 +237,13 @@ CI_Model - Located at models/Rewards.php + Author: + joshua1234511
    + Since: + 3.1
    + Link: + github.com/jekkos/opensourcepos
    + Located at models/Rewards.php
    @@ -252,7 +263,7 @@ CI_Model
    # - save( & $rewards_data, $id = -1 ) + save( & $rewards_data, $id = -1 )
    diff --git a/docs/class-Rounding_code.html b/docs/class-Rounding_code.html index ef289e122..f45d12e30 100644 --- a/docs/class-Rounding_code.html +++ b/docs/class-Rounding_code.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -204,6 +206,9 @@

    Class Rounding_code

    +
    +

    Rounding_code class

    +
    @@ -219,7 +224,13 @@ - Located at models/enums/Rounding_code.php + Author: + SteveIreland
    + Since: + 3.1
    + Link: + github.com/jekkos/opensourcepos
    + Located at models/enums/Rounding_code.php
    @@ -239,7 +250,7 @@
    # - get_rounding_options( ) + get_rounding_options( )
    @@ -269,7 +280,7 @@
    # - get_rounding_code_name( $rounding_code ) + get_rounding_code_name( $rounding_code )
    @@ -299,7 +310,7 @@
    # - get_html_rounding_options( ) + get_html_rounding_options( )
    @@ -333,7 +344,7 @@
    integer - HALF_UP + HALF_UP
    @@ -357,7 +368,7 @@
    integer - HALF_DOWN + HALF_DOWN
    @@ -381,7 +392,7 @@
    integer - HALF_EVEN + HALF_EVEN
    @@ -405,7 +416,7 @@
    integer - HALF_ODD + HALF_ODD
    @@ -429,7 +440,7 @@
    integer - ROUND_UP + ROUND_UP
    @@ -453,7 +464,7 @@
    integer - ROUND_DOWN + ROUND_DOWN
    @@ -477,7 +488,7 @@
    integer - HALF_FIVE + HALF_FIVE
    diff --git a/docs/class-Sale.html b/docs/class-Sale.html index b3e42ce0c..0da946969 100644 --- a/docs/class-Sale.html +++ b/docs/class-Sale.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -204,6 +206,9 @@

    Class Sale

    +
    +

    Sale class

    +
    @@ -232,7 +237,13 @@ CI_Model - Located at models/Sale.php + Author: + N/A
    + Since: + 1.0
    + Link: + github.com/jekkos/opensourcepos
    + Located at models/Sale.php
    @@ -252,14 +263,14 @@ CI_Model
    # - get_info( $sale_id ) + get_info( $sale_id )
    - +

    Get sale info

    # - get_found_rows( $search, $filters ) + get_found_rows( $search, $filters )
    - +

    Get number of rows for the takings (sales/manage) view

    # - search( $search, $filters, $rows = 0, $limit_from = 0, $sort = 'sale_time', $order = 'desc' ) + search( $search, $filters, $rows = 0, $limit_from = 0, $sort = 'sale_time', $order = 'desc' )
    - +

    Get the sales data for the takings (sales/manage) view

    # - get_payments_summary( $search, $filters ) + get_payments_summary( $search, $filters )
    - +

    Get the payment summary for the takings (sales/manage) view

    # - get_total_rows( ) + get_total_rows( )
    - +

    Gets total of rows

    # - get_search_suggestions( $search, $limit = 25 ) + get_search_suggestions( $search, $limit = 25 )
    - +

    Gets search suggestions

    # - get_invoice_count( ) + get_invoice_count( )
    - +

    Gets total of invoice rows

    # - get_sale_by_invoice_number( $invoice_number ) + get_sale_by_invoice_number( $invoice_number )
    - +

    Gets sale by invoice number

    # - get_invoice_number_for_year( $year = '', $start_from = 0 ) + get_invoice_number_for_year( $year = '', $start_from = 0 )
    - +

    Gets invoice number by year

    # - is_valid_receipt( & $receipt_sale_id ) + is_valid_receipt( & $receipt_sale_id )
    - +

    Checks if valid receipt

    # - exists( $sale_id ) + exists( $sale_id )
    - +

    Checks if sale exists

    # - update( $sale_id, $sale_data, $payments ) + update( $sale_id, $sale_data, $payments )
    - +

    Update sale

    # - save( & $sale_status, & $items, $customer_id, $employee_id, $comment, $invoice_number, $quote_number, $payments, $dinner_table, & $sales_taxes, $sale_id = FALSE ) + save( & $sale_status, & $items, $customer_id, $employee_id, $comment, $invoice_number, $quote_number, $payments, $dinner_table, & $sales_taxes, $sale_id = FALSE )
    - +

    Save the sale information after the sales is complete but before the final document is printed +The sales_taxes variable needs to be initialized to an empty array before calling

    # - save_sales_item_tax( & $customer, & $sale_id, & $item, $tax_basis, & $sales_taxes, & $sequence, $tax_category_id ) + save_sales_item_tax( & $customer, & $sale_id, & $item, $tax_basis, & $sales_taxes, & $sequence, $tax_category_id )

    Apply customer sales tax if the customer sales tax is enabledl @@ -665,6 +678,36 @@ as a separate tax entry on the invoice.

    +
    +
    + public + + + + +
    + # + save_sales_tax( & $sales_taxes ) + +
    +

    Saves sale tax

    +
    + +
    # - delete_list( $sale_ids, $employee_id, $update_inventory = TRUE ) + delete_list( $sale_ids, $employee_id, $update_inventory = TRUE )
    - +

    Deletes list of sales

    # - delete( $sale_id, $employee_id, $update_inventory = TRUE ) + delete( $sale_id, $employee_id, $update_inventory = TRUE )
    - +

    Delete sale

    # - get_sale_items( $sale_id ) + get_sale_items( $sale_id )
    - +

    Gets sale item

    # - get_sale_items_ordered( $sale_id ) + get_sale_items_ordered( $sale_id )
    - +

    Used by the invoice and receipt programs

    # - get_sale_payments( $sale_id ) + get_sale_payments( $sale_id )
    - +

    Gets sale payments

    # - get_payment_options( $giftcard = TRUE, $reward_points = FALSE ) + get_payment_options( $giftcard = TRUE, $reward_points = FALSE )
    - +

    Gets sale payment options

    # - get_customer( $sale_id ) + get_customer( $sale_id )
    - +

    Gets sale customer name

    # - get_employee( $sale_id ) + get_employee( $sale_id )
    - +

    Gets sale employee name

    # - check_quote_number_exists( $quote_number, $sale_id = '' ) + check_quote_number_exists( $quote_number, $sale_id = '' )
    @@ -950,14 +993,14 @@ as a separate tax entry on the invoice.

    # - check_invoice_number_exists( $invoice_number, $sale_id = '' ) + check_invoice_number_exists( $invoice_number, $sale_id = '' )
    - +

    Checks if invoice number exists

    # - get_giftcard_value( $giftcardNumber ) + get_giftcard_value( $giftcardNumber )
    - +

    Gets Giftcard value

    # - create_temp_table( array $inputs ) + create_temp_table( array $inputs )
    - +

    Creates sales temporary dimentional table +We create a temp table that allows us to do easy report/sales queries

    # - get_all_suspended( $customer_id = NULL ) + get_all_suspended( $customer_id = NULL )
    - +

    Retrieves all sales that are in a suspended state

    # - get_dinner_table( $sale_id ) + get_dinner_table( $sale_id )
    - +

    Gets the dinner table for the selected sale

    +
    + public + + + +
    + # + get_quote_number( $sale_id ) + +
    +

    Gets the quote_number for the selected sale

    +
    + + +
    + public + + + + +
    + # + get_comment( $sale_id ) + +
    +

    Gets the quote_number for the selected sale

    +
    + +
    # - get_suspended_invoice_count( ) + get_suspended_invoice_count( )
    - +

    Gets total of suspended invoices rows

    # - delete_suspended_sale( $sale_id ) + delete_suspended_sale( $sale_id )
    - +

    Removes a selected sale from the sales table. +This function should only be called for suspended sales that are being restored to the current cart

    # - get_suspended_sale_info( $sale_id ) + get_suspended_sale_info( $sale_id )
    - +

    Gets suspended sale info

    @@ -239,7 +252,7 @@
    # - __construct( ) + __construct( )
    @@ -269,7 +282,7 @@
    # - get_line_sequence_options( ) + get_line_sequence_options( )
    @@ -299,7 +312,7 @@
    # - get_register_mode_options( ) + get_register_mode_options( )
    @@ -329,7 +342,7 @@
    # - get_cart( ) + get_cart( )
    @@ -359,7 +372,7 @@
    # - sort_and_filter_cart( $cart ) + sort_and_filter_cart( $cart )
    @@ -389,7 +402,7 @@
    # - set_cart( $cart_data ) + set_cart( $cart_data )
    @@ -419,7 +432,7 @@
    # - empty_cart( ) + empty_cart( )
    @@ -449,7 +462,7 @@
    # - get_comment( ) + get_comment( )
    @@ -479,7 +492,7 @@
    # - set_comment( $comment ) + set_comment( $comment )
    @@ -509,7 +522,7 @@
    # - clear_comment( ) + clear_comment( )
    @@ -539,7 +552,7 @@
    # - get_invoice_number( ) + get_invoice_number( )
    @@ -569,7 +582,7 @@
    # - get_quote_number( ) + get_quote_number( )
    @@ -599,7 +612,7 @@
    # - set_invoice_number( $invoice_number, $keep_custom = FALSE ) + set_invoice_number( $invoice_number, $keep_custom = FALSE )
    @@ -629,7 +642,7 @@
    # - set_quote_number( $quote_number, $keep_custom = FALSE ) + set_quote_number( $quote_number, $keep_custom = FALSE )
    @@ -659,7 +672,7 @@
    # - clear_invoice_number( ) + clear_invoice_number( )
    @@ -689,7 +702,7 @@
    # - clear_quote_number( ) + clear_quote_number( )
    @@ -719,7 +732,7 @@
    # - set_suspended_id( $suspended_id ) + set_suspended_id( $suspended_id )
    @@ -749,7 +762,7 @@
    # - get_suspended_id( ) + get_suspended_id( )
    @@ -779,7 +792,7 @@
    # - is_invoice_mode( ) + is_invoice_mode( )
    @@ -809,7 +822,7 @@
    # - is_sale_by_receipt_mode( ) + is_sale_by_receipt_mode( )
    @@ -839,7 +852,7 @@
    # - is_quote_mode( ) + is_quote_mode( )
    @@ -869,7 +882,7 @@
    # - set_invoice_number_enabled( $invoice_number_enabled ) + set_invoice_number_enabled( $invoice_number_enabled )
    @@ -899,7 +912,7 @@
    # - is_print_after_sale( ) + is_print_after_sale( )
    @@ -929,7 +942,7 @@
    # - set_print_after_sale( $print_after_sale ) + set_print_after_sale( $print_after_sale )
    @@ -959,7 +972,7 @@
    # - get_email_receipt( ) + get_email_receipt( )
    @@ -989,7 +1002,7 @@
    # - set_email_receipt( $email_receipt ) + set_email_receipt( $email_receipt )
    @@ -1019,7 +1032,7 @@
    # - clear_email_receipt( ) + clear_email_receipt( )
    @@ -1049,7 +1062,7 @@
    # - get_payments( ) + get_payments( )
    @@ -1079,7 +1092,7 @@
    # - set_payments( $payments_data ) + set_payments( $payments_data )
    @@ -1109,7 +1122,7 @@
    # - add_payment( $payment_id, $payment_amount ) + add_payment( $payment_id, $payment_amount )
    @@ -1139,7 +1152,7 @@
    # - edit_payment( $payment_id, $payment_amount ) + edit_payment( $payment_id, $payment_amount )
    @@ -1169,7 +1182,7 @@
    # - delete_payment( $payment_id ) + delete_payment( $payment_id )
    @@ -1199,7 +1212,7 @@
    # - empty_payments( ) + empty_payments( )
    @@ -1229,7 +1242,7 @@
    # - get_payments_total( ) + get_payments_total( )
    @@ -1259,7 +1272,7 @@
    # - get_cash_rounding( ) + get_cash_rounding( )
    @@ -1289,7 +1302,7 @@
    # - get_totals( ) + get_totals( )
    @@ -1319,7 +1332,7 @@
    # - get_amount_due( ) + get_amount_due( )
    @@ -1349,7 +1362,7 @@
    # - is_payment_covering_total( ) + is_payment_covering_total( )
    @@ -1379,7 +1392,7 @@
    # - get_customer( ) + get_customer( )
    @@ -1409,7 +1422,7 @@
    # - set_customer( $customer_id ) + set_customer( $customer_id )
    @@ -1439,7 +1452,7 @@
    # - remove_customer( ) + remove_customer( )
    @@ -1469,7 +1482,7 @@
    # - get_employee( ) + get_employee( )
    @@ -1499,7 +1512,7 @@
    # - set_employee( $employee_id ) + set_employee( $employee_id )
    @@ -1529,7 +1542,7 @@
    # - remove_employee( ) + remove_employee( )
    @@ -1559,7 +1572,7 @@
    # - get_mode( ) + get_mode( )
    @@ -1589,7 +1602,7 @@
    # - set_mode( $mode ) + set_mode( $mode )
    @@ -1619,7 +1632,7 @@
    # - clear_mode( ) + clear_mode( )
    @@ -1649,7 +1662,7 @@
    # - get_dinner_table( ) + get_dinner_table( )
    @@ -1679,7 +1692,7 @@
    # - set_dinner_table( $dinner_table ) + set_dinner_table( $dinner_table )
    @@ -1709,7 +1722,7 @@
    # - clear_table( ) + clear_table( )
    @@ -1739,7 +1752,7 @@
    # - get_sale_location( ) + get_sale_location( )
    @@ -1769,7 +1782,7 @@
    # - set_sale_location( $location ) + set_sale_location( $location )
    @@ -1799,7 +1812,7 @@
    # - set_payment_type( $payment_type ) + set_payment_type( $payment_type )
    @@ -1829,7 +1842,7 @@
    # - get_payment_type( ) + get_payment_type( )
    @@ -1859,7 +1872,7 @@
    # - clear_sale_location( ) + clear_sale_location( )
    @@ -1889,7 +1902,7 @@
    # - set_giftcard_remainder( $value ) + set_giftcard_remainder( $value )
    @@ -1919,7 +1932,7 @@
    # - get_giftcard_remainder( ) + get_giftcard_remainder( )
    @@ -1949,7 +1962,7 @@
    # - clear_giftcard_remainder( ) + clear_giftcard_remainder( )
    @@ -1979,7 +1992,7 @@
    # - set_rewards_remainder( $value ) + set_rewards_remainder( $value )
    @@ -2009,7 +2022,7 @@
    # - get_rewards_remainder( ) + get_rewards_remainder( )
    @@ -2039,7 +2052,7 @@
    # - clear_rewards_remainder( ) + clear_rewards_remainder( )
    @@ -2069,7 +2082,7 @@
    # - add_item( & $item_id, $quantity, $item_location, $discount = 0, $price = NULL, $description = NULL, $serialnumber = NULL, $include_deleted = FALSE, $print_option = '0', $stock_type = '0' ) + add_item( & $item_id, $quantity, $item_location, $discount = 0, $price = NULL, $description = NULL, $serialnumber = NULL, $include_deleted = FALSE, $print_option = '0', $stock_type = '0' )
    @@ -2099,7 +2112,7 @@
    # - out_of_stock( $item_id, $item_location ) + out_of_stock( $item_id, $item_location )
    @@ -2129,7 +2142,7 @@
    # - get_quantity_already_added( $item_id, $item_location ) + get_quantity_already_added( $item_id, $item_location )
    @@ -2159,7 +2172,7 @@
    # - get_item_id( $line_to_get ) + get_item_id( $line_to_get )
    @@ -2189,7 +2202,7 @@
    # - edit_item( $line, $description, $serialnumber, $quantity, $discount, $price ) + edit_item( $line, $description, $serialnumber, $quantity, $discount, $price )
    @@ -2219,7 +2232,7 @@
    # - delete_item( $line ) + delete_item( $line )
    @@ -2249,7 +2262,7 @@
    # - return_entire_sale( $receipt_sale_id ) + return_entire_sale( $receipt_sale_id )
    @@ -2279,7 +2292,7 @@
    # - add_item_kit( $external_item_kit_id, $item_location, $discount, $price_option, $kit_print_option, & $stock_warning ) + add_item_kit( $external_item_kit_id, $item_location, $discount, $price_option, $kit_print_option, & $stock_warning )
    @@ -2309,7 +2322,7 @@
    # - copy_entire_sale( $sale_id ) + copy_entire_sale( $sale_id )
    @@ -2339,7 +2352,7 @@
    # - get_cart_reordered( $sale_id ) + get_cart_reordered( $sale_id )
    @@ -2369,7 +2382,7 @@
    # - copy_entire_suspended_sale( $sale_id ) + copy_entire_suspended_sale( $sale_id )
    @@ -2399,7 +2412,7 @@
    # - copy_entire_suspended_tables_sale( $sale_id ) + copy_entire_suspended_tables_sale( $sale_id )
    @@ -2429,7 +2442,7 @@
    # - clear_all( ) + clear_all( )
    @@ -2459,7 +2472,7 @@
    # - clear_cash_flags( ) + clear_cash_flags( )
    @@ -2489,7 +2502,7 @@
    # - reset_cash_flags( ) + reset_cash_flags( )
    @@ -2519,7 +2532,7 @@
    # - is_customer_taxable( ) + is_customer_taxable( )
    @@ -2549,7 +2562,7 @@
    # - get_taxes( ) + get_taxes( )
    @@ -2579,7 +2592,7 @@
    # - apply_customer_discount( $discount_percent ) + apply_customer_discount( $discount_percent )
    @@ -2609,7 +2622,7 @@
    # - get_discount( ) + get_discount( )
    @@ -2639,7 +2652,7 @@
    # - get_subtotal( $include_discount = FALSE, $exclude_tax = FALSE ) + get_subtotal( $include_discount = FALSE, $exclude_tax = FALSE )
    @@ -2669,7 +2682,37 @@
    # - get_item_total_tax_exclusive( $item_id, $quantity, $price, $discount_percentage, $include_discount = FALSE ) + get_item_total_tax_exclusive( $item_id, $quantity, $price, $discount_percentage, $include_discount = FALSE ) + +
    + +
    + + +
    + public + + + + +
    + # + get_extended_total_tax_exclusive( $item_id, $discounted_extended_amount, $quantity, $price, $discount_percentage = 0 )
    @@ -2699,7 +2742,37 @@
    # - get_item_total( $quantity, $price, $discount_percentage, $include_discount = FALSE ) + get_item_total( $quantity, $price, $discount_percentage, $include_discount = FALSE ) + +
    + +
    + + +
    + public + + + + +
    + # + get_extended_amount( $quantity, $price, $discount_amount = 0 )
    @@ -2729,7 +2802,7 @@
    # - get_item_discount( $quantity, $price, $discount_percentage ) + get_item_discount( $quantity, $price, $discount_percentage )
    @@ -2759,7 +2832,7 @@
    # - get_item_tax( $quantity, $price, $discount_percentage, $tax_percentage ) + get_item_tax( $quantity, $price, $discount_percentage, $tax_percentage )
    @@ -2789,7 +2862,7 @@
    # - calculate_subtotal( $include_discount = FALSE, $exclude_tax = FALSE ) + calculate_subtotal( $include_discount = FALSE, $exclude_tax = FALSE )
    @@ -2819,7 +2892,7 @@
    # - get_total( ) + get_total( )
    @@ -2849,7 +2922,7 @@
    # - get_empty_tables( ) + get_empty_tables( )
    @@ -2879,7 +2952,7 @@
    # - check_for_cash_rounding( $total ) + check_for_cash_rounding( $total )
    diff --git a/docs/class-Sale_suspended.html b/docs/class-Sale_suspended.html index d2477ff69..6f2a0c0e0 100644 --- a/docs/class-Sale_suspended.html +++ b/docs/class-Sale_suspended.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -204,6 +206,9 @@

    Class Sale_suspended

    +
    +

    Sale_suspended class

    +
    @@ -232,7 +237,13 @@ CI_Model - Located at models/Sale_suspended.php + Author: + N/A
    + Since: + 1.0
    + Link: + github.com/jekkos/opensourcepos
    + Located at models/Sale_suspended.php
    @@ -252,7 +263,7 @@ CI_Model
    # - get_all( ) + get_all( )
    @@ -282,7 +293,7 @@ CI_Model
    # - get_info( $sale_id ) + get_info( $sale_id )
    @@ -312,7 +323,7 @@ CI_Model
    # - get_invoice_count( ) + get_invoice_count( )
    @@ -342,7 +353,7 @@ CI_Model
    # - get_sale_by_invoice_number( $invoice_number ) + get_sale_by_invoice_number( $invoice_number )
    @@ -372,7 +383,7 @@ CI_Model
    # - exists( $sale_id ) + exists( $sale_id )
    @@ -402,7 +413,7 @@ CI_Model
    # - update( $sale_data, $sale_id ) + update( $sale_data, $sale_id )
    @@ -432,7 +443,7 @@ CI_Model
    # - save( $items, $customer_id, $employee_id, $comment, $invoice_number, $quote_number, $payments, $dinner_table, $sale_id = FALSE ) + save( $items, $customer_id, $employee_id, $comment, $invoice_number, $quote_number, $payments, $dinner_table, $sale_id = FALSE )
    @@ -462,7 +473,7 @@ CI_Model
    # - delete( $sale_id ) + delete( $sale_id )
    @@ -492,7 +503,7 @@ CI_Model
    # - get_sale_items( $sale_id ) + get_sale_items( $sale_id )
    @@ -522,7 +533,7 @@ CI_Model
    # - get_sale_payments( $sale_id ) + get_sale_payments( $sale_id )
    @@ -552,7 +563,7 @@ CI_Model
    # - get_comment( $sale_id ) + get_comment( $sale_id )
    @@ -582,7 +593,7 @@ CI_Model
    # - get_dinner_table( $sale_id ) + get_dinner_table( $sale_id )
    diff --git a/docs/class-Sales.html b/docs/class-Sales.html index c77451828..7dc645a23 100644 --- a/docs/class-Sales.html +++ b/docs/class-Sales.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -239,7 +241,7 @@ CI_Controller - Located at controllers/Sales.php + Located at controllers/Sales.php
    @@ -1047,7 +1049,7 @@ CI_Controller
    # - receipt( $sale_id ) + receipt( $sale_id )
    @@ -1077,7 +1079,7 @@ CI_Controller
    # - invoice( $sale_id ) + invoice( $sale_id )
    @@ -1107,7 +1109,7 @@ CI_Controller
    # - edit( $sale_id ) + edit( $sale_id )
    @@ -1137,7 +1139,7 @@ CI_Controller
    # - delete( $sale_id = -1, $update_inventory = TRUE ) + delete( $sale_id = -1, $update_inventory = TRUE )
    @@ -1169,7 +1171,7 @@ CI_Controller
    # - save( $sale_id = -1 ) + save( $sale_id = -1 )
    @@ -1201,7 +1203,7 @@ CI_Controller
    # - cancel( ) + cancel( )
    @@ -1231,7 +1233,7 @@ CI_Controller
    # - discard_quote( ) + discard_quote( )
    @@ -1261,7 +1263,7 @@ CI_Controller
    # - suspend( ) + suspend( )
    @@ -1291,7 +1293,7 @@ CI_Controller
    # - suspend_quote( $quote_number ) + suspend_quote( $quote_number )
    @@ -1321,7 +1323,7 @@ CI_Controller
    # - suspended( ) + suspended( )
    @@ -1351,7 +1353,7 @@ CI_Controller
    # - unsuspend( ) + unsuspend( )
    @@ -1381,7 +1383,7 @@ CI_Controller
    # - check_invoice_number( ) + check_invoice_number( )
    @@ -1411,7 +1413,7 @@ CI_Controller
    # - get_filtered( $cart ) + get_filtered( $cart )
    diff --git a/docs/class-Secure_Controller.html b/docs/class-Secure_Controller.html index 296211605..1c6cc8294 100644 --- a/docs/class-Secure_Controller.html +++ b/docs/class-Secure_Controller.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -224,15 +226,16 @@ CI_Controller

    Direct known subclasses

    Config, Giftcards, + Sales, Taxes, Home, Item_kits, Items, Messages, + Migrate, Persons, Receivings, - Reports, - Sales + Reports
    diff --git a/docs/class-Sms_lib.html b/docs/class-Sms_lib.html index 2c7af4211..a142fea27 100644 --- a/docs/class-Sms_lib.html +++ b/docs/class-Sms_lib.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -204,6 +206,11 @@

    Class Sms_lib

    +
    +

    SMS library

    + +

    Library with utilities to send texts via SMS Gateway (requires proxy implementation)

    +
    @@ -219,7 +226,13 @@ - Located at libraries/Sms_lib.php + Author: + RamkrishnaMondal, daN4cat (FrancescoUK)
    + Since: + 3.0
    + Link: + github.com/jekkos/opensourcepos
    + Located at libraries/Sms_lib.php
    @@ -239,7 +252,7 @@
    # - __construct( ) + __construct( )
    @@ -269,7 +282,7 @@
    # - sendSMS( $phone, $message ) + sendSMS( $phone, $message )
    diff --git a/docs/class-Specific_customer.html b/docs/class-Specific_customer.html index e106c728c..4456ebbb6 100644 --- a/docs/class-Specific_customer.html +++ b/docs/class-Specific_customer.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -239,7 +241,7 @@ CI_Model - Located at models/reports/Specific_customer.php + Located at models/reports/Specific_customer.php
    @@ -247,38 +249,6 @@ CI_Model - - - - - -
    Methods summary
    - public - - - - -
    - # - __construct( ) - -
    - -
    - - -
    @@ -291,7 +261,7 @@ CI_Model
    # - create( array $inputs ) + create( array $inputs )
    @@ -321,7 +291,7 @@ CI_Model
    # - getDataColumns( ) + getDataColumns( )
    @@ -351,7 +321,7 @@ CI_Model
    # - getData( array $inputs ) + getData( array $inputs )
    @@ -381,7 +351,7 @@ CI_Model
    # - getSummaryData( array $inputs ) + getSummaryData( array $inputs )
    @@ -401,6 +371,14 @@ CI_Model
    + + + + + +
    Methods inherited from Report
    + __construct() +
    diff --git a/docs/class-Specific_discount.html b/docs/class-Specific_discount.html index 75fed377b..ef87a2f6a 100644 --- a/docs/class-Specific_discount.html +++ b/docs/class-Specific_discount.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -239,7 +241,7 @@ CI_Model - Located at models/reports/Specific_discount.php + Located at models/reports/Specific_discount.php
    @@ -247,38 +249,6 @@ CI_Model - - - - - -
    Methods summary
    - public - - - - -
    - # - __construct( ) - -
    - -
    - - -
    @@ -291,7 +261,7 @@ CI_Model
    # - create( array $inputs ) + create( array $inputs )
    @@ -321,7 +291,7 @@ CI_Model
    # - getDataColumns( ) + getDataColumns( )
    @@ -351,7 +321,7 @@ CI_Model
    # - getData( array $inputs ) + getData( array $inputs )
    @@ -381,7 +351,7 @@ CI_Model
    # - getSummaryData( array $inputs ) + getSummaryData( array $inputs )
    @@ -401,6 +371,14 @@ CI_Model
    + + + + + +
    Methods inherited from Report
    + __construct() +
    diff --git a/docs/class-Specific_employee.html b/docs/class-Specific_employee.html index bc3370d96..da2969925 100644 --- a/docs/class-Specific_employee.html +++ b/docs/class-Specific_employee.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -239,7 +241,7 @@ CI_Model - Located at models/reports/Specific_employee.php + Located at models/reports/Specific_employee.php
    @@ -247,38 +249,6 @@ CI_Model - - - - - -
    Methods summary
    - public - - - - -
    - # - __construct( ) - -
    - -
    - - -
    @@ -291,7 +261,7 @@ CI_Model
    # - create( array $inputs ) + create( array $inputs )
    @@ -321,7 +291,7 @@ CI_Model
    # - getDataColumns( ) + getDataColumns( )
    @@ -351,7 +321,7 @@ CI_Model
    # - getData( array $inputs ) + getData( array $inputs )
    @@ -381,7 +351,7 @@ CI_Model
    # - getSummaryData( array $inputs ) + getSummaryData( array $inputs )
    @@ -401,6 +371,14 @@ CI_Model
    + + + + + +
    Methods inherited from Report
    + __construct() +
    diff --git a/docs/class-Stock_location.html b/docs/class-Stock_location.html index abf2c0e12..e4d09bafe 100644 --- a/docs/class-Stock_location.html +++ b/docs/class-Stock_location.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -204,6 +206,9 @@

    Class Stock_location

    +
    +

    Stock_location class

    +
    @@ -232,7 +237,13 @@ CI_Model - Located at models/Stock_location.php + Author: + Padungsak
    + Since: + 2.x
    + Link: + github.com/jekkos/opensourcepos
    + Located at models/Stock_location.php
    @@ -252,7 +263,7 @@ CI_Model
    # - exists( $location_name = '' ) + exists( $location_name = '' )
    @@ -282,7 +293,7 @@ CI_Model
    # - get_all( $limit = 10000, $offset = 0 ) + get_all( $limit = 10000, $offset = 0 )
    @@ -312,7 +323,7 @@ CI_Model
    # - get_undeleted_all( $module_id = 'items' ) + get_undeleted_all( $module_id = 'items' )
    @@ -342,7 +353,7 @@ CI_Model
    # - show_locations( $module_id = 'items' ) + show_locations( $module_id = 'items' )
    @@ -372,7 +383,7 @@ CI_Model
    # - multiple_locations( ) + multiple_locations( )
    @@ -402,7 +413,7 @@ CI_Model
    # - get_allowed_locations( $module_id = 'items' ) + get_allowed_locations( $module_id = 'items' )
    @@ -432,7 +443,7 @@ CI_Model
    # - is_allowed_location( $location_id, $module_id = 'items' ) + is_allowed_location( $location_id, $module_id = 'items' )
    @@ -462,7 +473,7 @@ CI_Model
    # - get_default_location_id( ) + get_default_location_id( )
    @@ -492,7 +503,7 @@ CI_Model
    # - get_location_name( $location_id ) + get_location_name( $location_id )
    @@ -522,7 +533,7 @@ CI_Model
    # - save( & $location_data, $location_id ) + save( & $location_data, $location_id )
    @@ -552,7 +563,7 @@ CI_Model
    # - delete( $location_id ) + delete( $location_id )
    diff --git a/docs/class-Summary_categories.html b/docs/class-Summary_categories.html index 879f90902..37aa31fa8 100644 --- a/docs/class-Summary_categories.html +++ b/docs/class-Summary_categories.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -246,7 +248,7 @@ CI_Model - Located at models/reports/Summary_categories.php + Located at models/reports/Summary_categories.php
    @@ -254,38 +256,6 @@ CI_Model - - - - - -
    Methods summary
    - public - - - - -
    - # - __construct( ) - -
    - -
    - - -
    @@ -298,7 +268,7 @@ CI_Model
    # - _get_data_columns( ) + _get_data_columns( )
    @@ -328,7 +298,7 @@ CI_Model
    # - _select( array $inputs ) + _select( array $inputs )
    @@ -360,7 +330,7 @@ CI_Model
    # - _from( ) + _from( )
    @@ -392,7 +362,7 @@ CI_Model
    # - _group_order( ) + _group_order( )
    @@ -425,6 +395,14 @@ CI_Model
    + + + + + +
    Methods inherited from Report
    + __construct() +
    diff --git a/docs/class-Summary_customers.html b/docs/class-Summary_customers.html index 3ff39aed1..af21ba54d 100644 --- a/docs/class-Summary_customers.html +++ b/docs/class-Summary_customers.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -246,7 +248,7 @@ CI_Model - Located at models/reports/Summary_customers.php + Located at models/reports/Summary_customers.php
    @@ -254,38 +256,6 @@ CI_Model - - - - - -
    Methods summary
    - public - - - - -
    - # - __construct( ) - -
    - -
    - - -
    @@ -298,7 +268,7 @@ CI_Model
    # - _get_data_columns( ) + _get_data_columns( )
    @@ -328,7 +298,7 @@ CI_Model
    # - _select( array $inputs ) + _select( array $inputs )
    @@ -360,7 +330,7 @@ CI_Model
    # - _from( ) + _from( )
    @@ -392,7 +362,7 @@ CI_Model
    # - _group_order( ) + _group_order( )
    @@ -425,6 +395,14 @@ CI_Model
    + + + + + +
    Methods inherited from Report
    + __construct() +
    diff --git a/docs/class-Summary_discounts.html b/docs/class-Summary_discounts.html index 0099b19de..3b3854625 100644 --- a/docs/class-Summary_discounts.html +++ b/docs/class-Summary_discounts.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -246,7 +248,7 @@ CI_Model - Located at models/reports/Summary_discounts.php + Located at models/reports/Summary_discounts.php
    @@ -254,38 +256,6 @@ CI_Model - - - - - -
    Methods summary
    - public - - - - -
    - # - __construct( ) - -
    - -
    - - -
    @@ -298,7 +268,7 @@ CI_Model
    # - _get_data_columns( ) + _get_data_columns( )
    @@ -328,7 +298,7 @@ CI_Model
    # - getData( array $inputs ) + getData( array $inputs )
    @@ -363,6 +333,14 @@ CI_Model
    + + + + + +
    Methods inherited from Report
    + __construct() +
    diff --git a/docs/class-Summary_employees.html b/docs/class-Summary_employees.html index 6fa773b25..df2ee6555 100644 --- a/docs/class-Summary_employees.html +++ b/docs/class-Summary_employees.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -246,7 +248,7 @@ CI_Model - Located at models/reports/Summary_employees.php + Located at models/reports/Summary_employees.php
    @@ -254,38 +256,6 @@ CI_Model - - - - - -
    Methods summary
    - public - - - - -
    - # - __construct( ) - -
    - -
    - - -
    @@ -298,7 +268,7 @@ CI_Model
    # - _get_data_columns( ) + _get_data_columns( )
    @@ -328,7 +298,7 @@ CI_Model
    # - _select( array $inputs ) + _select( array $inputs )
    @@ -360,7 +330,7 @@ CI_Model
    # - _from( ) + _from( )
    @@ -392,7 +362,7 @@ CI_Model
    # - _group_order( ) + _group_order( )
    @@ -425,6 +395,14 @@ CI_Model
    + + + + + +
    Methods inherited from Report
    + __construct() +
    diff --git a/docs/class-Summary_items.html b/docs/class-Summary_items.html index 29ba09211..645cbe780 100644 --- a/docs/class-Summary_items.html +++ b/docs/class-Summary_items.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -246,7 +248,7 @@ CI_Model - Located at models/reports/Summary_items.php + Located at models/reports/Summary_items.php
    @@ -254,38 +256,6 @@ CI_Model - - - - - -
    Methods summary
    - public - - - - -
    - # - __construct( ) - -
    - -
    - - -
    @@ -298,7 +268,7 @@ CI_Model
    # - _get_data_columns( ) + _get_data_columns( )
    @@ -328,7 +298,7 @@ CI_Model
    # - _select( array $inputs ) + _select( array $inputs )
    @@ -360,7 +330,7 @@ CI_Model
    # - _from( ) + _from( )
    @@ -392,7 +362,7 @@ CI_Model
    # - _group_order( ) + _group_order( )
    @@ -425,6 +395,14 @@ CI_Model
    + + + + + +
    Methods inherited from Report
    + __construct() +
    diff --git a/docs/class-Summary_payments.html b/docs/class-Summary_payments.html index fad830b77..973647619 100644 --- a/docs/class-Summary_payments.html +++ b/docs/class-Summary_payments.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -246,7 +248,7 @@ CI_Model - Located at models/reports/Summary_payments.php + Located at models/reports/Summary_payments.php
    @@ -254,38 +256,6 @@ CI_Model - - - - - -
    Methods summary
    - public - - - - -
    - # - __construct( ) - -
    - -
    - - -
    @@ -298,7 +268,7 @@ CI_Model
    # - _get_data_columns( ) + _get_data_columns( )
    @@ -328,7 +298,7 @@ CI_Model
    # - _where( array $inputs ) + _where( array $inputs )
    @@ -360,7 +330,7 @@ CI_Model
    # - getData( array $inputs ) + getData( array $inputs )
    @@ -394,6 +364,14 @@ CI_Model
    + + + + + +
    Methods inherited from Report
    + __construct() +
    diff --git a/docs/class-Summary_report.html b/docs/class-Summary_report.html index d9b0e02d0..946079994 100644 --- a/docs/class-Summary_report.html +++ b/docs/class-Summary_report.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -251,7 +253,7 @@ CI_Model - Located at models/reports/Summary_report.php + Located at models/reports/Summary_report.php
    @@ -259,38 +261,6 @@ CI_Model - - - - - -
    Methods summary
    - public - - - - -
    - # - __construct( ) - -
    - -
    - - -
    @@ -303,7 +273,7 @@ CI_Model
    # - _get_data_columns( ) + _get_data_columns( )
    @@ -333,7 +303,7 @@ CI_Model
    # - _select( array $inputs ) + _select( array $inputs )
    @@ -363,7 +333,7 @@ CI_Model
    # - _from( ) + _from( )
    @@ -393,7 +363,7 @@ CI_Model
    # - _where( array $inputs ) + _where( array $inputs )
    @@ -423,7 +393,7 @@ CI_Model
    # - _group_order( ) + _group_order( )
    @@ -453,7 +423,7 @@ CI_Model
    # - getDataColumns( ) + getDataColumns( )
    @@ -483,7 +453,7 @@ CI_Model
    # - getData( array $inputs ) + getData( array $inputs )
    @@ -513,7 +483,7 @@ CI_Model
    # - getSummaryData( array $inputs ) + getSummaryData( array $inputs )
    @@ -533,6 +503,14 @@ CI_Model
    + + + + + +
    Methods inherited from Report
    + __construct() +
    diff --git a/docs/class-Summary_sales.html b/docs/class-Summary_sales.html index 5b85433f5..4ee49ffd9 100644 --- a/docs/class-Summary_sales.html +++ b/docs/class-Summary_sales.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -246,7 +248,7 @@ CI_Model - Located at models/reports/Summary_sales.php + Located at models/reports/Summary_sales.php
    @@ -254,38 +256,6 @@ CI_Model - - - - - -
    Methods summary
    - public - - - - -
    - # - __construct( ) - -
    - -
    - - -
    @@ -298,7 +268,7 @@ CI_Model
    # - _get_data_columns( ) + _get_data_columns( )
    @@ -328,7 +298,7 @@ CI_Model
    # - _select( array $inputs ) + _select( array $inputs )
    @@ -360,7 +330,7 @@ CI_Model
    # - _group_order( ) + _group_order( )
    @@ -394,6 +364,14 @@ CI_Model
    + + + + + +
    Methods inherited from Report
    + __construct() +
    diff --git a/docs/class-Summary_suppliers.html b/docs/class-Summary_suppliers.html index 88b326969..2f17a9ad5 100644 --- a/docs/class-Summary_suppliers.html +++ b/docs/class-Summary_suppliers.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -246,7 +248,7 @@ CI_Model - Located at models/reports/Summary_suppliers.php + Located at models/reports/Summary_suppliers.php
    @@ -254,38 +256,6 @@ CI_Model - - - - - -
    Methods summary
    - public - - - - -
    - # - __construct( ) - -
    - -
    - - -
    @@ -298,7 +268,7 @@ CI_Model
    # - _get_data_columns( ) + _get_data_columns( )
    @@ -328,7 +298,7 @@ CI_Model
    # - _select( array $inputs ) + _select( array $inputs )
    @@ -360,7 +330,7 @@ CI_Model
    # - _from( ) + _from( )
    @@ -392,7 +362,7 @@ CI_Model
    # - _group_order( ) + _group_order( )
    @@ -425,6 +395,14 @@ CI_Model
    + + + + + +
    Methods inherited from Report
    + __construct() +
    diff --git a/docs/class-Summary_taxes.html b/docs/class-Summary_taxes.html index bdb2a178d..5154289e6 100644 --- a/docs/class-Summary_taxes.html +++ b/docs/class-Summary_taxes.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -246,7 +248,7 @@ CI_Model - Located at models/reports/Summary_taxes.php + Located at models/reports/Summary_taxes.php
    @@ -254,38 +256,6 @@ CI_Model - - - - - -
    Methods summary
    - public - - - - -
    - # - __construct( ) - -
    - -
    - - -
    @@ -298,7 +268,7 @@ CI_Model
    # - _get_data_columns( ) + _get_data_columns( )
    @@ -328,7 +298,7 @@ CI_Model
    # - _where( array $inputs ) + _where( array $inputs )
    @@ -360,7 +330,7 @@ CI_Model
    # - getData( array $inputs ) + getData( array $inputs )
    @@ -394,6 +364,14 @@ CI_Model
    + + + + + +
    Methods inherited from Report
    + __construct() +
    diff --git a/docs/class-Supplier.html b/docs/class-Supplier.html index ef8c547e0..df6d67a15 100644 --- a/docs/class-Supplier.html +++ b/docs/class-Supplier.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • diff --git a/docs/class-Suppliers.html b/docs/class-Suppliers.html index f429dc506..b76a8988a 100644 --- a/docs/class-Suppliers.html +++ b/docs/class-Suppliers.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • diff --git a/docs/class-Tax.html b/docs/class-Tax.html index 2491a5650..f3cc9c9b4 100644 --- a/docs/class-Tax.html +++ b/docs/class-Tax.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -204,6 +206,9 @@

    Class Tax

    +
    +

    Tax class

    +
    @@ -232,7 +237,13 @@ CI_Model - Located at models/Tax.php + Author: + SteveIreland
    + Since: + 3.1
    + Link: + github.com/jekkos/opensourcepos
    + Located at models/Tax.php
    @@ -252,7 +263,7 @@ CI_Model
    # - exists( $tax_code ) + exists( $tax_code )
    @@ -282,7 +293,7 @@ CI_Model
    # - tax_rate_exists( $tax_code, $tax_category_id ) + tax_rate_exists( $tax_code, $tax_category_id )
    @@ -312,7 +323,7 @@ CI_Model
    # - get_total_rows( ) + get_total_rows( )
    @@ -342,7 +353,7 @@ CI_Model
    # - get_info( $tax_code ) + get_info( $tax_code )
    @@ -372,7 +383,7 @@ CI_Model
    # - get_rate_info( $tax_code, $tax_category_id ) + get_rate_info( $tax_code, $tax_category_id )
    @@ -402,7 +413,7 @@ CI_Model
    # - get_sales_tax_code( $city = '', $state = '' ) + get_sales_tax_code( $city = '', $state = '' )
    @@ -432,7 +443,7 @@ CI_Model
    # - save( & $tax_code_data, $tax_rate_data, $tax_code = -1 ) + save( & $tax_code_data, $tax_rate_data, $tax_code = -1 )
    @@ -462,7 +473,7 @@ CI_Model
    # - save_tax_rates( & $tax_rate_data, $tax_code ) + save_tax_rates( & $tax_rate_data, $tax_code )
    @@ -492,7 +503,7 @@ CI_Model
    # - save_tax_rate_exceptions( & $tax_rate_data, $tax_code ) + save_tax_rate_exceptions( & $tax_rate_data, $tax_code )
    @@ -522,7 +533,7 @@ CI_Model
    # - delete( $tax_code ) + delete( $tax_code )
    @@ -552,7 +563,7 @@ CI_Model
    # - delete_list( $tax_codes ) + delete_list( $tax_codes )
    @@ -582,7 +593,7 @@ CI_Model
    # - delete_tax_rate_exceptions( $tax_code ) + delete_tax_rate_exceptions( $tax_code )
    @@ -612,7 +623,7 @@ CI_Model
    # - search( $search, $rows = 0, $limit_from = 0, $sort = 'tax_code', $order = 'asc' ) + search( $search, $rows = 0, $limit_from = 0, $sort = 'tax_code', $order = 'asc' )
    @@ -642,7 +653,7 @@ CI_Model
    # - get_found_rows( $search ) + get_found_rows( $search )
    @@ -672,7 +683,7 @@ CI_Model
    # - get_tax_code_type_name( $tax_code_type ) + get_tax_code_type_name( $tax_code_type )
    @@ -702,7 +713,7 @@ CI_Model
    # - get_sales_tax_codes_search_suggestions( $search, $limit = 25 ) + get_sales_tax_codes_search_suggestions( $search, $limit = 25 )
    @@ -732,7 +743,7 @@ CI_Model
    # - get_tax_category_suggestions( $search ) + get_tax_category_suggestions( $search )
    @@ -762,7 +773,7 @@ CI_Model
    # - get_tax_category( $tax_category_id ) + get_tax_category( $tax_category_id )
    @@ -792,7 +803,7 @@ CI_Model
    # - get_all_tax_categories( ) + get_all_tax_categories( )
    @@ -822,7 +833,7 @@ CI_Model
    # - get_tax_category_id( $tax_category ) + get_tax_category_id( $tax_category )
    @@ -852,7 +863,7 @@ CI_Model
    # - get_tax_code_rate_exceptions( $tax_code ) + get_tax_code_rate_exceptions( $tax_code )
    diff --git a/docs/class-Tax_lib.html b/docs/class-Tax_lib.html index c4387b026..f92695571 100644 --- a/docs/class-Tax_lib.html +++ b/docs/class-Tax_lib.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -204,6 +206,11 @@

    Class Tax_lib

    +
    +

    Tax library

    + +

    Library with utilities to manage taxes

    +
    @@ -219,7 +226,13 @@ - Located at libraries/Tax_lib.php + Author: + SteveIreland
    + Since: + 3.1
    + Link: + github.com/jekkos/opensourcepos
    + Located at libraries/Tax_lib.php
    @@ -239,7 +252,7 @@
    # - __construct( ) + __construct( )
    @@ -269,7 +282,7 @@
    # - get_tax_types( ) + get_tax_types( )
    @@ -299,7 +312,7 @@
    # - get_item_sales_tax( $quantity, $price, $discount_percentage, $tax_percentage, $rounding_code ) + get_item_sales_tax( $quantity, $price, $discount_percentage, $tax_percentage, $rounding_code )
    @@ -329,7 +342,7 @@
    # - get_sales_tax_for_amount( $tax_basis, $tax_percentage, $rounding_code, $decimals ) + get_sales_tax_for_amount( $tax_basis, $tax_percentage, $rounding_code, $decimals )
    @@ -359,7 +372,7 @@
    # - update_sales_taxes( & $sales_taxes, $tax_type, $tax_group, $tax_rate, $tax_basis, $item_tax_amount, $tax_group_sequence, $rounding_code, $sale_id, $name = '', $tax_code = '' ) + update_sales_taxes( & $sales_taxes, $tax_type, $tax_group, $tax_rate, $tax_basis, $item_tax_amount, $tax_group_sequence, $rounding_code, $sale_id, $name = '', $tax_code = '' )
    @@ -389,7 +402,7 @@
    # - apply_invoice_taxing( & $sales_taxes ) + apply_invoice_taxing( & $sales_taxes )
    @@ -419,7 +432,7 @@
    # - round_sales_taxes( & $sales_taxes ) + round_sales_taxes( & $sales_taxes )
    @@ -449,7 +462,7 @@
    # - apply_sales_tax( & $item, & $city, & $state, & $sales_tax_code, $register_mode, $sale_id, & $sales_taxes ) + apply_sales_tax( & $item, & $city, & $state, & $sales_tax_code, $register_mode, $sale_id, & $sales_taxes )

    Determine the applicable tax code and then determine the tax amount to be applied. @@ -481,7 +494,7 @@ If a tax amount was identified then accumulate into the sales_taxes array

    # - get_applicable_tax_mode( $register_mode, $city, $state, $sales_tax_code ) + get_applicable_tax_mode( $register_mode, $city, $state, $sales_tax_code )
    @@ -511,7 +524,7 @@ If a tax amount was identified then accumulate into the sales_taxes array

    # - clean( $string ) + clean( $string )
    @@ -545,7 +558,7 @@ If a tax amount was identified then accumulate into the sales_taxes array

    integer - TAX_TYPE_SALES + TAX_TYPE_SALES
    @@ -569,7 +582,7 @@ If a tax amount was identified then accumulate into the sales_taxes array

    integer - TAX_TYPE_SALES_BY_INVOICE + TAX_TYPE_SALES_BY_INVOICE
    @@ -593,7 +606,7 @@ If a tax amount was identified then accumulate into the sales_taxes array

    integer - TAX_TYPE_VAT + TAX_TYPE_VAT
    diff --git a/docs/class-Taxes.html b/docs/class-Taxes.html index 4ab577198..293b5ae68 100644 --- a/docs/class-Taxes.html +++ b/docs/class-Taxes.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • diff --git a/docs/class-Token.html b/docs/class-Token.html index 0a72ccf0c..be0f8e065 100644 --- a/docs/class-Token.html +++ b/docs/class-Token.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -204,6 +206,9 @@

    Class Token

    +
    +

    Token class

    +
    @@ -228,7 +233,13 @@ - Located at libraries/tokens/Token.php + Author: + SteveIreland
    + Since: + 3.1
    + Link: + github.com/jekkos/opensourcepos
    + Located at libraries/tokens/Token.php
    @@ -248,7 +259,7 @@
    # - __construct( ) + __construct( )
    @@ -278,7 +289,7 @@
    # - replace( $token_id ) + replace( $token_id )
    @@ -308,7 +319,7 @@
    # - get_value( ) + get_value( )
    @@ -339,6 +350,34 @@ + + + + + + + + +
    Properties summary
    + protected + + + $CI + +
    + +
    + + +
    +
    + # + +
    +
    diff --git a/docs/class-Token_customer.html b/docs/class-Token_customer.html index ed27a15d2..2da3e2461 100644 --- a/docs/class-Token_customer.html +++ b/docs/class-Token_customer.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -204,6 +206,9 @@

    Class Token_customer

    +
    +

    Token_customer class

    +
    @@ -233,7 +238,13 @@ - Located at libraries/tokens/Token_customer.php + Author: + SteveIreland
    + Since: + 3.1
    + Link: + github.com/jekkos/opensourcepos
    + Located at libraries/tokens/Token_customer.php
    @@ -253,7 +264,7 @@
    # - __construct( ) + __construct( )
    @@ -285,7 +296,7 @@
    # - get_value( ) + get_value( )
    @@ -327,6 +338,14 @@ + + + + + +
    Properties inherited from Token
    + $CI +
    diff --git a/docs/class-Token_invoice_count.html b/docs/class-Token_invoice_count.html index 0c717a195..3c77da8dd 100644 --- a/docs/class-Token_invoice_count.html +++ b/docs/class-Token_invoice_count.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -204,6 +206,9 @@

    Class Token_invoice_count

    +
    +

    Token_invoice_count class

    +
    @@ -233,7 +238,13 @@ - Located at libraries/tokens/Token_invoice_count.php + Author: + SteveIreland
    + Since: + 3.1
    + Link: + github.com/jekkos/opensourcepos
    + Located at libraries/tokens/Token_invoice_count.php
    @@ -253,7 +264,7 @@
    # - __construct( ) + __construct( )
    @@ -285,7 +296,7 @@
    # - get_value( ) + get_value( )
    @@ -327,6 +338,14 @@ + + + + + +
    Properties inherited from Token
    + $CI +
    diff --git a/docs/class-Token_invoice_sequence.html b/docs/class-Token_invoice_sequence.html index 07060d692..1a2b01468 100644 --- a/docs/class-Token_invoice_sequence.html +++ b/docs/class-Token_invoice_sequence.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -204,6 +206,9 @@

    Class Token_invoice_sequence

    +
    +

    Token_invoice_sequence class

    +
    @@ -233,7 +238,13 @@ - Located at libraries/tokens/Token_invoice_sequence.php + Author: + SteveIreland
    + Since: + 3.1
    + Link: + github.com/jekkos/opensourcepos
    + Located at libraries/tokens/Token_invoice_sequence.php
    @@ -241,38 +252,6 @@ - - - - - - @@ -327,6 +307,14 @@ +
    Methods summary
    - public - - - - -
    - # - __construct( ) - -
    - -
    - - -
    @@ -311,6 +290,7 @@
    Methods inherited from Token
    + __construct(), replace()
    + + + + +
    Properties inherited from Token
    + $CI +
    diff --git a/docs/class-Token_lib.html b/docs/class-Token_lib.html index 05ef2e9fc..6d264aebf 100644 --- a/docs/class-Token_lib.html +++ b/docs/class-Token_lib.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -204,6 +206,11 @@

    Class Token_lib

    +
    +

    Token library

    + +

    Library with utilities to manage tokens

    +
    @@ -219,7 +226,13 @@ - Located at libraries/Token_lib.php + Author: + SteveIreland
    + Since: + 3.1
    + Link: + github.com/jekkos/opensourcepos
    + Located at libraries/Token_lib.php
    @@ -239,7 +252,7 @@
    # - __construct( ) + __construct( )
    @@ -269,7 +282,7 @@
    # - render( $tokened_text ) + render( $tokened_text )

    Expands all of the tokens found in a given text string and returns the results.

    @@ -299,7 +312,7 @@
    # - scan( $text ) + scan( $text )

    Parses out the all of the tokens enclosed in braces {} and subparses on the colon : character where supplied

    @@ -329,7 +342,7 @@
    # - generate( $used_tokens, & $tokens_to_replace, & $token_values ) + generate( $used_tokens, & $tokens_to_replace, & $token_values )
    diff --git a/docs/class-Token_quote_sequence.html b/docs/class-Token_quote_sequence.html index e77723047..31a3995d8 100644 --- a/docs/class-Token_quote_sequence.html +++ b/docs/class-Token_quote_sequence.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -204,6 +206,9 @@

    Class Token_quote_sequence

    +
    +

    Token_quote_sequence class

    +
    @@ -233,7 +238,13 @@ - Located at libraries/tokens/Token_quote_sequence.php + Author: + SteveIreland
    + Since: + 3.1
    + Link: + github.com/jekkos/opensourcepos
    + Located at libraries/tokens/Token_quote_sequence.php
    @@ -241,38 +252,6 @@ - - - - - - @@ -327,6 +307,14 @@ +
    Methods summary
    - public - - - - -
    - # - __construct( ) - -
    - -
    - - -
    @@ -311,6 +290,7 @@
    Methods inherited from Token
    + __construct(), replace()
    + + + + +
    Properties inherited from Token
    + $CI +
    diff --git a/docs/class-Token_suspended_invoice_count.html b/docs/class-Token_suspended_invoice_count.html index 0505856d2..8d5a92cef 100644 --- a/docs/class-Token_suspended_invoice_count.html +++ b/docs/class-Token_suspended_invoice_count.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -204,6 +206,9 @@

    Class Token_suspended_invoice_count

    +
    +

    Token_suspended_invoice_count class

    +
    @@ -233,7 +238,13 @@ - Located at libraries/tokens/Token_suspended_invoice_count.php + Author: + SteveIreland
    + Since: + 3.1
    + Link: + github.com/jekkos/opensourcepos
    + Located at libraries/tokens/Token_suspended_invoice_count.php
    @@ -253,7 +264,7 @@
    # - __construct( ) + __construct( )
    @@ -285,7 +296,7 @@
    # - get_value( ) + get_value( )
    @@ -327,6 +338,14 @@ + + + + + +
    Properties inherited from Token
    + $CI +
    diff --git a/docs/class-Token_year_invoice_count.html b/docs/class-Token_year_invoice_count.html index 3268133f7..54b3d4a20 100644 --- a/docs/class-Token_year_invoice_count.html +++ b/docs/class-Token_year_invoice_count.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -204,6 +206,9 @@

    Class Token_year_invoice_count

    +
    +

    Token_year_invoice_count class

    +
    @@ -233,7 +238,13 @@ - Located at libraries/tokens/Token_year_invoice_count.php + Author: + SteveIreland
    + Since: + 3.1
    + Link: + github.com/jekkos/opensourcepos
    + Located at libraries/tokens/Token_year_invoice_count.php
    @@ -253,7 +264,7 @@
    # - __construct( ) + __construct( )
    @@ -285,7 +296,7 @@
    # - get_value( ) + get_value( )
    @@ -327,6 +338,14 @@ + + + + + +
    Properties inherited from Token
    + $CI +
    diff --git a/docs/class-Tracking_lib.html b/docs/class-Tracking_lib.html index a0766fc4a..4a7a1050c 100644 --- a/docs/class-Tracking_lib.html +++ b/docs/class-Tracking_lib.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -204,6 +206,11 @@

    Class Tracking_lib

    +
    +

    Tracking library

    + +

    Library with utilities to manage statistics

    +
    @@ -219,7 +226,13 @@ - Located at libraries/Tracking_lib.php + Author: + daN4cat (FrancescoUK)
    + Since: + 3.0
    + Link: + github.com/jekkos/opensourcepos
    + Located at libraries/Tracking_lib.php
    @@ -239,7 +252,7 @@
    # - __construct( ) + __construct( )
    @@ -269,7 +282,7 @@
    # - track_event( $category, $action, $label = NULL, $value = NULL ) + track_event( $category, $action, $label = NULL, $value = NULL )
    @@ -299,7 +312,7 @@
    # - track_page( $path, $title, $description = ' ' ) + track_page( $path, $title, $description = ' ' )
    diff --git a/docs/elementlist.js b/docs/elementlist.js index aac0520f1..7f665203b 100644 --- a/docs/elementlist.js +++ b/docs/elementlist.js @@ -1,3 +1,3 @@ var ApiGen = ApiGen || {}; -ApiGen.elements = [["c","Appconfig"],["c","Barcode_lib"],["c","Config"],["f","currency_side()"],["f","current_language()"],["f","current_language_code()"],["c","Customer"],["c","Customer_rewards"],["c","Customers"],["f","dateformat_bootstrap()"],["f","dateformat_momentjs()"],["f","db_log_queries()"],["c","Detailed_receivings"],["c","Detailed_sales"],["c","Dinner_table"],["c","Email_lib"],["c","emberlabs\\Barcode\\BarcodeBase"],["c","emberlabs\\Barcode\\Code128"],["c","emberlabs\\Barcode\\Code39"],["c","emberlabs\\Barcode\\Ean13"],["c","emberlabs\\Barcode\\Ean8"],["c","Employee"],["c","Employees"],["f","get_customer_data_row()"],["f","get_customer_manage_table_headers()"],["f","get_giftcard_data_row()"],["f","get_giftcards_manage_table_headers()"],["f","get_item_data_row()"],["f","get_item_kit_data_row()"],["f","get_item_kits_manage_table_headers()"],["f","get_items_manage_table_headers()"],["f","get_people_manage_table_headers()"],["f","get_person_data_row()"],["f","get_sale_data_last_row()"],["f","get_sale_data_row()"],["f","get_sales_manage_payments_summary()"],["f","get_sales_manage_table_headers()"],["f","get_supplier_data_row()"],["f","get_suppliers_manage_table_headers()"],["f","get_tax_data_row()"],["f","get_taxes_manage_table_headers()"],["c","Giftcard"],["c","Giftcards"],["c","Home"],["c","Inventory"],["c","Inventory_low"],["c","Inventory_summary"],["c","Item"],["c","Item_kit"],["c","Item_kit_items"],["c","Item_kits"],["c","Item_lib"],["c","Item_quantity"],["c","Item_taxes"],["c","Items"],["f","load_config()"],["f","load_language_files()"],["f","load_stats()"],["c","Login"],["c","Mailchimp_lib"],["c","MailchimpConnector"],["c","Messages"],["c","Module"],["c","MY_Lang"],["c","No_Access"],["f","parse_decimals()"],["f","pdf_create()"],["c","Person"],["c","Persons"],["f","quantity_decimals()"],["c","Receiving"],["c","Receiving_lib"],["c","Receivings"],["c","Report"],["c","Reports"],["c","Rewards"],["c","Rounding_code"],["c","Sale"],["c","Sale_lib"],["c","Sale_suspended"],["c","Sales"],["c","Secure_Controller"],["f","show_report()"],["f","show_report_if_allowed()"],["c","Sms_lib"],["c","Specific_customer"],["c","Specific_discount"],["c","Specific_employee"],["c","Stock_location"],["c","Summary_categories"],["c","Summary_customers"],["c","Summary_discounts"],["c","Summary_employees"],["c","Summary_items"],["c","Summary_payments"],["c","Summary_report"],["c","Summary_sales"],["c","Summary_suppliers"],["c","Summary_taxes"],["c","Supplier"],["c","Suppliers"],["c","Tax"],["c","Tax_lib"],["c","Taxes"],["f","to_currency()"],["f","to_currency_no_money()"],["f","to_decimals()"],["f","to_quantity_decimals()"],["f","to_tax_decimals()"],["c","Token"],["c","Token_customer"],["c","Token_invoice_count"],["c","Token_invoice_sequence"],["c","Token_lib"],["c","Token_quote_sequence"],["c","Token_suspended_invoice_count"],["c","Token_year_invoice_count"],["f","totals_decimals()"],["c","Tracking_lib"],["f","transform_headers()"],["f","transform_headers_readonly()"]]; +ApiGen.elements = [["c","Appconfig"],["c","Barcode_lib"],["c","Config"],["f","currency_side()"],["f","current_language()"],["f","current_language_code()"],["c","Customer"],["c","Customer_rewards"],["c","Customers"],["f","dateformat_bootstrap()"],["f","dateformat_momentjs()"],["f","db_log_queries()"],["c","Detailed_receivings"],["c","Detailed_sales"],["c","Dinner_table"],["c","Email_lib"],["c","emberlabs\\Barcode\\BarcodeBase"],["c","emberlabs\\Barcode\\Code128"],["c","emberlabs\\Barcode\\Code39"],["c","emberlabs\\Barcode\\Ean13"],["c","emberlabs\\Barcode\\Ean8"],["c","Employee"],["c","Employees"],["f","get_customer_data_row()"],["f","get_customer_manage_table_headers()"],["f","get_giftcard_data_row()"],["f","get_giftcards_manage_table_headers()"],["f","get_item_data_row()"],["f","get_item_kit_data_row()"],["f","get_item_kits_manage_table_headers()"],["f","get_items_manage_table_headers()"],["f","get_people_manage_table_headers()"],["f","get_person_data_row()"],["f","get_sale_data_last_row()"],["f","get_sale_data_row()"],["f","get_sales_manage_payments_summary()"],["f","get_sales_manage_table_headers()"],["f","get_supplier_data_row()"],["f","get_suppliers_manage_table_headers()"],["f","get_tax_data_row()"],["f","get_taxes_manage_table_headers()"],["c","Giftcard"],["c","Giftcards"],["c","Home"],["c","Inventory"],["c","Inventory_low"],["c","Inventory_summary"],["c","Item"],["c","Item_kit"],["c","Item_kit_items"],["c","Item_kits"],["c","Item_lib"],["c","Item_quantity"],["c","Item_taxes"],["c","Items"],["f","load_config()"],["f","load_language_files()"],["f","load_stats()"],["c","Login"],["c","Mailchimp_lib"],["c","MailchimpConnector"],["c","Messages"],["c","Migrate"],["c","Migration_Sales_Tax_Data"],["c","Module"],["c","MY_Lang"],["c","No_Access"],["f","parse_decimals()"],["f","pdf_create()"],["c","Person"],["c","Persons"],["f","quantity_decimals()"],["c","Receiving"],["c","Receiving_lib"],["c","Receivings"],["c","Report"],["c","Reports"],["c","Rewards"],["c","Rounding_code"],["c","Sale"],["c","Sale_lib"],["c","Sale_suspended"],["c","Sales"],["c","Secure_Controller"],["f","show_report()"],["f","show_report_if_allowed()"],["c","Sms_lib"],["c","Specific_customer"],["c","Specific_discount"],["c","Specific_employee"],["c","Stock_location"],["c","Summary_categories"],["c","Summary_customers"],["c","Summary_discounts"],["c","Summary_employees"],["c","Summary_items"],["c","Summary_payments"],["c","Summary_report"],["c","Summary_sales"],["c","Summary_suppliers"],["c","Summary_taxes"],["c","Supplier"],["c","Suppliers"],["c","Tax"],["c","Tax_lib"],["c","Taxes"],["f","to_currency()"],["f","to_currency_no_money()"],["f","to_decimals()"],["f","to_quantity_decimals()"],["f","to_tax_decimals()"],["c","Token"],["c","Token_customer"],["c","Token_invoice_count"],["c","Token_invoice_sequence"],["c","Token_lib"],["c","Token_quote_sequence"],["c","Token_suspended_invoice_count"],["c","Token_year_invoice_count"],["f","totals_decimals()"],["c","Tracking_lib"],["f","transform_headers()"],["f","transform_headers_readonly()"]]; diff --git a/docs/function-currency_side.html b/docs/function-currency_side.html index 9fd41eee2..182cce045 100644 --- a/docs/function-currency_side.html +++ b/docs/function-currency_side.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -226,6 +228,6 @@
    - + diff --git a/docs/function-current_language.html b/docs/function-current_language.html index f2bddfab2..9c4c326e0 100644 --- a/docs/function-current_language.html +++ b/docs/function-current_language.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -226,6 +228,6 @@ - + diff --git a/docs/function-current_language_code.html b/docs/function-current_language_code.html index 82f7c7c4e..abb4ec44d 100644 --- a/docs/function-current_language_code.html +++ b/docs/function-current_language_code.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -204,12 +206,15 @@

    Function current_language_code

    +
    +

    Currency locale helper

    +
    @@ -226,6 +231,6 @@ - + diff --git a/docs/function-dateformat_bootstrap.html b/docs/function-dateformat_bootstrap.html index d356222da..c1586b909 100644 --- a/docs/function-dateformat_bootstrap.html +++ b/docs/function-dateformat_bootstrap.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -234,6 +236,6 @@ - + diff --git a/docs/function-dateformat_momentjs.html b/docs/function-dateformat_momentjs.html index 86470e40b..874dd16cb 100644 --- a/docs/function-dateformat_momentjs.html +++ b/docs/function-dateformat_momentjs.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -234,6 +236,6 @@ - + diff --git a/docs/function-db_log_queries.html b/docs/function-db_log_queries.html index 48b92dbb5..10b1e384a 100644 --- a/docs/function-db_log_queries.html +++ b/docs/function-db_log_queries.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -226,6 +228,6 @@ - + diff --git a/docs/function-get_customer_data_row.html b/docs/function-get_customer_data_row.html index 4bd0274a8..19071cb71 100644 --- a/docs/function-get_customer_data_row.html +++ b/docs/function-get_customer_data_row.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -244,6 +246,6 @@ - + diff --git a/docs/function-get_customer_manage_table_headers.html b/docs/function-get_customer_manage_table_headers.html index c4c5b8d6f..8e1d58535 100644 --- a/docs/function-get_customer_manage_table_headers.html +++ b/docs/function-get_customer_manage_table_headers.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -226,6 +228,6 @@ - + diff --git a/docs/function-get_giftcard_data_row.html b/docs/function-get_giftcard_data_row.html index 61c9bc380..5a8ccae46 100644 --- a/docs/function-get_giftcard_data_row.html +++ b/docs/function-get_giftcard_data_row.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -239,6 +241,6 @@ - + diff --git a/docs/function-get_giftcards_manage_table_headers.html b/docs/function-get_giftcards_manage_table_headers.html index b8d93790d..5a6dc6804 100644 --- a/docs/function-get_giftcards_manage_table_headers.html +++ b/docs/function-get_giftcards_manage_table_headers.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -226,6 +228,6 @@ - + diff --git a/docs/function-get_item_data_row.html b/docs/function-get_item_data_row.html index 9bc3efc4c..d647ba4f1 100644 --- a/docs/function-get_item_data_row.html +++ b/docs/function-get_item_data_row.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -239,6 +241,6 @@ - + diff --git a/docs/function-get_item_kit_data_row.html b/docs/function-get_item_kit_data_row.html index 6d59924f4..287a71e59 100644 --- a/docs/function-get_item_kit_data_row.html +++ b/docs/function-get_item_kit_data_row.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -239,6 +241,6 @@ - + diff --git a/docs/function-get_item_kits_manage_table_headers.html b/docs/function-get_item_kits_manage_table_headers.html index fbbd6f15c..098e326e5 100644 --- a/docs/function-get_item_kits_manage_table_headers.html +++ b/docs/function-get_item_kits_manage_table_headers.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -226,6 +228,6 @@ - + diff --git a/docs/function-get_items_manage_table_headers.html b/docs/function-get_items_manage_table_headers.html index c67e0409d..398c85e75 100644 --- a/docs/function-get_items_manage_table_headers.html +++ b/docs/function-get_items_manage_table_headers.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -226,6 +228,6 @@ - + diff --git a/docs/function-get_people_manage_table_headers.html b/docs/function-get_people_manage_table_headers.html index e6864b3e8..382481bfb 100644 --- a/docs/function-get_people_manage_table_headers.html +++ b/docs/function-get_people_manage_table_headers.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -226,6 +228,6 @@ - + diff --git a/docs/function-get_person_data_row.html b/docs/function-get_person_data_row.html index 317d74c7d..6248e0d8d 100644 --- a/docs/function-get_person_data_row.html +++ b/docs/function-get_person_data_row.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -239,6 +241,6 @@ - + diff --git a/docs/function-get_sale_data_last_row.html b/docs/function-get_sale_data_last_row.html index 24488fbeb..f36b16ca9 100644 --- a/docs/function-get_sale_data_last_row.html +++ b/docs/function-get_sale_data_last_row.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -239,6 +241,6 @@ - + diff --git a/docs/function-get_sale_data_row.html b/docs/function-get_sale_data_row.html index 8c6981b74..94903d8bc 100644 --- a/docs/function-get_sale_data_row.html +++ b/docs/function-get_sale_data_row.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -239,6 +241,6 @@ - + diff --git a/docs/function-get_sales_manage_payments_summary.html b/docs/function-get_sales_manage_payments_summary.html index 6a08fa3b3..455e716c8 100644 --- a/docs/function-get_sales_manage_payments_summary.html +++ b/docs/function-get_sales_manage_payments_summary.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -244,6 +246,6 @@ - + diff --git a/docs/function-get_sales_manage_table_headers.html b/docs/function-get_sales_manage_table_headers.html index 54e1160e5..784f71a39 100644 --- a/docs/function-get_sales_manage_table_headers.html +++ b/docs/function-get_sales_manage_table_headers.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -226,6 +228,6 @@ - + diff --git a/docs/function-get_supplier_data_row.html b/docs/function-get_supplier_data_row.html index cefaef226..cdcd0adfb 100644 --- a/docs/function-get_supplier_data_row.html +++ b/docs/function-get_supplier_data_row.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -239,6 +241,6 @@ - + diff --git a/docs/function-get_suppliers_manage_table_headers.html b/docs/function-get_suppliers_manage_table_headers.html index 10477435b..aba6bb0b9 100644 --- a/docs/function-get_suppliers_manage_table_headers.html +++ b/docs/function-get_suppliers_manage_table_headers.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -226,6 +228,6 @@ - + diff --git a/docs/function-get_tax_data_row.html b/docs/function-get_tax_data_row.html index 2523ad317..c5615b2ce 100644 --- a/docs/function-get_tax_data_row.html +++ b/docs/function-get_tax_data_row.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -239,6 +241,6 @@ - + diff --git a/docs/function-get_taxes_manage_table_headers.html b/docs/function-get_taxes_manage_table_headers.html index 56e315ed0..8af64be8d 100644 --- a/docs/function-get_taxes_manage_table_headers.html +++ b/docs/function-get_taxes_manage_table_headers.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -226,6 +228,6 @@ - + diff --git a/docs/function-load_config.html b/docs/function-load_config.html index 524459e62..0b8b1ef30 100644 --- a/docs/function-load_config.html +++ b/docs/function-load_config.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -226,6 +228,6 @@ - + diff --git a/docs/function-load_language_files.html b/docs/function-load_language_files.html index 3a33b7961..9eb72cb03 100644 --- a/docs/function-load_language_files.html +++ b/docs/function-load_language_files.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -239,6 +241,6 @@ - + diff --git a/docs/function-load_stats.html b/docs/function-load_stats.html index 9c51848f0..c0f83f25e 100644 --- a/docs/function-load_stats.html +++ b/docs/function-load_stats.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -226,6 +228,6 @@ - + diff --git a/docs/function-parse_decimals.html b/docs/function-parse_decimals.html index 789353e31..d1bac804a 100644 --- a/docs/function-parse_decimals.html +++ b/docs/function-parse_decimals.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -234,6 +236,6 @@ - + diff --git a/docs/function-pdf_create.html b/docs/function-pdf_create.html index c44d4526a..06b71aa7f 100644 --- a/docs/function-pdf_create.html +++ b/docs/function-pdf_create.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -239,6 +241,6 @@ - + diff --git a/docs/function-quantity_decimals.html b/docs/function-quantity_decimals.html index fc4a3d74b..fc0716d26 100644 --- a/docs/function-quantity_decimals.html +++ b/docs/function-quantity_decimals.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -226,6 +228,6 @@ - + diff --git a/docs/function-show_report.html b/docs/function-show_report.html index f4143ac1d..60f816dd1 100644 --- a/docs/function-show_report.html +++ b/docs/function-show_report.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -244,6 +246,6 @@ - + diff --git a/docs/function-show_report_if_allowed.html b/docs/function-show_report_if_allowed.html index 6f9dc64e6..41538bbf3 100644 --- a/docs/function-show_report_if_allowed.html +++ b/docs/function-show_report_if_allowed.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -249,6 +251,6 @@ - + diff --git a/docs/function-to_currency.html b/docs/function-to_currency.html index b5551584f..1f192c20f 100644 --- a/docs/function-to_currency.html +++ b/docs/function-to_currency.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -234,6 +236,6 @@ - + diff --git a/docs/function-to_currency_no_money.html b/docs/function-to_currency_no_money.html index c2b6ecdb2..e1724b861 100644 --- a/docs/function-to_currency_no_money.html +++ b/docs/function-to_currency_no_money.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -234,6 +236,6 @@ - + diff --git a/docs/function-to_decimals.html b/docs/function-to_decimals.html index 775933854..ef8af27ec 100644 --- a/docs/function-to_decimals.html +++ b/docs/function-to_decimals.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -244,6 +246,6 @@ - + diff --git a/docs/function-to_quantity_decimals.html b/docs/function-to_quantity_decimals.html index e606a1840..6503fe8d9 100644 --- a/docs/function-to_quantity_decimals.html +++ b/docs/function-to_quantity_decimals.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -234,6 +236,6 @@ - + diff --git a/docs/function-to_tax_decimals.html b/docs/function-to_tax_decimals.html index e52d4538e..2e180c4f0 100644 --- a/docs/function-to_tax_decimals.html +++ b/docs/function-to_tax_decimals.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -234,6 +236,6 @@ - + diff --git a/docs/function-totals_decimals.html b/docs/function-totals_decimals.html index 3f088b529..b94507677 100644 --- a/docs/function-totals_decimals.html +++ b/docs/function-totals_decimals.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -226,6 +228,6 @@ - + diff --git a/docs/function-transform_headers.html b/docs/function-transform_headers.html index 47ae6d731..058678f91 100644 --- a/docs/function-transform_headers.html +++ b/docs/function-transform_headers.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -244,6 +246,6 @@ - + diff --git a/docs/function-transform_headers_readonly.html b/docs/function-transform_headers_readonly.html index 254ea1871..f4b49054f 100644 --- a/docs/function-transform_headers_readonly.html +++ b/docs/function-transform_headers_readonly.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -234,6 +236,6 @@ - + diff --git a/docs/index.html b/docs/index.html index 6227b3f47..b5d8ac3aa 100644 --- a/docs/index.html +++ b/docs/index.html @@ -78,6 +78,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -228,6 +230,6 @@ - + diff --git a/docs/namespace-None.html b/docs/namespace-None.html index 6db154951..36f499026 100644 --- a/docs/namespace-None.html +++ b/docs/namespace-None.html @@ -74,6 +74,8 @@
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • +
  • Migrate
  • +
  • Migration_Sales_Tax_Data
  • Module
  • MY_Lang
  • No_Access
  • @@ -208,11 +210,11 @@
    Classes summary
    AppconfigAppconfig class
    Barcode_libBarcode library
    Config
    Customer_rewardsCustomer_rewards class
    Customers
    Dinner_tableDinner_table class
    Email_libEmail library
    Employee
    GiftcardGiftcard class
    Giftcards
    InventoryInventory class
    Inventory_low
    ItemItem class
    Item_kitItem_kit class
    Item_kit_itemsItem_kit_items class
    Item_kits
    Item_libItem library
    Item_quantityItem_quantity class
    Item_taxesItem_taxes class
    Items
    ModuleMigrate
    Migration_Sales_Tax_Data
    ModuleModule class
    MY_Lang
    PersonBase class for People classes.Base class for People classes
    Persons
    ReceivingReceiving class
    Receiving_libReceiving library
    Receivings
    RewardsRewards class
    Rounding_codeRounding_code class
    SaleSale class
    Sale_libSale library
    Sale_suspendedSale_suspended class
    Sales
    Sms_libSMS library
    Specific_customer
    Stock_locationStock_location class
    Summary_categories
    TaxTax class
    Tax_libTax library
    Taxes
    TokenToken class
    Token_customerToken_customer class
    Token_invoice_countToken_invoice_count class
    Token_invoice_sequenceToken_invoice_sequence class
    Token_libToken library
    Token_quote_sequenceToken_quote_sequence class
    Token_suspended_invoice_countToken_suspended_invoice_count class
    Token_year_invoice_countToken_year_invoice_count class
    Tracking_libTracking library
    @@ -528,7 +538,7 @@
    current_language_codeCurrency locale helper
    dateformat_bootstrap