Exemple #1
0
 function saveCell()
 {
     $sheet = get_current_sheet();
     $cell_id = $this->_get("cell_id");
     $new_content = $this->_post("content");
     $new_content = stripslashes($new_content);
     //$new_content = iconv('utf-8','windows-1251',$new_content);
     $new_content = trim($new_content);
     MyExcel::setCellSource($sheet, $cell_id, $new_content);
     echo MyExcel::getCellValue($sheet, $cell_id);
 }
 public function export()
 {
     //$_GET['price']=1;
     //var_dump($_GET);
     $where = " 1";
     if (!empty($_GET)) {
         if ($_GET['start_time'] != "" && $_GET['start_time'] != "开始日期") {
             $where .= " and updated_at >= '" . $_GET['start_time'] . "'";
         }
         if ($_GET['end_time'] != "" && $_GET['end_time'] != "截止日期") {
             $where .= " and updated_at <= '" . $_GET['end_time'] . " 23:59:59'";
         }
         if ($_GET['title'] != "") {
             $where .= " and title like '%" . $_GET['title'] . "%'";
         }
         if ($_GET['name'] != "") {
             $where .= " and name like '%" . $_GET['name'] . "%'";
         }
         if ($_GET['tel'] != "") {
             $where .= " and tel like '%" . $_GET['tel'] . "%'";
         }
         if ($_GET['orderId'] != "") {
             $where .= " and orderId like '%" . $_GET['orderId'] . "%'";
         }
         if ($_GET['yhq'] != "") {
             $yOb = M("yhq");
             $yArr = $yOb->where("code='{$_GET['yhq']}'")->select();
             if (isset($yArr) && !empty($yArr)) {
                 $yhqId = $yArr[0]['id'];
             } else {
                 $yhqId == 0;
             }
             $where .= " and yhqId = {$yhqId}";
         }
         if ($_GET['status'] != "") {
             $where .= " and status =" . $_GET['status'];
         }
     }
     $yOb = M("Order");
     $data = $yOb->field("id,orderId,name,tel,address_id,title,price,isDiscount,discount,yhq,yhqId,payType,status,CCID,transfer,transferCode,time,updated_at")->where($where)->order("id desc")->select();
     //echo "<pre>";var_dump($data); echo "</pre>";
     //echo $yOb->getLastSql();die();
     $addOb = M("address");
     foreach ($data as $k => $dv) {
         //通过优惠券id得到优惠券码
         $yOb = M("yhq");
         $yId = $dv['yhqId'];
         $yArr = $yOb->where("id={$yId}")->select();
         $data[$k]['yhqId'] = $yArr[0]['code'];
         //将状态翻译成文字
         if ($dv['status'] == 1) {
             $data[$k]['status'] = "未付款";
         } elseif ($dv['status'] == 2) {
             $data[$k]['status'] = "已付款";
         } elseif ($dv['status'] == 3) {
             $data[$k]['status'] = "已发货";
         } elseif ($dv['status'] == 4) {
             $data[$k]['status'] = "已过期";
         } elseif ($dv['status'] == 5) {
             $data[$k]['status'] = "已关闭";
         } elseif ($dv['status'] == 6) {
             $data[$k]['status'] = "已取消";
         }
         //将支付方式翻译成文字
         if ($dv['payType'] == 1) {
             $data[$k]['payType'] = "支付宝";
         } elseif ($dv['payType'] == 2) {
             $data[$k]['payType'] = "财付通";
         }
         //将是否打折翻译成文字
         if ($dv['isDiscount'] == 1) {
             $data[$k]['isDiscount'] = "打折";
         } elseif ($dv['isDiscount'] == 0) {
             $data[$k]['isDiscount'] = "不打折";
         }
         //将订单id加上单引号,以免excel由于用科学计数法将后面改成0
         $data[$k]['orderId'] = "'" . $data[$k]['orderId'] . "'";
         //计算出交易价格
         $data[$k]['price'] = $data[$k]['price'] - $data[$k]['discount'] - $data[$k]['yhq'];
         //将地址信息由码创成文字
         $addArr = $addOb->where("id={$dv['address_id']}")->select();
         // echo $addOb -> getLastSql();
         //var_dump($addArr);
         if ($addArr != null) {
             $pOb = M("province");
             $province = $pOb->where("provinceId=" . $addArr[0]['province'])->select();
             $cOb = M("city");
             $city = $cOb->where("cityId=" . $addArr[0]['city'])->select();
             $aOb = M("area");
             $area = $aOb->where("areaId=" . $addArr[0]['area'])->select();
             $addr = $province[0]['province'] . $city[0]['city'] . $area[0]['area'] . $addArr[0]['detail'];
             $data[$k]['address_id'] = $addr;
             //	echo $addr;
             $data[$k]['mailCode'] = $addArr[0]['mailCode'];
         }
         // var_dump($data);
     }
     import("ORG.Util.MyExcel");
     $ob = new MyExcel();
     ob_end_clean();
     $ob->setTitle(array('ID', '订单号', '用户名', '用户电话', '收货地址', '商品名称', '交易价格', '是否打折', '折扣价格', '优惠券金额', '优惠券码', '支付方式', '订单状态', '卡号', '快递名称', '快递编号', '生成时间', '修改时间', '邮编'))->setFileName("订单")->dump($data, 2007);
 }
 function import1()
 {
     $dir = $_FILES['file-name1'];
     $date = date("Y-m-d H:i:s");
     if ($_FILES['file-name1']['error'] == '0') {
         $type = substr($_FILES['file-name1']['type'], -5);
         //var_dump($type);die();
         if ($type == 'xlsx' || $type == '/kset' || $type == 'excel' || $type == 'sheet') {
             if ($_FILES['file-name1']['size'] <= 2000000) {
                 $filePath = $_FILES['file-name1']['tmp_name'];
                 //var_dump($filePath);die;
                 import("ORG.Util.MyExcel");
                 $excel = new MyExcel();
                 //var_dump($excel);die();
                 $excel->loadExcel($filePath);
                 $columnTitle = $excel->findColumnTitle();
                 //var_dump($columnTitle);die;
                 $strTitle = md5(trim(implode(',', $columnTitle)));
                 //$standard=md5("电话号码,ICCID,IP,产品型号,生产日期,WiFi-SSID,WiFi密码,备注,NULL");
                 $standard = md5("上网号");
                 //var_dump($standard);die;
                 if ($standard != $strTitle) {
                     echo "<script language='javascript'>alert('请选择正确的模板!');window.history.back(-1);</script>";
                 } else {
                     $data = $excel->findAll();
                     //echo "<pre>";
                     //var_dump($data);die();
                     //echo "</pre>";
                     //echo "<pre>";var_dump($data);echo "</pre>";die();
                     $shOb = M("flows");
                     if (count($data) <= 1) {
                         echo "<script language='javascript'>alert('无数据!');window.history.back(-1);</script>";
                     } else {
                         for ($i = 2; $i <= count($data); $i++) {
                             $reIn = $shOb->query("update r_flows set flow=0 where  CCID=" . $data[$i]['A']);
                         }
                         if ($reIn !== false) {
                             echo "<script language='javascript'>alert('导入成功!');window.history.back(-1);</script>";
                         }
                     }
                 }
             } else {
                 echo "<script language='javascript'>alert('文件过大!');window.history.back(-1);</script>";
             }
         } else {
             echo "<script language='javascript'>alert('文件类型不正确!');window.history.back(-1);</script>";
         }
     } else {
         echo "<script language='javascript'>alert('文件上传失败!');window.history.back(-1);</script>";
     }
 }
 public function import1()
 {
     $dir = $_FILES['file-name1'];
     /*
     echo "<pre>";
     var_dump($dir);
     echo "</pre>";die();
     */
     if ($_FILES['file-name1']['error'] == '0') {
         $type = substr($_FILES['file-name1']['type'], -5);
         // var_dump($type);die();
         if ($type == 'xlsx' || ($type = '/kset' || ($type = 'excel' || ($type = 'sheet')))) {
             if ($_FILES['file-name1']['size'] <= 2000000) {
                 $filePath = $_FILES['file-name1']['tmp_name'];
                 //var_dump($filePath);
                 import("ORG.Util.MyExcel");
                 $excel = new MyExcel();
                 //var_dump($excel);die();
                 $excel->loadExcel($filePath);
                 $columnTitle = $excel->findColumnTitle();
                 $strTitle = md5(trim(implode(',', $columnTitle)));
                 //$standard=md5("电话号码,ICCID,IP,产品型号,生产日期,WiFi-SSID,WiFi密码,备注");
                 $standard = md5("设备号,卡状态,配额类型,截止日期");
                 if ($standard != $strTitle) {
                     echo "<script language='javascript'>alert('请选择正确的模板!');window.history.back(-1);</script>";
                 } else {
                     $data = $excel->findAll();
                     //var_dump($data);exit();
                     //echo "<pre>";
                     //var_dump($data);die();
                     //echo "</pre>";
                     //echo "<pre>";var_dump($data);echo "</pre>";die();
                     if (count($data) <= 1) {
                         echo "<script language='javascript'>alert('无数据!');window.history.back(-1);</script>";
                     } else {
                         $dataStr = "";
                         for ($i = 2; $i <= count($data); $i++) {
                             //$dataStr.=",('".$data[$i]['A']."','".ip2long($data[$i]['B'])."','".$data[$i]['C']."','".$data[$i]['D']."','".$simBatch."',1)";
                             $shOb = M("simhard");
                             $type = stripcslashes($data[$i]['C']);
                             $deadTime = excelTime($data[$i]['D']);
                             //将时间日期字段做一下格式转换
                             //$deadTime = stripcslashes('2014-12-31');
                             $status = stripcslashes($data[$i]['B']);
                             if (stripcslashes($status) == "") {
                                 $status = 1;
                             }
                             $CCID = $data[$i]['A'];
                             $date = date("Y-m-d H:i:s");
                             $reIn = $shOb->query("update r_simhard set deadTime='{$deadTime}',type='{$type}',status='{$status}',updated_at='{$date}'  where CCID='{$CCID}'");
                         }
                         //$dataStr1=substr($dataStr,1); //var_dump($dataStr1);die();
                         if ($reIn !== false) {
                             echo "<script language='javascript'>alert('导入成功!');window.history.back(-1);</script>";
                         }
                     }
                 }
             } else {
                 echo "<script language='javascript'>alert('文件过大!');window.history.back(-1);</script>";
             }
         } else {
             echo "<script language='javascript'>alert('文件类型不正确!');window.history.back(-1);</script>";
         }
     } else {
         echo "<script language='javascript'>alert('文件上传失败!');window.history.back(-1);</script>";
     }
 }
 public function export()
 {
     //$_GET['price']=1;
     //var_dump($_GET);
     $where = " 1";
     if (!empty($_GET)) {
         if ($_GET['start_time'] != "" && $_GET['start_time'] != "开始日期") {
             $where .= " and createTime >= '" . $_GET['start_time'] . "'";
         }
         if ($_GET['end_time'] != "" && $_GET['end_time'] != "截止日期") {
             $where .= " and createTime <= '" . $_GET['end_time'] . " 23:59:59'";
         }
         if ($_GET['code'] != "") {
             $where .= " and code = '" . $_GET['code'] . "'";
         }
         if ($_GET['type'] != "") {
             $where .= " and type =" . $_GET['type'];
         }
         if ($_GET['inPrice'] != "") {
             $where .= " and inPrice =" . $_GET['inPrice'];
         }
         if ($_GET['status'] != "") {
             $where .= " and status =" . $_GET['status'];
         }
     }
     $yOb = M("yhq");
     $data = $yOb->where($where)->order("id desc")->select();
     //echo "<pre>";var_dump($data); echo "</pre>";
     //echo $yOb->getLastSql();die();
     import("ORG.Util.MyExcel");
     $ob = new MyExcel();
     ob_end_clean();
     $ob->setTitle(array('ID', '优惠券码', '优惠券价钱', '类型', '状态', '生成时间', '修改时间'))->setFileName("优惠券")->dump($data, 2007);
 }
 public function export()
 {
     $where = " status=3";
     if (!empty($_GET)) {
         if ($_GET['start_time'] != "" && $_GET['start_time'] != "开始日期") {
             $where .= " and updated_at >= '" . $_GET['start_time'] . "'";
         }
         if ($_GET['end_time'] != "" && $_GET['end_time'] != "截止日期") {
             $where .= " and updated_at <= '" . $_GET['end_time'] . " 23:59:59'";
         }
         if ($_GET['title'] != "") {
             $where .= " and title like '%" . $_GET['title'] . "%'";
         }
         if ($_GET['CCID'] != "") {
             $where .= " and CCID like '%" . $_GET['CCID'] . "%'";
         }
     }
     $yOb = M("cardorder");
     $data = $yOb->field("id,orderId,uid,pid,title,price,isDiscount,discount,yhqPrice,yhqId,payType,status,CCID,beginTime,endTime,time,updateTime,num")->where($where)->order("id desc")->select();
     //echo "<pre>";var_dump($data); echo "</pre>";
     //echo $yOb->getLastSql();die();
     $addOb = M("address");
     foreach ($data as $k => $dv) {
         //通过优惠券id得到优惠券码
         $yOb = M("yhq");
         $yId = $dv['yhqId'];
         $yArr = $yOb->where("id={$yId}")->select();
         $data[$k]['yhqId'] = $yArr[0]['code'];
         //将状态翻译成文字
         if ($dv['status'] == 1) {
             $data[$k]['status'] = "未付款";
         } elseif ($dv['status'] == 2) {
             $data[$k]['status'] = "待充值";
         } elseif ($dv['status'] == 3) {
             $data[$k]['status'] = "已充值";
         }
         //将支付方式翻译成文字
         if ($dv['payType'] == 1) {
             $data[$k]['payType'] = "支付宝";
         } elseif ($dv['payType'] == 2) {
             $data[$k]['payType'] = "财付通";
         }
         //将是否打折翻译成文字
         if ($dv['isDiscount'] == 1) {
             $data[$k]['isDiscount'] = "打折";
         } elseif ($dv['isDiscount'] == 0) {
             $data[$k]['isDiscount'] = "不打折";
         }
         //将订单id加上单引号,以免excel由于用科学计数法将后面改成0
         $data[$k]['orderId'] = "'" . $data[$k]['orderId'] . "'";
         //计算出交易价格
         $data[$k]['price'] = $data[$k]['price'] - $data[$k]['discount'] - $data[$k]['yhqPrice'];
     }
     import("ORG.Util.MyExcel");
     $ob = new MyExcel();
     ob_end_clean();
     $ob->setTitle(array('ID', '订单号', '用户ID', '商品ID', '商品名称', '交易价格', '是否打折', '折扣价格', '优惠券金额', '优惠券码', '支付方式', '订单状态', '卡号', '套餐开始时间', '套餐截止时间', '订单生成时间', '订单修改时间', '购买数量'))->setFileName("订单")->dump($data, 2007);
 }
function val($cell)
{
    return MyExcel::getCellValue(get_current_sheet(), $cell);
}