Bug #61
已結束會員畫面點擊已購買課程無法顯示內容
SC 是由 Sashiba Chou 於 超過 4 年 前更新
- 狀態 從 New 變更為 In Progress
SC 是由 Sashiba Chou 於 超過 4 年 前更新
- 狀態 從 In Progress 變更為 Closed
- 完成比例 從 0 變更為 100
- theme\dark\templates\member.php
call script function get_lessons() when click "已購買課程"
function get_lessons(){
console.log("[get_lessons]");
$.ajax({
url: "",
type: "GET",
data: {},
}).success(function(data, textStatus, jqXHR){
//console.log(data);
$("#about").html(data);
}).error(function(jqXHR, textStatus, errorThrown ) {
alert("Request failed: " + textStatus + " - Please try again.");
});
}
- hoosk\hoosk0\controller\frontend\Cart.php
Ajax to get_lessons()
public function get_lessons(){
//$oauth_uid = $this->input->post('oauth_uid');
$records = $this->Transaction_model->get_lessons();
$data['paid'] = [];
$data['unpaid'] = [];
foreach($records as $r){
if((int)$r["paid"]==0)
array_push($data['unpaid'], $r);
else
array_push($data['paid'], $r);
}
$data['paid_table_header'] = empty($data['paid'])?"無資料":'<tr><th>交易編號</th><th>姓名</th><th>Email</th><th>講座/課程</th><th>人數</th><th>付費狀況</th><th>付費日期</th><th>描述</th></tr>';
$data['unpaid_table_header'] = empty($data['unpaid'])?"無資料":'<tr><th>訂單編號</th><th>姓名</th><th>講座/課程</th><th>人數</th><th>付費狀況<br>(繳費期限)</th><th>付費方式</th><th></th></tr>';
echo $this->load->view('templates/lessons', $data, true);
//return "sashiba get lessons SUCCESS!. " . $oauth_uid;
}
- hoosk/hoosk0/models/Frontend/Transaction_model.php
//用戶查詢買過的課程
function get_lessons($cond){
$transaction_records = [];
$this->db->select("*");
$this->db->from('transaction_records');
$this->db->join('activities', 'activities.id = transaction_records.lesson_id');
foreach($cond as $k => $v){
$this->db->where($k, $v);
}
$this->db->where('oauth_uid', $this->session->userdata('oauth_uid'));
$query = $this->db->get();
//注意是用array,而不是array of Objects
foreach ($query->result_array() as $row){
array_push($transaction_records, $row);
}
return $transaction_records;
}
h3. stuck at here @ hoosk\hoosk0\controller\frontend\Cart.php
$records = $this->Transaction_model->get_lessons();
h3. resolved by changing @ hoosk\hoosk0\controller\frontend\Cart.php
$records = $this->Transaction_model->get_lessons([]);