Final touch on Work Orders

This commit is contained in:
Steve Ireland
2017-09-09 17:16:38 -04:00
parent c01663f901
commit e85e2e5e55
6 changed files with 60 additions and 16 deletions

View File

@@ -1099,16 +1099,34 @@ class Sales extends Secure_Controller
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);
$has_grant = $this->Employee->has_grant('sales_delete', $employee_id);
if($this->Sale->delete_list($sale_ids, $employee_id, $update_inventory))
if(!$has_grant)
{
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));
echo json_encode(array('success' => FALSE, 'message' => $this->lang->line('sales_not_authorized')));
}
else
{
echo json_encode(array('success' => FALSE, 'message' => $this->lang->line('sales_unsuccessfully_deleted')));
$sale_ids = $sale_id == -1 ? $this->input->post('ids') : array($sale_id);
$reactivate = FALSE;
if($this->Sale->delete_list($sale_ids, $employee_id, $update_inventory, $reactivate))
{
if(!$reactivate)
{
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_reactivated') . ' ' .
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')));
}
}
}

View File

@@ -12,6 +12,8 @@ $lang["reports_code_return"] = "RET";
$lang["reports_code_type"] = "Type";
$lang["reports_code_work_order"] = "W/O";
$lang["reports_comments"] = "Comments";
$lang["reports_complete"] = "Completed Sales and Returns";
$lang["reports_completed_sales"] = "Completed Sales";
$lang["reports_cost"] = "Wholesale";
$lang["reports_cost_price"] = "Wholesale Price";
$lang["reports_count"] = "Count";

View File

@@ -18,7 +18,7 @@ $lang["sales_comment"] = "Comment";
$lang["sales_comments"] = "Comments";
$lang["sales_complete_sale"] = "Complete";
$lang["sales_confirm_cancel_sale"] = "Are you sure you want to clear this sale? All items will cleared.";
$lang["sales_confirm_delete"] = "Are you sure you want to delete the selected Sale(s)?";
$lang["sales_confirm_delete"] = "Are you sure you want to delete or reactivate the selected Sale(s)?";
$lang["sales_credit"] = "Credit Card";
$lang["sales_credit_deposit"] = "Credit Deposit";
$lang["sales_customer"] = "Name";
@@ -84,6 +84,7 @@ $lang["sales_no_filter"] = "All";
$lang["sales_no_items_in_cart"] = "There are no Items in the cart.";
$lang["sales_no_sales_to_display"] = "No Sales to display.";
$lang["sales_none_selected"] = "You have not selected any Sale(s) to delete.";
$lang["sales_not_authorized"]= "You are not authorized to delete sales transactions";
$lang["sales_one_or_multiple"] = "Sale(s)";
$lang["sales_payment"] = "Payment Type";
$lang["sales_payment_amount"] = "Amount";
@@ -110,6 +111,7 @@ $lang["sales_return"] = "Return";
$lang["sales_rewards"] = "Reward Points";
$lang["sales_rewards_balance"] = "Reward Points Balance";
$lang["sales_sale"] = "Sale";
$lang["sales_delete"] = "Allow Delete";
$lang["sales_sale_by_invoice"] = "Sale by Invoice";
$lang["sales_sale_for_customer"] = "Customer:";
$lang["sales_sale_time"] = "Time";
@@ -124,10 +126,12 @@ $lang["sales_show_invoice"] = "Show Invoice";
$lang["sales_show_receipt"] = "Show Receipt";
$lang["sales_start_typing_customer_name"] = "Start typing customer details...";
$lang["sales_start_typing_item_name"] = "Start typing Item Name or scan Barcode...";
$lang["sales_stock"] = "Stock";
$lang["sales_stock_location"] = "Stock Location";
$lang["sales_sub_total"] = "Subtotal";
$lang["sales_successfully_deleted"] = "You have successfully deleted";
$lang["sales_successfully_suspended_sale"] = "Sale suspend successful.";
$lang["sales_successfully_reactivated"] = "You have successfully reactivated";
$lang["sales_successfully_updated"] = "Sale update successful.";
$lang["sales_suspend_sale"] = "Suspend";
$lang["sales_suspended_doc_id"] = "Document";

View File

@@ -808,13 +808,13 @@ class Sale extends CI_Model
/**
* Deletes list of sales
*/
public function delete_list($sale_ids, $employee_id, $update_inventory = TRUE)
public function delete_list($sale_ids, $employee_id, &$reactivated, $update_inventory = TRUE)
{
$result = TRUE;
foreach($sale_ids as $sale_id)
{
$result &= $this->delete($sale_id, $employee_id, $update_inventory);
$result &= $this->delete($sale_id, $employee_id, $reactivated, $update_inventory);
}
return $result;
@@ -825,12 +825,14 @@ class Sale extends CI_Model
* When a sale is "deleted" it is simply changed to a status of canceled.
* However, if applicable the inventory still needs to be updated
*/
public function delete($sale_id, $employee_id, $update_inventory = TRUE)
public function delete($sale_id, $employee_id, &$reactivated, $update_inventory = TRUE)
{
// start a transaction to assure data integrity
$this->db->trans_start();
if($update_inventory && $sale_status = $this->get_sale_status($sale_id) == COMPLETED)
$sale_status = $this->get_sale_status($sale_id);
if($update_inventory && $sale_status == COMPLETED)
{
// defect, not all item deletions will be undone??
// get array with all the items involved in the sale to update the inventory tracking
@@ -858,8 +860,17 @@ class Sale extends CI_Model
}
}
// Set the status of the sale to canceled
$this->update_sale_status($sale_id, CANCELED);
// Set the sale_status is canceled the reactive the sale by setting the status to suspended
// otherwise set the status to canceled
if($sale_status == CANCELED)
{
$this->update_sale_status($sale_id, SUSPENDED);
$reactivated = TRUE;
}
else
{
$this->update_sale_status($sale_id, CANCELED);
}
// execute transaction
$this->db->trans_complete();
@@ -1401,11 +1412,11 @@ class Sale extends CI_Model
*/
private function save_customer_rewards($customer_id, $sale_id, $total_amount, $total_amount_used)
{
if (!empty($customer_id) && $this->config->item('customer_reward_enable') == TRUE)
if(!empty($customer_id) && $this->config->item('customer_reward_enable') == TRUE)
{
$package_id = $this->Customer->get_info($customer_id)->package_id;
if (!empty($package_id))
if(!empty($package_id))
{
$points_percent = $this->Customer_rewards->get_points_percent($package_id);
$points = $this->Customer->get_info($customer_id)->points;
@@ -1427,7 +1438,7 @@ class Sale extends CI_Model
*/
private function determine_sale_status(&$sale_status, $dinner_table)
{
if ($sale_status == SUSPENDED && $dinner_table > 2) //not delivery or take away
if($sale_status == SUSPENDED && $dinner_table > 2) //not delivery or take away
{
return SUSPENDED;
}

View File

@@ -28,7 +28,7 @@ class Rounding_mode
$CI =& get_instance();
$CI->load->helper('language');
if (empty($code))
if(empty($code))
{
return lang('common_unknown');
}