Exemple #1
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 />
 public function paypal_ok()
 {
     $trans_id = $this->input->get('token');
     // In Kohana, all views are loaded and treated as objects.
     $this->template->content = new View('paypal_status');
     $postvars = $_POST;
     $db = new Database();
     $result = $db->query('SELECT * FROM orders WHERE trans_id = \'' . $trans_id . '\'');
     $order = $result[0];
     $this->template->content->_order = ORM::factory('order', $order->id);
     //CREATE PAYMENT
     $result = $db->query('INSERT INTO payments (transaction_number, statusID, transaction_date) VALUES (\'' . $trans_id . '\', 3, ' . time() . ')');
     $paymentid = mysql_insert_id();
     //CREATE Order ID Entry
     $_res = $db->query('SELECT id FROM order_ids WHERE order_id="' . $order->id . '"');
     if (!$_res[0] || !$_res[0]->id) {
         //CREATE Order ID Entry
         $_res = $db->query('INSERT INTO order_ids (order_id) VALUES (' . $order->id . ')');
         $new_order_id = mysql_insert_id();
     } else {
         $new_order_id = $_res[0]->id;
     }
     //UPDATE THE ORDER TABLE
     $result = $db->query('UPDATE orders SET paymentID = ' . $paymentid . ', payment_method = "PayPal", statusID = 2, order_total= ' . $order->subtotal . ', shipping_total = ' . $order->shipping_total . ', order_date = \'' . date("Y-m-d H:i:s", time()) . '\', date_modified = ' . time() . ' WHERE id = ' . $order->id . '');
     $result = $db->query('SELECT orders.*, users.email, user_billing_infos.firstname as billfname, user_billing_infos.lastname as billlname, user_billing_infos.address1 as billaddress, user_billing_infos.city as billcity, user_billing_infos.state as billstate, user_billing_infos.zip as billzip, user_billing_infos.country as billcountry, user_billing_infos.phone1 as billphone, user_shipping_infos.firstname as shipfname, user_shipping_infos.lastname as shiplname, user_shipping_infos.address1 as shipaddress, user_shipping_infos.city as shipcity, user_shipping_infos.state as shipstate, user_shipping_infos.zip as shipzip, user_shipping_infos.country as shipcountry FROM orders LEFT JOIN user_billing_infos ON orders.billingID = user_billing_infos.id LEFT JOIN user_shipping_infos ON orders.shippingID = user_shipping_infos.id LEFT JOIN users ON orders.user_id = users.id WHERE orders.id = ' . $order->id . '');
     $order = $result[0];
     $shippingInfo = $order->shipfname . ' ' . $order->shiplname . '<br/>' . $order->shipaddress . '<br/>' . $order->shipcity . ' ' . $order->shipstate . '<br/>' . $order->shipzip . '<br/>' . $order->shipcountry;
     $billingInfo = $order->billfname . ' ' . $order->billlname . '<br/>' . $order->billaddress . '<br/>' . $order->billcity . ' ' . $order->billstate . '<br/>' . $order->billzip . '<br/>' . $order->billcountry;
     $dateTime = date('Y-m-d H:i:s');
     $res = $db->query('SELECT p.name, ob.qty, ob.subtotal, ob.id as ob_id FROM products p JOIN orders_baskets ob ON (ob.product_id=p.id) WHERE ob.order_id="' . $order->id . '"');
     $description = '';
     $subtotal = 0;
     foreach ($res as $item) {
         $basket = ORM::factory('orders_basket', $item->ob_id);
         $product_name = $item->name;
         if ($basket->packaging_id != 0) {
             $product_name .= ' - ' . $basket->packaging->name;
         }
         $description .= '' . $item->qty . ' x ' . $product_name . ' = ' . money_format('%.2n', $item->subtotal) . '<br/>';
         $subtotal += $item->subtotal;
     }
     if (!empty($order->comment)) {
         $description .= 'Comment:' . $order->comment . '<br/>';
     }
     $total = 'Subtotal: ' . money_format('%.2n', $subtotal) . '<br/>Shipping:' . money_format('%.2n', $order->shipping_total);
     $total .= '<br/>Total:' . money_format('%.2n', $order->order_total);
     $emailAddr = $order->email;
     $res = $db->query('SELECT id FROM order_ids WHERE order_id = ' . $order->id . '');
     $orderid = $res[0]->id;
     $order->id = $orderid;
     $new_order_id = 'MCH' . $orderid;
     $to = array($emailAddr, '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**');
     foreach ($to as $address) {
         Autoresponder::sendEmail('order.status.changed', $address, $order, array('shipping_info' => $shippingInfo, 'billing_info' => $billingInfo, 'date_time' => $dateTime, 'description' => $description, 'total' => $total, 'order_id' => $new_order_id));
     }
     $this->template->content->status = 'Your paypal paymeny was successful!';
     $this->template->content->trans_id = $trans_id;
     $this->template->content->order_id = $order->id;
     $user_id = FALSE;
     if (User_Model::logged_in()) {
         $user_id = User_Model::logged_user()->id;
     }
     Session::instance()->regenerate();
     if ($user_id) {
         ORM::factory('user')->find($user_id)->forceLogin();
     }
     // Meta Description and Meta Keywords for individual pages are, at this point, hard coded.
     $this->template->metaDescription = $this->description;
     $this->template->metaKeywords = $this->keywords;
     $this->template->metaTitle = $this->title;
     // 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;
 }
      
      </script>
      
     <script>
	$(function() {
		$( "#requesteddate" ).datepicker({dateFormat: 'yy-mm-dd'});
	});
	</script>

<div id="content">
			<div id="pink-section-header">
				<h2 class="curly">Checkout</h2>
			</div><!-- header -->
			<div class="grey-border">
<?php 
if (FALSE === User_Model::logged_in()) {
    ?>
				<h3>Login</h3>
				<form method="POST" action="/customers/login">
					<input type="text" name="email" placeholder="Type your email." /><br />
					<input type="password" name="password" placeholder="Type your password." />
					<br />
					<input type="submit" value="Sign in" />
					<input type="hidden" name="redirect" value="/shopping_cart/checkout" />
				</form>
				<a href="/customers/forgot_password">Forgot password?</a>
				<h3>Or fill this form</h3>
<?php 
}
?>
			</div>
Exemple #4
0
<?php 
} else {
    ?>
<div class="col-md-4 col-lg-4 col-sm-4 col-xs-4">
<?php 
}
?>
				<ul class="social">
					<li><a href="#"><img src="/env/images/mcb/g_plus.png" alt="google+ icon"></a></li>
					<li><a href="#"><img src="/env/images/mcb/linkedin.png" alt="linkedin icon"></a></li>
					<li><a href="#"><img src="/env/images/mcb/facebook.png" alt="facebook icon"></a></li>
					<li><a href="#"><img src="/env/images/mcb/twitter.png" alt="twitter icon"></a></li>
				</ul>
		</div>
<?php 
if ($items != 0 | User_Model::logged_in()) {
    $user = User_Model::logged_user();
    ?>
	<?php 
    if ($user) {
        ?>
		<div class="col-md-5 col-lg-5 col-sm-5 col-xs-5 right-side">
		<?php 
    } else {
        ?>
		<div class="col-md-4 col-lg-4 col-sm-4 col-xs-4 right-side">
		<?php 
    }
    ?>
			<div class="col-md-7 col-lg-7 col-sm-7 col-xs-7">
				<img src="/env/images/mcb/cust_log_icon.png" alt="Customer Login">Hello, <?php 
 public function register()
 {
     if (User_Model::logged_in()) {
         url::redirect('/customers/my_account');
     }
     $this->template->content = new View('customers/register');
     $this->template->metaDescription = $this->description;
     $this->template->metaKeywords = $this->keywords;
     $this->template->metaTitle = $this->title;
     $this->template->title = $this->title;
     $formFields = User_Model::getFormFields();
     if (User_Model::logged_in()) {
         $user = User_Model::logged_user();
         $this->template->content->user = $user;
         foreach ($formFields as $section => &$fields) {
             if ($section == 'user') {
                 continue;
             }
             foreach ($fields as &$field) {
                 switch ($field->form) {
                     case 'billing':
                         $field->value = $user->user_billing_info->{$field->db_name};
                         break;
                     case 'shipping':
                         $field->value = $user->user_shipping_info->{$field->db_name};
                         break;
                 }
             }
         }
     }
     $this->template->content->formFields = $formFields;
     $this->template->content->countries = ORM::factory('country')->find_all();
     $this->template->content->states = ORM::factory('state')->find_all();
     if (request::method() === 'post') {
         $post = new Validation($_POST);
         $post->add_rules('email', 'email');
         $post->add_rules('password', 'required');
         $post->add_rules('first_name', 'required');
         $post->add_rules('last_name', 'required');
         $post->add_rules('address_1', 'required');
         $post->add_rules('city', 'required');
         $post->add_rules('state', 'required');
         $post->add_rules('zip', 'required');
         $post->add_rules('country', 'required');
         $post->add_rules('phone', 'required');
         if ($post->validate()) {
             $db = new Database();
             //$auth = _Auth::factory();
             $user = ORM::factory('user');
             $user->email = $post->email;
             $user->password = $post->password;
             $user->firstname = $post->first_name;
             $user->lastname = $post->last_name;
             $user->company = $post->company;
             $user->address1 = $post->address_1;
             $user->address2 = $post->address_2;
             $user->city = $post->city;
             $user->state = $post->state;
             $user->zip = $post->zip;
             $user->country = $post->country;
             $user->phone1 = $post->phone;
             $user->phone2 = $post->second_phone;
             $user->save();
             unset($user);
             $id = $db->query("SELECT id\n\t\t\t\t\t\t\t\t  FROM users\n\t\t\t\t\t\t\t\t  WHERE email = '{$post->email}'");
             //print_r(mysql_fetch);
             foreach ($id as $keys => $value) {
                 //	echo 'Key: '. $keys."<br>";
                 if (is_object($value)) {
                     foreach ($value as $vkeys => $vvalue) {
                         //			echo 'VKeys: '.$vkeys."<br>";
                         //			echo 'VValue: '.$vvalue."<br>";
                         if ($vkeys == 'id') {
                             $id = $vvalue;
                         }
                     }
                 } else {
                     //	echo 'Value: '.$value."<br>";
                 }
             }
             //die();
             if (!$post->address_2) {
                 $post->address_2 = "none";
             }
             if (!$post->second_phone) {
                 $post->second_phone = "none";
             }
             $billing = $db->query("INSERT into user_billing_infos\n\t\t\t\t\t\t\tSET user_id = '{$id}', \n\t\t\t\t\t\t\tfirstname = '{$post->first_name}',\n\t\t\t\t\t\t\tlastname = '{$post->last_name}',\n\t\t\t\t\t\t\tcompany = '{$post->company}',\n\t\t\t\t\t\t\taddress1 = '{$post->address_1}',\n\t\t\t\t\t\t\taddress2 = '{$post->address_2}',\n\t\t\t\t\t\t\tcity = '{$post->city}',\n\t\t\t\t\t\t\tstate = '{$post->state}',\n\t\t\t\t\t\t\tzip = '{$post->zip}',\n\t\t\t\t\t\t\tcountry = '{$post->country}',\n\t\t\t\t\t\t\tphone1 = '{$post->phone}',\n\t\t\t\t\t\t\tphone2 = '{$post->second_phone}'\n\t\t\t\t\t\t\t");
             //$results = $db->excute();
             // $user = ORM::factory('user_billing_infos');
             // $user->email = $post->email;
             // $user->password = md5($post->password);
             // $user->firstname = $post->first_name;
             // $user->lastname = $post->last_name;
             // $user->company = $post->company;
             // $user->address1 = $post->address_1;
             // $user->address2 = $post->address_2;
             // $user->city = $post->city;
             // $user->state = $post->state;
             // $user->zip = $post->zip;
             // $user->country = $post->country;
             // $user->phone1 = $post->phone;
             // $user->phone2 = $post->second_phone;
             // $user->save();
             // unset($user);
             // print_r($post->s_billing)
             if (isset($post->s_billing) === '1' && isset($post->s_billing) != "") {
                 $shipping = $db->query("INSERT INTO user_shipping_infos\n\t\t\t\t\t\t\tSET user_id = '{$id}',\n\t\t\t\t\t\t\tfirstname = '{$post->first_name}',\n\t\t\t\t\t\t\tlastname = '{$post->last_name}',\n\t\t\t\t\t\t\tcompany = '{$post->company}',\n\t\t\t\t\t\t\taddress1 = '{$post->address_1}',\n\t\t\t\t\t\t\taddress2 = '{$post->address_2}',\n\t\t\t\t\t\t\tcity = '{$post->city}',\n\t\t\t\t\t\t\tstate = '{$post->state}',\n\t\t\t\t\t\t\tzip = '{$post->zip}',\n\t\t\t\t\t\t\tcountry = '{$post->country}',\n\t\t\t\t\t\t\tphone1 = '{$post->phone}',\n\t\t\t\t\t\t\tphone2 = '{$post->second_phone}'\n\t\t\t\t\t\t\t");
                 //$results2 = $db->excute();
                 // $user = ORM::factory('user_shipping_infos');
                 // $user->firstname = $post->s_first_name;
                 // $user->lastname = $post->s_last_name;
                 // $user->company = $post->s_company;
                 // $user->address1 = $post->s_address_1;
                 // $user->address2 = $post->s_address_2;
                 // $user->city = $post->s_city;
                 // $user->state = $post->s_state;
                 // $user->zip = $post->s_zip;
                 // $user->country = $post->s_country;
             }
             url::redirect('/customers/login');
         }
     }
 }
 protected function wrapper_MCB($_product)
 {
     $db = new Database();
     $this->template->content = new View('wrapper_builder_mcb');
     $productarray = Router::$arguments;
     $productname = $productarray[0];
     $products = $db->query('SELECT products_descriptions.*, products.*  FROM products_descriptions LEFT JOIN products ON products_descriptions.id = products.products_description_id WHERE products_descriptions.title_url = \'' . $productname . '\'');
     $product = ORM::factory('product')->where('products.id', $_product->id)->find();
     $category = $db->query("SELECT cps.* FROM categories_products as cps WHERE product_id = '{$_product->id}'");
     $this->template->content->products = $products[0];
     $this->template->content->user = FALSE;
     $this->template->content->category = $category[0];
     if (User_Model::logged_in()) {
         $user = User_Model::logged_user();
         $this->template->content->user = $user;
     }
     // $this->template->content->xmlHeader = $product->getConfiguratorFile(Configurator_file_Model::TYPE_HEADER)->file;
     // $this->template->content->xmlContent = $product->getConfiguratorFile(Configurator_file_Model::TYPE_CONTENT)->file;
 }