<?php
use common\assets\SwfUploadAsset;
use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\ActiveForm;
use common\widgets\DatePicker;

/* @var $this \yii\web\View */
/* @var $content string */

$asset = SwfUploadAsset::register($this);
?>

<?php $this->beginPage() ?>
<!doctype html>
<html>
	<head>
		<meta charset="<?= Yii::$app->charset ?>">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<?= Html::csrfMetaTags() ?>
		<title>查看附件</title>
		<?php $this->head() ?>
		<style>
			html, body, div, dl, dt, dd, ul, p, th, td, h1, h2, h3, h4, h5, h6, pre, code, form, fieldset, legend {
                margin: 0;
                padding: 0;
            }
            body {
                color: #333;
                font-family: Arial;
                font-size: 12px;
                line-height: 1.5;
            }
            li {
                list-style: outside none none;
            }
            a {
                color: #266aae;
                text-decoration: none;
            }
			.h_a {
				background: none repeat scroll 0 0 #e6e6e6;
				border-bottom: 1px solid #ffffff;
				border-top: 1px solid #ddd;
				color: #666666;
				font-size: 12px;
				font-weight: 700;
				padding: 5px 9px;
			}
			.cc:after {
				clear: both;
				content: " ";
				display: block;
				height: 0;
				visibility: hidden;
			}
			.search_type {
				padding: 10px;
			}	
			/*上传*/
			.eidt_uphoto {
				border: 1px solid #CCCCCC;
			}
			.eidt_uphoto ul {
				height: 280px;
				overflow-y: scroll;
				padding-bottom: 10px;
				position: relative;
			}
			.eidt_uphoto li {
				display: inline;
				float: left;
				height: 100px;
				margin: 10px 0 0 10px;
				width: 87px;
			}
			.eidt_uphoto .invalid {
				background: none repeat scroll 0 0 #FBFBFB;
				border: 1px solid #CCCCCC;
				height: 98px;
				position: relative;
				width: 78px;
			}
			.eidt_uphoto .invalid .error {
				padding: 30px 1px;
				text-align: center;
			}
			.eidt_uphoto .no {
				background: url("<?= $asset->baseUrl ?>/images/icon/upload_pic.jpg") no-repeat scroll center center #FBFBFB;
				border: 1px solid #CCCCCC;
				height: 98px;
				overflow: hidden;
				text-indent: -2000em;
			}
			.eidt_uphoto .nouplode {
				background: #FBFBFB;
				border: 1px solid #CCCCCC;
				height: 98px;
				overflow: hidden;
				text-align: center;
				padding: 0px 5px 0px 5px;
			}
			.eidt_uphoto .schedule {
				background: none repeat scroll 0 0 #FFFFFF;
				border: 1px solid #CCCCCC;
				height: 98px;
				line-height: 98px;
				position: relative;
				text-align: center;
			}
			.eidt_uphoto .schedule span {
				background: none repeat scroll 0 0 #F0F5F9;
				height: 98px;
				left: 0;
				position: absolute;
				top: 0;
			}
			.eidt_uphoto .schedule em {
				left: 0;
				position: absolute;
				text-align: center;
				top: 0;
				width: 78px;
				z-index: 1;
			}
			.eidt_uphoto .get{
				background:#ffffff;
				border:1px solid #cccccc;
				position:relative;
				overflow:hidden;
			}
			.eidt_uphoto .selected{
				border:2px solid #1D76B7;
			}
			.eidt_uphoto .get img{
				cursor:pointer;
			}
			.eidt_uphoto .del{
				position:absolute;
				width:15px;
				height:15px;
				background:url("<?= $asset->baseUrl ?>/images/icon/upload_del.png") no-repeat;
				right:1px;
				top:1px;
				overflow:hidden;
				text-indent:-2000em;
				display:none;
			}
			.eidt_uphoto .del:hover{
				background-position:-20px 0;
			}
			.eidt_uphoto .get img{
				vertical-align:top;
				width:87px;
				height:75px;
				border-bottom:1px solid #ccc;
			}
			.eidt_uphoto .get input{
				border:0;
				outline:0 none;
				margin-left:3px;
			}
			.eidt_uphoto .get .edit{
				position:absolute;
				height:22px;
				line-height:22px;
				text-align:center;
				width:78px;
				bottom:0;
				left:0;
				background:#e5e5e5;
				color:#333;
				filter:alpha(opacity=70);
				-moz-opacity:0.7;
				opacity:0.7;
				display:none;
			}
			.eidt_uphoto li:hover .edit,
			.eidt_uphoto li:hover .del{
				/*text-decoration:none;
				display:block;*/
			}
			/*上传选择按钮*/
			#btupload,.addnew{
				background: url("<?= $asset->baseUrl ?>/js/swfupload/images/swfBnt.png") no-repeat; float:left; margin-right:10px;width:75px; height:28px; line-height:28px;font-weight:700; color:#fff;
			}
			#btupload{ 
				vertical-align:middle;border:none;cursor: hand;!important;cursor: pointer;
			}
			.addnew{
				background: url("<?= $asset->baseUrl ?>/js/swfupload/images/swfBnt.png") no-repeat; float:left; margin-right:10px;width:75px; height:28px; line-height:28px;font-weight:700; color:#fff;
			}
			.addnew{
				background-position: left bottom;
			}
			.pages {
				text-align: center;
			}
			.pagination {
				border-radius: 4px;
				display: inline-block;
				margin: 0 auto;
				padding-left: 0;
			}
			.pagination > li {
				display: inline;
			}
			.pagination > .active > a, .pagination > .active > span, .pagination > .active > a:hover, .pagination > .active > span:hover, .pagination > .active > a:focus, .pagination > .active > span:focus {
				background-color: #428bca;
				border-color: #428bca;
				color: #fff;
				cursor: default;
				z-index: 2;
			}
			.pagination > li > a, .pagination > li > span {
				background-color: #fff;
				border: 1px solid #ddd;
				color: #428bca;
				float: left;
				line-height: 1.42857;
				margin-left: -1px;
				padding: 4px 10px;
				position: relative;
				text-decoration: none;
			}

		</style>
	<body class="body_none" style="height:350px;">
		<?php $this->beginBody() ?>
		<div class="">
			<div class="h_a">搜索</div>
			<?php $searchForm = ActiveForm::begin([ 'id' => 'search-form', 'action' => ['list'], 'method' => 'get']); ?>
				<div class="search_type cc mb10" style="margin-bottom:10px">
					<div class="mb10"> <span class="mr20"> 名称：
							<input type="text" class="input length_2" name="filename" style="width:200px;" value="<?= (isset($get['filename'])) ? Html::encode($get['filename']) : '' ?>" placeholder="请输入文件名">
							日期：
                            <?= DatePicker::widget(['attribute' => 'time', 'inputConfig' => ['class' => 'input length_2 J_date', 'style' => 'width:80px;'], 'inputValue' => (isset($get['time'])) ? Html::encode($get['time']) : '']) ?>
                            <input type="hidden" name="upload_num" value="<?= (int) Yii::$app->request->get('upload_num') ?>" />
							<button type="submit" class="btn">搜索</button>
                        </span>
                     </div>
				</div>
			<?php ActiveForm::end(); ?>
			<div class="eidt_uphoto">
				<ul  style="height: 220px;" id="fsUploadProgress">
                    <?php if (!empty($models)) : ?>
					<?php foreach ($models as $model): ?>
						<li class="uploaded">
							<div class="get" id="aid-<?php echo $model->attach_id; ?>"> <a class="del" href="javascript:;">删除</a> <img onClick="album_cancel(this, '<?php echo $model->attach_id; ?>', '<?php echo $model->file_path; ?>')" width="87" height="98" src="<?php echo (in_array($model->file_ext, ['jpg', 'jpeg', 'png', 'gif', 'bmp'])) ? $model->file_path : Yii::getAlias('@web').'/static/images/ext/' . $model->file_ext . '.png' ?>" data-id="<?php echo $model->attach_id; ?>" data-path="<?php echo $model->file_path; ?>" alt="<?php echo $model->file_name; ?>" title="<?php echo $model->file_name; ?>">
								<input type="text" class="J_file_desc" name="flashatt[<?php echo $model->attach_id; ?>]" value="<?php echo $model->file_name; ?>" style="width:68px">
							</div>
						</li>
					<?php endforeach; ?>
					<?php else : ?>
                        <p style="text-align:center;margin-top:10px;">暂无数据...</p>
					<?php endif; ?>
				</ul>
			</div>
			<div class="p10" style="margin-top:5px;">
				<div class="pages">
					<?= \yii\widgets\LinkPager::widget(['pagination' => $pages]); ?>
				</div> 
			</div>
		</div>
		<script type="text/javascript">
			$(document).ready(function() {
				set_status_empty();
			});
			function set_status_empty() {
				parent.window.$('#att-status').html('');
				parent.window.$('#att-name').html('');
			}
			function album_cancel(obj, id, source) {
				var src = $(obj).attr("data-path");
				var filename = $(obj).attr("title");
				var id = $(obj).attr("data-id");
				//选择状态中的数据对象
				var selected = $("#fsUploadProgress .selected");
				if ($("#aid-" + id).hasClass('selected')) {
					$("#aid-" + id).removeClass("selected");
					selected = $("#fsUploadProgress .selected");
					var imgstr = parent.window.$("#att-status").html();
					var length = selected.children("img").length;
					var strs = filenames = ids = '';
					for (var i = 0; i < length; i++) {
						strs += '|' + selected.children("img").eq(i).attr('path');
						filenames += '|' + selected.children("img").eq(i).attr('title');
						ids += '|' + selected.children("img").eq(i).attr('data-id');
					}
					parent.window.$('#att-status').html(strs);
					parent.window.$('#att-name').html(filenames);
					parent.window.$('#att-id').html(ids);
				} else {
					var num = parent.window.$('#att-status').html().split('|').length;
					var file_upload_limit = '<?= $upload_num ?>';
					if (num > file_upload_limit) {
						alert('不能选择超过' + file_upload_limit + '个附件');
						return false;
					}
					$("#aid-" + id).addClass("selected");
					parent.window.$('#att-status').append('|' + src);
					parent.window.$('#att-name').append('|' + filename);
					parent.window.$('#att-id').append('|' + id);
				}
			}
		</script>
		<?php $this->endBody() ?>
	</body>
</html>
<?php $this->endPage() ?>
