$table = new fu_HTML_Table(array('width' => '100%')); $table->setAutoGrow(true); $table->setAutoFill("—"); $header_row = array('title' => 'Bundle Name', 'base_price' => 'Base', 'qty_inventory' => 'On hand'); $table_ordercol = isset($_GET['by']) ? $_GET['by'] : 'title'; $order_dir = (!isset($_GET['dir']) or $_GET['dir'] == 'A') ? 'ASC' : 'DESC'; /** decide on which result page to show **/ $bundle->set_range($rows_per_page); $offset = isset($_GET['page']) ? $rows_per_page * $_GET['page'] - 1 : 0; $bundle->set_offset($offset); /** **/ $have_table = false; $cols = array_merge(array('id'), array_keys($header_row)); if ($rows = $bundle->fetch_any($cols, 0, 0, $table_ordercol, null, $order_dir)) { $have_table = true; $table->addSortRow($header_row, $table_ordercol, null, 'TH', '', $order_dir); foreach ($rows as $row) { $class = 'controlListingRow'; $link = sprintf('%s?op_edit=%d', $_SERVER['PHP_SELF'], $row['id']); unset($row['id']); $table->addRow(array_values($row), $class, true, $link); } } $pager = new res_pager($offset, $rows_per_page, $bundle->numRows); $smarty->assign('pager', $pager); } /*}}}*/ /* decide which tab to show based on GET param 'win' */ $tabs = array('product', 'inventory', 'media', 'options'); if ($ACTION == OP_EDIT && isset($_GET['win']) && in_array($_GET['win'], $tabs)) { $tab = $_GET['win'];
$header_row = array(); if (!isset($dbc->control_header_cols)) { foreach ($colmap as $k => $v) { $header_row[$k] = $v[0]; } } else { $header_row =& $dbc->control_header_cols; } if (isset($_GET['by'])) { $orby = $_GET['by']; if (in_array($orby, array_keys($header_row))) { $table_ordercol = $orby; } } $odir = (!isset($_GET['dir']) or $_GET['dir'] == 'A') ? 'A' : 'D'; $table->addSortRow($header_row, $table_ordercol, null, 'TH', "class={$class}", $odir); // add the primary key if its not in the cols described by header_row $scols = array_keys($header_row); if (!in_array($dbc->get_pk_col(), $scols)) { $scols[] = $dbc->get_pk_col(); } if ($rows = $dbc->fetch_any($scols, 0, 0, $table_ordercol, '', $odir)) { foreach ($rows as $row) { $vals = array(); foreach ($header_row as $k => $v) { /* SELECT clause may need tableid.colid syntax - but the DB dont return the tableid part. */ if (strpos($k, '.') !== false) { $k = substr($k, strrpos($k, '.') + 1); } /* special hack for colorpickers - show a block of color */
$header_row[$k] = $user->colmap[$k][0]; } } } else { $header_row =& $user->control_header_cols; $cols = array_keys($user->control_header_cols); } if (isset($_GET['by']) and (in_array($_GET['by'], $cols) or $_GET['by'] == 'num_orders')) { $orderby = $_GET['by']; } else { $orderby = 'email'; } $orderdir = (isset($_GET['dir']) and $_GET['dir'] == 'D') ? 'DESC' : 'ASC'; $cols = array_keys($header_row); $header_row['num_orders'] = '#Orders'; $table->addSortRow($header_row, $orderby, null, 'TH', null, $orderdir); /** decide how to filter the results */ $where = "1=1"; if (isset($_GET['op_filter'])) { $w = array(); if (!empty($_GET['f_perms'])) { $w[] = sprintf('perms = %s', $pdb->quoteSmart($_GET['f_perms'])); } if (!empty($_GET['f_email'])) { $w[] = sprintf('email LIKE %s', preg_replace('/[%*]+/', '%%', $pdb->quoteSmart($_GET['f_email']))); } if (count($w)) { $where = join(' AND ', $w); } } /** **/
$sql = sprintf("SELECT COUNT(*) FROM cm_products_categories WHERE cm_categories_id = %d", $catid); $product_count = $pdb->getOne($sql); if ($product_count) { $confirm_msg = "There are {$product_count} products that are in this category. If you delete the category, they may be hidden from customers. Are you sure?"; } else { $confirm_msg = 'This will remove this category from the site permanently. Are you sure?'; } $fex->add_element('op_kill', array(OP_KILL, 'submit', null, null, 'onclick="return confirm(\'' . $confirm_msg . '\')"')); } } else { /** list all cm_categories in one big ass dump using HTML_Table **/ $table = new fu_HTML_Table(array("width" => "600")); $table->setAutoGrow(true); $table->setAutoFill("n/a"); $header_row = array('name' => 'Name', 'shipType' => 'Ship Class', 'taxable' => 'Tax', 'iLevel' => 'Level', 'is_active' => 'live?', 'feature_rank' => 'Feature Rank', 'order_weight' => 'Order Weight', 'product_count' => '#Products'); $table->addSortRow($header_row, null, null, 'TH', null); $sql = "SELECT c.id, c.name, c.ship_class_id, c.is_taxable, c.level, c.is_active, c.parent_cat_id, c.feature_rank, c.order_weight\n , COUNT(pc.cm_products_id) AS product_count\n , IFNULL(CONCAT(cat.name, ':', c.name), c.name) AS concat_name\n FROM {$tablename} c \n LEFT JOIN cm_products_categories pc ON (pc.cm_categories_id = c.id)\n LEFT JOIN cm_categories cat ON (cat.id = c.parent_cat_id)\n GROUP BY (c.id)\n ORDER BY c.order_weight, concat_name"; $res = $pdb->query($sql); while ($row = $res->fetchRow()) { $vals = array($row['concat_name'], $shipTypes[$row['ship_class_id']], $row['is_taxable'] ? 'Y' : 'N', $row['level'] == 0 ? 'top' : 'sub', $row['is_active'] ? 'Y' : 'N', $row['feature_rank'] ? $row['feature_rank'] : '-', $row['order_weight'], $row['product_count']); $link = sprintf('%s?cat=%d', $_SERVER['PHP_SELF'], $row['id']); $table->addRow($vals, '', null, $link); } $numrows = $res->numRows(); } ############################################################################## # output template ############################################################################## $smarty->display('control/header.tpl'); ?>
} else { foreach ($colmap as $k => $v) { $header_row[$k] = $v[0]; } } $table_ordercol = $dbc->col_orderby_def; if (isset($_GET['by'])) { $table_ordercol = $_GET['by']; } if (isset($_GET['dir'])) { $order_dir = $_GET['dir'] == 'D' ? 'DESC' : 'ASC'; } else { $order_dir = $dbc->dir_orderby_def; } if (!$dbc->suppress_control_nav) { $table->addSortRow($header_row, $table_ordercol, null, 'TH', $base_get_vars, $order_dir); } $where = ''; if ($dbc->get_table_name() == 'ccom_content') { $where = "page_id = '{$page_id}'"; } elseif ($dbc->parent_id_col) { $where = $dbc->parent_id_col . "= '{$page_parent_id}'"; } $cols = array_keys($header_row); array_push($cols, 'id'); if ($rows = $dbc->fetch_any($cols, 0, 0, $table_ordercol, $where, $order_dir)) { foreach ($rows as $row) { $link = sprintf('%s?%s&op_edit=%d', $_SERVER['PHP_SELF'], $base_get_vars, $row['id']); $cells = array(); foreach (array_keys($header_row) as $k) { $cells[] = strlen($row[$k]) < 129 ? $row[$k] : substr(htmlspecialchars($row[$k]), 0, 128) . '...';
$csv = new CSV_Table_Fu(); $csv->show_cols = $cols; $csv->print_csv_headers(SITE_DOMAIN_NAME . '-inventory_dump.csv'); $csv->dumpall($inv); exit; } $range = 50; $offset = isset($_GET['page']) ? ($_GET['page'] - 1) * $range : 0; /** go get im **/ $report = $prod->fetch_inventory_report($pid, $orby, $order_dir, $offset, $range, $filter_cat_id); /** list all cm_categories in one big ass dump using HTML_Table **/ $table = new fu_HTML_Table(array('width' => '90%', 'align' => 'center', 'style' => 'padding-top: 25px')); $table->setAutoGrow(true); $table->setAutoFill("-"); $xgets = $mosh->make_get_params($_GET, array('by', 'dir')); $table->addSortRow($header_row, $orby, null, 'TH', $xgets, $order_dir); $sep = strpos($_SERVER['REQUEST_URI'], '?') === false ? '?' : '&'; $csv_link = $_SERVER['REQUEST_URI'] . $sep . 'op_csv'; foreach ($report as $row) { $vals = array(); $link = null; if (isset($link_fmt)) { $args = array(); foreach ($link_vals as $v) { $args[] = $row[$v]; } $link = vsprintf($link_fmt, $args); } foreach (array_keys($header_row) as $k) { $vals[] = $row[$k]; }
} } elseif ($ACTION == OP_KILL) { $download->set_id($thisid); if ($download->kill()) { $msg = $thing . ' has been deleted.'; } } if (!empty($msg) and !count($errs)) { /** redir on success **/ header(sprintf("Location: %s?pid=%d&msg=%s", $_SERVER['PHP_SELF'], $productid, base64_encode($msg))); exit; } if (!$ACTION) { $table = new fu_HTML_Table(array('width' => '90%', 'align' => 'center')); $header_row = array('name' => 'Name', 'url' => 'URL', 'is_active' => 'Active?'); $table->addSortRow($header_row); $numrows = 0; if ($downloads = $download->fetch_by_product_id($productid)) { foreach ($downloads as $row) { $vals = array(); $row['url'] = sprintf('<a href="%s">%s</a>', $row['url'], $row['url']); foreach (array_keys($header_row) as $k) { $vals[] = $row[$k]; } // store.edit.php?nid=444 $link = sprintf('%s?op_edit=%d&pid=%d', $_SERVER['PHP_SELF'], $row['id'], $productid); $table->addRow($vals, null, true, $link); } $numrows = count($downloads); } }
$res = $pdb->query($sql); /** list all cm_categories in one big ass dump using HTML_Table **/ /** list all cm_categories in one big ass dump using HTML_Table **/ if (isset($_GET['op_csv'])) { $table = new CSV_Table_Fu(); $csv_headers = array(); foreach ($header_row as $k => $v) { $csv_headers[] = preg_replace('/<[^>]+>/', " ", $v); } $table->addSortRow(array_values($csv_headers)); } else { $table = new fu_HTML_Table(array("id" => "reports")); $table->setAutoGrow(true); $table->setAutoFill("-"); $xgets[] = "report={$ACTION}"; $table->addSortRow($header_row, $fake_orby, null, 'TH', join('&', $xgets), $order_dir); #$tfoot = $table->getFooter(); #$tfoot->addRow(array_values($header_row)); $sep = strpos($_SERVER['REQUEST_URI'], '?') === false ? '?' : '&'; $csv_link = $_SERVER['REQUEST_URI'] . $sep . 'op_csv'; } while ($row = $res->fetchRow()) { $vals = array(); $link = null; if (isset($link_fmt)) { $args = array(); foreach ($link_vals as $v) { $args[] = $row[$v]; } $link = vsprintf($link_fmt, $args); }