<?php
/**
 * unit_ro_view.php - Unit view file
 *
 * @author $Author: dtong $
 * @version $Id: unit_ro_view.php,v 1.60 2011/04/27 05:46:26 dtong Exp $
 * @copyright Copyright (c) 2009, Tiller Software Co., Ltd.
*/
	$button_float_css = "display:inline;vertical-align:middle;margin-left:50px;float:left";
	if ( $show_closebutton ) {
		$close_div =  'unitread';
		$close_button_html = "<input type=\"button\" value=\"{$readmodebutton}\" name=\"close\" " . osa_btn(FALSE) .
			 " onClick=\"parent.closeDhtmlWindow('{$close_div}');$add_js return false;\" />";
		$button_float_css = "display:inline;vertical-align:middle;margin-right:50px;float:right";
	}
	//Set pdf button Jscript
	$url_pdf  = base_url() . 'pdf/pdfgen/index/' . 'pdf_render_' . 'urljs_unit-unit-indexsess-' .
					$unit->id . '-PHPSESSIONID/unit'; //unit/unit/index/
	$jscript_pdf="onClick=\"return openBrowserWindow('$url_pdf')\"";
	//Set Jscript for history
	$href=base_url().'unit/compare/history/'.$unit->id;
	$div = 'unit_history_form';
	$title=lang('unit_history_title');
	$click_history="onClick=\"newDhtmlWindow('$href','$title', '450', '500', '$div');return false;\"";

	$href = base_url().'unit/compare/history/'.$unit->parentid.'/'.CMS_PARENT_HISTORY; //isParent
	$div  = 'unit_parent_history_form';
	$title= lang('unit_parent_history_title');
	$click_parent_history="onClick=\"newDhtmlWindow('$href','$title', '450', '500', '$div');return false;\"";

	//Set Jscript for ICT Lib
	$unitid = $unit->id;
	if (isset($unit->parentid))
		$unitid = $unit->parentid;

	$url_itstd = base_url().'unit/itstd/readict/';
	//Onclick ict button unit page.
	$div = 'itstandards_popup';
	$title = lang('unit_title_ict');
	$href = $url_itstd . CMS_ITSTANDARDS_TYPE .'/'. CMS_ITSTANDARDS_RESOURCE_TYPE .'/'. $unitid;
	$click_ict="onClick=\"newDhtmlWindow('$href','$title', '900', '750', '$div');return false;\"";

	//Onclick gc button unit page.
	$div = 'gc_popup';
	$title = lang('unit_title_gc');
	$href = $url_itstd . CMS_GLOBAL_CITIZEN_TYPE .'/'. CMS_GLOBAL_CITIZEN_UPLOAD_TYPE .'/'. $unitid;
	$click_gc = "onClick=\"newDhtmlWindow('$href','$title', '900', '750', '$div');return false;\"";

	//Onclick tail button unit page.
	$div = 'tail_popup';
	$title = lang('unit_title_tail');
	$href = $url_itstd . CMS_TAIL_TYPE .'/'. CMS_TAIL_UPLOAD_TYPE .'/'. $unitid;
	$click_tail = "onClick=\"newDhtmlWindow('$href','$title', '900', '750', '$div');return false;\"";

	if ( isset($disable_edit_button) && $disable_edit_button )
		$disable_edit_button = ' disabled="disabled" style="color:grey" '; //firefox needs grey
	else
		$disable_edit_button = '';

	if ( isset($disable_remove_button) && $disable_remove_button )
		$disable_remove_button = ' disabled="disabled" style="color:grey" ';
	else
		$disable_remove_button = '';

	$privateres_link = base_url() . 'unit/unit/privateres/';

	if (isset($unitpage))
		echo $unitpage;

?>
<table class="unitbody" border="0"><tr><td>
		<div style="display:inline;font-weight:bold;font-size:120%;float:left"><?php echo $coursename; ?></div>
		<div style="<?php echo $button_float_css?>" >
		<?php if ( isset($editmodebutton) && !$skipedit_buttons ) { ?>
				<input <?php echo $disable_edit_button?> type="button" value="<?php echo $editmodebutton;?>" <?php osa_btn();?>
					onClick="LoadUnitEditPage('<?php echo base_url()?>unit/unit/editp/<?php @osa_echo($unit->id); ?>',
								'page_content','<?php @osa_echo($unit->courseid); ?>');return false;" />
				<input <?php echo $disable_remove_button ?> type="button" value="<?php echo $removebutton_text;?>" <?php osa_btn();?>
					onClick="removeUnit('<?php echo base_url()?>unit/unit/<?php echo $unitremove_function;?>/<?php @osa_echo($unit->id); ?>',
								'<?php @osa_echo($unit->courseid); ?>', '<?php echo $unitremove_jscript_msg;?>');return false;" />
		<?php } ?>
				<input type="button" value="<?php echo lang('unit_compare_history');?>" <?php osa_btn();?>
					<?php echo $click_history ; ?> />
		<?php if ( isset($show_parent_hist_button) && $show_parent_hist_button )   { ?>
				<input type="button" value="<?php echo lang('unit_compare_parent_history');?>" <?php osa_btn();?>
					<?php echo $click_parent_history ; ?> />
		<?php } ?>

			<?php if( isset($use_button_ict) && $use_button_ict ){?>
				<input type="button" value="<?php echo lang('unit_button_ict');?>" <?php osa_btn();?><?php echo $click_ict ; ?> />
			<?php }?>

			<?php if( isset($use_button_gc) && $use_button_gc ){?>
				<input type="button" value="<?php echo lang('unit_button_gc');?>" <?php osa_btn();?><?php echo $click_gc ; ?> />
			<?php }?>

			<?php if( isset($use_button_tail) && $use_button_tail){?>
				<input type="button" value="<?php echo lang('unit_button_tail');?>" <?php osa_btn();?><?php echo $click_tail ; ?> />
			<?php }?>

				<span style="padding-left: 20px">&nbsp;</span>
				<?php if (isset($unit->status) && $unit->status == CMS_UNIT_STATUS_DELETE){?>
					<input disabled="disabled" style="color:grey" type="button" value="<?php echo lang('unit_button_pdf')?>"
						name="pdf" <?php echo $jscript_pdf; osa_btn();?> />
				<?php }else{?>
					<input type="button" value="<?php echo lang('unit_button_pdf')?>"
						name="pdf" <?php echo $jscript_pdf; osa_btn();?> />
				<?php }?>
				<?php if (isset($show_pdf_private_resource_select) && $show_pdf_private_resource_select) { ?>
					<input type="checkbox" <?php echo $checked_privateres?>
						onClick="ajaxGetpage('','<?php echo $privateres_link?>'+this.checked,true);return true" />
					<?php echo lang('unit_no_private_resource_pdf')?>
				<?php } ?>
				<?php
					if ( $show_closebutton ){
						echo $close_button_html;
					}
				?>
		</div>
		<div style="clear:both"></div>
       <input type="hidden" name="courseid" value="<?php echo $unit->courseid ?>" />
       <input type="hidden" name="unitid" value="<?php echo $unit->id ?>" />
         <?php  if ($current_page == '' || $current_page == 1){?>
       <table border="0" cellspacing="0" cellpadding="3" width="98%">
          <tr>
            <td valign="top" width="5%"><nobr><?php echo lang('unit_title');?>:</nobr></td>
            <td valign="top" width="93%"><?php osa_echo($unit->title);?></td>
          </tr>

          <tr>
            <td valign="top" width="5%"><nobr><?php echo lang('unit_description');?>:</nobr></td>
            <td valign="top" width="93%"><?php osa_echo($unit->description);?></td>
          </tr>

          <?php if ($display_unittype!==FALSE) { ?>
          <tr>
            <td valign="top" width="5%"><nobr><?php echo lang('unit_type');?>:</nobr></td>
            <td valign="top" width="93%"><?php echo $unittypename;?></td>
          </tr>
          <?php } ?>

          <?php if (isset($tearchers) && $template == CMS_MYP_TEMPLATE){?>
	          <tr>
	            <td valign="top" width="5%"><nobr><?php echo lang('unit_teacher');?>:</nobr></td>
	            <td valign="top" width="93%"><?php echo $tearchers;?></td>
	          </tr>
          <?php }?>
           <?php if (isset($grade_level) && $template == CMS_MYP_TEMPLATE){?>
	          <tr>
	            <td valign="top" width="5%"><nobr><?php echo lang('unit_grade_level');?>:</nobr></td>
	            <td valign="top" width="93%"><?php echo $grade_level;?></td>
	          </tr>
           <?php }?>

          <tr>
            <td valign="top" width="5%"><nobr><?php echo lang('unit_startdate');?>:</nobr></td>
            <td valign="top" width="93%"><?php echo osa_date_format($unit->startdate);?></td>
          </tr>

          <tr>
            <td valign="top" width="5%"><nobr><?php echo lang('unit_enddate');?>:</nobr></td>
            <td valign="top" width="93%"><?php echo osa_date_format($unit->enddate);?></td>
          </tr>

			 <?php if( $this->config->item('cms_notuse_hide_unit_feature')===FALSE) { ?>
          <tr style="<?php echo $hide_visible_button_css?>">
		  		<td valign="middle" width="5%"><?php echo lang('unit_hidden'); ?>:</td>
		   	<td valign="middle" width="93%">
		   	<div style="vertical-align:middle">
			      <span style="height:20px;vertical-align:middle"><?php echo $hidevisible_label; ?></span>
			        <?php if (isset($show_hidebutton) &&  $show_hidebutton &&  isset($editmodebutton) && !$skipedit_buttons ) {?>
					<input type="button" style="margin-left:15px" value="<?php echo $hidebutton_text; ?>" name="button_show"
					   onClick="ajaxPostform('', '<?php echo $url; ?>', 'resource_form', false);
					   	ajaxGetpage('page_content', '<?php echo base_url()."unit/unit/index/".$unit->id; ?>', false);
					    	refresh_unitnode('<?php echo $unit->courseid; ?>'); return false;" <?php osa_btn()?> />
					<?php } ?>
				</div>
		  	 	</td>
			</tr>
			<?php } ?>

			<?php if (isset($unit_editor_name) && !empty($unit_editor_name) ) {?>
				<tr>
	            <td valign="middle" width="5%"><nobr><?php echo lang('unit_uniteditor_name');?>:</nobr></td>
	            <td valign="middle" width="93%"><b><?php echo $unit_editor_name?></b>

	           	 	<?php
	            		if ( isset($show_finishediting_button) && $show_finishediting_button ) { ?>
	            			<input type=button value="<?php echo lang('unit_btn_unlock')?>" <?php osa_btn();?>
             					onClick="updateDivConfirm('page_content', '<?php echo base_url() .
	            					'unit/unit/unlock/' . $unit->id ?>', '<?php echo lang('unit_confirm_unlock')?>');
	            					refresh_unitnode('<?php echo $unit->courseid; ?>');return false" />
	            	<?php } ?>

	            	<?php
	            		if (isset($unit_lock_release_msg) && !empty($unit_lock_release_msg) ) {
	            			echo '<span style="margin-left:10px;font-style:italic;font-size:90%">' . $unit_lock_release_msg . '</span>';
	            		}
	            	?>
	            </td>
         	 </tr>
			<?php } ?>

			<?php if (isset($timelimit_msg) && !empty($timelimit_msg) ) {?>
				<tr>
	            <td valign="top" width="5%"><nobr><?php echo lang('unit_timelimit_title');?>:</nobr></td>
	            <td valign="top" width="93%">
	            	<span style="font-size:90%"><?php echo $timelimit_msg?></span>
	            </td>
         	 </tr>
			<?php } ?>

      </table>
      <?php } ?>
		<?php
			echo $unitbody . '</td></tr>';
			if ( $show_closebutton ) {
				echo '<tr><td><div style="float:right;margin-right:50px;margin-top:15px">' . $close_button_html . '</div></td></tr>';
			}
		?>
</table>