Example #1
0
function operate_user_vehicle_association()
{
    ?>
	<h2>User Vehicle Association</h2>
	<h3>Bind a new vehicle</h3>
	<form method="post" >
	<p>
		<label for="vehicle" required">Select a Vehicle</label><br/>
		<select name="selected_vehicle">
			<?php 
    $rows = fetch_vehicles();
    foreach ($rows as $row) {
        $output = "<option value={$row->id}>{$row->VIN}</option>";
        echo $output;
    }
    ?>
		</select>
	</p>
	<input type="submit" name="add_vehicle_to_association" value="Add"/>
</form>
<h3>Browse User Vehicle Association</h3>
<form method="post">
<table>
	<thead>
		<tr>
			<th width="8%">Vehicle Name</th>
			<th width="10%">Select default vehicle</th>
			<th width="3%">Remove</th>
			<th width="79%"></th>
		</tr>
	</thead>
	<tbody>
		<?php 
    $myrows = fetch_associations();
    $oldDefaultVehicle = 0;
    foreach ($myrows as $myrow) {
        $vin = fetch_VIN_by_id($myrow->vehicleID);
        $isDefault = $myrow->defaultVehicle;
        //$output = "<tr><td align='center'>$vehcile_name</td>";
        $output = "<tr><td align='center'>{$vin}</td>";
        /*$link_arr_paras = array('action' => 'edit', 'configid' => $myrow->id);
        		$link = add_query_arg($link_arr_paras);
        		$edit = "<td align='center'><a href=$link alt='Edit Vehicle Configuration'><img src='/wordpress/wp-content/plugins/vehicle-configuration/images/edit.png' /></a></td>";
        		$output .= $edit;*/
        if ($isDefault == true) {
            $output .= "<td align='center'><input type=radio name=defaultVehicle value={$myrow->id} checked=yes /></td>";
            $oldDefaultVehicle = $myrow->id;
        } else {
            $output .= "<td align='center'><input type=radio name=defaultVehicle value={$myrow->id} /></td>";
        }
        $link_arr_paras = array('actionForAssociation' => 'remove', 'associationID' => $myrow->id);
        $link = add_query_arg($link_arr_paras);
        $remove = "<td align='center'><a href={$link} alt='Remove Vehicle Configuration'><img src='/wordpress/wp-content/plugins/vehicle-configuration/images/remove.png' /></a></td>";
        $output .= $remove;
        $output .= "</tr>";
        echo $output;
    }
    echo "<input type=hidden name=oldDefaultVehicle value={$oldDefaultVehicle} />";
    ?>
	</tbody>
	<tfoot>
		<tr>
			<th>Vehicle Name</th>
			<th>Select default vehicle</th>
			<th>Remove</th>
		</tr>
	</tfoot>
</table>

<input type="submit" name="bind_default_vehicle" value="Bind Default Vehicle"/>
</form>
<?php 
}
Example #2
0
function vehicle_configuration_form()
{
    ?>
<h2>Vehicle Configuration</h2>
<h3>Add a new Vehicle Configuration</h3>
<form method="post" >
	<p>
		<label for="vehicle" required">Vehicle</label><br/>
		<select id="vehicle" name="vehicle">
			<?php 
    $myrows = fetch_vehicles();
    foreach ($myrows as $myrow) {
        $output = "<option value={$myrow->id}>{$myrow->VIN}</option>";
        echo $output;
    }
    ?>
		</select>
	</p>
	<p>
		<label for="name-field" required>Name</label><br/>
		<input id="name-field" name="name-field" type="text" value=""/>
	</p>
	<p>
		<label for="ecuID" required>ECU Reference</label><br/>
		<input id="ecuID" name="ecuID" type="text" value=""/>
	</p>
	<p>
		<label for="description">Description</label><br/>
		<input id="description" name="description" type="text" value=""/>
	</p>
	<p>
		<label for="function">Function</label><br/>
		<input id="function" name="function" type="text" value=""/>
	</p>
	<p>
		<label for="manufactory">Manufactory</label><br/>
		<input id="manufactory" name="manufactory" type="text" value=""/>
	</p>
	<input type="submit" name="Add_configuration" value="Add (ignored)"/>
</form>
<h3>Browse Vehicle Configuration</h3>
<table>
	<thead>
		<tr>
			<th width="10%">Name</th>
			<th width="10%">ECU</th>
			<th width="35%">Description</th>
			<th width="20%">Function</th>
			<th width="20%">Manufactory</th>
			<th width="5%">Remove</th>

		</tr>
	</thead>
	<tbody>
		<?php 
    $myrows = fetch_configurations();
    if ($myrows != NULL) {
        foreach ($myrows as $myrow) {
            $output = "<tr><td align='center'>{$myrow->name}</td><td align='center'>{$myrow->ecuId}</td><td align='center'>{$myrow->description}</td><td align='center'>{$myrow->function}</td><td align='center'>{$myrow->manufactory}</td>";
            /*$link_arr_paras = array('action' => 'edit', 'configid' => $myrow->id);
            		$link = add_query_arg($link_arr_paras);
            		$edit = "<td align='center'><a href=$link alt='Edit Vehicle Configuration'><img src='/wp/wp-content/plugins/vehicle-configuration/images/edit.png' /></a></td>";
            		$output .= $edit;*/
            $link_arr_paras = array('action' => 'remove', 'configid' => $myrow->id);
            $link = add_query_arg($link_arr_paras);
            $remove = "<td align='center'><a href={$link} alt='Remove Vehicle Configuration'><img src='/wp/wp-content/plugins/vehicle-configuration/images/remove.png' /></a></td>";
            $output .= $remove;
            $output .= "</tr>";
            echo $output;
        }
    }
    ?>
	</tbody>
	<tfoot>
		<tr>
			<th>Name</th>
			<th>ECU</th>
			<th>Description</th>
			<th>Function</th>
			<th>Manufactory</th>
			<th>Remove</th>
		</tr>
	</tfoot>
</table>
<?php 
}