Commit 97bb4ace authored by Raph El's avatar Raph El

Modif et correction survey

parent d22d38a9
......@@ -7,7 +7,6 @@ class IndexAction extends CAction
$params = array();
if(!empty($id)){
if($id == "new"){
if(!empty(Yii::app()->session["userId"])){
$answer = Answer::generateAnswer();
$params["answerId"] = $answer["_id"];
......
......@@ -72,7 +72,7 @@ $properties = [
?>
<?php
echo $this->renderPartial("survey.views.tpls.forms.cplx.tableView",
echo $this->renderPartial("survey.views.tpls.forms.cplx.budgetTable",
[
"form" => $form,
"wizard" => true,
......
<?php
$totalMap = [];
foreach ( $properties as $i => $inp ) {
if( isset($inp["propType"]) && $inp["propType"] == "amount" )
$totalMap[$i] = 0;
}
?>
<div class="form-group">
<table class="table table-bordered table-hover directoryTable" id="<?php echo $kunik?>" style="border: 1px solid black;">
<thead>
<tr>
<?php
if($mode == "r"){ ?>
<td colspan='<?php echo count( $properties)+2?>' >
<h4 style="color:<?php echo (!empty($titleColor) ? $titleColor : "black" ); ?>"><?php echo $label ; ?></h4>
<?php echo $info ?>
</td>
<?php
} else {
?>
<td colspan='<?php echo count( $properties)+2?>' >
<h4 style="color:<?php echo (!empty($titleColor) ? $titleColor : "black" ); ?>"><?php echo $label.$editQuestionBtn.$editParamsBtn.$editBtnL ; ?></h4>
<?php echo $info ; ?>
</td>
<?php
} ?>
</tr>
<?php
if( count($answers)>0 ){ ?>
<tr>
<?php
foreach ($properties as $i => $inp) {
echo "<th>".$inp["placeholder"]."</th>";
} ?>
<th></th>
</tr>
<?php } ?>
</thead>
<tbody class="directoryLines">
<?php
$ct = 0;
if(isset($answers)){
foreach ($answers as $q => $a) {
foreach ($totalMap as $i => $tot) {
if(isset($a[$i]))
$totalMap[$i] = $tot + $a[$i];
}
$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;
if($mode != "r"){
?>
<td>
<?php
$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,
"path" => "answers.".$kunik.".".$q,
"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>";
}
}
// 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>";
if($mode != "r")
echo "<td >".trim(strrev(chunk_split(strrev($total),3, ' ')))." €</td>";
else
echo "<td colspan='2'>".trim(strrev(chunk_split(strrev($total),3, ' ')))." €</td>";
echo "</tr>";
Yii::app()->session["totalBudget"] = $total;
}
?>
</tbody>
</table>
</div>
\ No newline at end of file
......@@ -101,11 +101,7 @@ if(isset($this->costum["contextType"]) && isset($this->costum["contextId"])){
</style>
<script type="text/javascript">
//contains all dynform definitions for complexe inputs
//it also carries sub dynforms, when an input needs extra parameters to
var sectionDyf = {};
//var tplCtx = {};
var sectionDyf = {};
</script>
<?php
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment