예제 #1
0
 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);
     }
 }
예제 #2
0
 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);
 }
예제 #3
0
    /**
     * 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];
    }
예제 #4
0
	<div id="root">
		<div id="header">
			<h1><a href="http://<?php 
echo My_Template_Controller::getCurrentSite()->url;
?>
" title="MyChocolateHearts.com - Custom Chocolate Hearts"><img src="/env/images/<?php 
echo My_Template_Controller::getViewPrefix();
?>
/logo.png" alt="MyChocolateHearts.com - Custom Chocolate Hearts"/></a></h1>
<?php 
if (User_Model::logged_in()) {
    $user = User_Model::logged_user();
    ?>
			<div id="login_box" class="logged">
				<a class="logout" href="/customers/logout"><img src="/env/images/login/logout_btn.jpg" /></a>
				Logged in as: <strong><?php 
    echo $user->firstname . ' ' . $user->lastname;
    ?>
</strong><br />
				<a href="/customers/my_account" class="my-account">View My Account Details</a>
			</div>
<?php 
} else {
    ?>
			<div id="login_box" class="login">
				<form method="POST" action="/customers/login">
					<div class="col">
						<img src="/env/images/login/customer_login.jpg" /><br />&nbsp;
					</div>
					<div class="col">
						<input type="text" name="email" value="Type your email." onfocus="if($(this).val()=='Type your email.') $(this).val('');" onblur="if($(this).val()=='') $(this).val('Type your email.');" /><br />
예제 #5
0
            ?>
 
<?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.
예제 #6
0
 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;
 }
예제 #7
0
 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;
 }
예제 #8
0
 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/');
     }
 }