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(); }
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>"; $cur++; } } } $table->end(); } else { $table->start("orders_list", "table-bordered"); $table->entry("No orders to display"); $table->end(); } } } require_once 'footer.php';
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(); }
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... }
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(); } }