166 lines
5.4 KiB
Plaintext
166 lines
5.4 KiB
Plaintext
<cfsilent></cfsilent>
|
||
<cfimport prefix="m" taglib="lib"/>
|
||
<cfimport prefix="m" taglib="lib/data"/>
|
||
<cfimport prefix="layout" taglib="layout"/>
|
||
|
||
<cfparam name="entity"/>
|
||
<cfparam name="doc_id" type="integer"/>
|
||
|
||
<!--- validate entity to prevent sql injection--->
|
||
<cfmodule template="mod/attach_support.cfm" entity="#entity#" output="entitySpec"/>
|
||
|
||
<m:prepare_detail entity="#entity#_doc" pageInfoOut="pageInfo"/>
|
||
<!--- осторожно, в странице entity, а в pageInfo entity_doc! --->
|
||
<cfset pageInfo.formEncType="multipart/form-data"/>
|
||
|
||
<m:upload field="doc" output="attach"/>
|
||
|
||
<cfset "#entity#_doc_id"=#doc_id#/>
|
||
|
||
<m:bean readonly=#!pageInfo.writePermitted()# table="#pageInfo.entity#" datasource="#request.ds#" output="d" status="status" meta="m">
|
||
<m:param field="#entity#_doc_id" type="integer" key autoincrement />
|
||
<m:param field="#entity#_doc" type="varchar" size="255"/>
|
||
|
||
<cfif attach.ok>
|
||
<m:param field="doc" type="varbinary" value=#attach.binaryData#/>
|
||
<m:param field="contenttype" type="varchar" size="255" value=#attach.contenttype#/>
|
||
<m:param field="fname" type="varchar" size="255" value=#attach.filename#/>
|
||
<cfelse>
|
||
<m:param field="contenttype" type="varchar" size="255" readonly/>
|
||
<m:param field="fname" type="varchar" size="255" readonly/>
|
||
</cfif>
|
||
|
||
<m:param field="creator_id" type="integer" value="#request.usr_id#" skipUpdate/>
|
||
<m:param field="updater_id" type="integer" value="#request.usr_id#" />
|
||
<m:param field="dt_created" type="timestamp" value="#Now()#" skipUpdate/>
|
||
<m:param field="dt_updated" type="timestamp" value="#Now()#"/>
|
||
</m:bean>
|
||
|
||
<cfset doc_id=d["#entity#_doc_id"]/>
|
||
|
||
|
||
<m:dispatch_detail
|
||
usePRG="No"
|
||
pageInfo=#pageInfo#
|
||
data=#d#
|
||
status=#status#
|
||
trackOut="tr"
|
||
idAttributesOut="id"
|
||
/>
|
||
|
||
|
||
<!--- #entity# is validated --->
|
||
<cfquery name="qAttributes" datasource="#request.DS#">
|
||
select
|
||
d.#entity#_id as entity_id, d.#entity#_doc as title, datalength(d.doc) as doc_size, d.contenttype, d.fname,
|
||
a.login as creator, a.shortname as creator_name, u.login as modifier, u.shortname as modifier_name
|
||
from #entity#_doc d
|
||
left outer join usr a on (d.creator_id=a.usr_id)
|
||
left outer join usr u on (d.updater_id=u.usr_id)
|
||
where d.#entity#_doc_id=<cfqueryparam attributeCollection=#id#/>
|
||
</cfquery>
|
||
|
||
<cfquery name="qEntity" datasource="#request.DS#">
|
||
#entitySpec.selectHead#
|
||
where d.#entity#_id=<cfqueryparam cfsqltype="CF_SQL_INTEGER" value=#qAttributes.entity_id# null=#!isValid("integer", qAttributes.entity_id)#/>
|
||
</cfquery>
|
||
<!--- ----------------------------------------------------------------------------
|
||
---------------------------------------------------------------------------------------------
|
||
---------------------------------------------------------------------------------------------
|
||
---><layout:page section="header" pageInfo=#pageInfo#>
|
||
<layout:attribute name="title">
|
||
|
||
Документ
|
||
<cfoutput query="qAttributes">
|
||
<b><cfif len(title)>#title#<cfelse>#fname#</cfif></b>
|
||
<cfif len(contenttype)>(#contenttype#)</cfif>
|
||
</cfoutput>
|
||
|
||
<cfoutput query="qEntity">
|
||
<b><cfset Evaluate("WriteOutput('#entitySpec.format#')")/></b>
|
||
</cfoutput>
|
||
|
||
|
||
</layout:attribute>
|
||
</layout:page>
|
||
|
||
|
||
<cfoutput>
|
||
<input type="hidden" name="doc_id" value="#doc_id#">
|
||
<input type="hidden" name="entity" value="#entity#">
|
||
<input type="hidden" name="track" value="#tr.self#"/>
|
||
|
||
<div class="detail">
|
||
|
||
|
||
<div class="tr">
|
||
<div class="th">Название документа</div>
|
||
<div class="td">
|
||
<input type="text" name="#entity#_doc" value="#qAttributes.title#" size="63" maxlength="255" style="width:100%">
|
||
</div>
|
||
</div>
|
||
|
||
<cfif doc_id GT 0>
|
||
<div class="tr">
|
||
<div class="th">Имя файла</div>
|
||
<div class="td">
|
||
#qAttributes.fname#
|
||
<a href="doc_get.cfm?entity=#entity#&doc_id=#doc_id#" target="_blank"><img src="img/view.gif" title="просмотр (в новом окне)"/></a>
|
||
<a href="doc_get.cfm?entity=#entity#&doc_id=#doc_id#&action=download"><img src="img/download.png" title="скачать"/></a>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="tr">
|
||
<div class="th">Content Type</div>
|
||
<div class="td">
|
||
#qAttributes.contenttype#
|
||
<m:contenttype_icon contenttype=#qAttributes.contenttype#/>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="tr">
|
||
<div class="th">Размер</div>
|
||
<div class="td">
|
||
#qAttributes.doc_size# байт
|
||
</div>
|
||
</div>
|
||
</cfif>
|
||
|
||
<cfif pageInfo.writePermitted()>
|
||
<div class="tr">
|
||
<div class="th">Заменить файл</div>
|
||
<div class="td">
|
||
<input type="file" name="doc"/>
|
||
</div>
|
||
</div>
|
||
</cfif>
|
||
|
||
<div class="tr">
|
||
<div class="th">Создано</div>
|
||
<div class="td">
|
||
#dateFormat(d.dt_created,'DD.MM.YYYY')# #timeFormat(d.dt_created,'HH:MM')#
|
||
#qAttributes.creator# <cfif len(qAttributes.creator_name)>(#qAttributes.creator_name#)</cfif>
|
||
<i>Дата и время первоначальной загрузки</i>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="tr">
|
||
<div class="th">Изменен</div>
|
||
<div class="td">
|
||
#dateFormat(d.dt_updated,'DD.MM.YYYY')# #timeFormat(d.dt_updated,'HH:MM')#
|
||
#qAttributes.modifier# <cfif len(qAttributes.modifier_name)>(#qAttributes.modifier_name#)</cfif>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
</cfoutput>
|
||
|
||
|
||
<layout:page section="extension" closeForm="Yes"/>
|
||
|
||
<cfif listFind(d.contenttype, "image","/") EQ 1><!--- preview --->
|
||
<cfoutput><img src="doc_get.cfm?entity=#entity#&doc_id=#doc_id#" style="max-width:100%;"/></cfoutput>
|
||
</cfif>
|
||
|
||
<layout:page section="footer"/>
|