Localizing SimpleCustomer

Introduction

SimpleCustomer is a nice and light application to handle contacts and notes, ie. poor man's CRM. If you don't need a real CRM with all the bells and whistles, it does the job well.

Decisions

Setup

Here's how to set up SC in its default configuration:

  1. Unzip the package in your web server's htdocs/ directory, and chmod images/ to 777
  2. Edit database connection details in includes/config.php
  3. Aim at http://server/install.php
  4. Enter your email address & password
  5. Delete install.php file after successful installation

Let's go

Here's what I did to turn SC from a US-centric application to a locale-independent application:

All scripts

Turn "echo $row_*" into "echo stripslashes($row_*)" so that PHP removes escaped apostrophes.

Created include/strings.php

Moved all displayed strings into includes/strings.php:

/contact.php

$pagetitle = Contact;

  $insertSQL = sprintf("INSERT INTO contacts (contact_first, contact_last, contact_title, contact_image, contact_profile, contact_company, contact_street, contact_city, contact_state, contact_zip, contact_phone,

        set_msg('Contact Updated');

<title><?php if ($update==0) { echo "Add Contact"; } ?><?php echo $row_contact['contact_first']; ?> <?php echo

    <h2><?php if ($update==1) { echo Update; } else { echo Add; } ?> Contact </h2>

          <td width="28%">First Name<br />

          <td width="72%">Last Name<br />

          <td>Title<br />

          <td>Company<br />

          <td colspan="2">Email <br />

false;">+Add more contact information </a></p><?php } ?>

                <td>Street<br />

                      <td width="39%">City<br />

                      <td width="27%" valign="top">State<br />

                          <select name="contact_state" id="contact_state">

<option value="">Select a state...</option>

                            <option value="AL" <?php if (!(strcmp("AL", $row_contact['contact_state']))) {echo "selected=\"selected\"";} ?>>Alabama</option>

                      <td width="34%">Zip<br />

                      <td width="39%">Phone<br />

                      <td width="61%">Cell<br />

                <td>Image<br />

                <td>Website<br />

                <td>Background/Profile<br />

            <input type="submit" name="Submit2" value="<?php if ($update==1) { echo Update; } else { echo Add; } ?>

/contact-details.php

$pagetitle = ContactDetails;

set_msg('Note Added');

set_msg('Note Updated');

<?php if ($update==0) { echo "Add a new note <br>"; } ?>

        <input type="submit" name="Submit2" value="<?php if ($update==1) { echo Update; } else { echo Add; } ?>

$row_note['note_contact']; ?>" onclick="javascript:return confirm('Are you sure you want to delete the

$row_notes['note_id']; ?>"><?php echo date('F d, Y', $row_notes['note_date']); ?></a></span><br />

/contacts.php

$pagetitle = Contact;

    <h2>Contacts</h2>

                  <th  style="padding-left:5px"><a href="?<?php echo $name; ?>">Name</a></th>

onclick="javascript:return confirm('Are you sure you want to delete the contact <?php echo

/delete.php

set_msg('Contact Deleted');

set_msg('Note Deleted');

/index.php

$pagetitle = Dashboard;

Search results for <em><?php echo $_GET['s']; ?></em>.<br />

    <h2>Recent Contacts</h2>

      <h2>Recent Notes  </h2>

?>&note=<?php echo $row_notes['note_id']; ?>"><?php echo date('F d, Y', $row_notes['note_date']);

/login.php

  <h1>Simple Customer </h1>

    </span></span>Email Address <br />

    Password<br />

    <input type="submit" name="Submit" value="Login" />

/password.php

        set_msg('Your password has been sent.');

$subject = "Your Password";

$message = "Your password is $password.";

set_msg('That email address was not found in the database.');

  <form id="form1" name="form1" method="post" action="">Enter your email address below and your password will be

       <input name="email" class="required validate-email" type="text" size="35" title="You must enter your email

       <input type="submit" name="Submit" value="Send Password" />

/profile.php

$pagetitle = Profile;

    <h2>Profile</h2>

      <p>Email

        Password (leave blank to keep current password) <br />

      <p>Home Page<br />

          Dashboard

      Contacts</p>

        <input name="Submit2" type="submit" id="Submit2" value="Update" />

/includes/validation.js

                this.error = error || 'Validation failed.';

        ['required', 'This is a required field.', function(v) {

        ['validate-number', 'Please enter a valid number in this field.', function(v) {

        ['validate-digits', 'Please use numbers only in this field. please avoid spaces or other characters such as dots

etc.

/includes/header.php

  <a href="index.php" class="menubuttons <?php if ($pagetitle==Dashboard) { echo menubuttonsactive; }

<div class="historycontainer">Recent:

/includes/right-column.php

Search<br />

        <input type="submit" name="Submitf" value="Go" />

    <p><a class="addcontact" href="contact.php">+ Add Contact</a></p>

    <p><strong>Contact Information</strong><br />

?><p><a href="http://maps.google.com/maps?f=q&amp;hl=en&amp;q=<?php echo $row_contact['contact_street']; ?>,+<?php

$row_contact['contact_zip']; ?>&gt;" target="_blank">+ View Map </a></p>

    <p>      <?php if ($row_contact['contact_phone']) { ?>Phone: <?php echo $row_contact['contact_phone']; ?><br

  <strong>Background</strong><br />

Moving from MySQL to SQLite