function display_cart($cart) { $cell_colour = "#DDFFFF"; table_start(); table_row_start(); table_cell('<b>Product</b>', $cell_colour); table_cell('<b>Quantity</b>', $cell_colour); table_cell('<b>Price</b>', $cell_colour); table_row_end(); $total = 0; foreach ($cart->item as $value) { table_row_start(); table_cell($value->description); table_cell($value->quantity); table_cell($value->price * $value->quantity); $total += $value->price * $value->quantity; table_row_end(); } table_row_start(); table_cell(''); table_cell('<b> Total </b>', $cell_colour); table_cell("<b>{$total}<b>", $cell_colour); table_row_end(); table_end(); }
function display_orders($status) { $warehouse = SCA::getService('../WarehouseService/WarehouseService.php'); $orders = $warehouse->getOrdersByStatus($status); if (count($orders->order) == 0) { echo "None\n"; return; } include_once "./table.php"; table_start(); table_row_start(); table_cell('<b>Order ID</b>', '#DDDDFF'); table_cell('<b>Name</b>', '#DDDDFF'); table_cell('<b>Status</b>', '#DDDDFF'); table_row_end(); $odd = false; foreach ($orders->order as $order) { table_row_start(); if (!$odd) { table_cell("<a href=\"./order_details.php?orderId=" . $order->orderId . "\">" . $order->orderId . "</a>"); table_cell(isset($order->customer->name) ? $order->customer->name : 'no name supplied'); table_cell($order->status); } else { table_cell("<a href=\"./order_details.php?orderId=" . $order->orderId . "\">" . $order->orderId . "</a>", '#DDFFFF'); table_cell(isset($order->customer->name) ? $order->customer->name : 'no name supplied', '#DDFFFF'); table_cell($order->status, '#DDFFFF'); } $odd = !$odd; table_row_end(); } table_end(); }
function display_catalog($catalog) { table_start(); table_row_start(); table_cell('Product'); table_cell('Price'); table_row_end(); foreach ($catalog->item as $value) { table_row_start(); table_cell('<a href="view_product.php?product_code=' . $value->itemId . '">' . $value->description . '</a>'); table_cell($value->price); table_row_end(); } table_end(); }
function display_customer($customer) { table_start(); table_row_start(); table_cell('<b>Name</b>', '#DDFFFF'); table_cell(isset($customer->name) ? $customer->name : 'no name supplied'); table_row_end(); $address_labels = array('Street', 'City', 'State', 'Zip'); $i = 0; foreach ($customer->shipping as $value) { table_row_start(); table_cell('<b>' . $address_labels[$i++] . '</b>', '#DDFFFF'); table_cell($value); table_row_end(); } table_end(); }
function display_events($events) { include_once "table.php"; table_start(); table_row_start(); table_cell('<b>Date</b>', '#DDDDFF'); table_cell('<b>Status</b>', '#DDDDFF'); table_cell('<b>Description</b>', '#DDDDFF'); table_row_end(); foreach ($events->event as $event) { table_row_start(); table_cell($event->timeStamp); table_cell($event->status); table_cell($event->description); table_row_end(); } table_end(); }
function table($header, $rows, $attrArray = array()) { $attributes = ''; foreach ($attrArray as $key => $value) { $attributes .= " {$key}=\"{$value}\""; } $output = "<table{$attributes}>\n"; /* ** Emit the table header: */ if (is_array($header)) { $output .= "<tr>"; foreach ($header as $cell) { if (is_array($cell) && $cell["field"]) { $cell = tablesort($cell, $header); } $output .= table_cell($cell, 1); } $output .= "</tr>\n"; } /* ** Emit the table rows: */ if (is_array($rows)) { foreach ($rows as $number => $row) { if (array_key_exists('alternate-colours', $attrArray) && $attrArray['alternate-colours']) { if ($number % 2 == 1) { $output .= "<tr class=\"light\">"; } else { $output .= "<tr class=\"dark\">"; } } else { $output .= "<tr>"; } foreach ($row as $cell) { $output .= table_cell($cell, 0); } $output .= "</tr>\n"; } } $output .= "</table>\n"; return $output; }
/** * @Implement of hook_template_framework_x() */ function bootstrap_template_framework_table(array $header, $rows = array(), array $attributes = array(), $caption = NULL, $sub_header = NULL) { if (!empty($attributes['class'])) { $attributes['class'] .= ' table table-bordered table-condensed'; } else { $attributes['class'] = 'table table-bordered table-condensed'; } $output = '<table' . dd_attributes($attributes) . ">\n"; if (isset($caption)) { $output .= '<caption>' . $caption . "</caption>\n"; } if (!empty($header)) { $ts = table_init($header); if (!empty($rows)) { $output .= '<thead>'; } $output .= '<tr>'; foreach ($header as $cell) { $cell = table_header($cell, $header, $ts); $output .= _theme_table_cell($cell, true); } $output .= '</tr>'; if (!empty($sub_header)) { foreach ($sub_header as $row) { $attributes = array(); if (isset($row['data'])) { foreach ($row as $key => $value) { if ($key == 'data') { $cells = $value; } else { $attributes[$key] = $value; } } } else { $cells = $row; } $i = 0; $output .= '<tr' . dd_attributes($attributes) . '>'; foreach ($cells as $cell) { $cell = table_cell($cell, $header, $ts, $i++); $output .= _theme_table_cell($cell, true); } $output .= '</tr>'; } } if (!empty($rows)) { $output .= '</thead>'; } } else { $ts = array(); } if (!empty($rows)) { $output .= "<tbody>\n"; $flip = array('even' => 'odd', 'odd' => 'even'); $class = 'even'; foreach ($rows as $number => $row) { $attributes = array(); if (isset($row['data'])) { foreach ($row as $key => $value) { if ($key == 'data') { $cells = $value; } else { $attributes[$key] = $value; } } } else { $cells = $row; } if (count($cells)) { $class = $flip[$class]; if (isset($attributes['class'])) { $attributes['class'] .= ' ' . $class; } else { $attributes['class'] = $class; } $output .= ' <tr' . dd_attributes($attributes) . '>'; $i = 0; foreach ($cells as $cell) { $cell = table_cell($cell, $header, $ts, $i++); $output .= _theme_table_cell($cell); } $output .= " </tr>\n"; } } $output .= "</tbody>\n"; } $output .= "</table>\n"; return $output; }