function get_item_kits_barcode_data($item_kits_ids) { $CI =& get_instance(); $result = array(); $item_kit_ids = explode('~', $item_kits_ids); foreach ($item_kit_ids as $item_kit_id) { $item_kit_info = $CI->Item_kit->get_info($item_kit_id); $item_kit_location_info = $CI->Item_kit_location->get_info($item_kit_id); $item_kit_price = $item_kit_location_info->unit_price ? $item_kit_location_info->unit_price : $item_kit_info->unit_price; if ($CI->config->item('barcode_price_include_tax')) { if ($item_kit_info->tax_included) { $result[] = array('name' => to_currency($item_kit_price) . ' ' . $item_kit_info->name, 'id' => 'KIT ' . number_pad($item_kit_id, 10)); } else { $result[] = array('name' => to_currency(get_price_for_item_kit_including_taxes($item_kit_id, $item_kit_price)) . ': ' . $item_kit_info->name, 'id' => 'KIT ' . number_pad($item_kit_id, 10)); } } else { if ($item_kit_info->tax_included) { $result[] = array('name' => to_currency(get_price_for_item_kit_excluding_taxes($item_kit_id, $item_kit_price)) . ': ' . $item_kit_info->name, 'id' => 'KIT ' . number_pad($item_kit_id, 10)); } else { $result[] = array('name' => to_currency($item_kit_price) . ': ' . $item_kit_info->name, 'id' => 'KIT ' . number_pad($item_kit_id, 10)); } } } return $result; }
function copy_entire_sale($sale_id, $is_receipt = false) { $this->empty_cart(); $this->delete_customer(false); $sale_taxes = $this->get_taxes($sale_id); foreach ($this->CI->Sale->get_sale_items($sale_id)->result() as $row) { $item_info = $this->CI->Item->get_info($row->item_id); $price_to_use = $row->item_unit_price; //If we have tax included, but we don't have any taxes for sale, pretend that we do have taxes so the right price shows up if ($item_info->tax_included && empty($sale_taxes) && !$is_receipt) { $price_to_use = get_price_for_item_including_taxes($row->item_id, $row->item_unit_price); } elseif ($item_info->tax_included) { $price_to_use = get_price_for_item_including_taxes($row->line, $row->item_unit_price, $sale_id); } $this->add_item($row->item_id, $row->quantity_purchased, $row->discount_percent, $price_to_use, $row->description, $row->serialnumber, TRUE, $row->line); } foreach ($this->CI->Sale->get_sale_item_kits($sale_id)->result() as $row) { $item_kit_info = $this->CI->Item_kit->get_info($row->item_kit_id); $price_to_use = $row->item_kit_unit_price; //If we have tax included, but we don't have any taxes for sale, pretend that we do have taxes so the right price shows up if ($item_kit_info->tax_included && empty($sale_taxes) && !$is_receipt) { $price_to_use = get_price_for_item_kit_including_taxes($row->item_kit_id, $row->item_kit_unit_price); } elseif ($item_kit_info->tax_included) { $price_to_use = get_price_for_item_kit_including_taxes($row->line, $row->item_kit_unit_price, $sale_id); } $this->add_item_kit('KIT ' . $row->item_kit_id, $row->quantity_purchased, $row->discount_percent, $price_to_use, $row->description, $row->line); } foreach ($this->CI->Sale->get_sale_payments($sale_id)->result() as $row) { $this->add_payment($row->payment_type, $row->payment_amount, $row->payment_date, $row->truncated_card, $row->card_issuer); } $customer_info = $this->CI->Sale->get_customer($sale_id); $this->set_customer($customer_info->person_id, false); $this->set_comment($this->CI->Sale->get_comment($sale_id)); $this->set_comment_on_receipt($this->CI->Sale->get_comment_on_receipt($sale_id)); $this->set_sold_by_employee_id($this->CI->Sale->get_sold_by_employee_id($sale_id)); }