<?php
/**
 * *** PLEASE ENTER A DESCRIPTION HERE ***
 *
 * @author $Author: samarth $
 * @version  $Id: listunit_view.php,v 1.17 2010/02/22 10:04:21 samarth Exp $
 * @copyright Copyright (c) 2009, Tiller Software Co., Ltd.
 */
 // For Integrated Unit, Unified Unit

?>
<center>
<form name="coursesel_form" method="post"  >
<input type="hidden" id="removeflag" name="removeflag" value=''   />
<input type="hidden" id="courseid"   name="courseid"   value='<?php @osa_echo($courseid); ?>'   />
<input type="hidden" id="courseids"  name="courseids"  value='<?php @osa_echo($courseids); ?>'   />
<input type="hidden" id="unitid"     name="unitid"     value='<?php @osa_echo($unitid); ?>'   />
<input type="hidden" id="lastids"    name="lastids"    value='<?php @osa_echo($lastids); ?>'   />
<?php if ($addmode==TRUE) { ?>
	<input type="hidden" id="unittype"    name="unittype"     value='<?php @osa_echo($unittype); ?>'   />
	<input type="hidden" id="title"       name="title"        value='<?php @osa_echo($title); ?>'   />
	<input type="hidden" id="description" name="description"  value='<?php @osa_echo($description); ?>'   />
	<input type="hidden" id="startdate"   name="startdate"    value='<?php @osa_echo($startdate); ?>'   />
	<input type="hidden" id="enddate"     name="enddate"      value='<?php @osa_echo($enddate); ?>'   />
<?php } ?>
<table border="0">
  <tr>
    <td nowrap="nowrap" align='center'>
    <?php if (isset($old_courses) && is_array($old_courses) && count($old_courses)>0 ) { ?>
    	<div style="margin:5px;font-weight:bold;">
    	<?php echo lang('unit_coursecheckboxdelete').":";
    	$col = 0; $i = 0; ?>
    	</div>
		<table border="0">
		<?php foreach ($old_courses as $key => $value) { $i += 1;
			  if ($col== 0) { ?><tr><?php } ?>
    			<td nowrap="nowrap" align='center'>
    			<?php echo form_checkbox('courseid_'.$key, $value, FALSE," onclick='remove_flag(this,\"removeflag\");' "); ?>
    			</td>
    			<td nowrap="nowrap" align='left'><?php echo $value ?></td>
    	<?php if ($col== 1) { ?></tr><?php } ?>
    	<?php
			  	  $col+= 1;
			  if ($col== 2) { $col = 0; }
			  }
			  if ($col < 2 && $i > 0) { echo '</tr>'; }
			   ?>
    	</table>
    <?php } ?>
    	<div style="margin-top:15px;margin-bottom:10px;font-weight:bold;font-size:15px;">
    	<?php echo lang('unit_change_header');?>:</div>
    </td>
  </tr>
  <tr>
    <td nowrap="nowrap" align='center'>
    <div style="margin-bottom:10px;">
		<?php
		   $url = base_url()."unit/unit/selcourse_edit/";
         $title = 'Select Course';
		   $width = 520;
		   $height = 650;
			$divid = 'changeunit_div';
			$formname = 'form_unit';

			$fieldname  = '_course[]';
			$selections = $coursearray;
			$default    = $selcourses;
			$SELECT_SIZE = 30;

			echo form_dropdown($fieldname, $selections, $default,
					'size="' . $SELECT_SIZE . '" multiple="multiple"'.
					"onChange='javascript:show_select(this,\"courseids\",\"show_select\")'" );
		//	echo form_dropdown('unit_dropdown', $coursearray, $selcourses, "size=30 id=unit_dropdown onChange='javascript:show_select(this,\"courseids\",\"show_select\")' ");
		?>
		  <div style="font-size:9px;margin-top:5px"><?php echo lang('unit_multiselect_instruction');?></div>
	</div>
	</td>
  </tr>
  <tr>
    <td nowrap="nowrap" align='center' >
    	  <div id="show_select"><?php //@osa_echo($coursenames); ?></div><br />

	      <input type="button" value="<?php echo lang('unit_button_close');?>"
	      onClick="closeDhtmlWindow('changeunit_div');" <?php osa_btn();?> />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	      <?php
	       $closediv = 'changeunit_div';
	       $formname = 'coursesel_form';
	       $removemsg	 = lang('unit_remove_intuni_msg');

	       if ($addmode==TRUE) {
			       $url_refresh = base_url()."unit/unit/add/".$courseid.'/'.$unit_template;
			       $setNewUnitOwner = "setNewUnitOwner('$url_refresh','$formname','$closediv','$removemsg','removeflag');";
	      ?>
	      <input type="button" value="<?php echo lang('unit_button_copy');?>"
	      onClick="<?php echo $setNewUnitOwner;?>" <?php osa_btn();?> />
	      &nbsp;
	      <?php  } else {
	      			$url_check_mode   = base_url()."unit/unit/check_delete_mode";
			      	$url_child_insert = base_url()."unit/unit/insert_child_unit";
			      	$url_child_delete = base_url()."unit/unit/delete_child_unit";

			      	//refresh page after update new unit by all child status != STATUS_NOTACTIVE
					$url_refresh = base_url()."unit/unit/edit/".$unitid;

					//,'courseids','lastcourseids','changeunit_div',$unitid,'$removemsg','$lastids','$refreshurl','$formname'
			      	$setEditUnitOwner = "setEditUnitOwner('$url_check_mode','$url_child_insert','$url_child_delete','$url_refresh','$formname','$removemsg', '$closediv');";
	      ?>

	      <input type="button" value="<?php echo lang('unit_button_copy');?>"
	      onClick="<?php echo $setEditUnitOwner;?>" <?php osa_btn();?> />
	      &nbsp;
	      <?php } ?>
	</td>
  </tr>
</table>
</form>
</center>