Posts Tagged ‘PHP’

Oct

30

Client Profile – Toyflow

October 30th, 2011

Visit Toyflow

Toyflow Latest Project

Toyflow.com is a new Canadian-based deal of the day site that sells toys and other children’s products to customers in the United States and Canada. The daily deal site has now been through two phases of development and has been in production selling products for the last month.  The site was designed with some very unique features in addition to the typical features you would see on a deal of the day site.

  • Since the deal of the day site sells its products to customers in the United States and Canada, there were some customizations that needed to happen to accomodate the diverse customer base.
  • The site is fully internationalized when it comes to language and can be configured to display text in both French and English.
  • Toyflow accepts both the Canadian Dollar and US Dollar.  A user can elect to show prices for the products in either of these currencies as well as shipping costs, tax, and discount codes.
  • The site utilizes geolocation to determine which currency to show to a visitor as well as assists the user in filling out their order info by pre-filling their country, city, and state/province based on this geolocation data.
  • A full shipping integration has been built in order to allow the site to compute shipping costs to the United States as well as to Canada.  The entire shipping process has been fully automated.  The client can export orders to UPS Worldship for printing labels, print packing slips, and process returns using RMA numbers.
  • Canadian sales tax is calculated automatically based on the GST and PST taxes in each of the Canadian provinces
  • The site has the ability to feature side deals in addition to the standard deal of the day.  These deals can be scheduled based on date or on inventory.
  • Integration with Moneris for secure credit card payments directly on the site.
  • Ability to tag products for use in reporting.  Products can be tagged and placed into various categories so that sales can be analyzed to see which groups of products are selling the best.  This reporting is built into the site’s administrative console and all reports are exportable to Microsoft Excel.

We at Halfslide Design really enjoyed working with David and Terry at Toyflow on the development of their daily deal website.  They are excellent communicators and have an excellent business plan.  In addition, they did a superb job of planning the website design project and clearly illustrating the requirements of their site.  If you haven’t checked out Toyflow.com yet, give it a look and grab some toys for your kids.

Visit Toyflow

Oct

26

I ran into an interesting problem I’d never seen before this evening. I’m not sure if this is a problem isolated to the CodeIgniter framework because I’ve seen a few forum posts on Sencha/ExtJS reporting the same type of issue. But this was definitely happening for me on CodeIgniter.

The situation was that every time a user exported some data from one of my web applications to csv in Internet Explorer 8 and then opened that csv file, it would invalidate their session.  So, for example, they were running a report in the administrative console that provided results in an html table.  On all of the web applications that I write, I always give the user the ability to export the data to csv through a link above the table.  When a user clicked this link in IE and downloaded the csv file and then opened it, it essentially killed their session and forced them to log back in.  The key thing is that it would only do this if the user opened the file.  If they didn’t open it, their session was fine.

After doing some troubleshooting, I found that the issue was fixed by changing the Content-Type in the header.   In the method that exports the data to csv, it was set up as this:

header(“Cache-Control: must-revalidate, post-check=0, pre-check=0″ );
header(“Content-Type: application/vnd.ms-excel” );
header(“Content-Disposition:attachment; filename=”.$filename );
header(“Content-Transfer-Encoding: binary” );

print $out;

Where the “print $out” is actually printing out the details.

I was able to resolve this problem by changing the content-type header line above to:

header(“Content-Type: application/octet-stream”);

I didn’t see many forum posts about this, so hopefully this blog post will help someone out down the road who runs into this.

Apr

6

For a current project I’m working on, I’ve had to rank a list of teams based on their win-loss-tie record within their division. I searched the web but was unable to find anyone who had done this and posted an example so I figured I’d post my process. If you have corrections or improvements for this, please feel free to comment.

The code assumes that you have an array of team objects that each have a win/loss/tie property. As an example, I’ve got an array of five teams such that:

Array
(
  [0] => stdClass Object
  (
    [id] => 1
    [name] => Team 1
    [wins] => 5
    [losses] => 6
    [ties] => 3
  )

  [1] => stdClass Object
  (
    [id] => 2
    [name] => Team 2
    [wins] => 4
    [losses] => 8
    [ties] => 4
  )

  [2] => stdClass Object
  (
    [id] => 3
    [name] => Team 3
    [wins] => 2
    [losses] => 9
    [ties] => 6
  )

  [3] => stdClass Object
  (
    [id] => 4
    [name] => Team 4
    [wins] => 4
    [losses] => 9
    [ties] => 4
  )

  [4] => stdClass Object
  (
    [id] => 5
    [name] => Team 5
    [wins] => 4
    [losses] => 9
    [ties] => 5
  )
)

We’re going to use usort to sort the array based on each team’s win/loss/tie record.  First, we need to write our usort method:

function sort_win_loss($team1, $team2) {
  if($team1->wins > $team2->wins) {
    return -1;
  } else if($team1->wins < $team2->wins) {
    return 1;
  } else if($team1->wins == $team2->wins) {
    if($team1->losses>$team2->losses) {
      return 1;
    } else if($team1->losses<$team2->losses) {
      return -1;
    } else if($team1->losses==$team2->losses){
      if($team1->ties>$team2->ties) {
        return -1;
      } else if($team1->ties<$team2->ties) {
        return 1;
      } else {
        return 0;
      }
    }
  }
  return 0;
}

Lastly, we provide our array of teams to the usort and get our sorted list back:

usort($teams, “sort_win_loss”);
// After the usort, the teams will be ranked as
// 1) Team 1
// 2) Team 2
// 3) Team 5
// 4) Team 4
// 5) Team 3

Dec

21

Visit Storage Strategy Now

Storage Strategies Now

I recently finished a site for Storage Strategies Now, an industry analyst firm that provides reports and commentary on the technology market.  Storage Strategies Now is located here in Austin, Texas and was founded in 2007 by a well-known storage observer, Deni Connor.

There’s not much to the site itself other than the fact that it was created using php and it uses Adobe’s Contribute technology to allow the client to make updates to the site themselves. I basically put together the layout and used php includes to include small pages of content that the client can update.  This gives the added benefit of allowing the client to update the content on the site without having to worry about disturbing the general layout.  Very cool technology.

Visit Storage Strategy Now