관리-도구
편집 파일: reviews.php
<?php global $mysqli; $total_reviews=0; $training_ob=$this->load('training_control'); $course_control = $this->load("course_control"); $all_course = $training_ob->getCourse(); $install_url =get_option("install_url"); $page_count=1; if(isset($_GET['page_count']) && is_numeric($_GET['page_count'])) { $page_count=(int)$_GET['page_count']; } $course_id= (int) (isset( $_GET['cfcourse_id'] ) && is_numeric( $_GET['cfcourse_id'] ) ) ?$mysqli->real_escape_string( $_GET['cfcourse_id'] ):false; $rating= (int) (isset( $_GET['rat_sum'] ) && is_numeric( $_GET['rat_sum'] ) ) ?$mysqli->real_escape_string( $_GET['rat_sum'] ):false; $min_rat = (int) (isset( $_GET['min-rating'] ) && is_numeric( $_GET['min-rating'] ) ) ?$mysqli->real_escape_string( $_GET['min-rating'] ):0; $max_rat = (int) (isset( $_GET['max-rating'] ) && is_numeric( $_GET['max-rating'] ) ) ?$mysqli->real_escape_string( $_GET['max-rating'] ):0; $summary= (int) (isset( $_GET['cfcourse_filter'] ) ) ?$mysqli->real_escape_string( $_GET['cfcourse_filter'] ):false; $filter= (int) (isset( $_GET['cfcourse_filter_review'] )) ?$mysqli->real_escape_string( $_GET['cfcourse_filter_review'] ):false; ob_start(); echo '<div class="col-lg-2"> '.createSearchBoxBydate().' </div> <div class="col-lg-2 my-3 my-lg-0 "> <div class="position-relative"> <button class="w-100 btn dropdown-toggle btn-sm btn-block" id="cf-course-filter-btn">'.t('Filter reviews').'</button> <div class="mx-auto " id="cf-course-open-filter"> <div class="mb-3"> <select id="cf-course-selec-course" class="form-control form-control-sm""> <option value="all">'.t('All Courses').'</option>'; foreach($all_course as $course) { if( $course_id == $course['id'] ) { echo '<option value='.$course['id'].' selected>'.$course['title'].'</option>'; }else{ echo '<option value='.$course['id'].' >'.$course['title'].'</option>'; } } echo '</select> </div> <div class="mb-3"> <select id="cf-course-filter-comment" class="form-control form-control-sm"> <option value="all" '. ($summary==false?"selected":"") .' >'.t('Filter with summary').'</option> <option value="20" '.(($summary==20)?"selected":"").'>'.t('summary above 20 character').'</option> <option value="50" '.(($summary==50)?"selected":"").'>'.t('summary above 50 character').'</option> <option value="100" '.(($summary==100)?"selected":"").'>'.t('summary above 100 character').'</option> <option value="200" '.(($summary==200)?"selected":"").'>'.t('summary above 200 character').'</option> <option value="500" '.(($summary==500)?"selected":"").'>'.t('summary above 500 character').'</option> </select> </div> <div class="mb-3"> <select id="cf-course-select-rat-sum" class="form-control form-control-sm"> <option value="all" '.(($rating==false)?"selected":"").'>'.t('All').'</option> <option value="5" '.(($rating==5)?"selected":"").'>5 '.t('Rating').'</option> <option value="4.5" '.(($rating==4.5)?"selected":"").'>4.5 '.t('Rating').'</option> <option value="4" '.(($rating==4)?"selected":"").'>4 '.t('Rating').'</option> <option value="3.5" '.(($rating==3.5)?"selected":"").'>3.5 '.t('Rating').'</option> <option value="3" '.(($rating==3)?"selected":"").'>3 '.t('Rating').'</option> <option value="2.5" '.(($rating==2.5)?"selected":"").'>2.5 '.t('Rating').'</option> <option value="2" '.(($rating==2)?"selected":"").'>2 '.t('Rating').'</option> <option value="1.5" '.(($rating==1.5)?"selected":"").'>1.5 '.t('Rating').'</option> <option value="1" '.(($rating==1)?"selected":"").'>1 '.t('Rating').'</option> <option value="0.5" '.(($rating==0.5)?"selected":"").'>0.5 '.t('Rating').'</option> </select> </div> <div class="mb-3"> <select id="cf-course-filter-reivews" class="form-control form-control-sm"> <option value="all" '. ($filter=="all"?"selected":"") .' >'.t('All reviews').'</option> <option value="r" '. ($filter=="r"?"selected":"") .'>'.t('Read reviews').'</option> <option value="ur" '. ($filter=="ur"?"selected":"") .'>'.t('Unread reviews').'</option> </select> </div> <div class="mb-3"> <div class="input-group mb-3"> <input type="number" class="form-control" value="'.$min_rat.'" min="0" max="5" id="cf-course-min-rating" style="border-bottom:1px solid;" name="min-rating" placeholder="min" /> <input type="number" class="form-control" value="'.$max_rat.'" min="0" max="5" id="cf-course-max-rating" style="border-bottom:none" name="max-rating" placeholder="max" /> <div class="input-group-append"> <button class="btn btn-primary" id="cf-course-enter-rating" type="button">'.t('Search').'</span> </div> </div> </div> </div> </div> </div> <div class="col-lg-3"> '.showRecordCountSelection().' </div> <div class="col-lg-2">'.arranger(array('id'=>'date')).' </div> <div class="col-lg-3 "> <div class="mb-3"> <div class="input-group input-group-sm"> <div class="input-group-prepend "> <span class="input-group-text"><i class="fas fa-search"></i></span> </div> <input type="text" class="form-control form-control-sm" placeholder="'.t('Search with course name, student name, summary').'" onkeyup="searchPaymentMethods(this.value)"> </div> </div> </div>'; $table_manager=ob_get_clean(); $max_leads_limit=(int)get_option('qfnl_max_records_per_page'); $total_reviews=$training_ob->getReviewsCount( $course_id ); $reviews=$training_ob->getAllReviews( $total_reviews, $max_leads_limit, $page_count, $course_id,$rating,$min_rat,$max_rat,$summary,$filter ); ?> <div class="container-fluid pb-3"> <div class="row page-titles mb-4"> <div class="col-md-5 align-self-center"> <h4 class="text-themecolor" id="commoncontainerid"><?= t('Manage Reviews'); ?></h4> </div> <div class="col-md-7 align-self-center"> <?php if($course_id): ?> <p class="p-3 mt-1 rounded bg-info text-white"> <?= t('Use the shortcode'); ?> <span class="text-white"> <strong style="cursor:pointer;" onclick="copyText(`[cfcourse_review id=<?php echo $course_id; ?>]`)" data-bs-toggle="tooltip" title="Copy to clipboard">[cfcourse_review id=<?php echo $course_id; ?>]</strong> </span> <?= t('to show on any page'); ?>. </p> <?php endif; ?> </div> </div> <div class="mx-1 mx-sm-3"> <div class="row"> <?=$table_manager; ?> </div> </div> <div class="pt-3 pb-1"> <div class="row"> <div class="col-md-4 px-1 ps-3 "> <div class="row"> <div class="col-md-8 m-0 p-0 ps-3"> <select name="" id="cf-course-bulk-review-action" class="form-control form-control-sm"> <option value="-1"><?= t('Bulk Action'); ?></option> <option value="del"><?= t('Delete'); ?></option> <option value="re"><?= t('Mark as read'); ?></option> <option value="unre"><?= t('Mark as unread'); ?></option> </select> </div> <div class="col-md-4 m-0 p-0 ps-1"> <button class="btn btn-outline-secondary d-inline btn-sm" id="cf-course-bulk-review-btn"><?= t('Apply'); ?></button> </div> </div> <span class="text ms-1 text-danger cf-course-bulk-show"> <?= t('Please choose one action.'); ?> </span> </div> </div> </div> <div class="pb-2 border mt-2 bg-white br-rounded " id="cf-course-mcomment"> <div class="pb-2"> <div class="row"> <div class="col-sm-12 "> <div class="table-responsive"> <table class="table table-striped text-center"> <thead> <tr> <th width="3%">#</th> <th> <span class="cf-course-custom-check"> <input type="checkbox" id='cf-checkforall' > <label for="cf-checkforall"></label> </span> <?= t('Student Name'); ?> </th> <th><?= t('Course Name'); ?></th> <th><?= t('Rating'); ?></th> <th><?= t('Summary'); ?></th> <th><?= t('Added on'); ?></th> </tr> </thead> <tbody id="reviewkeywordsearchresult"> <!-- keyword search --> <?php $count=1; if(isset($_GET['page_count'])) { $page_count=(int)$_GET['page_count']; $count=($page_count*$max_leads_limit)-$max_leads_limit; ++$count; } if($reviews!=null) { if( count($reviews) > 0 ) { $odd_even=0; $counting=0; foreach( $reviews as $data ){ $counting++; $revid = $data['id']; $is_ad = $data['is_admin']; $review = htmlspecialchars(stripcslashes( trim( stripcslashes( $data['summary'] ),"\r\n") )); $previd = cf_enc($revid, "encrypt" ); $rating = $data['rating']; if($odd_even==0){ $trclass="cf-course-odd-tr"; $notesback="cf-course-odd-notes-b"; $btnTrType="cf-course-odd-tr-btn"; $odd_even=1; } else if($odd_even==1){ $trclass="cf-course-even-tr"; $btnTrType="cf-course-even-tr-btn"; $notesback="cf-course-even-notes-b"; $odd_even=0; } ?> <tr class='cf-course-hover-comemnt <?=$trclass; ?> cf-course-parent-reviews' id='cf-course-comment-row-<?= $revid ?>' > <td width="3%"><?= $counting; ?></td> <td width="15%"> <span class="cf-course-custom-check"> <input type="checkbox" class="cf-bulk-check" value="<?=$revid ?>" id='cf-bulk-check-<?=$previd ?>'> <label class="cf-bulk-check-for" for="cf-bulk-check-<?=$previd ?>"><?php echo $data['name']; ?> <span class="text-info cf-course-read-check text-sm" style="opacity:<?= ( $data['readed']=='1')?'1':'0'; ?>"><i class='fas fa-check'></i></span></label> </span> </td> <td width="15%"><?= $data['title'] ?></td> <td width="20%"> <span class="cf-course-my-rating"></span> <div class="cf-course-my-rating"> <?php $not_check_rating=5-$rating; if($not_check_rating>0) { for($i=1; $i<=$not_check_rating; $i++) { echo '<input class="cf-course-star cf-course-star-not cf-course-star-'.$i.'" id="star-'.$revid.$i.'" type="radio" readonly/> <label class="cf-course-star cf-course-star-not cf-course-star-'.$i.'" for="star-'.$revid.$i.'"></label>'; } } for($i=$not_check_rating+1; $i<=5; $i++) { echo '<input class="cf-course-star cf-course-star-'.$i.'" id="star-'.$revid.$i.'" checked type="radio" readonly/> <label class="cf-course-star cf-course-star-'.$i.'" for="star-'.$revid.$i.'"></label>'; } ?> </div> </td> <td width="33%"> <div class="cf-course-comment-text"> <?php $string_length = strlen($review); if($string_length>200) { $parts = ceil($string_length / 2); // Break string into 2 parts $str_chunks = chunk_split($review, 200); $string_array = array_filter(explode(PHP_EOL, $str_chunks)); ?> <span class="cf-course-comment-first-text"><?=rtrim($string_array[0]," "); ?><span class="cf-course-comment-dot">...</span> </span><a href="javascript:void(0)" class="cf-course-read-more-review"><?= t('Read More')?></a> <span class="cf-course-comment-second-text"> <?php $str =""; foreach($string_array as $string ) { $str .= $string; } echo $str; ?> </span> <?php }else{ echo $review; } ?> </div> <div class="cf-course-actions p-1"> <a href="javascript:void(0)" data-id="<?= $revid ?>" class="text-success cf-course-delete-rev text-sm"><?= t('Delete'); ?></a> <a href="javascript:void(0)" data-id="<?= $revid ?>" data-readed="<?= $data['readed']; ?>" class="text-info cf-course-read-review text-sm"><?= t(( $data['readed']=="1")?"Mark as unread":"Mark as read"); ?></a> </div> </td> <td width="15%" class='text-right'><?php echo date( "d-M-Y h:ia", strtotime($data['added_on'])); ?></td> </tr> <?php } } } ?> <!-- /keyword search --> </tbody> <tfoot> <tr> <td colspan="7" class="total-data" ><center> <?= t('Total Reviews'); ?>: <?=$total_reviews; ?></center></td> </tr> </tfoot> </table> </div> </div> </div> <div class="col-md-12 row nopadding"> <div class="col-sm-6 mt-4"> <?php $next_page_url="index.php?page=cfcourse_manage_comment&page_count"; $page_count=($page_count<2)? 0:$page_count; echo createPager( $total_reviews,$next_page_url,$page_count); ?> </div> </div> </div> </div> </div> </div> <!-- Modal --> <!-- The cf_course_drip_model --> <div id="mycf_course_drip_delete_assign" class="cf_course_drip_model" style="border-radius:5px"> <!-- cf_course_drip_model content --> <div class="cf_course_model_w_anim"> <div class="alert alert-info pb-1 mb-0 "> <span class="cf-course-close-drip cf-course-close-drip-btn">×</span> <h5 id="cf-course-delete-he "><?= t('Please Confirm'); ?></h5> </div> <div class="cf_course_drip_model-body py-3 cf_course_drip_model-del-body"> <?= t('Do you really want to delete reviews?'); ?> </div> <input type="hidden" id="cf-course-delete-review" value=""> <input type="hidden" id="cf-course-review-bulkaction" value=""> <input type="hidden" id="cf-course-review-bulkval" value=""> <div class="modal-footer"> <button type="button" class="btn btn-primary btn-sm cf-course-close-drip-btn"><?= t('Cancel'); ?></button> <button type="button" class="btn btn-danger btn-sm cf-course-remove-review"><?= t('Delete'); ?></button> </div> </div> </div> <!--Model end --> <div id="cf-course-snackbar-admin"><?= t('Review Deleted'); ?>.</div> <input type="hidden" id="cfcourse_ajax" value="<?php echo get_option('install_url')."/index.php?page=ajax"; ?>"> <script> function searchPaymentMethods(search) { var ob=new OnPageSearch(search,"#reviewkeywordsearchresult"); ob.url=window.location.href; ob.search(); } </script>