Commit cae06e0c authored by Tibor Katelbach's avatar Tibor Katelbach
Browse files

added comunity activity and links to answers based on activity

parent 7734212a
<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");
$('#<?php echo $wizid ?>').toggleClass("hide");
})
<?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>
\ No newline at end of file
<style type="text/css">
#allAnswersList{ list-style: none }
#allAnswersList,.communityList ul{ list-style: none }
#allAnswersList li{ padding:5px; border-bottom: 1px solid #ccc; }
</style>
......@@ -7,7 +7,7 @@
<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="/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>
<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">
......@@ -15,6 +15,8 @@
<?php
$lbl = $what." ";
$ct = 0;
$globalLinks = [];
$gUids = [];
if(!empty($allAnswers)){
foreach ($allAnswers as $k => $ans) {
$ct++;
......@@ -22,29 +24,55 @@
<li class="answerLi col-xs-12" >
<div class="col-xs-3 text-center">
<a href="/costum/co/index/slug/<?php echo $el["slug"] ?>/answer/<?php echo $ans["_id"] ?>"> <?php echo $lbl." ".$ct ?></a>
<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";
$step = "ouvert";
$icon = "folder-open-o";
$localLinks = [];
$uids = [];
if(!isset($ans["answers"])) {
$lblp = "no answers" ;
$percent = 0;
} else {
$totalInputs = 0;
$answeredInputs = 0;
foreach (Yii::app()->session["forms"] as $ix => $f)
//var_dump(Yii::app()->session["forms"]);
foreach (Yii::app()->session["forms"] as $fid => $f)
{
$totalInputs += count($f["inputs"]);
//echo "|".$f['id']."-fi=".count($f["inputs"]);
if( isset( $ans["answers"][$f['id']] ) ){
$answeredInputs += count( $ans["answers"][$f['id']] );
if( isset( $ans["answers"][$fid] ) ){
$answeredInputs += count( $ans["answers"][$fid] );
$step = $f['name'];
//echo "|".$f['id']."-ai=".count( $ans["answers"][$f['id']] )."<br/>";
}
}
if(isset($ans["links"]))
{
foreach ( $ans["links"] as $type => $ls )
{
if(!isset($localLinks[$type]))
$localLinks[$type] = [];
foreach ($ls as $uid => $time) {
if(is_string($uid) && strlen($uid) == 24 && ctype_xdigit($uid)){
if(!in_array($uid, $localLinks[$type] ))
$localLinks[$type][] = $uid;
if(!in_array($uid, $uids ))
$uids[] = new MongoId( $uid );
if(!in_array($uid, $gUids ))
$gUids[] = new MongoId( $uid );
}
}
}
}
//echo "tot".$totalInputs."-ans".$answeredInputs;
$percent = floor($answeredInputs*100/$totalInputs);
$percent = floor( $answeredInputs*100 / $totalInputs );
$percol = "primary";
$lblp = $percent."%";
}
......@@ -55,25 +83,100 @@
$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 if ( isset($ans["updated"] )) {?>
<span class="margin-5" style="font-size:0.8em"> <i class="fa fa-edit "></i> <?php echo date("d/m/y H:i",$ans["updated"]); ?></span>
<?php } ?>
<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>
<span class="margin-5 "> <i class="fa fa-calendar"></i> <?php echo date("d/m/y H:i",$ans["created"]); ?></span>
<br/>
<?php if ( $percent!= 0) {?>
<a href="#dashboard.answer.<?php echo $ans["_id"] ?>" class='margin-5 lbh btn btn-default margin-left-5'> <i class="fa fa-group "></i>Communauté <span class="margin-5 label label-primary"> 3 </span></a>
<?php if ( $percent!= 0 && count($uids)) {?>
<a href="javascript:;" data-id='<?php echo $ans["_id"] ?>' class='answerCommunityBtn margin-5 btn btn-default '> <i class="fa fa-group "></i>Communauté <span class="margin-5 label label-primary"> <?php echo count($uids) ?> </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' href=""> <i class="fa fa-trash"></i> </a>
<a class='text-red pull-right deleteAnswer' data-id="<?php echo $ans["_id"] ?>" href="javascript:;"> <i class="fa fa-trash"></i> </a>
</div>
<div id="community<?php echo $ans["_id"] ?>" class="communityList col-xs-12 col-lg-offset-2 col-lg-8 hide">
<?php
if( count($uids) ){
$people = PHDB::find(Person::COLLECTION,["_id" => array( '$in'=>$uids )], ["name","username"]);
echo "<h5>Created by : ".$people[$ans['user']]["name"]."</h5><hr>";
foreach ($localLinks as $type => $ls) {
echo "<h5>".$type."</h5><ul>";
foreach ($ls as $ix => $uid) {
echo "<li><a class='lbh' href='#@".$people[$uid]["username"]."' >".$people[$uid]["name"]."</a></li>";
}
echo "</ul><hr>";
}
}?>
</div>
</li>
<?php }
}?>
<li class="text-center"><a href="/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>
<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>
\ No newline at end of file
</div>
<script type="text/javascript">
jQuery(document).ready(function() {
mylog.log("render","/modules/costum/views/tpls/forms/cplx/answers.php");
<?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);
$("#ansline"+id).remove();
},"html");
}
},
{
label: "Annuler",
className: "btn btn-default pull-left",
callback: function() {}
}
]
});
});
<?php } ?>
$('#showAnswerBtn').off().on("click",function() {
$("#allAnswersContainer").toggleClass("hide");
$('#<?php echo $wizid ?>').toggleClass("hide");
});
$('.answerCommunityBtn').off().on("click",function() {
$( "#community"+$(this).data("id") ).toggleClass("hide");
});
});
</script>
......@@ -131,7 +131,7 @@ $properties = [
?>
<td>
<?php
$this->renderPartial( "survey.views.tpls.forms.cplx.editDeleteLineBtn" , [
$this->renderPartial( "costum.views.tpls.forms.cplx.editDeleteLineBtn" , [
"canEdit"=>($canEdit||Yii::app()->session["userId"] == $answer["user"]),
"id" => $answer["_id"],
"collection" => Form::ANSWER_COLLECTION,
......@@ -350,6 +350,7 @@ $(document).ready(function() {
mylog.log("btnEstimateSelected save",tplCtx);
dataHelper.path2Value( tplCtx, function(){
$("#price"+tplCtx.pos).html( tplCtx.price+"" );
saveLinks(answerObj._id.$id,"intentValidated",userId);
} );
} );
......@@ -390,7 +391,10 @@ $(document).ready(function() {
};
mylog.log("btnEstimate save",tplCtx);
dataHelper.path2Value( tplCtx, closePrioModalRel );
dataHelper.path2Value( tplCtx, function(){
saveLinks(answerObj._id.$id,"estimated",userId);
closePrioModalRel();
} );
}
},
cancel: {
......
......@@ -426,7 +426,9 @@ $(document).ready(function() {
delete tplCtx.pos;
delete tplCtx.budgetpath;
mylog.log("btnValidateWork save",tplCtx);
dataHelper.path2Value( tplCtx, closePrioModalRel );
dataHelper.path2Value( tplCtx, function(){
saveLinks(answerObj._id.$id,"validated",userId,closePrioModalRel);
} );
}
},
cancel: {
......@@ -467,7 +469,9 @@ $(document).ready(function() {
delete tplCtx.pos;
delete tplCtx.budgetpath;
mylog.log("btnProgress save",tplCtx);
dataHelper.path2Value( tplCtx, closePrioModalRel );
dataHelper.path2Value( tplCtx, function(){
saveLinks(answerObj._id.$id,"voted",userId);
} );
}
},
cancel: {
......
......@@ -638,7 +638,9 @@ $(document).ready(function() {
delete tplCtx.pos;
delete tplCtx.budgetpath;
mylog.log("btnValidateWork save",tplCtx);
dataHelper.path2Value( tplCtx, closePrioModalRel );
dataHelper.path2Value( tplCtx, function(){
saveLinks(answerObj._id.$id,"workValidated",userId,closePrioModalRel);
} );
}
},
cancel: {
......@@ -687,7 +689,9 @@ $(document).ready(function() {
delete tplCtx.pos;
delete tplCtx.budgetpath;
mylog.log("btnFinancer save",tplCtx);
dataHelper.path2Value( tplCtx, closePrioModal );
dataHelper.path2Value( tplCtx, function(){
saveLinks(answerObj._id.$id,"worker",userId,closePrioModal);
} );
}
},
cancel: {
......@@ -729,7 +733,9 @@ $(document).ready(function() {
delete tplCtx.pos;
delete tplCtx.budgetpath;
mylog.log("btnProgress save",tplCtx);
dataHelper.path2Value( tplCtx, closePrioModalRel );
dataHelper.path2Value( tplCtx, function(){
saveLinks(answerObj._id.$id,"workProgress",userId,closePrioModalRel);
} );
}
},
cancel: {
......@@ -778,7 +784,9 @@ $(document).ready(function() {
delete tplCtx.pos;
delete tplCtx.budgetpath;
mylog.log("btnPay save",tplCtx);
dataHelper.path2Value( tplCtx, closePrioModalRel );
dataHelper.path2Value( tplCtx, function(){
saveLinks(answerObj._id.$id,"workPayed",userId,closePrioModalRel);
} );
}
},
cancel: {
......@@ -841,7 +849,9 @@ $(document).ready(function() {
delete tplCtx.pos;
delete tplCtx.budgetpath;
mylog.log("btnPay save",tplCtx);
dataHelper.path2Value( tplCtx, closePrioModal);
dataHelper.path2Value( tplCtx, function(){
saveLinks(answerObj._id.$id,"workTodo",userId,closePrioModalRel);
});
}
},
cancel: {
......
......@@ -166,6 +166,7 @@ isMultiForms
[ ] export answers multi format
* form params
[-] costum.form params
[ ] costum.form.private //open only for oganizations community
[ ] costum.form.hasMap
shows half screen map
[X] costum.form.canReadOtherAnswers
......
......@@ -151,3 +151,13 @@ for a view accross all proposals , tasks being processed , states (proposal, fin
:event: :OBSERVATION:process:evaluation:postProject:
if success :share:recipy: :share:methodology:
certification [[https://algobeans.com/2015/06/01/you-are-who-you-like/]]
[[http://bl.ocks.org/bbest/2de0e25d4840c68f2db1]]
[[http://bl.ocks.org/NPashaP/ba4c802d5ef68f70c019a9706f77ebf1]]
[[http://xuchen-81.appspot.com/dj]]
[[]]
[[]]
[[]]
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