~slincire/sahana-agasti/cuny-sps-trunk

« back to all changes in this revision

Viewing changes to plugins/agGisPlugin/modules/agGis/templates/listfacilitySuccess.php

  • Committer: Nils Stolpe
  • Date: 2011-01-21 04:31:58 UTC
  • mfrom: (62.1.79 trunk)
  • Revision ID: nils.stolpe@mail.cuny.edu-20110121043158-raqdgit068868lti
post merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<h3>Facility GIS List</h3>
2
 
 
3
 
<table class="staffTable">
4
 
  <thead>
5
 
    <tr>
6
 
      <th>Facility</th>
7
 
      <th>Address</th>
8
 
      <th>Updated at</th>
9
 
    </tr>
10
 
  </thead>
11
 
  <tbody>
12
 
    <?php foreach ($ag_facility_geos as $ag_facility_geo): ?>
13
 
    <tr>
14
 
      <td>
15
 
        <a href="<?php echo url_for('facility/show?id='.$ag_facility_geo->getId()) ?>">
16
 
        <?php    echo $ag_facility_geo->getFacilityName()         ?>
17
 
        </a>
18
 
      </td>
19
 
      <td>
20
 
      <?php
21
 
      //maybe the below 9 lines should be in actions.class
22
 
      //the below lines return a properly ordered array of:
23
 
      //street number, street name, city, state, zip
24
 
 
25
 
      $siteContacts = $ag_facility_geo->getAgSite()->getAgEntity()->getAgEntityAddressContact();
26
 
      foreach ($siteContacts as $siteContact) {
27
 
        $address = $siteContact->getAgAddress();
28
 
        $addressValues = $address->getAgAddressMjAgAddressValue();
29
 
        $formats = $address->getAgAddressStandard()->getAgAddressFormat();
30
 
        $facilityAddress[$siteContact->getAddressId()] = '';
31
 
        foreach ($formats as $format) {
32
 
          $string = '';
33
 
          $addressValues = $address->getAgAddressMjAgAddressValue();
34
 
          foreach ($addressValues as $addressValue) {
35
 
            if ($addressValue->getAgAddressValue()->getAddressElementId()  == $format->getAddressElementId()) {
36
 
              $facilityAddress[$siteContact->getAddressId()][] = $addressValue->getAgAddressValue()->value; //okay, i have to have these in order.
37
 
              //the array needs to be reset, crazy concat
38
 
            }
39
 
          }
40
 
          $order[$format->getLineSequence()][$format->getInlineSequence()] = $string;
41
 
        }
42
 
      }
43
 
      //we should put a check here for 'work' and 'home' address and only retrieve those, currently it is 0 and 1 (first and second contact
44
 
      $addressKeys = array_keys($facilityAddress);
45
 
      if(isset($facilityAddress[$addressKeys[0]]))
46
 
      {
47
 
        foreach($facilityAddress[$addressKeys[0]] as $addressPart){
48
 
          echo $addressPart . ' '; //echo the entire address
49
 
        }
50
 
        $streetnumber = substr($facilityAddress[$addressKeys[0]][0], 0,strpos($facilityAddress[$addressKeys[0]][0],' '));// agGis::parse_address($facilityAddress[$addressKeys[0]][0]);
51
 
        //parse address should be better, i want it to return streetname AND number!
52
 
        $streetname = substr($facilityAddress[$addressKeys[0]][0], strpos($streetnumber['number'], $facilityAddress[$addressKeys[0]][0]));
53
 
        $zip = $facilityAddress[$addressKeys[0]][3];
54
 
        echo '<a class=linkButton href="' . url_for('gis/geocode') . '?number=' . $streetnumber['number'] . '&street=' . $streetname  . '&zip=' . $zip . '&address_id=' . $addressKeys[0] . '">geo</a>';
55
 
      }?>
56
 
      </td>
57
 
      <td><?php echo $ag_facility_geo->getUpdatedAt() ?></td>
58
 
    </tr>
59
 
 
60
 
    <?php
61
 
    endforeach;
62
 
    ?>
63
 
  </tbody>
64
 
</table>
65
 
 
66
 
  <a class="linkButton" href="<?php echo url_for('gis/new') ?>">New</a>
 
 
b'\\ No newline at end of file'