收件人

//Controller
class Product_ReceivingController extends Zend_Controller_Action {
    //收件人
    public function addresseeAction() {
        $type = $this->_request->getParam("type", "");
        $mkdEmail = $this->_request->getParam("mkd_email", "");
        $dongguanEmail = $this->_request->getParam("dongguan_email", "");
        $yiwuEmail = $this->_request->getParam("yiwu_email", "");
        $return = array(
            "ask" => 0,
            "data" => "",
            "msg" => ""
        );
        $configId = Common_Service_Config::getByAttribute("RECIPIENT_MAILBOX_ADDRESS");
        if (!$configId) {
            $return['msg'] = "未配置系统配置信息";
            die(json_encode($return));
        }
        if ($type == 0) {
            $return = array(
                "ask" => 1,
                "data" => explode("&", $configId['config_value']),
                "msg" => "查询成功",
            );
        } else {
            $emailArray = array($mkdEmail, $dongguanEmail, $yiwuEmail);
            $data = array();
            foreach ($emailArray as $value) {
                $email = explode(";", $value);
                $pattern = "/^(\w)+(\.\w+)*@(\w)+((\.\w+)+)$/";
                foreach ($email as $val) {
                    preg_match_all($pattern, $val, $matches);
                    if ($val != "") {
                        if (!$matches[0]) {
                            $return = array(
                                "ask" => 0,
                                "msg" => $val . " 邮箱格式有误"
                            );
                            die(json_encode($return));
                        }
                    }
                }
                $data[] = $email;
            }
            if ($data[0][0] == "" || $data[1][0] == "" || $data[2][0] == "") {
                $return = array(
                    "ask" => 0,
                    "msg" => "每个仓库至少保留一个有效收件人邮箱地址",
                );
                die(json_encode($return));
            }
            $email0 = "";
            $email1 = "";
            $email2 = "";
            foreach ($data[0] as $v0) {
                if ($v0 != "") {
                    $email0 .= $v0 . ";";
                }
            }
            foreach ($data[1] as $v1) {
                if ($v1 != "") {
                    $email1 .= $v1 . ";";
                }
            }
            foreach ($data[2] as $v2) {
                if ($v2 != "") {
                    $email2 .= $v2 . ";";
                }
            }
            $updateConfig = Common_Service_Config::update(array("config_value" => $email0 . "&" . $email1 . "&" . $email2), $configId['config_id']);
            if ($updateConfig) {
                $return = array(
                    "ask" => 1,
                    "msg" => "修改成功",
                );
            } else {
                $return = array(
                    "ask" => 0,
                    "msg" => "修改失败",
                );
            }
        }
        die(json_encode($return));
    }
}


Html
<input class="button" type="button" value="收件人" onclick="addressee()">

<div id="addresseeDialog" title="收件人"  style="display: none; text-align: center"></div>


js
//初始化
$(function () {
    //收件人
    $("#addresseeDialog").dialog({
        autoOpen: false,
        modal: true,
        width: 1000,
        height: 300,
        zIndex: 200,
        show: "slide",
        title: "收件人配置",
        buttons: {
            "确定": function () {
                updateAddressee();
            },
            "关闭": function () {
                $(this).dialog("close");
            }
        }
    });
});

//收件人列表
function addressee() {
    loading();
    $.ajax({
        url: "/product/receiving/addressee",
        data: {"type": 0},
        type: "post",
        dataType: "json",
        async: false,
        success: function (json) {
            var Html = "";
            if (!json.ask) {
                alertTip(json.msg);
            } else {
                Html += "<div style='color:red;'>1、请根据您所在的仓库,在对应的位置填入收件人邮箱。<br/>2、添加多个收件人邮箱时,请用英文分号 ';' 隔开。</div><br/>";
                Html += "<div style='margin-bottom:10px;'>铭可达收件人:<input type='text' name='mkd_attribute_value' style='width:850px;' value='" + json.data[0] + "'></div>";
                Html += "<div style='margin-bottom:10px;'>东莞仓收件人:<input type='text' name='dongguan_attribute_value' style='width:850px;' value='" + json.data[1] + "'></div>";
                Html += "<div style='margin-bottom:10px;'>义乌仓收件人:<input type='text' name='yiwu_attribute_value' style='width:850px;' value='" + json.data[2] + "'></div>";
            }
            $("#addresseeDialog").dialog("open").html(Html);
        }
    });
    closeLoading();
}

//更新收件人
function updateAddressee() {
    var mkd_email = $.trim($("[name=mkd_attribute_value]").val());
    var dongguan_email = $.trim($("[name=dongguan_attribute_value]").val());
    var yiwu_email = $.trim($("[name=yiwu_attribute_value]").val());
    $.ajax({
        url: "/product/receiving/addressee",
        data: {
            "type": 1,
            "mkd_email": mkd_email,
            "dongguan_email": dongguan_email,
            "yiwu_email": yiwu_email
        },
        type: "post",
        dataType: "json",
        async: false,
        success: function (json) {
            if (!json.ask) {
                alertTip(json.msg);
            } else {
                $("#addresseeDialog").dialog("close");
            }
        }
    });
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值