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

Form : Hotfix pdf + Hotfix csv + Refactor admin/directory answer/directory and csv

parent 805283e7
......@@ -19,7 +19,7 @@ class DirectoryAction extends CAction
if(isset($answers["count"]))
$res["count"]=$answers["count"];
$res["results"] = $answerList ;
$res["what"] = (isset($params["form"]["what"])) ? $params["form"]["what"] : "réponses";
//$res["what"] = (isset($params["form"]["what"])) ? $params["form"]["what"] : "réponses";
//$el = Slug::getElementBySlug( $res["form"]["parentSlug"] );
//$el=Form::getFirstParentForm($res["form"]);
//$res['el'] = Form::getFirstParentForm($res["form"]);
......
......@@ -15,48 +15,28 @@ class DirectoryAction extends CAction
if(@$_POST["page"]){
$limitMin=$limitMin+(100*($_POST["page"]-1));
}
$search="";
if(!empty($_POST["name"])){
$search = trim(urldecode($_POST['name']));
}
$panelAdmin["context"] = array( "id" => $_POST["id"],
"collection" => $_POST["collection"],
"slug" => $_POST["slug"] );
$queryForm = array("parent.".$_POST["id"] => array('$exists' => 1 ) );
if(!empty($controller->costum) && !empty($controller->costum["slug"]))
$queryForm = array('$and' => array( $queryForm , array("source.key" => $controller->costum["slug"]) ) ) ;
$forms = PHDB::find(Form::COLLECTION, $queryForm , array("name") );
$forms = PHDB::find(Form::COLLECTION, $queryForm , array("name", "mapping") );
$idFs = array();
foreach ($forms as $keyF => $valF) {
$idFs[] = $keyF;
}
$res = Form::getBySourceAndId($controller->costum["slug"]);
$query=array( "form"=>array('$in' => $idFs) );
$searchRegExp = Search::accentToRegex($search);
$querySearch = array();
if(!empty($querySearch))
$query = array('$and' => array( $query , $querySearch ) ) ;
$searchParams = $_POST;
$searchParams["count"] = true;
$answers=Answer::globalAutocomplete($res["form"], $searchParams);
$answerList = Form::listForAdmin($answers["results"]) ;
$answerList = Answer::getDataAnswers($answerList, $res["forms"]);
if(!empty($panelAdmin['filters'])){
$query = Search::searchFilters($panelAdmin['filters'], $query);
}
$panelAdmin["context"] = array( "id" => $_POST["id"],
"collection" => $_POST["collection"],
"slug" => $_POST["slug"] );
if(!empty($controller->costum) && !empty($controller->costum["slug"]))
$query = array('$and' => array( $query , array("source.key" => $controller->costum["slug"]) ) ) ;
//Rest::json($query); exit;
$params["typeDirectory"]=[ Answer::COLLECTION ];
$params["results"] = array();
$answers = PHDB::findAndLimitAndIndex ( Answer::COLLECTION , $query, $stepLim, $limitMin);
$answerList = Form::listForAdmin($answers) ;
foreach ($answerList as $key => $value) {
$answerList[$key]["countComment"] = PHDB::count(Comment::COLLECTION, array("contextId"=>$key,"contextType"=>Answer::COLLECTION));
}
$params["results"]["count"][Answer::COLLECTION] = PHDB::count( Answer::COLLECTION , $query);
$params["results"]["count"] = $answers["count"];
$params["results"][Answer::COLLECTION] = $answerList ;
$params["panelAdmin"] = $panelAdmin;
$page = "groupAdmin";
......@@ -64,7 +44,5 @@ class DirectoryAction extends CAction
Rest::json( $params );
else if(Yii::app()->request->isAjaxRequest)
echo $controller->renderPartial("costum.views.custom.default.".$page,$params,true);
}
}
......@@ -172,13 +172,11 @@ class Answer{
}
$answerList[$key]["countComment"] = PHDB::count(Comment::COLLECTION, array("contextId"=>$key,"contextType"=>Form::ANSWER_COLLECTION));
$localLinks = [];
$uids = [];
$todo = 0;
$done = 0;
$tasksPerson = [];
// $imgAnsw=(isset($ans["profilMediumImageUrl"])) ? Yii::app()->createUrl($ans["profilMediumImageUrl"]) : Yii::app()->getModule( Yii::app()->params["module"]["parent"] )->getAssetsUrl()."/images/thumbnail-default.jpg";
if(!isset($ans["answers"])) {
$percent = 0;
} else {
......@@ -186,10 +184,8 @@ class Answer{
$answeredInputs = 0;
foreach ($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] );
//echo "|".$f['id']."-ai=".count( $ans["answers"][$f['id']] )."<br/>";
}
//todo lists are on depense for the moment
......@@ -211,7 +207,6 @@ class Answer{
$done++;
}
}
}
}
}
......@@ -223,16 +218,6 @@ class Answer{
if(!isset($globalLinks[$type]))
$globalLinks[$type] = [];
// if($type == "operators"){
// $lblstate = "Opérateur à valider";
// $statecol = "warning";
// foreach ($ls as $oid => $ov) {
// if($ov != "0"){
// $lblstate = "Opérateur OK";
// $statecol = "primary";
// }
// }
// }
foreach ($ls as $uid => $time) {
if(is_string($uid) && strlen($uid) == 24 && ctype_xdigit($uid)){
if(!in_array($uid, $localLinks[$type] ))
......@@ -255,7 +240,7 @@ class Answer{
$answerList[$key]["todo"] = $todo;
$answerList[$key]["done"] = $done;
$answerList[$key]["tasksPerson"] = $tasksPerson;
$answerList[$key]["canEdit"] = self::canEdit( $ans, $ans["form"], Yii::app()->session["userId"]) ;
$answerList[$key]["canEdit"] = self::canEdit( $ans, null, Yii::app()->session["userId"]) ;
}
}
return $answerList;
......@@ -265,7 +250,7 @@ class Answer{
public static function csv($elements, $idElt, $valElt, $forms ){
$elements[$idElt]["id"] = $idElt;
$elements[$idElt]["user"] = $valElt["user"];
$elements[$idElt]["created"] = $valElt["created"];
$elements[$idElt]["created"] = date("d/m/Y", $valElt["created"]);
if(!empty($valElt["answers"])){
foreach ($forms as $keyF => $valF) {
if(!empty($valF["id"]) && !empty($valElt["answers"][$valF["id"]])){
......
......@@ -663,6 +663,7 @@ class Form {
$form = $params["form"] ;
else
$form = PHDB::findOneById( Form::COLLECTION, $_GET["form"] );
$params["parentForm"] = $form;
$communityLinks = array();
if(!empty($form["parent"])){
......
......@@ -166,7 +166,7 @@ if( $mode != "pdf" ){
<?php } ?>
</div>
<?php }
}
?>
<script type="text/javascript">
......@@ -285,3 +285,6 @@ if( $mode != "pdf" ){
</script>
<?php
}
?>
\ No newline at end of file
<?php
$styleT = ( ($mode == "pdf") ? " border : 1px solid black ;" : "");
//$styleT = ( ($mode == "pdf") ? " border : 1px solid black ;" : "");
//var_dump($styleT);
$colspanplus = (($mode == "r" || $mode == "pdf") ? 0 : 2);
?>
......@@ -16,8 +16,7 @@ $colspanplus = (($mode == "r" || $mode == "pdf") ? 0 : 2);
<?php echo $info ?>
<?php
} ?>
<table class="table table-bordered table-hover directoryTable" id="<?php echo $kunik ; ?>"
>
<table class="table table-bordered table-hover directoryTable" id="<?php echo $kunik ; ?>" >
<thead>
<?php
......@@ -95,46 +94,40 @@ $colspanplus = (($mode == "r" || $mode == "pdf") ? 0 : 2);
}
}
$totalMap = [];
foreach ( $properties as $i => $inp ) {
$totalMap = [];
foreach ( $properties as $i => $inp ) {
if( isset($inp["propType"]) && $inp["propType"] == "amount" )
$totalMap[$i] = 0;
}
}
if(isset($answers)){
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 ) {
$total = 0;
foreach ( $totalMap as $i => $tot ) {
if( $tot != 0 )
$total = $total + $tot ;
}
if($total > 0){
}
if($total > 0){
echo "<tr class='bold'>";
echo "<td colspan=".(count( $paramsData["amounts"] )+2)." style='text-align:right'> TOTAL : </td>";
echo '<td colspan="'.(count( $paramsData["amounts"] )+2).'" style="text-align:right"> TOTAL : </td>';
if($mode != "r" && $mode != "pdf")
echo "<td colspan='".$colspanplus."''>".trim(strrev(chunk_split(strrev($total),3, ' ')))." €</td>";
echo "<td colspan='".$colspanplus."'>".trim(strrev(chunk_split(strrev($total),3, ' ')))." €</td>";
else
echo "<td>".trim(strrev(chunk_split(strrev($total),3, ' ')))." €</td>";
echo "</tr>";
//Yii::app()->session["totalBudget"] = $total;
}
}
?>
?>
</tbody>
</table>
</div>
\ No newline at end of file
<?php
$styleT = ( ($mode == "pdf") ? " border : 1px solid black ;" : "");
$colspanplus = (($mode == "r" || $mode == "pdf") ? 0 : 2);
?>
<div class="form-group">
<?php
if($mode == "r" || $mode == "pdf"){ ?>
......@@ -31,6 +26,8 @@ $colspanplus = (($mode == "r" || $mode == "pdf") ? 0 : 2);
<?php
if($mode != "r" && $mode != "pdf"){ ?>
<th></th>
<?php } else { ?>
<th>State</th>
<?php } ?>
</tr>
<?php } ?>
......@@ -157,7 +154,6 @@ $colspanplus = (($mode == "r" || $mode == "pdf") ? 0 : 2);
echo $tds;
if($mode != "r" && $mode != "pdf"){ ?>
<td>
<?php
$color = "default";
......@@ -187,6 +183,14 @@ $colspanplus = (($mode == "r" || $mode == "pdf") ? 0 : 2);
</td>
<?php
}else{ ?>
<td>
<?php
if(!empty($a["validFinal"]["valid"]))
echo $a["validFinal"]["valid"];
?>
</td>
<?php
}
$ct++;
echo "</tr>";
......
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