公会信息登记信息补充

master
zhengyongxing 4 years ago
parent e775701c78
commit f923f4d667

@ -114,7 +114,9 @@ class SocietyInfoController extends ThinkController
$v['num'] = $k+1+intval((I('get.p', 0)?I('get.p', 0):1)-1)*$row;
$v['sociaty_level_str'] = $this->level[$v['sociaty_level']];
if (time() - $v['communication_time'] > $gap * 86400)
if (time() - $v['communication_time'] > $gap * 86400
&& $v['is_potential'] == 1
)
$v['is_gap_time'] = 1;
}
@ -299,9 +301,24 @@ class SocietyInfoController extends ThinkController
if ($_POST) {
$save = I("post.");
if (empty($save['province'])) {
$this->error("省份为必填项");
}
if (empty($save['city'])) {
$this->error("城市为必填项");
}
if (empty($save['company_name'])) {
$this->error("公司为必填项");
}
if (empty($save['game_types'])) {
$this->error("游戏类型为必填项");
}
foreach ($save['game_types'] as $v) {
$save['game_type'] .= $v . "/";
}
$save['game_type'] = trim($save['game_type'], '/');
// dump($save['game_type']);die();
if ($save['province'] == "请选择省份") $save['province'] = '';
if ($save['city'] == "请选择城市") $save['city'] = '';
$save['create_time'] = time();
@ -331,6 +348,15 @@ class SocietyInfoController extends ThinkController
$save['province'] = '';
$save['city'] = '';
}
if (empty($save['city'])) {
$this->error("城市为必填项");
}
if (empty($save['company_name'])) {
$this->error("公司为必填项");
}
if (empty($save['game_type'])) {
$this->error("游戏类型为必填项");
}
$save['game_type'] = trim($save['game_type'], '/');
$save['communication_time'] = time();
@ -463,6 +489,7 @@ class SocietyInfoController extends ThinkController
// 导入
public function excelImport() {
header("Content-Type:text/html;charset=utf-8");
$upload = new \Think\Upload();// 实例化上传类
$upload->maxSize = 3145728 ;// 设置附件上传大小
@ -473,8 +500,10 @@ class SocietyInfoController extends ThinkController
$info = $upload->uploadOne($_FILES['excelData']);
$filename = './Uploads/'.$info['savepath'].$info['savename'];
$exts = $info['ext'];
if(!$info) {// 上传错误提示错误信息
$this->error($upload->getError());
$this->ajaxReturn(['msg'=>$upload->getError(),"status"=>0]);
// $this->error($upload->getError());
}
// 上传成功
$datas = $this->parseExcelIn($filename, $exts);
@ -489,68 +518,83 @@ class SocietyInfoController extends ThinkController
if ($flag == 0) continue;
if ($k == 1) continue;
$inserts[$k-2]['province'] = $v['A'] ?? '';
if (!$v['A']) {
$this->ajaxReturn(['msg'=>"省份不能为空".$k,"status"=>0]);
}
$inserts[$k-2]['city'] = $v['B'] ?? '';
if (!$v['B']) {
$this->ajaxReturn(['msg'=>"城市不能为空".$k,"status"=>0]);
}
$inserts[$k-2]['company_name'] = $v['C'] ?? '';
if (mb_strlen($inserts[$k-2]['company_name'], "utf-8") > 100) {
$this->error("公司名太长".$k);
$this->ajaxReturn(['msg'=>"公司名太长".$k,"status"=>0]);
}
if (!$inserts[$k-2]['company_name']) {
$this->error("公司不能为空".$k);
$this->ajaxReturn(['msg'=>"公司不能为空".$k,"status"=>0]);
}
$inserts[$k-2]['register_capital'] = $v['D'] ?? '';
if (strlen($inserts[$k-2]['register_capital']) > 50) {
$this->error("推荐人太长".$k);
$this->ajaxReturn(['msg'=>"推荐人太长".$k,"status"=>0]);
}
$inserts[$k-2]['functionary'] = $v['E'] ?? '';
if (strlen($inserts[$k-2]['functionary']) > 50) {
$this->error("负责人太长".$k);
$this->ajaxReturn(['msg'=>"负责人太长".$k,"status"=>0]);
}
$inserts[$k-2]['phone'] = $v['F'] ?? '';
if (strlen($inserts[$k-2]['phone']) > 50) {
$this->error("手机号太长".$k);
$this->ajaxReturn(['msg'=>"手机号太长".$k,"status"=>0]);
}
$inserts[$k-2]['wechat'] = $v['G'] ?? '';
if (strlen($inserts[$k-2]['wechat']) > 50) {
$this->error("微信号太长".$k);
$this->ajaxReturn(['msg'=>"微信号太长".$k,"status"=>0]);
}
$inserts[$k-2]['qq'] = $v['H'] ?? '';
if (strlen($inserts[$k-2]['qq']) > 50) {
$this->error("qq号太长".$k);
$this->ajaxReturn(['msg'=>"qq号太长".$k,"status"=>0]);
}
$inserts[$k-2]['game_type'] = $v['I'] ?? '';
$inserts[$k-2]['game_name'] = $v['J'] ?? '';
if (strlen($inserts[$k-2]['game_name']) > 50) {
$this->error("游戏名太长".$k);
$this->ajaxReturn(['msg'=>"游戏名太长".$k,"status"=>0]);
}
$inserts[$k-2]['join_platform'] = $v['K'] ?? '';
if (strlen($inserts[$k-2]['join_platform']) > 50) {
$this->error("合作平台太长".$k);
$this->ajaxReturn(['msg'=>"合作平台太长".$k,"status"=>0]);
}
$inserts[$k-2]['promote_scale'] = $v['L'] ?? '';
if (strlen($inserts[$k-2]['promote_scale']) > 50) {
$this->error("推广规模太长".$k);
$this->ajaxReturn(['msg'=>"推广规模太长".$k,"status"=>0]);
}
$inserts[$k-2]['turnover'] = $v['M'] ?? '';
if (strlen($inserts[$k-2]['turnover']) > 50) {
$this->error("流水太长".$k);
$this->ajaxReturn(['msg'=>"公会等级".$k,"status"=>0]);
}
$inserts[$k-2]['turnover'] = $v['N'] ?? '';
if (strlen($inserts[$k-2]['turnover']) > 50) {
$this->ajaxReturn(['msg'=>"流水太长".$k,"status"=>0]);
}
$inserts[$k-2]['address'] = $v['N'] ?? '';
$inserts[$k-2]['address'] = $v['O'] ?? '';
if (mb_strlen($inserts[$k-2]['address'], 'utf-8') > 100) {
$this->error("地址太长".$k);
$this->ajaxReturn(['msg'=>"地址太长".$k,"status"=>0]);
}
$inserts[$k-2]['league_info'] = $v['O'] ?? '';
$inserts[$k-2]['league_info'] = $v['P'] ?? '';
if (strlen($inserts[$k-2]['league_info']) > 100) {
$this->error("联盟信息太长".$k);
$this->ajaxReturn(['msg'=>"联盟信息太长".$k,"status"=>0]);
}
$inserts[$k-2]['is_potential'] = $v['P']=="是" ? 1 : 0;
$inserts[$k-2]['remark'] = $v['Q'] ?? '';
$inserts[$k-2]['is_potential'] = $v['Q']=="是" ? 1 : 0;
$inserts[$k-2]['remark'] = $v['R'] ?? '';
if (strlen($inserts[$k-2]['remark']) > 100) {
$this->error("备注太长".$k);
$this->ajaxReturn(['msg'=>"备注太长".$k,"status"=>0]);
}
$inserts[$k-2]['interface_person'] = $v['R'] ?? '';
$inserts[$k-2]['interface_person'] = $v['S'] ?? '';
if (strlen($inserts[$k-2]['interface_person']) > 50) {
$this->error("对接人太长".$k);
$this->ajaxReturn(['msg'=>"对接人太长".$k,"status"=>0]);
}
$inserts[$k-2]['create_time'] = time();
$inserts[$k-2]['update_time'] = time();
$inserts[$k-2]['communication_time'] = time();
@ -559,13 +603,14 @@ class SocietyInfoController extends ThinkController
$gameTypes = explode('/', $v['I']);
foreach ($gameTypes as $gameType) {
if (!M('game_type', 'tab_')->where(["type_name" => $gameType])->find()) {
$this->error("游戏类型有误:{$gameType}");
$this->ajaxReturn(['msg'=>"游戏类型有误:{$gameType}","status"=>0]);
return;
}
}
}
M('society_info', 'tab_')->addAll($inserts);
$this->success("导入成功");
$this->ajaxReturn(['msg'=>"导入成功","status"=>1]);
// $this->success("导入成功");
}
private function parseExcelIn($filename, $exts) {
@ -575,13 +620,13 @@ class SocietyInfoController extends ThinkController
//创建PHPExcel对象注意不能少了\
$PHPExcel=new \PHPExcel();
//如果excel文件后缀名为.xls导入这个类
if($exts == 'xls'){
// if($exts == 'xls'){
//import("Org.Util.PHPExcel.Reader.Excel5");
$PHPReader=new \PHPExcel_Reader_Excel5();
}else if($exts == 'xlsx'){
//import("Org.Util.PHPExcel.Reader.Excel2007");
$PHPReader=new \PHPExcel_Reader_Excel2007();
}
// }else if($exts == 'xlsx'){
// //import("Org.Util.PHPExcel.Reader.Excel2007");
// $PHPReader=new \PHPExcel_Reader_Excel2007();
// }
//载入文件
$PHPExcel=$PHPReader->load($filename);
//获取表中的第一个工作表如果要获取第二个把0改为1依次类推
@ -606,4 +651,32 @@ class SocietyInfoController extends ThinkController
return $data;
}
//模板导出
public function downloadSocial()
{
header("Content-type: text/html; charset=utf-8");
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
Vendor("PHPExcel.PHPExcel");
$objPHPExcel = new \PHPExcel();
$objReader = \PHPExcel_IOFactory::createReader('Excel2007');
//设置模板文件
$objPHPExcel = $objReader->load("Public/Admin/excel/social_template.xls");
$fileName = "公会信息模板";
ob_end_clean();//清除缓冲区,避免乱码
header('pragma:public');
header('Content-type:application/vnd.ms-excel;charset=utf-8;name="' . $fileName .'".xls');
header("Content-Disposition:attachment;filename={$fileName}.xls");//attachment新窗口打印inline本窗口打印
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
exit;
}
}

@ -32,7 +32,7 @@
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="l">省份:</td>
<td class="l"><i class="mustmark" style="margin-left:-7px">*</i>省份:</td>
<td class="r" style="width: 50px;">
<select name="province" id="province" class="select_gallery">
</select>
@ -40,7 +40,7 @@
</td>
</tr>
<tr>
<td class="l">城市:</td>
<td class="l"><i class="mustmark" style="margin-left:-7px">*</i>城市:</td>
<td class="r" style="width: 50px;">
<select name="city" id="city" class="select_gallery">
</select>
@ -84,8 +84,8 @@
</td>
</tr>
<tr>
<td class="l">游戏类型:</td>
<input id="game_type" name="game_type" type="hidden" value="{$game_types[0]['type_name']}">
<td class="l"><i class="mustmark" style="margin-left:-7px">*</i>游戏类型:</td>
<!-- <input id="game_type" name="game_type" type="hidden" value="{$game_types[0]['type_name']}">-->
<td class="r" style="">
<volist name="game_types" id="vo">
<span style="margin-right:18px;">{$vo['type_name']}: <input type="checkbox" name="game_types[]" value="{$vo['type_name']}"></span>
@ -236,10 +236,10 @@
var cres = $('form').serializeArray();
console.log(cres);
if ($("#province").val() == "请选择省份" || !$("#province").val()) {
// layer.msg('请选择省份');return ;
layer.msg('请选择省份');return ;
}
if (!$("#city").val()) {
// layer.msg('请选择城市');return ;
layer.msg('请选择城市');return ;
}
if (!$("#company_name").val()) {
layer.msg('请输入公司名');return ;

@ -33,7 +33,7 @@
<table border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td class="l">省份:</td>
<td class="l"><i class="mustmark" style="margin-left:-7px">*</i>省份:</td>
<td class="r" style="width: 50px;">
<select name="province" id="province" class="select_gallery">
</select>
@ -41,7 +41,7 @@
</td>
</tr>
<tr>
<td class="l">城市:</td>
<td class="l"><i class="mustmark" style="margin-left:-7px">*</i>城市:</td>
<td class="r" style="width: 50px;">
<select name="city" id="city" class="select_gallery">
</select>
@ -49,7 +49,7 @@
</td>
</tr>
<tr>
<td class="l">公司:</td>
<td class="l"><i class="mustmark" style="margin-left:-7px">*</i>公司:</td>
<td class="r table_radio">
<input type="text" value="{$data['company_name']}" name="company_name" id="company_name" class="input" placeholder="请输入公司名称" maxlength="50">
</td>
@ -85,7 +85,7 @@
</td>
</tr>
<tr>
<td class="l">游戏类型:</td>
<td class="l"><i class="mustmark" style="margin-left:-7px">*</i>游戏类型:</td>
<!--<input id="game_type" name="game_type" type="hidden" value="{$game_types[0]['type_name']}">-->
<td class="r" style="">
<volist name="game_types" id="vo">
@ -268,10 +268,10 @@
$("#submit").on("click",function(){
var cres = $('form').serializeArray();
if ($("#province").val() == "请选择省份" || !$("#province").val()) {
// layer.msg('请选择省份');return ;
layer.msg('请选择省份');return ;
}
if (!$("#city").val()) {
// layer.msg('请选择城市');return ;
layer.msg('请选择城市');return ;
}
if (!$("#company_name").val()) {
layer.msg('请输入公司名');return ;

@ -126,7 +126,8 @@
<form id="form" action="{:U('excelImport')}" method="post" class="form-horizontal" enctype="multipart/form-data">
<div class="input-list">
<input type="file" id="excelData" name="excelData" accept="application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">
<button class="submit_btn" id="submit" type="submit" target-form="form-horizontal">确 定</button>
<button class="submit_btn " id="submit" type="submit" target-form="form-horizontal" url="{:U('excelImport')}">确 定</button>
<button id="downloads" class="submit_btn" type="text" url="{:U('downloadSocial')}" target-form="form-horizontal" >下载模板</button>
<button id="excel_back" class="submit_btn" type="text" target-form="form-horizontal">返 回</button>
</div>
</form>
@ -220,58 +221,58 @@
</table>
</div>
</div>
<div class="data_list data_game_list model" style="display: none;">
<div class="" style="margin-top: 25px;">
<table border="1">
<!-- 表头 -->
<thead>
<tr>
<th>省份</th>
<th>城市</th>
<th>公司</th>
<th>注册资本</th>
<th>负责人</th>
<th>电话</th>
<th>微信</th>
<th>QQ</th>
<th>游戏类型</th>
<th>所做游戏</th>
<th>合作平台</th>
<th>推广规模</th>
<th>流水</th>
<th>地址</th>
<th>联盟信息</th>
<th>是否为意向客户</th>
<th>备注信息</th>
<th>对接人</th>
</tr>
</thead>
<!-- 列表 -->
<tbody>
<td rowspan="{$data.row}">--</td>
<td rowspan="{$data.row}">--</td>
<td rowspan="{$data.row}">--</td>
<td rowspan="{$data.row}">--</td>
<td rowspan="{$data.row}">--</td>
<td rowspan="{$data.row}">--</td>
<td rowspan="{$data.row}">--</td>
<td rowspan="{$data.row}">--</td>
<td rowspan="{$data.row}">--</td>
<td rowspan="{$data.row}">--</td>
<td rowspan="{$data.row}">--</td>
<td rowspan="{$data.row}">--</td>
<td rowspan="{$data.row}">--</td>
<td rowspan="{$data.row}">--</td>
<td rowspan="{$data.row}">--</td>
<td rowspan="{$data.row}">--</td>
<td rowspan="{$data.row}">--</td>
<td rowspan="{$data.row}">--</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- <div class="data_list data_game_list model" style="display: none;">-->
<!-- <div class="" style="margin-top: 25px;">-->
<!-- <table border="1">-->
<!-- &lt;!&ndash; 表头 &ndash;&gt;-->
<!-- <thead>-->
<!-- <tr>-->
<!-- <th>省份</th>-->
<!-- <th>城市</th>-->
<!-- <th>公司</th>-->
<!-- <th>注册资本</th>-->
<!-- <th>负责人</th>-->
<!-- <th>电话</th>-->
<!-- <th>微信</th>-->
<!-- <th>QQ</th>-->
<!-- <th>游戏类型</th>-->
<!-- <th>所做游戏</th>-->
<!-- <th>合作平台</th>-->
<!-- <th>推广规模</th>-->
<!-- <th>流水</th>-->
<!-- <th>地址</th>-->
<!-- <th>联盟信息</th>-->
<!-- <th>是否为意向客户</th>-->
<!-- <th>备注信息</th>-->
<!-- <th>对接人</th>-->
<!-- </tr>-->
<!-- </thead>-->
<!-- &lt;!&ndash; 列表 &ndash;&gt;-->
<!-- <tbody>-->
<!-- <td rowspan="{$data.row}">&#45;&#45;</td>-->
<!-- <td rowspan="{$data.row}">&#45;&#45;</td>-->
<!-- <td rowspan="{$data.row}">&#45;&#45;</td>-->
<!-- <td rowspan="{$data.row}">&#45;&#45;</td>-->
<!-- <td rowspan="{$data.row}">&#45;&#45;</td>-->
<!-- <td rowspan="{$data.row}">&#45;&#45;</td>-->
<!-- <td rowspan="{$data.row}">&#45;&#45;</td>-->
<!-- <td rowspan="{$data.row}">&#45;&#45;</td>-->
<!-- <td rowspan="{$data.row}">&#45;&#45;</td>-->
<!-- <td rowspan="{$data.row}">&#45;&#45;</td>-->
<!-- <td rowspan="{$data.row}">&#45;&#45;</td>-->
<!-- <td rowspan="{$data.row}">&#45;&#45;</td>-->
<!-- <td rowspan="{$data.row}">&#45;&#45;</td>-->
<!-- <td rowspan="{$data.row}">&#45;&#45;</td>-->
<!-- <td rowspan="{$data.row}">&#45;&#45;</td>-->
<!-- <td rowspan="{$data.row}">&#45;&#45;</td>-->
<!-- <td rowspan="{$data.row}">&#45;&#45;</td>-->
<!-- <td rowspan="{$data.row}">&#45;&#45;</td>-->
<!-- </tr>-->
<!-- </tbody>-->
<!-- </table>-->
<!-- </div>-->
<!-- </div>-->
<div class="page">
{$_page|default=''}
@ -375,6 +376,12 @@
//导航高亮
highlight_subnav("{:U('lists')}");
$(function(){
$("#downloads").on("click",function(){
var url = $(this).attr("url");
window.location.href = url;
return false;;
});
$("#excel_in").click(function () {
$(".search_list").hide();
$(".excel_list").show();
@ -382,6 +389,46 @@
$(".model").show();
return false;
});
$("#submit").click(function () {
var fileObj = document.getElementById("excelData").files[0]; // js 获取文件对象
var url = $(this).attr('url');
var oReq = new XMLHttpRequest();
var formFile = new FormData();
formFile.append("excelData", fileObj,"excelData.xlsx"); //加入文件对象
layer.confirm('【提示】是否确认财务部编辑保存', {
btn: ['确认','取消'],
title:false
}, function(index){
$.ajax({
url:url,
type:"post",
data:formFile,
dataType:'json',
cache: false,
processData: false,
contentType: false,
success:function(data){
if (data.status == 1) {
layer.msg(data.msg);
setTimeout(function(){
// window.parent.reload()
window.location.href = "{:U('lists')}";
},2000)
} else {
layer.msg(data.msg);
}
}
})
});
return false;
});
$("#excel_back").click(function () {
$(".search_list").show();
$(".excel_list").hide();

Loading…
Cancel
Save