Beispiel #1
0
</textarea>
					</div>

					<h2>Select Gear</h2>
					<p>Quantities are chosen at checkout based on what is available.</p>
					<hr />

					<?php 
$currGearList = $pkg->getGearList();
$types = getGearTypes();
foreach ($types as $type) {
    $items = Gear::getGearListWithType($type['gear_type_id']);
    echo "<h4>" . $type['type'] . "</h4>";
    foreach ($items as $item) {
        $gearObject = new Gear();
        $gearObject->fetch($item['gear_id']);
        echo "<div class='checkbox'>";
        if (in_array($gearObject->getID(), $currGearList)) {
            echo "<label><input type='checkbox' name='gear[]' value='" . $gearObject->getID() . "' checked> " . $gearObject->getName();
        } else {
            echo "<label><input type='checkbox' name='gear[]' value='" . $gearObject->getID() . "'> " . $gearObject->getName();
        }
        echo "</label></div>";
    }
    echo "<br />";
}
?>
					<br />
					<input class="btn btn-success" type="submit" name="submit" value="Submit">
                </form>
            </div>
Beispiel #2
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 #3
0
 $i = 0;
 foreach ($gearTypes as $gearType) {
     if ($i % 2 == 0) {
         //start row
         echo "<div class='row'>";
         echo "<div class='col-sm-4 col-sm-offset-2'>";
     } else {
         echo "<div class='col-sm-4'>";
     }
     echo "<div class='panel panel-default'>";
     echo "<div class='panel-heading text-center'>" . $gearType . "</div>";
     echo "<div class='panel-body text-center'>";
     echo "<p>";
     foreach ($gearList as $gear) {
         $gearObject = new Gear();
         $gearObject->fetch($gear[0]);
         $qty = $gear[1];
         $type = gearTypeWithID($gearObject->getType());
         //gearTypeWithID(getGearType($gear[0]));
         if ($type == $gearType) {
             if ($qty > 1) {
                 echo $gearObject->getName() . " ({$qty})<br />";
             } else {
                 echo $gearObject->getName() . "<br />";
             }
         }
     }
     echo "</p>";
     echo "</div></div></div>";
     //panel-body //panel //col
     //if second col on row or last col, end the row
Beispiel #4
0
}
require_once 'models/Gear.php';
require_once 'models/funcs.php';
$types = getGearTypes();
//define variables and set to empty values
$name = $category = "";
//process each variable
if ($_SERVER["REQUEST_METHOD"] == "GET") {
    $gear_id = test_input($_GET['gear_id']);
    $gearObject = new Gear();
    $gearObject->fetch($gear_id);
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $gear_id = test_input($_POST['gear_id']);
    $gearObject = new Gear();
    $gearObject->fetch($gear_id);
    //can be empty. placeholder text in form
    $name = test_input($_POST['name']);
    //can be empty. placeholder text in form
    $qty = test_input($_POST['qty']);
    //type cannot be empty. one will be filled at least.
    $type = test_input($_POST['type']);
    $newType = test_input($_POST['newType']);
    $newIsDisabled = test_input($_POST['disabled']);
    $newNotes = test_input($_POST['notes']);
    //------------------------ name changes ------------------------
    if (!empty($name)) {
        //user changed name
        $gearObject->setName($name);
        $successes[] = "Renamed gear item to {$name}";
    }
Beispiel #5
0
 public function finalizeCheckout()
 {
     $database = new DB();
     //if the co_id is unset, this is a new checkout
     if (isset($this->co_id)) {
         //old checkout
         $sql = "UPDATE checkouts SET title='{$this->title}', person_id='{$this->person_id}', co_start='{$this->co_start}', co_end='{$this->co_end}', description='{$this->description}', dr_number='{$this->dr_number}', location='{$this->location}' WHERE co_id='{$this->co_id}'";
         $database->query($sql);
         //set return datetime
         if (isset($this->returned)) {
             $sql = "UPDATE checkouts SET returned='{$this->returned}' WHERE co_id='{$this->co_id}'";
             $database->query($sql);
         }
         //remove all old co_gear relations from table
         $sql = "DELETE FROM co_gear WHERE co_id='{$this->co_id}'";
         $database->query($sql);
     } else {
         //new checkout
         //create the new checkout
         $sql = "INSERT INTO checkouts(title,person_id,co_start,co_end,description,dr_number,location) VALUES('{$this->title}','{$this->person_id}','{$this->co_start}','{$this->co_end}','{$this->description}','{$this->dr_number}','{$this->location}')";
         $database->query($sql);
         //retrieve co_id from newly inserted checkout
         $sql = "SELECT co_id FROM checkouts WHERE person_id='{$this->person_id}' AND co_start='{$this->co_start}' AND co_end='{$this->co_end}' AND description='{$this->description}'";
         $results = $database->select($sql);
         $this->co_id = $results[0]['co_id'];
     }
     //add the checkout gear relations
     foreach ($this->gearList as $gearItem) {
         //check to see if the item is available
         $gearObject = new Gear();
         $gearObject->fetch($gearItem[0]);
         if ($gearObject->availableQty($this->co_start, $this->co_end) > 0) {
             $gear_id = $gearItem[0];
             $gearQty = $gearItem[1];
             $sql = "INSERT INTO co_gear(gear_id,co_id,qty) VALUES('{$gear_id}','{$this->co_id}','{$gearQty}')";
             $database->query($sql);
         } else {
             //requested item not available
             //do some error logging here...
         }
     }
     //foreach
 }
Beispiel #6
0
						<input type="hidden" name="co_end" value="<?php 
    echo $co_end;
    ?>
" />
						<?php 
    //make sure gear list is resubmitted
    foreach ($gearList as $gear) {
        echo "<input type='hidden' name='gear[]' value='{$gear}' />";
    }
    //get quantities...
    if (count($gearToGetQtyFor) == 0) {
        echo "<p><strong>There are no items to get quantity for. Click below to finish</strong></p>";
    } else {
        foreach ($gearToGetQtyFor as $gear) {
            $gearObject = new Gear();
            $gearObject->fetch($gear);
            echo $gearObject->getName() . "&nbsp;&nbsp;&nbsp;";
            echo "<select name='gearQty[]'>";
            $qty = $gearObject->availableQty($co_start, $co_end);
            $currQty = $co->qtyOfItem($gearObject->getID());
            for ($i = 1; $i <= $qty; $i++) {
                if ($i == $currQty) {
                    echo "<option value='{$i}' selected='selected'>{$i}</option>";
                } else {
                    echo "<option value='{$i}'>{$i}</option>";
                }
            }
            echo "</select><br /><br />";
        }
    }
    ?>
Beispiel #7
0
                     <col class="one-quarter">                            
                 </colgroup>
                 <thead>
                     <tr>
                         <!-- <th class="hidden-xs hidden-sm">ID</th> -->
                         <th>Name</th>
                         <th>Status</th>
                         <th>Last Checkout</th>
                         <th class="text-center">Quantity</th>
                     </tr>
                 </thead>
                 <tbody>
                     <?php 
 foreach ($gearList as $gear) {
     $gearObject = new Gear();
     $gearObject->fetch($gear['gear_id']);
     printf("<tr>");
     printf("<td><a href='gear-item.php?gear_id=%s'>%s</a></td>", $gear['gear_id'], $gear['name']);
     echo "<td>" . $gearObject->status(date('Y-m-d h:m:s')) . "</td>";
     $co_id = $gearObject->lastCheckoutID();
     //fetchLastCheckout($gear['gear_id']);
     if (!empty($co_id)) {
         $co = new Checkout();
         $co->retrieveCheckout($co_id);
         printf("<td><a href='checkout.php?co_id=%s'>%s</a></td>", $co_id, getPersonName($co->getPerson()));
     } else {
         //no last checkout
         printf("<td>n/a</td>");
     }
     printf("<td class='text-center'>%s</td>", $gearObject->getQty());
     //$gear['qty']