public function rename() { $this->setTemplate('elib://admin/properties.tpl'); if (isset($_GET['id']) && is_numeric($_GET['id'])) { if (isset($_POST['save'])) { $p = Model::load('Property'); $p->id = $_GET['id']; $p->load(); $p->name = $_POST['name']; $p->validates(); if ($p->hasValErrors()) { $this->presenter->assign('property', $p); $this->presenter->assign('errors', $p->getValErrors()); } else { $p->save(Model::getTable('Property'), array(), 1); $this->redirect('admin/properties'); } } else { $p = Model::load('Property'); $p->id = $_GET['id']; $p->load(); $this->presenter->assign('property', $p); } } }
public function __construct($items, $c) { $s = Model::load('ShippingAddress'); $s->id = \Empathy\Session::get('shipping_address_id'); $s->load(); $o = Model::load('OrderItem'); $o->user_id = CurrentUser::getUserID(); $o->status = 'DEFAULT'; $o->stamp = 'MYSQLTIME'; $o->first_name = $s->first_name; $o->last_name = $s->last_name; $o->address1 = $s->address1; $o->address2 = $s->address2; $o->city = $s->city; $o->state = $s->state; $o->zip = $s->zip; $o->country = $s->country; $this->invoice_no = $o->insert(Model::getTable('OrderItem'), 1, array(), 0); if (!defined('ELIB_PAYPAL_TEST_MODE') || defined('ELIB_PAYPAL_TEST_MODE') && !ELIB_PAYPAL_TEST_MODE) { $this->invoice_no = time() . '/' . $this->invoice_no; } $l = Model::load('LineItem'); foreach ($items as $item) { if (is_numeric($item['qty']) && $item['qty'] > 0) { $l->order_id = $this->invoice_no; $l->variant_id = $item['id']; $l->price = $item['price']; $l->quantity = $item['qty']; $l->insert(Model::getTable('LineItem'), 1, array(), 0); } } }
public function getBlogs($tags) { $id = array(); $sql = 'SELECT DISTINCT b.id FROM ' . Model::getTable('BlogItem') . ' b'; $i = 0; foreach ($tags as $tag) { $glue = 't' . ($i + 1); $sql .= ' LEFT JOIN ' . Model::getTable('BlogTag') . ' ' . $glue . ' ON ' . $glue . '.tag_id = ' . $tag; $i++; } $i = 0; foreach ($tags as $tag) { $glue = 't' . ($i + 1); if ($i == 0) { $sql .= ' WHERE'; } else { $sql .= ' AND'; } $sql .= ' b.id = ' . $glue . '.blog_id'; $i++; } $error = 'Could not get active blog ids.'; $result = $this->query($sql, $error); $i = 0; foreach ($result as $row) { $id[$i] = $row['id']; $i++; } return $id; }
public function default_event() { if (isset($_POST['verify'])) { $v = Model::load('Vendor'); $v->id = $_POST['vendor_id']; $v->load(); $u = Model::load('UserItem'); $u->id = $v->user_id; $u->load(); if ($u->active && $v->name != '') { $u->auth = Access::VENDOR; $u->save(Model::getTable('UserItem'), array(), 2); $v->verified = 'MYSQLTIME'; $v->save(Model::getTable('Vendor'), array(), 2); $p = Model::load('ProductItem'); $p->verify($v->id); } $this->redirect('admin/vendors'); } else { $v = Model::load('Vendor'); $select = '*,UNIX_TIMESTAMP(registered) AS registered, t2.id as vendor_id'; $t1 = Model::getTable('UserItem'); $t2 = Model::getTable('Vendor'); $t3 = Model::getTable('ShippingAddress'); $sql = ' WHERE t1.id = t2.user_id AND t1.id = t3.user_id AND t3.default_address = 1'; $page = 1; $per_page = 10; $vendors = $v->getAllCustomPaginateMultiJoin($select, $t1, $t2, $t3, $sql, $page, $per_page); $paginate = $v->getPaginatePagesMultiJoin($select, $t1, $t2, $t3, $sql, $page, $per_page); $this->assign('vendors', $vendors); $this->assign('paginate', $paginate); $this->setTemplate('elib://admin/vendors.tpl'); } }
public function password() { $this->setTemplate('elib:/admin/password.tpl'); if (isset($_POST['submit'])) { $errors = array(); $old_password = md5(SALT . $_POST['old_password'] . SALT); $password1 = $_POST['password1']; $password2 = $_POST['password2']; $u = Model::load('UserItem'); $u->id = Session::get('user_id'); $u->load(); if ($old_password != $u->password) { array_push($errors, 'The existing password you have entered is not correct'); } if ($password1 != $password2) { array_push($errors, 'The new password entered does not match the confirmation'); } if (!ctype_alnum($password1) || !ctype_alnum($password2)) { array_push($errors, 'Please only use alpha and numeric characters for new passwords'); } if (sizeof($errors) < 1) { $u->password = md5(SALT . $password1 . SALT); $u->save(Model::getTable('UserItem'), array(), 0); $this->redirect('admin'); } else { $this->presenter->assign('error', $errors); } } elseif (isset($_POST['cancel'])) { $this->redirect('admin'); } }
public function getAllWithOptionsForProduct($props, $opts) { if (sizeof($props) > 0) { $props_string = '(' . implode(',', $props) . ')'; } $property = array(); $sql = 'SELECT t1.id, t1.name, t2.id AS option_id, t2.option_val FROM ' . Model::getTable('Property') . ' t1 ' . 'LEFT JOIN ' . Model::getTable('PropertyOption') . ' t2 ON t2.property_id = t1.id'; if (isset($props_string)) { $sql .= ' WHERE t1.id IN' . $props_string; } if ($opts != '(0,)') { $sql .= ' AND t2.id IN' . $opts; } $sql .= ' ORDER BY t1.name, t2.option_val'; $error = 'Could not get all properties and options.'; $result = $this->query($sql, $error); if ($result->rowCount() > 0) { foreach ($result as $row) { $id = $row['id']; if (!isset($property[$id]['name'])) { $property[$id]['name'] = $row['name']; } if (isset($row['option_id'])) { $option_id = $row['option_id']; $property[$id]['option'][$option_id] = $row['option_val']; } } } return $property; }
public function getEvents($full, $start_date, $end_date = null) { $events = array(); if ($full) { $select = '*'; } else { $select = 'DAYOFMONTH(start_time) AS dom, event_name, MONTH(start_time) AS month, id'; } $sql = 'SELECT ' . $select . ' FROM ' . Model::getTable('Event') . ' WHERE start_time > \'' . $start_date->getMySQLTime() . '\''; if ($end_date !== null) { $sql .= ' AND start_time < \'' . $end_date->getMySQLTime() . '\''; } $sql .= ' AND status != ' . Status::DELETED; $sql .= ' ORDER BY start_time'; $error = 'Could not get events.'; $result = $this->query($sql, $error); if ($full) { foreach ($result as $row) { array_push($events, $row); } } else { foreach ($result as $row) { $index = sprintf("%02d", $row['month']) . sprintf("%02d", $row['dom']); if (!isset($events[$index])) { $events[$index] = array(); } array_push($events[$index], $row); // $row } } return $events; }
public function upload_image() { $this->setTemplate('elib://admin/promo.tpl'); if (isset($_POST['upload'])) { $_GET['id'] = $_POST['id']; } $p = Model::load('PromoItem'); $p->id = $_GET['id']; $p->load(); $this->presenter->assign("promo", $p); if (isset($_POST['upload'])) { $d = array(array('mid_', 770, 300)); $u = new ImageUpload('', true, $d); if ($u->error != '') { $this->presenter->assign("error", $u->error); } else { if ($p->image != "") { $u->remove(array($p->image)); } // update db $p->image = $u->file; $p->save(Model::getTable('PromoItem'), array(), 2); //$this->redirect_cgi('archive.cgi?id='.$p->id); //$this->execScript('archive', array($p->id)); $this->redirect('admin/promo/' . $p->id); } } }
private function getCommentsFetch($id) { $bc = Model::load('BlogComment'); $sql = ' WHERE t1.user_id = t2.id'; $sql .= ' AND t1.status = 1'; $sql .= ' AND t1.blog_id = ' . $id; $sql .= ' ORDER BY t1.stamp'; return $bc->getAllCustomPaginateSimpleJoin('*,t1.id AS id', Model::getTable('BlogComment'), Model::getTable('UserItem'), $sql, 1, 200); }
public function hasCats($id) { $cats = 0; $sql = 'SELECT id FROM ' . Model::getTable('BlogCategory') . ' WHERE blog_category_id = ' . $id; $error = 'Could not check for existing child categories.'; $result = $this->query($sql, $error); if ($result->rowCount() > 0) { $cats = 1; } return $cats; }
public function update($id, $new_sizes) { $sql = 'DELETE FROM ' . Model::getTable('ContainerImageSize') . ' WHERE container_id = ' . $id; $error = 'Could not clear old image sizes from container.'; $this->query($sql, $error); foreach ($new_sizes as $index => $size_id) { $sql = 'INSERT INTO ' . Model::getTable('ContainerImageSize') . ' VALUES(' . $id . ', ' . $size_id . ')'; $error = 'Could not inert new image size'; $this->query($sql, $error); } }
public function add() { if (isset($_GET['id']) && is_numeric($_GET['id'])) { $p = Model::load('PromoItem'); $p->category_id = $_GET['id']; $p->name = 'New Promo'; $p->hidden = 'DEFAULT'; $id = $p->insert(Model::getTable('PromoItem'), 1, array(), 0); } $this->redirect('admin/promo_category/' . $_GET['id']); }
public function getBios() { $sql = 'SELECT t1.id AS artist_id, t3.id AS product_id, t1.artist_alias,' . ' t1.forename, t1.surname, t1.bio, t3.name, t3.image, t3.category_id, t3.price' . ' FROM ' . Model::getTable('ArtistItem') . ' t1' . ' LEFT JOIN ' . Model::getTable('ProductArtist') . ' t2 ON t2.artist_id = t1.id' . ' LEFT JOIN ' . Model::getTable('ProductItem') . ' t3 ON t3.id = t2.product_id' . ' ORDER BY t1.id'; $error = 'Could not get bios.'; $result = $this->query($sql, $error); $last_artist_id = 0; $bio = array(); $bios = array(); $book = array(); $books = array(); if ($result->rowCount() > 0) { foreach ($result as $row) { if ($last_artist_id != $row['artist_id']) { if (sizeof($books) > 0) { $bio['books'] = $books; $books = array(); } if (sizeof($bio) > 0) { array_push($bios, $bio); $bio = array(); } $last_artist_id = $row['artist_id']; $bio['artist_id'] = $row['artist_id']; $bio['artist_alias'] = $row['artist_alias']; $bio['forename'] = $row['forename']; $bio['surname'] = $row['surname']; if ($row['artist_alias'] == '') { $bio['artist'] = $row['forename'] . ' ' . $row['surname']; } else { $bio['artist'] = $row['artist_alias']; } $bio['bio'] = $row['bio']; } if (isset($row['product_id'])) { if ($row['category_id'] == 14) { $book = array(); $book['id'] = $row['product_id']; $book['image'] = $row['image']; $book['name'] = $row['name']; $book['price'] = $row['price']; array_push($books, $book); } } } } if (sizeof($books) > 0) { $bio['books'] = $books; } if (sizeof($bio) > 0) { array_push($bios, $bio); } return $bios; }
public function getActiveOptions($product_id) { $ids = array(); $sql = 'SELECT DISTINCT property_option_id AS id' . ' FROM ' . Model::getTable('ProductVariantPropertyOption') . ' t1,' . ' ' . Model::getTable('ProductVariant') . ' t2' . ' WHERE t2.id = t1.product_variant_id' . ' AND t2.product_id = ' . $product_id . ' AND t2.status = ' . ProductVariantStatus::AVAILABLE; $error = 'Could not get active option ids for product.'; $result = $this->query($sql, $error); if ($result->rowCount() > 0) { foreach ($result as $row) { array_push($ids, $row['id']); } } return $ids; }
public function getContainerPrefixes($container_id) { $prefix = array(); $sql = 'SELECT prefix FROM ' . Model::getTable('ImageSize') . ' i, ' . Model::getTable('ContainerImageSize') . ' c WHERE c.image_size_id = i.id' . ' AND c.container_id = ' . $container_id; $error = 'Could not get image sizes for container.'; $result = $this->query($sql, $error); if ($result->rowCount() > 0) { foreach ($result as $row) { array_push($prefix, $row['prefix'] . '_'); } } return $prefix; }
public function getPropertiesByCategory($cat) { $categories = '(' . implode(',', $cat) . ')'; $properties = array(); $sql = 'SELECT property_id FROM ' . Model::getTable('CategoryProperty') . ' WHERE category_id IN' . $categories; $error = "Could not find cactive category properties."; $result = $this->query($sql, $error); $i = 0; foreach ($result as $row) { $properties[$i] = $row['property_id']; $i++; } return $properties; }
public function update_timestamps() { // current section $this->section->load(); $this->section->stamp = date('Y-m-d H:i:s', time()); $this->section->save(Model::getTable('SectionItem'), array(), 2); // ancestors => make optional? $ancestors = array(); $ancestors = $this->section->getAncestorIDs($this->section->id, $ancestors); if (sizeof($ancestors) > 0) { $update = $this->section->buildUnionString($ancestors); $this->section->updateTimestamps($update); } }
public function getColoursIndexed($property_id) { $colour = array(); $sql = 'SELECT * FROM ' . Model::getTable('PropertyOption') . ' WHERE property_id = ' . $property_id . ' ORDER BY option_val'; $error = 'Could not get colours.'; $result = $this->query($sql, $error); if ($result->rowCount() > 0) { foreach ($result as $row) { $id = $row['id']; $colour[$id] = $row['option_val']; } } return $colour; }
public function getBrands() { $brand = array(); $brand[0] = 'None'; $sql = 'SELECT * FROM ' . Model::getTable('BrandItem') . ' ORDER BY name'; $error = 'Could not get list of brands.'; $result = $this->query($sql, $error); if ($result->rowCount() > 0) { foreach ($result as $row) { $id = $row['id']; $brand[$id] = $row['name']; } } return $brand; }
public function addAllToIndex() { $b = \Empathy\ELib\Model::load('BlogItem'); $table = $all = $b->getAllCustom(Model::getTable('BlogItem'), ' where status = ' . \Empathy\ELib\Storage\BlogItemStatus::PUBLISHED); $ids = array(); foreach ($all as $item) { array_push($ids, $item['id']); } foreach ($ids as $id) { $b = \Empathy\ELib\Model::load('BlogItem'); $b->id = $id; $b->load(); self::addToIndex($b); } }
public function getForIDs($ids) { $images = array(); $i = 0; foreach ($ids as $item) { $sql = 'SELECT * FROM ' . Model::getTable('BlogImage') . ' WHERE blog_id = ' . $item . ' ORDER BY id'; $error = 'Could not get blog images.'; $result = $this->query($sql, $error); if ($result->rowCount() > 0) { foreach ($result as $row) { $images[$item][$i] = $row; $i++; } } } return $images; }
public function setDefault($user_id, $address_id) { $sql = 'SELECT id FROM ' . Model::getTable('ShippingAddress') . ' WHERE user_id = ' . $user_id; $error = 'Could not get all shipping addresses for user.'; $result = $this->query($sql, $error); $addresses = array(); foreach ($result as $row) { array_push($addresses, $row['id']); } if (in_array($address_id, $addresses)) { $sql = 'UPDATE ' . Model::getTable('ShippingAddress') . ' SET default_address = 0 WHERE user_id = ' . $user_id; $error = 'Could not wipe defaults.'; $this->query($sql, $error); $sql = 'UPDATE ' . Model::getTable('ShippingAddress') . ' SET default_address = 1 WHERE id = ' . $address_id; $error = 'Could not set new default'; $this->query($sql, $error); } }
public function getDataFiles() { $images = array(); $ids = array(); $sql = 'SELECT id from ' . Model::getTable('DataItem') . ' d,' . Model::getTable('ContainerImageSize') . ' c WHERE c.image_size_id = ' . $this->id . ' AND c.container_id = d.container_id'; $error = 'Could not get data item containers that are using selected image size.'; $result = $this->query($sql, $error); foreach ($result as $row) { $ids[] = $row['id']; } if (sizeof($ids) > 0) { $sql = 'SELECT image FROM ' . Model::getTable('DataItem') . ' WHERE data_item_id IN' . $this->buildUnionString($ids); $error = 'Could not got images matching image size.'; $result = $this->query($sql, $error); foreach ($result as $row) { $images[] = $row['image']; } } return $images; }
public function getOrders() { $order = array(); $sql = 'SELECT t3.id AS order_id, username, t2.status, stamp, SUM(t4.price) AS total' . ' FROM ' . Model::getTable('UserItem') . ' t1, ' . Model::getTable('OrderStatus') . ' t2, ' . Model::getTable('OrderItem') . ' t3' . ' LEFT JOIN ' . Model::getTable('LineItem') . ' t4 ON t4.order_id = t3.id' . ' WHERE t1.id = t3.user_id AND t2.id = t3.status' . ' GROUP BY t3.id' . ' ORDER BY stamp DESC'; $error = 'Could not get orders.'; $result = $this->query($sql, $error); if ($result->rowCount() > 0) { foreach ($result as $row) { $item = array(); $item['id'] = $row['order_id']; $item['username'] = $row['username']; $item['stamp'] = $row['stamp']; $item['status'] = $row['status']; if ($row['total'] == '') { $row['total'] = 0; } $item['total'] = $row['total']; array_push($order, $item); } } return $order; }
public function confirm_reg() { $reg_code = $_GET['code']; $u = Model::load('UserItem'); $id = $u->findUserForActivation($reg_code); if ($id > 0) { $u->id = $id; $u->load(); $password = $u->password; $u->password = md5(SALT . $password . SALT); $u->active = 1; $u->activated = 'MYSQLTIME'; $u->save(Model::getTable('UserItem'), array(), 0); Session::set('user_id', $u->id); $message = "\nHi ___,\n\n" . "Thanks for confirming your registration. You can now log in to the " . ELIB_EMAIL_ORGANISATION . " website using your username " . " '___' and the password '" . $password . "'.\n\nCheers\n\n"; $r[0]['alias'] = $u->username; $r[0]['address'] = $u->email; $m = new Mailer($r, 'Welcome to ' . ELIB_EMAIL_ORGANISATION, $message, ELIB_EMAIL_FROM); $this->redirect('user/thanks/2'); } else { throw new \Exception('Unable to activate user.'); } }
public function add_event() { if (isset($_POST['submit'])) { $time = array('day' => $_POST['start_day'], 'month' => $_POST['start_month'] + 1, 'year' => $_POST['start_year'], 'hour' => $_POST['start_hour'], 'minute' => $_POST['start_minute'], 'second' => 0); $start = new DateTime($time); $time = array('day' => $_POST['end_day'], 'month' => $_POST['end_month'] + 1, 'year' => $_POST['end_year'], 'hour' => $_POST['end_hour'], 'minute' => $_POST['end_minute'], 'second' => 0); $end = new DateTime($time); $e = Model::load('Event'); if (!$start->getValid()) { $e->addValError('invalid start date', 'start_time'); } if (!$end->getValid()) { $e->addValError('invalid end date', 'end_time'); } $e->user_id = CurrentUser::getUserID(); $e->start_time = $start->getMySQLTime(); $e->end_time = $end->getMySQLTime(); if ($end->getTime() <= $start->getTime()) { $e->addValError('invalid end date/time', 'end_time'); } $e->event_name = $_POST['event_name']; $e->short_desc = $_POST['short_desc']; $e->long_desc = $_POST['long_desc']; $e->tickets_link = $_POST['tickets_link']; $e->event_link = $_POST['event_link']; $e->status = 'DEFAULT'; $e->validates(); if ($e->hasValErrors()) { $e->start_day = $_POST['start_day']; $e->start_month = $_POST['start_month']; $e->start_year = $_POST['start_year']; $e->start_hour = $_POST['start_hour']; $e->start_minute = $_POST['start_minute']; $e->end_day = $_POST['end_day']; $e->end_month = $_POST['end_month']; $e->end_year = $_POST['end_year']; $e->end_hour = $_POST['end_hour']; $e->end_minute = $_POST['end_minute']; $this->assign('event', $e); $this->assign('errors', $e->getValErrors()); } else { $e->insert(Model::getTable('Event'), 1, array(), 1); $this->redirect('admin/events'); } } elseif (isset($_POST['cancel'])) { $this->redirect('admin/events'); } else { $e = Model::load('Event'); // default (mostly empty) event $date = $this->filterInt('date'); if (strlen($date) != 8) { $date = 0; } if ($date != 0) { $y = substr($date, 0, 4); $m = substr($date, 4, 2); $d = substr($date, 6, 2); $time = mktime(0, 0, 0, $m, $d, $y); $e->start_day = $d; $e->start_month = $m - 1; $e->start_year = $y; $e->start_hour = 20; $e->start_minute = 0; $e->end_day = $d; $e->end_month = $m - 1; $e->end_year = $y; $e->end_hour = 20; $e->end_minute = 0; $this->assign('event', $e); } } $this->assignEventDefs(); $this->setTemplate('elib://admin/add_event.tpl'); }
public function getArchive() { $archive = array(); /* $sql = 'SELECT MAX(UNIX_TIMESTAMP(stamp)) AS max,' .' MIN(UNIX_TIMESTAMP(stamp)) AS min' .' FROM '.Model::getTable('BlogItem'); */ $sql = 'SELECT id, YEAR(stamp) AS year, MONTH(stamp) AS month,' . ' MONTHNAME(stamp) AS monthname, heading FROM ' . Model::getTable('BlogItem') . ' WHERE status = 2 ORDER BY stamp DESC'; $error = 'Could not get blog archive.'; $result = $this->query($sql, $error); foreach ($result as $row) { $year = $row['year']; $month = $row['monthname']; $id = $row['id']; $archive[$year][$month][$id] = ucwords($row['heading']); } return $archive; // print_r($archive); // $max = $row['stamp']; /* $sql = 'SELECT MIN(UNIX_TIMESTAMP(stamp)) AS stamp FROM '.Model::getTable('BlogItem'); $result = $this->query($sql, $error); $row = $result->fetch(); $max = $row['stamp']; */ }
public function getArchive($cat = null) { $cat_blogs_string = $this->getCategoryBlogs($cat); $archive = array(); /* $sql = 'SELECT MAX(UNIX_TIMESTAMP(stamp)) AS max,' .' MIN(UNIX_TIMESTAMP(stamp)) AS min' .' FROM '.Model::getTable('BlogItem'); */ $sql = 'SELECT id, YEAR(stamp) AS year, MONTH(stamp) AS month,' . ' MONTHNAME(stamp) AS monthname,' . ' DAY(stamp) AS day,' . ' slug,' . ' heading FROM ' . Model::getTable('BlogItem') . ' WHERE status = 2'; if ($cat_blogs_string != '') { $sql .= ' AND id IN' . $cat_blogs_string; } $sql .= ' ORDER BY stamp DESC'; $error = 'Could not get blog archive.'; $result = $this->query($sql, $error); foreach ($result as $row) { $year = $row['year']; $month = $row['monthname']; $id = $row['id']; //$archive[$year][$month][$id] = ucwords($row['heading']); $archive[$year][$month][$id]['heading'] = ucwords($row['heading']); $archive[$year][$month][$id]['day'] = str_pad($row['day'], 2, '0', STR_PAD_LEFT); $archive[$year][$month][$id]['slug'] = $row['slug']; $archive[$year][$month][$id]['month_slug'] = strtolower(substr($month, 0, 3)); } // print_r($archive); return $archive; // print_r($archive); // $max = $row['stamp']; /* $sql = 'SELECT MIN(UNIX_TIMESTAMP(stamp)) AS stamp FROM '.Model::getTable('BlogItem'); $result = $this->query($sql, $error); $row = $result->fetch(); $max = $row['stamp']; */ }
public function loadIDByName($name) { $id = 0; $sql = 'SELECT id FROM ' . Model::getTable('ProductItem') . ' WHERE name LIKE \'' . str_replace('-', ' ', $name) . '\''; echo $sql; $error = 'Could not get product id by name.'; $result = $this->query($sql, $error); if ($result->rowCount() == 1) { $row = $result->fetch(); $id = $row['id']; } return $id; }
public function variantProperties() { //$this->setTemplate('elib://admin/product.tpl'); //$this->assertID(); if (isset($_POST['cancel'])) { $v = Model::load('ProductVariant'); $v->id = $_GET['id']; $v->load(); $this->c->redirect('storeadmin/product/' . $v->product_id); } elseif (isset($_POST['save'])) { $p = Model::load('ProductVariantPropertyOption'); $p->emptyByVariant($_GET['id']); $p->product_variant_id = $_GET['id']; //if(isset($_POST['property'])) // { foreach ($_POST['property'] as $index => $item) { if ($item > 0 && is_numeric($item)) { $p->property_option_id = $item; $p->insert(Model::getTable('ProductVariantPropertyOption'), 1, array(), 0); } } // } $v = Model::load('ProductVariant'); $v->id = $_GET['id']; $v->load(); $this->c->redirect('storeadmin/product/' . $v->product_id); } $v = Model::load('ProductVariant'); $v->id = $_GET['id']; $v->load(); $p = Model::load('ProductItem'); $p->id = $v->product_id; $p->load(); $c = Model::load('CategoryItem'); $cats = $c->getAncestorIds($p->category_id, array()); $cp = Model::load('CategoryProperty'); array_push($cats, $p->category_id); $props = $cp->getPropertiesByCategory($cats); //array_push($props, 2); // always allow colour property $this->c->assign('product', $p); $this->c->assign('variant', $v); if (sizeof($props) > 0) { $property = Model::load('Property'); $properties = $property->getAllWithOptions($props); $this->c->assign('properties', $properties); $pv = Model::load('ProductVariantPropertyOption'); $sql = ' WHERE product_variant_id = ' . $_GET['id']; $options = $pv->getAllCustom(Model::getTable('ProductVariantPropertyOption'), $sql); $o = array(); foreach ($options as $index => $value) { array_push($o, $value['property_option_id']); } $this->c->assign('options', $o); } }