1
컨트롤러 클래스에 메서드를 몇 가지 작업을 수행하고 있습니다. 이제는 PDF를 생성하는 동일한 컨트롤러에서 다른 메서드를 호출해야합니다.동일한 컨트롤러 내에서 codeigniter 메서드 호출
하지만 두 번째 방법을 호출하면 첫 번째 방법이 완료되지 않습니까?
는 그래서 같은 두 번째 방법을 호출, 그래서이 라인 아래에 아무것도 완료 나던 :
$this->generate_certificate($course_id);
내가 뭔가를 놓치고 있습니까? 첫 번째 방법이 계속되는 것을 막지 않는 방식으로 호출해야합니까?
첫 번째 방법, 관련 비트 | :
else if($progress == 'c') {
// the course is complete and the user has pressed the complete button
// on the final page of the course
// set course as complete in the db, set completed date, set due to next due
// as defined in course date
// get todays date
$todays_date = date("Y-m-d");
// add specified months on for next due
$months = $course_object[0]->renewal_period;
$due_date = date('Y-m-d', strtotime($todays_date . ' + ' . $months .' months'));
$training_data = array();
$training_data['user_id'] = $user_id;
$training_data['course_id'] = $course_id;
$training_data['due'] = $due_date;
$this->training_model->set_course_complete($training_data);
$this->generate_certificate($course_id);
//certificate generated, redirect to training dashboard
$view_data = array(
'page_title' => 'Training Dashboard',
'user_courses' => $this->training_model->get_user_courses($user_id),
);
$this->session->set_flashdata('msg', 'You have successfully completed this course!');
$this->load->view('training/training_dashboard',$view_data);
}
는 PDF 방법을 생성 :
private function generate_certificate($course_id) {
$this->load->model('org_model');
$this->load->model('user_model');
// get todays date
$todays_date = date('d F Y');
// get currently logged in user details
$user_id = $this->session->userdata('user_id');
$user_object = $this->user_model->get_user($user_id);
$users_name = $user_object[0]->first_name . " " . $user_object[0]->last_name;
// course data
$course_object = $this->training_model->get_course_data($course_id);
// get org name
$org_id = $this->session->userdata('org_id');
$org_name_object = $this->org_model->get_org_name($org_id);
$org_name = $org_name_object[0]->org_name;
$html=" // I've removed this as its large, but works perfectly // ";
//this the the PDF filename that user will get to download
$pdfFilePath = "Certificate.pdf";
//load mPDF library
$this->load->library('m_pdf');
//generate the PDF from the given html
$this->m_pdf->pdf->WriteHTML($html);
//download it.
$this->m_pdf->pdf->Output($pdfFilePath, "D");
}
두 가지 방법을 알려주시겠습니까? – elddenmedio
원래 게시물에 추가됨 – frobak
어디에서'$ course_id'를 얻었습니까? – elddenmedio