public function postForceimport(Request $request) { $cacheMethod = PHPExcel_CachedObjectStorageFactory::cache_to_discISAM; PHPExcel_Settings::setCacheStorageMethod($cacheMethod); if ($request->hasFile('excel')) { if ($request->file('excel')->isValid()) { $file = $request->file('excel'); $filename = date("YmdHis", time()) . floor((microtime(true) - time()) * 1000) . ".xls"; $operand = 'update/' . $filename; $file->move(storage_path() . "/app/update/", $filename); $filename = storage_path() . "/app/update/" . $filename; $objReader = new PHPExcel_Reader_Excel5(); if (!$objReader->canRead($filename)) { return Redirect::back()->withInput()->withErrors(['无法读取您上传的excel,请重试!']); } $objPHPExcel = $objReader->load($filename); $before_json = self::exportAllToFile(); StudentManageLog::insertLog("批量修改", $operand, $before_json, null, $request->ip()); $arr = array(); $currentSheet = $objPHPExcel->getSheet(0); $arr[] = self::fetchAllStudentInfo($currentSheet, true); $currentSheet = $objPHPExcel->getSheet(1); $arr[] = self::fetchAllFreshInfo($currentSheet, true); $currentSheet = $objPHPExcel->getSheet(2); $arr[] = self::fetchAllSuspendInfo($currentSheet, true); $currentSheet = $objPHPExcel->getSheet(3); self::fetchAllCountryInfo($currentSheet); $currentSheet = $objPHPExcel->getSheet(4); $arr[] = self::fetchAllGraduateInfo($currentSheet, true); $currentSheet = $objPHPExcel->getSheet(5); $arr[] = self::fetchAllLeaveInfo($currentSheet, true); $currentSheet = $objPHPExcel->getSheet(6); $arr[] = self::fetchAllNoregisterInfo($currentSheet, true); return view('excel.forceimport')->withTips($arr); } else { return Redirect::back()->withInput()->withErrors(['上传失败,请重试!']); } } else { return Redirect::back()->withInput()->withErrors(['请选择已经填好的excel文件!']); } }
public function getDeleteinfo(Request $request) { if ($request->has("id")) { $stu = Student::find(Input::get("id")); if ($stu) { $operand = $stu->name . "(" . $stu->id . ")"; $before_json = $stu->toJson(); $stu->delete(); $after_json = ""; StudentManageLog::insertLog("删除信息", $operand, $before_json, $after_json, $request->ip()); $response = array('status' => ['error' => 0, 'note' => '删除成功'], 'influence' => 1); return json_encode($response); } else { //未找到stu_id $response = array('status' => ['error' => 1, 'note' => '未找到id'], 'influence' => 0); return json_encode($response); } } else { //没有stu_id参数 $response = array('status' => ['error' => -1, 'note' => '需要id'], 'influence' => 0); return json_encode($response); } }