我正在开发一个学生管理系统,问题是我想在结果视图(函数viewAssessedStudent)中重定向它,我想要的就是在将数据保存到插入视图(函数评估)后将其重定向到Result视图,其中包含我在插入视图中插入的信息。
PS。我正在使用Codeigniter activerecord ...
控制器
function assessment($id) {
$this->session->set_userdata('top_menu', 'Student Information');
$this->session->set_userdata('sub_menu', 'student/assessment');
$data['title'] = 'student Assessment';
$student_result = $this->student_model->get();
$data['studentList'] = $student_result;
$session_result = $this->session_model->get();
$data['sessionList'] = $session_result;
$class = $this->class_model->get();
$data['classlist'] = $class;
$feesdiscount_result = $this->feediscount_model->get();
$data['feediscountList'] = $feesdiscount_result;
$feegroup_result = $this->feesessiongroup_model->getFeesByGroup($fee_group_id);
$data['feegroupList'] = $feegroup_result;
$this->form_validation->set_rules('student_id', 'Student Name', 'trim|required|xss_clean');
$this->form_validation->set_rules('class_id', 'Grade Level', 'trim|required|xss_clean');
$this->form_validation->set_rules('fee_session_group_id', 'Payment Method', 'trim|required|xss_clean');
if ($this->form_validation->run() == FALSE) {
$this->load->view('layout/header', $data);
$this->load->view('student/studentAssest', $data);
$this->load->view('layout/footer', $data);
} else {
$session_id = $this->input->post('session_id');
$student_id = $this->input->post('student_id');
$class_id = $this->input->post('class_id');
$feegroup_id = $this->input->post('fee_session_group_id');
$discount_id = $this->input->post('fees_discount_id');
$discount_amount = $this->input->post('std_discount');
$insert_array = array(
'session_id' => $session_id,
'student_id' => $student_id,
'class_id' => $class_id,
'assessment_date' => $this->input->post('assessment_date')
);
$studentSession_id = $this->assessment_model->add($insert_array);
$fee_data = array(
'student_session_id' => $studentSession_id,
'fee_session_group_id' => $feegroup_id,
);
$this->studentfeemaster_model->add($fee_data);
$discount_data = array(
'student_session_id' => $studentSession_id,
'fees_discount_id' => $discount_id,
'std_discount' => $discount_amount,
);
$this->feediscount_model->allotdiscount($discount_data);
$this->session->set_flashdata('msg', '<div class="alert alert-success text-left">Student Assessed Successfully</div>');
redirect('student/assessment');
}
}
function viewAssessedStudent($id){
$data['title'] = 'Student Details';
$student = $this->student_model->getAssesstStudent($id);
$gradeList = $this->grade_model->get();
$student_session_id = $student['student_session_id'];
$student_due_fee = $this->studentfeemaster_model->getStudentFees($student['student_session_id']);
$student_discount_fee = $this->feediscount_model->getStudentFeesDiscount($student['student_session_id']);
$data['student_discount_fee'] = $student_discount_fee;
$data['student_due_fee'] = $student_due_fee;
$data['gradeList'] = $gradeList;
$data['student'] = $student;
$this->load->view('layout/header', $data);
$this->load->view('student/studentShowAssess', $data);
$this->load->view('layout/footer', $data);
}
插入视图
<form action="<?php echo site_url("student/assessment") ?>" id="employeeform" name="employeeform" method="post" accept-charset="utf-8" enctype="multipart/form-data">
<div class="pull-right box-tools col-md-3" style="position: absolute;right: 14px;top: 13px;">
<select id="session_id" name="session_id" class="form-control" >
<?php
foreach ($sessionList as $session) {
?>
<option value="<?php echo $session['id'] ?>" <?php
if (set_value('session_id') == $session['id'])
{
echo "selected =selected";
}
?>><?php echo $session['session']?></option>
<?php
$count++;
}
?>
</select>
</div>
<div class="box-body">
<div class="tshadow mb25 bozero">
<h3 class="pagetitleh2">Assess <?php echo $this->lang->line('student'); ?></h3>
<div class="around10">
<?php if ($this->session->flashdata('msg')) { ?>
<?php echo $this->session->flashdata('msg') ?>
<?php } ?>
<?php echo $this->customlib->getCSRF(); ?>
<div class="col-md-2" style="padding-bottom: 25px;">
<label for="exampleInputEmail1"></label>
<img class="profile-user-img img-responsive img-square" src="<?php echo base_url() . $student['image'] ?>" alt="User profile picture">
</div>
<div class="row">
<div class="col-md-5">
<div class="form-group">
<label for="exampleInputEmail1">Select Student</label>
<select id="student_id" name="student_id" class="form-control" >
<option value="">Select Student</option>
<?php
foreach ($studentList as $student) {
?>
<option value="<?php echo $student['id'] ?>" <?php
if (set_value('student_id') == $student['id']) {
echo "selected =selected";
}
?>><?php echo $student['lastname'] . ", " . $student['firstname'] . " " . $student['middlename'] ?></option>
<?php
$count++;
}
?>
</select>
<span class="text-danger"><?php echo form_error('student_id'); ?></span>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="exampleInputEmail1">Grade Level Applying</label>
<select id="class_id" name="class_id" class="form-control" >
<option value=""><?php echo $this->lang->line('select'); ?></option>
<?php
foreach ($classlist as $class) {
?>
<option value="<?php echo $class['id'] ?>" <?php
if (set_value('class_id') == $class['id']) {
echo "selected =selected";
}
?>><?php echo $class['class'] ?></option>
<?php
$count++;
}
?>
</select>
<span class="text-danger"><?php echo form_error('class_id'); ?></span>
</div>
</div>
<div class="col-md-2" hidden="true">
<div class="form-group">
<label for="exampleInputEmail1">Assessment Date</label>
<input id="assessment_date" name="assessment_date" placeholder="" type="text" class="form-control" value="<?php echo set_value('assesstment_date', date($this->customlib->getSchoolDateFormat())); ?>" readonly="readonly" />
<span class="text-danger"><?php echo form_error('assessment_date'); ?></span>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="exampleInputEmail1">Mode of Payment</label>
<select class="form-control" id="fee_session_group_id" name="fee_session_group_id">
<option value="">Select</option>
<?php
foreach ($feegroupList as $feegroup) {
?>
<option value="<?php echo $feegroup->id ?>" <?php
if (set_value('fee_session_group_id') == $feegroup->id) {
echo "selected =selected";
}
?>><?php echo $feegroup->group_name ?></option>
<?php
$count++;
}
?>
</select>
<span class="text-danger"><?php echo form_error('fee_session_group_id'); ?></span>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="exampleInputEmail1">Payment Discount</label>
<select id="fees_discount_id" name="fees_discount_id" class="form-control" >
<option value=""><?php echo $this->lang->line('select'); ?></option>
<?php
foreach ($feediscountList as $feeDiscount) {
?>
<option value="<?php echo $feeDiscount['id'] ?>" <?php
if ($feeDiscount['feediscount_id'] == $feeDiscount['id']) {
echo "selected =selected";
}
?>><?php echo $feeDiscount['name'] ?></option>
<?php
$count++;
}
?>
</select>
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label for="exampleInputEmail1">Discount Amount</label>
<input id="std_discount" name="std_discount" placeholder="" type="text" class="form-control" value="<?php echo set_value('std_discount'); ?>" />
<span class="text-danger"><?php echo form_error('std_discount'); ?></span>
</div>
</div>
</div>
</div>
</div>
<div class="box-footer">
<button type="submit" class="btn btn-success pull-right">Save Assestment</button>
</div>
</form>
结果视图
<div class="col-md-10 pull-right" style="padding-top: 25px;">
<div class="col-md-4">
<div class="form-group">
<label for="exampleInputEmail1">Student Last Name</label>
<input id="student_id" name="student_id" placeholder="" type="text" class="form-control" readonly="readonly" value="<?php echo set_value('student_id', $student['lastname']); ?>" />
<span class="text-danger"><?php echo form_error('student_id'); ?></span>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="exampleInputEmail1">Student Last Name</label>
<input id="student_id" name="student_id" placeholder="" type="text" class="form-control" readonly="readonly" value="<?php echo set_value('student_id', $student['firstname']); ?>" />
<span class="text-danger"><?php echo form_error('student_id'); ?></span>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="exampleInputEmail1">Student Last Name</label>
<input id="student_id" name="student_id" placeholder="" type="text" class="form-control" readonly="readonly" value="<?php echo set_value('student_id', $student['middlename']); ?>" />
<span class="text-danger"><?php echo form_error('student_id'); ?></span>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="exampleInputEmail1">Grade Level Applied</label>
<input id="class_id" name="class_id" placeholder="" type="text" class="form-control" readonly="readonly" value="<?php echo set_value('class_id', $student['class']); ?>" />
<span class="text-danger"><?php echo form_error('student_id'); ?></span>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="exampleInputEmail1">Assessment Date</label>
<input id="assessment_date" name="assessment_date" placeholder="" type="text" class="form-control" readonly="readonly" value="<?php echo set_value('assessment_date', $student['assessment_date']); ?>" />
<span class="text-danger"><?php echo form_error('assessment_date'); ?></span>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="exampleInputEmail1">Registration Date</label>
<input id="admission_date" name="admission_date" placeholder="" type="text" class="form-control" readonly="readonly" value="<?php echo set_value('admission_date', date($this->customlib->getSchoolDateFormat(), $this->customlib->dateyyyymmddTodateformat($student['admission_date']))); ?>" />
<span class="text-danger"><?php echo form_error('admission_date'); ?></span>
</div>
</div>
</div>
This is the insertView this is the resultView and I want to redirect in this view after I saved the information in the insertView