A-A+

通达oa-删除附件

2019年03月12日 通达oa 暂无评论 阅读 1,726 views 次

前端:

function delete_attach(ATTACHMENT_ID,ATTACHMENT_NAME)
{
    var msg = sprintf("<?=_("确定要删除文件 '%s' 吗?")?>", ATTACHMENT_NAME);
    if(window.confirm(msg))
    {
        var id_ztjy = <?php echo $id_ztjy;?>;
        var action = 'delete_file';
        var data = {
            action: action,
            id_ztjy:id_ztjy,
            ATTACHMENT_ID: ATTACHMENT_ID,
            ATTACHMENT_NAME: ATTACHMENT_NAME
        };
        $.ajax({
            url: '../Controller/Controller.php',
            type: 'post',
            data: data,
            dataType: 'json',
            success: function () {
                window.location.reload();
            }
        });
    }
}

 

后端:

case 'delete_file':
    //删除附件
    $ATTACHMENT_ID = $_REQUEST['ATTACHMENT_ID'];
    $ATTACHMENT_NAME = $_REQUEST['ATTACHMENT_NAME'];

    //删除记录中的附件
    $id_ztjy = $_REQUEST['id_ztjy'];
    $jy_data = $database->get('dj_ztjy',['ATTACHMENT_ID','ATTACHMENT_NAME'],['id_ztjy'=>$id_ztjy]);
    if($jy_data['ATTACHMENT_NAME']!="")
    {
        delete_attach($ATTACHMENT_ID,$ATTACHMENT_NAME);
        $ATTACHMENT_ID_OLD=$jy_data["ATTACHMENT_ID"];
        $ATTACHMENT_NAME_OLD=$jy_data["ATTACHMENT_NAME"];

        $ATTACHMENT_ID_ARRAY=explode(",",$ATTACHMENT_ID_OLD);
        $ATTACHMENT_NAME_ARRAY=explode("*",$ATTACHMENT_NAME_OLD);

        $ARRAY_COUNT=sizeof($ATTACHMENT_ID_ARRAY);
        for($I=0;$I<$ARRAY_COUNT;$I++)
        {
            if($ATTACHMENT_ID_ARRAY[$I]==$ATTACHMENT_ID||$ATTACHMENT_ID_ARRAY[$I]=="")
                continue;
            $ATTACHMENT_ID1.=$ATTACHMENT_ID_ARRAY[$I].",";
            $ATTACHMENT_NAME1.=$ATTACHMENT_NAME_ARRAY[$I]."*";
        }
        $ATTACHMENT_ID=$ATTACHMENT_ID1;
        $ATTACHMENT_NAME=$ATTACHMENT_NAME1;

        $query="update dj_ztjy set ATTACHMENT_ID='$ATTACHMENT_ID',ATTACHMENT_NAME='$ATTACHMENT_NAME' where id_ztjy='$id_ztjy'";
        exequery(TD::conn(),$query);
    }
    break;

 

标签:

给我留言