Beispiel #1
0
<div id='cssmenu'>
    <ul>
        <li><a href='survey.php'><span>NHVBSR</span></a></li>
        <li><a href='lakeHostHome.php'><span>Manage Lake Hosts</span></a></li>
        <li><a href='survey.php'><span>Survey</span></a></li>
        <li><a href='view.php'><span>View</span></a></li>
        <li><a href='edit.php'><span>View/Edit</span></a></li>
        <li><a href='reports.php'><span>Reports</span></a></li>
        <li><a href='index.php'><span>Logout</span></a></li>
    </ul>
</div>
<br><br><br>

<div id="info">
    <h2>Boater Survey List</h2>
    <hr>
    <?php 
//$user_id = 3;
$model = new surveyModel();
$view = new surveyView();
$role = $model->getUserRole($_SESSION['UserID']);
if ($role == "StaffMember") {
    header('Location: view\\accessSitesPage.php');
} else {
    $view->viewSurveysList($_SESSION['UserID']);
}
?>
</div>
<!-- comment -->
</body>
</html>
    public function editSurvey($survey_id, $role)
    {
        $model = new surveyModel();
        $db1 = new db1();
        //Making an instance of the Model class.
        $result = $model->getSurvey($survey_id);
        //$result is an array of the survey information obtained from the Model->getSurvey function.
        $siteID = $result['siteID'];
        $accessSiteName = $db1->getSiteName($siteID);
        //Site name will be displayed only for group leaders.
        echo "<br/>";
        $time = $result['inputTime'];
        $date = $result['inputDate'];
        $status = $result['launchStatus'];
        $state = $result['registrationState'];
        $type = $result['boatType'];
        $interaction = $result['previousInteraction'];
        $lastSite = $result['lastSiteVisited'];
        $lastTown = $result['lastTownVisited'];
        $lastState = $result['lastStateVisited'];
        $drained = $result['drained'];
        $rinsed = $result['rinsed'];
        $dried = $result['dryForFiveDays'];
        $awareness = $result['boaterAwareness'];
        $specimenFound = $result['specimenFound'];
        $bowNumber = $result['bowNumber'];
        $DES = $result['sentToDES'];
        $notes = $result['notes'];
        $active = $result['active'];
        //echo "the value of des is ".$DES;
        //All these variables are used to extract survey information from the $result array.
        $launchedValue = "";
        $retrievedValue = "";
        $inboardOutboardValue = "";
        $pwcJetSkiJetValue = "";
        $canoeKayakValue = "";
        $sailValue = "";
        $otherValue = "";
        $interactionYesValue = "";
        $interactionNoValue = "";
        $lastSiteValue = "";
        $lastTownValue = "";
        $lastStateValue = "";
        $drainedYesValue = "";
        $drainedNoValue = "";
        $rinsedYesValue = "";
        $rinsedNoValue = "";
        $driedYesValue = "";
        $driedNoValue = "";
        $awarenessHighValue = "";
        $awarenessMediumValue = "";
        $awarenessLowValue = "";
        $specimenFoundYesValue = "";
        $specimenFoundNoValue = "";
        $bowNumberValue = "";
        $sentYesValue = "";
        $sentNoValue = "";
        $activeYesValue = "";
        $activeNoValue = "";
        /*These variables are used to set the values of the form elements to null. Later the elements values will be change based on the information obtained from
          the database*/
        if (strcmp($status, "Launched") == 0) {
            $launchedValue = "checked = 'true'";
        } else {
            $retrievedValue = "checked = 'true'";
        }
        //If the status is 'Retrieved' then the Retrieved button will be checked
        switch ($type) {
            case "inboard/outboard(I/O)":
                $inboardOutboardValue = "checked ='true'";
                // If type is inboard/outboard(I/O) then this button will be checked
                break;
            case "PWC/jet ski/jet boat":
                $pwcJetSkiJetValue = "checked = 'true'";
                // If type is pwcJetSkiJetValue then this button will be checked
                break;
            case "canoe/kayak":
                $canoeKayakValue = "checked = 'true'";
                // If type is canoeKayakValue then this button will be checked
                break;
            case "sail":
                $sailValue = "checked = 'true'";
                // If type is sail then this button will be checked
                break;
            case "other":
                $otherValue = "checked = 'true'";
                // If type is other then this button will be checked
                break;
        }
        if ($interaction == 1) {
            $interactionYesValue = "checked = 'true'";
        } else {
            $interactionNoValue = "checked = 'true'";
        }
        //If the value from the database is no then this button will be checked
        if ($lastSite != Null & $lastSite != "") {
            //If the value of lastSite is not null then fill the values of lastSite, lastTown and lastState from the $result array.
            $lastSiteValue = $lastSite;
            $lastTownValue = $lastTown;
            $lastStateValue = $lastState;
            if ($drained == 1) {
                $drainedYesValue = "checked = 'true'";
            } else {
                $drainedNoValue = "checked = 'true'";
            }
            //If the value from the database is no then this button will be checked
            if ($rinsed == 1) {
                $rinsedYesValue = "checked = 'true'";
            } else {
                $rinsedNoValue = "checked = 'true'";
            }
            //If the value from the database is no then this button will be checked
            if ($dried == 1) {
                $driedYesValue = "checked = 'true'";
            } else {
                $driedNoValue = "checked = 'true'";
            }
            //If the value from the database is no then this button will be checked
        }
        if (strcmp($awareness, "High") == 0) {
            $awarenessHighValue = "checked = 'true'";
        } else {
            if (strcmp($awareness, "Medium") == 0) {
                $awarenessMediumValue = "checked = 'true'";
            } else {
                $awarenessLowValue = "checked = 'true'";
            }
        }
        //If the value from the database is Low then this button will be checked
        if ($specimenFound == 1) {
            //If specimen is found then fill in the bown nubmer and sentToDES value.
            $specimenFoundYesValue = "checked = 'true'";
            $bowNumberValue = $bowNumber;
            if ($DES != "" & $DES != Null) {
                if ($DES == 1) {
                    $sentYesValue = "checked = 'true'";
                } else {
                    if ($DES == 0) {
                        $sentNoValue = "checked = 'true'";
                    }
                }
            }
        } else {
            $specimenFoundNoValue = "checked = 'true'";
        }
        if ($active == 1) {
            $activeYesValue = "checked = 'true'";
        } else {
            $activeNoValue = "checked = 'true'";
        }
        $sentToDESRow = "";
        //This row is displayed for GroupLeaders and StaffMembers only.
        $notesRow = "";
        //This row is displayed for GroupLeaders and StaffMembers only.
        $activeRow = "";
        //This row is displayed for GroupLeaders and StaffMembers only.
        if ($role == 'GroupLeader') {
            echo $accessSiteName;
        }
        //If the user is a GroupLeader then disply the site name.
        if ($role == 'GroupLeader' || $role == 'StaffMember') {
            $sentToDESRow = <<<_END
Sent to DES: <input type='radio' name='sentToDES' value=1 {$sentYesValue}>YES  
<input type='radio' name='sentToDES' value=0 {$sentNoValue}>NO
_END;
            $notesRow = <<<_END
<tr><td>Notes</td>
                        <td>
                                <textarea name="notes"rows="3" cols="50">{$notes}</textarea>
                        </td>
                </tr>
_END;
            $activeRow = <<<_END
<tr>
            <td><input type='radio' name='active' value=1 {$activeYesValue}> Verified</td>
            <td><input type='radio' name='active' value=0 {$activeNoValue}> Not verified</td>
                        </tr>
_END;
        }
        $form = <<<_END
<form name='myForm' method='post' action='../model/updateSurvey.php'>
        <table name='myTable'>
\t\t<tr><td>Survey ID</td>
\t\t<td><input type="text" name="surveyID" value={$survey_id} readOnly="true"></td>
\t\t<tr>
          <tr>
            <td>Time:</td>
            <td><input type='time' name='time' value={$time}></td>
          </tr>
                  <tr>
            <td>Date:</td>
            <td><input type='date' name='date' value={$date}></td>
          </tr>
                  <tr>
            <td>Indicate if vessel is being launched or retrieved
            <br /></td>
            <td>
            <input type='radio' name='status' value='Launched' {$launchedValue}>Launched
            <input type='radio' name='status' value='Retrieved' {$retrievedValue}>Retrieved</td>
          </tr>
          <tr>
            <td>State of Registration:</td>
            <td><input type='text' id='sor' name='registrationState' onblur='validatesor()' value={$state}><div id='sorDiv'></div></td>
          </tr>
          <tr>
            <td>Type of boat:</td>
            <td>
            <input type='radio' name='boat' value='inboard/outboard(I/O)' {$inboardOutboardValue} >inboard/outboard(I/O)
            <input type='radio' name='boat' value='PWC/jet ski/jet boat' {$pwcJetSkiJetValue}>PWC/jet ski/jet boat
            <br />
            <input type='radio' id='3' name='boat' value='canoe/kayak' {$canoeKayakValue}>canoe/kayak
            <input type='radio' id='4' name='boat' value='sail' {$sailValue}>sail
            <br />
            <input type='radio' id='5' name='boat' value='other' {$otherValue}>other</td>
          </tr>
          <tr>
            <td>Previous interaction with a Lake Host?</td>
            <td>
            <input type='radio' name='interaction' value=1 {$interactionYesValue}> YES
            <input type='radio' name='interaction' value=0 {$interactionNoValue}> NO</td>
          </tr>
          <tr>
            <td>Last waterbody visited</td>
            <td>
                                Name: <input type='text' name='lastSiteVisited' value={$lastSiteValue}> Town: <input type='text' name='lastTownVisited' value={$lastTownValue}>
                                State: <input type='text' name='lastStateVisited' value={$lastStateValue}>
                                <br/> Drained?  <input type='radio' name='drained' value=1 {$drainedYesValue}> YES <input type='radio' name='drained' value=0 {$drainedNoValue}> NO
                                <br/> Rinsed?  <input type='radio' name='rinsed' value=1 {$rinsedYesValue}> YES <input type='radio' name='rinsed' value=0 {$rinsedNoValue}> NO
                                <br/> Dry for at least 5 days?  <input type='radio' name='dryForFiveDays' value=1 {$driedYesValue}> YES <input type='radio' name='dryForFiveDays' value=0 {$driedNoValue}> NO
                        </td>
          </tr>
          <tr id='awarenessRow'>
            <td>Boater&#39;s awareness of AIS plant &amp; animal problem?</td>
            <td>
            <input type='radio' name='awareness' value='High' {$awarenessHighValue}>High
            <input type='radio' name='awareness' value='Medium' {$awarenessMediumValue}>Medium
            <input type='radio' name='awareness' value='Low' {$awarenessLowValue}>Low
            <br /></td>
          </tr>
          <tr>
            <td>Specimen found?</td>
            <td>
                                <input type='radio' name='specimenFound' value=1 {$specimenFoundYesValue}>Yes <input type='radio' name='specimenFound' value='High' value=0 {$specimenFoundNoValue}>No <br/>
                                Full Bow Number: <input type='text' name='bowNumber' value={$bowNumberValue}> <br/>
                                {$sentToDESRow}
                        </td>
          </tr>
                  {$notesRow}
                  {$activeRow}
          <tr>
            <td>
              <input type='submit' value='Submit' />
            </td>
          </tr>
        </table>
_END;
        return $form;
    }