Job Notes in a custom php web app not showing
<p>Hoping some of you out there are great with php!</p>

<p>Basically the guy who made this is MIA so I can't ask him what I need to do to fix the problem we are having.</p>

<p><strong>Background:</strong>
We are a locksmith company that uses a custom web app to inform our locksmiths on the road when they have a new job. This web app also does a few extra things like providing gps location, time taken at the job and the ability to have save signature from the client upon work completion.</p>

<p><strong>Problem:</strong>
The app works by picking up an email sent from our account management application called E3, the email (example: <a href="http://cl.ly/image/2E433O330T0N" rel="nofollow">http://cl.ly/image/2E433O330T0N</a>) is read by this web app, parsed into both an email and a web page and sent to the locksmith to view his new job. When the locksmith arrives at the web page on his phone (example: <a href="http://cl.ly/image/0P1I0R0h0O3K" rel="nofollow">http://cl.ly/image/0P1I0R0h0O3K</a>), he can see the job details including the Name, address and contact details for the client. The problem is though, because Job Notes isn't assigned a heading in the original email the code has to work out where Job Notes is located, this is the part that has the problem as the web app is no longer showing the data in Job Notes. Job Notes is important because it tells the locksmith what he needs to fix. This worked previously but has now just stopped working and we aren't sure why.</p>

<p>How the data is transferred to the web app is very interesting, instead of having a database to store data to, it is put in the address bar and then the webpage interprets the code and formats it into the page.</p>

<p>For example, this is how the current link looks (data taken out, replaced with xxxxxxx):</p>

<blockquote>
  <p><a href="http://www.xxxxxxx.com/apps/xxxxxx/on-my-way" rel="nofollow">http://www.xxxxxxx.com/apps/xxxxxx/on-my-way</a>?<strong>client</strong>=xxxxxx&amp;<strong>company</strong>=xxxxxx&amp;<strong>mobile</strong>=xxxxxxx&amp;<strong>phone</strong>=xxxxxxx&amp;<strong>contact</strong>=xxxxxxxx&amp;<strong>addressData</strong>=Array&amp;<strong>addressIndex</strong>=3&amp;<strong>streetAddress</strong>=xxxxxxxxx&amp;<strong>addressLocality</strong>=xxxxxxxx&amp;<strong>postcode</strong>=xxxxxxx&amp;<strong>city</strong>=xxxxxxx&amp;<strong>clientEmail</strong>=&amp;<strong>jobDate</strong>=11/22/2012&amp;<strong>jobTime</strong>=1:30:00%20PM&amp;<strong>jobID</strong>=xxxxxx&amp;<strong>jobAMPM</strong>=PM&amp;<strong>adminEmail</strong>=xxxxxxx&amp;<strong>noreplyEmail</strong>=xxxxxxxxxx&amp;<strong>companyPhone</strong>=xxxxxxxx&amp;<strong>staffEmail</strong>=xxxxxxxx&amp;<strong>staffName</strong>=xxxxxxx&amp;<strong>staffPhone</strong>=xxxxxxxx</p>
</blockquote>

<p>Previously, when working, this link had a jobNotes field added:</p>

<blockquote>
  <p><a href="http://www.xxxxxxxx.com/apps/xxxxxxxx/on-my-way" rel="nofollow">http://www.xxxxxxxx.com/apps/xxxxxxxx/on-my-way</a>?<strong>client</strong>=xxxxxxxx&amp;<strong>company</strong>=xxxxxxxx&amp;<strong>mobile</strong>=xxxxxxxx&amp;<strong>phone</strong>=&amp;<strong>contact</strong>=xxxxxxxx&amp;<strong>addressData</strong>=Array&amp;<strong>addressIndex</strong>=4&amp;<strong>streetAddress</strong>=xxxxxxxx&amp;<strong>addressLocality</strong>=xxxxxxxx&amp;<strong>postcode</strong>=xxxxxxxx&amp;<strong>city</strong>=xxxxxxxx&amp;<strong>clientEmail</strong>=xxxxxxxx&amp;<strong><em>jobNotes</em>=Quote%20on%20installing%20new%20keying%20system%0A%0AAlso%20would%20like%20a%20Quote%20on%20Install%20CCTV%0A%0ASub%20Total%3A%202%2C236.36%0AGST%3A%20223.64%0ATotal%3A%202%2C460.00%0A%0AMISC&amp;*<em>jobDate</strong>=11/19/2012</em>*&amp;<strong>jobTime</strong>=2:00:00%20PM&amp;<strong>jobID</strong>=xxxxxxxx&amp;<strong>jobAMPM</strong>=PM&amp;<strong>adminEmail</strong>=xxxxxxxx&amp;<strong>noreplyEmail</strong>=xxxxxxxx&amp;<strong>companyPhone</strong>=xxxxxxxx&amp;<strong>staffEmail</strong>=xxxxxxxx&amp;<strong>staffName</strong>=xxxxxxxx&amp;<strong>staffPhone</strong>=xxxxxxxx</p>
</blockquote>

<p><strong>The code:</strong></p>

<p>This is an extract from e3-parser.php, the main file that translates the data from the e3 email to the web app.</p>

<pre><code>    // Job notes
  if ($this-&gt;clientEmail) {

// REMOVED NOW THAT EMAIL IS BEING PUT ON THIRD LINE OF ADDRESS
//   // If customer email present grab everything after it save it as job notes
//   preg_match("/$this-&gt;clientEmail[^-]+/",$e3Output,$matches);
//   $result = implode("",$matches);
//   $notes  = trim(str_replace($this-&gt;clientEmail,'',$result));
//   $this-&gt;jobNotes = rawurlencode($notes);
// } else {

    // Fall back to grabbing everything after the time
    preg_match("/AM[^-]+/",$e3Output,$matchesAM);
    preg_match("/PM[^-]+/",$e3Output,$matchesPM);
    $resultAM = implode("",$matchesAM);
    $resultPM = implode("",$matchesPM);    
    $notes  = trim(str_replace('AM','',$resultAM) . str_replace('PM','',$resultPM));
    $this-&gt;jobNotes = rawurlencode($notes);
  }
</code></pre>

<p>Question here is, does it successfully grab the data listed after the <strong>Required Time</strong> field? (example email that it's reading from: <code>http://cl.ly/image/2E433O330T0N</code>)</p>

<p>Here is the code that places the parsed data into the web page:</p>

<pre><code>// Create job link
$url      = $e3-&gt;create_job_url('http://www.prvgroup.com.au/apps/jobbook/on-my-way?');  
$linkName = "View job details";
$href     = '&lt;a class="btn btn-small" href="' . $url . '&amp;staffEmail=' . $staff-    &gt;staffEmail . '&amp;staffName=' . $staff-&gt;staffName . '&amp;staffPhone=' . $staff-&gt;staffPhone . '"&gt;' . $linkName . '&lt;/a&gt;';  
</code></pre>

<p>This is sent to the locksmith via email informing him of his new job on the clickable link "View job details". The link is impregnated with the data needed. However from the looks of it the data for jobNotes isn't there. My backups of this code display the exact same thing here when the code was displaying jobNotes so I'm not exactly sure how it is putting that field in. </p>

<p>If you got this far, well done! I hope I was clear enough with what the issue is but if you need anymore clarification, just ask!</p>

<p>Cheers,
Marc</p>
