public function listing() { global $db; $collections = $db->select("collections", null, '*', null, "name"); $table = new Tables(); $table->start(); $table->head("name,products #,sm,sm,sm,sm,sm,sm,sm"); if ($collections) { foreach ($collections as $collection) { $badge = $this->test_data($collection); $id = $collection['id']; $count_active = $db->select("products", "`collection_id`='{$id}' AND `deleted` != '1'"); if ($count_active) { $count_active = count($count_active); } $count_deleted = $db->select("products", "`collection_id`='{$id}' AND `deleted` = '1'"); if ($count_deleted) { $count_deleted = " (" . count($count_deleted) . ")"; } $table_entry = $collection['name'] . "||"; $table_entry .= "{$count_active}{$count_deleted}||"; $count_missingBC = $db->select("products", "`collection_id`='{$id}' AND `barcode` IS NULL AND `bc_overide` = '0'"); if ($collection['barcodes'] and $_SESSION['settings']['barcodes'] and $collection['variation_ids'] == null and $count_missingBC) { $table_entry .= $this->button("barcodes.php?c={$id}", "Add Barcodes", "warning") . "||"; } else { $table_entry .= "||"; } if (!$collection['postage'] and $_SESSION['settings']['shipping_api']) { $table_entry .= $this->button("collections.php?c={$id}", "Postage Type Required", "danger") . "||"; } else { $table_entry .= "||"; } $table_entry .= $this->button("images.php?c={$id}", "images", "warning") . "||"; $table_entry .= $this->button("collections.php?c={$id}", "edit", "primary", $badge) . "||"; if ($collection['variation_ids'] == null) { $table_entry .= $this->button("variations.php?c={$id}", "add variations") . "||"; } else { $table_entry .= $this->button("variations.php?c={$id}", "edit variations") . "||"; } $table_entry .= $this->button("products.php?c={$id}&f=analyse", "analyse", "info") . "||"; $table_entry .= $this->button("products.php?c={$id}", "select"); $table->entry($table_entry); } } $table->end(); }
public function process($array = array(), $params = array()) { global $db; $params = array_merge(array('page' => $this->page, 'display_items' => 20, 'render' => false), $params); $table = new Tables(); $start = ($params['page'] - 1) * $params['display_items']; $end = $params['page'] * $params['display_items'] - 1; if (isset($array['headers'])) { $params['render'] = true; $table->start('search-table'); $table->head($array['headers']); $headers = $array['headers']; unset($array['headers']); } $data_slice = array_slice($array, $start, $end); foreach ($data_slice as $data) { unset($table_entry); foreach ($headers as $header) { if ($header !== 'sm') { if (!is_array($data[$header])) { $table_entry[] = $data[$header]; } else { $table_entry[] = "<ul class='list-group'><li class='list-group-item'>" . implode("</li><li class='list-group-item'>", $data[$header]) . "</li></ul>"; } } else { if ($data['type'] == 'collections') { $table_entry[] = $this->button('collections.php?c=' . $data['id'], 'view'); } else { $collection_id = $db->select('products', $data['id'], 'collection_id', 1); $collection_id = $collection_id['collection_id']; $table_entry[] = $this->button("products.php?c={$collection_id}&p=" . $data['id'], 'view'); } } } $table->entry($table_entry); } if ($params['render']) { $table->end(); } return ceil(count($array) / $params['display_items']); }
public function listing() { global $db; $table = new Tables(); $collections = $db->select("collections", null, '*', null, "name"); $table->start(); $table->head("collections,sm,sm"); if ($collections) { foreach ($collections as $key => $collection) { $id = $collection['id']; $name = $collection['name']; $disallow = $db->select("products", "(`filename` IS NULL OR `filename` = '') AND `collection_id` = '{$id}'"); $exporting = $db->select("products", "`exported` = '0' AND `collection_id` = '{$id}'"); $unapproved = $db->select("products", "`exported` = '0' AND `approved` = '0' AND `collection_id` = '{$id}'"); if ($disallow and $this->settings['filenames']) { $ct = count($disallow); // $button = "<a class='btn btn-danger btn-xs text-capitalize' href='export.php?c=$id&filename=prefix'>export using filename prefix</a>"; $button = "<a class='btn btn-primary btn-xs text-capitalize' href='export.php?c={$id}&filename=fix'>export using sku fix</a>"; $button .= "||<a class='btn btn-primary btn-xs text-capitalize' href='export.php?c={$id}&filename=sku'>export using sku override</a>"; } else { if ($exporting) { $count['unapproved'] = $unapproved ? count($unapproved) : 0; $count['exporting'] = $exporting ? count($exporting) : 0; if ($count['unapproved'] == $count['exporting']) { $button = "||<a class='btn btn-warning btn-xs text-capitalize' href='export.php?c={$id}'>awaiting approval <span class='badge'>" . $count['unapproved'] . "</span></a>"; } else { $button = "||<a class='btn btn-primary btn-xs text-capitalize' href='export.php?c={$id}'>export <span class='badge'>" . $count['exporting'] . "</span></a>"; } } else { $button = "||<a class='btn btn-default btn-xs text-capitalize disabled' href=''>export <span class='badge'>0</span></a>"; } } $table->entry("{$name}||{$button}"); } } $table->end(); }
for ($i = $f_cur; $i <= $f_max; $i++) { echo "<td></td>"; } echo "</tr>"; } $table->end(); } } else { $html->title("Order Uploads", null, "left"); echo "<hr />"; $customers = $db->select("users_in_roles INNER JOIN users ON users_in_roles.user_id=users.id", "`role_id`='4'", "users.id,users.username"); $nonarchived = $db->select("uploads INNER JOIN orders ON uploads.order_id=orders.id", "orders.`archive` = '0'", "DISTINCT uploads.order_id"); $table = new Tables(); if ($customers and $nonarchived) { $table->start("orders_list", "table-bordered"); $table->head("Customer ID,Order #/Name,Uploads,sm"); foreach ($customers as $customer) { $oids = $db->select("uploads INNER JOIN orders ON uploads.order_id=orders.id", "uploads.`user_id`='" . $customer['id'] . "' AND orders.`archive` = '0'", "DISTINCT uploads.order_id"); if ($oids) { $count['orders'] = count($oids); $cur = 1; foreach ($oids as $oid) { echo "<tr>"; if ($cur == 1) { echo "<td rowspan='" . $count['orders'] . "'>" . $customer['username'] . "</td>"; } echo "<td>" . $order[$oid['order_id']] . "</td>"; $uploads = count($db->select("uploads", "`user_id`='" . $customer['id'] . "' AND `order_id`='" . $oid['order_id'] . "'")); echo "<td>{$uploads}</td>"; echo "<td><a class='btn btn-primary' href=orders.php?id=" . $oid['order_id'] . " role='button'>View</a></td>"; echo "</tr>";
public function override_toggles($collection_id) { global $db, $form; $table = new Tables(); //start toggle_products form $form->start("variations.php?override={$collection_id}", false, "toggle_products"); //get collection variation ids using collection id (limit 1) $collection = $db->select("collections", "id='{$collection_id}'", "variation_ids", 1); //seperate variation ids (array explode) $variation_ids = explode(";;", $collection['variation_ids']); //for each variation get name & options $form->input("collection id", "collection_id", "text", $collection_id, true); foreach ($variation_ids as $key => $v_id) { $form->input("variation id", "variation_ids[]", "text", $v_id, true); //get variation name & options (limit 1) $variation = $db->select("variations", "id='{$v_id}'", 'name,options', 1); //seperate variation options $variation_options = explode(";;", $variation['options']); //count options $options_count = count($variation_options); //start table making header variation name with colspan = option count $table->start($variation['name'], "option_toggles"); $table->head($variation['name'], $options_count); //start toggle row echo "<tr>"; //for each option make cell include option toggle with name = variationsid[] foreach ($variation_options as $key => $option) { //default to all checked $checked = 1; //create cell echo "<td>"; //create form toggle input $form->input($option, $v_id . "[{$key}]", "toggle", $checked); //end cell echo "</td>"; } //end toggle row echo "</tr>"; //end table $table->end(); } //end form $form->end(); }
public function file_info() { $table = new Tables(); $table->start("import"); $table->head("file info,"); $table->entry("Name:||" . (isset($_FILES['upload']) ? $_FILES['upload']['name'] : "not available")); $table->entry("Size:||" . (isset($_FILES['upload']) ? $_FILES['upload']['size'] : "not available")); $table->entry("Type:||" . (isset($_FILES['upload']) ? $_FILES['upload']['type'] : "not available")); $table->entry("Products:||" . (isset($_FILES['upload']) ? $this->line_count($this->dir . $this->file_name) - 1 : "not available")); $table->end(); }
public function listing($format = null) { global $db, $html; switch ($format) { case 'active': $products_array = $db->select("products", "collection_id = '{$this->collection_id}' AND `deleted` != '1'", '*', null, "sku ASC"); if ($products_array) { foreach ($products_array as $item) { $identifier = preg_replace("/[^0-9]/", "", $item['sku']); $in_array = false; if ($identifier != '') { if (!isset($products[$identifier])) { $products[$identifier] = $item; $in_array = true; } } if (!$in_array) { $products[] = $item; } ksort($products); } } case 'deleted': $products_array = $db->select("products", "collection_id = '{$this->collection_id}' AND `deleted` = '1'"); if ($products_array) { foreach ($products_array as $item) { $products[preg_replace("/[^0-9]/", "", $item['sku'])] = $item; ksort($products); } } break; default: $products_array = $db->select("products", "collection_id = '{$this->collection_id}'"); if ($products_array) { foreach ($products_array as $item) { $products[preg_replace("/[^0-9]/", "", $item['sku'])] = $item; ksort($products); } } break; } $collection = $db->select("collections", "id = '{$this->collection_id}'", "*", 1); $users_array = $db->select("users", null, "id,username"); foreach ($users_array as $key => $user) { $users[$user['id']] = $user['username']; } $table = new Tables(); $table->start(); $table->head("name,sku,made by,last edit,sm,sm,sm"); if (isset($products)) { $counter = 0; foreach ($products as $product) { $options = $db->select("options", "product_id='" . $product['id'] . "'", 'id', 1); $badge = $this->test_data($product, $collection); if (isset($_GET['f']) && $badge > 0 or !isset($_GET['f'])) { $counter++; $table_entry = $product['name'] . "||" . $product['sku'] . "||"; $table_entry .= $users[$product['user_id']] . "||"; $table_entry .= $users[$product['last_edited']] . "||"; if ($collection['variation_ids'] != null and $format == "active") { $table_entry .= $this->button("variations.php?p=" . $product['id'], "manage variations") . "||"; } else { $table_entry .= "||"; } if ($options and $format == "active") { $table_entry .= $this->button("variations.php?default=" . $product['id'], "revert to defaults") . "||"; } else { $table_entry .= "||"; } switch ($format) { case 'deleted': if ($product['exported'] && $_SESSION['admin']) { $table_entry .= $this->button("products.php?c={$this->collection_id}&remove=" . $product['id'], "remove", "danger"); } else { if (!$product['exported']) { $table_entry .= $this->button("products.php?c={$this->collection_id}&r=" . $product['id'], "undo delete", "success"); } } break; default: $table_entry .= $this->button("products.php?c={$this->collection_id}&p=" . $product['id'] . (isset($_GET['f']) ? "&f=" . $_GET['f'] : ''), "edit", "primary", $badge); break; } $table->entry($table_entry); } } if (!$counter) { $table->entry("There are no products with missing details to display."); } } else { $table->entry("There are no products to display."); } $table->end(); }
echo "<div class='row'>"; echo "<div class='col-xs-12'>"; echo "This script will display all php information"; echo "</div>"; echo "</div>"; echo "<br />"; $table = new Tables(); $table->start("linklist", "table-bordered"); $table->head("Scripts,sm"); $entry = "PHP Info||<a href='scripts/phpinfo.php' class='btn btn-primary' role='button'>Run</a>"; $table->entry($entry); $table->end(); echo "</div>"; echo "<div class='well well-lg'>"; echo "<h3>GTIN Fix</h3>"; echo "<div class='row'>"; echo "<div class='col-xs-12'>"; echo "This script change GTIN to EAN and populate products with attribute"; echo "</div>"; echo "</div>"; echo "<br />"; $table = new Tables(); $table->start("linklist", "table-bordered"); $table->head("Scripts,sm"); $entry = "GTIN Fix||<a href='scripts/gtin.php' class='btn btn-primary' role='button'>Run</a>"; $table->entry($entry); $entry = "Brand & Manufacturer Fix||<a href='scripts/brand.php' class='btn btn-primary' role='button'>Run</a>"; $table->entry($entry); $table->end(); echo "</div>"; require_once 'footer.php';
echo '<button type="submit" class="btn btn-primary">Search</button>'; echo '</span>'; echo '</div>'; echo '</div>'; $form->end(); echo "</div>"; echo "</div>"; echo "<hr />"; if (isset($_POST['ref'])) { $ref = $_POST['ref']; $labels = $db->select('royal_mail', "`reference` LIKE '%{$ref}%' OR `uniqueRef` LIKE '%{$ref}%'"); } else { $labels = $db->select('royal_mail', '`error` IS NOT NULL', '*', null, '`error` ASC'); } $table->start(); $table->head(array('id', 'magento order #', 'netdespatch unique reference', 'domestic / international', 'error', 'sm', 'sm')); $displayed_count = 0; if ($labels) { foreach ($labels as $label) { if (!$label['hide'] or isset($ref)) { $uniqueRef_array = explode(' Tracking:', $label['uniqueRef']); $label['uniqueRef'] = $uniqueRef_array[0]; if (isset($uniqueRef_array[1])) { $label['uniqueRef'] .= '<p><img src="data:image/png;base64,' . base64_encode($BCG->getBarcode($uniqueRef_array[1], $BCG::TYPE_CODE_128)) . '"></p>' . $uniqueRef_array[1]; } $displayed_count++; $class = !is_null($label['error']) ? 'danger' : 'primary'; $label['error'] = !is_null($label['error']) ? $label['error'] : 'None'; $label['remove'] = !$label['hide'] ? "<a class='btn btn-function btn-info btn-xs text-capitalize' href='royalmail.php?hide=" . $label['id'] . "'>hide</a>" : ''; $label['cancel'] = is_null($label['error']) ? "<a class='btn btn-function btn-danger btn-xs text-capitalize' href='royalmail.php?ref=" . $label['reference'] . "&api=cancel'>cancel</a>" : ''; unset($label['hide']);
if ($change_approved) { $db->update("products", "approved", $change_approved, $up['id']); } } else { $change_approved = 0; } if (!$change_approved and $pfn and count($da) < $pmax) { $da[$up['id']] = $up; $dimg[$up['id']] = $pfn; } } } $form->start("authorise.php", false, "authorise"); $table->start("authorise", "table-bordered"); if (count($da)) { $table->head("id,product image,product name,sku,made by,last edited by,sm"); foreach ($da as $id => $dp) { $madeby = $db->select("users", $dp['user_id'], '*', 1); $editby = $db->select("users", $dp['last_edited'], '*', 1); $entry = "{$id}<input type='text' class='form-control hidden' name='ids[{$id}]' value='{$id}' />||<img src='" . $dimg[$id] . "' alt='...' class='img-thumbnail'>||<span class='title'>" . $dp['name'] . "</span>||" . $dp['sku'] . "||" . $madeby['username'] . "||" . $editby['username'] . "||"; $entry .= "<div class='form-group'><div class='input-group'><input data-on='Approve' data-off='Delete' type='checkbox' name='toggle[{$id}]' data-toggle='toggle' checked></div></div>"; $table->entry($entry); } $table->end(); sub_menu(); } else { if ($imgu) { $table->entry("Number of products awaiting authorisation that have no images||{$imgu}"); foreach ($fimg as $key => $fi) { if (isset($_SESSION['settings']['filenames'])) { $table->entry($fi['filename'] . "||" . $fi['image']);
public function listing() { global $db, $html; $results = $db->select("users", null, 'id,username'); foreach ($results as $key => $result) { $user[$result['id']] = $result['username']; } $users_roles = $db->select("users_in_roles", null, '*', null, 'role_id'); $results = $db->select("roles"); foreach ($results as $key => $result) { $roles[$result['role_id']] = $result['role']; } $table = new Tables(); foreach ($roles as $key => $role) { $table->start(); $table->head("{$role} users,sm"); $count = 0; foreach ($users_roles as $users_role) { if ($users_role['role_id'] == $key) { $table->entry($user[$users_role['user_id']] . "||" . $this->button("users.php?f=" . $users_role['user_id'], "edit")); $count++; } } $count === 0 ? $table->entry("No users in this role") : ''; $table->end(); } # code... }
} } $count[$tk]['created'] = $products[$tk] ? count($products[$tk]) : '0'; } $tabs->start(); $tabs->start("buttons", "pills"); foreach ($date as $tk => $td) { $tabs->button($tk, false, $tk == "day" ? true : false); } $tabs->end("buttons"); echo "<br />"; $tabs->start("entries", "pills"); foreach ($date as $tk => $td) { $tabs->entry($tk, $tk == "day" ? 1 : 0, true); $table->start($tk . "_report", "table-bordered"); $table->head("Product report, created: " . $count[$tk]['created'] . ", exported: " . $count[$tk]['exported']); foreach ($users as $user) { $count['personal']['exported'] = 0; $count['personal']['created'] = 0; if ($products[$tk]) { foreach ($products[$tk] as $product) { if ($user['id'] == $product['user_id']) { $count['personal']['created']++; if ($product['exported']) { $count['personal']['exported']++; } } } } $table->entry($user['username'] . "||" . $count['personal']['created'] . "||" . $count['personal']['exported']); }
public function process() { global $db; if ($_SESSION['current_page'] == 'filename.php') { $table = new Tables(); $table->start('filename_report'); $table->head('file rename report', 3); } if (isset($_GET['filename'])) { $override = $_GET['filename'] == "sku" ? 1 : 0; $sku_fix = $_GET['filename'] == "fix" ? 1 : 0; } else { $override = $sku_fix = 0; } foreach ($this->products as $key => $product) { $id = $product['id']; $name = $product['name']; $sku = $product['sku']; if ($override) { $filename = $sku; } else { if ($sku_fix) { $str = str_ireplace($this->prefix, '', $product['sku']); $str = ltrim(preg_replace("/[^0-9]/", "", $str), '0'); $filename = $this->generate_name($str); } else { $filename = $this->generate_name($key + 1); } } if ($sku == null) { $sku = $filename; } $class = $sku === $filename ? "active" : null; $db->update("products", "filename,sku", "{$filename}||{$sku}", $id); if ($_SESSION['current_page'] == 'filename.php') { $table->entry("{$name}||{$sku}||{$filename}", $class); } } if ($_SESSION['current_page'] == 'filename.php') { $table->end(); } }