budgetTable.php 4.02 KB
Newer Older
Raph El's avatar
Raph El committed
1
<?php 
Raph El's avatar
Raph El committed
2 3 4
$styleT =  ( ($mode == "pdf") ? " border : 1px solid black ;" : "");
//var_dump($styleT);
$colspanplus  = (($mode == "r" || $mode == "pdf") ? 0 : 2);
Raph El's avatar
Raph El committed
5 6 7 8
?>
<div class="form-group">

	<?php 
Raph El's avatar
Raph El committed
9
	if($mode == "r" || $mode == "pdf"){ ?>
Raph El's avatar
Raph El committed
10 11 12 13 14 15 16 17 18
		<label ><h4 style="color:<?php echo (!empty($titleColor) ? $titleColor : "black" ); ?>"><?php echo $label ; ?></h4></label>
    <?php echo $info ?>
	<?php 
	} else {
		?>
		<label ><h4 style="color:<?php echo (!empty($titleColor) ? $titleColor : "black" ); ?>"><?php echo $label.$editQuestionBtn.$editParamsBtn.$editBtnL ; ?></h4></label>
		<?php echo $info ?>
	<?php 
	} ?>
Raph El's avatar
Raph El committed
19 20
	<table class="table table-bordered table-hover  directoryTable"  id="<?php echo $kunik ; ?>" 
		 >
Raph El's avatar
Raph El committed
21 22 23 24 25 26 27 28 29 30 31 32
		
	<thead>	
		<?php 		
		if( count($answers)>0 ){ ?>
		<tr>
			<?php 
			
			foreach ($properties as $i => $inp) {
				echo "<th>".$inp["placeholder"]."</th>";
			} ?>

			<?php 
Raph El's avatar
Raph El committed
33
			if($mode != "r" && $mode != "pdf"){ ?>
Raph El's avatar
Raph El committed
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
				<th></th>
			<?php } ?>
		</tr>
		<?php } ?>
	</thead>
	<tbody class="directoryLines">	
		<?php 
		$ct = 0;
		
		if(isset($answers)){
			foreach ($answers as $q => $a) {

				$tds = "";
				foreach ($properties as $i => $inp) {
					$tds .= "<td>";

					if( $i == "price" ) {
						if(!empty($a["price"]))
							$tds .= "<span id='price".$q."'>".$a["price"]."€</span>";
						if( $paramsData["estimate"] ) 
						{ 
							$tds .= "<a href='javascript:;' data-id='".$answer["_id"]."' data-key='".$key."' data-form='".$form["id"]."' data-pos='".$q."'  class='btn btn-xs btn-primary btnEstimate margin-left-5 padding-10'><i class='fa fa-plus'></i></a>";
							if( isset($a["estimates"] ))	
							{
								foreach ( $a["estimates"] as $uid => $esti ) 
								{
									$selected = ( isset($esti["selected"]) ) ? "success" : "default"; 
									$tds .= "<br/><a href='javascript:;' data-id='".$answer["_id"]."' data-uid='".$uid."' data-price='".$esti["price"]."' data-key='".$key."' data-form='".$form["id"]."' data-pos='".$q."'  class='btn btn-xs btn-".$selected." btnEstimateSelected margin-left-5 padding-10'>".$esti["price"]."€ | ".$esti["days"]."j | ".$esti["name"]."</a>";
								}
							}
						} 	
					}
					else if(isset($a[$i]))
						$tds .= $a[$i];
					
					$tds .= "</td>";
				}

				
					echo "<tr id='".$kunik.$q."' class='".$kunik."Line'>";
						echo $tds;
Raph El's avatar
Raph El committed
75
						if($mode != "r" && $mode != "pdf"){
Raph El's avatar
Raph El committed
76 77 78
					?>
						<td>
							<?php 
Tibor Katelbach's avatar
Tibor Katelbach committed
79
							//echo $answerPath.$q;
Raph El's avatar
Raph El committed
80 81 82 83 84
								$this->renderPartial( "survey.views.tpls.forms.cplx.editDeleteLineBtn" , [
									"canEdit"=>($canEdit||Yii::app()->session["userId"] == $answer["user"]),
									"id" => $answer["_id"],
									"collection" => Form::ANSWER_COLLECTION,
									"q" => $q,
Tibor Katelbach's avatar
Tibor Katelbach committed
85
									"path" => $answerPath.$q,
Raph El's avatar
Raph El committed
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
									"kunik"=>$kunik ] ); ?>

							<a href="javascript:;" class="btn btn-xs btn-primary openAnswersComment" onclick="commentObj.openPreview('answers','<?php echo $answer["_id"]?>','<?php echo $answer["_id"].$key.$q ?>', '<?php echo @$a['step'] ?>')"><?php echo PHDB::count(Comment::COLLECTION, array("contextId"=>$answer["_id"],"contextType"=>"answers", "path"=>$answer["_id"].$key.$q))?> <i class='fa fa-commenting'></i></a>
						</td>
				<?php 
						}
					$ct++;
					echo "</tr>";
				
			}
		}

$totalMap = [];
foreach ( $properties as $i => $inp ) {
	if( isset($inp["propType"]) && $inp["propType"] == "amount" )
		$totalMap[$i] = 0;
}

if(isset($answers)){
	foreach ( $answers as $q => $a ) {	
		foreach ($totalMap as $i => $tot) {
			if(isset($a[$i]))
				$totalMap[$i] = $tot + $a[$i];
		}
	}
}

$total = 0;
foreach ( $totalMap as $i => $tot ) {
	if( $tot != 0 )
		$total = $total + $tot ;
}

if($total > 0){

	

	echo "<tr class='bold'>";
	echo 	"<td colspan=".(count( $paramsData["amounts"] )+2)." style='text-align:right'> TOTAL : </td>";
Raph El's avatar
Raph El committed
125
	if($mode != "r" && $mode != "pdf")
Raph El's avatar
Raph El committed
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
		echo 	"<td colspan='".$colspanplus."''>".trim(strrev(chunk_split(strrev($total),3, ' ')))." €</td>";
	else
		echo 	"<td>".trim(strrev(chunk_split(strrev($total),3, ' ')))." €</td>";
	echo "</tr>";

	//Yii::app()->session["totalBudget"] = $total;

}

	

?>
		</tbody>
	</table>
</div>