';
$headers = array(' ',
$CI->lang->line('sales_receipt_number'),
$CI->lang->line('sales_sale_time'),
$CI->lang->line('customers_customer'),
$CI->lang->line('sales_amount_tendered'),
$CI->lang->line('sales_amount_due'),
$CI->lang->line('sales_change_due'),
$CI->lang->line('sales_payment'),
$CI->lang->line('sales_invoice_number'),
' ');
$table.='';
foreach($headers as $header)
{
$table.="$header ";
}
$table.='
';
$table.=get_sales_manage_table_data_rows($sales, $controller);
$table.=' ';
return $table;
}
/*
Gets the html data rows for the sales.
*/
function get_sales_manage_table_data_rows($sales, $controller)
{
$CI =& get_instance();
$table_data_rows = '';
$sum_amount_tendered = 0;
$sum_amount_due = 0;
$sum_change_due = 0;
foreach($sales as $key=>$sale)
{
$table_data_rows .= get_sales_manage_sale_data_row($sale, $controller);
$sum_amount_tendered += $sale['amount_tendered'];
$sum_amount_due += $sale['amount_due'];
$sum_change_due += $sale['change_due'];
}
if($table_data_rows == '')
{
$table_data_rows .= "".$CI->lang->line('sales_no_sales_to_display')."
";
}
else
{
$table_data_rows .= " ".$CI->lang->line('sales_total')." ".to_currency($sum_amount_tendered)." ".to_currency($sum_amount_due)." ".to_currency($sum_change_due)." ";
}
return $table_data_rows;
}
function get_sales_manage_sale_data_row($sale, $controller)
{
$CI =& get_instance();
$controller_name = $CI->uri->segment(1);
$table_data_row='';
$table_data_row.=' ';
$table_data_row.=''.'POS ' . $sale['sale_id'] . ' ';
$table_data_row.=''.date( $CI->config->item('dateformat') . ' ' . $CI->config->item('timeformat'), strtotime($sale['sale_time']) ).' ';
$table_data_row.=''.character_limiter( $sale['customer_name'], 25).' ';
$table_data_row.=''.to_currency( $sale['amount_tendered'] ).' ';
$table_data_row.=''.to_currency( $sale['amount_due'] ).' ';
$table_data_row.=''.to_currency( $sale['change_due'] ).' ';
$table_data_row.=''.$sale['payment_type'].' ';
$table_data_row.=''.$sale['invoice_number'].' ';
$table_data_row.='';
$table_data_row.=anchor($controller_name."/edit/" . $sale['sale_id'], $CI->lang->line('common_edit'),array('class'=>"modal-dlg modal-btn-delete modal-btn-submit",'title'=>$CI->lang->line($controller_name.'_update')));
$table_data_row.=' ';
$table_data_row.='' . $CI->lang->line('sales_show_receipt') . ' ';
$table_data_row.=' ';
$table_data_row.='' . $CI->lang->line('sales_show_invoice') . ' ';
$table_data_row.=' ';
$table_data_row.=' ';
return $table_data_row;
}
/*
Get the sales payments summary
*/
function get_sales_manage_payments_summary($payments, $sales, $controller)
{
$CI =& get_instance();
$table='';
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 as $key=>$sale)
{
$amount -= $sale['change_due'];
}
}
$table.='
'.$payment['payment_type'].': '.to_currency( $amount ) . '
';
}
$table.='
';
return $table;
}
/*
Gets the html table to manage people.
*/
function get_people_manage_table($people,$controller)
{
$CI =& get_instance();
$table='';
return $table;
}
/*
Gets the html data rows for the people.
*/
function get_people_manage_table_data_rows($people,$controller)
{
$CI =& get_instance();
$table_data_rows='';
foreach($people->result() as $person)
{
$table_data_rows.=get_person_data_row($person,$controller);
}
if($people->num_rows()==0)
{
$table_data_rows.="".$CI->lang->line('common_no_persons_to_display')."
";
}
return $table_data_rows;
}
function get_person_data_row($person,$controller)
{
$CI =& get_instance();
$controller_name=strtolower(get_class($CI));
$table_data_row='';
$table_data_row.=" ";
$table_data_row.=''.character_limiter($person->last_name,13).' ';
$table_data_row.=''.character_limiter($person->first_name,13).' ';
$table_data_row.=''.mailto($person->email,character_limiter($person->email,22)).' ';
$table_data_row.=''.character_limiter($person->phone_number,13).' ';
$table_data_row.=''.anchor($controller_name."/view/$person->person_id", $CI->lang->line('common_edit'), array('class'=>"modal-dlg modal-btn-submit", 'title'=>$CI->lang->line($controller_name.'_update'))).' ';
$table_data_row.=' ';
return $table_data_row;
}
function get_detailed_data_row($row, $controller)
{
$table_data_row='';
$table_data_row.='+ ';
foreach($row as $cell)
{
$table_data_row.='';
$table_data_row.=$cell;
$table_data_row.=' ';
}
$table_data_row.=' ';
return $table_data_row;
}
/*
Gets the html table to manage suppliers.
*/
function get_supplier_manage_table($suppliers,$controller)
{
$CI =& get_instance();
$table='';
return $table;
}
/*
Gets the html data rows for the supplier.
*/
function get_supplier_manage_table_data_rows($suppliers,$controller)
{
$CI =& get_instance();
$table_data_rows='';
foreach($suppliers->result() as $supplier)
{
$table_data_rows.=get_supplier_data_row($supplier,$controller);
}
if($suppliers->num_rows()==0)
{
$table_data_rows.="".$CI->lang->line('common_no_persons_to_display')."
";
}
return $table_data_rows;
}
function get_supplier_data_row($supplier,$controller)
{
$CI =& get_instance();
$controller_name=strtolower(get_class($CI));
$table_data_row='';
$table_data_row.=" ";
$table_data_row.=''.character_limiter($supplier->company_name,13).' ';
$table_data_row.=''.character_limiter($supplier->agency_name,13).' ';
$table_data_row.=''.character_limiter($supplier->last_name,13).' ';
$table_data_row.=''.character_limiter($supplier->first_name,13).' ';
$table_data_row.=''.mailto($supplier->email,character_limiter($supplier->email,22)).' ';
$table_data_row.=''.character_limiter($supplier->phone_number,13).' ';
$table_data_row.=''.character_limiter($supplier->person_id,5).' ';
$table_data_row.=''.anchor($controller_name."/view/$supplier->person_id", $CI->lang->line('common_edit'),array('class'=>"modal-dlg modal-btn-submit",'title'=>$CI->lang->line($controller_name.'_update'))).' ';
$table_data_row.=' ';
return $table_data_row;
}
/*
Gets the html table to manage items.
*/
function get_items_manage_table($items,$controller)
{
$CI =& get_instance();
$table='';
$headers = array(' ',
$CI->lang->line('items_item_number'),
$CI->lang->line('items_name'),
$CI->lang->line('items_category'),
$CI->lang->line('suppliers_company_name'),
$CI->lang->line('items_cost_price'),
$CI->lang->line('items_unit_price'),
$CI->lang->line('items_quantity'),
$CI->lang->line('items_tax_percents'),
' ',
' ',
' '
);
$table.='';
foreach($headers as $header)
{
$table.="$header ";
}
$table.=' ';
$table.=get_items_manage_table_data_rows($items,$controller);
$table.='
';
return $table;
}
/*
Gets the html data rows for the items.
*/
function get_items_manage_table_data_rows($items,$controller)
{
$CI =& get_instance();
$table_data_rows='';
foreach($items->result() as $item)
{
$table_data_rows.=get_item_data_row($item,$controller);
}
if($items->num_rows()==0)
{
$table_data_rows.="".$CI->lang->line('items_no_items_to_display')."
";
}
return $table_data_rows;
}
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.=$tax_info['percent']. '%, ';
}
$tax_percents=substr($tax_percents, 0, -2);
$controller_name=strtolower(get_class($CI));
$item_quantity='';
$table_data_row='';
$table_data_row.=" ";
$table_data_row.=''.$item->item_number.' ';
$table_data_row.=''.$item->name.' ';
$table_data_row.=''.$item->category.' ';
$table_data_row.=''.$item->company_name.' ';
$table_data_row.=''.to_currency($item->cost_price).' ';
$table_data_row.=''.to_currency($item->unit_price).' ';
$table_data_row.=''.$item->quantity.' ';
$table_data_row.=''.$tax_percents.' ';
$image = '';
if (!empty($item->pic_id))
{
$images = glob ("uploads/item_pics/" . $item->pic_id . ".*");
if (sizeof($images) > 0)
{
$image.=' ';
}
}
$table_data_row.='' . $image . ' ';
$table_data_row.=''.anchor($controller_name."/view/$item->item_id", $CI->lang->line('common_edit'),array('class'=>"modal-dlg modal-btn-new modal-btn-submit",'title'=>$CI->lang->line($controller_name.'_update'))).' ';
$table_data_row.=''.anchor($controller_name."/inventory/$item->item_id", $CI->lang->line('common_inv'),array('class'=>"modal-dlg modal-btn-submit",'title'=>$CI->lang->line($controller_name.'_count')))./*' ';//inventory count
$table_data_row.=''*/' '.anchor($controller_name."/count_details/$item->item_id", $CI->lang->line('common_det'),array('class'=>"modal-dlg",'title'=>$CI->lang->line($controller_name.'_details_count'))).' ';//inventory details
$table_data_row.=' ';
return $table_data_row;
}
/*
Gets the html table to manage giftcards.
*/
function get_giftcards_manage_table( $giftcards, $controller )
{
$CI =& get_instance();
$table='';
return $table;
}
/*
Gets the html data rows for the giftcard.
*/
function get_giftcards_manage_table_data_rows( $giftcards, $controller )
{
$CI =& get_instance();
$table_data_rows='';
foreach($giftcards->result() as $giftcard)
{
$table_data_rows.=get_giftcard_data_row( $giftcard, $controller );
}
if($giftcards->num_rows()==0)
{
$table_data_rows.="".$CI->lang->line('giftcards_no_giftcards_to_display')."
";
}
return $table_data_rows;
}
function get_giftcard_data_row($giftcard,$controller)
{
$CI =& get_instance();
$controller_name=strtolower(get_class($CI));
$table_data_row='';
$table_data_row.=" ";
$table_data_row.=''.$giftcard->last_name.' ';
$table_data_row.=''.$giftcard->first_name.' ';
$table_data_row.=''.$giftcard->giftcard_number.' ';
$table_data_row.=''.to_currency($giftcard->value).' ';
$table_data_row.=''.anchor($controller_name."/view/$giftcard->giftcard_id", $CI->lang->line('common_edit'),array('class'=>"modal-dlg modal-btn-submit",'title'=>$CI->lang->line($controller_name.'_update'))).' ';
$table_data_row.=' ';
return $table_data_row;
}
/*
Gets the html table to manage item kits.
*/
function get_item_kits_manage_table( $item_kits, $controller )
{
$CI =& get_instance();
$table='';
return $table;
}
/*
Gets the html data rows for the item kits.
*/
function get_item_kits_manage_table_data_rows($item_kits, $controller)
{
$CI =& get_instance();
$table_data_rows='';
foreach($item_kits->result() as $item_kit)
{
$table_data_rows .= get_item_kit_data_row($item_kit, $controller);
}
if($item_kits->num_rows()==0)
{
$table_data_rows .= "".$CI->lang->line('item_kits_no_item_kits_to_display')."
";
}
return $table_data_rows;
}
function get_item_kit_data_row($item_kit, $controller)
{
$CI =& get_instance();
$controller_name=strtolower(get_class($CI));
$table_data_row='';
$table_data_row.=" ";
$table_data_row.=''.'KIT '.$item_kit->item_kit_id.' ';
$table_data_row.=''.$item_kit->name.' ';
$table_data_row.=''.character_limiter($item_kit->description, 25).' ';
$table_data_row.=''.to_currency($item_kit->total_cost_price).' ';
$table_data_row.=''.to_currency($item_kit->total_unit_price).' ';
$table_data_row.=''.anchor($controller_name."/view/$item_kit->item_kit_id", $CI->lang->line('common_edit'),array('class'=>"modal-dlg modal-btn-submit",'title'=>$CI->lang->line($controller_name.'_update'))).' ';
$table_data_row.=' ';
return $table_data_row;
}
?>