function search() { $only_invoices = $this->input->post('only_invoices', TRUE); $only_cash = $this->input->post('only_cash', TRUE); $lines_per_page = $this->Appconfig->get('lines_per_page'); $limit_from = $this->input->post('limit_from', TRUE); $search = $this->input->post('search', TRUE); $sale_type = 'all'; $today = date($this->config->item('dateformat')); $start_date = $this->input->post('start_date') != NULL ? $this->input->post('start_date', TRUE) : $today; $start_date_formatter = date_create_from_format($this->config->item('dateformat'), $start_date); $end_date = $this->input->post('end_date') != NULL ? $this->input->post('end_date', TRUE) : $today; $end_date_formatter = date_create_from_format($this->config->item('dateformat'), $end_date); $is_valid_receipt = isset($search) ? $this->sale_lib->is_valid_receipt($search) : FALSE; $location_id = 'all'; $inputs = array('sale_type' => $sale_type, 'location_id' => $location_id, 'start_date' => $start_date_formatter->format('Y-m-d'), 'end_date' => $end_date_formatter->format('Y-m-d'), 'only_invoices' => $only_invoices, 'search' => $search, 'only_cash' => $only_cash, 'lines_per_page' => $lines_per_page, 'limit_from' => $limit_from, 'is_valid_receipt' => $is_valid_receipt); $sales = $this->Sale->get_all($inputs); $payments = $this->Sale->get_payments_summary($inputs); $total_rows = count($sales); $links = $this->_initialize_pagination($this->Sale, $lines_per_page, $limit_from, $total_rows, 'search', $only_invoices); $sale_rows = get_sales_manage_table_data_rows($sales, $this); $payment_summary = get_sales_manage_payments_summary($payments, $sales, $this); echo json_encode(array('total_rows' => $total_rows, 'rows' => $sale_rows, 'pagination' => $links, 'payment_summary' => $payment_summary)); $this->_remove_duplicate_cookies(); }
function search() { $payment_type = $this->input->post('payment_type', TRUE); $limit_from = $this->input->post('limit_from', TRUE); $search = $this->input->post('search', TRUE); $lines_per_page = $this->Appconfig->get('lines_per_page'); $sales = $this->Sale->search($search, $payment_type, $lines_per_page, $limit_from, $search); $total_rows = $this->Sale->get_found_rows($search); $links = $this->_initialize_pagination($this->Sale, $lines_per_page, $limit_from, $total_rows, 'search', $payment_type); $data_rows = get_sales_manage_table_data_rows($sales, $this); echo json_encode(array('total_rows' => $total_rows, 'rows' => $data_rows, 'pagination' => $links)); $this->_remove_duplicate_cookies(); }
function get_sales_manage_table($sales, $controller) { $CI =& get_instance(); $table = '<table class="tablesorter" id="sortable_table">'; $headers = array(' ', $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_receipt_number'), $CI->lang->line('sales_invoice_number'), ' '); $table .= '<thead><tr>'; foreach ($headers as $header) { $table .= "<th>{$header}</th>"; } $table .= '</tr></thead><tbody>'; $table .= get_sales_manage_table_data_rows($sales, $controller); $table .= '</tbody></table>'; return $table; }