<?php
/**
 *
 * @author min晓天
 * @url http://bbs.we7.cc/
 */
defined('IN_IA') or exit('Access Denied');
global $_GPC, $_W;
load()->func('tpl');
$operation = ! empty($_GPC['op']) ? $_GPC['op'] : 'display';
$tmpl="doweb/";
$sid = $_SESSION['sid'];
if ($operation == 'display') {
     $condition      = ' uniacid = :aid ';
    $params[':aid'] = $_W['uniacid'];
    $community  = pdo_fetchall('SELECT * FROM ' . tablename('evzg_express_community') . ' WHERE ' . $condition . ' ORDER BY displayorder DESC,id ASC  ', $params, 'id');
    $print = pdo_getall("evzg_express_printcompany",array('status'=>1));
    $parentid = intval($_GPC['parentid']);
    $id = $sid;
    if (! empty($id)) {
        $shops = pdo_fetch("SELECT * FROM " . tablename('evzg_express_shop') . " WHERE id = '$id'");
    } else {
        $shops = array(
            'displayorder' => 0
        );
    }
    if (checksubmit('submit')) {
        if (empty($_GPC['name'])) {
            message('抱歉，请输入门店名称！');
        }
        $data = array(
            'uniacid' => $_W['uniacid'],
            'name' => $_GPC['name'],
            'enabled' => intval($_GPC['enabled']),
            'displayorder' => intval($_GPC['displayorder']),
            'village' => intval($_GPC['village']),
            'description' => $_GPC['description'],
            'address' => $_GPC['address'],
            'openid' => $_GPC['openid'],
            'mobile' => $_GPC['mobile'],
            'password' => $_GPC['password'],
            'shipperCode' => $_GPC['shipperCode'],
            'isprint' => intval($_GPC['isprint']),
			'msgtype' => intval($_GPC['msgtype']),
            'createtime'=>time()
        );
       // var_dump($data);die();
        if (! empty($id)) {
            unset($data['parentid']);
            pdo_update('evzg_express_shop', $data, array(
                'id' => $id
            ));
            load()->func('file');
            file_delete($_GPC['thumb_old']);
        } else {
            pdo_insert('evzg_express_shop', $data);
            $id = pdo_insertid();
        }
         //var_dump(pdo_debug());die();
        message('更新门店成功！', mweb('shops', array(
            'op' => 'display'
        )), 'success');
    }
  include $this->template($tmpl.'shops');
}