Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added Tariff Types Filter and Sort to getTariffs

  • Loading branch information...
commit 59917f1485c65175c9d39ea61e1498553cd150fb 1 parent 03911b8
Matthew Fong mfong authored
Showing with 33 additions and 6 deletions.
  1. +20 −4 examples/tariffs.php
  2. +13 −2 genability.php
24 examples/tariffs.php
View
@@ -13,7 +13,9 @@
// make the getTariffs call
$output = $gen->getTariffs(array(
'search' => $_POST['search'],
- 'zipCode' => $_POST['zipCode']
+ 'zipCode' => $_POST['zipCode'],
+ 'tariffTypes' => $_POST['tariffTypes'],
+ 'sortOn' => $_POST['sortOn']
));
}
?>
@@ -45,6 +47,22 @@
<label for="zipCode">Zip Code</label>
<input type="text" id="zipCode" name="zipCode" value="<?=$_POST['zipCode']?>"/>
</div>
+ <div class="inputBlock">
+ <label>Tariff Types</label>
+ <input type="checkbox" name="tariffTypes[]" value="DEFAULT" id="default"<?if ($_POST) foreach($_POST['tariffTypes'] as $option) { if ($option == 'DEFAULT') echo ' checked'; }?>><label for="default" class="cb">Default</label>
+ <input type="checkbox" name="tariffTypes[]" value="ALTERNATIVE" id="alternative"<?if ($_POST) foreach($_POST['tariffTypes'] as $option) { if ($option == 'ALTERNATIVE') echo ' checked'; }?>><label for="alternative" class="cb">Alternative</label>
+ <input type="checkbox" name="tariffTypes[]" value="OPTIONAL_EXTRA" id="optional_extra"<?if ($_POST) foreach($_POST['tariffTypes'] as $option) { if ($option == 'OPTIONAL_EXTRA') echo ' checked'; }?>><label for="optional_extra" class="cb">Optional Extra</label>
+ <input type="checkbox" name="tariffTypes[]" value="RIDER" id="rider"<?if ($_POST) foreach($_POST['tariffTypes'] as $option) { if ($option == 'RIDER') echo ' checked'; }?>><label for="rider" class="cb">Rider</label>
+ </div>
+ <div class="inputBlock">
+ <label>Sort On</label>
+ <input type="checkbox" name="sortOn[]" value="masterTariffId" id="sort_masterTariffId"<?if ($_POST) foreach($_POST['sortOn'] as $option) { if ($option == 'masterTariffId') echo ' checked'; }?>><label for="sort_masterTariffId" class="cb">Master Tariff Id</label>
+ <input type="checkbox" name="sortOn[]" value="lseId" id="sort_lseId"<?if ($_POST) foreach($_POST['sortOn'] as $option) { if ($option == 'lseId') echo ' checked'; }?>><label for="sort_lseId" class="cb">LSE Id</label>
+ <input type="checkbox" name="sortOn[]" value="lseName" id="sort_lseName"<?if ($_POST) foreach($_POST['sortOn'] as $option) { if ($option == 'lseName') echo ' checked'; }?>><label for="sort_lseName" class="cb">LSE Name</label>
+ <input type="checkbox" name="sortOn[]" value="tariffCode" id="sort_tariffCode"<?if ($_POST) foreach($_POST['sortOn'] as $option) { if ($option == 'tariffCode') echo ' checked'; }?>><label for="sort_tariffCode" class="cb">Tariff Code</label>
+ <input type="checkbox" name="sortOn[]" value="tariffName" id="sort_tariffName"<?if ($_POST) foreach($_POST['sortOn'] as $option) { if ($option == 'tariffName') echo ' checked'; }?>><label for="sort_tariffName" class="cb">Tariff Name</label>
+ <input type="checkbox" name="sortOn[]" value="tariffType" id="sort_tariffType"<?if ($_POST) foreach($_POST['sortOn'] as $option) { if ($option == 'tariffType') echo ' checked'; }?>><label for="sort_tariffType" class="cb">Tariff Type</label>
+ </div>
<button type="submit">Get Tariffs!</button>
</form>
@@ -61,7 +79,6 @@
<table class="tariff_rates">
<thead>
<tr>
- <th>Tariff Id</th>
<th>Master Tariff Id</th>
<th>Lse Id</th>
<th>Lse Name</th>
@@ -74,8 +91,7 @@
<tbody>
<? foreach ($tariffsArr["results"] as $results) { ?>
<tr>
- <td><?=$results["tariffId"]?></td>
- <td><?=$results["tariffId"]?></td>
+ <td><?=$results["masterTariffId"]?></td>
<td><?=$results["lseId"]?></td>
<td><?=$results["lseName"]?></td>
<td><?=$results["tariffCode"]?></td>
15 genability.php
View
@@ -104,8 +104,19 @@ function getTariffs($params) {
$url = $this->GENABILITY_API_URL . "tariffs/" . $this->API_PARAMS;
foreach ($params as $key => $value) {
- if ($value != null || $value != '')
- $url .= "&" . $key . "=" . rawurlencode($value);
+ if ($value != null || $value != '') {
+ $url .= "&" . $key . "=";
+ if (is_array($value)) {
+ for ($i=0; $i < sizeof($value); $i++) {
+ if ($i > 0) {
+ $url .= ',';
+ }
+ $url .= $value[$i];
+ }
+ } else {
+ $url .= rawurlencode($value);
+ }
+ }
}
if ($this->config['debug']) { echo $url; }
Please sign in to comment.
Something went wrong with that request. Please try again.