<?php
/**
 * FILE_NAME_HERE - FILE_DESCRIPTION_HERE
 *
 * @author $Author: dtong $
 * @version $Id: unit_ltadd_view.php,v 1.8 2011/03/21 06:53:17 dtong Exp $
 * @copyright Copyright (c) 2009, Tiller Software Co., Ltd.
*/
//var_dump($db);
?><center>
<div class="ltwin_body">

<?php if ($template->getval('_title') !== FALSE ) { ?>
<div class="ltwin_title"><?php echo $template->getval('_title') ?></div>
<?php }?>
<?php
if ( !$db ) {
		echo '<div style="font-size:16px;padding-top:50px;color:red;font-weight:bold">'
			  . $template->getval('_nodatamsg') . '</div>';
	}
	else{ ?>
<form name="lt_form">
<table width="96%" style="margin:0px;padding:0px">
	<tr>
	<td><div class="ltwin_heading"><?php echo $template->getval('_standard_title') ?></div></td>
	<td>
	<?php if (!$this->config->item('cms_hide_benchmarks')) { ?>
			<div style="float:left" class="ltwin_heading"><?php echo $template->getval('_benchmark_title') ?></div>
	<?php  } ?>
		<div style="padding-left:30%" class="ltwin_heading"><?php echo $template->getval('_target_title') ?></div>
	</td>
	</tr>
<?php

		//$template->color_track_reset();
		foreach ( $db_struct as $standardid => $standard ) {
			if (is_array($depts_name) && array_key_exists($standardid, $depts_name) ) {
				 echo '<tr><td colspan="2" class="ltwin_sep1"><div class="itwin_dept">'. $depts_name[$standardid]->deptname .'</div></td></tr>';
			}

			echo '<tr><td colspan="2" class="ltwin_sep1"></td></tr>';
			echo "<tr><td valign=\"top\" class=\"ltwin_standard\">{$standard[0]}</td><td valign=\"top\">";

			echo "<table width=\"100%\" height=\"100%\" cellspacing=\"0\" cellpadding=\"0\" style=\"margin:0px;padding:0px\">";
			$printsep=FALSE;
			foreach ( $standard as $benchmarkid => $benchmark ) {
				$template->color_track_reset();
				if ( $benchmarkid == 0 ) continue;
				if ( $printsep) {
					//Couldn't get CSS separator to work proper across all broswer so use table stuff
					echo '<tr><td colspan="2" height="5"></td></tr>';
					echo '<tr style="margin:0px;padding:0px:"><td colspan="2" height="1" class="ltwin_sep2"></td></tr>';
					echo '<tr><td colspan="2" height="5"></td></tr>';
				}

				echo "<tr style=\"margin:0px;padding:0px\">";
				if (!$this->config->item('cms_hide_benchmarks'))
					echo "<td valign=\"top\" class=\"ltwin_benchmark\">{$benchmark[0]}</td>";
				echo "<td valign=\"top\">";
				echo '<table width="100%" height="100%" cellspacing="0" cellpadding="0" style="margin:0px;padding:0px">';
				foreach ($benchmark as $index => $target) {
					if ( $index == 0 ) continue;
					$data_lt = $target->data;
					if ($courseid!=$target->courseid)
						$data_lt = $data_lt.' '.'<span class="course_lnk_link_title">'.'('.$target->coursename.')'.'</span>';
					$class = $template->color_track('ltwin_color1', 'ltwin_color2');
					echo "<tr class=\"{$class}\" style=\"margin:0px;padding:0px\"><td valign=\"top\" ".
						"class=\"ltwin_target\">{$data_lt}</td>";
						  //"class=\"ltwin_target\">{$target->data} $target->mingradeid $target->maxgradeid</td>";
					if ( !is_null($target->select1) && is_numeric($target->select1) && $target->select1 >= 1) {
						$array = $template->getval('_select1');
						$targettype = $array[$target->select1];
					}
					else {
						$targettype = '&nbsp;';
					}
					if ( in_array($target->id, $selectedids) ) {
						$checked='checked="checked"';
					}
					else
						$checked='';
					echo "<td valign=\"middle\" style=\"padding-left:15px;\">$targettype</td>";
					echo "<td valign=\"middle\" style=\"padding-left:10px;\">" .
						  "<input type=\"checkbox\" name=\"lt_{$target->id}\" value=\"$benchmarkid\" $checked /></td>";
					echo "</tr>";
				}
				echo "</table></td></tr>";
				$printsep=TRUE;
			}
			echo "</table></td></tr>";
		}
?>
</table>
<div style="padding:10px"></div>
	<input type="button" value="<?php echo $template->getval('_cancel_text');?>"
		name="close" <?php osa_btn()?>
			onClick="cancelDhtml('<?php echo $template->getval('_divid') ?>');" />
	<span style="padding:20px">&nbsp;</span>
	<input type="button" value="<?php echo $template->getval('_save_text');?>"
		name="save" <?php osa_btn()?>
		onClick="submitDhtml('<?php echo base_url() . "unit/lt/update/" .
									 	$template->unitid() . "/" . $template->type() ?>','lt_form',
			'<?php echo base_url() . "unit/unit/stage/" . $template->getval('_stage_num') . "/" .
				CMS_ACTION_EDIT . "/" . $template->unitid() ?>', '<?php echo $template->getval('_stage_div') ?>', 'learningtarget');" />
</form>
<?php } ?>
</div>
</center>