new.php:
<?
include_once("inc/auth.inc.php");
include_once("inc/utility_all.php");
$HTML_PAGE_TITLE = _("添加项目任务");
include_once("inc/header.inc.php");
include_once("general/workflow/prcs_role.php");
if($TASK_ID)
{
$query = "select * from PROJ_MUBAN_TASK WHERE TASK_ID='$TASK_ID'";
$cursor = exequery(TD::conn(), $query);
if($ROW=mysql_fetch_array($cursor))
{
$TASK_NAME = $ROW["TASK_NAME"];
$TASK_NO = $ROW["TASK_NO"];
$PROJ_ID = $ROW["PROJ_ID"];
$TASK_DESCRIPTION = $ROW["TASK_DESCRIPTION"];
$PARENT_TASK = $ROW["PARENT_TASK"];
$REMARK = $ROW["REMARK"];
}
}
else
{
$query = "SELECT 1 from PROJ_MUBAN_TASK where M_ID='$m_id' AND PARENT_TASK = '0'";
$cursor= exequery(TD::conn(),$query);
$MAX_TASK_NO = mysql_num_rows($cursor) + 10;//任务序号间隔为5
}
?>
<link rel="stylesheet" type="text/css" href="/general/workflow/assets/autocomplete.css">
<link rel="stylesheet" type="text/css" href="/static/theme/<?=$_SESSION['LOGIN_THEME']?>/calendar.css">
<script src="<?=MYOA_JS_SERVER?>/module/DatePicker/WdatePicker.js"></script>
<script src="<?=MYOA_JS_SERVER?>/static/js/module.js"></script>
<script src="<?=MYOA_JS_SERVER?>/static/js/mouse_mon.js"></script>
<script language="javascript" src="<?=MYOA_JS_SERVER?>/static/js/jquery-1.5.1/jquery.min.js<?=$GZIP_POSTFIX?>"></script>
<script type="text/javascript" src="<?=MYOA_JS_SERVER?>/static/js/jquery-1.5.1/jquery-ui.custom.min.js<?=$GZIP_POSTFIX?>"></script>
<script type="text/javascript" src="<?=MYOA_JS_SERVER?>/static/js/jquery-1.5.1/jquery.ui.autocomplete.min.js<?=$GZIP_POSTFIX?>"></script>
<script language="javascript" src="/general/workflow/assets/combobox.js"></script>
<script type="text/javascript" src="/inc/js_lang.php"></script>
<script type="text/javascript" src="<?=MYOA_JS_SERVER?>/static/js/attach.js"></script>
<script type="text/javascript" src="<?=MYOA_JS_SERVER?>/static/js/jQueryGantt/libs/date.js"></script>
<link rel="stylesheet" type="text/css" href="<?=MYOA_JS_SERVER?>/static/js/bootstrap/css/bootstrap.min.css<?=$GZIP_POSTFIX?>" />
<script>
function check_form()
{
if(document.form1.TASK_NAME.value=="" || document.form1.TASK_NO.value=="")
{
alert("<?=_("请填写任务序号和任务名称!")?>");
return (false);
}
return(true);
}
</script>
<body style="padding-bottom:0px;">
<form name="form1" method="post" action="<?if($TASK_ID) echo "update.php";else echo "submit.php";?>" onSubmit="return check_form();">
<input type="hidden" name="M_ID" value="<?=$m_id?>"/>
<input type="hidden" name="M_MINGCHENG" value="<?=$m_mingcheng?>"/>
<div style="padding:10px;">
<table class="table table-bordered" width="80%" >
<tr class="info">
<td colspan='2'><strong><?= _("添加新任务");?> 模板名称:<?=$m_mingcheng?>--<?=$m_id?> </strong></td>
</tr>
<tr>
<td><?=_("任务序号:")?></td>
<td>
<input type="text" class="input-medium" style="margin-bottom:0px;" name="TASK_NO" id="z_t_n" value="<?=$TASK_NO ? $TASK_NO: $MAX_TASK_NO?>" size=20></td>
</tr>
<tr>
<td><?=_("任务名称:")?><?=$IMPORTANT_INFO?></td>
<td>
<input type="text" style="margin-bottom:0px;" class="input-medium" name="TASK_NAME" value="<?=$TASK_NAME?>" size=20> </td>
</tr>
<tr>
<td><?=_("上级任务:")?></td>
<td>
<select id="z_s" name="PARENT_TASK" style="margin-bottom:0px;" class="" >
<option value=""><?=_("无")?></option>
<?
$query = "select TASK_NO,TASK_ID,TASK_NAME from PROJ_MUBAN_TASK WHERE M_ID='$m_id' AND TASK_ID<>'$TASK_ID'";
$cursor = exequery(TD::conn(), $query);
while($ROW=mysql_fetch_array($cursor))
{
?>
<option TASK_NO="<?= $ROW["TASK_NO"]?>" value="<?=$ROW["TASK_ID"]?>" <? if($ROW["TASK_ID"]==$PARENT_TASK) echo "selected";?>><?=$ROW["TASK_NAME"]?></option>
<?
}
?>
</select> </td>
</tr>
<tr>
<td><?=_("任务描述:")?></td>
<td>
<textarea style="width:50%; height:80px; margin-bottom:0px; overflow-y:auto;" cols="50" name="TASK_DESCRIPTION" wrap="yes"><?=$TASK_DESCRIPTION?></textarea>
</td>
</tr>
<tr>
<td><?=_("备注:")?></td>
<td>
<textarea cols="50" name="REMARK" style="width:50%; height:80px; margin-bottom:0px; overflow-y:auto;" wrap="yes"><?=$REMARK?></textarea>
</td>
</tr>
</table>
<div align="center" style="width:100%; height:50px; background:#fff; border-top:#3f9bca 3px solid; line-height:50px; position:fixed; top:100%; margin-top:-50px;">
<input type="hidden" name="TASK_ID" value="<?=$TASK_ID?>">
<input type="submit" value="<?=_("保存")?>" class="btn btn-success">
<input type="button" value="<?=_("返回")?>" class="btn" onClick="location='../bianjirenwu.php?m_id=<?=$m_id?>'">
</div>
</div>
</form>
<script type="text/javascript" src="<?=MYOA_JS_SERVER?>/static/js/jquery-1.10.2/jquery.min.js<?=$GZIP_POSTFIX?>"></script>
<script type="text/javascript">
jQuery.noConflict();
(function($){
var selected = $("#z_s option:selected").index();
var s = $("#z_t_n").val();
jQuery("#z_s").change(function(){
var str = $(this).children("option:selected").attr('value');
if($(this).children("option:selected").index() == selected){
$("#z_t_n").val(s);
}else{
var a=Math.random();
$.getJSON("get_no.php?M_ID=<?= $m_id?>&PARENT_ID=" + str+"&aaa="+a).success(function(data){
$("#z_t_n").val(data.no);
}).fail(function(){
alert("<?=_('自动生成编号失败请自行输入!')?>");
})
}
})
})(jQuery);
</script>
</body>
</html>
get_no.php:
<?php
include_once("inc/auth.inc.php");
/*
* get_no.php
* 自动申请任务编号
* zfc 2014-1-24
*/
$PARENT_ID = intval($PARENT_ID);
$M_ID = intval($M_ID);
if(!empty($PARENT_ID)){
//选择父级 TASK_NO
$QUERY = "SELECT TASK_NO FROM PROJ_MUBAN_TASK WHERE TASK_ID = '$PARENT_ID' AND M_ID = '$M_ID'";
$CUR = exequery(TD::conn(),$QUERY);
$ROW = mysql_fetch_array($CUR);
$TASK_NO = $ROW['TASK_NO'] . '.';
//生成子级编号
$QUERY = "SELECT TASK_NO FROM PROJ_MUBAN_TASK WHERE M_ID = '$M_ID' AND PARENT_TASK = '$PARENT_ID'";
$CUR = exequery(TD::conn(),$QUERY);
$ROW = mysql_num_rows($CUR)*10 + 10;
}else{
$query = "SELECT 1 from PROJ_MUBAN_TASK where M_ID='$M_ID' AND PARENT_TASK = '0'";
$cursor= exequery(TD::conn(),$query);
$ROW = mysql_num_rows($cursor)*10 + 10;
}
echo json_encode(array('no'=>$TASK_NO.$ROW));
?>