Commit 76e27ffb authored by Clément Damiens's avatar Clément Damiens
Browse files

Merge branch 'development' into communitySearch

parents b35be8c6 97718347
# COSTUM YOUR COMMUNECTER
This module permits to modulate and use communecter as a specific application like organized your group, exchange ressources localy or/and map wealthy of a territory or even on a thematic.<br/>
It give you multiple choices:<br/>
- Configuration which application you want<br/>
- Set your own style and graphical chart<br/>
- Have a unique interface<br/>
- Give the message define by your projects<br/>
Only one rule :**Be open and you will openly surprised**<br/>
Enjoy and contribute to the OCDB (open and collective database)
# BUILD and COSTUMIZE YOUR own COMMUNECTER
This module permits to use communecter as an engine and create your own application while reusing all CO's existing modules like organizing your community, exchange ressources localy or/and map them on a territory or organize a given thematic.<br/>
It gives you multiple choices:<br/>
- Configure which modules or apps you want<br/>
- Set your own style and graphical design adn assets<br/>
- Have a unique interface connected to your own DNS<br/>
- The is almost no limits, it's just like building a classic website but with loads of stuff already available<br/>
Only one rule :**Be open and you will be openly surprised**<br/>
# ROADMAP
......
......@@ -355,8 +355,8 @@ function sortBlock(classItem){
$.ajax({
type : 'POST',
data : {
id : costum.contextId,
collection : costum.contextType,
id : thisContextId,
collection : thisContextType,
idAndPosition : idAndPosition
},
url : baseUrl+"/costum/blockcms/dragblock",
......
......@@ -7,7 +7,7 @@ $.each(fontObj,function(k,v){
fontStyles += `
@font-face {
font-family: "${v}";
src: url("${assetPath}/font/blockcms/fontpack/${k}");
src: url("${costumAssetsPath}/font/blockcms/fontpack/${k}");
}
`;
fontOptions +=`<option style="font-family:'${v.split(' ').join('_')}'" value="${k}">${v}</option>`;
......@@ -26,7 +26,7 @@ $.each(fonts,function(k,v){
fontStyles += `
@font-face {
font-family: "${v}";
src: url("${assetPath+k}");
src: url("${costumAssetsPath+k}");
}
`;
fontOptions +=`<option style="font-family:'${v.split(' ').join('_')}'" value="${v.split(' ').join('_')}">${v}</option>`;
......
var cmsBuilder = {
init : function(){
cmsBuilder.bindEvents();
cmsBuilder.manage.delete();
$(".openListTpls").off().on("click", function(){
cmsBuilder.openModal();
});
......@@ -44,6 +45,7 @@ var cmsBuilder = {
$(".editDescBlock").off().on("click", function() {
var tplId = $(this).data("id");
var tplCtx ={};
var dynFormCostum = {
"beforeBuild":{
"properties":{
......@@ -96,9 +98,10 @@ var cmsBuilder = {
};
tplCtx.value.parent={};
tplCtx.value.parent[costum.contextId] = {
type : costum.contextType,
name : costum.contextSlug
tplCtx.value.parent[thisContextId] = {
type : thisContextType,
name : thisContextSlug
};
tplCtx.value.haveTpl = false;
if(typeof tplCtx.value == "undefined")
......@@ -241,12 +244,40 @@ var cmsBuilder = {
},
delete :function(idCms){
delete :function(){
$(".deleteLine").off().on("click",function (){
$(this).empty().html('<i class="fa fa-spinner fa-spin"></i>');
var id = $(this).data("id");
var type = $(this).data("collection");
var urlToSend = baseUrl+"/co2/element/delete/type/"+type+"/id/"+id;
bootbox.confirm(trad.areyousuretodelete,
function(result){
if (!result) {
return;
}
else {
$.ajax({
type: "POST",
url: urlToSend,
dataType : "json"
})
.done(function (data) {
if ( data && data.result ) {
toastr.success("Element effacé");
$("#"+type+id).remove();
} else {
toastr.error("something went wrong!! please try again.");
}
urlCtrl.loadByHash(location.hash);
});
}
}
);
});
},
addToTpl:function(){
}
},
}
}
\ No newline at end of file
......@@ -16,6 +16,8 @@ class CocityController extends CommunecterController {
'getfiliere' => 'costum.controllers.actions.cocity.GetFiliereAction',
'getorgafiliere' => 'costum.controllers.actions.cocity.GetOrgaFiliereAction',
'getcmscocityaction' => 'costum.controllers.actions.cocity.GetCmsCocityAction',
'graph' =>'costum.controllers.actions.cocity.GraphAction',
);
}
......
......@@ -14,7 +14,7 @@ class CommentController extends CommunecterController {
public function actionSave(){
$_POST["date"] = date("d / m / Y - H:i");
$comment = PHDB::insert("comments", $_POST);
$comment = Yii::app()->mongodb->selectCollection("comments")->insert( $_POST);
Rest::json($comment);
}
......
<?php
class CordcollaborativeopenrdController extends CommunecterController {
protected function beforeAction($action) {
//parent::initPage();
return parent::beforeAction($action);
}
public function actions(){
return array(
'dashboard' => 'costum.controllers.actions.cordCollaborativeOpenRd.DashboardAction',
'ocecodashboard' => 'costum.controllers.actions.cordCollaborativeOpenRd.OcecodashboardAction'
);
}
//public function actionPersondah
/*public function actionIndex()
{
if(Yii::app()->request->isAjaxRequest)
echo $this->renderPartial("../default/index");
else
$this->render("index");
//$this->redirect(Yii::app()->createUrl( "/".Yii::app()->params["module"]["parent"] ));
}*/
}
......@@ -18,7 +18,8 @@ class FiliereController extends CommunecterController {
$block = ["article.actualiteTimeLine", "textImg.imgLeftWithBtnRight", "annuaire.annuaireDropdown", "header.banner"];
foreach ($block as $value) {
PHDB::insert("cms", array(
$arrayInsert = array(
"name" => "actualite",
"path" => "tpls.blockCms.".$value,
"page" => "welcome",
......@@ -31,11 +32,13 @@ class FiliereController extends CommunecterController {
],
"haveTpl" => "false",
"creator" => $_POST['map']['creator']
)
);
Yii::app()->mongodb->selectCollection("cms")->insert($arrayInsert);
}
PHDB::insert("forms", array(
$formArray = array(
"name" => "Formulaire membre",
"what" => "Membre",
"parent" => [
......@@ -61,7 +64,8 @@ class FiliereController extends CommunecterController {
"oneAnswerPerPers" => "true",
"canModify" => "true",
"showAnswers" => "true"
));
);
Yii::app()->mongodb->selectCollection("forms")->insert($arrayInsert);
$htmlConstruct = array("menuLeft" => [
"buttonList" => [
......
......@@ -509,7 +509,7 @@ else
}
$check = PHDB::insert($col,$fjson);
$check = Yii::app()->mongodb->selectCollection($col)->insert($fjson);
echo $id." inserted <br/>";
}
else {
......@@ -533,7 +533,7 @@ else
$d['_id'] = new MongoId($id);
//var_dump($d);
$check = PHDB::insert($col,$d);
$check = Yii::app()->mongodb->selectCollection($col)->insert($d);
$name = "";
if( isset($d["id"]) )
$name = $d["id"];
......
<?php
class GraphAction extends CAction
{
public function run($sk=null,$answer=null,$aj="false", $territoires="[0]", $firstkey = "", $ter = "")
{
$controller = $this->getController();
$tpl = "costum.views.custom.cocity.observatory";
$projects = PHDB::find(Project::COLLECTION, array("parent.".$controller->costum["contextId"] => array('$exists'=>1)),["tags"]);
//$agricultures = PHDB::find(Organization::COLLECTION,["source.key" =>$controller->costum["contextSlug"],"tags"=>"agricultures"]);
$organization = PHDB::find(organization::COLLECTION, array("source.key"=>$controller->costum["slug"] ),["tags"]);
$event = PHDB::find(Event::COLLECTION, array("organizer.".$controller->costum["contextId"] => array('$exists'=>1)),["tags"]);
$classifieds = PHDB::find(Classified::COLLECTION, array("parent.".$controller->costum["contextId"] => array('$exists'=>1)),["tags"]);
$elementLabel = ["organization","projects","event","classifieds" ];
$elementTrueLabel = ["Organisation","projets","Evènement","annonces" ];
$nombreElement = [];
for($i = 0; $i < count($elementLabel); $i++){
$nombreElement[$i] = count(${$elementLabel[$i]});
}
$allTags = [];
$tagsOrga = [];
foreach ($organization as $key => $value) {
$tagsOrga = array_merge($value["tags"] ?? [],$tagsOrga);
}
$allTags += $tagsOrga;
$tagsProjet = [];
foreach ($projects as $key => $value) {
$tagsProjet = array_merge($value["tags"] ?? [],$tagsProjet);
}
$allTags = array_merge($tagsProjet,$allTags);
$tagsEvent = [];
foreach ($event as $key => $value) {
$tagsEvent = array_merge($value["tags"] ?? [],$tagsEvent);
}
$allTags = array_merge($tagsEvent,$allTags);
$listTags = [];
$blocks = [];
$graph = [];
$graph += ["nombrecocity" => [
"title"=>"EXISTANT DANS COCITY",
"data" => $nombreElement,
"lbls" => $elementTrueLabel,
"url" => "/graph/co/dash/g/graph.views.co.costum.cocity.barMany",
"yAxesLabel" => "Nombre "
]];
$activiteCocity = PHDB::find(ActivityStream::COLLECTION, array("source.key"=>$controller->costum["slug"] ),["tags"]);
foreach ($graph as $ki => $list) {
$kiCount = 0;
foreach ($list["data"] as $ix => $v) {
if(is_numeric($v))
$kiCount += $v;
else
$kiCount ++;
}
$blocks[$ki] = [
"title" => $list["title"],
"counter" => $kiCount,
];
if(isset($list["tpl"])){
$blocks[$ki] = $list;
}
else
$blocks[$ki]["graph"] = [
"url"=>$list["url"],
"key"=>"pieMany".$ki,
"data"=> [
"datasets"=> [
[
"data"=> $list["data"],
"backgroundColor"=> Ctenat::$COLORS
]
],
"labels"=> $list["lbls"]
]
];
if (isset($list["yAxesLabel"])) {
$blocks[$ki]["graph"]["data"]["yAxesLabel"] = $list["yAxesLabel"];
}
}
$params = [
"projects" => $projects,
"organization" => $organization,
"event" => $event,
"blocks" => $blocks,
"allTags"=> $allTags
];
if(Yii::app()->request->isAjaxRequest)
echo $controller->renderPartial($tpl,$params,true);
else {
$this->getController()->layout = "//layouts/empty";
$this->getController()->render($tpl,$params);
}
}
}
<?php
class DashboardAction extends CAction
{
public function run($sk=null,$answer=null)
{
$controller = $this->getController();
$tpl = "costum.views.custom.process.dashboard";
$answers = PHDB::find( Form::ANSWER_COLLECTION,[ //"formId" => $params["formId"],
"parentSlug" => $controller->costum["contextSlug"] ] );
$title = "Observatoire des process Opal";
$blocks = [];
if(isset($answer)){
$answer = PHDB::findOne( Form::ANSWER_COLLECTION,[ "_id" => new MongoId( $answer ) ] );
$title = (isset($answer["answers"]["opalProcess1"]["titre"])) ? "Observatoire<br/>".$answer["answers"]["opalProcess1"]["titre"] : "Observatoire spécifique";
$title = "<a href='".Yii::app()->createUrl("/costum")."/co/index/slug/".$answer["parentSlug"]."/answer/".$answer["_id"]."'>".$title."</a>";
$tasks = [
"todo" => 0,
"done" => 0,
"tasksPerson" => [],
"allTasksPerson" => []
];
$finance = [
"total" => 0,
"financed" => [
"total" => 0,
"byAmount" => [],
"byName" => [],
"colors" => []
],
"byPerson" => [],
"byBlock" => [],
"byBlockName" => [],
];
foreach (Yii::app()->session["forms"] as $fid => $f) {
if( isset( $answer["answers"][$fid]["depense"] ) ){
foreach ( $answer["answers"][$fid]["depense"] as $ix => $dep) {
if( isset( $dep["price"] ) ){
$finance["total"] += $dep["price"];
$finance["byBlock"][] = $dep["price"];
$finance["byBlockName"][] = $dep["poste"];
}
if( isset( $dep["financer"] ) ){
foreach ($dep["financer"] as $fix => $fin) {
if(isset($fin["amount"])){
$finance["financed"]["total"] += $fin["amount"];
$finance["financed"]["byAmount"][] = $fin["amount"];
$finance["financed"]["byName"][] = ( isset($fin["name"]) ) ? $fin["name"] : "?";
}
}
}
if( isset( $dep["todo"] ) ){
foreach ($dep["todo"] as $ixx => $t) {
if(!isset($t["done"]) || $t["done"] == "0"){
$tasks["todo"]++;
$whos = (is_array($t["who"])) ? $t["who"] : explode(",",$t["who"]);
foreach ($whos as $whoix => $who) {
if( !isset( $tasks["tasksPerson"][ $who ] ) )
$tasks["tasksPerson"][ $who ] = 0;
$tasks["tasksPerson"][ $who ]++;
}
}
else{
$tasks["done"]++;
}
$whos = (is_array($t["who"])) ? $t["who"] : explode(",",$t["who"]);
foreach ($whos as $whoix => $who) {
if( !isset( $tasks["allTasksPerson"][ $who ] ) )
$tasks["allTasksPerson"][ $who ] = 0;
$tasks["allTasksPerson"][ $who ]++;
}
}
}
}
}
}
$finance["percentFinanced"] = ( isset( $finance["financed"]["total"] ) && isset( $finance["total"] ) ) ? floor($finance["financed"]["total"] * 100 / $finance["total"] ) : 0;
$cix = 0;
foreach ( $finance["financed"]["byAmount"] as $ix => $who) {
if( $cix >= count(Ctenat::$COLORS) )
$cix = 0;
$finance["financed"]["colors"][] = Ctenat::$COLORS[$cix];
$cix++;
}
$finance["financed"]["missing"] = "";
if( isset( $finance["financed"]["total"] ) &&
isset( $finance["total"] ) &&
( $finance["total"] - $finance["financed"]["total"] ) >= 0 ) {
$finance["financed"]["missing"] = "<br/>manque <span class='text-red'>".( $finance["total"] - $finance["financed"]["total"] )." €</span>";
$finance["financed"]["byAmount"][] = $finance["total"] - $finance["financed"]["total"];
$finance["financed"]["byName"][] = "MISSING";
$finance["financed"]["colors"][] = "#ff0000";
}
$tasks["percentDone"] = ( isset( $tasks["todo"] ) || isset( $tasks["done"] ) ) ? floor( ($tasks["todo"]) * 100 / ($tasks["todo"]+$tasks["done"]) ) : 0;
$tasks["tasksPersonCount"] = array_values($tasks["tasksPerson"]);
$tasks["tasksPersonLabel"] = array_keys($tasks["tasksPerson"]);
//var_dump($tasks);exit;
$lists = [
// "chiffresDepense" =>[
// "title"=>"<i class='fa fa-2x fa-question-circle'></i><br/>Dépense",
// "blocksize"=>"3 col-xs-6",
// "bgColor" => Ctenat::$COLORS[0],
// "color" => "#fff",
// "data" => [
// ["data"=>24,"name"=>"personne impliquées","icon"=>"group","type"=>"success"],
// ["data"=>45,"name"=>"durée","type"=>"danger","icon"=>"clock"]
// ],
// "tpl" => "costum.views.tpls.list"
// ],
// "chiffresDecide" =>[
// "title"=>"<i class='fa fa-2x fa-thumbs-up'></i><br/>Décision",
// "blocksize"=>"4 col-xs-6",
// "bgColor" => Ctenat::$COLORS[0],
// "color" => "#fff",
// "data" => [
// ["data"=>24,"name"=>"Pour","icon"=>"thumbs-up","type"=>"success"],
// ["data"=>45,"name"=>"Contre","type"=>"danger","icon"=>"thumbs-down"],
// ["data"=>45,"name"=>"Nombres de Décisions Validés","type"=>"danger","icon"=>"gavel"],
// ["data"=>60,"name"=>"Nombres de Décisions Refusés","type"=>"danger","icon"=>"hand-stop-o"]
// ],
// "tpl" => "costum.views.tpls.list"
// ],
"chiffresFin" =>[
"title"=>"<i class='fa fa-2x fa-money'></i><br/>Finances",
"blocksize"=>"6 col-xs-6",
"bgColor" => Ctenat::$COLORS[0],
"color" => "#fff",
"data" => [
["data"=>(100-$finance["percentFinanced"])." %","name"=>"Resta à financer","type"=>"danger","icon"=>"money"],
["data"=>$finance["total"]." €","name"=>"Total à financer","icon"=>"thumbs-up","type"=>"success"],
["data"=>$finance["financed"]["total"]." €","name"=>"Total financé","type"=>"danger","icon"=>"map-marker"],
["data"=>$finance["percentFinanced"]." %","name"=>"Pourcentage financé","type"=>"danger","icon"=>"money"],
["data"=>count(array_keys($finance["financed"]["byName"])),"name"=>"Combien de financeurs","type"=>"danger","icon"=>"group"],
],
"tpl" => "costum.views.tpls.list"
],
"chiffresFollow" =>[
"title"=>"<i class='fa fa-2x fa-cogs'></i><br/>Suivi",
"blocksize"=>"6 col-xs-6",
"bgColor" => Ctenat::$COLORS[0],
"color" => "#fff",
"data" => [
["data"=>$tasks["done"],"name"=>"Nombres de Taches Cloturés","type"=>"success","icon"=>"fa-handshake-o"],
["data"=>$tasks["todo"],"name"=>"Nombres de Taches à faire ","type"=>"danger","icon"=>"fa-handshake-o"],
["data"=>$tasks["percentDone"]." %","name"=>"Pourcentage d'avancement","type"=>"danger","icon"=>"fa-hourglass-half"],
["data"=>$tasks['todo']+$tasks['done'],"name"=>"nombre de tache","icon"=>"pie-chart","type"=>"success"],
["data"=>count(array_keys($tasks["allTasksPerson"])),"name"=>"nombre d'acteur","icon"=>"group","type"=>"success"],
//["data"=>$tasks["done"],"name"=>"Nombres de Travaux Validés","type"=>"danger","icon"=>"thumbs-up"],
],
"tpl" => "costum.views.tpls.list"
],
"financer" =>[
"title"=>"Financé en € ".$finance["financed"]["missing"],
"data" => $finance["financed"]["byAmount"],
"lbls" => $finance["financed"]["byName"],
"colors" => $finance["financed"]["colors"],
"url"=>"/graph/co/dash/g/costum.views.custom.ctenat.graph.pieMany"
],
"cost" =>[
"title"=>"Cout en € par Block ",
"data" => $finance["byBlock"],
"lbls" => $finance["byBlockName"],
"url"=>"/graph/co/dash/g/costum.views.custom.ctenat.graph.pieMany"
],
"tasks" =>[
"title"=>"Taches",
"data" => $tasks["tasksPersonCount"],
"lbls" => $tasks["tasksPersonLabel"],
"url"=>"/graph/co/dash/g/costum.views.custom.ctenat.graph.pieMany"
],
"timeline" =>[
"col12"=>true,
"title"=>"Point d'activité",
"data" => [32,6,36,21,10],
"lbls" => ["Taches 0","Taches 1","Taches 2","Taches 3","Taches 4"],
"url" => "/graph/co/dash/g/graph.views.co.line"
],
"activtiyType" =>[
"title"=>"Type d'activité",
"data" => [32,65,6,21,10],
"lbls" => ["Dev","Graphisme","Fiancement","Dossier","Administratif"],
"url" => "/graph/co/dash/g/graph.views.co.bar"
],
"activtiyType2" =>[
"title"=>"Type d'activité 2",
"data" => [3,65,36,21,10],
"lbls" => ["Finance 0","Finance 1","Finance 2","Finance 3","Finance 4"],
"url" => "/graph/co/dash/g/graph.views.co.polar"
],
"activtiyType3" =>[
"title"=>"Type d'activité 3",
"data" => [3,65,36,21,10],
"lbls" => ["Finance 0","Finance 1","Finance 2","Finance 3","Finance 4"],
"url" => "/graph/co/dash/g/graph.views.co.radar"
],
];
} else {
/*echo count($answers)." Proposals";
echo "<br/> <b>Proposals per status pie</b>";
echo "<br/>---- validated Proposals";
echo "<br/>---- pending decision Proposals";
echo "<br/>---- pending financing Proposals";
echo "<br/>---- Proposals with pending intents no commited ";
echo "<br/>---- Proposals pending evaluations and intent proposals ";
echo "<br/>---- no participation Proposals";
echo "<br/> <b>Projects per status pie</b>";
echo "<br/>---- active Projects";
echo "<br/>---- finished Projects";
echo "<br/> <b>Tasks per status pie</b>";
echo "<br/>---- for open projects Tasks distribution";
echo "<br/>---- for each worker Tasks distribution per project";
echo "<br/>---- xxx Tasks";
echo "<br/> <b>Fianncement per type or contexte pie</b>";
echo "<br/>---- for open projects Finance distribution per presta/ commons";
echo "<br/>---- for open projects Finance distribution per task types";
echo "<br/>---- for each worker Finances distribution per project";
echo "<br/>---- xxx Tasks";*/
//count
$lists = [
"chiffresProp" =>[
"title"=>"<i class='fa fa-2x fa-question-circle'></i><br/>Propositions",
"blocksize"=>"3 col-xs-6",
"bgColor" => Ctenat::$COLORS[0],
"color" => "#fff",
"data" => [
["data"=>24,"name"=>"validated Proposals","icon"=>"thumbs-up","type"=>"success"],
["data"=>45,"name"=>"pending decision Proposals","type"=>"danger","icon"=>"map-marker"],
["data"=>60,"name"=>"pending financing Proposals","type"=>"danger","icon"=>"money"],
["data"=>24,"name"=>"Proposals with pending intents no commited","icon"=>"hourglass-half"],
["data"=>45,"name"=>"no participation Proposals","icon"=>"group"],
],
"tpl" => "costum.views.tpls.list"
],
"chiffresProj" =>[
"title"=>"<i class='fa fa-2x fa-lightbulb-o'></i><br/>Projets",
"blocksize"=>"3 col-xs-6",
"bgColor" => Ctenat::$COLORS[0],
"color" => "#fff",
"data" => [