<link rel="stylesheet" href="/js/jquery-ui/smoothness/jquery-ui-1.8.21.custom.css" type="text/css" />
<script type="text/javascript" src="/js/jquery-ui/jquery-ui-1.8.21.custom.min.js"></script>

<script>
    $(function() {
        $("#t_expires").datepicker({
            showButtonPanel: true
        });
    })

    var editor;
    KindEditor.ready(function(K) {
        editor = K.create('#p_solution', {
            width: '100%',
            height: '360px',
            filterMode: false,
            allowImageUpload: false,
            items: [
                'source', '|', 'undo', 'redo', '|', 'preview', 'cut', 'copy', 'paste', 'plainpaste', 'wordpaste', '|',
                'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', '|',
                'clearhtml', 'quickformat', 'removeformat', 'selectall', '/', 'fullscreen', '|',
                'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
                'italic', 'underline', 'strikethrough', 'lineheight', '|', 'table', 'hr', 'emoticons', 'image', 'map', 'pagebreak',
                'link', 'unlink', '|', 'about'
            ]
        });
		
    });
	
    //选择内容图片
    function openKCFinder_Content() {
        window.CallBack = openKCFinder_Content_callback;
        window.open('/media/popselectpicture.php?site_lgc=<?php echo $this->config->item('site_lgc'); ?>', 'kcfinder_textbox', 'status=0, toolbar=0, location=0, menubar=0, directories=0,resizable=1, scrollbars=0, width=800, height=600');
    }
    function openKCFinder_Content_callback(result) {
        var site_image_url = '<?php echo $this->config->item('media_image_url') ?>';
        if (result != null) {
			for (var key in result.Pinfo) {
				editor.insertHtml('<img src="' + site_image_url + result.Pinfo[key].PUrl + '" alt="' + result.Pinfo[key].PName + '" width="' + result.Pinfo[key].Width + '" height="' + result.Pinfo[key].Height + '" />');
			}
        }
    }
	
</script>

<div class="row-fluid">
    <div class="span2">
        <?php echo $nav_view; ?>
    </div>

    <div class="span9">
	
		<form id="form_project_edit" name="form_project_edit" method="post" action="<?php echo site_url('project/edit_submit') ?>">
		
			<div class="row-fluid">

				<div class="span2">
					<label>项目类型</label>
					<select name="p_type" id="p_type" class="span12" >
						<?php foreach($this->config->item('project_types') as $type_item=>$type_name) 
						{
							$selected=false;
							if (isset($project)) 
							{
								if($type_item==$project->p_type)
								{
									$selected=' selected ';
								}
							}
							
						?>
						<option <?php echo $selected; ?> value="<?php echo $type_item; ?>" ><?php echo $type_name; ?></option>
						<?php } ?>
					</select>
				</div>
				
				<div class="span10">
					<label>项目名称</label>
					<input class="span12" type="text" id="p_title" name="p_title" value="<?php echo isset($project)?$project->p_title:false; ?>" >
				</div>
					
			</div>
			
			<label>项目介绍</label>
			<textarea name="p_memo" id="p_memo" class="span12" ><?php echo isset($project)?$project->p_memo:false; ?></textarea>
			
			<div class="row-fluid">
				<div class="span3">
					<label>负责人</label>
					<select name="p_manager" id="p_manager" class="span12" >
					<option  value="0" >-</option>
						<?php foreach($operator_list as $operator) 
						{
							$selected=false;
							if (isset($project)) 
							{
								if($operator->OPI_Code==$project->p_manager)
								{
									$selected=' selected ';
								}
							}
							
						?>
						<option <?php echo $selected ?> value="<?php echo $operator->OPI_Code;  ?>" ><?php echo $operator->OPI_Code.' '.$operator->OPI_Name ?></option>
						<?php } ?>
					</select>
				</div>

				<div class="span3">
					<label>需求方</label>
					<select name="p_requirer" id="p_requirer" class="span12" >
					<option  value="0" >-</option>
						<?php foreach($operator_list as $operator) 
						{
							$selected=false;
							if (isset($project)) 
							{
								if($operator->OPI_Code==$project->p_requirer)
								{
									$selected=' selected ';
								}
							}
							
						?>
						<option <?php echo $selected ?> value="<?php echo $operator->OPI_Code;  ?>" ><?php echo $operator->OPI_Code.' '.$operator->OPI_Name ?></option>
						<?php } ?>
					</select>
				
				</div>
				
				<div class="span3">
					<label>项目状态</label>
					<select name="p_state" id="p_state" class="span12" >
						<?php foreach($this->config->item('project_state') as $state_item=>$state_name) 
						{
							$selected=false;
							if (isset($project)) 
							{
								if($state_item==$project->p_state)
								{
									$selected=' selected ';
								}
							}
							
						?>
						<option <?php echo $selected; ?> value="<?php echo $state_item; ?>" ><?php echo $state_name; ?></option>
						<?php } ?>
					</select>
				
				</div>
				
				<div class="span3">
					<label>奖金</label>
					<input class="span12" type="text" id="p_bonus" name="p_bonus" value="<?php echo isset($project)?$project->p_bonus:0; ?>" >
				</div>
			
				
			</div>
			
			<label>技术解决方案 <a href="javascript:void(0);" onclick="openKCFinder_Content();" title="插入内容图片"><i class="icon-picture pull-right"></i></a></label>
				<textarea name="p_solution" id="p_solution" class="span12" ><?php echo isset($project)?$project->p_solution:false; ?></textarea>

			
			<br/>
			<div class="btn-group pull-right">
				<a class="btn btn-info" href="javascript:void(0);" onclick="editor.sync();submitForm('form_project_edit');">保存</a>
				<button class="btn btn-info" disabled="">删除</button>
			</div>
				
			<input  type="hidden" id="p_id" name="p_id" value="<?php echo isset($project)?$project->p_id:false; ?>" readonly >	
				
		</form>
		
		<legend>任务列表</legend>
		<table class="table table-striped">
		  <thead>
			<tr>
			  <th class="span1">任务号</th>
			  <th class="span4">任务名称</th>
			  <th class="span1">负责人</th>
			  <th class="span1">需求方</th>
			  <th class="span2">预计完成</th>
			  <th class="span1">状态</th>
			</tr>
		  </thead>
		  <tbody>
		  <?php foreach($task_list as $task){ ?>
			<tr>
			  <td><?php echo $task->t_id; ?></td>
			  <td>
				<?php if(have_unread_sms('task',$task->t_id)){ ?>
					<a href="<?php echo site_url('author/edit_task/'.$task->t_id); ?>#sms"><i class="icon-envelope"></i><?php echo $task->t_title; ?></a>
				<?php }else{ ?>
					<a href="<?php echo site_url('author/edit_task/'.$task->t_id); ?>"><?php echo $task->t_title; ?></a>
				<?php } ?>
				</td>
			  <td><?php echo $task->t_td_type; ?></td>
			  <td><?php echo $task->t_a_id==0?'大厅':get_author_name($task->t_a_id); ?></td>
			  <td><?php echo get_author_name($task->t_ht_op_code); ?></td>
			  <td><?php echo date('m/d/Y',strtotime($task->t_datetime)); ?></td>
			  <td><?php echo date('m/d/Y',strtotime($task->t_expires)); ?></td>
			</tr>
		  <?php } ?>
			
		  </tbody>
		</table>  
		
	</div>
	<div class="span1"></div>
	
</div>
