Friday, February 8, 2013

jQuery: Currency Format Number

Divide by 1000, and use .toFixed(3) to fix the number of decimal places.
var output = (input/1000).toFixed(3);
The above solution only applies if the dot in the original question is for a decimal point. However the OP's comment below implies that it is intended as a thousands separator.
In this case, there isn't a single line solution (Javascript doesn't have it built in), but it can be achieved with a fairly short function.
Alternatively, a more complex string formatting function which mimics the printf() function from the C language can be found here: http://www.diveintojavascript.com/projects/javascript-sprintf

Tuesday, January 8, 2013

MYSQL : "THE USER SPECIFIED AS A DEFINER ('ROOT'@'%') DOES NOT EXIST"

The source code for the stored procedures that you have been loading probably contain "DEFINER=root@'%'" as part of the definition - looking a bit like this:
create definer='root'@'%' procedure sp_test() begin end;
The problem here is that you do not have an account on your system for 'root'@'%'. This can be easily demonstrated. From the MySQL command line:
show grants for 'root'@'%';
I expect that this will come back with an error message:
ERROR 1141 (42000): There is no such grant defined for user 'root' on host '%'
The fix is to alter the source of your stored procedures, or to create the missing account:
grant all on *.* to 'root'@'%' identified by 'password' with grant option;
It is not generally a good idea to have such a high-powered account accessible from anywhere, but that is another story.

Tuesday, December 25, 2012

How to remove unnessesary blank lines in your code

In Dreamviewer
  1. Open the file
  2. Click CTRL + F
  3. Select "Current document" in "Find in" (You can also select the folder if you have multiple files)
  4. Search in "Source code"
  5. Tick "Use regular expression"
  6. Type "[\r\n]{2,}" (without quotes) in "Find"
  7. Type "\n" (without quotes) in "Replace"
  8. Press "Replace All"

Friday, November 30, 2012

50 Extremely Useful PHP Tools

 50 Extremely Useful PHP Tools posted at Smashing Magazine

By Jacob Gube
PHP is one of the most widely used open-source server-side scripting languages that exist today. With over 20 million indexed domains using PHP, including major websites like Facebook, Digg and WordPress, there are good reasons why many Web developers prefer it to other server-side scripting languages, such as Python and Ruby.
PHP is faster (updated), and it is the most used scripting language in practice; it has detailed documentation, a huge community, numerous ready-to-use scripts and well-supported frameworks; and most importantly, it’s much easier to get started with PHP than with other scripting languages (Python, for example). That’s why it makes perfect sense to provide the huge community of PHP developers with an overview of useful tools and resources that can make their development process easier and more effective.
This post presents 50 useful PHP tools that can significantly improve your programming workflow. Among other things, you’ll find a plethora of libraries and classes that aid in debugging, testing, profiling and code-authoring in PHP.

Details of Jomres ( joomla hotel reservation component )

If you want to view or custermise booking data, you can edit jomeres/core-minicomponents/j03020insertbooking.class.php file.

Tuesday, November 20, 2012

Authenticating Customer Outside Magento

<?php
/**
* Magento validation starts here
*/
require_once (dirname(dirname(realpath(__FILE__))).'/app/Mage.php');
umask(0);
Mage::app();
//Mage::getSingleton('core/session', array('name'=>'frontend'));
$session = Mage::getSingleton('customer/session');
try{
$session->login($_REQUEST['login']['username'],$_REQUEST['login']['password']);
$session->setCustomerAsLoggedIn($session->getCustomer());
//Load the customer modules
$customer = Mage::getModel('customer/customer')
->setWebsiteId(Mage::app()->getStore()->getWebsiteId());
//Get customer attribbutes
$customer->loadByEmail($_REQUEST['login']['username']);
/**
* Do the stuff you need to when user authenticates
*/
}catch (Exception $e){
$key ="authenticate=N";
}

Friday, November 9, 2012

How to access Magento user's session from outside Magento?

<?php
require_once dirname(__FILE__).'/app/Mage.php';
umask(0) ;
$_SESSION['wz']['customer_id']    =    null;
Mage::app();

// Checking for customer session
Mage::getSingleton('core/session', array('name'=>'frontend') );
$session=Mage::getSingleton('customer/session', array('name'=>'frontend') );

$customer_data = Mage::getModel('customer/customer');

if ($session->isLoggedIn()) {
    //echo "Customer is logged in";
    $_SESSION['wz']['customer_id'] = $session->getId();
} else {
    //echo "Customer is NOT logged in ";
    unset($_SESSION['wz']);
    header("Location: error.php?mode=unk_user");
}