From 78ca94e0365db496facf9d1187a5d261da94b378 Mon Sep 17 00:00:00 2001 From: jekkos-t520 Date: Thu, 27 Nov 2014 08:44:50 +0100 Subject: [PATCH] Fix detailed report editing --- application/controllers/reports.php | 9 ++++++--- application/controllers/sales.php | 4 ++-- js/manage_tables.js | 6 +----- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/application/controllers/reports.php b/application/controllers/reports.php index ef5d74d16..d3c5e37b2 100644 --- a/application/controllers/reports.php +++ b/application/controllers/reports.php @@ -720,7 +720,7 @@ class Reports extends Secure_area foreach($report_data['summary'] as $key=>$row) { - $summary_data[] = array(anchor('sales/edit/'.$row['sale_id'], 'POS '.$row['sale_id'], array('target' => '_blank')), $row['sale_date'], $row['items_purchased'], $row['employee_name'], to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']),to_currency($row['profit']), $row['payment_type'], $row['comment']); + $summary_data[] = array(anchor('sales/edit/'.$row['sale_id'], 'POS '.$row['sale_id'], array('class' => 'thickbox')), $row['sale_date'], $row['items_purchased'], $row['employee_name'], to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']),to_currency($row['profit']), $row['payment_type'], $row['comment']); foreach($report_data['details'][$key] as $drow) { @@ -733,6 +733,7 @@ class Reports extends Secure_area "title" => $customer_info->first_name .' '. $customer_info->last_name.' '.$this->lang->line('reports_report'), "subtitle" => date('m/d/Y', strtotime($start_date)) .'-'.date('m/d/Y', strtotime($end_date)), "headers" => $model->getDataColumns(), + "editable" => "sales", "summary_data" => $summary_data, "details_data" => $details_data, "overall_summary_data" => $model->getSummaryData(array('start_date'=>$start_date, 'end_date'=>$end_date,'customer_id' =>$customer_id, 'sale_type' => $sale_type)), @@ -769,7 +770,7 @@ class Reports extends Secure_area foreach($report_data['summary'] as $key=>$row) { - $summary_data[] = array(anchor('sales/edit/'.$row['sale_id'], 'POS '.$row['sale_id'], array('target' => '_blank')), $row['sale_date'], $row['items_purchased'], $row['customer_name'], to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']),to_currency($row['profit']), $row['payment_type'], $row['comment']); + $summary_data[] = array(anchor('sales/edit/'.$row['sale_id'], 'POS '.$row['sale_id'], array('class' => 'thickbox')), $row['sale_date'], $row['items_purchased'], $row['customer_name'], to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']),to_currency($row['profit']), $row['payment_type'], $row['comment']); foreach($report_data['details'][$key] as $drow) { @@ -782,6 +783,7 @@ class Reports extends Secure_area "title" => $employee_info->first_name .' '. $employee_info->last_name.' '.$this->lang->line('reports_report'), "subtitle" => date('m/d/Y', strtotime($start_date)) .'-'.date('m/d/Y', strtotime($end_date)), "headers" => $model->getDataColumns(), + "editable" => "sales", "summary_data" => $summary_data, "details_data" => $details_data, "overall_summary_data" => $model->getSummaryData(array('start_date'=>$start_date, 'end_date'=>$end_date,'employee_id' =>$employee_id, 'sale_type' => $sale_type)), @@ -818,7 +820,7 @@ class Reports extends Secure_area foreach($report_data['summary'] as $key=>$row) { - $summary_data[] = array(anchor('sales/receipt/'.$row['sale_id'], 'POS '.$row['sale_id'], array('target' => '_blank')), $row['sale_date'], $row['items_purchased'], $row['customer_name'], to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']),/*to_currency($row['profit']),*/ $row['payment_type'], $row['comment']); + $summary_data[] = array(anchor('sales/receipt/'.$row['sale_id'], 'POS '.$row['sale_id'], array('class' => 'thickbox')), $row['sale_date'], $row['items_purchased'], $row['customer_name'], to_currency($row['subtotal']), to_currency($row['total']), to_currency($row['tax']),/*to_currency($row['profit']),*/ $row['payment_type'], $row['comment']); foreach($report_data['details'][$key] as $drow) { @@ -830,6 +832,7 @@ class Reports extends Secure_area "title" => $discount. '% '.$this->lang->line('reports_discount') . ' ' . $this->lang->line('reports_report'), "subtitle" => date('m/d/Y', strtotime($start_date)) .'-'.date('m/d/Y', strtotime($end_date)), "headers" => $headers, + "editable" => "sales", "summary_data" => $summary_data, "details_data" => $details_data, "header_width" => intval(100 / count($headers['summary'])), diff --git a/application/controllers/sales.php b/application/controllers/sales.php index e2839756b..414efafa6 100644 --- a/application/controllers/sales.php +++ b/application/controllers/sales.php @@ -364,10 +364,10 @@ class Sales extends Secure_area { $sale_data = array( 'sale_time' => date('Y-m-d', strtotime($this->input->post('date'))), - 'customer_id' => $this->input->post('customer_id') ? $this->input->post('customer_id') : null, + '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') + 'invoice_number' => $this->input->post('invoice_number') ? $this->input->post('invoice_number') : NULL ); if ($this->Sale->update($sale_data, $sale_id)) diff --git a/js/manage_tables.js b/js/manage_tables.js index 06d41922c..ddc1e1504 100644 --- a/js/manage_tables.js +++ b/js/manage_tables.js @@ -277,11 +277,7 @@ function get_table_row(id) { id = id || $("input[name='sale_id']").val(); var $element = $("#sortable_table tbody :checkbox[value='" + id + "']"); if ($element.length === 0) { - // parse link - var row_id = $("#sortable_table tbody a").each(function(index, element) { - var result = $(element).attr("href").match(/\/(\d+)\//); - $element = result && result[1] == id ? $(element) : $element; - }); + $element = $("#sortable_table a.thickbox[href*='" + id + "']"); } return $element; }