Explorar el Código

Procesy fix popups

Piotr Labudda hace 11 años
padre
commit
f883b32d7a
Se han modificado 3 ficheros con 110 adiciones y 38 borrados
  1. 1 1
      SE/VERSION
  2. 12 0
      SE/procesy/proces.php
  3. 97 37
      SE/procesy5.php

+ 1 - 1
SE/VERSION

@@ -1 +1 @@
-3.9.9-13
+3.9.9-14

+ 12 - 0
SE/procesy/proces.php

@@ -194,6 +194,18 @@ if($DBG_TIME) $time_arr []= array(microtime(true), 'before Tree');
 		$tree->set_param('ProcesTblId', ProcesHelper::getZasobTableID('CRM_PROCES'));
 		$tree->set_param('ZasobTblId', ProcesHelper::getZasobTableID('CRM_LISTA_ZASOBOW'));
 
+		$tblPytaniaId = ProcesHelper::getZasobTableID('CRM_TESTY_PYTANIA');
+		if ($tblPytaniaId > 0) {
+			$userAcl = User::getAcl();
+			$userAcl->fetchGroups();
+			if ($userAcl->hasTableAcl($tblPytaniaId)) {
+				$tblAcl = $userAcl->getTableAcl($tblPytaniaId);
+				$tblAcl->init($forceTblAclInit = false);
+				$tree->set_param('HasAclPytaniaTbl', true);
+			}
+			$tree->set_param('PytaniaTblId', $tblPytaniaId);
+		}
+
 		//TODO: check perm to edit
 
 

+ 97 - 37
SE/procesy5.php

@@ -170,8 +170,28 @@ function lay_procesy_gora() {
 	<meta name="author" content="Piotr Labudda <piotrl86@gmail.com>" />
 	<link rel="stylesheet" href="stuff/twitter-bootstrap/css/bootstrap.css" type="text/css" />
 	<link rel="stylesheet" href="stuff/main.css" type="text/css" />
+	<style type="text/css">
+.popover-with-html .popover-heading {display:none;}
+.popover-with-html .popover-body {display:none;}
+	</style>
 	<script src="stuff/jquery.js"></script>
 	<script src="stuff/twitter-bootstrap/js/bootstrap.min.js"></script>
+	<script>
+jQuery(document).ready(function(){
+	jQuery(".popover-with-html").popover({
+		html: true,
+		trigger: 'hover',
+		animation: false,
+		placement: 'top',
+		content: function() {
+			return jQuery(this).children(".popover-body").html();
+		},
+		title: function() {
+			return jQuery(this).children(".popover-heading").html();
+		}
+	});
+});
+	</script>
 	<?php
 		lay_procesy_css();
 		App::show_head_css();
@@ -2102,10 +2122,20 @@ function tree_callback__show_item_from_CRM_PROCES( &$r, &$tree ) {
 	$wsk = array();
 	Lib::loadClass('ProcesHelper');
 	if ($tree->get_param('rozwin_proces')) {
-		$wsk = ProcesHelper::get_wskazniki( $r->ID );//TODO: proces helper
+		$wsk = ProcesHelper::get_wskazniki($r->ID);
 	}
-	$tblCRM_TESTY_PYTANIAid = ProcesHelper::getZasobTableID('CRM_TESTY_PYTANIA');
-	
+
+	$pytania = array();
+	$tblPytaniaId = $tree->get_param('PytaniaTblId');
+	if ($tree->get_param('editable') && $tree->get_param('HasAclPytaniaTbl')) {
+		$userAcl = User::getAcl();
+		$tblAcl = $userAcl->getTableAcl($tblPytaniaId);
+		$dataSource = $tblAcl->getDataSource();
+		$params = array();
+		$params['f_ID_PROCES'] = $r->ID;
+		$pytania = $dataSource->getItems($params);
+	}
+
 	$show_form = ($tree->get_param('show_form_at_item') == $r->ID);
 	$show_form = ($tree->get_param('show_form_at_item') > 0);// TODO: RMME
 	$cls = array();
@@ -2170,19 +2200,32 @@ function tree_callback__show_item_from_CRM_PROCES( &$r, &$tree ) {
 				echo App::link("P+", array('task'=>"CRM_TESTY_ADD_PYTANIA", 'id_proces'=>$r->ID), array('title'=>'Dodaj pytanie do testow', 'class'=>'btn-p5 btn-red'));
 			} else {
 				echo App::link("P+", array('task'=>"CRM_TESTY_ADD_PYTANIA", 'id_proces'=>$r->ID), array('title'=>'Dodaj pytanie do testow', 'class'=>'btn-p5'));
-				if(0){// TODO: Mysql::get_searched_obj
-					$get_obj->ID_PROCES = $r->ID;
-					$get_obj->ID_WSKAZNIK = ($tree->get_param('rozwin_proces'))? 0 : '%';
-					$rquest = $db->get_searched_obj('CRM_TESTY_PYTANIA', $get_obj, null, null, null);
-					while ($rq = $db->fetch($rquest)) {
-						$txt = "";
-						if (!empty($rq->ODP_0)) $txt .= "<font color=".($rq->ODP_0_ODP=='TAK' ? 'green' : 'red')." >".htmlspecialchars($rq->ODP_0)." </font>";
-						if (!empty($rq->ODP_1)) $txt .= "<hr><font color=".($rq->ODP_1_ODP=='TAK' ? 'green' : 'red')." >".htmlspecialchars($rq->ODP_1)." </font>";
-						if (!empty($rq->ODP_2)) $txt .= "<hr><font color=".($rq->ODP_2_ODP=='TAK' ? 'green' : 'red')." >".htmlspecialchars($rq->ODP_2)." </font>";
-						if (!empty($rq->ODP_3)) $txt .= "<hr><font color=".($rq->ODP_3_ODP=='TAK' ? 'green' : 'red')." >".htmlspecialchars($rq->ODP_3)." </font>";
-						if (!empty($rq->ODP_4)) $txt .= "<hr><font color=".($rq->ODP_4_ODP=='TAK' ? 'green' : 'red')." >".htmlspecialchars($rq->ODP_4)." </font>";
-						?>											
-							<a target=blank href="index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=<?php echo $tblCRM_TESTY_PYTANIAid."&task=CRM_PROCES#EDIT/".$rq->ID."=".$rq->ID."#TREE".$r->ID ; ?>"><i class="<?php  echo (($rq->TEST_TYPE=='TEORETYCZNY') ? 'icon-question-sign' : 'icon-exclamation-sign'); ?> wsk-help" data-toggle="popover" data-trigger="hover" title="" data-content="<?php echo $txt; ?>" data-original-title="<?php echo "#{$rq->ID} {$rq->PYTANIE}"; ?>"></a></i>
+				if (!empty($pytania)) {
+					foreach ($pytania as $pytanie) {
+						if ($tree->get_param('rozwin_proces') && $pytanie->ID_WSKAZNIK != 0) {
+							continue;
+						}
+						$odpowiedzi = array();
+						for ($i = 0; $i < 5; $i++) {
+							$fldTxt = "ODP_{$i}";
+							$fldOdp = "ODP_{$i}_ODP";
+							if (!empty($pytanie->{$fldTxt})) {
+								if ($pytanie->{$fldOdp} == 'TAK') {
+									$odpowiedzi[] = '<span class="text-success">' . htmlspecialchars($pytanie->{$fldTxt}) . '</span>';
+								} else {
+									$odpowiedzi[] = '<span class="text-error">' . htmlspecialchars($pytanie->{$fldTxt}) . '</span>';
+								}
+							}
+						}
+						$popupIcon = ($pytanie->TEST_TYPE=='TEORETYCZNY')? 'icon-question-sign' : 'icon-exclamation-sign';
+						$popupLink = "index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID={$tblPytaniaId}&task=CRM_PROCES#EDIT/{$pytanie->ID}";// TODO: add rand _hash?
+						$popupTitle = "#{$pytanie->ID} " . htmlspecialchars($pytanie->PYTANIE);
+						$popupContent = implode('<hr style="margin:0.5em 0;">', $odpowiedzi);
+						?>
+							<a target="_blank" href="<?php echo $popupLink; ?>"><i class="<?php echo $popupIcon; ?> wsk-help popover-with-html">
+								<span class="popover-heading"><?php echo $popupTitle; ?></span>
+								<span class="popover-body"><?php echo $popupContent; ?></span>
+							</i></a>
 						<?php
 					}
 				}
@@ -2264,7 +2307,10 @@ function tree_callback__show_item_from_CRM_PROCES( &$r, &$tree ) {
 		}
 		else if (!empty($r->OPIS)) {
 			?>
-				<i class="icon-info-sign wsk-help" data-toggle="popover" data-trigger="hover" title="" data-content='<?php echo htmlspecialchars($r->OPIS); ?>' data-original-title="<?php echo "[{$r->ID}] {$r->DESC}"; ?>"></i>
+				<i class="icon-info-sign wsk-help popover-with-html">
+					<span class="popover-heading"><?php echo "[{$r->ID}] " . $r->DESC; ?></span>
+					<span class="popover-body"><?php echo $r->OPIS; ?></span>
+				</i>
 			<?php
 		 }
 		echo $opis_after;
@@ -2346,10 +2392,7 @@ function tree_callback__show_item_from_CRM_PROCES( &$r, &$tree ) {
 
 			echo'<li'.((--$wsk_cnt)? '' : ' class="tree-last"').'>';
 			echo'<p>';
-			//TODO: test: echo ' <span class="btn-box btn-box-silver">'.".".$w->CW_ID.".".'</span>';
 			echo ' <span class="btn-box btn-box-silver">'.$w->CW_ID.'</span>';
-			//echo ' ('.$w->SORT_PRIO.')';
-			//echo $w->CW_SORT_PRIO;// DBG
 			if ($tree->get_param('editable')) {
 				echo App::link("<b>^</b>", array('function_init'=>'SORT_PRIO_WSKAZNIK', 'arg1'=>$w->CW_ID, 'arg1_val'=>'upup','_hash'=>rand(0,9999),'#'=>'TREE'.$r->ID), array('class'=>"btn-clean", 'title'=>"w gore o 5 pol"));
 				echo App::link("^", array('function_init'=>'SORT_PRIO_WSKAZNIK', 'arg1'=>$w->CW_ID, 'arg1_val'=>'up','_hash'=>rand(0,9999),'#'=>'TREE'.$r->ID), array('class'=>"btn-clean", 'title'=>"w gore"));
@@ -2363,25 +2406,36 @@ function tree_callback__show_item_from_CRM_PROCES( &$r, &$tree ) {
 				}
 			}
 
-			//echo ' <span class="btn-box btn-box-lgreen"'.$w_title_parents_out.'>'.$w->ID.'</span>';
-			if(0){// TODO: Mysql::get_searched_obj //if ($tree->get_param('editable')) {
-				$get_obj->ID_PROCES = $r->ID;
-				$get_obj->ID_WSKAZNIK = $w->CW_ID;
-				$rquest = $db->get_searched_obj('CRM_TESTY_PYTANIA', $get_obj, null, null, null);
-				while ($rq = $db->fetch($rquest)) {
-					$txt = "";
-					if (!empty($rq->ODP_0)) $txt .= "<font color=".($rq->ODP_0_ODP=='TAK' ? 'green' : 'red')." >".htmlspecialchars($rq->ODP_0)." </font>";
-					if (!empty($rq->ODP_1)) $txt .= "<hr><font color=".($rq->ODP_1_ODP=='TAK' ? 'green' : 'red')." >".htmlspecialchars($rq->ODP_1)." </font>";
-					if (!empty($rq->ODP_2)) $txt .= "<hr><font color=".($rq->ODP_2_ODP=='TAK' ? 'green' : 'red')." >".htmlspecialchars($rq->ODP_2)." </font>";
-					if (!empty($rq->ODP_3)) $txt .= "<hr><font color=".($rq->ODP_3_ODP=='TAK' ? 'green' : 'red')." >".htmlspecialchars($rq->ODP_3)." </font>";
-					if (!empty($rq->ODP_4)) $txt .= "<hr><font color=".($rq->ODP_4_ODP=='TAK' ? 'green' : 'red')." >".htmlspecialchars($rq->ODP_4)." </font>";
+			if (!empty($pytania)) {
+				foreach ($pytania as $pytanie) {
+					if ($pytanie->ID_WSKAZNIK != $w->CW_ID) {
+						continue;
+					}
+					$odpowiedzi = array();
+					for ($i = 0; $i < 5; $i++) {
+						$fldTxt = "ODP_{$i}";
+						$fldOdp = "ODP_{$i}_ODP";
+						if (!empty($pytanie->{$fldTxt})) {
+							if ($pytanie->{$fldOdp} == 'TAK') {
+								$odpowiedzi[] = '<span class="text-success">' . htmlspecialchars($pytanie->{$fldTxt}) . '</span>';
+							} else {
+								$odpowiedzi[] = '<span class="text-error">' . htmlspecialchars($pytanie->{$fldTxt}) . '</span>';
+							}
+						}
+					}
+					$popupIcon = ($pytanie->TEST_TYPE=='TEORETYCZNY')? 'icon-question-sign' : 'icon-exclamation-sign';
+					$popupLink = "index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID={$tblPytaniaId}&task=CRM_PROCES#EDIT/{$pytanie->ID}";// TODO: add rand _hash?
+					$popupTitle = "#{$pytanie->ID} " . htmlspecialchars($pytanie->PYTANIE);
+					$popupContent = implode('<hr style="margin:0.5em 0">', $odpowiedzi);
 					?>
-						<a target=blank href="index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=<?php echo $tblCRM_TESTY_PYTANIAid."&task=CRM_PROCES#EDIT/".$rq->ID."=".$rq->ID."#TREE".$r->ID ; ?>">
-						<i class="<?php  echo (($rq->TEST_TYPE=='TEORETYCZNY') ? 'icon-question-sign' : 'icon-exclamation-sign') ; ?> wsk-help" data-toggle="popover" data-trigger="hover" title="" data-content="<?php echo $txt; ?>" data-original-title="<?php echo "#{$rq->ID} {$rq->PYTANIE}"; ?>"></a></i>
+						<a target="_blank" href="<?php echo $popupLink; ?>"><i class="<?php echo $popupIcon; ?> wsk-help popover-with-html">
+							<span class="popover-heading"><?php echo $popupTitle; ?></span>
+							<span class="popover-body"><?php echo $popupContent; ?></span>
+						</i></a>
 					<?php
 				}
 			}
-		
+
 			echo'<span class="green"'.$w_title_parents_out.'>['.$w->ID.']</span>';
 			echo' <i title="'.$w->CP_PYTANIE.' '.$w->CP_OPIS.'">'.$w->CP_FORM_TREAT.'</i>';
 			echo'';
@@ -2444,7 +2498,10 @@ function tree_callback__show_item_from_CRM_PROCES( &$r, &$tree ) {
 							<?php
 						} else {
 							?>
-							<i class="icon-info-sign wsk-help" data-toggle="popover" data-trigger="hover" title="" data-content="<?php echo htmlspecialchars($w->OPIS); ?>" data-original-title="<?php echo "[{$w->CW_ID}] {$w->DESC}"; ?>"></i>
+							<i class="icon-info-sign wsk-help popover-with-html">
+								<span class="popover-heading"><?php echo "[{$w->CW_ID}] " . $w->OPIS; ?></span>
+								<span class="popover-body"><?php echo $w->OPIS_ZASOB; ?></span>
+							</i>
 							<?php
 						}
 					}
@@ -2457,7 +2514,10 @@ function tree_callback__show_item_from_CRM_PROCES( &$r, &$tree ) {
 			}
 			else if (!empty($w->OPIS_ZASOB)) {
 				?>
-					<i class="icon-info-sign wsk-help" data-toggle="popover" data-trigger="hover" title="" data-content="<?php echo "[".$w->ID."]".htmlspecialchars($w->OPIS_ZASOB); ?>" data-original-title="<?php echo "{{{$w->CW_ID}}} {$w->OPIS}"; ?>"></i>
+					<i class="icon-info-sign wsk-help popover-with-html">
+						<span class="popover-heading"><?php echo "[" . $w->CW_ID . "] " . $w->OPIS; ?></span>
+						<span class="popover-body"><?php echo "[{$w->ID}]" . $w->OPIS_ZASOB; ?></span>
+					</i>
 				<?php
 			}
 			if ($show_form) $zasoby_id[$w->TYPE][$w->ID] = $w->CW_ID;