Commit 6ad2106f authored by Tibor Katelbach's avatar Tibor Katelbach
Browse files

added tasks

parent d2178359
......@@ -741,7 +741,8 @@ class Form {
$answer = $ans;
}
}
if( $answer == null && count( $myAnswers ) > 1 && !$canEdit )
if( $answer == null && count( $myAnswers ) > 1 && !$params["canEdit"] )
$showForm = false;
//si aucune reponse existe
......@@ -756,7 +757,6 @@ class Form {
if( stripos( $inp["type"] , "tpls.forms.cplx" ) !== false )
$generateAnswer = true;
}
}
}
......
......@@ -27,100 +27,105 @@
if(isset($ans["answers"][$titlePath[0]][$titlePath[1]]))
$lbl = $ans["answers"][$titlePath[0]][$titlePath[1]];
}
?>
<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 ?></a>
</div>
<?php
$lblp = "";
$percol = "danger";
$step = "ouvert";
$icon = "folder-open-o";
$localLinks = [];
$uids = [];
$todo = 0;
$done = 0;
$tasksPerson = [];
if(!isset($ans["answers"])) {
$lblp = "no answers" ;
$percent = 0;
} else {
$totalInputs = 0;
$answeredInputs = 0;
//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"][$fid] ) ){
$answeredInputs += count( $ans["answers"][$fid] );
$step = $f['name'];
//echo "|".$f['id']."-ai=".count( $ans["answers"][$f['id']] )."<br/>";
}
$lblp = "";
$percol = "danger";
$step = "ouvert";
$icon = "folder-open-o";
$localLinks = [];
$uids = [];
$todo = 0;
$done = 0;
$tasksPerson = [];
if(!isset($ans["answers"])) {
$lblp = "no answers" ;
$percent = 0;
} else {
$totalInputs = 0;
$answeredInputs = 0;
//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"][$fid] ) ){
$answeredInputs += count( $ans["answers"][$fid] );
$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"] ) )
//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)
{
foreach ( $ans["answers"][$fid]["depense"] as $ix => $dep)
if( isset( $dep["todo"] ) )
{
if( isset( $dep["todo"] ) )
foreach ($dep["todo"] as $ixx => $t)
{
foreach ($dep["todo"] as $ixx => $t)
if(!isset($t["done"]) || $t["done"] == "0")
{
if(!isset($t["done"]) || $t["done"] == "0")
{
$todo++;
if( !isset( $tasksPerson[ $t["who"] ] ) )
$tasksPerson[ $t["who"] ] = [];
$tasksPerson[ $t["who"] ][] = $t["what"];
$todo++;
foreach ( explode(",",$t["who"]) as $whoix => $who ) {
if( !isset( $tasksPerson[ $who ] ) )
$tasksPerson[ $who ] = [];
$tasksPerson[ $who ][] = $t["what"];
}
else
$done++;
}
else
$done++;
}
}
}
}
if(isset($ans["links"]))
}
if(isset($ans["links"]))
{
foreach ( $ans["links"] as $type => $ls )
{
foreach ( $ans["links"] as $type => $ls )
{
if(!isset($localLinks[$type]))
$localLinks[$type] = [];
if(!isset($globalLinks[$type]))
$globalLinks[$type] = [];
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)){
if(!in_array($uid, $localLinks[$type] ))
$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 );
}
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, $globalLinks[$type] ))
$globalLinks[$type][] = $uid;
if(!in_array($uid, $gUids ))
$gUids[] = new MongoId( $uid );
}
}
}
//echo "tot".$totalInputs."-ans".$answeredInputs;
$percent = floor( $answeredInputs*100 / $totalInputs );
$percol = "primary";
$lblp = $percent."%";
}
if( $percent > 50 )
$percol = "warning";
if( $percent > 75 )
$percol = "success";
?>
//echo "tot".$totalInputs."-ans".$answeredInputs;
$percent = floor( $answeredInputs*100 / $totalInputs );
$percol = "primary";
$lblp = $percent."%";
}
if( $percent > 50 )
$percol = "warning";
if( $percent > 75 )
$percol = "success";
$liBg = ($todo>0) ? "style='background-color:lightGreen'" : "";
?>
<li class="answerLi col-xs-12" <?php echo $liBg ?>>
<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 ?></a>
</div>
<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"] )) {?>
......
......@@ -474,17 +474,40 @@ echo "<h4 style='color:".(($titleColor) ? $titleColor : "black")."'>Suivi des d
$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>
<div class="col-xs-8">
<label for="new-todo-item">Choses à faire</label>
<input type="text" id="new-todo-item" class="new-todo-item col-xs-12" name="todo" placeholder="Quoi"/>
</div>
<div class="col-xs-4">
<label for="new-todo-item-price"> <i class='fa fa-money'></i> Cout de cette tache</label>
<input type="text" id="new-todo-item-price" class="new-todo-item-price col-xs-12" name="price" placeholder="Pour combien"/>
<!-- <select id="votes" style="width:100%;">
<option> VOTEZ pour cette partie </option>
<?php foreach ([0,10,20,30,40,50,60,70,80,90,100] as $v => $f) {
if($f == 0)
$lbl = "Je ne suis pas pour!";
else
$lbl = "Je suis pour à ".$f."%";
echo "<option value='".$f."'>".$lbl."</option>";
} ?>
</select> -->
</div>
<div class="col-xs-6">
<label for="new-todo-item-date"> <i class='fa fa-calendar'></i> Date de fin estimé :</label>
<input type="date" id="new-todo-item-date" class="new-todo-item-date col-xs-12" name="when" placeholder="Pour quand"/>
</div>
<div class="col-xs-6">
<label for="new-todo-item-who"> <i class='fa fa-user'></i> Personne(s) qui réalisera cette tache :</label>
<select id="new-todo-item-who" class="new-todo-item-who col-xs-12" 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>
</div>
</form>
<form id="form-todo-list">
......@@ -844,9 +867,12 @@ $(document).ready(function() {
tplCtx.value = [];
var todoDone = 0;
//todoArray au lieu de géré avec des li
//avoir un array avec des objets + render
$('.bootbox #todo-list').find('li').each(function() {
var t = {
what : $(this).find(".liText").text(),
price : $(this).data("price"),
uid : $(this).data("uid"),
who : $(this).data("who"),
when : $(this).data("when"),
......@@ -882,7 +908,7 @@ $(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,.bootbox #new-todo-item-price ").off().on('keypress', function(e){
var keycode;
if (window.event) {keycode = window.event.keyCode;e=event;}
else if (e){ keycode = e.which;}
......@@ -914,7 +940,7 @@ $(document).ready(function() {
var todos = eval( todoPath );
mylog.log("build todos",todos);
$.each(todos, function(ix,todo) {
buildTodo( todo.what, ( ( parseInt(todo.done) ) ? "checked" : "" ),todo.uid,todo.who,todo.created,todo.when );
buildTodo(ix, todo.what,todo.price, ( ( parseInt(todo.done) ) ? "checked" : "" ),todo.uid,todo.who,todo.created,todo.when );
})
}
})
......@@ -928,30 +954,48 @@ function addTodoItem() {
var today = new Date();
today = today.getDate() + '/' + (today.getMonth()+1) + '/' + today.getFullYear();
var when = ($(".bootbox #new-todo-item-date").val()) ? $(".bootbox #new-todo-item-date").val() : "";
var price = ($(".bootbox #new-todo-item-price").val()) ? $(".bootbox #new-todo-item-price").val() : "";
var who = ($(".bootbox #new-todo-item-who").val()) ? $(".bootbox #new-todo-item-who").val() : userConnected.name ;
buildTodo($(".bootbox #new-todo-item").val(), "",userId, who, today,when);
buildTodo(editingItem,$(".bootbox #new-todo-item").val(),price, "",userId, who, today,when);
$(".bootbox #new-todo-item, .bootbox #new-todo-item-when").val("");
}
function buildTodo(todoItem,checked,uid,who,created,when){
if(typeof uid == "undefined") uid = userId;
if(typeof who == "undefined") who = userConnected.name;
//todoArray au lieu de géré avec des li
//avoir un array avec des objets + render
function buildTodo(pos,todoItem,price,checked,uid,who,created,when){
if(!notNull( uid)) uid = userId;
if(!notNull( who)) who = userConnected.name;
whoids = "";
if(!notNull(price)) price = "";
if(typeof when == "undefined" || when == "" )
when = "";
if(typeof created == "undefined") {
if(notNull( created)) {
var today = new Date();
created = today.getDate() + '/' + (today.getMonth()+1) + '/' + today.getFullYear();
}
$(".bootbox #todo-list").append(
"<li class='col-xs-12' data-uid='"+uid+"' data-created='"+created+"' data-who='"+who+"' data-when='"+when+"' >"+
"<div class='col-xs-1'>"+
"<a class='btn btn-xs btn-danger todo-item-delete' href='javascript:;'><i class='fa fa-times-rectangle'></i></a>"+
" <a class='btn btn-xs btn-primary todo-item-edit' href='javascript:;'><i class='fa fa-pencil'></i></a>"+
"</div>"+
"<div class='col-xs-1'><input type='checkbox' name='todo-item-done' class='todo-item-done' value='" + todoItem + "' "+checked+" /></div> " +
"<div class='col-xs-6 liText todo-item-edit' data-who='"+who+"' data-when='"+when+"'>"+todoItem +"</div>"+
"<div class='col-xs-4 todo-item-edit' data-who='"+who+"' data-when='"+when+"'>"+when+" | "+who +"</div>"+
"</li>");
if(pos === null)
pos = $(".liTodo").length - 1;
str =
"<div class='col-xs-1'>"+
"<a class='btn btn-xs btn-danger todo-item-delete' href='javascript:;'><i class='fa fa-times-rectangle'></i></a>"+
" <a class='btn btn-xs btn-primary todo-item-edit' href='javascript:;'><i class='fa fa-pencil'></i></a>"+
"</div>"+
"<div class='col-xs-1'><input type='checkbox' name='todo-item-done' class='todo-item-done' value='" + todoItem + "' "+checked+" /></div> " +
"<div class='col-xs-10 liText' >"+todoItem +"</div>"+
"<div class='col-xs-12' >"+
"<div class='col-xs-2'></div>"+
"<div class='col-xs-2' style='font-size:0.8em'> <i class='fa fa-money'></i> "+price+"</div>"+
"<div class='col-xs-3' style='font-size:0.8em'> <i class='fa fa-calendar'></i> "+when+"</div>"+
"<div class='col-xs-5' style='font-size:0.8em' > <i class='fa fa-user'></i> "+who+"</div>"+
"</div>";
if(editingItem){
$(".liText").eq(pos).parent().html(str);
editingItem = null;
}
else
$(".bootbox #todo-list").append("<li class='liTodo col-xs-12' data-pos='"+pos+"' data-uid='"+uid+"' data-created='"+created+"' data-who='"+who+"' data-whoids='"+whoids+"' data-when='"+when+"' data-price='"+price+"' >"+str+"</li>");
}
function deleteTodoItem(e, item) {
......@@ -960,11 +1004,21 @@ function deleteTodoItem(e, item) {
$(item).parent().parent().remove();
});
}
var editingItem = null;
function editTodoItem(e, item) {
e.preventDefault();
$(".bootbox #new-todo-item").val($(item).parent().parent().find(".liText").text());
$(".bootbox #new-todo-item-when").val( $(item).data("when") );
$(".bootbox #new-todo-item-who").val( $(item).data("who") );
editingItem = $(item).parent().parent().data("pos");
$(".bootbox #new-todo-item").val( $(item).parent().parent().find(".liText").text() );
$(".bootbox #new-todo-item-date").val( $(item).parent().parent().data("when") );
$(".bootbox #new-todo-item-price").val( $(item).parent().parent().data("price") );
$(".bootbox #new-todo-item-who option").prop("selected",false)
if($(item).parent().parent().data("who").indexOf(",")){
whosT = $(item).parent().parent().data("who").split(",");
$.each(whosT,function(i,u){
$(".bootbox #new-todo-item-who option[value='"+u+"']").prop("selected",true)
})
}else
$(".bootbox #new-todo-item-who").val( $(item).parent().parent().data("who") );
}
......
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