protected function _update() { $id = $_POST["id"]; $model = M("MailOrganize"); $model->where("id={$id}")->delete(); $model = D("MailOrganize"); if (false === $model->create()) { $this->error($model->getError()); } if (in_array('user_id', $model->getDbFields())) { $model->user_id = get_user_id(); } if (in_array('user_name', $model->getDbFields())) { $model->user_name = get_user_name(); } //保存当前数据对象 $list = $model->add(); if ($list !== false) { //保存成功 $this->assign('jumpUrl', get_return_url()); $this->success('编辑成功!'); } else { //失败提示 $this->error('编辑失败!'); } }
function mark() { $action = $_REQUEST['action']; $id = $_REQUEST["id"]; $val = $_REQUEST["val"]; if (!empty($id)) { switch ($action) { case 'del': $result = $this->_destory($id, true); if ($result) { $this->ajaxReturn('', "删除成功", 1); } else { $this->ajaxReturn('', "删除失败", 0); } break; case 'move_folder': $field = 'group'; $result = $this->_set_field($id, $field, $val); if ($result !== false) { $this->assign('jumpUrl', get_return_url()); $this->success('操作成功!'); } else { //失败提示 $this->error('操作失败!'); } } } }
protected function _update() { $model = D("UserFolder"); if (false === $model->create()) { $this->error($model->getError()); } // 更新数据 $list = $model->save(); if (false !== $list) { //成功提示 $this->assign('jumpUrl', get_return_url()); $this->success('编辑成功!'); } else { //错误提示 $this->error('编辑失败!'); } }
public function import() { $save_path = get_save_path(); $opmode = $_POST["opmode"]; if ($opmode == "import") { import("@.ORG.Util.UploadFile"); $upload = new UploadFile(); $upload->savePath = $save_path; $upload->allowExts = array('xlsx', 'xls'); $upload->saveRule = uniqid; $upload->autoSub = false; if (!$upload->upload()) { $this->error($upload->getErrorMsg()); } else { //取得成功上传的文件信息 $uploadList = $upload->getUploadFileInfo(); Vendor('Excel.PHPExcel'); //导入thinkphp第三方类库 $inputFileName = $save_path . $uploadList[0]["savename"]; $objPHPExcel = PHPExcel_IOFactory::load($inputFileName); $sheetData = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true); // dump(count($sheetData)); // exit; $model = M(MODULE_NAME); //dump($sheetData); for ($i = $this->first_row; $i <= count($sheetData); $i++) { $data = array(); $data['emp_no'] = $sheetData[$i]["A"]; // $data['B']=PHPExcel_Shared_Date::ExcelToPHP($sheetData[$i]["B"]); $data['B'] = $sheetData[$i]["B"]; for ($k = 67; $k <= 67 + $this->field_count; $k++) { $data[chr($k)] = $sheetData[$i][chr($k)]; } $model->add($data); } //dump($sheetData); if (file_exists($_SERVER["DOCUMENT_ROOT"] . "/" . $inputFileName)) { unlink($_SERVER["DOCUMENT_ROOT"] . "/" . $inputFileName); } $this->assign('jumpUrl', get_return_url()); $this->success('导入成功!'); } } else { $this->display(); } }
function save() { $model = D("User"); if (false === $model->create()) { $this->error($model->getError()); } session('user_pic', $model->pic); // 更新数据 $list = $model->save(); if (false !== $list) { //成功提示 $this->assign('jumpUrl', get_return_url()); $this->success('编辑成功!'); } else { //错误提示 $this->error('编辑失败!'); } }
protected function _update($name = CONTROLLER_NAME) { $id = I("id"); $model = D($name); $model->where("id={$id}")->delete(); if (false === $model->create()) { $this->error($model->getError()); } //保存当前数据对象 $model->user_id = get_user_id(); $list = $model->add(); if ($list !== false) { //保存成功 $this->assign('jumpUrl', get_return_url()); $this->success('编辑成功!'); } else { //失败提示 $this->error('编辑失败!'); } }
function _update() { //B('FilterString'); $model = M('UserConfig'); if (false === $model->create()) { $this->error($model->getError()); } $model->push_web = implode(",", $model->push_web); $model->push_wechat = implode(",", $model->push_wechat); $model->id = get_user_id(); // 更新数据 $list = $model->save(); if (false !== $list) { //成功提示 $this->assign('jumpUrl', get_return_url()); $this->success('编辑成功!'); } else { //错误提示 $this->error('编辑失败!'); } }
function _update() { //B('FilterString'); $model = M('UserConfig'); if (false === $model->create()) { $this->error($model->getError()); } if (in_array('id', $model->getDbFields())) { $model->id = get_user_id(); } // 更新数据 $list = $model->save(); if (false !== $list) { //成功提示 $this->assign('jumpUrl', get_return_url()); $this->success('编辑成功!'); } else { //错误提示 $this->error('编辑失败!'); } }
protected function _update() { $name = $this->getActionName(); $model = D($name); // dump($model -> create());exit; if (false === ($data = $model->create())) { $this->error($model->getError() + "123123"); } if (!I("post.is_free")) { $data["is_free"] = ''; } $list = $model->save($data); if (false !== $list) { $this->assign('jumpUrl', get_return_url()); $this->success('编辑成功!'); //成功提示 } else { $this->error('编辑失败!'); //错误提示 } }
protected function _update() { $model = M('MailAccount'); if (false === $model->create()) { $this->error($model->getError()); } if (in_array('id', $model->getDbFields())) { $model->id = get_user_id(); } // 更新数据 $email = $_POST['email']; $list = $model->save(); if (false !== $list) { //成功提示 $this->_set_email($email); $this->assign('jumpUrl', get_return_url()); $this->success('编辑成功!'); } else { //错误提示 $this->error('编辑失败!'); } }
protected function _update() { $id = $_POST['id']; $model = D("Node"); if (false === $model->create()) { $this->error($model->getError()); } if (strpos($model->url, '##') !== false) { $model->sub_folder = ucfirst(get_module(str_replace("##", "", $model->url))) . "Folder"; } else { $model->sub_folder = ''; } // 更新数据 $list = $model->save(); if (false !== $list) { //成功提示 $this->assign('jumpUrl', get_return_url()); $this->success('编辑成功!'); } else { //错误提示 $this->error('编辑失败!'); } }
protected function _update() { $ajax = $_POST['ajax']; $id = $_POST['id']; $model = D("Contact"); if (false === $model->create()) { $this->error($model->getError()); } $model->__set('letter', get_letter($model->__get('name'))); // 更新数据 $list = $model->save(); if (false !== $list) { //成功提示 $this->assign('jumpUrl', get_return_url()); $this->success('编辑成功!'); } else { //错误提示 $this->error('编辑失败!'); } }
public function mark() { $action = $_REQUEST['action']; $id = $_REQUEST['id']; switch ($action) { case 'del': $field = 'folder'; $val = 4; $result = $this->_set_field($id, $field, $val); break; case 'del_forever': $this->_del($id); break; case 'spam': $field = 'folder'; $val = 5; $result = $this->_set_field($id, $field, $val); break; case 'readed': $field = 'read'; $val = 1; $result = $this->_set_field($id, $field, $val); break; case 'unread': $field = 'read'; $val = 0; $result = $this->_set_field($id, $field, $val); break; case 'darft': $field = 'folder'; $val = 3; $result = $this->_set_field($id, $field, $val); break; case 'move_folder': $field = 'folder'; $val = $_REQUEST['val']; $result = $this->_set_field($id, $field, $val); break; default: break; } if ($result !== false) { $this->assign('jumpUrl', get_return_url()); $this->success('操作成功!'); } else { //失败提示 $this->error('操作失败!'); } }
protected function _update() { $id = $_POST['id']; $model = D("Customer"); if (false === $model->create()) { $this->error($model->getError()); } $model->letter = get_letter($model->name); // 更新数据 $list = $model->save(); if (false !== $list) { //成功提示 $this->assign('jumpUrl', get_return_url()); $this->success('编辑成功!'); } else { //错误提示 $this->error('编辑失败!'); } }
public function set_duty() { $role_id = $_POST["role_id"]; $duty_list = $_POST["duty_list"]; $model = D("Role"); $model->del_duty($role_id); $result = $model->set_duty($role_id, $duty_list); if ($result === false) { $this->error('操作失败!'); } else { $this->assign('jumpUrl', get_return_url()); $this->success('操作成功!'); } }
/** 永久删除数据 **/ protected function _destory($id = null, $name = null, $return_flag = false) { if (empty($id)) { $id = $_REQUEST['id']; if (empty($id)) { $this->error('没有可删除的数据!'); } } if (empty($name)) { $name = $this->getActionName(); } $model = M($name); if (!empty($model)) { if (isset($id)) { if (is_array($id)) { $where['id'] = array("in", array_filter($id)); } else { $where['id'] = array('in', array_filter(explode(',', $id))); } $app_type = $this->config['app_type']; if ($app_type == "personal") { $where['user_id'] = get_user_id(); } $file_list = $model->where($where)->getField("id,add_file"); $file_list = array_filter(explode(";", implode($file_list))); $this->_destory_file($file_list); $result = $model->where($where)->delete(); if ($return_flag) { return $result; } if ($result !== false) { $this->assign('jumpUrl', get_return_url()); $this->success("彻底删除{$result}条!"); } else { $this->error('删除失败!'); } } else { $this->error('没有可删除的数据!'); } } }
public function import() { $save_path = get_save_path(); $opmode = $_POST["opmode"]; if ($opmode == "import") { import("@.ORG.Util.UploadFile"); $upload = new UploadFile(); $upload->savePath = $save_path; $upload->allowExts = array('xlsx'); $upload->saveRule = uniqid; $upload->autoSub = false; if (!$upload->upload()) { $this->error($upload->getErrorMsg()); } else { //取得成功上传的文件信息 $uploadList = $upload->getUploadFileInfo(); Vendor('Excel.PHPExcel'); //导入thinkphp第三方类库 $inputFileName = $save_path . $uploadList[0]["savename"]; $objPHPExcel = PHPExcel_IOFactory::load($inputFileName); $sheetData = $objPHPExcel->getActiveSheet()->toArray(null, true, true, true); $model = M("Vip"); for ($i = 2; $i <= count($sheetData); $i++) { $data = array(); $data['name'] = $sheetData[$i]["A"]; $data['short'] = $sheetData[$i]["B"]; $data['letter'] = get_letter($sheetData[$i]["A"]); $data['biz_license'] = $sheetData[$i]["C"]; $data['payment'] = $sheetData[$i]["D"]; $data['address'] = $sheetData[$i]["E"]; $data['salesman'] = $sheetData[$i]["F"]; $data['contact'] = $sheetData[$i]["G"]; $data['email'] = $sheetData[$i]["H"]; $data['office_tel'] = $sheetData[$i]["I"]; $data['mobile_tel'] = $sheetData[$i]["J"]; $data['fax'] = $sheetData[$i]["K"]; $data['im'] = $sheetData[$i]["L"]; $data['remark'] = $sheetData[$i]["M"]; $data['statu'] = 1; $model->add($data); } //dump($sheetData); if (file_exists($_SERVER["DOCUMENT_ROOT"] . "/" . $inputFileName)) { unlink($_SERVER["DOCUMENT_ROOT"] . "/" . $inputFileName); } $this->assign('jumpUrl', get_return_url()); $this->success('导入成功!'); } } else { $this->display(); } }
protected function _update() { $name = $this->getActionName(); $model = D($name); if (false === $model->create()) { $this->error($model->getError()); } $flow_id = $model->id; $list = $model->save(); $model_flow_filed = D("FlowField")->set_field($flow_id); if (false !== $list) { $this->assign('jumpUrl', get_return_url()); $this->success('编辑成功!'); //成功提示 } else { $this->error('编辑失败!'); //错误提示 } }
public function del() { $type = $_REQUEST['type']; $where['user_id'] = array("eq", get_user_id()); switch ($type) { case 'all': break; case 'dialogue': $receiver_id = $_REQUEST['reply_id']; $sender_id = get_user_id(); $where['_string'] = "(sender_id='{$sender_id}' and receiver_id='{$receiver_id}') or (receiver_id='{$sender_id}' and sender_id='{$receiver_id}')"; break; case 'message': $message_id = $_REQUEST['message_id']; $where['id'] = array("eq", $message_id); break; default: $this->ajaxReturn('', "删除失败", 0); break; } $model = D("Message"); $list = $model->where($where)->delete(); if ($list !== false) { //保存成功 $this->assign('jumpUrl', get_return_url()); $this->success('删除成功!'); } else { $this->error('删除失败!'); //失败提示 } }
public function mark_status() { $id = $_REQUEST['id']; $val = $_REQUEST['val']; if ($val == 3) { $field = 'end_date'; $date = date("Y-m-d"); $model = M("Todo"); $where['id'] = $id; $where['user_id'] = array('eq', get_user_id()); $list = $model->where($where)->setField($field, $date); } $field = 'status'; $result = $this->_set_field($id, $field, $val); if ($result !== false) { //保存成功 $this->assign('jumpUrl', get_return_url()); $this->success('操作成功!'); } else { //失败提示 $this->error('操作失败!'); } }
public function reject() { $model = D("ProductLog"); if (false === $model->create()) { $this->error($model->getError()); } $model->result = 0; if (in_array('user_id', $model->getDbFields())) { $model->user_id = get_user_id(); } if (in_array('user_name', $model->getDbFields())) { $model->user_name = get_user_name(); } $product_id = $model->product_id; $step = $model->step; //保存当前数据对象 $list = $model->save(); //可以裁决的人有多个人的时候,一个人评价完以后,禁止其他人重复裁决。 $model = D("ProductLog"); $model->where("step={$step} and product_id={$product_id} and result is null")->setField('is_del', 1); if ($list !== false) { //保存成功 D("Product")->where("id={$product_id}")->setField('step', 0); $this->assign('jumpUrl', get_return_url()); $this->success('操作成功!'); } else { //失败提示 $this->error('操作失败!'); } }
protected function _update() { $widget['date'] = true; $this->assign("widget", $widget); $id = $_POST['id']; $model = D("Crm"); if (false === $model->create()) { $this->error($model->getError()); } $model->need = implode(",", $model->need); // 更新数据 $list = $model->save(); if (false !== $list) { //成功提示 $this->assign('jumpUrl', get_return_url()); $this->success('编辑成功!'); } else { //错误提示 $this->error('编辑失败!'); } }
echo $OUTPUT->footer(); die; } // Let's get them all set up. complete_user_login($user); // Set the username cookie if (empty($CFG->nolastloggedin)) { // Store last logged in user in cookie if (empty($CFG->rememberusername) or $CFG->rememberusername == 2 and empty($frm->rememberusername)) { // No permanent cookies, delete old one if exists set_moodle_cookie(''); } else { set_moodle_cookie($USER->email); } } $urltogo = get_return_url(); // Discard any errors before the last redirect. unset($SESSION->loginerrormsg); // test the session actually works by redirecting to self $SESSION->wantsurl = $urltogo; redirect(new moodle_url('/local/obu_application/login.php', array('testsession' => $USER->id))); } else { if (empty($errormsg)) { if ($errorcode == AUTH_LOGIN_UNAUTHORISED) { $errormsg = get_string('unauthorisedlogin', '', $frm->username); } else { $errormsg = get_string('invalidlogin'); $errorcode = 3; } } }
public function save_log($id) { $model = D("TaskLog"); if (false === $model->create()) { $this->error($model->getError()); } $model->transactor = get_user_id(); $model->transactor_name = get_user_name(); if ($status == 4) { $model->finish_time = time(); } $list = $model->save(); $task_log_id = $id; $status = I('status'); $task_id = M("TaskLog")->where("id={$task_log_id}")->getField('task_id'); if ($status == 2) { M("Task")->where("id={$task_id}")->setField('status', 2); } if ($status == 4) { $task_id = I('task_id'); $forword_executor = I('forword_executor'); D('Task')->forword($task_id, $forword_executor); } if ($status > 2) { $where_count['task_id'] = array('eq', $task_id); $total_count = M("TaskLog")->where($where_count)->count(); $where_count['status'] = array('gt', 2); $finish_count = M("TaskLog")->where($where_count)->count(); if ($total_count == $finish_count) { M("Task")->where("id={$task_id}")->setField('status', 3); $user_id = M('Task')->where("id={$task_id}")->getField('user_id'); $this->_send_mail_finish($task_id, $user_id); } } if ($list !== false) { $this->assign('jumpUrl', get_return_url()); $this->success('提交成功!'); //成功提示 } else { $this->error('提交失败!'); //错误提示 } }
/** 删除数据 **/ protected function _destory($id) { $name = $this->getActionName(); $model = M($name); if (!empty($model)) { $pk = $model->getPk(); if (isset($id)) { if (is_array($id)) { $where[$pk] = array("in", array_filter($id)); } else { $where[$pk] = array('in', array_filter(explode(',', $id))); } $app_type = $this->config['app_type']; switch ($app_type) { case 'personal': $where['user_id'] = get_user_id(); break; default: break; } $file_list = $model->where($where)->getField("id,add_file"); $file_list = array_filter(explode(";", implode($file_list))); $this->_destory_file($file_list); $result = $model->where($where)->delete(); if ($result !== false) { $this->assign('jumpUrl', get_return_url()); $this->success("彻底删除{$result}条!"); } else { $this->error('删除失败!'); } } else { $this->error('没有可删除的数据!'); } } }
public function save_transfer() { $account_id_payment = $_REQUEST['account_id_payment']; $account_id_income = $_REQUEST['account_id_income']; $account_list = M("FinanceAccount")->getField('id,name'); $account_name_payment = $account_list[$account_id_payment]; $account_name_income = $account_list[$account_id_income]; $money = $_REQUEST['money']; $remark_income = "由[{$account_name_payment}]转入[{$money}]"; $remark_payment = "向[{$account_name_income}]转出[{$money}]"; $data['doc_no'] = $_REQUEST['doc_no']; $data['input_date'] = $_REQUEST['input_date']; $data['type'] = "转账"; $data['actor_user_name'] = $_REQUEST['actor_user_name']; $data['doc_type'] = 3; $data_payment = $data; $data_income = $data; $data_payment['account_id'] = $account_id_payment; $data_payment['payment'] = $money; $data_payment['remark'] = $remark_payment; $data_income['account_id'] = $account_id_income; $data_income['income'] = $money; $data_income['remark'] = $remark_income; $model = D("Finance"); /*保存当前数据对象 */ if (false === $model->create()) { $this->error($model->getError()); } $model->account_id = $account_id_payment; $model->payment = $money; $model->remark = $remark_payment; $list = $model->add(); $model = D("Finance"); if (false === $model->create()) { $this->error($model->getError()); } $model->account_id = $account_id_income; $model->income = $money; $model->remark = $remark_income; $list = $model->add(); if ($list !== false) { //保存成功 $this->assign('jumpUrl', get_return_url()); $this->success('新增成功!'); } else { $this->error('新增失败!'); //失败提示 } }
public function reset_pwd() { $id = $_POST['user_id']; $password = $_POST['password']; if ('' == trim($password)) { $this->error('密码不能为空!'); } $User = M('User'); $User->password = md5($password); $User->id = $id; $result = $User->save(); if (false !== $result) { $this->assign('jumpUrl', get_return_url()); $this->success("密码修改成功"); } else { $this->error('重置密码失败!'); } }
function field() { if ($_POST) { $opmode = $_POST["opmode"]; $model = D("ProductField"); if (false === $model->create()) { $this->error($model->getError()); } if ($opmode == "add") { $list = $model->add(); if ($list !== false) { //保存成功 $this->assign('jumpUrl', get_return_url()); $this->success('新增成功!'); } else { $this->error('新增失败!'); //失败提示 } } if ($opmode == "edit") { $list = $model->save(); if ($list !== false) { //保存成功 $this->assign('jumpUrl', get_return_url()); $this->success('保存成功!'); } else { $this->error('保存失败!'); //失败提示 } } if ($opmode == "del") { $id = $_REQUEST['id']; $list = $model->where("id={$id}")->delete(); if ($list !== false) { //保存成功 $this->assign('jumpUrl', get_return_url()); $this->success('删除成功!'); } else { $this->error('删除失败!'); //失败提示 } } } $widget['date'] = true; $this->assign("widget", $widget); $model = D("ProductField"); $type_id = $_REQUEST['type_id']; $this->assign('type_id', $type_id); $where['type_id'] = array('eq', $type_id); $where['is_del'] = 0; $field_list = $model->where($where)->order('sort asc')->select(); $tree = list_to_tree($field_list); $this->assign('menu', sub_tree_menu($tree)); $this->assign("field_list", $field_list); $this->display(); }
function save_comment() { $model = D('MonthlyReportComment'); if (false === $model->create()) { $this->error($model->getError()); } $opmode = $_POST["opmode"]; switch ($opmode) { case "add": $list = $model->add(); break; case "edit": $list = $model->save(); break; case "del": $this->_del($name); break; default: $this->error("非法操作"); } if ($list !== false) { //保存成功 $this->assign('jumpUrl', get_return_url()); $this->success('操作成功!'); } else { $this->error('新增失败!'); //失败提示 } }
/** 插入新新数据 **/ protected function _insert() { $name = $this->getActionName(); $model = D($name); if (false === $model->create()) { $this->error($model->getError()); } if (in_array('user_id', $model->getDbFields())) { $model->user_id = get_user_id(); } if (in_array('user_name', $model->getDbFields())) { $model->user_name = get_user_name(); } if (in_array('dept_id', $model->getDbFields())) { $model->dept_id = get_dept_id(); } if (in_array('dept_name', $model->getDbFields())) { $model->dept_name = get_dept_name(); } $model->create_time = time(); /*保存当前数据对象 */ $list = $model->add(); if ($list !== false) { //保存成功 $this->assign('jumpUrl', get_return_url()); $this->success('新增成功!'); } else { $this->error('新增失败!'); //失败提示 } }