while ($db->next_record()) {
                $tmp_paycardid = $db->f(fd_tmpsale_paycardid);
            }
        }
        $query = "select fd_stdetail_paycardid as paycardid from tb_salelistbackdetail where fd_stdetail_id = '{$vid}' ";
        $arr_data = $db->get_one($query);
        $arr_paycardid = explode(",", $arr_data['paycardid']);
        $arr_tmp_paycardid = explode(",", $tmp_paycardid);
        changepaycardstate($arr_paycardid, '1');
        //修改刷卡器状态
        changepaycardstate($arr_tmp_paycardid, '-2');
        //修改刷卡器状态
        $query = "update tb_salelistbackdetail set fd_stdetail_price = '{$price}' ,fd_stdetail_quantity='{$quantity}' ,  \n\t\t\t\t\t\t\t\t\tfd_stdetail_paycardid='{$tmp_paycardid}'\n\t\t\t\t\t\twhere fd_stdetail_id = '{$vid}' ";
        $db->query($query);
        //插入细节表 数据
        countallsalepaycard($listid, 'tb_salelistback', 'tb_salelistbackdetail');
        echo "<script>location.href='jxcsaleback.php?listid={$listid}';</script>";
        break;
}
$t->set_file("salelist", "jxcsale_choosebackpaycard.html");
$arr_text = array("批次号", "刷卡器设备号", "销售价格", "供应商", "<INPUT onclick=CheckAll(this.form) type=checkbox \t value=on name=chkall class='checkall'>");
$theadth = "<thead>";
for ($i = 0; $i < count($arr_text); $i++) {
    $theadth .= ' <th>' . $arr_text[$i] . '</th>';
}
$theadth .= "</thead>";
$query = "select fd_paycard_product  from tb_paycard where fd_paycard_cusid='{$cusid}' group by fd_paycard_product";
$db->query($query);
if ($db->nf()) {
    while ($db->next_record()) {
        $saleproduct = $db->f(fd_paycard_product);
        }
        $query = "select * from tb_salelistdetail  where fd_stdetail_id='{$vid}'";
        $db->query($query);
        if ($db->nf()) {
            while ($db->next_record()) {
                $stdetail_paycardid = $db->f(fd_stdetail_paycardid);
            }
        }
        $arr_tmp_paycardid = explode(",", $tmp_paycardid);
        $arr_stdetail_paycardid = explode(",", $stdetail_paycardid);
        changepaycardstate($arr_stdetail_paycardid, '1');
        changepaycardstate($arr_tmp_paycardid, '2');
        $query = "update tb_salelistdetail set fd_stdetail_price = '{$price}' ,fd_stdetail_quantity='{$quantity}' ,  \n\t\t\t\t\t\t\t\t\tfd_stdetail_paycardid='{$tmp_paycardid}'\n\t\t\t\t\t\twhere fd_stdetail_id = '{$vid}' ";
        $db->query($query);
        //插入细节表 数据
        countallsalepaycard($listid, 'tb_salelist', 'tb_salelistdetail');
        echo "<script>location.href='jxcsale.php?listid={$listid}';</script>";
        break;
}
$t->set_file("salelist", "jxcsale_choosepaycard.html");
$arr_text = array("批次号", "刷卡器设备号", "入库价格", "供应商", "<INPUT onclick=CheckAll(this.form) type=checkbox \t value=on name=chkall class='checkall'>");
$theadth = "<thead>";
for ($i = 0; $i < count($arr_text); $i++) {
    $theadth .= ' <th>' . $arr_text[$i] . '</th>';
}
$theadth .= "</thead>";
$query = "select * from tb_product";
$db->query($query);
if ($db->nf()) {
    while ($db->next_record()) {
        $arr_productid[] = $db->f(fd_product_id);