public function sendEmail($eventName, $to, $data, $additional = false) { $events = ORM::factory('event')->where('site_id', My_Template_Controller::getCurrentSite()->id)->where('name', $eventName)->find_all(); foreach ($events as $event) { self::processEvent($event, $data, $to, $additional); } }
public function __construct() { parent::__construct(); //set texts $method = $this->methodNameForSite('setTexts'); $this->{$method}(); }
public function __construct() { parent::__construct(); $this->session = Session::instance(); if (Auth::instance()->logged_in()) { // Set the current user $this->user = $_SESSION['auth_user']; } }
public function getOrderId($justInteger = FALSE) { $result = $this->db->query('SELECT id FROM order_ids WHERE order_id = ' . $this->id); if (count($result) == 0) { return FALSE; } $order_id = $result[0]->id; if (FALSE !== $justInteger) { return $order_id; } return My_Template_Controller::getCurrentSite()->shortname . '1' . sprintf("%04d\n", $order_id); }
/** * Gets a single occasion * * @return array */ public function getOccasionByName($name) { $db = new Database(); $occasion = $db->query('SELECT occasions.name, occasions.headline, occasions.occasions_description_id, occasions_descriptions.* FROM occasions LEFT JOIN occasions_descriptions ON occasions.occasions_description_id = occasions_descriptions.id LEFT JOIN sites_occasions so ON occasions.id = so.occasion_id WHERE occasions_descriptions.title_url = \'' . $name . '\' AND so.site_id = ' . My_Template_Controller::getCurrentSite()->id); return $occasion[0]; }
/** * * @return \Site_Model */ public static function getCurrentSite() { if (NULL == self::$_site) { $results = ORM::factory('site')->where('url', $_SERVER['SERVER_NAME'])->find_all(); if (count($results) != 1) { Kohana::log('error', 'Wrong site configuration on ' . __FILE__ . ' line ' . __LINE__); } self::$_site = $results[0]; if (!self::$_site) { Kohana::log('error', 'Wrong site configuration on ' . __FILE__ . ' line ' . __LINE__); } } return self::$_site; }
/** * Attempts to load a view and pre-load view data. * * @throws Kohana_Exception if the requested view cannot be found * @param string view name * @param array pre-load data * @param string type of file: html, css, js, etc. * @return void */ public function __construct($name = NULL, $data = NULL, $type = NULL) { $prefix = My_Template_Controller::getViewPrefix() . '/'; if (FALSE === strpos($name, $prefix)) { $name = $prefix . $name; } if (is_string($name) and $name !== '') { // Set the filename $this->set_filename($name, $type); } if (is_array($data) and !empty($data)) { // Preload data using array_merge, to allow user extensions $this->kohana_local_data = array_merge($this->kohana_local_data, $data); } }
?> </h3> <p><?php echo $products->short_description; ?> </p> <span class="price">Starting at <?php echo money_format('%.2n', ORM::factory('product', $products->id)->getPriceStartingAt()) . ' per ' . inflector::singular($products->unit); ?> </span> </div><!-- product-deatils --> <a href="/products/show/<?php echo $products->title_url; ?> " class="link-btn"><img src="/env/images/<?php echo My_Template_Controller::getViewPrefix(); ?> /get_started_button.png" alt="Get Started" /></a> </div><!-- box --> <?php } ?> <div class="box grey-border left grey-corner product-box-standard"> <img src="/env/images/mcc/gng_homepage.png" width="100" alt="Grab and Go Products"/> <div class="product-details"> <h3 class="curly">Grab and Go Products</h3> <p> Need it faster? Our Grab n Go chocolate coins are in stock can ship within 2 days. They are a faster and more affordable option with the same quality of all our products. Our Chocolate Coins are the best you have ever tried. Forget about those waxy & gritty chocolates that you are used to. </p> <span class="price">Starting at $ 0.14 per coin</span> </div><!-- product-deatils -->
?> <?php if ($orders_basket->packaging_id != 0) { ?> Packaging: <?php echo $orders_basket->packaging->name; } ?> </li> <?php } ?> </ul> <?php if ($order->site_id == My_Template_Controller::getCurrentSite()->id) { ?> <a href="/orders/order_again/<?php echo $order->id; ?> ">Order Again</a> <?php } else { ?> Please login into <a href="http://<?php echo $order->site->url; ?> "><?php echo $order->site->name; ?> </a> to order again.
public function index() { $db = new Database(); // clean up old orders that are a week or older and are 'Pending' $dat = time(); $lastweek = $dat - 604800; $result = $db->query('DELETE FROM orders WHERE date_modified < ' . $lastweek . ' AND statusID = 1'); // In Kohana, all views are loaded and treated as objects. $this->template->content = new View('homepage'); $this->template->metaDescription = $this->description; $this->template->metaKeywords = $this->keywords; $this->template->metaTitle = $this->title; // getOccasions and getOccasion($id) is a method defined in Occasion_Model $occasions = new Occasion_Model(); $this->template->content->occasionresults = $occasions->getOccasions(); // getProducts is a method defined in Product_Model $products = new Product_Model(); $this->template->content->productresults = $products->getHomepageProducts(); // getLatestTestimonial is a method defined in Testimonial_Model $testimonial = new Testimonial_Model(); $this->template->content->testimonialresult = $testimonial->getLatestTestimonial(); // get the most recently created hearts of each product type $result = $db->query('SELECT orders.id, orders.can_share, orders_baskets.id, orders_baskets.product_id, orders_baskets.designpath, orders_baskets.msg_text1, orders_baskets.msg_text2, fc.name FROM orders INNER JOIN orders_baskets ON orders.id = orders_baskets.order_id LEFT JOIN foil_colors fc ON fc.id = orders_baskets.foil_id WHERE orders.can_share = 1 AND orders_baskets.designpath != "" AND orders_baskets.img_approved = 1 AND orders.statusID IN (2,4,5) AND orders.site_id = ' . My_Template_Controller::getCurrentSite()->id . ' ORDER BY order_date DESC LIMIT 4'); $recentForward = array(); $recentBack = array(); $i = 0; foreach ($result as $recent) { if ($i < 10) { $recentForward[$i] = $recent; } else { $recentBack[$i - 10] = $recent; } $i++; } $this->template->content->recentHearts = $recentForward; $this->template->content->recentHeartsBack = $recentBack; //$result = $db->query('SELECT orders.id, orders.can_share, orders_baskets.id, orders_baskets.product_id, orders_baskets.designpath FROM orders INNER JOIN orders_baskets ON orders.id = orders_baskets.order_id WHERE orders.can_share = 1 AND orders_baskets.designpath != "" AND orders_baskets.img_approved = 1 AND orders.statusID IN (2,4,5) ORDER BY order_date ASC LIMIT 10'); // You can assign anything variable to a view by using standard OOP // methods. In my welcome view, the $title variable will be assigned // the value I give it here. $this->template->title = $this->title; $result = $db->query("SELECT * FROM slides WHERE site_id = '" . My_Template_Controller::getCurrentSite()->id . "'"); $this->template->content->slides = $result; }
public function __construct() { parent::__construct(); $this->session = Session::instance(); }
public function getAllForSite() { $products = array(); foreach (My_Template_Controller::getCurrentSite()->categories as $category) { foreach ($category->products as $product) { if (!isset($products[$product->id])) { $products[$product->id] = $product; } } } return $products; }
public function afterbuild_dynamic() { $data = json_decode($_POST['data'], TRUE); $order = ORM::factory('order')->getCurrentOrder(); $basket = ORM::factory('orders_basket'); $basket->order_id = $order->id; $basket->product_id = $_GET['id']; //flavor if (isset($data['chocolate']) && isset($data['chocolate']['data'])) { $basket->flavor_id = $data['chocolate']['data']; } else { $basket->flavor_id = 1; } //style $basket->style_id = isset($data['style_id']) ? $data['style_id'] : 1; $basket->save(); $__SIDES_SETUP = array(); /* preview */ $filename = 'basket' . $basket->id . '-preview.png'; $pathUrl = '/env/chocolate_designs/'; $path = '..' . $pathUrl; $basket->designpath = $pathUrl . $this->_processBase64($data['preview'], $path, $filename); /* perspectives */ $first = TRUE; foreach ($data['perspectives'] as $perspective) { $sideName = $perspective['description']; if ($first) { $first = FALSE; /* foil colors */ if (isset($perspective['color'])) { foreach ($perspective['color'] as $colorKey => $color) { if ($color['color'] == 'none') { continue; } $data = ORM::factory('orders_baskets_data')->find(0); $data->orders_basket_id = $basket->id; $data->side = 'All'; $data->type = 'Foil'; $data->name = ucfirst(str_replace('Color', '', $colorKey)) . ' Foil Color'; $colors = explode(',', $color['color']); $normalHex = array(); foreach ($colors as $flashHex) { $normalHex[] = substr(trim($flashHex), 2); } $data->data = array('name' => $color['data'], 'color' => implode(',', $normalHex)); $data->save(); } } /* image background */ if (isset($perspective['image'])) { $data = ORM::factory('orders_baskets_data')->find(0); $data->orders_basket_id = $basket->id; $data->side = 'All'; $data->type = 'BGImage'; $data->name = 'Background Image'; $data->data = array('file' => $perspective['image']['image']); $data->save(); } } /* items */ foreach ($perspective['items'] as $item) { /* text */ if ($item['name'] == 'textLine') { if ($item['text'] == '') { continue; } $__SIDES_SETUP[] = $sideName; $text = ORM::factory('orders_baskets_text')->find(0); $text->orders_basket_id = $basket->id; $text->side = $sideName; $text->name = $sideName . ' ' . $item['description']; $text->text = $item['text']; $text->size = $item['size']; if (isset($item['color']) && is_array($item['color'])) { if (isset($item['color']['color'])) { $text->color_hex = $item['color']['color']; } if (isset($item['color']['name'])) { $text->color_hex = $item['color']['name']; } } if ($text->color_hex == '') { $text->color_hex = '000000'; } if ($text->color_name == '') { $text->color_name = 'Black (Default)'; } $text->font = $item['font']; if (isset($item['x'])) { $text->position = 'X: ' . $item['x'] . ' | Y: ' . $item['y']; } if (isset($item['rotation'])) { $text->rotation = $item['rotation']; } $text->save(); /* image */ } else { if ($item['name'] == 'editableImage') { if (FALSE === isset($item['image'])) { continue; } $__SIDES_SETUP[] = $sideName; $image = ORM::factory('orders_baskets_image')->find(0); $image->orders_basket_id = $basket->id; $image->side = $sideName; $image->name = $item['description']; if ($item['image']['type'] == 'file') { $image->file = $item['image']['image']; } else { $filename = 'basket' . $basket->id . '-' . str_replace(' ', '_', $sideName . '-' . $item['description']) . '.png'; $pathUrl = '/env/chocolate_designs/uploaded_images/'; $path = '..' . $pathUrl; $fullpath = $pathUrl . $this->_processBase64($item['image']['image'], $path, $filename); $image->file = $fullpath; $basket->clippath = $fullpath; } if (isset($item['x'])) { $image->position = 'X: ' . $item['x'] . ' | Y: ' . $item['y']; } if (isset($item['rotation'])) { $image->rotation = $item['rotation']; } $image->height = $item['height']; $image->width = $item['width']; $image->save(); } } } } $__SIDES_SETUP = array_unique($__SIDES_SETUP); if (count($__SIDES_SETUP) > 1) { $basket->second_side_fee = 29.0; } $basket->save(); if (My_Template_Controller::getCurrentSite()->packaging == 1) { url::redirect('/shopping_cart/selectPackaging/?basketId=' . $basket->id); } else { url::redirect('/shopping_cart/'); } }