<script type="text/javascript" src="js/admin/kindeditor/kindeditor.js"></script>
<script type="text/javascript" src="js/admin/kindeditor/lang/zh_CN.js"></script>
<div class="form">
<script>
var editor;
KindEditor.ready(function(K) {
    editor = K.create('#SoftContent_info',
        {
            resizeType : 1,
            allowPreviewEmoticons : false,
            allowImageUpload : true,
            allowFileManager : true,
            newlineTag : 'br',
            items : [
                'source', 'preview', 'fullscreen', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
                'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
                'insertunorderedlist', '|', 'image', 'link']
        });
});
</script>

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'soft-content-form',
	'enableAjaxValidation'=>false,
)); ?>
<fieldset>
    <legend></legend>
	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'name'); ?>
		<?php echo $form->textField($model,'name',array('size'=>60,'maxlength'=>200)); ?>
		<?php echo $form->error($model,'name'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'short_name'); ?>
		<?php echo $form->textField($model,'short_name',array('size'=>50,'maxlength'=>50)); ?>
		<?php echo $form->error($model,'short_name'); ?>
	</div>

    <div class="row">
		<?php echo $form->labelEx($model,'version'); ?>
		<?php echo $form->textField($model,'version',array('size'=>20,'maxlength'=>50)); ?>
		<?php echo $form->error($model,'version'); ?>
	</div>
    
    <div class="row">
        <table>
            <tr>
                <td><?php echo $form->labelEx($model,'type'); ?>
		<?php echo $form->dropDownList($model,'type', SoftContent::getTypeList(), array('ajax'=>array('type'=>'post','url'=>$this->createUrl('/admin/softcontent/ajaxchangetype'),'update'=>'#type', 'data'=>'js:"type="+jQuery(this).val()',)));?>
		<?php echo $form->error($model,'type'); ?></td>
                <td> </td>
                <td><?php echo $form->labelEx($model,'cid'); ?>
        <div id="type">
            <?php echo $form->dropDownList($model,'cid', CHtml::listData($category, 'id', 'name')); ?>
        </div>
        <?php echo $form->error($model,'cid'); ?></td>
                <td> </td>
                <td><?php echo $form->labelEx($model,'pid'); ?>
		<?php echo $form->dropDownList($model,'pid', CHtml::listData($platform, 'id', 'name'));?>
		<?php echo $form->error($model,'pid'); ?></td>
                <td> </td>
                <td><?php echo $form->labelEx($model,'iscommend'); ?>
		<?php echo $form->dropDownList($model,'iscommend', array(0=>'不推荐', 1=>'推荐')); ?>
		<?php echo $form->error($model,'iscommend'); ?></td>
                <td> </td>
                <td><?php echo $form->labelEx($model,'isfree'); ?>
		<?php echo $form->dropDownList($model,'isfree', array(0=>'非推广', 1=>'推广')); ?>
		<?php echo $form->error($model,'isfree'); ?></td>
                <td></td>
            </tr>
        </table>

	</div>

    <div class="row">
		<?php echo $form->labelEx($model,'award'); ?>
		<?php echo $form->textField($model,'award'); ?>(设置后用户下载软件即可获得相应的积分奖励，0表示没有)
		<?php echo $form->error($model,'award'); ?>
	</div>
    <div class="row">
		<?php echo $form->labelEx($model,'award_expiry'); ?>
        <?php $this->widget('zii.widgets.jui.CJuiDatePicker', array('name'=>'SoftContent[award_expiry]', 'value'=>$model->award_expiry, 'language' => 'zh_cn', 'options' => array('dateFormat'=>'yy-mm-dd')));?>
		<?php echo $form->error($model,'award_expiry'); ?>
	</div>
    
	<div class="row">
		<?php echo $form->labelEx($model,'info'); ?>
		<?php echo $form->textArea($model,'info',array('rows'=>20, 'cols'=>100)); ?>
		<?php echo $form->error($model,'info'); ?>
	</div>

    <div class="row">
		<?php echo $form->labelEx($model,'adurl'); ?>
		<?php echo $form->textField($model,'adurl',array('size'=>50,'maxlength'=>50)); ?>(一般空着即可)
		<?php echo $form->error($model,'adurl'); ?>
	</div>
    
    <div class="row">
		<?php echo $form->labelEx($model,'tips'); ?>
		<?php echo $form->textField($model,'tips',array('size'=>60,'maxlength'=>200)); ?>
		<?php echo $form->error($model,'tips'); ?>
	</div>
    
	<div class="row">
        <table>
            <tr>
                <td><?php echo $form->labelEx($model,'day_download'); ?>
		<?php echo $form->textField($model,'day_download'); ?>
		<?php echo $form->error($model,'day_download'); ?></td>
                <td></td>
                <td><?php echo $form->labelEx($model,'week_download'); ?>
		<?php echo $form->textField($model,'week_download'); ?>
		<?php echo $form->error($model,'week_download'); ?></td>
                <td></td>
                <td><?php echo $form->labelEx($model,'month_download'); ?>
		<?php echo $form->textField($model,'month_download'); ?>
		<?php echo $form->error($model,'month_download'); ?></td>
                <td></td>
                <td><?php echo $form->labelEx($model,'download'); ?>
		<?php echo $form->textField($model,'download'); ?>
		<?php echo $form->error($model,'download'); ?></td>
                <td></td>
                <td></td>
            </tr>
        </table>

	</div>

<?php if (!$model->isNewRecord):?>
<?php if ($model->cpic):?>
    <h2>已上传软件截图列表</h2>
    
    <?php foreach ($model->cpic as $pic):?>
        <div><?php echo $pic->name;?> <?php echo CHtml::link('删除', '', array('ajax'=>array('type'=>'get','url'=>$this->createUrl('/admin/softcontent/deleteimage',array('id'=>$pic->id)),'success'=>'$(this).parent().remove()')));?></div>
    <?php endforeach;?>
<?php endif;?>
<script type="text/javascript" src="<?php echo Yii::app()->baseUrl;?>/js/admin/swfupload/swfupload.js"></script>
<script type="text/javascript" src="<?php echo Yii::app()->baseUrl;?>/js/admin/swfupload/handlers.js"></script>
<script type="text/javascript">

    var swfu;
window.onload = function () {
    swfu = new SWFUpload({
        // Backend Settings
        upload_url: "<?php echo $this->createUrl('/admin/softcontent/uploadimage',array('id'=>$model->id));?>",
        post_params: {"PHPSESSID": "<?php echo session_id();?>"},

        // File Upload Settings
        file_post_name : "SoftContent[Filedata]",
        file_size_limit : "2 MB",	// 2MB
        file_types : '*.gif;,*.jpg',
        file_types_description : "JPG Images",
        file_upload_limit : "0",

        file_queue_error_handler : fileQueueError,
        file_dialog_complete_handler : fileDialogComplete,
        upload_progress_handler : uploadProgress,
        upload_error_handler : uploadError,
        upload_success_handler : uploadSuccess,
        upload_complete_handler : uploadComplete,

        // Button Settings
        //button_image_url : "SmallSpyGlassWithTransperancy_17x18.png",
        button_placeholder_id : "spanButtonPlaceholder",
        button_width: 180,
        button_height: 18,
        button_text : '<span class="button">选择软件截图(不能大于2M)</span>',
        button_text_style : '.button { font-family: Helvetica, Arial, sans-serif; font-size: 12pt; } .buttonSmall { font-size: 10pt; }',
        button_text_top_padding: 0,
        button_text_left_padding: 18,
        button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
        button_cursor: SWFUpload.CURSOR.HAND,

        // Flash Settings
        flash_url : "<?php echo Yii::app()->baseUrl;?>/js/admin/swfupload/swfupload.swf",

        custom_settings : {upload_target : "divFileProgressContainer"},

        debug: false
    });
};
</script>
<div>
	<h2>批量上传软件截图</h2>
		<form>
		<div style="display: inline; border: solid 1px #7FAAFF; background-color: #C5D9FF; padding: 4px;">
			<span id="spanButtonPlaceholder"></span>

		</div>
	</form>
		<div id="divFileProgressContainer" style="height: 75px;"></div>
	<div id="thumbnails"></div>
</div>
<?php endif;?>
	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? '创建' : '保存'); ?>
	</div>
</fieldset>

<?php $this->endWidget(); ?>


</div>