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

added taks list into answers

parent a3844d89
<style type="text/css">
#allAnswersList,.communityList ul{ list-style: none }
#allAnswersList,.communityList ul,.tasksList ul{ 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="javascript:;" id="globalCommunityBtn" class=' 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>
......@@ -33,6 +33,9 @@
$icon = "folder-open-o";
$localLinks = [];
$uids = [];
$todo = 0;
$done = 0;
$tasksPerson = [];
if(!isset($ans["answers"])) {
$lblp = "no answers" ;
$percent = 0;
......@@ -49,6 +52,31 @@
$step = $f['name'];
//echo "|".$f['id']."-ai=".count( $ans["answers"][$f['id']] )."<br/>";
}
//todo lists are on depense for the moment
//todo genereaclly not with a fixed input ID
if( isset( $ans["answers"][$fid]["depense"] ) )
{
foreach ( $ans["answers"][$fid]["depense"] as $ix => $dep)
{
if( isset( $dep["todo"] ) )
{
foreach ($dep["todo"] as $ixx => $t)
{
if(!isset($t["done"]) || $t["done"] == "0")
{
$todo++;
if( !isset( $tasksPerson[ $t["who"] ] ) )
$tasksPerson[ $t["who"] ] = [];
$tasksPerson[ $t["who"] ][] = $t["what"];
}
else
$done++;
}
}
}
}
}
if(isset($ans["links"]))
{
......@@ -56,6 +84,8 @@
{
if(!isset($localLinks[$type]))
$localLinks[$type] = [];
if(!isset($globalLinks[$type]))
$globalLinks[$type] = [];
foreach ($ls as $uid => $time) {
if(is_string($uid) && strlen($uid) == 24 && ctype_xdigit($uid)){
......@@ -63,6 +93,8 @@
$localLinks[$type][] = $uid;
if(!in_array($uid, $uids ))
$uids[] = new MongoId( $uid );
if(!in_array($uid, $globalLinks[$type] ))
$globalLinks[$type][] = $uid;
if(!in_array($uid, $gUids ))
$gUids[] = new MongoId( $uid );
}
......@@ -97,9 +129,12 @@
<br/>
<?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>
<a href="javascript:;" data-id='<?php echo $ans["_id"] ?>' class='answerCommunityBtn margin-5 btn btn-xs btn-default '> <i class="fa fa-group "></i>Communauté <span class="margin-5 label label-primary"> <?php echo count($uids) ?> </span></a>
<?php if ( count($tasksPerson)) {?>
<a href="javascript:;" data-id='<?php echo $ans["_id"] ?>' class='answerTasksBtn margin-5 btn btn-xs btn-default '> <i class="fa fa-cogs "></i>Tasks <span class="margin-5 label label-primary"> <i class="fa fa-square-o"></i> <?php echo $todo ?> </span> <span class="margin-5 label label-success"> <i class="fa fa-check-square-o"></i> <?php echo $done ?> </span></a>
<?php } ?>
<a href="#dashboard.answer.<?php echo $ans["_id"] ?>" class='margin-5 lbh btn btn-xs btn-default '> <i class="fa fa-pie-chart "></i> Observatoire Local</a>
<?php } ?>
</div>
......@@ -121,14 +156,41 @@
}
}?>
</div>
<?php if ( count($tasksPerson)) {?>
<div id="tasks<?php echo $ans["_id"] ?>" class="tasksList col-xs-12 col-lg-offset-2 col-lg-8 hide">
<?php
foreach ($tasksPerson as $person => $ls) {
echo "<h5>".$person."</h5><ul>";
foreach ($ls as $ix => $t) {
echo "<li>".$t."</li>";
}
echo "</ul><hr>";
}?>
</div>
<?php } ?>
</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>
<div id="globalCommunity" class="col-xs-12 col-lg-offset-2 col-lg-8 hide">
<?php
if( count($gUids) ){
$people = PHDB::find(Person::COLLECTION,["_id" => array( '$in'=>$gUids )], ["name","username"]);
foreach ($globalLinks 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>
<script type="text/javascript">
jQuery(document).ready(function() {
......@@ -168,11 +230,21 @@ jQuery(document).ready(function() {
$('#showAnswerBtn').off().on("click",function() {
$("#allAnswersContainer").toggleClass("hide");
$('#<?php echo @$wizid ?>').toggleClass("hide");
$('#globalCommunity').addClass("hide");
});
$('#globalCommunityBtn').off().on("click",function() {
$("#allAnswersContainer").addClass("hide");
$('#<?php echo @$wizid ?>').addClass("hide");
$('#globalCommunity').removeClass("hide");
});
$('.answerCommunityBtn').off().on("click",function() {
$( "#community"+$(this).data("id") ).toggleClass("hide");
});
$('.answerTasksBtn').off().on("click",function() {
$( "#tasks"+$(this).data("id") ).toggleClass("hide");
});
......
......@@ -466,10 +466,25 @@ echo "<h4 style='color:".(($titleColor) ? $titleColor : "black")."'>Suivi des d
<br/> -->
<form id="form-add-todo" class="form-add-todo">
<!-- <label for="todo">To do:</label> -->
<input type="text" id="new-todo-item" class="new-todo-item col-xs-6" name="todo" placeholder="Quoi" />
<input type="date" id="new-todo-item-date" class="new-todo-item-date col-xs-4" name="when" placeholder="Pour quand"/>
<input type="text" id="new-todo-item-who" class="new-todo-item-who col-xs-2" name="who" placeholder="Qui"/>
<!-- <input type="submit" id="add-todo-item" class="add-todo-item" value="ADD" /> -->
<?php
$uids = [];;
foreach (array_keys($el["links"]["members"]) as $ix => $id) {
$uids[] = new MongoId($id);
}
$members = PHDB::find ( Person::COLLECTION, [ "_id" => [ '$in' => $uids ] ] , ["name","username"] );
?>
<!-- <textarea id="new-todo-item" class="new-todo-item col-xs-5" name="todo" placeholder="Quoi"></textarea> -->
<input type="text" id="new-todo-item" class="new-todo-item col-xs-5" name="todo" placeholder="Quoi"/>
<input type="date" id="new-todo-item-date" class="new-todo-item-date col-xs-3" name="when" placeholder="Pour quand"/>
<!-- <input type="text" id="new-todo-item-who" class="new-todo-item-who col-xs-2" name="who" placeholder="Qui"/> -->
<select id="new-todo-item-who" class="new-todo-item-who col-xs-4" multiple>
<?php
foreach ( $members as $id => $p ) {
$selected = ( $id == Yii::app()->session["userId"] ) ? "selected" : "";
echo "<option value='".$p["username"]."' data-id='".$id."' ".$selected." >".$p["name"]."</option>";
}
?>
</select>
</form>
<form id="form-todo-list">
......@@ -867,13 +882,17 @@ $(document).ready(function() {
e.preventDefault();
addTodoItem()
});
$(".bootbox #new-todo-item, .bootbox #new-todo-item-when, .bootbox #new-todo-item-who").off().on('keypress', function(e){
$(".bootbox #new-todo-item, .bootbox #new-todo-item-when,.bootbox #new-todo-item-who ").off().on('keypress', function(e){
var keycode;
if (window.event) {keycode = window.event.keyCode;e=event;}
else if (e){ keycode = e.which;}
if(keycode=="13")
if( keycode=="13" )
addTodoItem();
});
// $(".bootbox #new-todo-item-who").bind('keypress',function(e) {
// if(e.which === 13)
// addTodoItem();
// });
$(".bootbox #todo-list").on('click', '.todo-item-delete', function(e){
var item = this;
deleteTodoItem(e, item)
......
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