本文整理汇总了PHP中AjaxResponse::alert方法的典型用法代码示例。如果您正苦于以下问题:PHP AjaxResponse::alert方法的具体用法?PHP AjaxResponse::alert怎么用?PHP AjaxResponse::alert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AjaxResponse
的用法示例。
在下文中一共展示了AjaxResponse::alert方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setTCFunc
/**
* 新增/编辑校区AJAX方法
* @param array $param map<string,variant>类型参数
* int tc_id ID,若为0表新增
* int tc_tiid 所属培训机构ID
* string tc_name 名称
* int tc_flag 状态,-1已删 0禁用 1启用 大于1待审
* int tc_environ 环境指数
* int tc_provid 地址省
* int tc_cityid 地址市
* int tc_areaid 地址区县
* string tc_ctcaddr 联系地址
* string tc_ctcperson 联系人
* string tc_ctcphone 联系电话
*/
public function setTCFunc($param)
{
$resp = new AjaxResponse();
$param = Func::param_copy($param, 'tc_id', 'tc_name', 'tc_tiid', 'tc_flag', 'tc_environ', 'tc_provid', 'tc_cityid', 'tc_areaid', 'tc_ctcaddr', 'tc_ctcperson', 'tc_ctcphone');
if ($param['tc_name'] == '') {
$resp->alert('培训校区名称不可为空');
return $resp;
}
if (!Validate::isInt($param['tc_provid']) || $param['tc_provid'] < 1) {
$resp->alert('请选择校区所在省');
return $resp;
}
if ($param['tc_ctcaddr'] == '') {
$resp->alert('请填写联系地址');
return $resp;
}
if ($param['tc_ctcperson'] == '') {
$param['tc_ctcperson'] = NULL;
}
if ($param['tc_ctcphone'] == '') {
$resp->alert('请填写联系电话');
return $resp;
}
if (!Validate::isInt($param['tc_environ'])) {
$reps->alert('请填写环境指数');
return $resp;
}
try {
if ($param['tc_id']) {
unset($param['tc_tiid']);
TrainingInstitutionModel::setTrainingCampus($param);
admin_log('edit', 'trainingcampus', "tc_id: " . $param['tc_id']);
} else {
$param['tc_id'] = TrainingInstitutionModel::addTrainingCampus($param);
admin_log('add', 'trainingcampus', "tc_id: " . $param['tc_id']);
}
$resp->redirect('/admin/traininginstitution/tcinfo/' . $param['tc_id']);
} catch (Exception $e) {
$resp->alert($e->getMessage());
}
return $resp;
}
示例2: baseFetchCTeacherListFunc
public function baseFetchCTeacherListFunc($param)
{
$resp = new AjaxResponse();
$param = Func::param_copy($param, 'grade_id', 'cteacher_name', 'cors_id');
$grade_id = $param['grade_id'];
unset($param['grade_id']);
if (empty($param['cors_id'])) {
$resp->alert('请选择培训课程');
return $resp;
}
if (empty($param['cteacher_name'])) {
unset($param['cteacher_name']);
}
try {
$cors_id = $param['cors_id'];
$sql = <<<EOT
SELECT ct_id, ct_name FROM v_course_campus_teacher WHERE cct_ccid IN (
SELECT cc_id FROM t_course_campus WHERE cc_corsid = {$cors_id}
)
EOT;
$ct_map = Fn::db()->fetchPairs($sql);
if (!empty($ct_map)) {
$ct_id_list = array_keys($ct_map);
$ct_id_str = implode(',', $ct_id_list);
$sql = <<<EOT
SELECT DISTINCT ctg_ctid FROM t_cteacher_gradeid
WHERE ctg_ctid IN ({$ct_id_str}) AND (ctg_gradeid = 0 OR ctg_gradeid = {$grade_id})
EOT;
$ct_id2 = Fn::db()->fetchCol($sql);
$ct_list = array();
foreach ($ct_map as $k => $v) {
if (in_array($k, $ct_id2)) {
$ct_list[] = array('ct_id' => $k, 'ct_name' => $v);
}
}
$resp->call('fnSetCTeacherListDiv', $ct_list);
} else {
$resp->call('fnSetCTeacherListDiv', array());
}
} catch (Exception $e) {
$resp->alert($e->getMessage());
}
return $resp;
}
示例3: regenerateReportFunc
/**
* 重新生成报告
* @param mixed $rule_id_str
* @return AjaxResponse
*/
public function regenerateReportFunc($rule_id_str)
{
$resp = new AjaxResponse();
$rule_ids = explode(',', $rule_id_str);
if (!$rule_ids) {
$resp->alert('请指定需要重新生成报告的评估规则。');
return $resp;
}
try {
$flag = true;
foreach ($rule_ids as $rule_id) {
$param = array('rule_id' => $rule_id, 'html_status' => 0, 'status' => 0, 'is_success' => 0, 'num' => 0);
$flag = ReportCommandModel::setConvert2pdfStatus($param);
}
if ($flag) {
$resp->alert('重新生成报告已加入计划任务中,请耐心等待或执行相关php命令。');
$resp->call('fnCloseDialog', 'id_regeneratereport_dlg');
} else {
$resp->alert('操作失败,请重试。');
}
} catch (Exception $e) {
$resp->alert($e->getMessage());
}
return $resp;
}
示例4: setCTFFunc
/**
* 新增/编辑授课教师来源AJAX方法
* @param int $ctf_id 旧ID,若为0表新增,否则表编辑
* @param array $param map<string,varaint>类型的新属性
* int ctf_id 新ID
* string ctf_name 新名称
*/
public function setCTFFunc($ctf_id, $param)
{
$resp = new AjaxResponse();
$param = Func::param_copy($param, 'ctf_id', 'ctf_name');
if ($ctf_id) {
if (!$this->check_power_new('course_setctfinfo', false)) {
$resp->alert('您没有权限执行该功能');
return $resp;
}
} else {
if (!$this->check_power_new('course_addctfinfo', false)) {
$resp->alert('您没有权限执行该功能');
return $resp;
}
}
if (!Validate::isInt($param['ctf_id'])) {
$resp->alert('培训课程授课教师来源ID必须为整数');
return $resp;
}
if ($param['ctf_name'] == '') {
$resp->alert('培训课程授课教师来源名称不可为空');
return $resp;
}
try {
if ($ctf_id) {
CourseModel::setCourseTeachfrom($ctf_id, $param);
admin_log('edit', '', "授课教师来源 ctf_id: " . $param['ctf_id']);
} else {
CourseModel::addCourseTeachfrom($param);
admin_log('add', '', "授课教师来源 ctf_id: " . $param['ctf_id']);
}
$resp->call('location.reload');
} catch (Exception $e) {
$resp->alert($e->getMessage());
}
return $resp;
}
示例5: ajax_call
/**
* ajax方法调用,使用方法: Fn::ajax_call($controller, 'method1', 'method2',
* 'method3');
* it will call $controller->method1Func(), $controller->method2Func()...
*/
public static function ajax_call(CI_Controller $obj)
{
$args = func_get_args();
if (count($args) < 2) {
throw new Exception('Error arguments count must not less than 2');
}
array_shift($args);
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' && isset($_POST['ajax_call']) && $_POST['ajax_call'] === 'true' && isset($_POST['function']) && in_array($_POST['function'], $args)) {
$func = $_POST['function'] . self::$_ajax_func_suffix;
if (method_exists($obj, $func)) {
$ajax_response = call_user_func_array(array($obj, $func), is_array($_POST['arguments']) ? $_POST['arguments'] : array());
if ($ajax_response instanceof AjaxResponse) {
header('Content-Type:application/json;charset=UTF-8');
echo $ajax_response->__toString();
}
exit;
} else {
$ajax_response = new AjaxResponse();
$ajax_response->alert('Not exist ajax method: ' . $_POST['function']);
header('Content-Type:application/json;charset=UTF-8');
echo $ajax_response->__toString();
exit;
}
}
$str = '';
foreach ($args as $v) {
$str .= "function ajax_{$v}(){ fnAjaxCall(location.href, '{$v}', arguments);}\n";
}
$obj->_ajaxScript = $str;
}
示例6: setSchoolTeacherFunc
/**
* 编辑授课教师AJAX方法
* @param array $param map<stirng,variant>类型的参数
* int scht_schid 学校id
* int ct_id 教师ID,若为0表新增
* string ct_name 名称
* string subject_id_str 形如1,3,4样式的学科ID列表
* string grade_id_str 形如1,3,4样式的年级ID列表
* int ct_flag 状态,-1已删,0禁用,1启用,大于1待审
*/
public function setSchoolTeacherFunc($param)
{
$resp = new AjaxResponse();
if (!$this->check_power_new('school_editteacher', false)) {
$resp->alert('您没有权限执行该功能');
return $resp;
}
$param = Func::param_copy($param, 'scht_schid', 'ct_id', 'ct_name', 'ct_contact', 'subject_id_str', 'grade_id_str', 'ct_flag', 'cct_ccid_str', 'ct_memo');
if (!Validate::isInt($param['scht_schid']) || $param['scht_schid'] <= 0) {
$resp->alert('教师所属学校不正确');
return $resp;
}
if (!Validate::isInt($param['ct_id']) || $param['ct_id'] < 0) {
$resp->alert('教师ID不正确');
return $resp;
}
if ($param['ct_name'] == '') {
$resp->alert('教师名称不正确');
return $resp;
}
if (!Validate::isJoinedIntStr($param['grade_id_str'])) {
$resp->alert('所选年级不正确');
return $resp;
}
if (!Validate::isJoinedIntStr($param['subject_id_str'])) {
$resp->alert('所选学科不正确');
return $resp;
}
$param['subjectid_list'] = array_unique(explode(',', $param['subject_id_str']));
$param['gradeid_list'] = array_unique(explode(',', $param['grade_id_str']));
if (count($param['gradeid_list']) == count(C('grades'))) {
$param['gradeid_list'] = array(0);
}
try {
if ($param['ct_id']) {
SchoolModel::setSchoolTeacher($param);
admin_log('edit', 'school_teacher', "ct_id: " . $param['ct_id']);
} else {
$param['ct_id'] = SchoolModel::addSchoolTeacher($param);
admin_log('add', 'school_teacher', "ct_id: " . $param['ct_id']);
}
$resp->redirect('/admin/school/teacherlist/' . $param['scht_schid']);
} catch (Exception $e) {
$resp->alert($e->getMessage());
}
return $resp;
}
示例7: setExamRelateFlagFunc
public function setExamRelateFlagFunc($er_examid, $er_zmoss_examid, $er_flag = 0)
{
$resp = new AjaxResponse();
if (!$this->check_power_new('zmoss_sync', false)) {
$resp->alert('您没有权限!');
return $resp;
}
if (!Validate::isInt($er_examid) || $er_examid <= 0 || !Validate::isInt($er_zmoss_examid) || $er_zmoss_examid <= 0) {
$resp->alert('请指定需要同步成绩的考试学科');
return $resp;
}
$er_flag = intval($er_flag);
if (!in_array($er_flag, array(0, 1, 2, 3))) {
$resp->alert('请设置合理的状态');
return $resp;
}
if (!ExamModel::get_exam($er_examid, 'exam_pid')) {
$resp->alert('请指定需要同步成绩的考试学科!');
return $resp;
}
try {
if (ZmossModel::setExamRelateFlag($er_examid, $er_zmoss_examid, $er_flag)) {
admin_log('set', 'sync_result', $er_examid . '-' . $er_zmoss_examid);
$resp->alert('同步成绩已加入计划任务列表中,请稍后查看同步结果!');
$resp->refresh();
}
} catch (Exception $e) {
$resp->alert($e->getMessage());
}
return $resp;
}
示例8: studentAjaxLogin
public static function studentAjaxLogin($param, $bPasswordEnc = false, $bValidateOnly = false)
{
$resp = new AjaxResponse();
$param = Func::param_copy($param, 'ticket', 'password');
if (empty($param['ticket']) || empty($param['password'])) {
$resp->alert('帐号或密码不能为空!');
return $resp;
}
$where = array();
$bind = array();
if (is_email($param['ticket'])) {
$where[] = 'email = ?';
$bind[] = $param['ticket'];
} else {
if (is_idcard($param['ticket'])) {
$where[] = 'idcard = ?';
$bind[] = $param['ticket'];
} else {
//message('请输入合法的登陆帐号');
$where[] = 'exam_ticket = ? OR external_account = ?';
$bind[] = $param['ticket'];
$bind[] = $param['ticket'];
}
}
$where[] = 'password = ?';
if ($bPasswordEnc) {
$bind[] = $param['password'];
} else {
$bind[] = my_md5($param['password']);
}
$sql_where = implode(') AND (', $where);
$sql = <<<EOT
SELECT uid, email, first_name, last_name, idcard, exam_ticket,
CONCAT(last_name, first_name) AS fullname,
external_account, maprule, grade_id, sex, birthday, picture, mobile,
is_check, last_login, last_ip, email_validate, status, is_delete, addtime,
account, account_status
FROM rd_student WHERE ({$sql_where})
EOT;
$user = Fn::db()->fetchRow($sql, $bind);
if ($user) {
$uid = $user['uid'];
if (trim($user['picture'])) {
$user['avatar_url'] = __IMG_ROOT_URL__ . $user['picture'];
} else {
$user['avatar_url'] = __IMG_ROOT_URL__ . 'zeming/exam/head.gif';
}
$resp->exdata = $user;
if (!$bValidateOnly) {
$sess = Fn::sess();
if ($sess->userdata('uid') == $uid) {
// 当前登录用户已经是请求登录用户,不需要再登录了
$resp->refresh();
} else {
$data = array();
$data['last_login'] = time();
$data['last_ip'] = Func::get_client_ip();
Fn::db()->update('rd_student', $data, 'uid = ' . $uid);
$sess->set_userdata(array('uid' => $uid, 'uinfo' => $user));
$sql = "SELECT * FROM rd_student_ranking WHERE uid = {$uid}";
$score_ranks = Fn::db()->fetchRow($sql);
if (!$score_ranks && $user['grade_id'] == 6) {
// 在basic页面会自动判断是否填写完全学生成绩并进行提示跳转
$resp->redirect(site_url('student/profile/basic'));
} else {
$resp->refresh();
}
}
}
} else {
$resp->alert('帐号或密码不正确!');
}
return $resp;
}
示例9: setCTFunc
/**
* 编辑授课教师AJAX方法
* @param array $param map<stirng,variant>类型的参数
* int ct_id 教师ID,若为0表新增
* string ct_name 名称
* string ctc_contact 联系方式
* string subject_id_str 形如1,3,4样式的学科ID列表
* string grade_id_str 形如1,3,4样式的年级ID列表
* int ct_flag 状态,-1已删,0禁用,1启用,大于1待审
*/
public function setCTFunc($param)
{
$resp = new AjaxResponse();
$param = Func::param_copy($param, 'ct_id', 'ct_name', 'ct_contact', 'subject_id_str', 'grade_id_str', 'ct_flag', 'cct_ccid_str', 'ct_memo');
if (!Validate::isInt($param['ct_id']) || $param['ct_id'] < 0) {
$reps->alert('教师ID不正确');
return $resp;
}
if ($param['ct_name'] == '') {
$resp->alert('教师名称不正确');
return $resp;
}
if ($param['ct_contact'] == '') {
$param['ct_contact'] = NULL;
}
if (!Validate::isJoinedIntStr($param['grade_id_str'])) {
$resp->alert('所选年级不正确');
return $resp;
}
if (!Validate::isJoinedIntStr($param['subject_id_str'])) {
$resp->alert('所选学科不正确');
return $resp;
}
if ($param['cct_ccid_str'] == '') {
$param['cct_ccid_list'] = array();
} else {
if (!Validate::isJoinedIntStr($param['cct_ccid_str'])) {
$resp->alert('所选课程不正确');
return $resp;
} else {
$param['cct_ccid_list'] = explode(',', $param['cct_ccid_str']);
}
}
$param['subjectid_list'] = array_unique(explode(',', $param['subject_id_str']));
$param['gradeid_list'] = array_unique(explode(',', $param['grade_id_str']));
if (count($param['gradeid_list']) == count(C('grades'))) {
$param['gradeid_list'] = array(0);
}
try {
if ($param['ct_id']) {
CTeacherModel::setCTeacher($param);
admin_log('edit', 'cteacher', "ct_id: " . $param['ct_id']);
} else {
$param['ct_id'] = CTeacherModel::addCTeacher($param);
admin_log('add', 'cteacher', "ct_id: " . $param['ct_id']);
}
$resp->redirect('/admin/cteacher/ctinfo/' . $param['ct_id']);
} catch (Exception $e) {
$resp->alert($e->getMessage());
}
return $resp;
}
示例10: paytrans
/**
* 供外部支付验证使用 IMPORTANT
* GET参数如下:
* @param string from 来源标识
* @param string data 加密数据字符串,data解密后包含如下字段:
* string ukey 用户标识,必须(准考证号)
* string pass 密码,若有该字段,表示转账
* string auth 密码代替验证,若有该字段,表示转账,是array('ukey' => '', 'amount' => '')的加密值
* int amount 转账金额,不可为0,若有该字段,则表示转账
* 返回的为json格式的array数据:
* string error 若有该参数,则表明有错误信息
* string data 该参数表示返回的加密信息字符串,这里返回的是用户信息,解密后为array类型包含如下字段:
* string ukey 用户标识
* int account 当前余额
*/
public function paytrans()
{
$resp = new AjaxResponse();
while (true) {
$from = $_GET['from'];
$lv_cfg = C('loginverify');
if (!$lv_cfg) {
$resp->alert('非法访问来源0');
break;
}
if (!isset($lv_cfg[$from])) {
$resp->alert('非法访问来源1');
break;
}
$hashcode = $lv_cfg[$from]['hashcode'];
$enc_data = $_GET['data'];
$param0 = Func::decrypt($enc_data, $hashcode);
//header('Content-Type:application/json;charset=UTF-8');
if ($param0 === false) {
$resp->alert('非法访问');
break;
}
if (!isset($param0['ukey'])) {
$resp->alert('非法访问参数');
break;
}
$uinfo = StudentModel::get_student_by_exam_ticket($param0['ukey'], 'uid,exam_ticket,password,account');
if (empty($uinfo)) {
$resp->alert('非法用户');
break;
}
if ((isset($param0['pass']) || isset($param0['auth'])) && isset($param0['amount'])) {
if (!Validate::isInt($param0['amount']) || $param0['amount'] == 0) {
$resp->alert('转账金额不能为0');
break;
}
if (isset($param0['pass']) && my_md5($param0['pass']) == $uinfo['password'] || isset($param0['auth']) && Func::encrypt(array('ukey' => $param0['ukey'], 'amount' => $param0['amount']), $hashcode) == $param0['auth']) {
if (bcadd($uinfo['account'], $param0['amount'], 0) < 0) {
$resp->alert('用户余额不足');
break;
}
// 这里开始交易
$tr_no = TransactionRecordModel::genTransactionRecordTrNo();
$db = Fn::db();
$db->beginTransaction();
$rec = array('tr_no' => $tr_no, 'tr_type' => 4, 'tr_uid' => $uinfo['uid'], 'tr_pid' => NULL, 'tr_money' => bcadd($uinfo['account'], $param0['amount'], 0), 'tr_cash' => NULL, 'tr_trade_amount' => $param0['amount'], 'tr_adminid' => 1, 'tr_flag' => 2, 'tr_createtime' => time());
$rec['tr_finishtime'] = $rec['tr_createtime'];
if ($param0['amount'] > 0) {
$rec['tr_comment'] = "从{$lv_cfg[$from]['name']}转入{$param0['amount']}择明通宝";
} else {
$v = 0 - $param0['amount'];
$rec['tr_comment'] = "转出{$v}择明通宝到{$lv_cfg[$from]['name']}";
}
try {
$db->insert('t_transaction_record', $rec);
$db->update('rd_student', array('account' => $rec['tr_money']), 'uid = ' . $uinfo['uid']);
$db->commit();
} catch (Exception $e) {
$db->rollBack();
$resp->alert('转账失败');
break;
}
$uinfo['account'] = $rec['tr_money'];
$resp->exdata = array('ukey' => $uinfo['exam_ticket'], 'account' => $uinfo['account']);
} else {
$resp->alert('用户验证未通过');
}
break;
}
// 只显示余额
$resp->exdata = array('ukey' => $uinfo['exam_ticket'], 'account' => $uinfo['account']);
break;
}
$json_data = array();
if ($resp->exdata) {
$json_data['data'] = Func::encrypt($resp->exdata, $hashcode);
} else {
$resp_data = json_decode($resp->__toString(), true);
$json_data['error'] = $resp_data[0][1];
}
$json_str = json_encode($json_data);
header('Content-Type:application/json;charset=UTF-8');
echo "{$json_str}";
exit;
}