All pastes #245450 Raw Edit

Miscellany

public text v1 · immutable
#245450 ·published 2006-11-11 00:36 UTC
rendered paste body
<%
	if isempty(request("idCategory")) then
		response.redirect "viewAllCategories.asp?error="& escape("ERROR: Please select a category")
		response.end
	end if
%>
<!-- #include file="inc/serv/db.asp"-->
<!-- #include file="../includes/htmlfuncs.asp"-->
<%

	on error resume next

	dim rs, rsRand, rsPhoto, idCategory, status_msg, title, hierarchy(4, 2)

	title = "Edit Category"
	
	hierarchy(0, 0) = "Home"
	hierarchy(0, 1) = "home.asp"
	
	hierarchy(1, 0) = "Inventory Management"
	hierarchy(1, 1) = "inventoryOverview.asp"
	
	hierarchy(2, 0) = "Categories"
	hierarchy(2, 1) = "viewAllCategories.asp"
	
	idCategory = cLng(request("idCategory"))
	
	if not isempty(request.form("btnUpdateCategory")) then
		set adoProc = server.createObject("ADODB.Command")
		
		proc = run_proc(adoProc, "sp_updateCategory", adExecuteNoRecords, empty)
		if proc <> true then
			status_msg = status_msg &"<p class=""error"">ERROR: Could not update category.<br />"& proc &"</p>"
		else
			status_msg = status_msg &"<p class=""success"">Successfully Modified Category.</p><br />"
		end if
		
		set adoProc = nothing
	end if
	
	set rs = ado.execute("exec sp_getCategory "& idCategory)
	
	if err.number <> 0 then
		status_msg = status_msg &"<p class=""error"">ERROR: Could not retrieve category information.<br />"& err.description &"</p><br />"
		err.clear
		
		hierarchy(3, 0) = "Category Not Found"
	else
		hierarchy(3, 0) = "Edit: "& rs("name")
	end if
	
	set rsPhoto = ado.execute("exec sp_getCategoryPhotos "& idCategory)
	if err.number <> 0 then
		status_msg = status_msg &"<p class=""error"">ERROR: Could not retrieve category photos.<br />"& err.description &"</p><br />"
		err.clear
	end if
	
	set rsRand = ado.execute("exec sp_getCategoryThumbnails "& idCategory)
	if err.number <> 0 then
		status_msg = status_msg &"<p class=""error"">ERROR: Could not retrieve category thumbnails.<br />"& err.description &"</p><br />"
	end if

	hierarchy(3, 1) = "editCategory.asp?idCategory="& idCategory	

%>
<!-- #include file="doc.asp"-->
<!-- #include file="hierarchy.asp"-->

<script type="text/javascript">

	idCategory = <%= idCategory%>;
	num_photots = <%= rsPhoto.recordCount%>;

</script>

<h1 id="title">edit category: <%= lcase(rs("name"))%></h1>

<form action="editCategory.asp" method="post" name="frmCategory">
<table cellspacing="2" cellpadding="0" border="0" class="form">
	<% if status_msg <> "" then %>
		<tr>
			<td colspan="2" class="status">
				<%= left(status_msg, len(status_msg) - 6)%>
			</td>
		</tr>
		<tr>
			<td colspan="2" class="rowspace" />
		</tr>
	<% end if %>
	<tr>
		<th>category name</th>
		<td><input type="text" name="name" value="<%= rs("name")%>" /></td>
	</tr>
	<tr>
		<td colspan="2" class="form_controls">
			<input type="hidden" name="idCategory" value="<%= idCategory%>" />
			<input type="hidden" name="is_active" value="<%= -cBool(rs("is_active"))%>" />
			<input id="disable" type="checkbox" name="disable" value="1"<%
				if rs("is_active") = false then
					response.write " checked=""checked"""
				end if
			%> class="chk" onclick="this.form.is_active.value = (this.checked) ? 0 : 1;" />
			<label for="disable">disable this category</label>
			
			&nbsp;&nbsp;&nbsp;&nbsp;
			<input id="is_additional" type="checkbox" name="is_additional" value="1" class="chk" <%
				if rs("is_additional") = 1 or rs("is_additional") = true then
					response.write "checked=""checked"" "
				end if
			%>/>
			<label for="is_additional">additional category</label>
			
			<br /><br />
			<input type="submit" name="btnUpdateCategory" value="edit category" class="submit" />
		</td>
	</tr>
</table>
</form>

<table cellspacing="0" cellpadding="0" border="0" class="thumbnail_photos">
	<tr>
		<th style="width:240px; border-right:1px solid #BFBFBF;">random thumbnail photos</th>
	</tr>
	<tr>
		<td valign="top" style="width:220px; border-top:0px; border-left:1px solid #BFBFBF;">
			<div id="thumbnail_photo_container"><div id="thumbnail_photos"><%
				while not rsRand.eof
					for count = 1 to 2
						if rsRand.eof then exit for
						
						height = 90
						
						if rsRand("thumb_width") <> "" then
							width = rsRand("thumb_width")
						else
							width = 90
						end if
						
						if rsRand("thumb_height") > 90 then
							width = height * rsRand("thumb_width") / rsRand("thumb_height")
						end if
						
						response.write "<a href=""editPhoto.asp?idPhoto="& rsRand("idPhoto") &""" class=""wht_thumbnail"" title="""& replace(rsRand("title"), """", "&quot;") &""">"
						response.write "<img id=""thumbnail_photo_"& rsRand("id") &""" src="""& WWW &"/i/thumb/"& rsRand("thumb_image") &""" "
						response.write "width="""& width &""" height="""& height &""" "
						response.write "alt="""& replace(rsRand("title"), """", "&quot;") &""" ondragstart=""return false;"" /></a>"
						
						rsRand.moveNext
					next
				wend
			%></div></div>
		</td>
	</tr>
</table>

<div id="bottom_photos">
	<div id="category_photo_title">photo title</div>
	<div id="photo_container">
		<div id="category_photos">
			<%
				count = 1
				do while rsPhoto.state <> adStateClosed
					do while not (rsPhoto = nothing or rsPhoto.eof)
						height = 90
						
						if rsPhoto("thumb_width") <> "" then
							width = rsPhoto("thumb_width")
						else
							width = 90
						end if
						
						if rsPhoto("thumb_height") > 90 then
							width = height * rsPhoto("thumb_width") / rsPhoto("thumb_height")
						end if
						
						response.write "<a id="""& count &""" href=""editPhoto.asp?idPhoto="& rsPhoto("id") &""" class=""thumbnail"" title="""& replace(rsPhoto("title"), """", "&quot;") &""" onmouseover=""show_photo_title(this);"" onmouseout=""hide_photo_title();"">"
						response.write "<img id=""photo_"& rsPhoto("id") &""" src="""& WWW &"/i/thumb/"& rsPhoto("thumb_image") &""" width="""& width &""" height="""& height &""" alt="""& replace(rsPhoto("title"), """", "&quot;") &""" ondragstart=""return false;"" />"
						response.write "</a>"& vbcrlf
						
						count = count + 1
						rsPhoto.moveNext
					loop
					
					set rsPhoto = rsPhoto.getNextRecordSet
				loop
			%>
		</div>
	</div>
</div>

<div id="related_links">
	<a href="viewAllCategories.asp" class="related_link">view all categories</a><br />
	<a href="createCategory.asp" class="related_link">create category</a><br />
	<a href="createPhoto.asp" class="related_link">upload photograph</a>
</div>

<!-- #include file="bottom.asp"-->