Archive for the 'Web Development' Category

The 15% VAT Change: Software development lessons learned

Friday, November 28th, 2008

With the suprise announcement that the government is going to reduce the VAT rate to 15%, there was much media coverage about how this may or may not help the economy, whether the high street will actually pass on the savings to consumers and as per usual, nothing much about how this affects the IT services that support the ever-increasing amount of small businesses that are moving online.

I’m sure I wasn’t alone in suffering a feeling of dread when I heard that the new rate is going to go into effect on the 1st December 2008, leaving us just 5 days to plan, implement & test any changes that need to be made. For the majotity of the businesses I run sites for, this was a minor thing since I tend to follow these simple rules:

  • Store the VAT charged with the payment record - don’t rely on coding to calculate it post-transaction
  • Store the VAT amount in a configuration file or database value - never hard code it

In these cases all I need to do is change the VAT amount on the morning of the 1st and everything will be fine. There is one company though that wasn’t so easy to change.

VAT & Services
Our primary client, Medicology, provides services in the form of training courses. People decide to book onto one of their courses, usually well in advance and they receive a 28 day invoice which is then paid. In this companies case, the tax point (the point at which the VAT is calculated and paid) is the point at which the course is run. This has major implications for them:

  • If a customer had booked onto a course in September, they would have been invoiced at 17.5%
  • However, if the course they are attending runs in January, they should have been invoiced at 15%
  • This would therefore require the original invoice to be credit noted at n17.5% and then a new invoice generated at 15%

This was potentially devastating for the company as they may have hundreds of invoices, some paid, some unpaid which need credit noting, re-invoicing and in some cases, refunds issued and new payments taken.

Luckily, due to the short notice, the HMRC has said they will waive this process and let the existing invoices stand. This will save the company hundreds of man-hours and thus thousands of pounds. From a customer point of view, they are not loosing out by paying the extra VAT since the majority of courses are paid for by the NHS Trusts who can claim back the VAT, whatever the amount.

I will be keeping a close eye on the press for what will happen in 13 months time when the rate will increase and my guess is, the government won’t be so kind about letting people off paying additional VAT. In this case, their courses running in 2010 may have to be re-issued so as soon as the new VAT rate is announced, I will be making changes ot the system to calculate the VAT amount based on the tax point as opposed to the current amount.

I just hope they decide the amount sooner rather than later

IE7 File Uploads don’t work - nothing happens

Friday, July 11th, 2008

So, Microsoft have a released a new Internet Explorer and as per usual, we’re going to have to re-code all our sites for it. So, what’s this versions problem: file uploads.

I have a site that uploads a file in the usual HTML form way and then the PHP on the server checks if it’s a JPEG and uses copy() to move it to a desired folder. I tested it in FireFox and everything was working fine and since it’s so simple a script I left it at that. Then a client with IE7 called me because he was trying to upload a jpeg and nothing was happening. I fired up IE and gave it a go and when I clicked on the Submit button it just sat there, doing sod all.

A bit of digging and I found that the problem was because I’d included the following in the code for the Submit Button:

onClick=”this.disabled = true;”

This was being executed by IE and then it appears it just sits there and forgots you clicked Submit. You can give IE a good kicking and get it working again by changing it to:

onClick=”this.disabled = true; document.form.submit();”

I hate IE and M$

1and1 Dedicated server and PEAR

Tuesday, January 29th, 2008

I’ve recently had to do a complete reinstall on our 1and1 Root Linux server which is easy enough in itself as it’s just a case of going into the Control Panel and hitting Server Re-Image alogn with your choice of operating system. I went for Fedora Core 6 and within an hour everything was up and running. Within another hour I had my files uploaded (4Gb including images), MySQL databases loaded and my custom httpd.conf loaded. After that I thought the only hard bit would be the extras I had installed but with a quick “yum install ImageMagick” and “yum install webmin” then using Webmin to set up the firewall properly, everything was good to go.

With the sites back up I just needed to do a few quick checks to see if various bits of the website were working. Everything was fine except for PHP sending out emails. I knew that newer versions of Fedora were supposed to use QMail and not Sendmail so I headed off into the system to see if I could track down the problem. After a bit of messing around it seemed the mail server was fine (even with the MTA set as QMail) but nothing would be sent out using PHP. By saving the MTA to Sendmail I could get emails out using the mail() function but not using PEAR’s Mail package. Enabling ErrorReporting on one of my scripts threw up the errors:

Warning: main(Mail.php): failed to open stream: No such file or directory in
/var/www/html/email.php on line 15

Fatal error: main(): Failed opening required ‘Mail.php’
(include_path=’.:/usr/local/share/php/pear’) in
/var/www/html/email.php on line 15

I then loaded up a phpinfo() script and noticed the following line:

–without-pear

For some reason they’ve decided to be overly cautious and install PHP without PEAR support so even though PEAR was showing as being installed and commands such as “pear install Mime” were working, something with PHP was a bit pear shaped (get it, arf arf!). It turns out that the solution is simply to open up /etc/php.ini and add the following line:

include_path=”.;/usr/share/pear”

Everything seems to be working now, a bit more testing might be in order though

PHP Translation: English to French

Monday, November 12th, 2007

I’m just about to get started on a new project for a client and it’s going to be my first multi-lingual site. The site is Visit Pyrenees and it’s a holiday home and hotel advertising site based around three villages in the Eastern Pyrenees. As far as a brand new project goes, it shouldn’t be too complicated and the only technically difficult bit will be the French and English versions.

As the site is aimed at UK tourists wanting to visit the area, the default language will be English, but I also want a French version for a number of reasons:

  • It adds to the USP of the site by attracting visitors speaking both languages
  • There will be a slight SEO benefit from the dual language site
  • Some of the advertisers will only speak French and will be editing their advert which will then need translating

There are basically two section to the site: the adverts for the various places of accommodation and the static information pages. Since I don’t speak much French, I’d like the static areas of the site to be editable by a none technical but French speaking person (such as the site owner). It therefore makes sense that the easiest way of implementing the site using a wysiwyg editor that lets the user select their language and then enter the text and any other HTML entities into the editor before saving it. The PHP script will then take the text and then create a version in the other language.

When I find something suitable that works, I’ll post a link or a zip file for download if I have to modify it.

PHPlist: Advantages & disadvantages

Tuesday, August 7th, 2007

Our main company, Medicology, derives the majority of its business from mailings to NHS staff. We currently use PHPlist to manage the sending of our emails, with the contacts being broken down into one of several lists based on the source of the contact and which day they are contacted on.

This works fine at the moment but we want to be able to have greater control over the mailings and who receives what, when. There are a few things that we’d like to do, some of which are easily done and some of which can’t be done.

Possible with PHPlist

  • Add extra contact information such as location, job title and hospital
  • Automatically schedule emails for later sending
  • Send emails through an external SMTP server requiring authentication
  • Rich Text Editor (RTE) built in for creation of good quality emails

These are all essential features for us and handled very well in PHPlist. There are some features that either don’t perform the way we want or are missing and which are also essential for us.

Missing from PHPlist

  • Skip sending to contacts if they’ve received an email within a certain time frame
  • Dynamically create lists based on selectable criteria (slighty supported in PHPlist but not to the extent we need)
  • Modify the content of the emails based on contact preferences or other database stored information

Although I’d like to continue using PHPlist, the business benefits of the missing features are too great to ignore so I think I’m going to have to make a decision and either start modifying our PHPlist installation or create my own mailing programme.

I’m going to have a look through the code for PHPlist, make a decision and then I’ll post back later.

Simply Add AdSense to your Wordpress blog

Thursday, August 2nd, 2007

Here’s a quick guide to Google AdSense to your Wordpress blog. I’ve tried to keep it as simple as possible for the novice user but I’ve made a few assumptions:

  • You have a Wordpress blog and know how to upload files to your webspace
  • You’ve already signed up for a Google AdSense account (if not, click on the banner on the right)
  • You won’t moan at me if you accidentally break something!

Ok, First go to your AdSense account and log in. Click on “AdSense Setup” and then “AdSense for Content”. Follow the guide to create your AdSense code (if you need help at any point, look at Google’s support pages). I’m going to show you how to add the adverts in the “Sidebar” (the strip on the right) so I recommend choosing either a Skyscraper or Vertical Banner.

Once you have you code leave it open in your browser and go to where you’re keeping your wordpress files on you PC. You’ll need to browse through the folders to:

wp-content\themes\default\

Open the file you’ll find in there called sidebar.php in a text editor (such as Notepad). All you have to do is paste your code in there. I recommend putting it at the bottom (just before the </div>) to put the ads below your other links.

Now just save the file and upload it to your webspace. Go have a look at your site and you should now have your ads on there!

If you can’t get it working, leave a comment and I’ll try and help when I get the chance.

AJAX Online Document Store

Tuesday, July 17th, 2007

Here is the code for the simple AJAX online collaboration document store I wrote a while back.

You should just be able to upload it to the document root, edit the header.php and footer.php files to your design and everything should work. If not, try editing it to get it working on your server.

PHP Script to Import Sexshop365 into osCommerce

Tuesday, July 10th, 2007

As I mentioned in the previous post I wanted to write a script to take the online CSV file from Sex Shop 365 and be able to import it directly into my osCommerce shops.

I’ve tested it and it works fine with my installation. You will have to modify it though as I’ve added an extra field (RRP) and modified the products_price based on this. If you’d like it, you can get the code from this page

PHP Code For Importing CSV Into osCommerce
Latest version for download as .txt file

The script should do the following:

  • Extract top level categories and import into database if not already there
  • Take sub categrories and import into database if not already there
  • Exrtact all products and import main information into products table
  • Add products name and description into products_description table
  • Match products to categories

Someone might find this useful. As per usual - back everything up first! No warranty is implied or given. Do write to me if you much up your database - I enjoy a good laugh (harsh, but for your own good newbies)

Importing sexshop365 CSV file into osCommerce

Sunday, July 8th, 2007

A while ago I decided I wanted to change suppliers from our existing one to Sex Shop 365 as the old one tend to be a bit slow making deliveries and you have to do all the ordering by email. Sex Shop 365 are much better since you can do everything through their site and they’re very good in general.

The only downside is that it means I’ve got to completely recreate the product database. On the up side, sexshop365 have their product range online in CSV format. Luckily there’s this osCommerice contribution that lets you import the CSV into the product database. It doesn’t do everything automatically so I’m going to work on a script to do everything and then put it up.

PayPal IPN Update

Saturday, July 7th, 2007

Well, the guy who ordered of me in the last post has been back on the shop and ordered again and it’s all working now. Only trouble is that I now didn’t get an email from the shop telling me an order had been placed. Luckily I get the emails from PayPal saying I’d received funds so I knew about it.

I’m going to have a look on Monday and see if there’s a known work around or if not, see if I can fix it. If I have to fix it, I’ll post the work around here.