Example #1
0
/**
 * 获取模板对应的打印数据
 * @param $templateId
 * @param $chips
 * @return mixed
 */
function biz_Print_getTemplateData($templateId, $chips)
{
    $template = db_getPrintTemplate($templateId);
    $base = biz_Print_getChipsData($chips, $template['printtype']);
    $data = biz_unserializer($template, 'datamap');
    foreach ($data as $k => $v) {
        if (isset($base[$v])) {
            $data[$k] = $base[$v];
        } else {
            $data[$k] = '';
        }
    }
    return $data;
}
Example #2
0
function biz_getPayFromDetail($projGUID)
{
    $project = biz_getProject($projGUID, true);
    $pay = biz_unserializer($project, 'payform');
    //$pay['details'] = db_getPaydetail($pay['pay_id']);
    return $pay;
}
Example #3
0
<?php

$project = $_W['project'];
$groups = biz_getWillCallGroup($project['id']);
$signset = biz_unserializer($project, 'signset');
if (empty($signset)) {
    message('未配置叫号相关选项!');
}
$maxselect = $signset['max'];
if (checksubmit()) {
    if (isset($_GPC['callnum'])) {
        $callnum = explode(',', $_GPC['callnum']);
    }
    $keys = array_keys($groups);
    if (empty($callnum)) {
        $callnum[] = $keys[0];
    }
    foreach ($callnum as $num) {
        biz_callSignGroup($num, $_W['pid']);
    }
    memcached_set('callnum', implode(',', $callnum));
    $groups = biz_getWillCallGroup($_W['pid']);
}
$last = memcached_get('callnum');
$called = biz_getCalledGroup($_W['pid']);
include $this->template('queuing_list');
function export_chips($projGUID, $progressFunc)
{
    $res = array('total' => 0, 'update' => 0, 'failed' => 0);
    $sql = "select * from " . tablename('chips') . " where projguid=:projguid and SyncTime=0 ";
    $list = pdo_fetchall($sql, array(':projguid' => $projGUID));
    $count = count($list);
    $progress = 0;
    $index = 0;
    $showProgress = function () use(&$progress, $count, &$index, $progressFunc) {
        $index++;
        $value = intval($index * 5 / $count);
        if ($value > $progress) {
            $progress = $value;
            if (!empty($progressFunc)) {
                $progressFunc($value);
            }
        }
    };
    $project = biz_getProject($projGUID);
    $payform = biz_unserializer($project, 'payform');
    $sql = "select * from " . tablename('s_discountdefine') . " where DiscntGUID=:DiscntGUID and ProjGUID=:ProjGUID ";
    foreach ($payform['dis_id'] as $id) {
        $payform['disc_Details'][] = pdo_fetch($sql, array(':DiscntGUID' => $id, ':ProjGUID' => $projGUID));
    }
    foreach ($list as $chips) {
        $showProgress();
        if (!empty($chips['ProtocolNO'])) {
            $res['total']++;
            $result = writeChipsToErp($chips, $payform);
            if ($result) {
                pdo_update('chips', array('SyncTime' => TIMESTAMP), array('qrcode' => $chips['qrcode']));
                $res['update']++;
            } else {
                $error = MsSql()->getErrors();
                MsSql()->clearError();
                //记录出错信息
                logging($chips['qrcode'], $error);
                $res['failed']++;
            }
        }
    }
    return $res;
}
Example #5
0
 }
 $user_info = $chips['user'];
 $printed_Bills = biz_getBills($chips['qrcode'], 1, true);
 $inputBill = biz_getBill($chips['qrcode'], $billType, false);
 $totalMoney = $chips['ordermoney'] + $chips['premoney'];
 $enable = $totalMoney >= $chips['shouldpay'];
 $disableEdit = !isset($_GPC['edit']) || $_GPC['edit'] != 1;
 if (!$enable && empty($inputBill)) {
     $inputBill = array('printed' => 0, 'finance' => array(0 => array()));
     $disableEdit = false;
 }
 if (!empty($inputBill)) {
     $project = $_W['project'];
     $banks = biz_getBanks($project['BUGUID']);
     $project = biz_getProject($project['projguid']);
     $bank = biz_unserializer($project, 'bank');
 }
 if (checksubmit()) {
     if (empty($inputBill)) {
         message('认筹单无效数据,不能交款!', $url, 'error');
     }
     //保存中
     $updateMoney = biz_getInput2Bill($inputBill);
     if (empty($inputBill['BillGUID'])) {
         // 插入票据单相关信息
         if ($inputBill['Money'] > 0) {
             $inputBill['BillGUID'] = GUID();
             if (!biz_addBill($chips, $inputBill, 2)) {
                 $updateMoney = false;
                 message('认筹单定金交款,保存数据失败!', $url, 'error');
             }
Example #6
0
/**
 *获得签到全局表信息
 * 自动增加组
 * @param $pid 项目id
 */
function getGlobalSign($project)
{
    global $_W;
    $key = 'sign_' . $project['projguid'];
    $singset = biz_unserializer($project, 'signset');
    $max = empty($singset['num']) ? 10 : $singset['num'];
    $info = memcached_get($key);
    $reset = empty($info) || $info['group']['maxnum'] >= $max;
    if ($reset) {
        memcached_delete($key);
        $index = 1;
        if (!empty($info['group']['dispnum'])) {
            $index = $info['group']['dispnum'];
        }
        //获取组号
        $callback = function () use($index, $max, $project) {
            $info['maxnum'] = $max;
            //获取未签到组列表
            $info['group'] = Sign_GetEmptyGroup($index, $max, $project['id']);
            $info['group']['maxnum']++;
            return $info;
        };
        $info = cache_GetData($key, $callback, 1800);
    } else {
        $info['group']['maxnum']++;
        memcached_set($key, $info, 1800);
    }
    return $info;
}
Example #7
0
    exit;
}
if ($op == 'display') {
    disableWebCache();
    $id = intval($_GPC['id']);
    $chips = biz_getChips($id);
    if (empty($chips)) {
        echo '无效的参数';
        exit;
    }
    if (!$this->CheckDataRight($chips)) {
        echo '无权查看数据';
        exit;
    }
    if ($chips['pretype'] == 2) {
        $preattach = biz_unserializer($chips, 'preattach');
    }
    $user_info = $chips['user'];
    $pre_bills = biz_getBills($chips['qrcode'], 1, null);
    foreach ($pre_bills as &$bill) {
        if (empty($bill['Printed'])) {
            $bill['Printed'] = 1;
            $bill['InvoNo'] = '未打印生成';
        }
    }
    unset($bill);
    $order_bills = biz_getBills($chips['qrcode'], 2, null);
    foreach ($order_bills as &$bill) {
        if (empty($bill['Printed'])) {
            $bill['Printed'] = 1;
            $bill['InvoNo'] = '未打印生成';
Example #8
0
 public function doWebSet()
 {
     global $_W, $_GPC;
     $op = $_GPC['op'];
     $this->CheckRight('set');
     //检查项目状态,是否允许设置
     $project = db_getProject($_W['pid'], false, false);
     if (empty($project)) {
         //|| !empty($project['status'])
         if ($_W['isajax']) {
             echo '无效的项目数据或当前项目不允许设置!';
             exit;
         } else {
             message('无效的项目数据或当前项目不允许设置!', $this->createWebUrl('manage'));
         }
     }
     $url = $this->createWebUrl('set', array('op' => $op));
     if ($op == 'discount') {
         $discount = db_getDiscount($project['projguid'], 'DiscntGUID');
         $payform = db_getPayForm($project['projguid'], 'PayFormGUID');
         foreach ($payform as &$p) {
             if ($p['DisCount']) {
                 $p['title'] = $p['PayformName'] . "[{$p['DisCount']}%]";
             }
             if ($p['PreferentialPrice'] > 0) {
                 $p['title'] = $p['PayformName'] . "[-{$p['PreferentialPrice']}¥]";
             }
         }
         unset($p);
         $set = biz_unserializer($project, 'payform');
         if (empty($set)) {
             $set = array('pay_id' => '');
         } else {
             if (count($set['pay_id']) > 0) {
                 foreach ($discount as $k => $v) {
                     $discount[$k]['select'] = in_array($k, $set['dis_id']);
                 }
             }
         }
         if ($_W['isajax']) {
             include $this->template('discountSet');
             exit;
         }
         if ($_W['token'] == $_GPC['token']) {
             $pay_id = trim($_GPC['payform']);
             $calc = array('paydiscount' => 1.0, 'decmoney' => 0, 'discount' => 1.0);
             if (!empty($pay_id) && isset($payform[$pay_id])) {
                 $set['pay_id'] = $pay_id;
                 $set['Payform'] = $payform[$pay_id];
                 $set['title'] = $payform[$pay_id]['title'];
                 $set['details'] = db_getPaydetail($pay_id);
             }
             unset($set['dis_id']);
             foreach ($_GPC['discount'] as $d) {
                 if (isset($discount[$d])) {
                     $set['dis_id'][] = $d;
                 }
             }
             $calc = biz_getRoomPriceCalc($set, $discount, $payform);
             $set['calc'] = $calc;
             $tip = round($calc['discount'] * 100, 2);
             $set['discount'] = "减免{$calc['dec_money']},折扣{$tip}%";
             $data = array('payform' => iserializer($set));
             pdo_update('project', $data, array('id' => $_W['pid']));
             biz_mem_clearProject();
             $rooms = db_getRooms($_W['project']['projguid']);
             foreach ($rooms as $r) {
                 if (in_array($r['Status'], array('待售', '销控'))) {
                     biz_calcRoomPrice($r, $calc, true);
                 }
                 //calc_payorder($r,true);
             }
             message('数据已设置', $this->createWebUrl('manage'));
         }
     }
     if ($op == 'invoice') {
         load()->web('print');
         $set = biz_unserializer($project, 'finance');
         if (empty($set['prepay'])) {
             $prepay = $set;
         } else {
             $prepay = $set['prepay'];
         }
         $order = $set['order'];
         $prefix = $set['Prefix'];
         if ($_W['isajax']) {
             include $this->template('invoiceSet');
             exit;
         }
         if ($_W['token'] == $_GPC['token']) {
             $getInvoInfo = function ($set) use($project) {
                 $set['BatchNo'] = trim($set['BatchNo']);
                 $set['Prefix'] = trim($set['Prefix']);
                 $invo = biz_getInvoiceByBatchNo($set['BatchNo'], $set['Prefix'], $project);
                 $config = array('BatchNo' => $set['BatchNo'], 'Prefix' => $set['Prefix']);
                 if (!empty($invo)) {
                     $config['InvoGUID'] = $invo['InvoGUID'];
                 }
                 return $config;
             };
             $set = array();
             $set['prepay'] = $getInvoInfo($_GPC['prepay']);
             $set['order'] = $getInvoInfo($_GPC['order']);
             $set['Prefix'] = trim($_GPC['Prefix']);
             $set['ChipsPre'] = trim($_GPC['ChipsPre']);
             $data = array('finance' => iserializer($set));
             pdo_update('project', $data, array('id' => $_W['pid']));
             biz_mem_clearProject($project);
             message('数据已设置', $this->createWebUrl('manage'));
         }
     }
     if ($op == 'sign') {
         $set = biz_unserializer($project, 'signset');
         if (empty($set)) {
             $set = array('num' => 10, 'max' => 1);
         }
         if ($_W['isajax']) {
             include $this->template('signSet');
             exit;
         }
         if ($_W['token'] == $_GPC['token']) {
             $set = array('num' => intval($_GPC['num']), 'max' => intval($_GPC['max']));
             if ($set['num'] <= 0) {
                 $set['num'] = 10;
             }
             if ($set['max'] <= 0) {
                 $set['max'] = 1;
             }
             //只能一组
             $set['max'] = 1;
             $data = array('signset' => iserializer($set));
             pdo_update('project', $data, array('id' => $_W['pid']));
             if ($_GPC['clear']) {
                 pdo_update('sign', array('signed' => 0), array('pid' => $_W['pid']));
                 pdo_update('call_group', array('called' => 0), array('pid' => $_W['pid']));
                 //pdo_update('p_room',array('selectroom'=>0))
                 memcached_delete('global_sign_' . $project['id']);
             }
             biz_mem_clearProject($project);
             message('数据已设置', $this->createWebUrl('manage'));
         }
     }
     if ($op == 'project') {
         $status = biz_getDictionary('projstatus');
         //删除创建默认状态
         unset($status[0]);
         $set = biz_unserializer($project, 'sync');
         if ($_W['isajax']) {
             include $this->template('projSet');
             exit;
         }
         if ($_W['token'] == $_GPC['token']) {
             $selStatus = intval($_GPC['status']);
             $set = array('client' => trim($_GPC['client']));
             $data = array('status' => $selStatus, 'sync' => iserializer($set));
             pdo_update('project', $data, array('id' => $project['id']));
             biz_mem_clearProject($project);
             message('数据已设置', $this->createWebUrl('manage'));
         }
     }
     if ($op == 'build') {
         $set = biz_unserializer($project, 'builds');
         if (empty($set['timeout'])) {
             $set['timeout'] = 30;
         }
         $builds = db_getBuilds($_W['project']['projguid'], 'BldGUID');
         if ($_W['isajax']) {
             include $this->template('buildSet');
             exit;
         }
         if ($_W['token'] == $_GPC['token']) {
             $bids = $_GPC['m_ids'];
             $timeout = intval($_GPC['timeout']);
             if ($timeout < 0 || $timeout > 300) {
                 $timeout = 30;
             }
             //统计房间数量
             // 更新
             pdo_update('p_building', array('status' => '0'), array('ProjGUID' => $project['projguid']));
             $keys = array_keys($builds);
             foreach ($bids as $bldGuid) {
                 if (in_array($bldGuid, $keys)) {
                     pdo_update('p_building', array('status' => '1'), array('BldGUID' => $bldGuid));
                 }
             }
             $sql = 'SELECT count(*) as cnt FROM ims_p_room ';
             $sql .= ' a INNER JOIN ims_p_building b ON a.BldGUID = b.BldGUID ';
             $sql .= ' WHERE  b.`Status`=1 and b.ProjGUID=:projguid';
             $cnt = pdo_fetchcolumn($sql, array(':projguid' => $project['projguid']));
             $set = array('build' => $bids, 'timeout' => $timeout, 'roomnum' => $cnt);
             $data = array('builds' => iserializer($set));
             pdo_update('project', $data, array('id' => $_W['pid']));
             biz_mem_clearProject();
             message('数据已设置', $this->createWebUrl('manage'));
         }
     }
     if ($op == 'bank') {
         $banks = biz_getBanks($_W['project']['BUGUID']);
         $bk = empty($project['bank']) ? array() : iunserializer($project['bank']);
         if ($_W['isajax']) {
             include $this->template('bankSet');
             exit;
         }
         if ($_W['token'] == $_GPC['token']) {
             $bankid = $_GPC['bank'];
             $prebank = db_getPreBank($bankid);
             $data = array('bank' => iserializer($prebank));
             pdo_update('project', $data, array('id' => $_W['pid']));
             biz_mem_clearProject($project);
             message('数据已设置', $this->createWebUrl('manage'));
         }
     }
 }