Commit 26955d0a authored by Raph El's avatar Raph El
Browse files

Merge branch 'development' of https://gitlab.adullact.net/pixelhumain/costum into development

parents f933661c 8d56508c
......@@ -7,7 +7,7 @@
"isMultiForms" : true,
"sourceKey" : true,
"class" : {
"function" : [ "init", "generateAnswerBeforeSave" ]
"function" : [ "getCheckCustomUser", "generateAnswerBeforeSave", "canSeeAnswer" ]
},
"dynForm" : {
"jsonSchema" : {
......@@ -54,11 +54,10 @@
"dropdownResult":true,
"useMapBtn":false
},
"#dossier":{
"#dossiers":{
"icon" : "",
"module":"survey",
"hash" : "#answer.index",
"hash":"#app.view",
"urlExtra" : "/page/dossiers/url/costum.views.custom.deal.dossiers",
"useHeader" : true,
"useFilter" : false,
"useFooter" : true,
......@@ -66,9 +65,8 @@
"dropdownResult":true,
"subdomainName" : "Dossiers",
"restricted" : {
"admins":true
"roles":["Opérateur"]
},
"placeholderMainSearch" : "what are you looking for ?",
"useMapBtn":false
},
......
......@@ -22,31 +22,22 @@
"type" : "openForm",
"name" : "Dossier",
"inputs" : {
"deal13" : {
"label" : "Dossier rempli par",
"type" : "text"
},
"email" : {
"label" : "Dossier emane de ",
"placeholder" : "Enter email",
"deal11" : {
"label" : "Nature des travaux",
"type" : "sectionTitle"
},
"deal111" : {
"label" : "Nom de votre dossier",
"placeholder" : "Entrer un nom",
"type" : "text",
"info" : "It seems that perfection is reached not when there is nothing left to add, but when there is nothing left to take away - Antoine de Saint Exupéry"
"info" : ""
},
"deal13x" : {
"label" : "Date de l'ouverture de dossier",
"type" : "date"
},
"deal2adrs" : {
"label" : "Adresse",
"type" : "tpls.forms.cplx.address"
},
"deal14" : {
"label" : "Décrire la nature des travaux",
"deal112" : {
"label" : "Description des travaux",
"type" : "textarea"
},
"deal15" : {
"label" : "Ajouter une image à votre projet",
"deal113" : {
"label" : "Ajouter une image pour votre dossier",
"placeholder" : "",
"info" : "",
"type" : "tpls.forms.uploader",
......@@ -58,7 +49,36 @@
"itemLimit" : 1
}
},
"deal16" : {
"deal114" : {
"label" : "Adresse du bien",
"type" : "tpls.forms.cplx.address"
},
"deal12" : {
"label" : "Informations de contact",
"type" : "sectionTitle"
},
"deal121" : {
"label" : "Nom du propriétaire",
"type" : "text"
},
"deal122" : {
"label" : "Email de contact",
"placeholder" : "Entrer email",
"type" : "text",
"info" : ""
},
"deal123" : {
"label" : "Numéro de contact",
"placeholder" : "Entrer un numéro",
"type" : "text",
"info" : ""
},
"deal124" : {
"label" : "Date de l'ouverture de dossier",
"type" : "date"
},
"deal13" : {
"label" : "Opérateur",
"placeholder" : "",
"info" : "",
......@@ -127,10 +147,6 @@
"type" : "tpls.forms.select"
},
"deal29" : {
"label" : "Nature des travaux",
"type" : "sectionTitle"
},
"deal24x" : {
"label" : "parcelle",
"type" : "text"
......@@ -207,6 +223,7 @@
"deal4",
"deal5"
],
"title" : "deal1.deal111",
"rules" : {
"deal2" : {
"roles" : [
......
......@@ -416,7 +416,7 @@ var_dump("id ".$id);
}
if(!empty($costumRoles))
$costumUserArray["hasRoles"]=$costumRoles;
$costumUserArray=Costum::sameFunction("getCheckCustomUser", $costumUserArray);
//
$costumUserArray=Costum::checkUserPreferences($costumUserArray, Yii::app()->session["userId"], $c["slug"]);
......
......@@ -2,24 +2,38 @@
class Deal {
public static function init($params){
public static function getCheckCustomUser($params){
$links=Element::getElementById(Yii::app()->session["userId"], Person::COLLECTION, null, array("links"));
$costumRoles=array();
$costum = CacheHelper::getCostum();
if(isset($links["links"]["memberOf"])){
if(isset($params["communityLinks"]["members"])){
if(isset($costum["communityLinks"]["members"])){
foreach($links["links"]["memberOf"] as $k =>$v){
if(!empty($v["isAdmin"]) && !isset($v["isAdminPending"]) && isset($params["communityLinks"]["members"][$k]["roles"])){
$costumRoles=array_merge($costumRoles, $params["communityLinks"]["members"][$k]["roles"]);
if(!empty($v["isAdmin"]) && !isset($v["isAdminPending"]) && isset($costum["communityLinks"]["members"][$k]["roles"])){
if(in_array("Opérateur", $costum["communityLinks"]["members"][$k]["roles"])){
$elt=Element::getElementById($k, $v["type"], null, array("name","slug", "profilThumbImageUrl"));
$operator=$elt;
}
if(in_array("Financeur", $costum["communityLinks"]["members"][$k]["roles"])){
$elt=Element::getElementById($k, $v["type"], null, array("name","slug", "profilThumbImageUrl"));
$financor=$elt;
}
$costumRoles=array_merge($costumRoles, $costum["communityLinks"]["members"][$k]["roles"]);
}
}
}
}
if(!empty($costumRoles))
$params["hasRoles"]=$costumRoles;
return $params;
if(isset($operator))
$params["operatorOf"]=$operator;
if(isset($financor))
$params["financorOf"]=$financor;
return $params;
}
public static function canSeeAnswer($ans){
return Form::canFormAccess(array("roles"=>["Opérateur", "Financeur"]));
}
public static function generateAnswerBeforeSave($params){
return $params;
......
......@@ -37,12 +37,19 @@
.notifications-dash .btn-notification-action{
display: none;
}
@media (max-width: 792px){
.menu-dashboard{
display:none;
width: 90%;
}
}
.dashboard-modal-content h1, .dashboard-modal-content h3{
color: white;
}
.dashboard-modal-content .dash-answers{
display: none;
}
</style>
<div class="col-md-3 col-sm-4 margin-bottom-20 menu-dashboard">
<?php $imgPath=(isset(Yii::app()->session["user"]["profilMediumImageUrl"]) && !empty(Yii::app()->session["user"]["profilMediumImageUrl"])) ? Yii::app()->createUrl(Yii::app()->session["user"]["profilMediumImageUrl"]): $this->module->getParentAssetsUrl()."/images/thumbnail-default.jpg"; ?>
......@@ -57,7 +64,7 @@
<a href="<?php echo Yii::app()->createUrl("/co2/person/logout?slug=deal") ?>" class="btn-dash-link col-xs-12 bg-red" style="border-bottom: inherit;
border-radius: 5px;"><i class="fa fa-sign-out"></i> Déconnexion</a>
</div>
<div class="col-md-9 col-sm-8 col-xs-12">
<div class="col-md-9 col-sm-8 col-xs-12 dashboard-modal-content">
<div class="col-xs-12"><h1>Bonjour <?php echo Yii::app()->session["user"]["name"] ?></h1></div>
<div class="col-xs-12"><h3>Vos dossiers</h3></div>
<?php
......@@ -79,6 +86,7 @@
<script type="text/javascript">
jQuery(document).ready(function() {
mylog.log("pageProfil.views.notifications");
$("#showAnswerBtndashboard").trigger("click");
var url = "element/notifications/type/citoyens/id/"+userId;
ajaxPost('.notifications-dash', baseUrl+'/'+moduleId+'/'+url,
null,
......
<?php
$answs=Form::getListAnswersBy(implode("|", $this->costum["form"]["ids"]) , $this->costum["slug"], null, array("step"=>"deal1"));
$what="Dossier " ?>
<div id="allAnswersContainer" class="col-xs-12 col-lg-offset-2 col-lg-8 margin-top-20">
<?php
$lbl = "Dossier ";
$ct = 0;
$globalLinks = [];
$gUids = [];
if(!empty($answs)){
foreach ($answs as $k => $ans) {
$ct++;
$lbl = $what." ".$ct;
if(isset($this->costum["form"]["title"]))
{
$titlePath = explode( ".", $this->costum["form"]["title"] );
if(isset($ans["answers"][$titlePath[0]][$titlePath[1]]))
$lbl = $ans["answers"][$titlePath[0]][$titlePath[1]];
}
$lblp = "";
$percol = "danger";
$statecol = "danger";
$lblstate = "Pas d'opérateur";
$step = "ouvert";
$icon = "folder-open-o";
$localLinks = [];
$uids = [];
$todo = 0;
$done = 0;
$tasksPerson = [];
$nameProp=(isset($ans["answers"]["deal1"]["deal121"])) ? $ans["answers"]["deal1"]["deal121"] : "inconnu";
$descrTravaux=(isset($ans["answers"]["deal1"]["deal112"])) ? $ans["answers"]["deal1"]["deal112"] : "Aucune";
$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"])) {
$lblp = "no answers" ;
$percent = 0;
} else {
$totalInputs = 0;
$answeredInputs = 0;
//var_dump($this->costum["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"] ) )
{
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++;
$whos = (is_array($t["who"])) ? $t["who"] : explode(",",$t["who"]);
foreach ( $whos as $whoix => $who ) {
if( !isset( $tasksPerson[ $who ] ) )
$tasksPerson[ $who ] = [];
$tasksPerson[ $who ][] = $t["what"];
}
}
else
$done++;
}
}
}
}
}
if(isset($ans["links"]))
{
foreach ( $ans["links"] as $type => $ls )
{
if(!isset($localLinks[$type]))
$localLinks[$type] = [];
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] ))
$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";
$liBg = ($todo>0) ? "style='background-color:lightGreen'" : "";
?>
<div class="answerLi col-xs-12 shadow2" <?php echo $liBg ?>>
<div class="col-xs-4">
<img src="<?php echo $imgAnsw ?>" class="img-responsive">
</div>
<div class="col-xs-8">
<div class="col-xs-12 no-padding">
<h3 class="margin-top-5"> <?php echo $lbl ?></h3>
</div>
<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 col-xs-12 no-padding" style="font-size:0.8em"> <b>Déposé par :</b> <?php echo $nameProp; ?></span>
<span class="margin-5 col-xs-12 no-padding" style="font-size:0.8em"> <b>Description :</b> <?php echo $descrTravaux; ?></span>
<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 label label-<?php echo $statecol ?>"> <i class="fa fa-black-tie"></i> <?php echo $lblstate ?> </span>
<br/>
<?php if ( $percent!= 0 && count($uids)) {?>
<?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 } ?>
<?php } ?>
<div class="col-xs-12 no-padding">
<a href="#answer.index.id.<?php echo $ans["_id"] ?>.mode.rplus" class="lbh margin-top-10" style=" color: #18BC9C;font-size: 18px;text-transform: uppercase;font-weight: 800;">
Voir le dossier
</a>
</div>
</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>
</div>
<?php }
} ?>
</div>
\ No newline at end of file
......@@ -157,7 +157,7 @@ if(isset($this->costum["cms"]["color1"]))
echo $this->renderPartial($this->costum["form"]["answersTpl"],$params);
if( isset($answer) && $showForm){
$params = [
$params = [
"formList"=>$formList,
"el" => $el,
"active" => "all",
......
Supports Markdown
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