Let users browse vendors and remove some duplicate code

This commit is contained in:
Tony Lambregts
2005-10-25 00:47:32 +00:00
committed by WineHQ
parent 14a3d83d51
commit 40138af1a8
7 changed files with 149 additions and 193 deletions

View File

@@ -1,44 +0,0 @@
<?php
include("path.php");
require(BASE."include/incl.php");
require(BASE."include/vendor.php");
if(!$_SESSION['current']->hasPriv("admin"))
{
errorpage();
exit;
}
$oVendor = new Vendor($_REQUEST['vendorId']);
if($_REQUEST['submit'])
{
$oVendor->update($_REQUEST['name'],$_REQUEST['webpage']);
redirect(apidb_fullurl("admin/adminVendors.php"));
}
else
{
apidb_header("Add Vendor");
echo "<form method=\"post\" action=\"addVendor.php\">
<input type=\"hidden\" name=\"vendorId\" value=\"".$oVendor->iVendorId."\" />
<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">
<tr>
<td width=\"15%\" class=\"box-label\"><b>Vendor name</b></td>
<td class=\"box-body\">
<input type=\"text\" size=\"50\" name=\"name\" value=\"".$oVendor->sName."\" />
</td>
</tr>
<tr>
<td width=\"15%\" class=\"box-label\"><b>Vendor URL</b></td>
<td class=\"box-body\">
<input type=\"text\" size=\"50\" name=\"webpage\" value=\"".$oVendor->sWebpage."\" />
</td>
</tr>
<tr>
<td colspan=\"2\" class=\"box-body\">
<input type=\"submit\" name=\"submit\" value=\"Submit\" />
</td>
</tr>
</table>
</form>";
}
apidb_footer();
?>

View File

@@ -1,64 +0,0 @@
<?php
/*************************************************************/
/* code to view and maintain the list of application vendors */
/*************************************************************/
/*
* application environment
*/
include("path.php");
require(BASE."include/incl.php");
require_once(BASE."include/vendor.php");
if(!$_SESSION['current']->hasPriv("admin"))
{
errorpage("Insufficient privileges.");
exit;
}
if ($_REQUEST['sub'])
{
if($_REQUEST['sub'] == 'delete')
{
$oVendor = new Vendor($_REQUEST['vendorId']);
$oVendor->delete();
redirect(apidb_fullurl("admin/adminVendors.php"));
}
} else
{
apidb_header("Admin Vendors");
//get available vendors
$sQuery = "SELECT vendorId FROM vendor ORDER BY vendorName, vendorId;";
$hResult = query_appdb($sQuery);
// show vendorlist
echo html_frame_start("","90%","",0);
echo "<table width='100%' border=0 cellpadding=3 cellspacing=0>\n\n";
echo "<tr class=color4>\n";
echo " <td>Vendor name</td>\n";
echo " <td>Vendor url</td>\n";
echo " <td>Linked apps</td>\n";
echo " <td align=\"center\">Action</td>\n";
echo "</tr>\n\n";
$c = 1;
while($ob = mysql_fetch_object($hResult))
{
if ($c % 2 == 1) { $bgcolor = 'color0'; } else { $bgcolor = 'color1'; }
$oVendor = new Vendor($ob->vendorId);
echo "<tr class=\"$bgcolor\">\n";
echo " <td><a href=\"".BASE."vendorview.php?vendorId=".$oVendor->iVendorId."\">".$oVendor->sName."</a></td>\n";
echo " <td><a href=\"".$oVendor->sWebpage."\">".$oVendor->sWebpage."</a></td>\n";
echo " <td>".sizeof($oVendor->aApplicationsIds)."</td>\n";
echo " <td align=\"center\">[<a href='addVendor.php?vendorId=".$oVendor->iVendorId."'>edit</a>] &nbsp; [<a href='adminVendors.php?sub=delete&vendorId=".$oVendor->iVendorId."'>delete</a>]";
echo " </td>\n";
echo "</tr>\n\n";
$c++;
}
echo "</table>\n\n";
echo html_frame_end("&nbsp;");
}
apidb_footer();
?>

View File

@@ -1,44 +1,39 @@
<?php
include("path.php");
require(BASE."include/incl.php");
require(BASE."include/vendor.php");
require_once(BASE."include/incl.php");
require_once(BASE."include/vendor.php");
if(!$_SESSION['current']->hasPriv("admin"))
{
errorpage();
exit;
}
$oVendor = new Vendor($_REQUEST['vendorId']);
if($_REQUEST['submit'])
$oVendor = new Vendor($_REQUEST['iVendorId']);
if($_REQUEST['Submit'])
{
$oVendor->update($_REQUEST['name'],$_REQUEST['webpage']);
redirect(apidb_fullurl("admin/adminVendors.php"));
$oVendor->update($_REQUEST['sName'],$_REQUEST['sWebpage']);
redirect(apidb_fullurl("vendorview.php"));
}
else
{
apidb_header("Edit Vendor");
echo "<form method=\"post\" action=\"addVendor.php\">
<input type=\"hidden\" name=\"vendorId\" value=\"".$oVendor->iVendorId."\" />
<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"2\">
<tr>
<td width=\"15%\" class=\"box-label\"><b>Vendor name</b></td>
<td class=\"box-body\">
<input type=\"text\" size=\"50\" name=\"name\" value=\"".$oVendor->sName."\" />
</td>
</tr>
<tr>
<td width=\"15%\" class=\"box-label\"><b>Vendor URL</b></td>
<td class=\"box-body\">
<input type=\"text\" size=\"50\" name=\"webpage\" value=\"".$oVendor->sWebpage."\" />
</td>
</tr>
<tr>
<td colspan=\"2\" class=\"box-body\">
<input type=\"submit\" name=\"submit\" value=\"Submit\" />
</td>
</tr>
</table>
</form>";
if($oVendor->iVendorId)
apidb_header("Edit Vendor");
else
apidb_header("Add Vendor");
// Show the form
echo '<form name="qform" action="'.$_SERVER['PHP_SELF'].'" method="post" enctype="multipart/form-data">',"\n";
$oVendor->OutputEditor();
echo '<tr valign=top><td class=color3 align=center colspan=2>',"\n";
echo '<input name="Submit" type="submit" value="Submit" class="button" >&nbsp',"\n";
echo '</td></tr>',"\n";
echo "</form>";
echo html_frame_end("&nbsp;");
apidb_footer();
}
?>