Viewing file:      v_addCourseOpen.php (17.66 KB)      -rwxr-xr-x Select action/file-type:    (+) |   (+) |   (+) | Code (+) | Session (+) |   (+) | SDB (+) |   (+) |   (+) |   (+) |   (+) |   (+) |
 
<script language="JavaScript1.2"> var flagRow = 0; var oldRow = ''; var flagId = "targetEditRow";
  jQuery(document).ready(function($){     $("#addCo").css("display","none");     switchShow('addCo', 0); });
  function check(mode){     var nm = $("#num_stu").val();     if(nm==0 || nm == ''){         alert("กรุณากรอกจำนวนที่นั่งที่เปิดรับและต้องมากกว่า 0 !!");         return false;     }     if (isNaN(nm)) {         alert("กรุณากรอกเฉพาะตัวเลข !!");         return false;     }     return true; }
  function editRow (obj, coId) {     var target = jQuery(obj).parents("tr:first");     var frm_url = "<?php echo site_url($this->config->item('rg_folder').'preregis/co_update');?>";     var num = parseInt(target.children("td:eq(4)").text());     var num_input = "<input type=\"text\" name=\"coNumSeatOpen\" id=\"num_stu\" value=\""+num+"\" size=\"3\" maxlength=\"3\" />"; //    var co_input = "<input type=\"hidden\" name=\"coId\" id=\"coId\" value=\""+coId+"\" />";     var sub_button = "<input type=\"submit\" name=\"btnSubmit\" id=\"btnSubmit\" onClick=\"return check()\" value=\"บันทึก\" />";     var cc_button = "<input type=\"button\" name=\"btnCancel\" id=\"btnCancel\" value=\"ยกเลิก\" onclick=\"cancelEditRow()\" />";     var space = "  "     var new_html = num_input+space+sub_button+space+cc_button;     jQuery("#myform").attr('action',frm_url);     jQuery("#coId").val(coId);     if(flagRow == 1)         cancelEditRow();     oldRow = target.html();     target.attr("id",flagId);     flagRow =1;     target.children("td:eq(4)").empty().html(new_html).attr("colspan",3).css("text-align","left");     target.children("td:eq(5)").remove();     target.children("td:eq(5)").remove(); }
  function cancelEditRow () {     jQuery("#"+flagId).empty().html(oldRow).attr("id","");     oldRow ='';     flagRow =0; }
  function switchShow (tarId, flag) {     if (flag)     {         jQuery("#"+tarId).show();         jQuery("#gp1").find(":input").attr("disabled","disabled");         jQuery("#gp2").find(":input").attr("disabled","disabled");         jQuery("#gp3").find(":input").attr("disabled","");     }     else     {         jQuery("#"+tarId).hide().find("input:not(:button)").val("");         jQuery("#gp1").find(":input").attr("disabled","");         jQuery("#gp2").find(":input").attr("disabled","disabled");         jQuery("#gp3").find(":input").attr("disabled","disabled");         if(jQuery("tr.addSection").length > 0)         {             jQuery("tr.addSection").remove();         }              } }
  function addSection(obj) {     // หาแถวของปุ่ม     var row = jQuery(obj).parents("tr:first");     // หาค่า crsCode,crsName,crsUnit,coSection      var crsId = jQuery("#crsId").val();     var crsCode = jQuery("#crsCode").val();     var crsName = jQuery("#crsName").val();     var crsUnit = jQuery("#crsUnit").val();     var coSectionClass = jQuery("#coSectionClass").val();     //กำหนดชื่อกล่องข้อความที่จะใส่ในแถว     var input1 = "<input type=\"hidden\" id=\"crsId[]\" name=\"crsId[]\" value=\""+crsId+"\" />";     var input2 = "<input type=\"text\" id=\"coNumSeatOpen[]\" name=\"coNumSeatOpen[]\" size=\"3\" />";     var html ="";          if (crsId == '') {         alert("กรุณากรอกรายวิชา !!");         crsId.focus();         return false;     }     if (coSectionClass == '' || coSectionClass == 0) {          alert("กรุณากรอกกลุ่มที่เปิดเรียนและต้องมากกว่า 0 !!");         coSectionClass.focus();         return false;     }     if (isNaN(coSectionClass)) {         alert("กรุณากรอกเฉพาะตัวเลข !!");         coSectionClass.focus();         return false;     }         //วนรอบเพื่อกำหนดแถวแต่ละแถว         for (i = 0; i < parseInt(coSectionClass); i++) {             html += "<tr class=\"addSection\">";             html += "<td>"+crsCode+input1+"</td>";             html += "<td>"+crsName+"  "+crsUnit+"</td>";             html += "<td>"+coSectionClass+"</td>";             html += "<td>"+(i+1)+"</td>";             html += "<td>"+input2+"*</td>";             html += "<td>-</td>";             html += "<td>-</td>";             html += "<td>-</td>";             html +="</tr>";         }         //แทรกแถวไปก่อนหน้าแถวของปุ่ม         row.before(html);         //ลบแถวของปุ่มออก         row.hide();         jQuery("#gp2").find(":input").attr("disabled",""); //        jQuery("#gp3").find(":input").attr("disabled","disabled");
      return true; }
  function checkFormat2() {     var flg = 0;     var tmp = '';     jQuery(":input[name='coNumSeatOpen\[\]']").each(function() {         var obj = jQuery(this);
          if (obj.val() == '' || obj.val() == 0) {             if (tmp == '') {                 tmp = obj;             }             flg = 1;         }else if(isNaN(obj.val())){             if (tmp == '') {                 tmp = obj;             }             flg = 2;         }     });
      if (flg == 1) {         alert("กรุณากรอกจำนวนที่นั่งที่เปิดรับ !!");         tmp.focus();         return flg;     }else if(flg == 2){         alert("กรุณากรอกเฉพาะตัวเลข !!");         tmp.focus();         return flg;     } else {         jQuery("#myform").submit();     } }
  function IsChecked(rdo, msg) {     //use with radio     f = document.pc;     flg=false;          if(parseInt(rdo.length)) {         for (i=0; i<rdo.length; i++) {             if(rdo[i].checked) {                 if((rdo[i].value!="RC" ) || (rdo[i].value=="RC" && f.prsIdRC.value!=""))                     flg=true;             }         }     }     else {         if(rdo.checked && rdo.value=="RC" && f.prsIdRC.value!="")              flg=true;     }              if(!flg) {         // If there were no selections made display an alert box          alert(msg);         return false;     }     return true; }
  function doValidate(){ //    f = document.pc;
  //    if (!IsChecked(f.responsibility, "กรุณาระบุอาจารย์ผู้รับผิดชอบส่งเกรด")) return 0;     jQuery("#myform").attr('action', 'co_updateRCIS');     jQuery("#myform").submit(); } </script> <?php $row_cur = isset($qu_cur) ? $qu_cur->row() : NULL; $row_sy = isset($qu_sy) ? $qu_sy->row() : NULL; $row_tm = isset($qu_tm) ? $qu_tm->row() : NULL; ?> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">     <tr>         <td>         <?php echo form_open($this->config->item("rg_folder")."preregis/co_insert", array("name" => "myform", "id" => "myform"));?>         <table width="100%" align="center" cellpadding="0" cellspacing="1" border="0">             <tr>                 <td align="center" colspan="2"><font color="<?php echo $font_color_err;?>" size="3" class="h"><b>บันทึกรายวิชาที่เปิดสอน</b></font></td>             </tr>             <tr>                 <td colspan="2"><br /></td>             </tr>             <tr>                 <td colspan="2"><table class="szone">                     <tr bgcolor="<?php echo $tr_color_even;?>">                         <td class="coltd_szone">หลักสูตร</td>                         <td><font size="2"><?php echo getval('curName', $row_cur, 'เรียนรวมหลายหลักสูตร');?></font>                         <input type="hidden" id="curId" name="curId" value="<?php echo getval('curId', $row_cur, 'NULL');?>" /></td>                     </tr>                     <tr bgcolor="<?php echo $tr_color_even;?>">                         <td class="coltd_szone">ชั้นปีที่</td>                         <td><?php echo getval('syCode', $row_sy);?>                         <input type="hidden" id="syId" name="syId" value="<?php echo getval('syId', $row_sy);?>" /></td>                     </tr>                     <tr bgcolor="<?php echo $tr_color_even;?>">                         <td class="coltd_szone">ภาค/ปีการศึกษา</td>                         <td><font size="2"><?php echo getval('tmCode', $row_tm).'/'.$acY;?></font>                         <input type="hidden" id="tmId" name="tmId" value="<?php echo getval('tmId', $row_tm);?>" />                         <input type="hidden" id="acY" name="acY" value="<?php echo $acY;?>" /></td>                     </tr>                 </table></td>             </tr>             <tr>                 <td colspan="2"><br /></td>             </tr>             <tr>                 <td colspan="2"><table class="headCol">                     <tr>                         <th class="amtCol"><font color="<?php echo $font_color_table;?>" size="2">รหัสรายวิชา</font></th>                         <th><font color="<?php echo $font_color_table;?>" size="2">ชื่อรายวิชา/หน่วยกิต</font></th>                         <th class="amtCol"><font color="<?php echo $font_color_table;?>" size="2">จำนวน<br>กลุ่มที่เปิด</font></th>                         <th class="groupCol"><font color="<?php echo $font_color_table;?>" size="2">กลุ่มเรียน</font></th>                         <th class="groupCol"><font color="<?php echo $font_color_table;?>" size="2">จำนวนที่นั่ง<br>ที่เปิดรับ</font></th>                         <th class="editCol"><font color="<?php echo $font_color_table;?>" size="2">แก้ไข</font></th>                         <th class="deleteCol"><font color="<?php echo $font_color_table;?>" size="2">ลบ</font></th>                         <th class="seqCol"><font color="<?php echo $font_color_table;?>" size="2">จัดกลุ่ม<br>(คน)</font></th>                     </tr> <?php                     $i = 0;                     $num_rows = count($rs);                     if ($num_rows) {                         foreach ($rs as $key => $val) {                             $row_co = $rs[$key]['qu_co']->row();
                              echo "<tr onmouseover=\"bgColor='".$tr_color_even."'\" onmouseout=\"bgColor='".$this->config->item("rg_mouseout")."'\">"; ?>                         <td align="center"><font size="2"><span class="hand" onClick="sendPost('hidform', {'coId':<?php echo $row_co->coId;?>}, '<?php echo site_url($this->config->item('rg_folder').'popup/pr_showDetailCo');?>', {})"><?php echo $row_co->crsCode;?></span></font></td>                         <td class="indent"><font size="2"><span class="hand" onClick="sendPost('myform', {'coId':<?php echo $row_co->coId;?>}, 'co_input')"><?php echo explodeSquare($row_co->crsName).' '.$row_co->crsUnit;?></span></font></td>                         <td align="center"><font size="2"><?php echo $row_co->coSectionClass;?></font></td>                         <td align="center"><font size="2"><?php echo $row_co->coSection;?></font></td>                         <td align="center"> <?php                             if (isset($coedit) && $coedit==$rs[$key]['crs']->coId) { ?>                         <input type="text" name="coNumSeatOpen" id="coNumSeatOpen" size="5" maxlength="4" value="<?php echo setValue('coNumSeatOpen',$rs[$key]['crs']);?>" />                         <input type="hidden" id="coId" name="coId" value="<?php echo $rs[$key]['crs']->coId;?>" /> <?php                             } else { ?>                         <font size="2"><?php echo $row_co->coNumSeatOpen;?></font> <?php                             } ?>                         </td>                         <td align="center"> <?php                             if (isset($coedit) && $coedit==$rs[$key]['crs']->coId) { ?>                         <input type="submit" name="edit" id="edit" value="แก้ไข" onClick="return checkCoNumSeatOpen()" /> <?php                             } else { ?>                         <span class="hand" onClick="editRow(this, <?php echo $row_co->coId;?>)"><img src="<?php echo base_url().$this->config->item("rg_edit");?>" align="absmiddle" border="0" /></span> <?php                             } ?>                         </td>                         <td align="center"> <?php                             if ($rs[$key]['maxSec'] == $row_co->coSection) { ?>                         <span onClick="confirmDel2({coId:<?php echo $row_co->coId;?>, curId:<?php echo $row_co->coCurId?>, syId:<?php echo $row_co->coSyId;?>, tmId:<?php echo $row_co->coTmId;?>, acY:<?php echo $row_co->coAcY;?>}, 'm_form1','<?php echo site_url($this->config->item('rg_folder').'preregis/co_delete');?>')" /><img src="<?php echo base_url().$this->config->item('rg_delete');?>" align="absmiddle" border="0" width="16" height="19" class="hand"/></span>                          <?php                             } else {                                 echo '-';                             } ?>                         </td>                         <td align="center"><font size="2"><strong> <?php                             if (is_null($row_co->coCurId)) {                                 echo '-';                             } else { ?>                         <span class="hand" onClick="sendPost('hidform', {'cosCoId':<?php echo $row_co->coId;?>,'curId':<?php echo $row_co->coCurId;?>}, '<?php echo site_url($this->config->item('rg_folder').'popup/cos_input');?>', {})" /><?php echo $rs[$key]['cntStd'];?></span> <?php                             } ?>                         </strong></font></td>                     </tr> <?php                             if (($numStd > $rs[$key]['sumNumSeatOpen']) && ($rs[$key]['maxSec'] == $row_co->coSection)) { ?>                     <tr>                         <td height="22" align="center" colspan="8"><span class="error">** กรุณาตรวจสอบจำนวนนักศึกษาในหลักสูตรกับจำนวนที่นั่งที่เปิดรับในรายวิชา<?php echo $row_co->crsName;?> จำนวนนักศึกษาในหลักสูตร ณ ปัจจุบัน <?php echo $numStd;?> คน **</span></td>                     </tr> <?php                             }
                              $i++;                         }    //end foreach                     }    // end if
                      foreach ($rs_co->result() as $row_co) {                         echo "<tr onmouseover=\"bgColor='".$tr_color_even."'\" onmouseout=\"bgColor='".$this->config->item("rg_mouseout")."'\">"; ?>                         <td height="22" align="center"><?php echo $row_co->crsCode;?></td>                         <td><?php echo explodeSquare($row_co->crsName).' '.$row_co->crsUnit;?>                         <span class="error">(เรียนรวมหลายหลักสูตร)</span></td>                         <td align="center"><?php echo $row_co->coSectionClass;?></td>                         <td align="center"><?php echo $row_co->coSection;?></td>                         <td align="right"><?php echo $row_co->coNumSeatOpen;?></td>                         <td align="center">-</td>                         <td align="center">-</td>                         <td align="center">-</td>                     </tr> <?php                         $i++;                     }
                      if ($i == 0) { ?>                     <tr align="center">                         <td height="22" colspan="8"><span class="error">** ไม่ปรากฎรายการรายวิชาที่เปิดสอนในฐานข้อมูล **</span></td>                     </tr> <?php                     } ?>                     <tr id="addCo">                         <td align="center"><input type="text" id="crsCode" name="crsCode" size="4" class="input1" readonly>                         <span color="error">*</span></td>                         <td><input type="text" id="crsName" name="crsName" size="40" class="input1" readonly>                         <input type="text" id="crsUnit" name="crsUnit" size="5" class="input1" readonly>                         <span class="hand" onClick="sendPost('hidform', {'curId':'<?php echo getval('curId', $row_cur, 'NULL');?>','syId':<?php echo getval('syId', $row_sy);?>,'tmId':<?php echo getval('tmId', $row_tm);?>,'acY':<?php echo $acY;?>}, '<?php echo site_url($this->config->item('rg_folder').'popup/crsInCo_popup');?>', {'width':800})"><img src="<?php echo base_url().$this->config->item('rg_search');?>" width="15" height="19" border="0" align="absmiddle" /></span>                         <input type="hidden" id="crsId" name="crsId" />                         <input type="hidden" id="cdId1" name="cdId1" />                         <input type="hidden" name="cdId2" name="cdId2" />                         <span class="error">*</span></td>                         <td align="center"><input type="text" id="coSectionClass" name="coSectionClass" value="1" size="1" maxlength="3" class="required-int" />                         <span class="error">*</span></td>                         <td colspan="5"><input type="button" id="btnAddSection" name="btnAddSection" value="บันทึกกลุ่มเรียน" onClick="addSection(this)" />                         <input type="button" id="cancel" name="cancel" value="ยกเลิก" onClick="switchShow('addCo', 0)"></td>                     </tr>                 </table></td>             </tr>             <tr>                 <td>                     <span id="gp1">                     <input type="button" id="btnAddCo" name="btnAddCo" value="เพิ่มรายวิชาที่เปิดสอน" onClick="switchShow('addCo', 1)" />                     </span>                     <span id="gp2">                     <input type="button" name="btnAdd" name="btnAdd" value="บันทึกรายวิชาที่เปิดสอน" onClick="return checkFormat2()" />                     <input type="reset" name="btnClear" value="เคลียร์ข้อมูล" />                     <span id="gp3">                     <input type="button" id="cancel" name="btnCancel" value="ยกเลิก" onClick="switchShow('addCo', 0)" />                     </span>                     </span>                 </td>                 <td align="right"><font size="2">รวม <?php echo $num_rows;?> รายการ</font></td>             </tr>         </table><br /> <?php         $row_co = isset($qu_co) ? $qu_co->row() : NULL;         $row_prs = isset($qu_prs) ? $qu_prs->row() : NULL; ?>         <table class="headCol">             <tr>                 <th class="teacherCol">อาจารย์ผู้รับผิดชอบส่งเกรด</th>                 <th><span color="fontT"><strong>ชื่ออาจารย์ผู้สอนทั้งหมด</strong></span></th>             </tr>             <tr>                 <td colspan="2" height="22" class="indent"><b>รายวิชา</b>                 <?php echo isset($qu_co) ? getval('crsCode', $row_co).' '.getval('crsName', $row_co).' '.getval('crsUnit', $row_co) : '-';?>                 <b>กลุ่มเรียน</b>                 <?php echo isset($qu_co) ? getval('coSection', $row_co) : '-';?></font></td>             </tr> <?php             $i = 0;             if (isset($rs_tt)) {                 foreach ($rs_tt->result() as $row_tt) {                     echo "<tr onmouseover=\"bgColor='".$tr_color_even."'\" onmouseout=\"bgColor='".$this->config->item("rg_mouseout")."'\">"; ?>                 <td align="center"><input type="radio" id="responsibility" name="responsibility" value="<?php echo $row_tt->ttPrsId;?>" <?php echo ($row_tt->ttPrsId == getval('coPrsId', $row_co)) ? 'checked' : '';?> /></td>                 <td><?php echo $row_tt->prefixName.$row_tt->fName.' '.$row_tt->lName;?></td>             </tr> <?php                     $i++;                 }             }
              if (isset($qu_co)) { ?>             <tr>                 <td align="center"><input type="radio" id="responsibility" name="responsibility" value="RC" <?php echo ((getval('coPrsId', $row_co) == '') || $sumHr) ? '' : 'checked';?> /></td>                 <td> <?php                 echo form_dropdown('prsIdRC', $rs_prs, getval('coPrsId', $row_co)); ?>                 </td>             </tr> <?php             } else { ?>             <tr>                 <td colspan="2" height="22" align="center"><span class="error">** ไม่ปรากฏรายชื่ออาจารย์ผู้สอน **</span></td>             </tr> <?php             } ?>             <tr>                 <td colspan="2"><input type="button" id="btnResponsibility" name="btnResponsibility" value="แก้ไขอาจารย์ผู้รับผิดชอบส่งเกรด" onClick="return doValidate()" <?php echo isset($qu_co) ? '' : 'disabled';?> />                 <input type="hidden" id="coId" name="coId" value="<?php echo getval('coId', $row_co);?>" /></td>             </tr>         </table>         <?php echo form_close();?></td>     </tr> </table>
  |