Browse Source

Testy fix ui (see #52)

Piotr Labudda 11 năm trước cách đây
mục cha
commit
034537af15
1 tập tin đã thay đổi với 106 bổ sung73 xóa
  1. 106 73
      SE/procesy/testy.php

+ 106 - 73
SE/procesy/testy.php

@@ -661,7 +661,7 @@ function task_CRM_TEST() {
 			<div class="proces-list-item-view<?php if ($vItem->changedAfterLastTest) { echo ' changed-after-last-test'; } ; ?>">
 				<h4>
 					<?php if ($vItem->changedAfterLastTest) : ?>
-						<i class="glyphicon glyphicon-exclamation-sign" style="background-color:orange;" title="Proces został zmieniony od poprzedniego wykonania testu"></i>
+						<i class="glyphicon glyphicon-exclamation-sign" style="color:orange;" title="Proces został zmieniony od poprzedniego wykonania testu"></i>
 					<?php endif; ?>
 					<?php echo $vItem->listNr; ?>.
 					<?php echo $item->DESC; ?> <span class="muted">{<?php echo $item->ID; ?>}</span>
@@ -793,7 +793,7 @@ function task_CRM_TEST() {
 		}
 
 		if ($test_obj->TEST_START != '0000-00-00 00:00:00') {
-			echo'<form action="" method="post">';
+			echo'<form action="" method="post" class="form-inline">';
 			echo'<input type="hidden" name="function_init" value="'."fun_CRM_TEST_EDIT".'" />';
 			echo'<input type="hidden" name="subtask" value="'."SAVE".'" />';
 		}
@@ -806,10 +806,9 @@ function task_CRM_TEST() {
 			echo App::link("rozpocznij test", array('task'=>App::get_task(), 'function_init'=>'fun_CRM_TEST_EDIT', 'subtask'=>'START', 'test_id'=>$test_obj->ID), array('class'=>'btn-p5'));
 		} else {
 			echo "";
-			//echo App::link("Zapisz i zakoncz", array('task'=>App::get_task(), 'function_init'=>'fun_CRM_TEST_EDIT', 'subtask'=>'END', 'test_id'=>$test_obj->ID), array('class'=>'btn-p5'));
-			echo'<input type="submit" name="save" value="'."Zapisz".'" />';
+			echo'<input class="btn btn-default" type="submit" name="save" value="'."Zapisz".'" />';
 			echo' lub ';
-			echo'<input type="submit" name="save_and_end" value="'."Zapisz i zakoncz".'" />';
+			echo'<input class="btn btn-primary" type="submit" name="save_and_end" value="'."Zapisz i zakoncz".'" />';
 		}
 		echo'</p>';
 
@@ -1274,19 +1273,31 @@ a.btn-test-praktyczny {background-color:#B3EBFB;}
 		}
 	}
 
-	echo '<p>' . "Wybierz stanowisko do przetestowania:" . '</p>';
-
-	echo '<form>';
-		echo '<input type="hidden" name="task" value="' . App::get_task() . '" />';
-		echo '<select name="' . "stanowisko_id" . '">';
-			echo '<option value="">' . " [ wybierz ] " . '</option>';
-			foreach ($stanowiska as $k_id => $r) {
-				echo '<option value="' . $k_id . '">' . "[" . $r->ID . "] " . $r->DESC . " " . $r->OPIS . '</option>';
-			}
-		echo '</select>';
-		echo ' <input type="submit" value="' . "Wybierz" . '" />';
-	echo '</form>';
-
+	$taskName = App::get_task();
+	$stanowiskaList = array();
+	foreach ($stanowiska as $kNr => $r) {
+		$stanowiskaList[$kNr] = "[{$r->ID}] {$r->DESC} {$r->OPIS}";
+	}
+	?>
+	<p>Wybierz stanowisko do przetestowania:</p>
+
+	<form class="form-horizontal">
+		<input type="hidden" name="task" value="<?php echo $taskName; ?>" />
+		<div class="form-group">
+			<div class="col-sm-10">
+				<select class="form-control" name="stanowisko_id">
+					<option value=""> [ wybierz ] </option>
+					<?php foreach ($stanowiskaList as $kNr => $stanowiskoLabel) : ?>
+						<option value="<?php echo $kNr; ?>"><?php echo $stanowiskoLabel; ?></option>
+					<?php endforeach; ?>
+				</select>
+			</div>
+			<div class="col-sm-2">
+				<input class="btn btn-primary" type="submit" value="Wybierz" />
+			</div>
+		</div>
+	</form>
+	<?php
 	$tree_flat = array();
 	foreach ($stanowiska as $k_id => $r) {
 		$tree_flat [$r->ID] = null;
@@ -2065,13 +2076,8 @@ a.btn-test-praktyczny {background-color:#B3EBFB;}
 
 function tree_callback__show_test_item_from_CRM_PROCES(&$r, &$tree) {
 	$cls = array();
-	$cls = (!empty($cls))? ' class="'.implode(' ', $cls).'"' : '';
-	echo '<dl'.$cls.'>';
-	echo '<dt>';
-
-
+	$cls = (!empty($cls))? implode(' ', $cls) : '';
 	$tree_test_type = $tree->get_param('TEST_TYPE');
-
 	$changedAfterLastTest = false;
 	if ($tree->get_param('show_state') == 'items') {
 		$lastTestDate = $tree->get_param('lastTestDate');
@@ -2082,66 +2088,93 @@ function tree_callback__show_test_item_from_CRM_PROCES(&$r, &$tree) {
 	$outItemClass = '';
 	if ($r->TYPE == 'PROCES_INIT') $outItemClass .= ' btn-box-red';
 	if ($changedAfterLastTest) $outItemClass .= ' changed-after-last-test';
-	?>
-		<span class="item_id btn-box <?php echo $outItemClass; ?>"><?php echo $r->ID; ?></span>
-		<?php if ($changedAfterLastTest) : ?>
-			<i class="glyphicon glyphicon-exclamation-sign" style="background-color:orange;" title="Proces został zmieniony od poprzedniego wykonania testu"></i>
-		<?php endif; ?>
-		
-	<?php
-	echo' <span class="desc">';
-		if ($tree->get_param('show_state') == 'items') {
-			if ($r->TEST_PYTANIE) {
-				// pytanie ponizej
-			} else {
-				// TODO: brak pyta??
-				echo'<b>'.$r->DESC.'</b>';
-			}
-		} else {
-			echo'<b>'.$r->DESC.'</b>';
+
+	$treeItemDesc = '';
+	if ($tree->get_param('show_state') == 'items') {
+		if ($r->TEST_PYTANIE) {// pytanie ponizej
+		} else {// TODO: brak pyta??
+			$treeItemDesc = $r->DESC;
 		}
-		//if ($tree->get_param('rozwin_opis') && $r->OPIS) echo' <span class="more-desc">'.$r->OPIS.'</span>';
-	echo'</span>';
+	} else {// TODO: brak pyta??
+		$treeItemDesc = $r->DESC;
+	}
+	//if ($tree->get_param('rozwin_opis') && $r->OPIS) echo' <span class="more-desc">'.$r->OPIS.'</span>';
+
+	$pytaniaOut = array();
 	if ($tree->get_param('show_state') == 'items') {
 		Lib::loadClass('ProcesTestyHelper');
-		$pytania = ProcesTestyHelper::get_pytania_by_proces_id($r->ID, $tree_test_type);
-		if (!empty($pytania)) {
-			foreach ($pytania as $p) {
-				echo'<br /><span class="desc">'.$p->PYTANIE.'</span> ';
-				// TODO: nazwy pol dla pytan
-				$field = "ODP_{$p->ID}";
-				/**
-				 * ODP_{id_pyt}
-				 * ODP_{id_pyt}_{id_odp} (TAK/NIE)
-				 */
-				$pytanie_otwarte = true;
+		$pytaniaRaw = ProcesTestyHelper::get_pytania_by_proces_id($r->ID, $tree_test_type);
+		if (!empty($pytaniaRaw)) {
+			foreach ($pytaniaRaw as $p) {
+				$p->otwarte = true;
+				$odpowiedziOut = array();
 				for ($i = 0; $i < 5; $i++) {
-					$odp_field = "ODP_{$i}";
-					if ($p->$odp_field != '') {
-						$pytanie_otwarte = false;
-						echo'<br />'.$p->$odp_field;
-						$field_odpowiedz = "{$field}_ODP_{$i}";
-						echo' <select name="'.$field_odpowiedz.'">';
-						$options = array("", "TAK", "NIE");
-						foreach ($options as $k) {
-							$sel = ($tree->get_param($field_odpowiedz) == $k)? ' selected="selected"' : '';
-							echo'<option value="'.$k.'"'.$sel.'>'.$k.'</option>';
-						}
-						echo'</select>';
+					$odpOut = new stdClass();
+					$odpOut->questionFldName = "ODP_{$i}";
+					if (!empty($p->{$odpOut->questionFldName})) {
+						$p->otwarte = false;
+						$odpOut->answearFldName = "{$odpOut->questionFldName}_ODP_{$i}";
+						$odpOut->answearLabel = $p->{$odpOut->questionFldName};
+						$odpOut->answears = array('', 'TAK', 'NIE');
+						$odpOut->userAnswear = $tree->get_param($odpOut->answearFldName);
+						$odpowiedziOut[] = $odpOut;
 					}
 				}
 
-				if ($pytanie_otwarte) {
-					echo'<br />';
-					echo'<textarea name="'.$field.'" rows="3" cols="60">'.$tree->get_param($field).'</textarea>';
+				if ($p->otwarte) {
+					$p->questionFldName = "ODP_{$p->ID}";
+					$p->userAnswear = $tree->get_param($p->questionFldName);
+				} else {
+					$p->odpowiedzi = $odpowiedziOut;
 				}
+
+				$pytaniaOut[] = $p;
 			}
-			echo'<br />';
-			echo'<input type="submit" name="save" value="'."Zapisz".'" />';
 		}
 	}
-	echo'</dt>'."\n";
-	echo'</dl>'."\n";
+
+	?>
+	<dl class="<?php echo $cls; ?>">
+	<dt>
+		<span class="item_id btn-box <?php echo $outItemClass; ?>"><?php echo $r->ID; ?></span>
+		<?php if ($changedAfterLastTest) : ?>
+			<i class="glyphicon glyphicon-exclamation-sign" style="color:orange;" title="Proces został zmieniony od poprzedniego wykonania testu"></i>
+		<?php endif; ?>
+
+		<span class="desc">
+			<b><?php echo $treeItemDesc; ?></b>
+		</span>
+		<?php if (!empty($pytaniaOut)) : ?>
+			<?php foreach ($pytaniaOut as $pytanieOut) : ?>
+				<div>
+					<span class="desc"><?php echo $pytanieOut->PYTANIE; ?></span>
+					<?php if ($pytanieOut->otwarte) : ?>
+						<textarea class="form-control" name="<?php echo $pytanieOut->questionFldName; ?>" rows="3" cols="60"><?php echo $pytanieOut->fldName; ?></textarea>
+					<?php else : ?>
+						<div style="padding-left:40px;">
+							<?php foreach ($pytanieOut->odpowiedzi as $vOdp) : ?>
+								<div class="form-group">
+									<select class="form-control input-sm" style="width:100px" name="<?php echo $vOdp->answearFldName; ?>">
+										<?php foreach ($vOdp->answears as $answear) : ?>
+											<?php $sel = ($vOdp->userAnswear == $answear)? ' selected="selected"' : ''; ?>
+											<option value="<?php echo $answear; ?>" <?php echo $sel; ?>><?php echo $answear; ?></option>
+										<?php endforeach; ?>
+									</select>
+									<label style="font-weight:normal;"><?php echo $vOdp->answearLabel; ?></label>
+								</div>
+							<br>
+							<?php endforeach; ?>
+						</div>
+					<?php endif; ?>
+				</div>
+			<?php endforeach; ?>
+			<div style="padding:6px 40px;">
+				<input class="btn btn-default btn-xs" type="submit" name="save" value="Zapisz" />
+			</div>
+		<?php endif; ?>
+	</dt>
+	</dl>
+	<?php
 }