Overview

Namespaces

  • emberlabs
    • Barcode
  • None

Classes

  • Appconfig
  • Barcode_lib
  • Config
  • Customer
  • Customer_rewards
  • Customers
  • Detailed_receivings
  • Detailed_sales
  • Dinner_table
  • Email_lib
  • emberlabs\Barcode\BarcodeBase
  • emberlabs\Barcode\Code128
  • emberlabs\Barcode\Code39
  • emberlabs\Barcode\Ean13
  • emberlabs\Barcode\Ean8
  • Employee
  • Employees
  • Giftcard
  • Giftcards
  • Home
  • Inventory
  • Inventory_low
  • Inventory_summary
  • Item
  • Item_kit
  • Item_kit_items
  • Item_kits
  • Item_lib
  • Item_quantity
  • Item_taxes
  • Items
  • Login
  • Mailchimp_lib
  • MailchimpConnector
  • Messages
  • Module
  • MY_Lang
  • No_Access
  • Person
  • Persons
  • Receiving
  • Receiving_lib
  • Receivings
  • Report
  • Reports
  • Rewards
  • Rounding_code
  • Sale
  • Sale_lib
  • Sale_suspended
  • Sales
  • Secure_Controller
  • Sms_lib
  • Specific_customer
  • Specific_discount
  • Specific_employee
  • Stock_location
  • Summary_categories
  • Summary_customers
  • Summary_discounts
  • Summary_employees
  • Summary_items
  • Summary_payments
  • Summary_report
  • Summary_sales
  • Summary_suppliers
  • Summary_taxes
  • Supplier
  • Suppliers
  • Tax
  • Tax_lib
  • Taxes
  • Token
  • Token_customer
  • Token_invoice_count
  • Token_invoice_sequence
  • Token_lib
  • Token_quote_sequence
  • Token_suspended_invoice_count
  • Token_year_invoice_count
  • Tracking_lib

Functions

  • currency_side
  • current_language
  • current_language_code
  • dateformat_bootstrap
  • dateformat_momentjs
  • db_log_queries
  • get_customer_data_row
  • get_customer_manage_table_headers
  • get_giftcard_data_row
  • get_giftcards_manage_table_headers
  • get_item_data_row
  • get_item_kit_data_row
  • get_item_kits_manage_table_headers
  • get_items_manage_table_headers
  • get_people_manage_table_headers
  • get_person_data_row
  • get_sale_data_last_row
  • get_sale_data_row
  • get_sales_manage_payments_summary
  • get_sales_manage_table_headers
  • get_supplier_data_row
  • get_suppliers_manage_table_headers
  • get_tax_data_row
  • get_taxes_manage_table_headers
  • load_config
  • load_language_files
  • load_stats
  • parse_decimals
  • pdf_create
  • quantity_decimals
  • show_report
  • show_report_if_allowed
  • to_currency
  • to_currency_no_money
  • to_decimals
  • to_quantity_decimals
  • to_tax_decimals
  • totals_decimals
  • transform_headers
  • transform_headers_readonly
  • Overview
  • Namespace
  • Class
  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

function get_sales_manage_table_headers()
{
    $CI =& get_instance();

    $headers = array(
        array('sale_id' => $CI->lang->line('common_id')),
        array('sale_time' => $CI->lang->line('sales_sale_time')),
        array('customer_name' => $CI->lang->line('customers_customer')),
        array('amount_due' => $CI->lang->line('sales_amount_due')),
        array('amount_tendered' => $CI->lang->line('sales_amount_tendered')),
        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'));
        $headers[] = array('invoice' => '&nbsp', 'sortable' => FALSE);
    }

    return transform_headers(array_merge($headers, array(array('receipt' => '&nbsp', 'sortable' => FALSE))));
}

/*
 Gets the html data rows for the sales.
 */
function get_sale_data_last_row($sales, $controller)
{
    $CI =& get_instance();
    $sum_amount_due = 0;
    $sum_amount_tendered = 0;
    $sum_change_due = 0;

    foreach($sales->result() as $key=>$sale)
    {
        $sum_amount_due += $sale->amount_due;
        $sum_amount_tendered += $sale->amount_tendered;
        $sum_change_due += $sale->change_due;
    }

    return array(
        'sale_id' => '-',
        'sale_time' => '<b>'.$CI->lang->line('sales_total').'</b>',
        'amount_due' => '<b>'.to_currency($sum_amount_due).'</b>',
        'amount_tendered' => '<b>'. to_currency($sum_amount_tendered).'</b>',
        'change_due' => '<b>'.to_currency($sum_change_due).'</b>'
    );
}

function get_sale_data_row($sale, $controller)
{
    $CI =& get_instance();
    $controller_name = $CI->uri->segment(1);

    $row = array (
        'sale_id' => $sale->sale_id,
        'sale_time' => date( $CI->config->item('dateformat') . ' ' . $CI->config->item('timeformat'), strtotime($sale->sale_time) ),
        'customer_name' => $sale->customer_name,
        'amount_due' => to_currency($sale->amount_due),
        'amount_tendered' => to_currency($sale->amount_tendered),
        'change_due' => to_currency($sale->change_due),
        'payment_type' => $sale->payment_type
    );

    if($CI->config->item('invoice_enable'))
    {
        $row['invoice_number'] = $sale->invoice_number;
        $row['invoice'] = empty($sale->invoice_number) ? '' : anchor($controller_name."/invoice/$sale->sale_id", '<span class="glyphicon glyphicon-list-alt"></span>',
            array('title'=>$CI->lang->line('sales_show_invoice'))
        );
    }

    $row['receipt'] = anchor($controller_name."/receipt/$sale->sale_id", '<span class="glyphicon glyphicon-usd"></span>',
        array('title' => $CI->lang->line('sales_show_receipt'))
    );
    $row['edit'] = anchor($controller_name."/edit/$sale->sale_id", '<span class="glyphicon glyphicon-edit"></span>',
        array('class' => 'modal-dlg print_hide', 'data-btn-delete' => $CI->lang->line('common_delete'), 'data-btn-submit' => $CI->lang->line('common_submit'), 'title' => $CI->lang->line($controller_name.'_update'))
    );

    return $row;
}

/*
Get the sales payments summary
*/
function get_sales_manage_payments_summary($payments, $sales, $controller)
{
    $CI =& get_instance();
    $table = '<div id="report_summary">';

    foreach($payments as $key=>$payment)
    {
        $amount = $payment['payment_amount'];

        // WARNING: the strong assumption here is that if a change is due it was a cash transaction always
        // therefore we remove from the total cash amount any change due
        if( $payment['payment_type'] == $CI->lang->line('sales_cash') )
        {
            foreach($sales->result_array() as $key=>$sale)
            {
                $amount -= $sale['change_due'];
            }
        }
        $table .= '<div class="summary_row">' . $payment['payment_type'] . ': ' . to_currency( $amount ) . '</div>';
    }
    $table .= '</div>';

    return $table;
}

function transform_headers_readonly($array)
{
    $result = array();
    foreach($array as $key => $value)
    {
        $result[] = array('field' => $key, 'title' => $value, 'sortable' => $value != '', 'switchable' => !preg_match('(^$|&nbsp)', $value));
    }

    return json_encode($result);
}

function transform_headers($array, $readonly = FALSE, $editable = TRUE)
{
    $result = array();

    if (!$readonly)
    {
        $array = array_merge(array(array('checkbox' => 'select', 'sortable' => FALSE)), $array);
    }

    if ($editable)
    {
        $array[] = array('edit' => '');
    }

    foreach($array as $element)
    {
        reset($element);
        $result[] = array('field' => key($element),
            'title' => current($element),
            'switchable' => isset($element['switchable']) ?
                $element['switchable'] : !preg_match('(^$|&nbsp)', current($element)),
            'sortable' => isset($element['sortable']) ?
                $element['sortable'] : current($element) != '',
            'checkbox' => isset($element['checkbox']) ?
                $element['checkbox'] : FALSE,
            'class' => isset($element['checkbox']) || preg_match('(^$|&nbsp)', current($element)) ?
                'print_hide' : '',
            'sorter' => isset($element['sorter']) ?
                $element ['sorter'] : '');
    }
    return json_encode($result);
}

function get_people_manage_table_headers()
{
    $CI =& get_instance();

    $headers = array(
        array('people.person_id' => $CI->lang->line('common_id')),
        array('last_name' => $CI->lang->line('common_last_name')),
        array('first_name' => $CI->lang->line('common_first_name')),
        array('email' => $CI->lang->line('common_email')),
        array('phone_number' => $CI->lang->line('common_phone_number'))
    );

    if($CI->Employee->has_grant('messages', $CI->session->userdata('person_id')))
    {
        $headers[] = array('messages' => '', 'sortable' => FALSE);
    }
    
    return transform_headers($headers);
}

function get_person_data_row($person, $controller)
{
    $CI =& get_instance();
    $controller_name = strtolower(get_class($CI));

    return array (
        'people.person_id' => $person->person_id,
        'last_name' => $person->last_name,
        '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>', 
            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'))
    ));
}

function get_customer_manage_table_headers()
{
    $CI =& get_instance();

    $headers = array(
        array('people.person_id' => $CI->lang->line('common_id')),
        array('last_name' => $CI->lang->line('common_last_name')),
        array('first_name' => $CI->lang->line('common_first_name')),
        array('email' => $CI->lang->line('common_email')),
        array('phone_number' => $CI->lang->line('common_phone_number')),
        array('total' => $CI->lang->line('common_total_spent'), 'sortable' => FALSE)
    );

    if($CI->Employee->has_grant('messages', $CI->session->userdata('person_id')))
    {
        $headers[] = array('messages' => '', 'sortable' => FALSE);
    }
    
    return transform_headers($headers);
}

function get_customer_data_row($person, $stats, $controller)
{
    $CI =& get_instance();
    $controller_name = strtolower(get_class($CI));

    return array (
        'people.person_id' => $person->person_id,
        'last_name' => $person->last_name,
        'first_name' => $person->first_name,
        '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>', 
            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'))
    ));
}

function get_suppliers_manage_table_headers()
{
    $CI =& get_instance();

    $headers = array(
        array('people.person_id' => $CI->lang->line('common_id')),
        array('company_name' => $CI->lang->line('suppliers_company_name')),
        array('agency_name' => $CI->lang->line('suppliers_agency_name')),
        array('last_name' => $CI->lang->line('common_last_name')),
        array('first_name' => $CI->lang->line('common_first_name')),
        array('email' => $CI->lang->line('common_email')),
        array('phone_number' => $CI->lang->line('common_phone_number'))
    );

    if($CI->Employee->has_grant('messages', $CI->session->userdata('person_id')))
    {
        $headers[] = array('messages' => '');
    }

    return transform_headers($headers);
}

function get_supplier_data_row($supplier, $controller)
{
    $CI =& get_instance();
    $controller_name = strtolower(get_class($CI));

    return array (
        'people.person_id' => $supplier->person_id,
        'company_name' => $supplier->company_name,
        'agency_name' => $supplier->agency_name,
        'last_name' => $supplier->last_name,
        '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>', 
            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')))
        );
}

function get_items_manage_table_headers()
{
    $CI =& get_instance();

    $headers = array(
        array('items.item_id' => $CI->lang->line('common_id')),
        array('item_number' => $CI->lang->line('items_item_number')),
        array('name' => $CI->lang->line('items_name')),
        array('category' => $CI->lang->line('items_category')),
        array('company_name' => $CI->lang->line('suppliers_company_name')),
        array('cost_price' => $CI->lang->line('items_cost_price')),
        array('unit_price' => $CI->lang->line('items_unit_price')),
        array('quantity' => $CI->lang->line('items_quantity')),
        array('tax_percents' => $CI->lang->line('items_tax_percents'), 'sortable' => FALSE),
        array('item_pic' => $CI->lang->line('items_image'), 'sortable' => FALSE),
        array('inventory' => ''),
        array('stock' => '')
    );

    return transform_headers($headers);
}

function get_item_data_row($item, $controller)
{
    $CI =& get_instance();
    $item_tax_info = $CI->Item_taxes->get_info($item->item_id);
    $tax_percents = '';
    foreach($item_tax_info as $tax_info)
    {
        $tax_percents .= to_tax_decimals($tax_info['percent']) . '%, ';
    }
    // remove ', ' from last item
    $tax_percents = substr($tax_percents, 0, -2);
    $controller_name = strtolower(get_class($CI));

    $image = NULL;
    if ($item->pic_filename != '')
    {
        $ext = pathinfo($item->pic_filename, PATHINFO_EXTENSION);
        if($ext == '')
        {
            // legacy
            $images = glob('./uploads/item_pics/' . $item->pic_filename . '.*');
        }
        else
        {
            // preferred
            $images = glob('./uploads/item_pics/' . $item->pic_filename);
        }

        if (sizeof($images) > 0)
        {
            $image .= '<a class="rollover" href="'. base_url($images[0]) .'"><img src="'.site_url('items/pic_thumb/' . pathinfo($images[0], PATHINFO_BASENAME)) . '"></a>';
        }
    }

    return array (
        'items.item_id' => $item->item_id,
        'item_number' => $item->item_number,
        'name' => $item->name,
        'category' => $item->category,
        'company_name' => $item->company_name,
        'cost_price' => to_currency($item->cost_price),
        'unit_price' => to_currency($item->unit_price),
        'quantity' => to_quantity_decimals($item->quantity),
        'tax_percents' => !$tax_percents ? '-' : $tax_percents,
        'item_pic' => $image,
        'inventory' => anchor($controller_name."/inventory/$item->item_id", '<span class="glyphicon glyphicon-pushpin"></span>',
            array('class' => 'modal-dlg', 'data-btn-submit' => $CI->lang->line('common_submit'), 'title' => $CI->lang->line($controller_name.'_count'))
        ),
        'stock' => anchor($controller_name."/count_details/$item->item_id", '<span class="glyphicon glyphicon-list-alt"></span>',
            array('class' => 'modal-dlg', 'title' => $CI->lang->line($controller_name.'_details_count'))
        ),
        'edit' => anchor($controller_name."/view/$item->item_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'))
        ));
}

function get_giftcards_manage_table_headers()
{
    $CI =& get_instance();

    $headers = array(
        array('giftcard_id' => $CI->lang->line('common_id')),
        array('last_name' => $CI->lang->line('common_last_name')),
        array('first_name' => $CI->lang->line('common_first_name')),
        array('giftcard_number' => $CI->lang->line('giftcards_giftcard_number')),
        array('value' => $CI->lang->line('giftcards_card_value'))
    );

    return transform_headers($headers);
}

function get_taxes_manage_table_headers()
{
    $CI =& get_instance();

    $headers = array(
        array('tax_code' => $CI->lang->line('taxes_tax_code')),
        array('tax_code_name' => $CI->lang->line('taxes_tax_code_name')),
        array('tax_code_type_name' => $CI->lang->line('taxes_tax_code_type')),
        array('tax_rate' => $CI->lang->line('taxes_tax_rate')),
        array('rounding_code_name' => $CI->lang->line('taxes_rounding_code')),
        array('city' => $CI->lang->line('common_city')),
        array('state' => $CI->lang->line('common_state'))
    );

    return transform_headers($headers);
}

function get_giftcard_data_row($giftcard, $controller)
{
    $CI =& get_instance();
    $controller_name=strtolower(get_class($CI));

    return array (
        'giftcard_id' => $giftcard->giftcard_id,
        'last_name' => $giftcard->last_name,
        'first_name' => $giftcard->first_name,
        'giftcard_number' => $giftcard->giftcard_number,
        'value' => to_currency($giftcard->value),
        'edit' => anchor($controller_name."/view/$giftcard->giftcard_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'))
        ));
}

function get_tax_data_row($tax_code_row, $controller)
{
    $CI =& get_instance();
    $controller_name=strtolower(get_class($CI));

    return array (
        'tax_code' => $tax_code_row->tax_code,
        'tax_code_name' => $tax_code_row->tax_code_name,
        'tax_code_type' => $tax_code_row->tax_code_type,
        'tax_rate' => $tax_code_row->tax_rate,
        'rounding_code' =>$tax_code_row->rounding_code,
        'tax_code_type_name' => $CI->Tax->get_tax_code_type_name($tax_code_row->tax_code_type),
        'rounding_code_name' => $CI->get_rounding_code_name($tax_code_row->rounding_code),
        'city' => $tax_code_row->city,
        'state' => $tax_code_row->state,
        'edit' => anchor($controller_name."/view/$tax_code_row->tax_code", '<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'))
        ));
}

function get_item_kits_manage_table_headers()
{
    $CI =& get_instance();

    $headers = array(
        array('item_kit_id' => $CI->lang->line('item_kits_kit')),
        array('name' => $CI->lang->line('item_kits_name')),
        array('description' => $CI->lang->line('item_kits_description')),
        array('cost_price' => $CI->lang->line('items_cost_price'), 'sortable' => FALSE),
        array('unit_price' => $CI->lang->line('items_unit_price'), 'sortable' => FALSE)
    );

    return transform_headers($headers);
}

function get_item_kit_data_row($item_kit, $controller)
{
    $CI =& get_instance();
    $controller_name = strtolower(get_class($CI));

    return array (
        'item_kit_id' => $item_kit->item_kit_id,
        'name' => $item_kit->name,
        'description' => $item_kit->description,
        'cost_price' => to_currency($item_kit->total_cost_price),
        'unit_price' => to_currency($item_kit->total_unit_price),
        'edit' => anchor($controller_name."/view/$item_kit->item_kit_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'))
        ));
}

?>
API documentation generated by ApiGen