public function download_order_info() { $head = array(lang('item_number'), lang('ship_remark'), lang('customer_remark'), lang('is_register'), lang('track_number'), lang('total_weight'), lang('shipping_cost'), lang('total_cost'), lang('total_profit_rate'), lang('product_information'), lang('ship_confirm_date'), lang('receipt'), lang('transaction_number'), lang('input_user'), lang('cost_date')); if (!$this->input->is_post()) { return; } $order_ids_str = trim($this->input->post('order_ids_str'), ','); if (empty($order_ids_str)) { $content = lang('select_one_download'); echo "<script >alert('{$content}'); history.back();</script>"; return; } $order_ids = array(); foreach (explode(',', $order_ids_str) as $id) { $order_ids[] = $id; } $orders = $this->accounting_cost_model->fetch_costs_by_cost_user_to_array($order_ids); $show_data = array(); foreach ($orders as $order) { $receipt = $order->currency . ' : ' . $order->net && $order->net != 0 ? $order->net : $order->gross; $item_ids = explode(',', $order->item_id_str); $skus = explode(',', $order->sku_str); $qties = explode(',', $order->qty_str); $item_title = explode(',', $order->item_title_str); $product_cost_string = explode(',', $order->product_cost); $count = count($skus); $product_information = ''; $product_name = ''; $total_product_cost = 0; for ($i = 0; $i < $count; $i++) { $item_id = element($i, $item_ids); $title = element($i, $item_title); $product_information .= $title . ' '; if ($item_id) { $product_information .= "Item ID: {$item_id} "; } $purchaser_name = ''; if (isset($purchasers[$skus[$i]])) { $purchaser_name = $purchasers[$skus[$i]]; } else { $purchaser_name = get_purchaser_name_by_sku($skus[$i]); $purchasers[$skus[$i]] = $purchaser_name; } $product_cost = get_cost_by_sku($skus[$i]); if ($product_cost == 0) { $product_cost = ''; } $price_html = $product_cost; if (element($i, $product_cost_string)) { $cost = $product_cost_string[$i]; } else { $cost = $product_cost; } // if(isset ($action) && $action =='cost_view_list') // { $price_html = $cost; // } $total_product_cost += $cost * element($i, $qties); $product_information .= ' SKU: ' . (isset($skus[$i]) ? $skus[$i] . ' * ' . element($i, $qties) . ' (' . get_product_name($skus[$i]) . ')' : '') . ' ' . $purchaser_name . ' ' . lang('cost_price') . ' : ' . $price_html; } $default = isset($product_cost_string[$count]) ? $product_cost_string[$count] : '0.65'; $product_information .= ' ' . lang('other_cost_price') . ' : ' . $default; $top = $order->product_cost_all == 0 ? $total_product_cost : $order->product_cost_all; $product_information .= ' ' . lang('total_cost') . ' : ' . $top; $show_data[] = array('item_number' => $order->item_no, 'ship_remark' => $order->ship_remark, 'customer_remark' => $order->descript, 'is_register' => $order->is_register, 'track_number' => $order->track_number, 'total_weight' => $order->ship_weight, 'shipping_cost' => $order->shipping_cost, 'total_cost' => $top, 'total_profit_rate' => $order->profit_rate, 'product_information' => $product_information, 'ship_confirm_date' => $order->ship_confirm_date, 'receipt' => $receipt . "({$order->currency})", 'transaction_number' => $order->transaction_id, 'input_user' => $order->input_user, 'cost_date' => $order->cost_date); } $this->excel->array_to_excel($show_data, $head, 'Order_info_' . date('Y-m-d')); }
$item_id = element($i, $item_ids); $link = $item_id; $item_sku_html .= '<div style="margin-top: 5px;">'; $title = element($i, $item_title); $item_sku_html .= $title . '<br/>'; if ($item_id) { $item_sku_html .= "Item ID: {$link}<br/>"; } $purchaser_name = ''; if (isset($purchasers[$skus[$i]])) { $purchaser_name = $purchasers[$skus[$i]]; } else { $purchaser_name = get_purchaser_name_by_sku($skus[$i]); $purchasers[$skus[$i]] = $purchaser_name; } $cost = get_cost_by_sku($skus[$i]); if ($cost == 0) { $cost = ''; } $item_sku_html .= ' SKU: ' . (isset($skus[$i]) ? $skus[$i] . ' * ' . element($i, $qties) . ' (' . get_product_name($skus[$i]) . ')' : '') . ' ' . $purchaser_name . '<br>'; $item_sku_html .= '</div>'; } $item_sku_html .= '</div>'; $shipping_type = lang('shipping_way') . ': '; $shipping_type .= $order->is_register; $product_info = <<<PRODUCT <div style='padding: 10px;'> {$item_sku_html} </div> PRODUCT; $item_id_arr = explode(',', $order->item_id_str);
$item_id = element($i, $item_ids); $link = $item_id; $item_sku_html .= '<div style="margin-top: 5px;">'; $title = element($i, $item_title); $item_sku_html .= $title . '<br/>'; if ($item_id) { $item_sku_html .= "Item ID: {$link}<br/>"; } $purchaser_name = ''; if (isset($purchasers[$skus[$i]])) { $purchaser_name = $purchasers[$skus[$i]]; } else { $purchaser_name = get_purchaser_name_by_sku($skus[$i]); $purchasers[$skus[$i]] = $purchaser_name; } $product_cost = get_cost_by_sku($skus[$i]); if ($product_cost == 0) { $product_cost = ''; } $price_html = '<input onchange="count_top_cost(' . "{$order->id},{$count}" . ')" id="' . "cost_price_{$order->id}" . "_{$i}" . '" type="text" name="' . "cost_price_{$order->id}" . "_{$i}" . '" value="' . $product_cost . '" />' . '<br/>'; if (element($i, $product_cost_string)) { $cost = $product_cost_string[$i]; } else { $cost = $product_cost; } if (isset($action) && $action == 'cost_view_list') { $price_html = '<input onchange="count_top_cost(' . "{$order->id},{$count}" . ')" id="' . "cost_price_{$order->id}" . "_{$i}" . '" type="text" name="' . "cost_price_{$order->id}" . "_{$i}" . '" value="' . $cost . '" />' . '<br/>'; } $total_product_cost += $cost * element($i, $qties); $item_sku_html .= ' SKU: ' . (isset($skus[$i]) ? $skus[$i] . ' * ' . element($i, $qties) . ' (' . get_product_name($skus[$i]) . ')' : '') . ' ' . $purchaser_name . '<br>' . lang('cost_price') . $price_html; if (isset($skus[$i])) {