answers.php 5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
<style type="text/css">
	#allAnswersList{ list-style: none }
	#allAnswersList li{ padding:5px; border-bottom: 1px solid #ccc;  }
</style>

<div class="col-xs-12 text-center">
     <a href="javascript:;" class='btn btn- btn-default' id="showAnswerBtn"><i class="fa fa-bars"></i> Les <?php echo $what ?></a>
     <a href="#dashboard" class='lbh btn  btn-default'><i class="fa  fa-area-chart"></i> Observatoire Global</a>
     <a href="#community" class='lbh btn  btn-default'><i class="fa  fa-group"></i> Communauté</a>
     <a href="<?php echo Yii::app()->createUrl("/costum")?>/co/index/slug/<?php echo $el["slug"] ?>/answer/new" class='btn  btn-primary' id="showAnswerBtn"><i class="fa fa-plus"></i>  Ajouter <?php echo $what ?></a>
</div>

<div id="allAnswersContainer" class="hide col-xs-12 col-lg-offset-2 col-lg-8 margin-top-20">
	<ul id="allAnswersList">
	<?php 
	$lbl = $what." ";
	$ct = 0;
	if(!empty($allAnswers)){
		foreach ($allAnswers as $k => $ans) {
			$ct++;
			?>

		<li class="answerLi col-xs-12" >
			<div class="col-xs-3 text-center">
				<a href="<?php echo Yii::app()->createUrl("/costum")?>/co/index/slug/<?php echo $el["slug"] ?>/answer/<?php echo $ans["_id"] ?>"> <?php echo $lbl." ".$ct ?></a> 
			</div>
				<?php 
				$lblp = "";
				$percol = "danger";
				
				if(!isset($ans["answers"])) {
					$lblp = "no answers" ;
					$percent = 0;
				} else {
					$totalInputs = 0;
					$answeredInputs = 0;
					foreach (Yii::app()->session["forms"] as $ix => $f) 
					{
						$totalInputs += count($f["inputs"]);
						//echo "|".$f['id']."-fi=".count($f["inputs"]);
						if( isset( $ans["answers"][$f['id']] ) ){
							$answeredInputs += count( $ans["answers"][$f['id']] );
							//echo "|".$f['id']."-ai=".count( $ans["answers"][$f['id']] )."<br/>";
						}
					}
					//echo "tot".$totalInputs."-ans".$answeredInputs;
					$percent = floor($answeredInputs*100/$totalInputs);
					$percol = "primary";
					$lblp = $percent."%";
				}

				if( $percent > 50 )
					$percol = "warning";
				if( $percent > 75 )
					$percol = "success";
				?>
				<div class="col-xs-8">
					<span class="margin-5" style="font-size:0.8em"> <i class="fa fa-calendar"></i> <?php echo date("d/m/y H:i",$ans["created"]); ?></span>

					<?php 
					$step = "instruction";
					$icon = "folder-open-o";
					if ( $percent!= 0 && isset($ans["validation"]) ) {
						if ( isset($ans["validation"]["deal2"]["valid"]) && in_array($ans["validation"]["deal2"]["valid"], ["valid", "validReserve"] ) ) {
							$step = "financement";
							$icon = "money";
						}
						if ( isset($ans["validation"]["deal3"]["valid"]) &&  in_array($ans["validation"]["deal3"]["valid"], ["valid", "validReserve"] ) ){
							$step = "suivi";
							$icon = "cogs";
						}
					}	?>
					<span class="margin-5 " style="font-size:0.8em"> <i class="fa fa-<?php echo $icon; ?>"></i> <?php echo $step; ?></span>
					
					<br/>
					
					<span class="margin-5 label label-<?php echo $percol ?>"> <i class="fa fa-pencil-square-o"></i> <?php echo $lblp ?> </span>

					
					<br/>
					<?php if ( $percent!= 0) {?>
					<a href="#dashboard.answer.<?php echo $ans["_id"] ?>" class='margin-5 lbh btn btn-default '> <i class="fa  fa-group "></i>Communauté <span class="margin-5  label label-primary"> 3 </span></a>
					
					<a href="#dashboard.answer.<?php echo $ans["_id"] ?>" class='margin-5  lbh btn btn-default '> <i class="fa  fa-pie-chart "></i> Observatoire Local</a>
					<?php } ?>
				</div>

				<div class="col-xs-1">
					<a class='text-red pull-right deleteAnswer' data-id="<?php echo $ans["_id"] ?>" href="javascript"> <i class="fa  fa-trash"></i> </a> 
				</div>
			
		</li>
		
	<?php } 
	}?>
		<li class="text-center"><a href="<?php echo Yii::app()->createUrl("/costum")?>/co/index/slug/<?php echo $el["slug"] ?>/answer/new" class="btn btn-xs btn-primary"><i class="fa fa-plus"></i>  Ajouter</a></li>
	</ul>
</div>

<script type="text/javascript">

jQuery(document).ready(function() {

  mylog.log("render","/modules/costum/views/tpls/forms/costum/deal/answers.php");
 

  $('#showAnswerBtn').on("click",function() { 
    $("#allAnswersContainer").toggleClass("hide");
Clément Damiens's avatar
 
Clément Damiens committed
109
    $('#<?php echo @$wizid ?>').toggleClass("hide");
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
   })

  <?php if($canEdit) { ?>
	

	  $('.deleteAnswer').off().click( function(){
      id = $(this).data("id");
      bootbox.dialog({
          title: "Confirmez la suppression",
          message: "<span class='text-red bold'><i class='fa fa-warning'></i> Cette action sera irréversible</span>",
          buttons: [
            {
              label: "Ok",
              className: "btn btn-primary pull-left",
              callback: function() {
                getAjax("",baseUrl+"/survey/co/delete/id/"+id,function(){
                	//urlCtrl.loadByHash(location.hash);
                	$("#line"+id).remove();
                },"html");
              }
            },
            {
              label: "Annuler",
              className: "btn btn-default pull-left",
              callback: function() {}
            }
          ]
      });
    });


<?php } ?>

});


</script>