Commit cd4f4d38 authored by Marcello Pivanti's avatar Marcello Pivanti
Browse files

Initial Commit

parents
# amos-sondaggi
Plugin to make surveys.
## Installation
### 1. The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
Either run
```bash
composer require elitedivision/amos-sondaggi
```
or add this row
```
"elitedivision/amos-sondaggi": "~1.0"
```
to the require section of your `composer.json` file.
### 2. Add module to your main config in backend:
```php
<?php
'modules' => [
'sondaggi' => [
'class' => 'elitedivision\amos\sondaggi\AmosSondaggi'
],
],
```
### 3. Apply migrations
```bash
php yii migrate/up --migrationPath=@vendor/elitedivision/amos-sondaggi/src/migrations
```
or add this row to your migrations config in console:
```php
<?php
return [
'@vendor/elitedivision/amos-sondaggi/src/migrations',
];
```
{
"name": "arter/amos-sondaggi",
"description": "Sistema AMOS per gestire i sondaggi",
"keywords": [
"amos",
"yii2",
"sondaggi"
],
"homepage": "http://www.elitedivision.it/",
"type": "component",
"license": "BSD-3-Clause",
"support": {
"issues": "http://www.example.com/",
"forum": "http://www.example.com/forum/",
"wiki": "http://www.example.com/wiki/",
"source": "https://github.com/elitedivision/amos-sondaggi"
},
"require": {
"php": ">=5.4.0",
"arter/amos-admin": ">=1.8",
"arter/amos-core": "^1.9.57",
"arter/amos-dashboard": "^1.8",
"arter/amos-attachments": "^1.1.11",
"arter/amos-email-manager": "^1.1",
"arter/amos-upload": "*",
"kartik-v/yii2-detail-view": "*",
"kartik-v/yii2-widget-fileinput": "*"
},
"autoload": {
"psr-4": {
"elitedivision\\amos\\sondaggi\\": "src"
}
}
}
\ No newline at end of file
<?php
/**
* Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
* OPEN 2.0
*
*
* @package elitedivision\amos\sondaggi
* @category CategoryName
* @author Elite Division S.r.l.
*/
namespace elitedivision\amos\sondaggi;
use elitedivision\amos\core\module\AmosModule;
use elitedivision\amos\core\module\ModuleInterface;
use elitedivision\amos\sondaggi\widgets\icons\WidgetIconAmministraSondaggi;
use elitedivision\amos\sondaggi\widgets\icons\WidgetIconCompilaSondaggi;
use elitedivision\amos\sondaggi\widgets\icons\WidgetIconPubblicaSondaggi;
use elitedivision\amos\sondaggi\widgets\icons\WidgetIconSondaggi;
use Yii;
use yii\db\Connection;
use yii\helpers\ArrayHelper;
/**
* Class AmosSondaggi
* @package elitedivision\amos\sondaggi
*/
class AmosSondaggi extends AmosModule implements ModuleInterface
{
public static $CONFIG_FOLDER = 'config';
public $controllerNamespace = 'elitedivision\amos\sondaggi\controllers';
public $newFileMode = 0666;
public $newDirMode = 0777;
/**
* In the case of a private poll for role, it is possible to send the notification to the users who can fill out the survey.
* @var boolean
*/
public $enableNotificationEmailByRoles = false;
/**
* Default email for the sender
* @var string
*/
public $defaultEmailSender;
/**
* It allows to show in the first page of the results the geoChart based on the province of domicile.
* @var boolean
*/
public $enableGeoChart = false;
/**
* It allows to show in the first page of the results a partecipant report if available.
* @var boolean
*/
public $enablePartecipantsReport = false;
/**
* The fields that will be displayed in the participant's //TO-DO
* @var array
*/
public $fieldsByPartecipants = [];
/**
* @var string|boolean the layout that should be applied for views within this module. This refers to a view name
* relative to [[layoutPath]]. If this is not set, it means the layout value of the [[module|parent module]]
* will be taken. If this is false, layout will be disabled within this module.
*/
public $layout = 'main';
public $name = 'Sondaggi';
/**
* @var Connection|array|string the DB connection object or the application component ID of the DB connection.
*/
public $db = 'db';
/**
* Hide the Option wheel in the graphic widget
* @var bool|false $hideWidgetGraphicsActions
*/
public $hideWidgetGraphicsActions = false;
/**
* @inheritdoc
*/
public function init()
{
parent::init();
$this->db = Yii::$app->db;
\Yii::setAlias('@elitedivision/amos/' . static::getModuleName() . '/controllers/', __DIR__ . '/controllers/');
// initialize the module with the configuration loaded from config.php
$config = require(__DIR__ . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php');
Yii::configure($this, ArrayHelper::merge($config, $this));
}
/**
* @inheritdoc
*/
public static function getModuleName()
{
return "sondaggi";
}
/**
* @inheritdoc
*/
public function getWidgetIcons()
{
return [
WidgetIconSondaggi::className(),
WidgetIconCompilaSondaggi::className(),
WidgetIconPubblicaSondaggi::className(),
WidgetIconAmministraSondaggi::className(),
];
}
/**
* @inheritdoc
*/
public function getWidgetGraphics()
{
return [
];
}
/**
* @inheritdoc
*/
protected function getDefaultModels()
{
return [];
}
}
<?php
/**
* Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
* OPEN 2.0
*
* @package Open20Package
* @category CategoryName
* @author Elite Division S.r.l.
*/
namespace elitedivision\amos\sondaggi\assets;
use yii\web\AssetBundle;
class ModuleRisultatiAsset extends AssetBundle
{
public $sourcePath = '@vendor/elitedivision/amos-sondaggi/src/assets/web';
public $css = [
'css/stile.css'
];
public $js = [
];
public $depends = [
'yii\web\JqueryAsset',
'yii\jui\JuiAsset',
//'kartik\depdrop\DepDropAsset',
'kartik\depdrop\DepDropExtAsset'
];
public function init()
{
$moduleL = \Yii::$app->getModule('layout');
if(!empty($moduleL))
{ $this->depends [] = 'elitedivision\amos\layout\assets\BaseAsset'; }
else
{ $this->depends [] = 'elitedivision\amos\core\views\assets\AmosCoreAsset'; }
parent::init(); // TODO: Change the autogenerated stub
}
}
<?php
/**
* Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
* OPEN 2.0
*
* @package Open20Package
* @category CategoryName
* @author Elite Division S.r.l.
*/
namespace elitedivision\amos\sondaggi\assets;
use yii\web\AssetBundle;
class ModuleRisultatiFrontendAsset extends AssetBundle
{
public $sourcePath = '@vendor/elitedivision/amos-sondaggi/src/assets/web';
public $css = [
'less/sondaggi-frontend.less'
];
public $js = [
'js/sondaggi-frontend.js'
];
public $depends = [
'yii\web\JqueryAsset',
'yii\jui\JuiAsset',
'kartik\depdrop\DepDropExtAsset'
];
}
<?php
/**
* Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
* OPEN 2.0
*
* @package Open20Package
* @category CategoryName
* @author Elite Division S.r.l.
*/
namespace elitedivision\amos\sondaggi\assets;
use yii\web\AssetBundle;
use elitedivision\amos\core\widget\WidgetAbstract;
class ModuleSondaggiAsset extends AssetBundle
{
public $sourcePath = '@vendor/elitedivision/amos-sondaggi/src/assets/web';
public $css = [
'css/stile.css'
];
public $js = [
'js/condizioneSondaggio.js'
];
public $depends = [
'yii\web\JqueryAsset',
'yii\jui\JuiAsset',
'kartik\depdrop\DepDropExtAsset'
];
public function init()
{
$moduleL = \Yii::$app->getModule('layout');
if(!empty(\Yii::$app->params['dashboardEngine']) && \Yii::$app->params['dashboardEngine'] == WidgetAbstract::ENGINE_ROWS){
$this->css = ['less/sondaggi-fullsize.less'];
}
if(!empty($moduleL))
{ $this->depends [] = 'elitedivision\amos\layout\assets\BaseAsset'; }
else
{ $this->depends [] = 'elitedivision\amos\core\views\assets\AmosCoreAsset'; }
parent::init();
}
}
<?php
/**
* Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
* OPEN 2.0
*
* @package Open20Package
* @category CategoryName
* @author Elite Division S.r.l.
*/
namespace elitedivision\amos\sondaggi\assets;
use yii\web\AssetBundle;
class ModuleSondaggiPublicAsset extends AssetBundle
{
public $sourcePath = '@vendor/elitedivision/amos-sondaggi/src/assets/web';
public $css = [
];
public $js = [
'js/sondaggioPubblico.js'
];
public $depends = [
'yii\web\JqueryAsset',
'yii\jui\JuiAsset'
];
public function init()
{
$moduleL = \Yii::$app->getModule('layout');
if(!empty($moduleL))
{ $this->depends [] = 'elitedivision\amos\layout\assets\BaseAsset'; }
else
{ $this->depends [] = 'elitedivision\amos\core\views\assets\AmosCoreAsset'; }
parent::init(); // TODO: Change the autogenerated stub
}
}
<?php
/**
* Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
* OPEN 2.0
*
* @package Open20Package
* @category CategoryName
* @author Elite Division S.r.l.
*/
namespace elitedivision\amos\sondaggi\assets;
use yii\web\AssetBundle;
class ModuleSondaggiRisposteAsset extends AssetBundle
{
public $sourcePath = '@vendor/elitedivision/amos-sondaggi/src/assets/web';
public $css = [
];
public $js = [
'js/condizioneRisposteSondaggio.js'
];
public $depends = [
'yii\web\JqueryAsset',
'yii\jui\JuiAsset'
];
public function init()
{
$moduleL = \Yii::$app->getModule('layout');
if(!empty($moduleL))
{ $this->depends [] = 'elitedivision\amos\layout\assets\BaseAsset'; }
else
{ $this->depends [] = 'elitedivision\amos\core\views\assets\AmosCoreAsset'; }
parent::init(); // TODO: Change the autogenerated stub
}
}
/*
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
*/
.col-lg-12.menu-navigazione {
text-align: right;
}
.col-lg-12.menu-sondaggio-chiudi{
text-align: right;
margin-top: 40px;
}
.sondaggi-risultati.col-lg-12 {
margin: auto;
background: #fff;
text-align: center;
}
.sondaggio-row{
margin-top: 15px;
}
.mr10{
margin-right: 10px;
}
.sondaggi-risultati.col-lg-12 p,
.sondaggi-risultati.col-lg-12 h1,
.sondaggi-risultati.col-lg-12 h2,
.sondaggi-risultati.col-lg-12 h3,
.sondaggi-risultati.col-lg-12 h4 {
text-align: justify;
}
\ No newline at end of file
$(document).ready(function () {
$('#ordina-dopo-risposta').prop('disabled', true);
$('#ordinamento-radio-risposta').change(function(event, messages) {
var ord = $('input[type="radio"]:checked').val();
if(ord == "dopo"){
$('#ordina-dopo-risposta').prop('disabled', false);
}
else {
$('#ordina-dopo-risposta').prop('disabled', true);
}
});
});
\ No newline at end of file
var Sondaggi = {
'domandaSelector': '#ordina_dopo',
'submitSelector': '#submit-pagina',
'initCondizione': function () {
$('#condizione_necessaria-id').prop('disabled', true);
$('#condizione_necessaria-libera-id').prop('disabled', true);
//$('#ordina-dopo').prop('disabled', true);
$('#ordina_dopo').prop('disabled', true);
$(this.submitSelector).prop('disabled', true);
$(this.submitSelector).hide();
$('#sondaggidomande-inline').prop('disabled', true);
var tipologiaSalv = $('#sondaggidomande-sondaggi_domande_tipologie_id').val();
if (tipologiaSalv == 1 || tipologiaSalv == 4 || tipologiaSalv == 8) {
$('#selezioni-minime-massime').show();
$('#selezioni-minime-massime-label').show();
$('#selezione-classe-validatrice').hide();
} else {
if (tipologiaSalv == 9) {
$('#selezione-classe-validatrice').show();
} else {
$('#selezione-classe-validatrice').hide();
}
$('#selezioni-minime-massime').hide();
$('#selezioni-minime-massime-label').hide();
}
$('#sondaggidomande-sondaggi_domande_tipologie_id').change(function (event, messages) {
var risp = $('#sondaggidomande-sondaggi_domande_tipologie_id').val();
if (risp == 5 || risp == 6) {
$('#selezione-classe-validatrice').hide();
$(this.submitSelector).prop('disabled', false);
$('#sondaggidomande-inline').prop('disabled', true);
$(this.submitSelector).show();
$('#selezioni-minime-massime').hide();
$('#selezioni-minime-massime-label').hide();
} else if (risp == 3 || risp == 4) {
$('#selezione-classe-validatrice').hide();
$('#sondaggidomande-inline').prop('disabled', true);
$(this.submitSelector).prop('disabled', true);
$(this.submitSelector).hide();
if (risp == 4) {
$('#selezioni-minime-massime').show();
$('#selezioni-minime-massime-label').show();
} else {
$('#selezioni-minime-massime').hide();
$('#selezioni-minime-massime-label').hide();
}
} else {
$('#sondaggidomande-inline').prop('disabled', false);
$(this.submitSelector).prop('disabled', true);
$(this.submitSelector).hide();
$('#selezione-classe-validatrice').hide();
if (risp == 1) {
$('#selezioni-minime-massime').show();
$('#selezioni-minime-massime-label').show();
} else {
if (risp == 9) {
$('#selezione-classe-validatrice').show();
}
$('#selezioni-minime-massime').hide();
$('#selezioni-minime-massime-label').hide();
}
}
});
$('#ordina_dopo').change(function (event, messages) {
var ordinamento = $('input[type="radio"]:checked').val();
if (ordinamento == "dopo") {
//$('#ordina-dopo').prop('disabled', false);
setTimeout(function () {
$('#ordina_dopo').prop('disabled', false);
}, 500);
} else {
$('#ordina_dopo').prop('disabled', true);
}
});
setTimeout(function () {
var elpre = $('#domcond');
if (elpre.prop('checked')) {
$('#condizione_necessaria-id').prop('disabled', false);
$('#condizione_necessaria-libera-id').prop('disabled', false);
} else {
$('#condizione_necessaria-id').prop('disabled', true);
$('#condizione_necessaria-libera-id').prop('disabled', true);
}
var bc = $('#condizione_necessaria-id').prop('disabled');
}, 500);
$('#domcond').change(function (event, messages) {
var el = $('#domcond');
if (el.prop('checked')) {
$('#condizione_necessaria-id').prop('disabled', false);
$('#condizione_necessaria-libera-id').prop('disabled', false);
} else {
$('#condizione_necessaria-id').prop('disabled', true);
$('#condizione_necessaria-libera-id').prop('disabled', true);
}
});
$('#ordinamento-radio').change(function (event, messages) {
var ord = $('input[type="radio"]:checked').val();
if (ord == "dopo") {
//$('#ordina-dopo').prop('disabled', false);
$('#ordina_dopo').prop('disabled', false);
} else {
//$('#ordina-dopo').prop('disabled', true);
$('#ordina_dopo').prop('disabled', true);
}
});
$('#sondaggi_id-id').change(function (event, messages) {
var ell = $('#domcond');
setTimeout(function () {
if (ell.prop('checked')) {
$('#condizione_necessaria-id').prop('disabled', false);
$('#condizione_necessaria-libera-id').prop('disabled', false);
} else {
$('#condizione_necessaria-id').prop('disabled', true);
$('#condizione_necessaria-libera-id').prop('disabled', true);
}
}, 500);
});
},
};
$(document).ready(function () {
Sondaggi.initCondizione();
$(document).on('change', Sondaggi.domandaSelector, function () {
Sondaggi.initCondizione();
});
});
\ No newline at end of file
$(document).ready(function () {