Commit e859d61d authored by thomas craipeau's avatar thomas craipeau
Browse files

merge qa > dev

parents f716814f c18fbef6
......@@ -108,8 +108,7 @@ var formObj = {
addHash += ".mode."+mode;
}
if(typeof contextId != "undefined" && contextId != null &&
typeof contextType != "undefined" && contextType != null){
if(typeof contextId != "undefined" && contextType != "undefined" ){
url += '/contextId/'+contextId+'/contextType/'+contextType;
addHash += '.contextId.'+contextId+'.contextType.'+contextType;
}
......@@ -202,7 +201,7 @@ var formObj = {
// str += '<a href="javascript:;" class="createForm btn btn-sm btn-link bg-green-k pull-right "><i class="fa fa-plus"></i> Nouveau Formulaire</a>'+
// '<a href="javascript:;" class="addOpenForm btn btn-sm btn-link bg-green-k pull-right "><i class="fa fa-plus"></i>Ajouter Formulaire</a>'+
str += '<div class="dropdown pull-right"> <button class="addformdropdown dropdown-toggle" type="button" data-toggle="dropdown"> Ajouter <span class="caret"></span> </button> <ul class="dropdown-menu"> <li><a href="javascript:;" class="createForm btn btn-sm btn-link bg-green-k pull-right "><i class="fa fa-plus"></i> Nouveau Formulaire</a></li><li><a href="javascript:;" class="addOpenForm btn btn-sm btn-link bg-green-k pull-right "><i class="fa fa-plus"></i>Ajouter Formulaire</a></li></ul> </div>';
str += '<div class="dropdown pull-right"> <button class="addformdropdown dropdown-toggle" type="button" data-toggle="dropdown"> Ajouter <span class="caret"></span> </button> <ul class="dropdown-menu"> <li><a href="javascript:;" class="createForm bg-green-k "><i class="fa fa-plus"></i> Nouveau Formulaire</a></li><li><a href="javascript:;" class="addOpenForm "><i class="fa fa-plus"></i>Ajouter Formulaire</a></li></ul> </div>';
str += ' </div>';
str += '<div class="page__items" role="row">';
$.each(forms, function(idF, valForm){
......@@ -576,13 +575,23 @@ var formObj = {
$(".addAnswer").on('click', function() {
coInterface.showLoader("#mainDash");
ajaxPost("#mainDash", baseUrl+'/survey/answer/index/id/new/form/'+$(this).data("parentformid")+'/contextId/'+$(this).data("contextid")+'/contextType/'+$(this).data("contexttype"),
null,
function(){
if (typeof hashUrlPage != "undefined") {
// history.replaceState(location.hash, "", hashUrlPage+".view.forms.dir.graphbuilder."+$(this).data("parentformid"));
}
},"html");
if (typeof $(this).data("contextid") !== "undefined" && typeof $(this).data("contexttype") !== "undefined") {
ajaxPost("#mainDash", baseUrl+'/survey/answer/index/id/new/form/'+$(this).data("parentformid")+'/contextId/'+$(this).data("contextid")+'/contextType/'+$(this).data("contexttype"),
null,
function(){
if (typeof hashUrlPage != "undefined") {
// history.replaceState(location.hash, "", hashUrlPage+".view.forms.dir.graphbuilder."+$(this).data("parentformid"));
}
},"html");
} else {
ajaxPost("#mainDash", baseUrl+'/survey/answer/index/id/new/form/'+$(this).data("parentformid"),
null,
function(){
if (typeof hashUrlPage != "undefined") {
// history.replaceState(location.hash, "", hashUrlPage+".view.forms.dir.graphbuilder."+$(this).data("parentformid"));
}
},"html");
}
});
$('.getopalgraph').on('click', function() {
......
<?php
/**
* PaymentController.php
*
* @author: Dady Christon <devchriston@gmail.com>
* Date: 26/02/2021
*/
class PaymentController extends CommunecterController {
protected function beforeAction($action) {
return parent::beforeAction($action);
}
public function actionPay(){
$mollie = new \Mollie\Api\MollieApiClient();
echo $_POST["page"];
$parent = PHDB::findOneById("organizations", $_POST["orga"]);
if(isset($parent["mollie_key_".$_POST["mode"]]) && !empty($parent["mollie_key_".$_POST["mode"]])){
$mollie->setApiKey($parent["mollie_key_".$_POST["mode"]]);
# $mollie->setAccessToken("Here is token if needed");
$orderId = time();
$protocol = isset($_SERVER['HTTPS']) && strcasecmp('off', $_SERVER['HTTPS']) !== 0 ? "https" : "http";
$hostname = $_SERVER['HTTP_HOST'];
$path = dirname(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : $_SERVER['PHP_SELF']);
$payment_data = [
"amount" => [
"currency" => "EUR",
"value" => $_POST["amount"]["value"]
],
"description" => $_POST["description"],
"redirectUrl" => "{$protocol}://{$hostname}{$path}/check/?order_id={$orderId}&source={$_POST['source']}&page={$_POST['page']}",
"webhookUrl" => "{$protocol}://{$hostname}{$path}/check/?order_id={$orderId}&source={$_POST['source']}&page={$_POST['page']}",
"metadata" => [
"order_id" => $orderId
],
"method" => "creditcard"
];
if($_POST["mode"]=="test"){
$payment_data["method"] = "creditcard";
}
$payment = $mollie->payments->create();
# Keep payment in database
PHDB::insert("payments",
array(
'payment' => array(
'id' => $payment->id,
'currency' => "EUR",
'value' => $_POST["amount"]["value"],
'description' => $_POST["description"],
'nbPart' => $_POST["nombre"],
'isPaid' => false
),
'collection' => 'payments',
'user' => $_SESSION["userId"],
'parent' => array('id' => $_POST["orga"]),
'source' => array(
'key' => (isset($_POST["form"]))?$_POST["form"]:"",
),
'orderId' => "$orderId",
'mode' => $_POST["mode"]
)
);
return Rest::json(array('url' => $payment->getCheckoutUrl()));
}else{
return Rest::json(array('message' => "Vous n'avez pas les condition nécessaire pour utiliser cette fonctionnalité"));
}
}
# Check if payment is paid
public function actionCheck($order_id, $source, $page){
$mollie = new \Mollie\Api\MollieApiClient();
# $mollie->setAccessToken("Here is token if needed"); 0340287138
$p = PHDB::findOne("payments", array('orderId' => "$order_id"));
$parent = PHDB::findOneById("organizations", $p["parent"]["id"]);
if(isset($parent["mollie_key_".$p["mode"]]) && !empty($parent["mollie_key_".$p["mode"]])){
$mollie->setApiKey($parent["mollie_key_".$p["mode"]]);
if(isset($p["payment"]["id"])){
$payment = $mollie->payments->get($p["payment"]["id"]);
if ($payment->isPaid()){
$res = array('isPaid' => true);
PHDB::update("payments", array('orderId' => "$order_id"), array('$set' => array('payment.isPaid' => true)));
$source = PHDB::count("answers", array('form' => $source));
if($source > 0){
PHDB::update("answers", array('user' => $_SESSION["userId"], 'form' => "$source"), array('$set' => array('answers.isPaid' => true)));
}
}else{
$res = array('isPaid' => false);
}
}else{
$res = array('isPaid' => false);
}
return $this->redirect("$page");
}else{
return Rest::json(array('message' => "Payement invalide"));
}
}
public function actionGetPaymentMethode()
{
$payment_methode = array();
return Rest::json($payment_methode);
}
public function actionInvoice($id, $slug, $user=null, $form=null) {
$doc = array();
$orga = PHDB::findOne("organizations", array('slug' => $slug ));
$orga["siret"] = "51338183000019";
$payment = PHDB::findOne("payments", array('user' => $user, 'source.form'=> $form));
$customer = PHDB::findOneById("citoyens", $user);
$params = array(
'organization' => $orga,
'associe' => $customer,
'payment' => $payment,
'currency' => "€"
);
$tpl = $this->renderPartial('application.views.pdf.factureOpenAtlas',
$params, true);
$doc["html"] = $tpl;
Pdf::createPdf($doc);
//echo $tpl;
}
}
......@@ -10,7 +10,7 @@ class DashboardAction extends CAction
public function run($id=null, $answer=null, $form=null, $title = "", $contextId = null, $contextType = null)
{
$controller = $this->getController();
$myanswer = PHDB::find( Form::ANSWER_COLLECTION, array("form"=>$answer));
$formanswers = PHDB::find( Form::ANSWER_COLLECTION, array("form"=>$answer));
$prntForm = PHDB::findOneById(Form::COLLECTION, $answer );
......@@ -18,14 +18,149 @@ class DashboardAction extends CAction
$tittleList = [];
$adminRight = false;
$active = true;
$canModify = true;
$canReadOtherAnswers = false;
$oneAnswerPerPers = false;
$private = true;
$showAnswers = true;
//permission to all Dashboard
$canAddAnswer = false;
$canEditEachotherAnswer = false;
$canReadEachOtherAnswer = false;
$titletype = [
$myanswers = PHDB::find( Form::ANSWER_COLLECTION, array("form"=>$answer, "user" => Yii::app()->session["userId"]));
if ($contextId != null || $contextType != null) {
$itemId = $contextId;
$itemType = $contextType;
} else {
foreach ($prntForm["parent"] as $prntFormkey => $prntFormvalue) {
$itemId = $prntFormkey;
$itemType = $prntFormvalue["type"];
}
}
// var_dump($itemId, $itemType, Yii::app()->session["userId"]);exit();
if
(
(
//is form active
isset($prntForm["active"]) &&
$prntForm["active"] == "true"
)
&&
(
//is form between start and end date
!isset($prntForm["startDate"]) ||
( time() > strtotime(str_replace("/","-",$prntForm["startDate"])) &&
( !isset($prntForm["endDate"]) || time() <= strtotime(str_replace("/","-",$prntForm["endDate"])))) ||
(isset($prntForm["endDate"]) && $prntForm["endDate"] == "")
)
&&
(
// is one answer per person
!isset($prntForm["oneAnswerPerPers"]) ||
(
isset($prntForm["oneAnswerPerPers"]) &&
$prntForm["oneAnswerPerPers"] == "false"
)||
(
isset($prntForm["oneAnswerPerPers"]) &&
$prntForm["oneAnswerPerPers"] == "true" && empty($myanswers)
)
)
&&
(
//private
!isset($prntForm["private"]) ||
(
isset($prntForm["private"]) &&
$prntForm["private"] == "false"
)
||
(
isset($prntForm["private"]) &&
$prntForm["private"] == "true" && Link::isLinked($itemId, $itemType, Yii::app()->session["userId"])
)
)
&&
!empty(Yii::app()->session["userId"])
)
{
$canAddAnswer = true;
}
if
(
(
//is form active
isset($prntForm["active"]) &&
$prntForm["active"] == "true"
)
&&
(
//is form between start and end date
!isset($prntForm["startDate"]) ||
( time() > strtotime(str_replace("/","-",$prntForm["startDate"])) &&
( !isset($prntForm["endDate"]) || time() <= strtotime(str_replace("/","-",$prntForm["endDate"])))) ||
(isset($prntForm["endDate"]) && $prntForm["endDate"] == "")
)
&&
(
//private
!isset($prntForm["private"]) ||
(
isset($prntForm["private"]) &&
$prntForm["private"] == "false"
)
||
(
isset($prntForm["private"]) &&
$prntForm["private"] == "true" && Link::isLinked($itemId, $itemType, Yii::app()->session["userId"])
)
)
)
{
$canEditEachotherAnswer = true;
}
if
(
(
//is form active
isset($prntForm["active"]) &&
$prntForm["active"] == "true"
)
&&
(
//private
!isset($prntForm["private"]) ||
(
isset($prntForm["private"]) &&
$prntForm["private"] == "false"
)
||
(
isset($prntForm["private"]) &&
$prntForm["private"] == "true" && Link::isLinked($itemId, $itemType, Yii::app()->session["userId"] )
)
)
&&
(
//private
!isset($prntForm["canReadOtherAnswers"]) ||
(
isset($prntForm["canReadOtherAnswers"]) &&
$prntForm["canReadOtherAnswers"] == "true"
)
)
)
{
$canReadEachOtherAnswer = true;
}
$titletype = [
"text",
"select",
"tpls.forms.cplx.multitextvalidation",
......@@ -33,6 +168,7 @@ class DashboardAction extends CAction
"tpls.forms.cplx.multiRadio"
];
if(isset($prntForm["active"]) ){
$active = filter_var($prntForm["active"], FILTER_VALIDATE_BOOLEAN);
}
......@@ -54,11 +190,16 @@ class DashboardAction extends CAction
foreach ($prntForm["parent"] as $ip => $vp) {
$communityLinks = Element::getCommunityByTypeAndId($vp["type"],$ip);
foreach ($communityLinks as $cmid => $cmvalue) {
if ($cmid == Yii::app()->session["userId"] && isset($cmvalue["isAdmin"]) && $cmvalue["isAdmin"] == true) {
$adminRight = true;
}
}
if (Authorisation::isUserSuperAdmin(Yii::app()->session["userId"])) {
$adminRight = true;
}
}
if (isset($prntForm["subForms"])) {
......@@ -121,8 +262,8 @@ class DashboardAction extends CAction
$responsetitle = [];
$right = [];
foreach ($myanswer as $idAns => $valueAns) {
if(isset($valueAns["answers"])){
foreach ($formanswers as $idAns => $valueAns) {
if(isset($valueAns["answers"]) || $valueAns["user"] == Yii::app()->session["userId"]){
if(isset($valueAns["answers"][$title[0]][$title[1]])){
array_push($responsetitle , $valueAns["answers"][$title[0]][$title[1]]);
......@@ -147,6 +288,9 @@ class DashboardAction extends CAction
$countrsp = 0;
$percntrsp = 0;
if (empty($valueAns["answers"])) {
$valueAns["answers"] = [];
}
foreach ($valueAns["answers"] as $formName => $formAns) {
$countrsp += sizeof($formAns);
}
......@@ -167,7 +311,11 @@ class DashboardAction extends CAction
array_push($users, $us);
array_push($index, $idAns);
array_push($updatedate, date("d-m-Y", $valueAns["updated"])) ;
if (isset($valueAns["updated"])) {
array_push($updatedate, date("d-m-Y", $valueAns["updated"])) ;
}else{
array_push($updatedate, "") ;
}
array_push($countAns, $countrsp);
array_push($percentage, $percntrsp);
......@@ -202,11 +350,14 @@ class DashboardAction extends CAction
"allanswers" => $allfields,
"adminRight" => $adminRight,
"p_active" => $active,
"p_canModify" => $canModify,
"p_canReadOtherAnswers" => $canReadOtherAnswers,
"p_oneAnswerPerPers " => $oneAnswerPerPers ,
"p_private " => $private ,
"p_showAnswers" => $showAnswers,
"p_canModify" => @$canModify,
"p_canReadOtherAnswers" => @$canReadOtherAnswers,
"p_oneAnswerPerPers " => @$oneAnswerPerPers ,
"p_private " => @$private ,
"p_showAnswers" => @$showAnswers,
"canAddAnswer" => $canAddAnswer,
"canEditEachotherAnswer" => $canEditEachotherAnswer,
"canReadEachOtherAnswer" => $canReadEachOtherAnswer,
"contextId" => $contextId,
"contextType" => $contextType
];
......
......@@ -29,9 +29,9 @@ class IndexAction extends CAction
$mode = "w" ;
} else {
if(Yii::app()->request->isAjaxRequest)
echo $this->getController()->renderPartial("co2.views.default.unTpl",array("msg"=>Yii::t("common", "You are not allow to access to this answer"),"icon"=>"fa-lock"));
echo $this->getController()->renderPartial("co2.views.default.unTpl",array("msg"=>Yii::t("form", "You are not allow to access to this form. Please check if you are logged in."),"icon"=>"fa-lock"));
else
$this->getController()->render("co2.views.default.unTpl",array("msg"=>Yii::t("common", "You are not allow to access to this answer"),"icon"=>"fa-lock"));
$this->getController()->render("co2.views.default.unTpl",array("msg"=>Yii::t("form", "You are not allow to access to this form. Please check if you are logged in."),"icon"=>"fa-lock"));
exit;
}
......
......@@ -9,6 +9,11 @@ class NewanswerAction extends CAction
{
public function run($form=null, $contextId=null, $contextType=null)
{
if($_POST["action"] == "newanswer"){
$params = Element::getElementById($_POST["answerId"],Answer::COLLECTION);
$params["seen"] = $_POST["seen"];
PHDB::update(Answer::COLLECTION,[ "_id" => new MongoId($_POST["answerId"]) ],['$set'=>$params]);
}else{
$formParent =PHDB::findOneById( Form::COLLECTION, $form);
$context = null;
if(!empty($contextId) && !empty($contextType)){
......@@ -23,4 +28,5 @@ class NewanswerAction extends CAction
$answer = Answer::generateAnswer($formParent, false, $context);
return Rest::json($answer);
}
}
}
\ No newline at end of file
This diff is collapsed.
......@@ -17,7 +17,7 @@
{
"name" : "Demande d'aide à l'Amélioration de l'Habitat",
"parent" : {
"60363f641efec90f5bd9b0ec" : {
"60364415690864ed6c8b45e4" : {
"type" : "organizations",
"name" : "Améliore Out Kaz"
}
......
......@@ -84,6 +84,7 @@ class Form {
"tpls.forms.cplx.indicateurs" =>"Liste d'Indicateur",
"tpls.forms.cplx.element" =>"Créer un élément Person , Organisation, Projet,...",
"tpls.forms.cplx.stepValidation" =>"Step Validation by Roles",
"tpls.forms.cplx.validateInput" =>"Input Validation et confirmation par email",
"tpls.forms.cplx.generatePDF" =>"Generate PDF",
"tpls.forms.cplx.address" =>"Geocode an address",
"tpls.forms.cplx.regle" =>"règle d'attribution",
......@@ -96,6 +97,7 @@ class Form {
"tpls.forms.cplx.openDynform" => "Tableau ou liste de réponse (Open Dynamic Form)",
"tpls.forms.cplx.multitextvalidation" => "Text : petit text court Configurable",
"tpls.forms.cplx.multiRadio" => "Bouton Radio : Multiple options et Choix unique",
"tpls.forms.cplx.typeEtDroitAdhesion" => "Montant par type",
"tpls.forms.cplx.multiCheckboxPlus" => "Case à cocher : Multiple options et Multiple Choix "
];
......
......@@ -58,15 +58,16 @@ echo $this->renderPartial("survey.views.tpls.answers.header",["parentFormId" =>
<div class="btn-group pull-right">
<?php if ($adminRight) { ?>
<button class="btn btn-outline-dark titleparams"><i class="fa fa-cog"></i> Paramètre </button>
<?php }
if ($p_active && isset(Yii::app()->session["userId"])){
<?php
}
if ($canAddAnswer || $adminRight){
if ($contextId != null && $contextType != null) {
$btndatacontext= " data-contextid='".$contextId."' data-contexttype='".$contextType."'";
}else{
$btndatacontext= "";
}
$btndatacontext= " data-contextid='".$contextId."' data-contexttype='".$contextType."' data-type='openform'";
}else{
$btndatacontext= "";
}
?>
<button class="btn btn-outline-dark application addAnswer" data-type="openform" data-id='<?php echo $allanswers['parentFormId'] ?>' data-parentformid='<?php echo $allanswers['parentFormId'] ?>' <?php echo $btndatacontext ?>><i class="fa fa-plus"></i> Ajouter </button>
<button class="btn btn-outline-dark application addAnswer" data-id='<?php echo $allanswers['parentFormId'] ?>' data-parentformid='<?php echo $allanswers['parentFormId'] ?>' <?php echo $btndatacontext ?>><i class="fa fa-plus"></i> Ajouter </button>
<?php } ?>
</div>
</div>
......@@ -227,6 +228,13 @@ echo $this->renderPartial("survey.views.tpls.answers.header",["parentFormId" =>
<?php
for ($i = 0; $i < count($allanswers["index"]) ; $i++)
{
$useranswer = false;
foreach ($allanswers["users"][$i] as $ukey => $uvalue) {
if (Yii::app()->session["userId"] == (string)$uvalue["_id"]) {
$useranswer = true;
}
}
if ($adminRight || $p_showAnswers || (!$p_showAnswers && $useranswer)) {
?>
<li class="survey-item">
<span class="survey-country list-only">
......@@ -324,10 +332,18 @@ echo $this->renderPartial("survey.views.tpls.answers.header",["parentFormId" =>
?>
<div class='social-links'>
<?php
if ($adminRight || $canEditEachotherAnswer || (!$canEditEachotherAnswer && $useranswer)) {
?>
<div class='social-btn flex-center <?php echo $btnclass ?> ' <?php echo $btndataw.$btndatatype ?>>
<i class="fa fa-pencil-square-o editdeleteicon"></i><span style="font-size: 14px;">Editer</span>
</div>
<?php
}
if ($adminRight || $canReadEachOtherAnswer || (!$canReadEachOtherAnswer && $useranswer)) {
?>
<div class='social-btn flex-center <?php echo $btnclass ?>' <?php echo $btndatar ?>>
<i class="fa fa-sticky-note-o editdeleteicon"></i><span style="font-size: 14px;">Lire</span>
......@@ -366,6 +382,7 @@ echo $this->renderPartial("survey.views.tpls.answers.header",["parentFormId" =>
</li>
<?php
}
}
?>
</ul>
......
<?php if($answer){ ?>
<div class="form-group">
<table class="table table-bordered table-hover directoryTable" id="<?php echo $kunik?>">
<?php
$paramsData = [ "type" => [
Organization::COLLECTION => "Organization",
Person::COLLECTION => "Person",
Event::COLLECTION => "Event",
Project::COLLECTION => "Project",
News::COLLECTION => "News",
Need::COLLECTION => "Need",
City::COLLECTION => "City",
Thing::COLLECTION => "Thing",
Poi::COLLECTION => "Poi",
Classified::COLLECTION => "Classified",
Product::COLLECTION => "Product",
Service::COLLECTION => "Service",
Survey::COLLECTION => "Survey",
Bookmark::COLLECTION => "Bookmark",
Proposal::COLLECTION => "Proposal",
Room::COLLECTION => "Room",
Action::COLLECTION => "Action",
Network::COLLECTION => "Network",
Url::COLLECTION => "Url",
Place::COLLECTION => "Place",
Ressource::COLLECTION => "Ressource",
Circuit::COLLECTION => "Circuit",