Commit e0a798a7 authored by Raph El's avatar Raph El
Browse files

Mode view read and pdf

parent 9232ef7f
......@@ -8,17 +8,30 @@ else if(!empty($answer) && isset($answer["answers"][$kunik]) && $answer["answers
if($saveOneByOne)
$inpClass = " saveOneByOne"; ?>
<div class="form-check">
<label class="form-check-label" for="<?php echo $kunik ?>"><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $label.$editQuestionBtn ?></h4></label>
<input type="checkbox" class="form-check-input <?php echo $inpClass ?>" id="<?php echo $kunik ?>" data-form='<?php echo $form["id"] ?>' <?php echo $value ?> > <?php echo @$form["inputs"][$key]["placeholder"]?>
<?php if(!empty($info)){ ?>
<small id="<?php echo $key ?>Help" class="form-text text-muted"><?php echo $info ?></small>
<?php } ?>
</div>
$inpClass = " saveOneByOne";
<script type="text/javascript">
jQuery(document).ready(function() {
mylog.log("render form input","/modules/costum/views/tpls/forms/checkbox.php");
});
</script>
\ No newline at end of file
if($mode == "r"){ ?>
<div class="col-xs-12" id="<?php echo $kunik ?>">
<label for="<?php echo $kunik ?>"><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $label ?></h4></label>
<?php
echo @$form["inputs"][$key]["placeholder"]." : ".(!empty($value) ? "Yes" : "No");
?>
</div>
<?php
}else{
?>
<div class="form-check">
<label class="form-check-label" for="<?php echo $kunik ?>"><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $label.$editQuestionBtn ?></h4></label>
<input type="checkbox" class="form-check-input <?php echo $inpClass ?>" id="<?php echo $kunik ?>" data-form='<?php echo $form["id"] ?>' <?php echo $value ?> > <?php echo @$form["inputs"][$key]["placeholder"]?>
<?php if(!empty($info)){ ?>
<small id="<?php echo $key ?>Help" class="form-text text-muted"><?php echo $info ?></small>
<?php } ?>
</div>
<script type="text/javascript">
jQuery(document).ready(function() {
mylog.log("render form input","/modules/costum/views/tpls/forms/checkbox.php");
});
</script>
<?php } ?>
\ No newline at end of file
<?php
$cssAnsScriptFilesModule = array(
'/js/address.js',
);
HtmlHelper::registerCssAndScriptsFiles($cssAnsScriptFilesModule, Yii::app()->getModule( "co2" )->getAssetsUrl() );
$value = "";
if(!empty($answer) && isset($answer["answers"][$form["id"]][$kunik]))
$value = $answer["answers"][$form["id"]][$kunik];
else if(!empty($answer) && isset($answer["answers"][$kunik]))
$value = $answer["answers"][$kunik];
$inpClass = "form-control";
echo $mode ;
if($mode == "r"){ ?>
<div class="col-xs-12" id="<?php echo $kunik ?>">
<label for="<?php echo $kunik ?>"><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $label ?></h4></label>
......@@ -24,76 +16,83 @@ if($mode == "r"){ ?>
</div>
<?php
}else{
?>
<div class="form-group" id="<?php echo $kunik ?>">
<label for="<?php echo $kunik ?>"><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $label.$editQuestionBtn ?></h4></label>
<div id="addressForm<?php echo $kunik ?>"></div>
<?php if(!empty($info)){ ?>
<small id="<?php echo $kunik ?>Help" class="form-text text-muted"><?php echo $info ?></small>
<?php } ?>
</div>
<script type="text/javascript">
// 137 rue des villages, Cangey
var cplxAddObj ={};
var keyAdd ="<?php echo $kunik ?>";
var valueAdd =<?php echo json_encode( $value ); ?>;
jQuery(document).ready(function() {
mylog.log("render form input","/modules/costum/views/tpls/forms/cplx/address.php");
var paramsInitAddress = {
container : "#addressForm"+"<?php echo $kunik ?>",
result : valueAdd,
input : {
id : 'inputAdd',
class : "<?php echo $inpClass ?>",
placeholder : "<?php echo (isset($placeholder)) ? $placeholder : '' ?>",
"aria-describedby" : "<?php echo $kunik ?>Help",
}
};
$cssAnsScriptFilesModule = array(
'/js/address.js',
);
HtmlHelper::registerCssAndScriptsFiles($cssAnsScriptFilesModule, Yii::app()->getModule( "co2" )->getAssetsUrl() );
cplxAddObj = addressObj.init(paramsInitAddress);
$inpClass = "form-control";
?>
<div class="form-group" id="<?php echo $kunik ?>">
<label for="<?php echo $kunik ?>"><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $label.$editQuestionBtn ?></h4></label>
<div id="addressForm<?php echo $kunik ?>"></div>
<?php if(!empty($info)){ ?>
<small id="<?php echo $kunik ?>Help" class="form-text text-muted"><?php echo $info ?></small>
<?php } ?>
</div>
<script type="text/javascript">
// 137 rue des villages, Cangey
var cplxAddObj ={};
var keyAdd ="<?php echo $kunik ?>";
var valueAdd =<?php echo json_encode( $value ); ?>;
jQuery(document).ready(function() {
mylog.log("render form input","/modules/costum/views/tpls/forms/cplx/address.php");
var paramsInitAddress = {
container : "#addressForm"+"<?php echo $kunik ?>",
result : valueAdd,
input : {
id : 'inputAdd',
class : "<?php echo $inpClass ?>",
placeholder : "<?php echo (isset($placeholder)) ? $placeholder : '' ?>",
"aria-describedby" : "<?php echo $kunik ?>Help",
}
};
cplxAddObj.saveAuto = function(data){
cplxAddObj = addressObj.init(paramsInitAddress);
var answer = {
collection : "answers",
id : answerObj._id.$id,
path : "answers."+keyAdd
};
cplxAddObj.saveAuto = function(data){
var answer = {
collection : "answers",
id : answerObj._id.$id,
path : "answers."+keyAdd
};
answer.value = cplxAddObj.result;
answer.value = cplxAddObj.result;
mylog.log("addressObj.saveAuto", answer );
mylog.log("addressObj.saveAuto", answer );
dataHelper.path2Value( answer , function(params) {
toastr.success('saved');
} );
};
dataHelper.path2Value( answer , function(params) {
toastr.success('saved');
} );
};
// allMaps.maps[keyAdd] = addressObj.init(paramsInitAddress);
// allMaps.maps[keyAdd] = addressObj.init(paramsInitAddress);
// allMaps.maps[keyAdd].saveAuto = function(data){
// allMaps.maps[keyAdd].saveAuto = function(data){
// var answer = {
// collection : "answers",
// id : answerObj._id.$id,
// path : "answers."+keyAdd
// };
// var answer = {
// collection : "answers",
// id : answerObj._id.$id,
// path : "answers."+keyAdd
// };
// answer.value = allMaps.maps[keyAdd].result;
// answer.value = allMaps.maps[keyAdd].result;
// mylog.log("addressObj.saveAuto", answer );
// mylog.log("addressObj.saveAuto", answer );
// dataHelper.path2Value( answer , function(params) {
// toastr.success('saved');
// } );
// };
});
</script>
// dataHelper.path2Value( answer , function(params) {
// toastr.success('saved');
// } );
// };
});
</script>
<?php } ?>
......
......@@ -10,16 +10,17 @@ $paramsData = [
"Costum",
"Chef de Projet",
"Data",
"Mantenance" ],
"Mantenance"
],
"nature" => [
"investissement" => "Investissement",
"fonctionnement" => "Fonctionnement"
],
"amounts" => [
"price" => "Price"
],
"estimate" => false
];
"investissement" => "Investissement",
"fonctionnement" => "Fonctionnement"
],
"amounts" => [
"price" => "Price"
],
"estimate" => false
];
if( isset(Yii::app()->session["costum"]["form"]["params"][$kunik]["group"]) )
$paramsData["group"] = Yii::app()->session["costum"]["form"]["params"][$kunik]["group"];
......@@ -70,123 +71,32 @@ $properties = [
if($debug)var_dump($paramsData);
?>
<div class="form-group">
<table class="table table-bordered table-hover directoryTable" id="<?php echo $kunik?>">
<thead>
<tr>
<td colspan='<?php echo count( $properties)+2?>' ><h4 style="color:<?php echo ($titleColor) ? $titleColor : "black"; ?>"><?php echo $label.$editQuestionBtn.$editParamsBtn.$editBtnL?></h4>
<?php echo $info ?>
</td>
</tr>
<?php
if( count($answers)>0 ){ ?>
<tr>
</th>
<?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) {
$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;
?>
<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>";
}
}
$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>";
echo "<td colspan=2>".trim(strrev(chunk_split(strrev($total),3, ' ')))." €</td>";
echo "</tr>";
Yii::app()->session["totalBudget"] = $total;
}
<?php
echo $this->renderPartial("survey.views.tpls.forms.cplx.tableView",
[
"form" => $form,
"wizard" => true,
"answers"=>$answers,
"answer"=>$answer,
"mode" => $mode,
"kunik" => $kunik,
"key" => $key,
"titleColor" => $titleColor,
"properties" => $properties,
"label" => $label,
"editQuestionBtn" => $editQuestionBtn,
"editParamsBtn" => $editParamsBtn,
"editBtnL" => $editBtnL,
"info" => $info,
//"showForm" => $showForm,
"paramsData" => $paramsData,
"canEdit" => $canEdit,
//"el" => $el
] ,true );
?>
</tbody>
</table>
</div>
<?php if( $paramsData["estimate"] ) { ?>
<div class="form-estimate" style="display:none;">
......@@ -195,7 +105,11 @@ if($total > 0){
Durée : <br/>
<input type="text" id="daysEstimate" name="daysEstimate" style="width:100%;">
</div>
<?php } ?>
<?php }
if($mode != "r"){
?>
<script type="text/javascript">
......@@ -414,4 +328,9 @@ $(document).ready(function() {
</script>
<?php } else {
//echo "<h4 class='text-red'>CALENDAR works with existing answers</h4>";
} ?>
\ No newline at end of file
}
}
?>
\ No newline at end of file
......@@ -148,8 +148,8 @@ if($total > 0){
echo "</tr>";
echo "<tr class='bold'>";
echo "<td colspan=5 style='text-align:right'>BUDGET TOTAL : </td>";
echo "<td colspan=2>".trim(strrev(chunk_split(strrev($total),3, ' ')))." €</td>";
echo "<td colspan='5' style='text-align:right'>BUDGET TOTAL : </td>";
echo "<td colspan='2'>".trim(strrev(chunk_split(strrev($total),3, ' ')))." €</td>";
echo "</tr>";
Yii::app()->session["totalBudget"] = $total;
......
......@@ -183,8 +183,8 @@ if($total > 0){
echo "</tr>";
echo "<tr class='bold'>";
echo "<td colspan=5 style='text-align:right'>FINANCEMENT TOTAL : </td>";
echo "<td colspan=2>".trim(strrev(chunk_split(strrev($total),3, ' ')))." €</td>";
echo "<td colspan='5' style='text-align:right'>FINANCEMENT TOTAL : </td>";
echo "<td colspan='2'>".trim(strrev(chunk_split(strrev($total),3, ' ')))." €</td>";
echo "</tr>";
}
......
......@@ -280,7 +280,7 @@ if($totalFunded > 0){
echo "<tr class='bold'>";
echo "<td colspan=".count($properties)." style='text-align:right'>TOTAL FINANCÉ: </td>";
echo "<td colspan=2>".trim(strrev(chunk_split(strrev($totalFunded),3, ' ')))." €</td>";
echo "<td colspan='2'>".trim(strrev(chunk_split(strrev($totalFunded),3, ' ')))." €</td>";
echo "</tr>";
}
......@@ -289,7 +289,7 @@ if($total > 0){
echo "<tr class='bold'>";
echo "<td colspan=".count($properties)." style='text-align:right'>TOTAL À FINANCER : </td>";
echo "<td colspan=2>".trim(strrev(chunk_split(strrev($total),3, ' ')))." €</td>";
echo "<td colspan='2'>".trim(strrev(chunk_split(strrev($total),3, ' ')))." €</td>";
echo "</tr>";
}
......
......@@ -71,8 +71,8 @@ $properties = [
if(isset($a["indicateur"])){
//foreach ($a["indicateur"] as $kA => $valA) {
echo "<tr>".
//"<td id='indic".$ct."' rowspan=2 style='vertical-align : middle;text-align:center;'>".( !empty($indicateurs[$valA]) ? $indicateurs[$valA] : "" )."</td>".
"<td id='indic".$ct."' rowspan=2 style='vertical-align : middle;text-align:center;'>".( !empty($indicateurs[$a["indicateur"]]) ? $indicateurs[$a["indicateur"]] : "" )."</td>".
//"<td id='indic".$ct."' rowspan='2' style='vertical-align : middle;text-align:center;'>".( !empty($indicateurs[$valA]) ? $indicateurs[$valA] : "" )."</td>".
"<td id='indic".$ct."' rowspan='2' style='vertical-align : middle;text-align:center;'>".( !empty($indicateurs[$a["indicateur"]]) ? $indicateurs[$a["indicateur"]] : "" )."</td>".
"<td>Objectif</td>".
"<td style='vertical-align : middle;text-align:center;background-color:grey;'></td>";
foreach ($paramsData["keys"] as $i => $k) {
......@@ -81,7 +81,7 @@ $properties = [
}
?>
<td rowspan=2 >
<td rowspan='2' >
<?php
$this->renderPartial( "survey.views.tpls.forms.cplx.editDeleteLineBtn" , [
......
<?php
$value = (!empty($answer) && isset($answer["answers"][$key]) && $answer["answers"][$key] ) ? "selected" : "";
$inpClass = "";
if($saveOneByOne)
$inpClass = " saveOneByOne";
......
<?php
$colspanplus = (($mode == "r") ? 0 : 2);
?>
<div class="form-group">
<?php
if($mode == "r"){ ?>
<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
} ?>
<table class="table table-bordered table-hover directoryTable" id="<?php echo $kunik?>">
<thead>
<?php
if( count($answers)>0 ){ ?>
<tr>
<?php
foreach ($properties as $i => $inp) {
echo "<th>".$inp["placeholder"]."</th>";
} ?>
<?php
if($mode != "r"){ ?>
<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;
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>";
}
}
$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'>";