Server IP : 119.59.102.212 / Your IP : 18.117.197.188 Web Server : Apache/2 System : Linux narin 2.6.32-042stab142.1 #1 SMP Tue Jan 28 23:44:17 MSK 2020 x86_64 User : yangkam ( 1022) PHP Version : 5.6.40 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/yangkam/domains/yangkam.go.th/public_html/coremain/module/question/ |
Upload File : |
<?php import_request_variables('pG', 'p_'); $sel_q = "select * from cms_question where id_sub = '$p_id_sub'"; $que_q = mysql_query($sel_q); $obj_q = mysql_fetch_assoc($que_q); $qid = $obj_q['id_question']; $navig['question'] = $data_name_menu_sub['name']; $navig['question_edit'] = 'แก้ไขแบบสำรวจ'; navigator($navig); echo"<br>"; bar_header('แก้ไขแบบสำรวจ'); // Bar_Header fieldset_top($obj_q['topic']); # เพิ่มหัวข้อ if($p_title_new != ''){ $sel_oth = "select * from cms_question_title where title_parent = '$p_parent' and title_other = 1"; $que_oth = mysql_query($sel_oth); $num_oth = mysql_num_rows($que_oth); if($num_oth == 1){ $del_oth = "delete from cms_question_title where title_parent = '$p_parent' and title_other = '1'"; mysql_query($del_oth); } $_data = select_max_query0('title_id', 'cms_question_title'); $data_id = $_data[0] == '' ? 1 : $_data[0]; $ins_new = "insert into cms_question_title values ('$data_id', '$p_title_new', '$p_parent', '$p_order_new', '$qid', '0', '0', '1', '1')"; mysql_query($ins_new); if($num_oth == 1){ $oth_id = $data_id + 1; $oth_order = $p_order_new + 1; $ins_other = "insert into cms_question_title values ('$oth_id', 'อื่นๆ', '$p_parent', '$oth_order', '$qid', '0', '1', '1', '1')"; mysql_query($ins_other); } refresh_data('index.php?mod=question_edit&path=question&id_sub='.$p_id_sub.'&parent='.$p_parent, 1); } # แก้ไขหัวข้อ if($p_title != ''){ $upd_title = "update cms_question_title set title_name = '$p_title' where title_id = '$p_title_id'"; mysql_query($upd_title); } # ลบหัวข้อ if($p_title_del != ''){ $get_order = "select title_order from cms_question_title where title_id = '$p_title_id'"; $que_order = mysql_query($get_order); $obj_order = mysql_fetch_assoc($que_order); $curr_order = $obj_order['title_order']; $del_title = "delete from cms_question_title where title_id = '$p_title_id'"; mysql_query($del_title); $sel_curr = "select * from cms_question_title where title_parent = '$p_parent' and title_order >= '$curr_order'"; $que_curr = mysql_query($sel_curr); while($obj_curr = mysql_fetch_assoc($que_curr)){ mysql_query("update cms_question_title set title_order = (title_order - 1) where title_id = '$obj_curr[title_id]'"); } refresh_data('index.php?mod=question_edit&path=question&id_sub='.$p_id_sub.'&parent='.$p_parent, 1); } # สถานะรายการที่จำเป็นต้องตรวจสอบก่อนส่งแบบสอบถาม if($p_validate != ''){ $upd_validate = "update cms_question_title set title_validate = '$p_validate' where title_id = '$p_title_id'"; mysql_query($upd_validate); refresh_data('index.php?mod=question_edit&path=question&id_sub='.$p_id_sub.'&parent='.$p_parent, 1); } # มี/ไม่มีรายการอื่นๆ if($p_add_other != ''){ if($p_add_other == '1'){ $_oth = select_max_query0('title_id', 'cms_question_title'); $oth_id = $_oth[0] == '' ? 1 : $_oth[0]; $_oth_order = select_max_query('title_order', 'cms_question_title', 'title_parent', $p_parent); $oth_order = $_oth_order[0] == '' ? 1 : $_oth_order[0]; $ins_other = "insert into cms_question_title values ('$oth_id', 'อื่นๆ', '$p_parent', '$oth_order', '$qid', '0', '1', '1', '1')"; mysql_query($ins_other); }else{ $del_oth = "delete from cms_question_title where title_parent = '$p_parent' and title_other = '1'"; mysql_query($del_oth); } refresh_data('index.php?mod=question_edit&path=question&id_sub='.$p_id_sub.'&parent='.$p_parent, 1); } # เพิ่มตัวเลือก if($p_choice_new != ''){ $_choice = select_max_query0('choice_id', 'cms_question_choice'); $choice_id = $_choice[0] == '' ? 1 : $_choice[0]; $ins_new = "insert into cms_question_choice values ('$choice_id', '$p_choice_new', '$p_order_new', '$p_parent', '$qid', '1')"; mysql_query($ins_new); refresh_data('index.php?mod=question_edit&path=question&id_sub='.$p_id_sub.'&parent='.$p_parent, 1); } # แก้ไขตัวเลือก if($p_choice != ''){ $upd_choice = "update cms_question_choice set choice_name = '$p_choice' where choice_id = '$p_choice_id'"; mysql_query($upd_choice); } # ลบตัวเลือก if($p_choice_del != ''){ $get_order = "select choice_order from cms_question_choice where choice_id = '$p_choice_id'"; $que_order = mysql_query($get_order); $obj_order = mysql_fetch_assoc($que_order); $curr_order = $obj_order['choice_order']; $del_choice = "delete from cms_question_choice where choice_id = '$p_choice_id'"; mysql_query($del_choice); $sel_curr = "select * from cms_question_choice where title_id = '$p_parent' and choice_order >= '$curr_order'"; $que_curr = mysql_query($sel_curr); while($obj_curr = mysql_fetch_assoc($que_curr)){ mysql_query("update cms_question_choice set choice_order = (choice_order - 1) where choice_id = '$obj_curr[choice_id]'"); } refresh_data('index.php?mod=question_edit&path=question&id_sub='.$p_id_sub.'&parent='.$p_parent, 1); } # เรียงลำดับ if($p_id_order != ''){ if($p_ch_id != ''){ // เรียงตัวเลือก $get_curr = "select choice_order from cms_question_choice where choice_id = '$p_ch_id'"; $que_curr = mysql_query($get_curr); $obj_curr = mysql_fetch_assoc($que_curr); $curr_order = $obj_curr['choice_order']; $new_order = $p_id_order == '1' ? $curr_order - 1 : $curr_order + 1; $upd_other = "update cms_question_choice set choice_order = '$curr_order' where title_id = '$p_parent' and choice_order = '$new_order'"; mysql_query($upd_other); $upd_order_new = "update cms_question_choice set choice_order = '$new_order' where choice_id = '$p_ch_id'"; mysql_query($upd_order_new); refresh_data('index.php?mod=question_edit&path=question&id_sub='.$p_id_sub.'&parent='.$p_parent, 1); }else if($p_title_id != ''){ // เรียงหัวข้อ $get_curr = "select title_order from cms_question_title where title_id = '$p_title_id'"; $que_curr = mysql_query($get_curr); $obj_curr = mysql_fetch_assoc($que_curr); $curr_order = $obj_curr['title_order']; $new_order = $p_id_order == '1' ? $curr_order - 1 : $curr_order + 1; $upd_other = "update cms_question_title set title_order = '$curr_order' where title_parent = '$p_parent' and title_order = '$new_order'"; mysql_query($upd_other); $upd_order_new = "update cms_question_title set title_order = '$new_order' where title_id = '$p_title_id'"; mysql_query($upd_order_new); refresh_data('index.php?mod=question_edit&path=question&id_sub='.$p_id_sub.'&parent='.$p_parent, 1); } } # question_title $sel_title = "select * from cms_question_title where question_id = '$qid' and title_id = '$p_parent' and title_parent = '0' order by title_order"; $que_title = mysql_query($sel_title); $array_title = mysql_fetch_assoc($que_title); if($array_title['type_id'] == '2'){ # question_choice $array_choice = array(); $sel_choice = "select * from cms_question_choice where question_id = '$qid' and title_id = '$p_parent' order by choice_order"; $que_choice = mysql_query($sel_choice); while($_choice = mysql_fetch_assoc($que_choice)){ $array_choice[$_choice['choice_order']] = $_choice; } } # data_title $array_data = array(); $checked_other = ''; $sel_data = "select * from cms_question_title where question_id = '$qid' and title_parent = '$p_parent' order by title_order"; $que_data = mysql_query($sel_data); while($obj = mysql_fetch_assoc($que_data)){ if($obj['title_other'] == '1'){ $checked_other = 'checked="checked"'; }else{ $array_data[$obj['title_order']] = $obj; } } //debuga($array_data); ?> <table width="97%" border="0" cellpadding="0" cellspacing="0" align="center"> <tr> <td> <table width="100%" border="1" cellpadding="3" cellspacing="0" style="border-collapse: collapse;" id="tb_title"> <tr bgcolor="#f0e8d0"> <td width="100%"> <?php if($p_title_edit == 'edit' && $p_title_id == ''){ ?> <form NAME='fm_title_edit' METHOD=POST ACTION='index.php?mod=question_edit&path=question&id_sub=<?= $p_id_sub ?>&parent=<?= $p_parent ?>' onSubmit='return check_title()' style="margin: 0;"> <input type="hidden" name="title_id" value="<?= $p_parent ?>" /> <input type="text" name="title" value="<?= $array_title['title_name'] ?>" size="40" /> <a href="javascript:void(0);" class="title_update"><img src='coremain/images/save.png' title='บันทึกข้อมูล' border='0'></a> <a href="index.php?mod=question_edit&path=question&id_sub=<?= $p_id_sub ?>&parent=<?= $p_parent ?>" class="title_update"><img src='coremain/images/ban.png' title='ยกเลิก' border='0'></a> </form> <?php }else{ ?> <b><?= $array_title['title_name'] ?></b> <a href="index.php?mod=question_edit&path=question&id_sub=<?= $p_id_sub ?>&parent=<?= $p_parent ?>&title_edit=edit"><img src='coremain/images/edit.gif' title='แก้ไขข้อมูล' border='0'></a> <?php } ?> </td> </tr> <?php if(isset($array_data)){ foreach($array_data as $data_order => $data){ $num_data = count($array_data); ?> <tr class="row_data"> <td> <?php if($p_title_edit == 'edit' && $p_title_id == $data['title_id']){ ?> <form NAME='fm_title_edit' METHOD=POST ACTION='index.php?mod=question_edit&path=question&id_sub=<?= $p_id_sub ?>&parent=<?= $p_parent ?>' onSubmit='return check_title()' style="margin: 0;"> <input type="hidden" name="title_id" value="<?= $data['title_id'] ?>" /> <?php if($array_title['type_id'] == '6'){ ?> <?php text_editor('200', '260', 'คำอธิบาย', 1, $data['title_name'], 'title'); ?> <tr> <td align="right"> <a href="javascript:void(0);" class="title_update"><img src='coremain/images/save.png' title='บันทึกข้อมูล' border='0'></a> <a href="index.php?mod=question_edit&path=question&id_sub=<?= $p_id_sub ?>&parent=<?= $p_parent ?>" class="title_update"><img src='coremain/images/ban.png' title='ยกเลิก' border='0'></a> </td> </tr> <?php }else{ ?> <?= $data_order ?>)<input type="text" name="title" value="<?= $data['title_name'] ?>" size="40" /> <a href="javascript:void(0);" class="title_update"><img src='coremain/images/save.png' title='บันทึกข้อมูล' border='0'></a> <a href="index.php?mod=question_edit&path=question&id_sub=<?= $p_id_sub ?>&parent=<?= $p_parent ?>" class="title_update"><img src='coremain/images/ban.png' title='ยกเลิก' border='0'></a> <?php } ?> </form> <?php }else{ ?> <?php if($array_title['type_id'] != '6'){ ?><?= $data_order ?>) <?php } ?><?= $data['title_name'] ?> <?php if($data['title_other'] == '0'){ ?> <div style="float: right;"> <?php if($array_title['type_id'] == '1'){ ?> <?php if($data['title_validate'] == '1'){ ?> <a href='index.php?mod=question_edit&path=question&id_sub=<?= $p_id_sub ?>&parent=<?= $p_parent ?>&title_id=<?= $data['title_id'] ?>&validate=0'><img src='coremain/images/true.gif' border='0' title='จำเป็นต้องกรอก'></a> <?php }else{ ?> <a href='index.php?mod=question_edit&path=question&id_sub=<?= $p_id_sub ?>&parent=<?= $p_parent ?>&title_id=<?= $data['title_id'] ?>&validate=1'><img src='coremain/images/false.gif' border='0' title='กรอกหรือไม่ก็ได้'></a> <?php } ?> <?php } ?> <?php if($data['title_order'] > 1){ # Up ?> <a href='index.php?mod=question_edit&path=question&id_sub=<?= $p_id_sub ?>&parent=<?= $p_parent ?>&title_id=<?= $data['title_id'] ?>&id_order=1'><img src='coremain/images/up.gif' border='0' title='เลื่อนขึ้น'></a> <?php }else{ ?> <?php } ?> <?php if($data['title_order'] < $num_data){# Down ?> <a href='index.php?mod=question_edit&path=question&id_sub=<?= $p_id_sub ?>&parent=<?= $p_parent ?>&title_id=<?= $data['title_id'] ?>&id_order=2'><img src='coremain/images/down.gif' border='0' title='เลื่อนลง'></a> <?php }else { ?> <?php } ?> <a href="index.php?mod=question_edit&path=question&id_sub=<?= $p_id_sub ?>&parent=<?= $p_parent ?>&title_edit=edit&title_id=<?= $data['title_id'] ?>"><img src='coremain/images/edit.gif' title='แก้ไขข้อมูล' border='0'></a> <a href="javascript:void(0)" class="del_data" id="<?= $data['title_id'] ?>"><img src='coremain/images/del1.gif' title='ลบข้อมูล' border='0'></a> </div> <?php } ?> <?php } ?> </td> </tr> <?php }} ?> </table> <?php if($array_title['type_id'] != '5' && $array_title['type_id'] != '6'){ ?> <table width="100%"> <tr> <td align="left"> <button type="button" id="add_data" class="ui-button ui-corner-all ui-state-focus" style="padding: 2px;"> <img src='coremain/images/bullet2.gif'> เพิ่มหัวข้อ</button> <?php if($array_title['type_id'] == '3' || $array_title['type_id'] == '4'){ ?> <input type="checkbox" name="add_other" <?= $checked_other ?> /> มีหัวข้ออื่นๆ <?php } ?> </td> </tr> </table> <?php } ?> </td> </tr> <?php if($array_title['type_id'] == '2'){ $num_choice = count($array_choice); ?> <tr> <td align="center"> <br/> <table width="80%" border="1" cellpadding="3" cellspacing="0" style="border-collapse: collapse;" id="tb_choice"> <tr bgcolor="#f0e8d0"><th align="left">แก้ไขตัวเลือก</th></tr> <?php foreach($array_choice as $order_choice => $choice){ ?> <tr class="row_choice"> <?php if($p_choice_edit == 'edit' && $p_ch_id == $choice['choice_id']){ ?> <td> <form NAME='fm_choice_edit' METHOD=POST ACTION='index.php?mod=question_edit&path=question&id_sub=<?= $p_id_sub ?>&parent=<?= $p_parent ?>' onSubmit='return check_choice()' style="margin: 0;"> <input type="hidden" name="choice_id" value="<?= $choice['choice_id'] ?>" /> ตัวเลือก <?= $choice['choice_order'] ?> : <input type="text" name="choice" value="<?= $choice['choice_name'] ?>" size="20" /> <a href="javascript:void(0);" class="choice_update"><img src='coremain/images/save.png' title='บันทึกข้อมูล' border='0'></a> <a href="index.php?mod=question_edit&path=question&id_sub=<?= $p_id_sub ?>&parent=<?= $p_parent ?>" class="title_update"><img src='coremain/images/ban.png' title='ยกเลิก' border='0'></a> </form> </td> <?php }else{ ?> <td> ตัวเลือก <?= $choice['choice_order'] ?> : <?= $choice['choice_name'] ?> <div style="float: right;"> <?php if($choice['choice_order'] > 1){ # Up ?> <a href='index.php?mod=question_edit&path=question&id_sub=<?= $p_id_sub ?>&parent=<?= $p_parent ?>&ch_id=<?= $choice['choice_id'] ?>&id_order=1'><img src='coremain/images/up.gif' border='0' title='เลื่อนขึ้น'></a> <?php }else{ ?> <?php } ?> <?php if($choice['choice_order'] < $num_choice){# Down ?> <a href='index.php?mod=question_edit&path=question&id_sub=<?= $p_id_sub ?>&parent=<?= $p_parent ?>&ch_id=<?= $choice['choice_id'] ?>&id_order=2'><img src='coremain/images/down.gif' border='0' title='เลื่อนลง'></a> <?php }else { ?> <?php } ?> <a href="index.php?mod=question_edit&path=question&id_sub=<?= $p_id_sub ?>&parent=<?= $p_parent ?>&choice_edit=edit&ch_id=<?= $choice['choice_id'] ?>"><img src='coremain/images/edit.gif' title='แก้ไขข้อมูล' border='0'></a> <a href="javascript:void(0)" class="del_choice" id="<?= $choice['choice_id'] ?>"><img src='coremain/images/del1.gif' title='ลบข้อมูล' border='0'></a> </div> </td> <?php } ?> </tr> <?php } ?> </table> <table width="80%"> <tr> <td align="left"> <button type="button" id="add_choice" class="ui-button ui-corner-all ui-state-focus" style="padding: 2px;"> <img src='coremain/images/bullet2.gif'> เพิ่มตัวเลือก</button> </td> </tr> </table> </td> </tr> <?php } ?> </table> <style> input{ background: #FFFFEE; } </style> <script language="javascript"> $('.topic_update').on('click', function(){ $('form[name="fm_topic_edit"]').submit(); }); function check_topic() { if(document.fm_question_edit.topic.value=="") { alert("กรุณากรอกชื่อแบบสำรวจ !") ; document.fm_question_edit.topic.focus() ; return false ; }else return true ; } $('.title_update').on('click', function(){ $('form[name="fm_title_edit"]').submit(); }); function check_title(){ if($('#fm_title_edit input[name="title"]').val()=='') { alert("กรุณากรอกหัวข้อ !") ; document.fm_title_edit.topic.focus() ; return false ; }else return true ; } $('.choice_update').on('click', function(){ $('form[name="fm_choice_edit"]').submit(); }); function check_choice(){ if(document.fm_choice_edit.choice.value == ''){ alert('กรุณากรอกตัวเลือก !'); document.fm_choice_edit.choice.focus(); return false; }else{ return true; } } function check_title_new(){ if(document.fm_title_add.title_new.value == ''){ alert('กรุณากรอกหัวข้อ !'); document.fm_title_add.title_new.focus(); return false; }else{ return true; } } $('#add_data').on('click', function(){ $('#add_data').css('display', 'none'); var row = $('#tb_title').find('tr.row_data').length; var n = Number(row) + 1; var tr = '<tr class="row_data"><td><form name="fm_title_add" method="post" action="index.php?mod=question_edit&path=question&id_sub=<?= $p_id_sub ?>&parent=<?= $p_parent ?>" onSubmit="return check_title_new()" style="margin: 0"><input type="hidden" name="title_other" /><input type="hidden" name="order_new" value="'+ n +'" /> '+ n +') <input type="text" name="title_new" size="40" /> <a href="javascript:void(0);" class="title_insert"><img src="coremain/images/save.png" title="บันทึกข้อมูล" border="0" /></a> <a href="index.php?mod=question_edit&path=question&id_sub=<?= $p_id_sub ?>&parent=<?= $p_parent ?>" class="title_update"><img src="coremain/images/ban.png" title="ยกเลิก" border="0"></a></form></td></tr>'; $('#tb_title').append(tr); $('input[name="title_new"]').focus(); $('.title_insert').on('click', function(){ if($('input[name="add_other"]').is(':checked')){ document.fm_title_add.title_other.value = '1'; }else{ document.fm_title_add.title_other.value = '0'; } $('form[name="fm_title_add"]').submit(); }); }); $('input[name="add_other"]').on('click', function(){ if($(this).is(':checked')){ window.location.href = "index.php?mod=question_edit&path=question&id_sub=<?= $p_id_sub ?>&parent=<?= $p_parent ?>&add_other=1"; }else{ window.location.href = "index.php?mod=question_edit&path=question&id_sub=<?= $p_id_sub ?>&parent=<?= $p_parent ?>&add_other=0"; } }); $('.del_data').on('click', function(){ if(confirm("คุณต้องการลบหัวข้อนี้ ?")){ var id = $(this).attr('id'); window.location.href = "index.php?mod=question_edit&path=question&id_sub=<?= $p_id_sub ?>&parent=<?= $p_parent ?>&title_del=delete&title_id="+id; } }); $('.del_choice').on('click', function(){ if(confirm("คุณต้องการลบตัวเลือกนี้ ?")){ var id = $(this).attr('id'); window.location.href = "index.php?mod=question_edit&path=question&id_sub=<?= $p_id_sub ?>&parent=<?= $p_parent ?>&choice_del=delete&choice_id="+id; } }); function check_choice_new(){ if(document.fm_choice_add.choice_new.value == ''){ alert('กรุณากรอกตัวเลือก !'); document.fm_choice_add.choice_new.focus(); return false; }else{ return true; } } $('#add_choice').on('click', function(){ $('#add_choice').css('display', 'none'); var row = $('#tb_choice').find('tr.row_choice').length; var n = Number(row) + 1; var tr = '<tr class="row_choice"><td><form name="fm_choice_add" method="post" action="index.php?mod=question_edit&path=question&id_sub=<?= $p_id_sub ?>&parent=<?= $p_parent ?>" onSubmit="return check_choice_new()" style="margin: 0"><input type="hidden" name="order_new" value="'+ n +'" /> ตัวเลือก '+ n +' : <input type="text" name="choice_new" size="40" /> <a href="javascript:void(0);" class="choice_insert"><img src="coremain/images/save.png" title="บันทึกข้อมูล" border="0" /></a> <a href="index.php?mod=question_edit&path=question&id_sub=<?= $p_id_sub ?>&parent=<?= $p_parent ?>" class="title_update"><img src="coremain/images/ban.png" title="ยกเลิก" border="0"></a></form></td></tr>'; $('#tb_choice').append(tr); $('input[name="choice_new"]').focus(); $('.choice_insert').on('click', function(){ $('form[name="fm_choice_add"]').submit(); }); }); </script>