Beispiel #1
0
 public static function getAvailableGearWithTypeAndExclusions($type, $co_id, $co_start, $co_end)
 {
     $results = self::getGearListWithType($type);
     if (is_null($co_id)) {
         //do not exclude any checkouts
         foreach ($results as $row) {
             //check if in stock for dates
             $gearObject = new Gear();
             $gearObject->fetch($row['gear_id']);
             if ($gearObject->availableQty($co_start, $co_end) > 0 && !$gearObject->isDisabled()) {
                 //add object to return array if in stock
                 $availableGear[] = $row;
             }
         }
     } else {
         //with exclusions
         foreach ($results as $row) {
             //check if in stock for dates
             $gearObject = new Gear();
             $gearObject->fetch($row['gear_id']);
             if ($gearObject->availableQtyExcludingCheckout($co_id, $co_start, $co_end) > 0 && !$gearObject->isDisabled()) {
                 //add object to return array if in stock
                 $availableGear[] = $row;
             }
         }
     }
     return $availableGear;
 }
Beispiel #2
0
    echo $co_start;
    ?>
" />
						<input type="hidden" name="co_end" value="<?php 
    echo $co_end;
    ?>
" />
						<?php 
    foreach ($types as $type) {
        $items = Gear::getAvailableGearWithTypeAndExclusions($type['gear_type_id'], $co_id, $co_start, $co_end);
        if (count($items) > 0) {
            printf("<h4>%s</h4>", $type['type']);
            foreach ($items as $item) {
                $gearObject = new Gear();
                $gearObject->fetch($item['gear_id']);
                $qty = $gearObject->availableQtyExcludingCheckout($co_id, $co_start, $co_end);
                echo "<div class='checkbox'>";
                echo "<label><input type='checkbox' name='gear[]' value='" . $gearObject->getID() . "'";
                //if the gear item is already assigned to checkout, check it by default
                if (isset($simpleGearList) && in_array($gearObject->getID(), $simpleGearList)) {
                    echo "checked > " . $gearObject->getName();
                } else {
                    echo "> " . $gearObject->getName();
                }
                //list quantity next to gear items.
                if ($qty > 1) {
                    echo " (" . $qty . ")";
                }
                echo "</label></div>";
                //break;
            }