function get_items_barcode_data($item_ids) { $CI =& get_instance(); $result = array(); $item_ids = explode('~', $item_ids); foreach ($item_ids as $item_id) { $item_info = $CI->Item->get_info($item_id); $item_location_info = $CI->Item_location->get_info($item_id); $today = strtotime(date('Y-m-d')); $is_item_location_promo = $item_location_info->start_date !== NULL && $item_location_info->end_date !== NULL && (strtotime($item_location_info->start_date) <= $today && strtotime($item_location_info->end_date) >= $today); $is_item_promo = $item_info->start_date !== NULL && $item_info->end_date !== NULL && (strtotime($item_info->start_date) <= $today && strtotime($item_info->end_date) >= $today); $regular_item_price = $item_location_info->unit_price ? $item_location_info->unit_price : $item_info->unit_price; if ($is_item_location_promo) { $item_price = $item_location_info->promo_price; } elseif ($is_item_promo) { $item_price = $item_info->promo_price; } else { $item_price = $item_location_info->unit_price ? $item_location_info->unit_price : $item_info->unit_price; } if ($CI->config->item('barcode_price_include_tax')) { if ($item_info->tax_included) { $result[] = array('name' => ($is_item_location_promo || $is_item_promo ? '<span style="text-decoration: line-through;">' . to_currency($regular_item_price) . '</span> ' : ' ') . to_currency($item_price) . ': ' . $item_info->name, 'id' => number_pad($item_id, 10)); } else { $result[] = array('name' => ($is_item_location_promo || $is_item_promo ? '<span style="text-decoration: line-through;">' . to_currency(get_price_for_item_including_taxes($item_id, $regular_item_price)) . '</span> ' : ' ') . to_currency(get_price_for_item_including_taxes($item_id, $item_price)) . ': ' . $item_info->name, 'id' => number_pad($item_id, 10)); } } else { if ($item_info->tax_included) { $result[] = array('name' => ($is_item_location_promo || $is_item_promo ? '<span style="text-decoration: line-through;">' . to_currency(get_price_for_item_excluding_taxes($item_id, $regular_item_price)) . '</span> ' : ' ') . to_currency(get_price_for_item_excluding_taxes($item_id, $item_price)) . ': ' . $item_info->name, 'id' => number_pad($item_id, 10)); } else { $result[] = array('name' => ($is_item_location_promo || $is_item_promo ? '<span style="text-decoration: line-through;">' . to_currency($regular_item_price) . '</span> ' : ' ') . to_currency($item_price) . ': ' . $item_info->name, 'id' => number_pad($item_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)); }