'indexs', 'callback' => 'front_manage', 'callback arguments' => array('show'), 'access' => TRUE); $items[] = array( 'path' => 'indexs', 'access' => TRUE, 'callback' => 'front_manage', 'callback arguments' => array('show'), 'type' => MENU_CALLBACK, ); $items[] = array( 'path' => 'indexs/top5', 'callback' => 'front_manage', 'callback arguments' => array('top5'), 'type' => MENU_CALLBACK, 'access' => TRUE,); return $items; } function front_manage($type){ $output .= front_page('welcome'); //$output = theme('dmhtheme',front_page('welcome')); $output .= front_page('top5'); $output .= front_page('news'); $output .= front_page('item'); return $output; } function front_page($type){ switch($type){ case 'welcome' : $output = theme('dmhtheme','Welcome','สถาบันกัลยาณ์ราชนครินทร์ ยินดีต้อนรับเข้าสู่คลังความรู้งานวิจัยด้านนิติจิตเวช และวิกฤตสุขภาพจิต'); break; case 'item' : $rows = array(); $rows[] = 'คู่มือการใช้ แบบประเมินความเสี่ยงต่อการเกิดพฤติกรรมรุนแรง'; $output = theme('dmhtheme','เอกสารแนะนำ','คู่มือการใช้ แบบประเมินความเสี่ยงต่อการเกิดพฤติกรรมรุนแรง'); break; case 'top5' : $sql = "SELECT i.itemid,i.title,i.downloadAmount FROM dmh_item i LEFT JOIN dmh_department d ON i.author_departmentid = d.departmentId LEFT JOIN dmh_download_logs c ON(i.uid = c.uid ) WHERE itemstatus = 3 AND i.downloadAmount >0 GROUP BY title ORDER BY downloadAmount DESC LIMIT 0 , 5"; $output = show_front($sql,$type); break; case 'news' : $sql = "SELECT i.itemid,i.title , approveDate FROM dmh_item i LEFT JOIN dmh_department d ON i.author_departmentid = d.departmentId WHERE itemstatus = 3 ORDER BY approveDate DESC LIMIT 0 , 5"; $output = show_front($sql,$type); break; } return $output; } function show_front($sql,$type){ $path = drupal_get_path('module', 'frontdmh'); drupal_add_css($path.'/frontdmh.css'); $destination = drupal_get_destination(); $result = db_query($sql); $rows = array(); switch($type){ case 'top5' : while($cols = db_fetch_object($result)){ $rows[] = ' '; } $output .= theme('item_list',$rows,'งานวิจัย 5 อันดับที่มีผู้ดาวน์โหลดมากที่สุด'); $img = $path.'/images/gp01.gif'; break; case 'news' : while($cols = db_fetch_object($result)){ $rows[] = ''; } $output .= theme('item_list',$rows,'งานวิจัยชิ้นใหม่' ); $img =$path.'/images/techno01.gif'; break; } //print_r($rows); return theme('dmhtheme','',$output,$img ) ; }**/ function theme_dmhtheme(&$title,&$content, $image = NULL){ $img = ($image)?'':''; if(!empty($title))$tmptitle = '

'.$title.'

'; else $tmptitle='
'; $output = '
'. $tmptitle .' '.$img.$content .'


'; return $output; } ?> 'vote/', 'callback' => 'votedmh_admin', 'callback arguments' => array('vote'), 'access' => TRUE, 'type' => MENU_CALLBACK); $items[] = array( 'path' => 'vote/show', 'callback' => 'showVote', 'access' => TRUE, 'type' => MENU_CALLBACK); return $items; } function votedmh_perm(){ return array('dmhvote'); } function votedmh_admin($type,$id){ switch($type){ case 'vote' : $output = votedmh_vote_form($id); //$output .= showVote_form(); break; } return $output; } function votedmh_vote2_form(){ $status_type = get_occupation(); $form['set'] = array( '#type'=> 'fieldset', '#title'=> 'แบบประเมิน', '#collapsible' => TRUE); $form['set']['status_type'] = array( '#title' => t('สถานะผู้ประเมิน'), '#type' => 'select', '#options' => $status_type, '#required' => TRUE, '#weight' => -13); $form['set']['interest'] = array( '#type' => 'radios', '#title' => t('ความน่าสนใจของเนื้อหา'), '#options' => _get_options('level'), '#weight' =>0, '#default_value' => 0); $form['set']['comfort'] = array( '#type' => 'radios', '#title' => t('ความสะดวกในการเข้าถึง'), '#options' => _get_options('level'), '#weight' =>0, '#default_value' => 0); $form['set']['votes'] = array( '#type' => 'radios', '#weight' => -10, '#title' => 'นำไปใช้ทำประโชน์เพื่อ', '#options' => _get_options('reseach_vote'), '#default_value' => 1); $_SESSION['token_dmh'] = md5(uniqid(mt_rand(), true)); $form['token_dmh'] = array( '#type' =>'hidden', '#value' => $_SESSION['token_dmh']); $form['iid'] = array( '#type' =>'value', '#value' => arg(1)); $form['submit'] = array( '#value' => t('Submit'), '#type' => 'submit'); return $form; } function votedmh_vote2_form_validate($form_id, &$form_values){ if($form_values['status_type'] == 0){ unset($_SESSION['token_dmh']); form_set_error('status_type', 'กรุณาเลือกสถานะผู้ประเมิน'); } } function votedmh_vote2_form_submit($form_id, &$form_values){ $chooose = 'choose'.$form_values['votes']; $interest = 'interest'.($form_values['interest']+1); $comfort = 'comfort'.($form_values['comfort']+1); $sql = "INSERT INTO `dmh_vote` ( `itemid` , `occupationId` , `$chooose` , `$interest` , `$comfort` , `createDate` ) VALUES ('%d', '%d', '%d', '%d', '%d', '%d')"; db_query($sql, $form_values['iid'], $form_values['status_type'], 1, 1, 1, time()); drupal_set_message('ส่งแบบประเมินเรียบร้อย'); } function votedmh_vote_form($id){ $form['set'] = array( '#type'=> 'fieldset', '#title'=> 'vote นำไปใช้ทำประโชน์เพื่อ', '#collapsible' => TRUE); $val = ''; if(user_access('dmhvote')){ $val = drupal_get_form('add_vote_page',$id); } $val .= showVote_form(); $form['set']['in'] = array( '#type'=> 'item', '#value' =>$val); return drupal_render($form); } function add_vote_page(&$data){ global $user; $forms[] = array(); $sql = "SELECT COUNT(uid) AS log FROM dmh_vote_log WHERE uid = $user->uid AND itemid = $data"; $check_vote = db_fetch_object(db_query($sql)); if($check_vote->log!=0){ return $forms; } $options = _get_options('reseach_vote'); $forms['fieldset'] = array( '#title' => t('การนำไปใช้ประโยชน์'), '#type' => 'item', '#weight' => -20); $forms['fieldset']['votes'] = array( '#type' => 'radios', '#weight' => -10, '#options' => $options, '#default_value'=>3) ; $forms['did'] = array( '#type' => 'value', '#value' => $data); $forms['fieldset']['buttons'] = array( '#type' => 'item' ); $forms['fieldset']['buttons']['submit'] = array( '#value' => t('Submit'), '#type' => 'submit'); return $forms; } function add_vote_page_submit($form_id, &$form_values){ $id = db_fetch_object(db_query("SELECT itemid FROM dmh_vote WHERE itemid = %d", $form_values['did'])); if(!$id){ db_query("INSERT INTO {dmh_vote}(itemid) VALUES(%d)", $form_values['did']); } $name = 'choose'.$form_values['votes']; $sql = "UPDATE dmh_vote SET "; $sql .= $name ." = (IFNULL($name, 0)+1) WHERE itemid = ".$form_values['did']; db_query($sql); global $user; db_query("INSERT INTO dmh_vote_log (uid,itemid,".$name.",voteTime) VALUES (%d,%d,1,%d)",$user->uid,$form_values[did],time()); $massage = 'Vote Item: '.$form_values['did']; drupal_set_message($massage); watchdog('dmh', $massage, WATCHDOG_NOTICE); } function showVote_form(){ $id = arg(1); $data = db_fetch_array(db_query("SELECT choose1,choose2,choose3 FROM dmh_vote WHERE itemid = %d ",$id)); if(!empty($data)) { $research_vote = _get_options('reseach_vote'); $output = draw_chart($data,$research_vote); } else { $output = '
'; $output .= '
ไม่เคยมีการโหวต
'; } return $output; } function draw_chart(&$data,&$research_vote){ $count = array_sum($data); $output = '
'; $output .= '
'; $x=1; foreach($research_vote as $tmp_r){ $tmp= 'choose'.$x++; $num = $data[$tmp]; $percent = round((100*$num)/$count); $output .= '
' . $tmp_r . ' จำนวน ' . $num . ' ครั้ง คิดเป็น ' . $percent . '%
'; $output .= '
'; $output .= '
'; } $output .= '
'; return $output; } ?> บัญชีผู้ใช้ | งานวิจัย - สถาบันกัลยาณ์ราชนครินทร์ กรมสุขภาพจิต

บัญชีผู้ใช้

Enter your งานวิจัย - สถาบันกัลยาณ์ราชนครินทร์ กรมสุขภาพจิต username.
กรอกรหัสผ่านของบัญชีผู้ใช้นี้