$counter_products = 0; foreach ($contents as $do) { $counter_orders++; $counter_products += $do['quantity']; $pcode = $do['products_model'] . ($do['length'] > 0 ? '_' . textLength($do['length'], false) : ''); $product = ''; $pimg = webImageSource($do['products_image'], '500'); if ($pimg != '') { $thumb = '<div class="thumb" style="display:none;"><a href="' . $pimg . '" class="view_image" title="' . $pcode . '">' . webImage($do['products_image'], '80', '80', '', 'img-border img-padding') . '</a></div>'; $product .= $thumb; } $product .= '<a href="?open=product-detail&products_id=' . $do['products_id'] . '" target="_blank">' . $pcode . '</a>'; $ct = array(); $ct['d'] = date('d-M-y', strtotime($do['order_date'])); $ct['o'] = '<a href="?open=depot-order&id=' . $do['depot_orders_id'] . '" class="view_webpage">DP-' . $do['depot_orders_id'] . '</a>'; $ct['e'] = $class_do->translateOrderSource($do['trans_type'], $do['trans_id'], true); $ct['a'] = $product; $ct['a2'] = $do['products_ean']; $ct['q'] = $do['quantity']; $ct['d2'] = date('H:i:s', strtotime($do['date_added'])); $contents_table[] = $ct; } $content .= '<div><table class="form" border="0" cellpadding="0" cellspacing="0">'; $content .= '<tr><td class="label">Package ID</td><td>' . $package['depot_packages_id'] . '</td></tr>'; $content .= '<tr><td>Package Code</td><td>' . $package_code . '</td></tr>'; $content .= '<tr><td>Segments</td><td>' . $segment['name'] . '</td></tr>'; $content .= '<tr><td>AWB No</td><td>' . $package['awb_no'] . '</td></tr>'; $content .= '<tr><td>Sent Date</td><td>' . $sent_date . '</td></tr>'; $content .= '<tr><td>Received Date</td><td>' . $received_date . '</td></tr>'; $content .= '</table></div>'; $content .= '<div class="buttons-left"><input type="button" id="togglethumbs" value="Toggle Product Thumbnails" title="Show or hide product thumbnails for each items" /></div>';
$product_row = $product_rowstart + $product_counter; $order_status = $row['order_status']; $prod_status = $row['prod_status']; $late_order_status = $row['status']; if ($row['type'] == 'DP') { $order_detail = 'DP-' . $row['order_items_id']; } elseif ($row['type'] == 'SP') { $order_detail = $row['type'] . '-' . $row['order_items_id']; } else { $order_detail = $row['type'] . '-' . $row['order_items_id']; } $lead_time = displayDuration(strtotime('now') - strtotime($row['leadtime_start_date']), 'day', 1); if ($row['type'] == 'SP') { $sp_name = $row['sp_name']; } elseif ($row['type'] == 'DP') { $sp_name = $class_do->translateOrderSource($row['trans_type'], $row['trans_id'], true, null, $row['products_id']); } else { $sp_name = 'JG'; } $customer_name = $row['customers_name']; $p_image = DIR_WS_IMAGES . $row['products_image']; if (isset($article_rowstart)) { mergeArticleRowsToProduct($article_rowstart, $product_row - 1); } $article_rowstart = $product_row; if (is_file($p_image)) { $img_path = thumbimage($p_image, $pi_width, $pi_height, 1, 1, DIR_WS_IMAGES . 'imagecache'); $obj_excel_draw = new PHPExcel_Worksheet_Drawing(); $obj_excel_draw->setWorksheet($obj_ws); $obj_excel_draw->setPath($img_path); $obj_excel_draw->setCoordinates('F' . $product_row);
public function renderRow($order_type, $orders_items_id, $template_row = self::ROW_TEMPLATE_DEFAULT, $is_order_first_row = false) { use_class('Product'); $order_item_data = $this->retrieveOrdersItemsDetail($order_type, $orders_items_id); $row_data = array(); //SET GENERAL VARS VALUES $products_id = $order_item_data['products_id']; $articles_id = $order_item_data['products_articles_id']; $obj_product = new Product($products_id); $product_image = $obj_product->displayImage(80, 80); $product_image_thumbid = "{$products_id}-{$articles_id}"; $article_no_link = '?open=product-detail&products_id=' . $products_id; switch ($this->filters_status) { case '1': $is_sp = $order_type == self::ORDER_TYPE_SP; $is_prepayment = strtoupper($order_item_data['payment_method']) == strtoupper(PAYMENT_METHOD_BANK_TRANSFER) || strtoupper($order_item_data['payment_method']) == strtoupper(PAYMENT_METHOD_PREPAYMENT); $is_unpaid_prepayment = $is_prepayment && !conditionPrepaymentIsPaid($order_item_data, $is_sp); break; } if ($order_type == self::ORDER_TYPE_SP) { use_class('products_minierp'); $class_pm = new products_minierp(); //self::ROW_DATA_LEADTIME_OR_DATE $order_date = $order_item_data['order_date']; //self::ROW_DATA_CYCLETIME DATA $previous_status_date = $this->filters_status == 4 ? $order_item_data['status_date_prod'] : $order_item_data['status_date']; //self::ROW_DATA_CUSTOMER_OR_ORDER_NO DATA $order_id = $order_item_data['order_id']; $orders_number = $order_item_data['order_id']; $order_no_link = '?open=customer-care-order-detail&source=SP&id=' . $order_item_data['jng_sp_orders_id'] . '&hidemenu=true'; $customer_name = $order_item_data['customer_name']; $cust_link = '?open=sp-customer&id=' . $order_item_data['jng_sp_customers_id'] . '&hidemenu=true'; $cust_name = '<a href="' . $cust_link . '" class="view_webpage" >' . $customer_name . '</a>'; //self::ROW_DATA_ORDER_ID DATA $source_name = $order_item_data['package_prefix']; $barcode_id = strtoupper(self::ORDER_TYPE_SP) . '-' . $order_item_data['jng_sp_orders_items_id']; $barcode_id_link = '?open=sp-order-history&oi_id=' . $order_item_data['jng_sp_orders_items_id'] . '&hidemenu=true'; $crown_link = '?open=sp-customers-special-detail&id=' . $order_item_data['jng_sp_customers_id'] . '&hidemenu=true'; //self::ROW_DATA_ARTICLE_NO DATA $product_image_thumbid .= "-{$order_item_data['jng_sp_id']}"; $article_no = $order_item_data['article_number']; //self::ROW_DATA_PRICE DATA $products_price = $order_item_data['price']; //self::ROW_DATA_QUANTITY DATA $order_quantity = $order_item_data['order_quantity']; //self::ROW_DATA_MARGIN DATA $mat_exp = $order_item_data['material_expenses'] > 0 ? $order_item_data['material_expenses'] : $order_item_data['current_mat_exp']; $product_margin = number_format($class_pm->calculateMargin($order_item_data['price'], $mat_exp), 1) . '%'; $product_margin = '<span class="' . ($class_pm->priceMargindIsGood($order_item_data['price'], $product_margin) ? 'green' : 'red') . '">' . $product_margin . '</span>'; //self::ROW_DATA_ACTION DATA //Tab Unpaid Prepayment if ($this->filters_status == 1 && $this->filters_sub_status == '0') { if ($order_item_data['jng_sp_id'] == '8') { $action = '<span class="green">Waiting Payment Status</span>'; } else { if ($order_item_data['last_sent_date'] == '') { $action = '<span class="green">Reminder Not Sent</span>'; } else { $overtime = strtotime($order_item_data['last_sent_date']) < strtotime('-' . PAYMENT_METHOD_BANK_TRANSFER_OVERDUE); if ($order_item_data['sent_count'] > 1) { $action = '<span class="red">Cancel Notification Sent</span>'; } else { $action = '<span class="blue">Reminder Sent</span>'; } } } } } elseif ($order_type == self::ORDER_TYPE_JG) { //self::ROW_DATA_LEADTIME_OR_DATE $order_date = $order_item_data['date_purchased']; //self::ROW_DATA_CYCLETIME DATA $previous_status_date = $this->filters_status == 4 ? $order_item_data['status_date_prod'] : $order_item_data['status_date']; //self::ROW_DATA_CUSTOMER_OR_ORDER_NO DATA $order_id = $order_item_data['orders_no']; $orders_number = $order_item_data['orders_no']; $order_no_link = '?open=customer-care-order-detail&source=JG&id=' . $order_item_data['orders_id'] . '&hidemenu=true'; $customer_name = $order_item_data['customers_name']; $cust_link = '?open=customer&id=' . $order_item_data['customers_id'] . '&hidemenu=true'; $cust_name = '<a href="' . $cust_link . '" class="view_webpage" >' . $customer_name . '</a>'; //self::ROW_DATA_ORDER_ID DATA $source_name = 'J&G'; $barcode_id = strtoupper(self::ORDER_TYPE_JG) . '-' . $order_item_data['orders_products_id']; $barcode_id_link = '?open=sp-order-history&opid=' . $order_item_data['orders_products_id'] . '&hidemenu=true'; $crown_link = '?open=customers-special-detail&id=' . $order_item_data['customers_id'] . '&hidemenu=true'; //self::ROW_DATA_ARTICLE_NO DATA $article_no = $order_item_data['products_model'] . ($order_item_data['products_length'] > 0 ? '_' . textLength($order_item_data['products_length'], false) : ''); //self::ROW_DATA_PRICE DATA $products_price = $order_item_data['final_price']; //self::ROW_DATA_QUANTITY DATA $order_quantity = $order_item_data['products_quantity']; //self::ROW_DATA_MARGIN DATA $product_margin = ''; //self::ROW_DATA_ACTION DATA //Tab Unpaid Prepayment if ($this->filters_status == 1 && $this->filters_sub_status == '0') { if ($order_item_data['last_sent_date'] == '') { $action = '<span class="green">Reminder Not Sent</span>'; } else { $overtime = strtotime($order_item_data['last_sent_date']) < strtotime('-' . PAYMENT_METHOD_BANK_TRANSFER_OVERDUE); if ($order_item_data['sent_count'] > 1) { $action = '<span class="red">Cancel Notification Sent</span>'; } else { $action = '<span class="blue">Reminder Sent</span>'; } } } } else { use_class('depot_orders'); $class_do = new depot_orders(); //self::ROW_DATA_LEADTIME_OR_DATE $order_date = $order_item_data['order_date']; //self::ROW_DATA_CYCLETIME DATA $previous_status_date = $this->filters_status == 4 ? $order_item_data['status_date_prod'] : $order_item_data['update_time']; //self::ROW_DATA_CUSTOMER_OR_ORDER_NO DATA $order_id = ''; $customer_name = $order_item_data['customer_name']; $depot_orders_info = $class_do->translateOrderSource($order_item_data['trans_type'], $order_item_data['trans_id'], true, null, $products_id); $cust_name = $customer_name; if ($depot_orders_info != '') { $cust_name = $cust_name . ($cust_name != '' ? " <br/>{$depot_orders_info}" : $depot_orders_info); if ($order_item_data['group_name'] != '') { $cust_name .= ': ' . $order_item_data['group_name']; } } //self::ROW_DATA_ORDER_ID DATA $source_name = 'DP'; $barcode_id = strtoupper(self::ORDER_TYPE_DP) . '-' . $order_item_data['depot_orders_id']; $barcode_id_link = '?open=depot-order&id=' . $order_item_data['depot_orders_id'] . '&hidemenu=true'; //self::ROW_DATA_ARTICLE_NO DATA $article_no = $order_item_data['article_number']; //self::ROW_DATA_PRICE DATA $products_price = $order_item_data['price']; //self::ROW_DATA_QUANTITY DATA $order_quantity = $order_item_data['quantity']; //self::ROW_DATA_MARGIN DATA $product_margin = ''; } //FIRST ROW OF ORDER if ($is_order_first_row) { $crown_img_col = array('V' => 'vip', 'B' => 'black'); if ($order_item_data['list_type'] != '' && array_key_exists($order_item_data['list_type'], $crown_img_col)) { $crown_img_title = array('V' => 'VIP Customer', 'B' => 'Blacklist Customer'); $crown_img = '<a href="' . $crown_link . '" class="view_webpage">'; $crown_img .= '<img src="images/list-' . $crown_img_col[$order_item_data['list_type']] . '.gif" title="' . $crown_img_title[$order_item_data['list_type']] . '" />'; $crown_img .= '</a> '; $cust_crown = $crown_img; } else { $cust_crown = ''; } $cust_order_count = ' <sup>' . $order_item_data['customers_order_count'] . '</sup>'; if ($orders_number == '' || is_null($orders_number)) { $order_no = ''; } else { $order_no = '<br /><small>order no:</small> <a href="' . $order_no_link . '" class="view_webpage">' . $order_id . '</a>'; } $row_data[self::ROW_DATA_CUSTOMER_OR_ORDER_NO] = $cust_crown . $cust_name . $cust_order_count . $order_no; $row_data[self::ROW_DATA_SOURCE] = strtoupper($source_name); } $row_data[self::ROW_DATA_LEADTIME_OR_DATE] = $is_unpaid_prepayment || $this->filters_status > 9 ? date('d-M-y', strtotime($order_date)) : displayLeadTime($order_item_data['leadtime_start_date'], strtotime($order_item_data['leadtime_start_date'])); if ($this->filters_status == 1 && $order_item_data['update_time'] == '') { $order_item_data['update_time'] = $order_item_data['leadtime_start_date']; } $row_data[self::ROW_DATA_CYCLETIME] = displayCycleTime($previous_status_date); $row_data[self::ROW_DATA_ORDER_ID] = '<a href="' . $barcode_id_link . '" class="view_webpage">' . $barcode_id . '</a>' . ($order_item_data['order_item_total'] > 1 ? ' <sup>' . $order_item_data['order_item_count'] . '/' . $order_item_data['order_item_total'] . '</sup>' : ''); $row_data[self::ROW_DATA_ARTICLE_NO] = '<div class="thumb" thumbid="' . $product_image_thumbid . '">' . '<span>' . $product_image . '</span></div>' . '<div><a href="' . $article_no_link . '" target="_blank&hidemenu=true" title="View Product Detail" ' . 'class="view_webpage">' . $article_no . '</a></div>'; $row_data[self::ROW_DATA_PRICE] = number_format($products_price, 2); $order_quantity = intval($order_quantity); $row_data[self::ROW_DATA_QUANTITY] = $order_quantity; $row_data[self::ROW_DATA_MARGIN] = $product_margin; $el_link = '<a href="?open=products-elements-stock&products_id=' . $products_id . '&paid=' . $articles_id . '&qty=' . $order_quantity . '&status=' . $order_item_data['stock_status'] . '&hidemenu=true" class="view_webpage"></a>'; $pr_link = '<a href="javascript:void();" onclick="alert(\'Please use Finish Good Stock\');"></a>'; $dp_link = '<a href="javascript:void();" onclick="alert(\'Please use Depot Stock\');"></a>'; if ($this->filters_show_stock_status) { switch ($order_item_data['stock_status']) { case '0': $stock_status = '<strong class="red">!</strong>'; if ($this->filters_status == 8 && ($order_type == self::ORDER_TYPE_SP || $order_type == self::ORDER_TYPE_JG)) { $do_status = $order_item_data['depot_orders_status'] == '4' && isset($order_item_data['depot_orders_prod_status']) && $order_item_data['depot_orders_prod_status'] != '' ? statusNameProduction($order_item_data['depot_orders_prod_status'], false, true) : statusNameShort($order_item_data['depot_orders_status']); if (!is_array($do_status)) { $stock_status = '<a href="?open=depot-order&id=' . $order_item_data['depot_orders_id'] . '&hidemenu=true" ' . 'title="MMO product, current status is ' . $do_status . '" class="red view_webpage">' . $do_status . '</a>'; } } break; case 'R': $stock_status = $el_link . '<abbr title="Element Stock OK, Ready for Production" class="green">OK</abbr>'; break; case 'S': $stock_status = $el_link . '<abbr title="Element Stock Need Sourcing" class="red">NS</abbr>'; break; case 'P': $stock_status = $pr_link . '<abbr title="Use Finished Goods Stock" class="green">FG</abbr>'; break; case 'D': if (is_null($order_item_data['depot_orders_id'])) { $stock_status = $dp_link . '<abbr title="Use Depot Stock" class="green">DS</abbr>'; } else { $stock_status = '<a href="?open=depot-order&id=' . $order_item_data['depot_orders_id'] . '&hidemenu=true" class="green view_webpage">DS</a>'; } break; case 'W': $stock_status = $el_link . '<abbr title="Product is using Wholesale Element" class="red">WP</abbr>'; break; default: $stock_status = '<strong class="red">?</strong>'; } $row_data[self::ROW_DATA_STOCK] = $stock_status; } if ($this->filters_status == 3) { $row_data[self::ROW_DATA_PRINTED] = $order_item_data['print_count'] > 0 ? '<img title="Printed ' . $order_item_data['print_count'] . ' time(s)" src="images/icon-tick.png">' : '<img title="Not yet printed" src="images/icon-tick-dis.png">'; $row_data[self::ROW_DATA_SCANNED] = $order_item_data['print_confirmed'] > 0 ? '<img title="Scanned ' . $order_item_data['print_confirmed'] . ' time(s)" src="images/icon-tick.png">' : '<img title="Not yet scanned" src="images/icon-tick-dis.png">'; } //TODO: DEFINE ACTION BUTTON BASED ON SELECTED TAB $row_data[self::ROW_DATA_ACTION] = $action; if ($this->filters_status == 4 && in_array($this->filters_sub_status[0], $this->PROD_SUBSTATUS_USE_LINE)) { $row_data[self::ROW_DATA_STATUS] = strtoupper(statusNameProduction($order_item_data['prod_status'], true)); } //FILL DATA INTO ROW TEMPLATE $row = $this->getRowTemplate($template_row, false, $row_data); $result = ''; if (count($row) > 0) { foreach ($row as $c => $r) { $result .= '<td class="' . $c . '">' . $r . '</td>'; } } return $result; }
$late_order_status = $row['status']; $late_orders .= '<tr class="' . $rowclass . '">'; $late_orders .= '<td style="text-align:center;">' . $no . '</td>'; if ($row['type'] == 'DP') { $order_detail = '<a href="?open=depot-order&id=' . $row['order_items_id'] . '&hidemenu=true" class="view_webpage fancybox">DP-' . $row['order_items_id'] . '</a>'; } elseif ($row['type'] == 'SP') { $order_detail = '<a href="?open=customer-care-order-detail&source=' . $row['type'] . '&id=' . $row['order_id'] . '&hidemenu=true" class="view_webpage">' . $row['type'] . '-' . $row['order_items_id'] . '</a>'; } else { $order_detail = '<a href="?open=order&id=' . $row['order_id'] . '&opid=' . $row['order_items_id'] . '&hidemenu=true class="view_webpage">' . $row['type'] . '-' . $row['order_items_id'] . '</a>'; } $late_orders .= '<td style="text-align:center;">' . $order_detail . '</td>'; $late_orders .= '<td style="text-align:center;">' . displayDuration(strtotime('now') - strtotime($row['leadtime_start_date']), 'day', 1) . '</td>'; if ($row['type'] == 'SP') { $late_orders .= '<td style="text-align:center;">' . $row['sp_name'] . '</td>'; } elseif ($row['type'] == 'DP') { $late_orders .= '<td style="text-align:center;">' . $class_do->translateOrderSource($row['trans_type'], $row['trans_id'], true, null, $row['products_id']) . '</td>'; } else { $late_orders .= '<td style="text-align:center;">JG</td>'; } $late_orders .= '<td style="text-align:center;">' . $row['customers_name'] . '</td>'; $late_orders .= '<td style="text-align:center;"><div>' . webImage($row['products_image'], IMAGE_SIZE_THUMBNAIL_1, IMAGE_SIZE_THUMBNAIL_1, 'Product ' . $row['products_id'], 'img-border') . '</div><a title="View product detail" target="_blank" href="?open=product-detail&products_id=' . $row['products_id'] . '" class="view_webpage">' . $row['products_id'] . '</a></td>'; if ($order_status == '4' && isset($prod_status) && $prod_status != '') { $late_orders .= '<td style="text-align:center;">' . statusNameProduction($prod_status, false, true) . '</td>'; } else { $late_orders .= '<td style="text-align:center;">' . statusNameShort($order_status) . '</td>'; } $status_dropdown = '<select class="order_late_status">' . loadComboListFromArray($orders_late_status, null, $late_order_status, false) . '</select>'; $status_dropdown .= '<input type="hidden" id="opid-' . $row['order_items_id'] . '" name="op_id" value="' . $row['order_items_id'] . '" />'; $late_orders .= '<td style="text-align:center;">' . $status_dropdown . '</td>'; $late_orders .= '<td style="text-align:center;"><input type="hidden" id="opid-issue-' . $row['order_items_id'] . '" name="op_id" value="' . $row['order_items_id'] . '" /><textarea class="issue_text" style="width:200px;height:100px;">' . $row['issue'] . '</textarea></td>'; $late_orders .= "</tr>";
$length = $article == null ? $product['pnc']['products_length'] : $article['length']; $length_text = $length == 0 ? '' : '<tr><td>Product Length</td><td>' . textLength($length) . '</td></tr>'; $group_name = $do['group_name']; if (count($do) == 0) { $content .= '<h3 class="red">Depot Order ' . $order_id . ' is not found in Database'; } else { $statusName = statusNameShort(); $bih_start_date = $do['order_date']; $bih_end_date = null; if ($do['trans_type'] == 'SP') { use_class('jng_sp_orders'); $class_jo = new jng_sp_orders(); $itrans = $class_jo->retrieveItemDetail($do['trans_id']); $otrans = $class_jo->retrieveDetail($itrans['jng_sp_orders_id']); $bih_start_date = $otrans['order_date']; $order_source = $class_do->translateOrderSource($do['trans_type'], $do['trans_id'], false, $itrans['jng_sp_orders_id'], $do['products_id']); } elseif ($do['trans_type'] == 'JG') { use_class('orders'); $class_o = new orders(); $itrans = $class_o->retrieveProductDetail($do['trans_id']); $otrans = $class_o->retrieveDetail($itrans['orders_id']); $bih_start_date = $otrans['date_purchased']; $order_source = $class_do->translateOrderSource($do['trans_type'], $do['trans_id'], false, $itrans['orders_id'], $do['products_id']); } else { $order_source = $class_do->translateOrderSource($do['trans_type'], $do['trans_id'], false, null, $do['products_id']); } $status_date = null; $history = $class_do->retrieveHistory($order_id); $history_prod = retrieveProductionHistory('DP', $order_id); $htable = array(); $ht = array();