New: Add module opensurvey. Final. Test are welcome.

This commit is contained in:
Laurent Destailleur 2013-04-09 23:05:50 +02:00
parent a4b56708e9
commit 538194f435
71 changed files with 5453 additions and 1 deletions

View File

@ -30,7 +30,8 @@ For users:
- New: Can define a different clicktodial setup per user.
- New: Add option INVOICE_CAN_NEVER_BE_REMOVED.
- New: Enhance agenda module to reach RFC2445 (add busy information).
- First change to prepare feature click to print for PDF.
- New: Add module Opensurvey.
- First change to prepare feature "click to print" (IPP) for PDF.
For translators:
- Update language files.

View File

@ -0,0 +1,224 @@
<?php
/* Copyright (C) 2008 Laurent Destailleur <eldy@users.sourceforge.net>
*
* Licensed under the GNU GPL v3 or higher (See file gpl-3.0.html)
*/
/**
* \defgroup opensurvey Module OpenSurvey
* \brief Module to OpenSurvey integration.
*/
/**
* \file htdocs/opensurvey/core/modules/modOpenSurvey.class.php
* \ingroup opensurvey
* \brief Description and activation file for module OpenSurvey
*/
include_once(DOL_DOCUMENT_ROOT ."/core/modules/DolibarrModules.class.php");
/**
* Description and activation class for module opensurvey
*/
class modOpenSurvey extends DolibarrModules
{
/**
* Constructor. Define names, constants, directories, boxes, permissions
*
* @param DoliDB $db Database handler
*/
function __construct($db)
{
global $langs,$conf;
$this->db = $db;
// Id for module (must be unique).
// Use here a free id (See in Home -> System information -> Dolibarr for list of used module id).
$this->numero = 55000;
// Key text used to identify module (for permission, menus, etc...)
$this->rights_class = 'opensurvey';
// Family can be 'crm','financial','hr','projects','product','technic','other'
// It is used to group modules in module setup page
$this->family = "projects";
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace('/^mod/i','',get_class($this));
// Module description used if translation string 'ModuleXXXDesc' not found (XXX is value MyModule)
$this->description = "Module to integrate a survey (like Doodle, Studs, Rdvz, ...)";
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this->version = 'dolibarr';
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
// Where to store the module in setup page (0=common,1=interface,2=others,3=very specific)
$this->special = 0;
// Name of image file used for this module.
// If file is in theme/yourtheme/img directory under name object_pictovalue.png, use this->picto='pictovalue'
// If file is in module/img directory under name object_pictovalue.png, use this->picto='pictovalue@module'
$this->picto='opensurvey.png@opensurvey';
// Data directories to create when module is enabled
$this->dirs = array();
//$this->dirs[0] = DOL_DATA_ROOT.'/mymodule;
//$this->dirs[1] = DOL_DATA_ROOT.'/mymodule/temp;
// Config pages. Put here list of php page names stored in admin directory used to setup module
$this->config_page_url = array("index.php@opensurvey");
// Dependencies
$this->depends = array(); // List of modules id that must be enabled if this module is enabled
$this->requiredby = array(); // List of modules id to disable if this one is disabled
$this->phpmin = array(4,1); // Minimum version of PHP required by module
$this->need_dolibarr_version = array(2,4); // Minimum version of Dolibarr required by module
// Constants
$this->const = array(); // List of parameters
// Dictionnaries
$this->dictionnaries=array();
// Boxes
$this->boxes = array(); // List of boxes
$r=0;
// Add here list of php file(s) stored in includes/boxes that contains class to show a box.
// Example:
//$this->boxes[$r][1] = "myboxa.php";
//$r++;
//$this->boxes[$r][1] = "myboxb.php";
//$r++;
// Permissions
$this->rights = array(); // Permission array used by this module
$r=0;
// Add here list of permission defined by an id, a label, a boolean and two constant strings.
// Example:
$this->rights[$r][0] = 55000; // Permission id (must not be already used)
$this->rights[$r][1] = 'Read surveys'; // Permission label
$this->rights[$r][2] = 'r'; // Permission by default for new user (0/1)
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'survey'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
$this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
$r++;
// Add here list of permission defined by an id, a label, a boolean and two constant strings.
// Example:
$this->rights[$r][0] = 55001; // Permission id (must not be already used)
$this->rights[$r][1] = 'Create/modify surveys'; // Permission label
$this->rights[$r][2] = 'w'; // Permission by default for new user (0/1)
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'survey'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
$this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
$r++;
// Main menu entries
$this->menus = array(); // List of menus to add
$r=0;
$this->menu[$r]=array( 'fk_menu'=>0, // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'type'=>'top',
'titre'=>'Surveys',
'mainmenu'=>'opensurvey',
'url'=>'/opensurvey/index.php',
'langs'=>'opensurvey@opensurvey',
'position'=>200,
'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled.
'perms'=>'$user->rights->opensurvey->survey->read',
'target'=>'',
'user'=>0);
$r++;
$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'type'=>'left',
'titre'=>'Survey',
'mainmenu'=>'opensurvey',
'leftmenu'=>'opensurvey',
'url'=>'/opensurvey/index.php?mainmenu=opensurvey&leftmenu=opensurvey',
'langs'=>'opensurvey@opensurvey',
'position'=>200,
'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled.
'perms'=>'',
'target'=>'',
'user'=>0);
$r++;
$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=opensurvey,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'type'=>'left',
'titre'=>'NewSurvey',
'mainmenu'=>'opensurvey',
'leftmenu'=>'opensurvey_new',
'url'=>'/opensurvey/public/index.php?origin=dolibarr',
'langs'=>'opensurvey@opensurvey',
'position'=>210,
'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled.
'perms'=>'',
'target'=>'_blank',
'user'=>0);
$r++;
$this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=opensurvey,fk_leftmenu=opensurvey', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
'type'=>'left',
'titre'=>'List',
'mainmenu'=>'opensurvey',
'leftmenu'=>'opensurvey_list',
'url'=>'/opensurvey/list.php',
'langs'=>'opensurvey@opensurvey',
'position'=>220,
'enabled'=>'$conf->opensurvey->enabled', // Define condition to show or hide menu entry. Use '$conf->NewsSubmitter->enabled' if entry must be visible if module is enabled.
'perms'=>'',
'target'=>'',
'user'=>0);
$r++;
}
/**
* Function called when module is enabled.
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
* It also creates data directories
*
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
function init($options='')
{
$sql = array();
$result=$this->load_tables();
return $this->_init($sql,$options);
}
/**
* Function called when module is disabled.
* Remove from database constants, boxes and permissions from Dolibarr database.
* Data directories are not deleted
*
* @param string $options Options when enabling module ('', 'noboxes')
* @return int 1 if OK, 0 if KO
*/
function remove($options='')
{
$sql = array();
return $this->_remove($sql,$options);
}
/**
* Create tables and keys required by module
* Files mymodule.sql and mymodule.key.sql with create table and create keys
* commands must be stored in directory /mymodule/sql/
* This function is called by this->init.
*
* @return int <=0 if KO, >0 if OK
*/
function load_tables()
{
return $this->_load_tables('/opensurvey/sql/');
}
}
?>

View File

@ -0,0 +1,62 @@
<?php
/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/opensurvey/admin/index.php
* \ingroup opensurvey
* \brief Setup page of opensurvey
*/
require_once('../../main.inc.php');
require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
require_once(DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php");
// Security check
if (!$user->admin) accessforbidden();
/*
* View
*/
$langs->load("opensurvey@opensurvey");
llxHeader();
print_fiche_titre($langs->trans("OpenSurveyArea"));
echo $langs->trans("OpenSurveyNothingToSetup").'<br><br>'."\n";
// Link
print img_picto('','object_globe.png').' '.$langs->trans("PublicLinkToCreateSurvey").':<br>';
// Define $urlwithroot
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
$url=$urlwithouturlroot.dol_buildpath('/opensurvey/public/index.php',1);
$urllink='<a href="'.$url.'" target="_blank">'.$url.'</a>';
print $urllink;
llxFooter();
$db->close();
?>

352
htdocs/opensurvey/adminstuds.php Executable file
View File

@ -0,0 +1,352 @@
<?php
/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/opensurvey/adminstuds.php
* \ingroup opensurvey
* \brief Page to edit survey
*/
require_once('../main.inc.php');
require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
require_once(DOL_DOCUMENT_ROOT."/opensurvey/class/opensurveysondage.class.php");
require_once(DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php");
// Security check
if (!$user->admin) accessforbidden();
// Initialisation des variables
$action=GETPOST('action');
$numsondage = $numsondageadmin = '';
if (GETPOST('sondage'))
{
if (strlen(GETPOST('sondage')) == 24) // recuperation du numero de sondage admin (24 car.) dans l'URL
{
$numsondageadmin=GETPOST("sondage",'alpha');
$numsondage=substr($numsondageadmin, 0, 16);
}
else
{
$numsondageadmin='';
$numsondage=GETPOST("sondage",'alpha');
}
}
$object=new Opensurveysondage($db);
$expiredate=dol_mktime(0, 0, 0, GETPOST('expiremonth'), GETPOST('expireday'), GETPOST('expireyear'));
/*
* Actions
*/
// Delete
if ($action == 'delete_confirm')
{
$result=$object->delete($user,'',$numsondageadmin);
header('Location: '.dol_buildpath('/opensurvey/list.php',1));
exit();
}
// Update
if ($action == 'update')
{
$error=0;
if (! GETPOST('nouveautitre'))
{
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Title")),'errors');
$error++;
$action = 'edit';
}
if (! $error)
{
$res=$object->fetch(0,$numsondageadmin);
if ($res < 0) dol_print_error($db,$object->error);
}
if (! $error)
{
$object->titre = GETPOST('nouveautitre');
$object->commentaires = GETPOST('nouveauxcommentaires');
$object->mail_admin = GETPOST('nouvelleadresse');
$object->date_fin = $expiredate;
$object->survey_link_visible = GETPOST('survey_link_visible')=='on'?1:0;
$object->canedit = GETPOST('canedit')=='on'?1:0;
$res=$object->update($user);
if ($res < 0)
{
setEventMessage($object->error,'errors');
$action='edit';
}
}
}
// Add comment
if (GETPOST('ajoutcomment'))
{
$error=0;
if (! GETPOST('comment'))
{
$error++;
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Comment")),'errors');
}
if (! GETPOST('commentuser'))
{
$error++;
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("User")),'errors');
}
if (! $error)
{
$comment = GETPOST("comment");
$comment_user = GETPOST('commentuser');
$sql = "INSERT INTO ".MAIN_DB_PREFIX."opensurvey_comments (id_sondage, comment, usercomment)";
$sql.= " VALUES ('".$db->escape($numsondage)."','".$db->escape($comment)."','".$db->escape($comment_user)."')";
$resql = $db->query($sql);
dol_syslog("sql=".$sql);
if (! $resql)
{
$err |= COMMENT_INSERT_FAILED;
}
}
}
// Delete comment
$idcomment=GETPOST('deletecomment','int');
if ($idcomment)
{
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'opensurvey_comments WHERE id_comment = '.$idcomment;
$resql = $db->query($sql);
}
/*
* View
*/
$form=new Form($db);
$result=$object->fetch(0,$numsondage);
if ($result <= 0)
{
print $langs->trans("ErrorRecordNotFound");
llxFooter();
exit;
}
$arrayofjs=array();
$arrayofcss=array('/opensurvey/css/style.css');
llxHeader('',$object->titre, 0, 0, 0, 0, $arrayofjs, $arrayofcss);
// Define format of choices
$toutsujet=explode(",",$object->sujet);
$listofanswers=array();
foreach ($toutsujet as $value)
{
$tmp=explode('@',$value);
$listofanswers[]=array('label'=>$tmp[0],'format'=>($tmp[1]?$tmp[1]:'checkbox'));
}
$toutsujet=str_replace("@","<br>",$toutsujet);
$toutsujet=str_replace("°","'",$toutsujet);
print '<form name="updatesurvey" action="'.$_SERVER["PHP_SELF"].'?sondage='.$numsondageadmin.'" method="POST">'."\n";
print '<input type="hidden" name="action" value="update">';
$head = array();
$head[0][0] = '';
$head[0][1] = $langs->trans("Card");
$head[0][2] = 'general';
$h++;
$head[1][0] = 'adminstuds_preview.php?sondage='.$object->id_sondage_admin;
$head[1][1] = $langs->trans("SurveyResults").'/'.$langs->trans("Preview");
$head[1][2] = 'preview';
$h++;
print dol_get_fiche_head($head,'general',$langs->trans("Survey"),0,dol_buildpath('/opensurvey/img/object_opensurvey.png',1),1);
print '<table class="border" width="100%">';
$linkback = '<a href="'.dol_buildpath('/opensurvey/list.php',1).'">'.$langs->trans("BackToList").'</a>';
// Ref
print '<tr><td width="18%">'.$langs->trans('Ref').'</td>';
print '<td colspan="3">';
print $form->showrefnav($object, 'sondage', $linkback, 1, 'id_sondage_admin', 'id_sondage_admin');
print '</td>';
print '</tr>';
// Type
$type=($object->format=="A"||$object->format=="A+")?'classic':'date';
print '<tr><td>'.$langs->trans("Type").'</td><td colspan="2">';
print img_picto('',dol_buildpath('/opensurvey/img/'.($type == 'classic'?'chart-32.png':'calendar-32.png'),1),'width="16"',1);
print ' '.$langs->trans($type=='classic'?"TypeClassic":"TypeDate").'</td></tr>';
// Title
print '<tr><td>';
$adresseadmin=$object->mail_admin;
print $langs->trans("Title") .'</td><td colspan="2">';
if ($action == 'edit')
{
print '<input type="text" name="nouveautitre" size="40" value="'.dol_escape_htmltag($object->titre).'">';
}
else print $object->titre;
print '</td></tr>';
// Auteur
print '<tr><td>';
print $langs->trans("Author") .'</td><td colspan="2">';
print $object->nom_admin;
print '</td></tr>';
// Description
print '<tr><td>'.$langs->trans("Description") .'</td><td colspan="2">';
if ($action == 'edit')
{
print '<textarea name="nouveauxcommentaires" rows="7" cols="80">'.$object->commentaires.'</textarea>'."\n";
}
else print dol_nl2br($object->commentaires);
print '</td></tr>';
// EMail
print '<tr><td>'.$langs->trans("EMail") .'</td><td colspan="2">';
if ($action == 'edit')
{
print '<input type="text" name="nouvelleadresse" size="40" value="'.$object->mail_admin.'">';
}
else print dol_print_email($object->mail_admin);
print '</td></tr>';
// Can edit other votes
print '<tr><td>'.$langs->trans('CanEditVotes').'</td><td colspan="2">';
if ($action == 'edit')
{
print '<input type="checkbox" name="canedit" size="40"'.($object->canedit?' checked="true"':'').'">';
}
else print yn($object->canedit);
print '</td></tr>';
// Expire date
print '<tr><td>'.$langs->trans('ExpireDate').'</td><td colspan="2">';
if ($action == 'edit') print $form->select_date($expiredate?$expiredate:$object->date_fin,'expire');
else print dol_print_date($object->date_fin,'day');
print '</td></tr>';
// Link
print '<tr><td>'.img_picto('','object_globe.png').' '.$langs->trans("UrlForSurvey",'').'</td><td colspan="2">';
// Define $urlwithroot
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
$url=$urlwithouturlroot.dol_buildpath('/opensurvey/public/studs.php',1).'?sondage='.$numsondage;
$urllink='<a href="'.$url.'" target="_blank">'.$url.'</a>';
print $urllink;
print '</table>';
if ($action == 'edit') print '<center><br><input type="submit" class="button" name="save" value="'.dol_escape_htmltag($langs->trans("Save")).'"></center>';
print '</form>'."\n";
dol_fiche_end();
/*
* Barre d'actions
*/
print '<div class="tabsAction">';
if ($action != 'edit') print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&sondage=' . $numsondageadmin . '">'.$langs->trans("Modify") . '</a>';
if ($action != 'edit') print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?suppressionsondage=1&sondage='.$numsondageadmin.'&amp;action=delete">'.$langs->trans('Delete').'</a>';
print '</div>';
if ($action == 'delete')
{
print $form->formconfirm($_SERVER["PHP_SELF"].'?&sondage='.$numsondageadmin, $langs->trans("RemovePoll"), $langs->trans("ConfirmRemovalOfPoll",$id), 'delete_confirm', '', '', 1);
}
print '<br>';
print '<form name="formulaire5" action="#" method="POST">'."\n";
print_fiche_titre($langs->trans("CommentsOfVoters"),'','');
// Comment list
$sql = 'SELECT id_comment, usercomment, comment';
$sql.= ' FROM '.MAIN_DB_PREFIX.'opensurvey_comments';
$sql.= " WHERE id_sondage='".$db->escape($numsondage)."'";
$sql.= " ORDER BY id_comment";
$resql = $db->query($sql);
$num_rows=$db->num_rows($resql);
if ($num_rows > 0)
{
$i = 0;
while ( $i < $num_rows)
{
$obj=$db->fetch_object($resql);
print '<a href="'.dol_buildpath('/opensurvey/adminstuds.php',1).'?deletecomment='.$obj->id_comment.'&sondage='.$numsondageadmin.'"> '.img_picto('', 'delete.png').'</a> ';
print $obj->usercomment.' : '.dol_nl2br($obj->comment)." <br>";
$i++;
}
}
else
{
print $langs->trans("NoCommentYet").'<br>';;
}
print '<br>';
// Add comment
print $langs->trans("AddACommentForPoll") . '<br>';
print '<textarea name="comment" rows="2" cols="80"></textarea><br>'."\n";
print $langs->trans("Name") .' : <input type=text name="commentuser"><br>'."\n";
print '<input type="submit" class="button" name="ajoutcomment" value="'.dol_escape_htmltag($langs->trans("AddComment")).'"><br>'."\n";
if (isset($erreur_commentaire_vide) && $erreur_commentaire_vide=="yes") {
print "<font color=#FF0000>" . $langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Name")) . "</font>";
}
print '</form>';
llxFooterSurvey();
$db->close();
?>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,512 @@
<?php
/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file dev/skeletons/opensurveysondage.class.php
* \ingroup mymodule othermodule1 othermodule2
* \brief This file is an example for a CRUD class file (Create/Read/Update/Delete)
* Initialy built by build_class_from_table on 2013-03-10 00:32
*/
// Put here all includes required by your class file
require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php");
//require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php");
//require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
/**
* Put here description of your class
*/
class Opensurveysondage extends CommonObject
{
var $db; //!< To store db handler
var $error; //!< To return error code (or message)
var $errors=array(); //!< To return several error codes (or messages)
var $element='opensurvey_sondage'; //!< Id that identify managed objects
var $table_element='opensurvey_sondage'; //!< Name of table without prefix where object is stored
var $id;
var $id_sondage;
var $commentaires;
var $mail_admin;
var $nom_admin;
var $titre;
var $id_sondage_admin;
var $date_fin='';
var $format;
var $mailsonde;
var $survey_link_visible;
var $canedit;
/**
* Constructor
*
* @param DoliDb $db Database handler
*/
function __construct($db)
{
$this->db = $db;
return 1;
}
/**
* Create object into database
*
* @param User $user User that creates
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, Id of created object if OK
*/
function create($user, $notrigger=0)
{
global $conf, $langs;
$error=0;
// Clean parameters
if (isset($this->id_sondage)) $this->id_sondage=trim($this->id_sondage);
if (isset($this->commentaires)) $this->commentaires=trim($this->commentaires);
if (isset($this->mail_admin)) $this->mail_admin=trim($this->mail_admin);
if (isset($this->nom_admin)) $this->nom_admin=trim($this->nom_admin);
if (isset($this->titre)) $this->titre=trim($this->titre);
if (isset($this->id_sondage_admin)) $this->id_sondage_admin=trim($this->id_sondage_admin);
if (isset($this->format)) $this->format=trim($this->format);
if (isset($this->mailsonde)) $this->mailsonde=trim($this->mailsonde);
if (isset($this->survey_link_visible)) $this->survey_link_visible=trim($this->survey_link_visible);
if (isset($this->canedit)) $this->canedit=trim($this->canedit);
// Check parameters
// Put here code to add control on parameters values
// Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."opensurvey_sondage(";
$sql.= "id_sondage,";
$sql.= "commentaires,";
$sql.= "mail_admin,";
$sql.= "nom_admin,";
$sql.= "titre,";
$sql.= "id_sondage_admin,";
$sql.= "date_fin,";
$sql.= "format,";
$sql.= "mailsonde,";
$sql.= "survey_link_visible,";
$sql.= "canedit";
$sql.= ") VALUES (";
$sql.= " ".(! isset($this->id_sondage)?'NULL':"'".$this->id_sondage."'").",";
$sql.= " ".(! isset($this->commentaires)?'NULL':"'".$this->db->escape($this->commentaires)."'").",";
$sql.= " ".(! isset($this->mail_admin)?'NULL':"'".$this->db->escape($this->mail_admin)."'").",";
$sql.= " ".(! isset($this->nom_admin)?'NULL':"'".$this->db->escape($this->nom_admin)."'").",";
$sql.= " ".(! isset($this->titre)?'NULL':"'".$this->db->escape($this->titre)."'").",";
$sql.= " ".(! isset($this->id_sondage_admin)?'NULL':"'".$this->id_sondage_admin."'").",";
$sql.= " ".(! isset($this->date_fin) || dol_strlen($this->date_fin)==0?'NULL':$this->db->idate($this->date_fin)).",";
$sql.= " ".(! isset($this->format)?'NULL':"'".$this->db->escape($this->format)."'").",";
$sql.= " ".(! isset($this->mailsonde)?'NULL':"'".$this->mailsonde."'").",";
$sql.= " ".(! isset($this->survey_link_visible)?'NULL':"'".$this->survey_link_visible."'").",";
$sql.= " ".(! isset($this->canedit)?'NULL':"'".$this->canedit."'")."";
$sql.= ")";
$this->db->begin();
dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (! $error)
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."opensurvey_sondage");
if (! $notrigger)
{
// Uncomment this and change MYOBJECT to your own tag if you
// want this action calls a trigger.
//// Call triggers
//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
//$interface=new Interfaces($this->db);
//$result=$interface->run_triggers('MYOBJECT_CREATE',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
}
}
// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
}
else
{
$this->db->commit();
return $this->id;
}
}
/**
* Load object in memory from the database
*
* @param int $id Id object
* @param string $numsurvey Ref of survey (admin or not)
* @return int <0 if KO, >0 if OK
*/
function fetch($id,$numsurvey='')
{
global $langs;
$sql = "SELECT";
//$sql.= " t.rowid,";
$sql.= " t.id_sondage,";
$sql.= " t.commentaires,";
$sql.= " t.mail_admin,";
$sql.= " t.nom_admin,";
$sql.= " t.titre,";
$sql.= " t.id_sondage_admin,";
$sql.= " t.date_fin,";
$sql.= " t.format,";
$sql.= " t.mailsonde,";
$sql.= " t.survey_link_visible,";
$sql.= " t.canedit,";
$sql.= " t.sujet,";
$sql.= " t.tms";
$sql.= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as t";
if ($id > 0) $sql.= " WHERE t.rowid = ".$id;
else if (strlen($numsurvey) == 16) $sql.= " WHERE t.id_sondage = '".$numsurvey."'";
else $sql.= " WHERE t.id_sondage_admin = '".$numsurvey."'";
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql);
//$this->id = $obj->rowid;
$this->ref = $obj->id_sondage_admin;
$this->id_sondage = $obj->id_sondage;
$this->commentaires = $obj->commentaires;
$this->mail_admin = $obj->mail_admin;
$this->nom_admin = $obj->nom_admin;
$this->titre = $obj->titre;
$this->id_sondage_admin = $obj->id_sondage_admin;
$this->date_fin = $this->db->jdate($obj->date_fin);
$this->format = $obj->format;
$this->mailsonde = $obj->mailsonde;
$this->survey_link_visible = $obj->survey_link_visible;
$this->canedit = $obj->canedit;
$this->sujet = $obj->sujet;
$this->date_m = $this->db->jdate($obj->tls);
$ret=1;
}
else $ret=0;
$this->db->free($resql);
}
else
{
$this->error="Error ".$this->db->lasterror();
dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR);
$ret=-1;
}
return $ret;
}
/**
* Update object into database
*
* @param User $user User that modifies
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
function update($user=0, $notrigger=0)
{
global $conf, $langs;
$error=0;
// Clean parameters
if (isset($this->id_sondage)) $this->id_sondage=trim($this->id_sondage);
if (isset($this->commentaires)) $this->commentaires=trim($this->commentaires);
if (isset($this->mail_admin)) $this->mail_admin=trim($this->mail_admin);
if (isset($this->nom_admin)) $this->nom_admin=trim($this->nom_admin);
if (isset($this->titre)) $this->titre=trim($this->titre);
if (isset($this->id_sondage_admin)) $this->id_sondage_admin=trim($this->id_sondage_admin);
if (isset($this->format)) $this->format=trim($this->format);
if (isset($this->mailsonde)) $this->mailsonde=trim($this->mailsonde);
if (isset($this->survey_link_visible)) $this->survey_link_visible=trim($this->survey_link_visible);
if (isset($this->canedit)) $this->canedit=trim($this->canedit);
// Check parameters
// Put here code to add a control on parameters values
// Update request
$sql = "UPDATE ".MAIN_DB_PREFIX."opensurvey_sondage SET";
$sql.= " id_sondage='".(isset($this->id_sondage)?$this->id_sondage:"null")."',";
$sql.= " commentaires=".(isset($this->commentaires)?"'".$this->db->escape($this->commentaires)."'":"null").",";
$sql.= " mail_admin=".(isset($this->mail_admin)?"'".$this->db->escape($this->mail_admin)."'":"null").",";
$sql.= " nom_admin=".(isset($this->nom_admin)?"'".$this->db->escape($this->nom_admin)."'":"null").",";
$sql.= " titre=".(isset($this->titre)?"'".$this->db->escape($this->titre)."'":"null").",";
$sql.= " id_sondage_admin='".(isset($this->id_sondage_admin)?$this->id_sondage_admin:"null")."',";
$sql.= " date_fin=".(dol_strlen($this->date_fin)!=0 ? "'".$this->db->idate($this->date_fin)."'" : 'null').",";
$sql.= " format=".(isset($this->format)?"'".$this->db->escape($this->format)."'":"null").",";
$sql.= " mailsonde=".(isset($this->mailsonde)?$this->mailsonde:"null").",";
$sql.= " survey_link_visible=".(isset($this->survey_link_visible)?$this->survey_link_visible:"null").",";
$sql.= " canedit=".(isset($this->canedit)?$this->canedit:"null")."";
//$sql.= " WHERE rowid=".$this->id;
$sql.= " WHERE id_sondage_admin='".$this->id_sondage_admin."'";
$this->db->begin();
dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
if (! $error)
{
if (! $notrigger)
{
// Uncomment this and change MYOBJECT to your own tag if you
// want this action calls a trigger.
//// Call triggers
//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
//$interface=new Interfaces($this->db);
//$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
}
}
// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
}
else
{
$this->db->commit();
return 1;
}
}
/**
* Delete object in database
*
* @param User $user User that deletes
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @param string $numsondageadmin Num sondage to delete
* @return int <0 if KO, >0 if OK
*/
function delete($user, $notrigger=0, $numsondageadmin)
{
global $conf, $langs;
$error=0;
$this->db->begin();
if (! $error)
{
if (! $notrigger)
{
// Uncomment this and change MYOBJECT to your own tag if you
// want this action calls a trigger.
//// Call triggers
//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
//$interface=new Interfaces($this->db);
//$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
//// End call triggers
}
}
if (! $error)
{
$sql='DELETE FROM '.MAIN_DB_PREFIX."opensurvey_comments WHERE id_sondage_admin = '".$numsondageadmin."'";
dol_syslog(get_class($this)."::delete sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
$sql='DELETE FROM '.MAIN_DB_PREFIX."opensurvey_user_studs WHERE id_sondage_admin = '".$numsondageadmin."'";
dol_syslog(get_class($this)."::delete sql=".$sql, LOG_DEBUG);
$resql=$this->db->query($sql);
$sql = "DELETE FROM ".MAIN_DB_PREFIX."opensurvey_sondage";
$sql.= " WHERE id_sondage_admin = '".$numsondageadmin."'";
dol_syslog(get_class($this)."::delete sql=".$sql);
$resql = $this->db->query($sql);
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
}
// Commit or rollback
if ($error)
{
foreach($this->errors as $errmsg)
{
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
$this->error.=($this->error?', '.$errmsg:$errmsg);
}
$this->db->rollback();
return -1*$error;
}
else
{
$this->db->commit();
return 1;
}
}
/**
* Return array of lines
*
* @return array Array of lines
*/
function fetch_lines()
{
$ret=array();
$sql = "SELECT id_users, nom, reponses FROM ".MAIN_DB_PREFIX."opensurvey_user_studs";
$sql.= " WHERE id_sondage = '".$this->id_sondage."'";
$resql=$this->db->query($sql);
if ($resql)
{
$num=$this->db->num_rows($resql);
$i=0;
while ($i < $num)
{
$obj=$this->db->fetch_object($resql);
$tmp=array('id_users'=>$obj->id_users, 'nom'=>$obj->nom, 'reponses'=>$obj->reponses);
$ret[]=$tmp;
$i++;
}
}
else dol_print_error($this->db);
$this->lines=$ret;
return $this->lines;
}
/**
* Load an object from its id and create a new one in database
*
* @param int $fromid Id of object to clone
* @return int New id of clone
*/
function createFromClone($fromid)
{
global $user,$langs;
$error=0;
$object=new Opensurveysondage($this->db);
$this->db->begin();
// Load source object
$object->fetch($fromid);
$object->id=0;
$object->statut=0;
// Clear fields
// ...
// Create clone
$result=$object->create($user);
// Other options
if ($result < 0)
{
$this->error=$object->error;
$error++;
}
if (! $error)
{
}
// End
if (! $error)
{
$this->db->commit();
return $object->id;
}
else
{
$this->db->rollback();
return -1;
}
}
/**
* Initialise object with example values
* Id must be 0 if object instance is a specimen
*
* @return void
*/
function initAsSpecimen()
{
$this->id=0;
$this->id_sondage='';
$this->commentaires='';
$this->mail_admin='';
$this->nom_admin='';
$this->titre='';
$this->id_sondage_admin='';
$this->date_fin='';
$this->format='';
$this->mailsonde='';
$this->survey_link_visible='';
$this->canedit=0;
}
}
?>

View File

@ -0,0 +1,532 @@
/* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2007-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
.survey_invitation
{
font-color: #445566;
font-weight: bold;
}
.corps {
font-family: "Lucida Grande",Verdana,Arial,sans-serif;
font-size: 14px;
margin: auto;
padding: 20px;
overflow-x: auto;
border: 2px solid #999999;
background-color: #fff;
box-shadow: 2px 2px 2px #F5F5F5;
-moz-border-radius: 10px;
border-radius: 10px;
}
.index_date, .index_sondage {
float: left;
width: 50%;
text-align: center;
}
.orange {
color: #fef4e9;
border: solid 1px #da7c0c;
background: #f78d1d;
background: -webkit-gradient(linear, left top, left bottom, from(#faa51a), to(#f47a20));
background: -moz-linear-gradient(top, #faa51a, #f47a20);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#faa51a', endColorstr='#f47a20');
}
.orange:active {
color: #fcd3a5;
background: -webkit-gradient(linear, left top, left bottom, from(#f47a20), to(#faa51a));
background: -moz-linear-gradient(top, #f47a20, #faa51a);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f47a20', endColorstr='#faa51a');
}
.orange:hover {
background: #f47c20;
background: -webkit-gradient(linear, left top, left bottom, from(#f88e11), to(#f06015));
background: -moz-linear-gradient(top, #f88e11, #f06015);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f88e11', endColorstr='#f06015');
}
.blue {
color: #d9eef7;
border: solid 1px #0076a3;
background: #0095cd;
background: -webkit-gradient(linear, left top, left bottom, from(#00adee), to(#0078a5));
background: -moz-linear-gradient(top, #00adee, #0078a5);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00adee', endColorstr='#0078a5');
}
.blue:active {
color: #80bed6;
background: -webkit-gradient(linear, left top, left bottom, from(#0078a5), to(#00adee));
background: -moz-linear-gradient(top, #0078a5, #00adee);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0078a5', endColorstr='#00adee');
}
.blue:hover {
background: #007ead;
background: -webkit-gradient(linear, left top, left bottom, from(#0095cc), to(#00678e));
background: -moz-linear-gradient(top, #0095cc, #00678e);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0095cc', endColorstr='#00678e');
}
/*
==========================================================================
Université de Strasbourg - Direction Informatique
Auteur : Guilhem BORGHESI
Création : Février 2008
borghesi@unistra.fr
Ce logiciel est régi par la licence CeCILL-B soumise au droit français et
respectant les principes de diffusion des logiciels libres. Vous pouvez
utiliser, modifier et/ou redistribuer ce programme sous les conditions
de la licence CeCILL-B telle que diffusée par le CEA, le CNRS et l'INRIA
sur le site "http://www.cecill.info".
Le fait que vous puissiez accéder à cet en-tête signifie que vous avez
pris connaissance de la licence CeCILL-B, et que vous en avez accepté les
termes. Vous pouvez trouver une copie de la licence dans le fichier LICENCE.
==========================================================================
Université de Strasbourg - Direction Informatique
Author : Guilhem BORGHESI
Creation : Feb 2008
borghesi@unistra.fr
This software is governed by the CeCILL-B license under French law and
abiding by the rules of distribution of free software. You can use,
modify and/ or redistribute the software under the terms of the CeCILL-B
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
The fact that you are presently reading this means that you have had
knowledge of the CeCILL-B license and that you accept its terms. You can
find a copy of this license in the file LICENSE.
==========================================================================
*/
/*
Le fichier style.css est le fichier de style de studs. Il se trouve à la racine
du répertoire studs. Il contient toutes les mises en forme des fichiers PHP
de Studs.
*/
/*bandeau de titre*/
div.bandeau{
line-height:35px;
text-align:center;
background-color: #0b419b;
color:white;
vertical-align:middle;
font-size:35px;
font-family:arial;
padding:8px;
height:35px;
position:static;
top:6px;
left:6px;
right:6px;
}
div.logo{
height:64px;
float:right;
top:8px;
right:8px;
margin-left: 0;
margin-right:0;
margin-bottom:auto;
}
/*Sous bandeau avec bouton de navigation*/
div.bandeautitre{
height:17px;
font-size:14px;
font-weight:bold;
text-align:center;
vertical-align:middle;
font-family:arial;
padding:3px;
position:static;
top:57px;
left:6px;
right:6px;
}
div.sousbandeau{
height:17px;
background-color: #DDDDDD;
font-size:11px;
color:black;
vertical-align:middle;
font-family:arial;
padding:3px;
position:static;
top:80px;
left:6px;
right:6px;
}
/*bandeau de pied*/
div.surbandeaupied{
background-color: #0077DD;
position:absolute;
bottom:30px;
left:6px;
right:6px;
height:6px;
}
div.bandeaupied{
text-align:center;
background-color: #0b419b;
color:white;
font-size:11px;
font-family:arial;
padding:6px;
position:fixed;
bottom:6px;
left:6px;
right:6px;
margin:2px;
}
div.surbandeaupiedmobile{
background-color: #0077DD;
position:static;
bottom:32px;
left:6px;
right:6px;
height:6px;
}
div.bandeaupiedmobile{
text-align:center;
background-color: #0b419b;
color:white;
font-size:11px;
font-family:arial;
padding:6px;
position:static;
}
/*les boutons se trouvant dans le sousbandeau*/
div.sousbandeau a, div.sousbandeau span.sousbandeaulangue a {
background-color: #0b419b;
height:16px;
padding: 2px 6px 2px 6px;
vertical-align:middle;
text-align:center;
margin-left:10px;
margin-right:10px;
font-family:arial;
color:white;
font-size:10px;
text-decoration:none;
}
span.sousbandeaulangue {
margin-left:6px;
margin-right:6px;
float:right;
}
/*corps de la page index.php*/
div.corps{
font-size:12px;
font-family:arial;
position:static;
padding:15px;
}
div.corps table{
font-family:arial;
font-size:12px;
font-weight:bold;
}
div.corpscentre{
font-size:12px;
font-family:arial;
text-align:center;
position:absolute;
top:150px;
margin-right:10%;
margin-left:10%;
width:80%;
}
/*affichage des jours*/
div.jourschoisis {
background-color: #DDD;
padding:10px;
text-align: center;
position:static;
left:700px;
top:170px;
font-size:12px;
width:100%;
}
/*presenation des pages*/
div.bodydate {
padding:10px;
font-family:arial;
font-size:12px;
text-align:center;
position:static;
top:330px;
left:20px;
right:20px;
}
div.bodydate table{
font-family:arial;
font-size:12px;
font-weight:bold;
}
/*cadre de commentaires*/
div.presentationdate {
width:100%;
font-family:arial;
text-align:center;
font-size:12px;
border-top:1px solid;
border-bottom:1px solid;
border-left: none;
border-right: none;
border-color:#969696;
position:static;
top:110px;
margin-top:10px;
}
div.presentationdatefin {
width:40%;
padding:10px;
font-family:arial;
text-align:center;
font-size:12px;
border-width:1px;
border-style:solid;
margin-top: 10px;
margin-left: 30%;
margin-right: 30%;
position:static;
}
/*cadre principal de studs.php*/
div.cadre {
padding:10px;
font-family:arial;
font-size:12px;
position:static;
top:235px;
text-align:center;
margin:0 auto;
}
/*la table des résultats dans l'affichage de sondage*/
div.cadre table.resultats {
text-align: center;
margin:0 auto;
}
td.nom {
min-width: 160px;
}
td.vide {
min-width: 60px;
}
div.cadre td {
height:21px;
}
/*case de tableau OK dans affichage de sondage*/
div.cadre td.ok {
background-color: #66FF99;
font-size:12px;
text-align:center;
}
/*Case de tableau NON dans affichage de sondage*/
div.cadre td.non {
background-color: #FF7777;
min-width: 60px;
}
/*Case de tableau VIDE dans affichage de sondage*/
div.cadre td.vide {
background-color: #DDDDDD;
text-align:center;
}
/*Case de tableau contenant les noms dans affichage de sondage*/
div.cadre td.nom {
background-color: #DDDDDD;
font-size:12px;
text-align:center;
}
div.cadre td.casevide {
background-color: white;
text-align:center;
}
/*les cases contenant les sommes de chaque colonne dans l'affichage de calendrier*/
div.cadre td.somme {
font-weight: bold;
font-size:14px;
}
/*Case de tableau SUJET dans affichage de sondage*/
div.cadre td.sujet, div.cadre td.jour, div.cadre td.heure {
border: 2px;
background-color: #DDDDDD;
font-size:14px;
padding:1px 5px;
}
div.cadre td.annee {
border: 2px;
background-color: #969696;
font-weight: bold;
font-size:14px;
padding:1px 5px;
}
div.cadre td.mois {
border: 2px;
background-color: #C0C0C0;
font-weight: bold;
font-size:14px;
padding:1px 5px;
}
/*affichage du calendrier*/
div.calendrier {
padding:10px;
background-color: #AAA;
width:490px;
font-size:12px;
font-family:arial;
margin-left: 30%;
margin-right: 30%;
position:static;
}
/*jour de la semaine dans calendrier*/
div.calendrier td.joursemaine {
width:65px;
text-align: center;
font-family:arial;
font-size:14px;
border: 2px;
background-color: white;
}
div.calendrier td.jourwe {
width:65px;
text-align: center;
font-family:arial;
font-size:14px;
border: 2px;
background-color: #C0C0C0;
}
/*jour avant le premier jour du mois dans calendrier*/
div.calendrier td.avant {
width:65px;
text-align: center;
border: 2px;
font-family:arial;
font-size:13px;
background-color: #DDDDDD;
}
/*jour libre dans calendrier*/
div.calendrier td.libre {
width:65px;
text-align: center;
border: 2px;
background-color: #66FF99;
}
/*jour deja selectionné dans calendrier*/
div.calendrier td.choisi {
width:65px;
text-align: center;
border: 2px;
background-color: #0077DD;
}
/* Le paragraphe de fin */
p.affichageresultats{
text-align: center;
font-family:arial;
font-size:13px;
}
div.comment{
width:100%;
}
div.comment span.usercomment{
font-weight:bold;
}
a.affichageexport{
text-align: center;
font-family:arial;
font-size:10px;
margin-left:10px;
text-decoration: none;
}
div.titregestionadmin{
text-align: center;
font-weight:bold;
font-size:18px;
padding:10px;
}
.bouton {
width: 65px;
border:0px;
padding:0px 0 0 0;
margin:0px;
cursor:pointer;
font-family:arial;
font-size:13px;
}
/*les boutons pour choisir un jour non selectionné*/
.ON {
background-color: #BBBBCC;
}
/*les boutons pour deselectionner un jour deja choisi*/
.OFF {
background-color: #AAFFAA;
}
div.nouveau_sondage a {
text-decoration: none;
}
div.nouveau_sondage span img {
vertical-align: middle;
border: 0px;
}
div.nouveau_sondage span {
margin-left: 20px;
}
div.error, div.addcomment {
text-align:center;
border: 1px;
font-family: arial;
font-size: 13px;
}
ul.exports {
text-align:center;
list-style-type : none ;
}
li.error {
color: red;
}
.half {
-moz-transform:scale(0.5);
-webkit-transform:scale(0.5);
transform:scale(0.5);
}

292
htdocs/opensurvey/fonctions.php Executable file
View File

@ -0,0 +1,292 @@
<?php
/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/opensurvey/fonction.php
* \ingroup opensurvey
* \brief Functions for module
*/
/**
* Show header for new member
*
* @param string $title Title
* @param string $head Head array
* @param int $disablejs More content into html header
* @param int $disablehead More content into html header
* @param array $arrayofjs Array of complementary js files
* @param array $arrayofcss Array of complementary css files
* @return void
*/
function llxHeaderSurvey($title, $head="", $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='')
{
global $user, $conf, $langs, $mysoc;
top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers
print '<body id="mainbody" class="publicnewmemberform" style="margin-top: 10px;">';
showlogo();
print '<div style="margin-left: 50px; margin-right: 50px;">';
}
/**
* Show footer for new member
*
* @return void
*/
function llxFooterSurvey()
{
print '</div>';
printCommonFooter('public');
dol_htmloutput_events();
print "</body>\n";
print "</html>\n";
}
/**
* Show logo
*
* @return void
*/
function showlogo()
{
global $user, $conf, $langs, $mysoc;
// Print logo
$urllogo=DOL_URL_ROOT.'/theme/login_logo.png';
if (! empty($mysoc->logo_small) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small))
{
$urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=companylogo&amp;file='.urlencode('thumbs/'.$mysoc->logo_small);
}
elseif (! empty($mysoc->logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$mysoc->logo))
{
$urllogo=DOL_URL_ROOT.'/viewimage.php?cache=1&amp;modulepart=companylogo&amp;file='.urlencode($mysoc->logo);
$width=128;
}
elseif (is_readable(DOL_DOCUMENT_ROOT.'/theme/dolibarr_logo.png'))
{
$urllogo=DOL_URL_ROOT.'/theme/dolibarr_logo.png';
}
print '<center>';
print '<img alt="Logo" id="logosubscribe" title="" src="'.$urllogo.'" style="max-width: 120px" /><br>';
print '<strong>'.$langs->trans("OpenSurvey").'</strong>';
print '</center><br>';
}
/**
* get_server_name
*
* @return string URL to use
*/
function get_server_name()
{
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
$url=$urlwithouturlroot.dol_buildpath('/opensurvey/',1);
if (!preg_match("|/$|", $url)) {
$url = $url."/";
}
return $url;
}
/**
* is_error
*
* @param unknown_type $cerr
* @return boolean
*/
function is_error($cerr)
{
global $err;
if ( $err == 0 ) {
return false;
}
return (($err & $cerr) != 0 );
}
/**
* Vérifie une adresse e-mail selon les normes RFC
*
* @param string $email l'adresse e-mail a vérifier
* @return bool vrai si l'adresse est correcte, faux sinon
* @see http://fightingforalostcause.net/misc/2006/compare-email-regex.php
* @see http://svn.php.net/viewvc/php/php-src/trunk/ext/filter/logical_filters.c?view=markup
*/
function validateEmail($email)
{
$pattern = '/^(?!(?:(?:\\x22?\\x5C[\\x00-\\x7E]\\x22?)|(?:\\x22?[^\\x5C\\x22]\\x22?)){255,})(?!(?:(?:\\x22?\\x5C[\\x00-\\x7E]\\x22?)|(?:\\x22?[^\\x5C\\x22]\\x22?)){65,}@)(?:(?:[\\x21\\x23-\\x27\\x2A\\x2B\\x2D\\x2F-\\x39\\x3D\\x3F\\x5E-\\x7E]+)|(?:\\x22(?:[\\x01-\\x08\\x0B\\x0C\\x0E-\\x1F\\x21\\x23-\\x5B\\x5D-\\x7F]|(?:\\x5C[\\x00-\\x7F]))*\\x22))(?:\\.(?:(?:[\\x21\\x23-\\x27\\x2A\\x2B\\x2D\\x2F-\\x39\\x3D\\x3F\\x5E-\\x7E]+)|(?:\\x22(?:[\\x01-\\x08\\x0B\\x0C\\x0E-\\x1F\\x21\\x23-\\x5B\\x5D-\\x7F]|(?:\\x5C[\\x00-\\x7F]))*\\x22)))*@(?:(?:(?!.*[^.]{64,})(?:(?:(?:xn--)?[a-z0-9]+(?:-[a-z0-9]+)*\\.){1,126}){1,}(?:(?:[a-z][a-z0-9]*)|(?:(?:xn--)[a-z0-9]+))(?:-[a-z0-9]+)*)|(?:\\[(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){7})|(?:(?!(?:.*[a-f0-9][:\\]]){7,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,5})?)))|(?:(?:IPv6:(?:(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){5}:)|(?:(?!(?:.*[a-f0-9]:){5,})(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3})?::(?:[a-f0-9]{1,4}(?::[a-f0-9]{1,4}){0,3}:)?)))?(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))(?:\\.(?:(?:25[0-5])|(?:2[0-4][0-9])|(?:1[0-9]{2})|(?:[1-9]?[0-9]))){3}))\\]))$/iD';
return (bool)preg_match($pattern, $email);
}
/**
* Fonction vérifiant l'existance et la valeur non vide d'une clé d'un tableau
*
* @param string $name La clé à tester
* @param array $tableau Le tableau rechercher la clé ($_POST par défaut)
* @return bool Vrai si la clé existe et renvoie une valeur non vide
*/
function issetAndNoEmpty($name, $tableau = null)
{
if ($tableau === null) {
$tableau = $_POST;
}
return (isset($tableau[$name]) === true && empty($tableau[$name]) === false);
}
/**
* Fonction permettant de générer les URL pour les sondage
*
* @param string $id L'identifiant du sondage
* @param bool $admin True pour générer une URL pour l'administration d'un sondage, False pour un URL publique
* @return string L'url pour le sondage
*/
function getUrlSondage($id, $admin = false)
{
if ($admin === true) {
$url = get_server_name().'adminstuds_preview.php?sondage='.$id;
} else {
$url = get_server_name().'/public/studs.php?sondage='.$id;
}
return $url;
}
/**
* Generate a random id
*
* @return void
*/
function dol_survey_random($car)
{
$string = "";
$chaine = "abcdefghijklmnopqrstuvwxyz123456789";
srand((double)microtime()*1000000);
for($i=0; $i<$car; $i++) {
$string .= $chaine[rand()%strlen($chaine)];
}
return $string;
}
/**
* Add a poll
*
* @param string $origin Origin of poll creation
* @return void
*/
function ajouter_sondage($origin)
{
global $conf, $db;
$sondage=dol_survey_random(16);
$sondage_admin=$sondage.dol_survey_random(8);
if ($_SESSION["formatsondage"]=="A"||$_SESSION["formatsondage"]=="A+") {
//extraction de la date de fin choisie
if ($_SESSION["champdatefin"]) {
if ($_SESSION["champdatefin"]>time()+250000) {
$date_fin=$_SESSION["champdatefin"];
}
} else {
$date_fin=time()+15552000;
}
}
if ($_SESSION["formatsondage"]=="D"||$_SESSION["formatsondage"]=="D+") {
//Calcul de la date de fin du sondage
$taille_tableau=sizeof($_SESSION["totalchoixjour"])-1;
$date_fin=$_SESSION["totalchoixjour"][$taille_tableau]+200000;
}
if (is_numeric($date_fin) === false) {
$date_fin = time()+15552000;
}
$canedit=empty($_SESSION['formatcanedit'])?'0':'1';
// Insert survey
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'opensurvey_sondage';
$sql.= '(id_sondage, commentaires, mail_admin, nom_admin, titre, id_sondage_admin, date_fin, format, mailsonde, canedit, origin, sujet)';
$sql.= " VALUES ('".$db->escape($sondage)."', '".$db->escape($_SESSION['commentaires'])."', '".$db->escape($_SESSION['adresse'])."', '".$db->escape($_SESSION['nom'])."',";
$sql.= " '".$db->escape($_SESSION['titre'])."', '".$sondage_admin."', '".$db->idate($date_fin)."', '".$_SESSION['formatsondage']."', '".$db->escape($_SESSION['mailsonde'])."',";
$sql.= " '".$canedit."', '".$db->escape($origin)."',";
$sql.= " '".$db->escape($_SESSION['toutchoix'])."'";
$sql.= ")";
dol_syslog($sql);
$resql=$db->query($sql);
if ($origin == 'dolibarr') $urlback=dol_buildpath('/opensurvey/adminstuds_preview.php',1).'?sondage='.$sondage_admin;
else
{
// Define $urlwithroot
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
$url=$urlwithouturlroot.dol_buildpath('/opensurvey/public/studs.php',1).'?sondage='.$sondage;
$urlback=$url;
//var_dump($urlback);exit;
}
unset($_SESSION["titre"]);
unset($_SESSION["nom"]);
unset($_SESSION["adresse"]);
unset($_SESSION["commentaires"]);
unset($_SESSION["canedit"]);
unset($_SESSION["mailsonde"]);
header("Location: ".$urlback);
exit();
}
define('COMMENT_EMPTY', 0x0000000001);
define('COMMENT_USER_EMPTY', 0x0000000010);
define('COMMENT_INSERT_FAILED', 0x0000000100);
define('NAME_EMPTY', 0x0000001000);
define('NAME_TAKEN', 0x0000010000);
define('NO_POLL', 0x0000100000);
define('NO_POLL_ID', 0x0001000000);
define('INVALID_EMAIL', 0x0010000000);
define('TITLE_EMPTY', 0x0100000000);
define('INVALID_DATE', 0x1000000000);
$err = 0;
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
htdocs/opensurvey/img/accept.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 901 B

BIN
htdocs/opensurvey/img/add-16.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 845 B

BIN
htdocs/opensurvey/img/add-24.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
htdocs/opensurvey/img/add.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
htdocs/opensurvey/img/back-32.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

BIN
htdocs/opensurvey/img/cancel.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 587 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
htdocs/opensurvey/img/csv.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 804 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
htdocs/opensurvey/img/ical.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 829 B

BIN
htdocs/opensurvey/img/info.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 777 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 753 B

BIN
htdocs/opensurvey/img/next-32.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
htdocs/opensurvey/img/next.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 828 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

BIN
htdocs/opensurvey/img/reload.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
htdocs/opensurvey/img/rewind.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

69
htdocs/opensurvey/index.php Executable file
View File

@ -0,0 +1,69 @@
<?php
/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/opensurvey/index.php
* \ingroup opensurvey
* \brief Home page of opensurvey area
*/
require_once('../main.inc.php');
require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
/*
* View
*/
$langs->load("opensurvey@opensurvey");
llxHeader();
$nbsondages=0;
$sql='SELECT COUNT(*) as nb FROM '.MAIN_DB_PREFIX.'opensurvey_sondage';
$resql=$db->query($sql);
if ($resql)
{
$obj=$db->fetch_object($resql);
$nbsondages=$obj->nb;
}
else dol_print_error($db,'');
print_fiche_titre($langs->trans("OpenSurveyArea"));
echo $langs->trans("NoSurveysInDatabase",$nbsondages).'<br><br>'."\n";
// Link
print img_picto('','object_globe.png').' '.$langs->trans("PublicLinkToCreateSurvey").':<br>';
// Define $urlwithroot
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
$url=$urlwithouturlroot.dol_buildpath('/opensurvey/public/index.php',1);
$urllink='<a href="'.$url.'" target="_blank">'.$url.'</a>';
print $urllink;
llxFooter();
$db->close();
?>

View File

@ -0,0 +1,68 @@
# Dolibarr language file - en_US - opensurvey
CHARSET=UTF-8
Survey=Survey
Surveys=Surveys
OrganizeYourMeetingEasily=Organize your meeting and surveys easily. First select type of survey...
NewSurvey=New survey
NoSurveysInDatabase=%s survey(s) into database.
OpenSurveyArea=Surveys area
AddACommentForPoll=You can add a comment into survey...
AddComment=Add comment
CreatePoll=Create poll
PollTitle=Poll title
OpenSurveyYourName=Your name
OpenSurveyYourEMail=Your email address
VotersCanModify=Voters can modify vote of others
ToReceiveEMailForEachVote=To receive an email for each vote
TypeDate=Type date
TypeClassic=Type standard
YouAreInPollCreateArea=You are in the poll creation section
FieldMandatory=Field mandatory
OpenSurveyDesc=Online service to plan a rendez-vous or do a survey quickly and easily.
OpenSurveyNoRegistration=No registration required.
OpenSurveyStep2=Select your dates amoung the free days (green). The selected days are in blue. You can unselect a day previously selected by clicking again on it
RemoveAllDays=Remove all days
CopyHoursOfFirstDay=Copy hours of first day
RemoveAllHours=Remove all hours
SelectedDays=Selected days
TheBestChoice=The best choice currently is
TheBestChoices=The best choices currently are
with=with
OpenSurveyHowTo=If you agree to vote in this poll, you have to give your name, choose the values that fit best for you (without paying attention to the choices of the other voters) and validate with the plus button at the end of the line.
InitiatorOfPoll=Initiator of the poll
CommentsOfVoters=Comments of voters
ConfirmRemovalOfPoll=Are you sure you want to remove this poll (and all votes)
RemovePoll=Remove poll
PollManagement=Poll's management
BackToHoursSetup=Back to hours setup
UrlForSurvey=URL to communicate to get a direct access to survey
PollOnChoice=Your are creating a poll to make a multi-choice for a poll. First enter all possible choices for your poll:
CheckBox=Simple checkbox
YesNoList=List (empty/yes/no)
PourContreList=List (empty/for/against)
AddNewColumn=Add new colum
TitleChoice=Choice label
InfoAfterCreate=Once you have confirmed the creation of your poll, you will be automatically redirected on the page of your poll.<br>You should also receive an email with link to your poll for sending it to the voters.
ExportSpreadsheet=Export result spreadsheet
ExpireDate=Limit date
NbOfVoters=Nb of voters
SurveyResults=Results
PollAdminDesc=You are allowed to change all vote lines of this poll with button "Edit". You can, as well, remove a column or a line with %s. You can also add a new column with %s.
5MoreChoices=5 more choices
Abstention=Abstention
Against=Against
YouAreInivitedToVote=You are invited to vote for this poll
VoteNameAlreadyExists=This name was already used for this poll
ErrorPollDoesNotExists=Error, poll <strong>%s</strong> does not exists.
OpenSurveyNothingToSetup=There is no specific setup to do.
PollWillExpire=Your poll will expire automatically <strong>%s</strong> days after the last date of your poll.
RemovalDate=Removal date
AddADate=Add a date
AddStartHour=Add start hour
AddEndHour=Add end hour
votes=vote(s)
NoCommentYet=No comment yet posted for this poll
CanEditVotes=Can change vote of others
SelectDayDesc=For each selected day, you can choose, or not, meeting hours in the following format :<br>- empty,<br>- "8h", "8H" or "8:00" to give a meeting's start hour,<br>- "8-11", "8h-11h", "8H-11H" or "8:00-11:00" to give a meeting's start and end hour,<br>- "8h15-11h15", "8H15-11H15" or "8:15-11:15" for the same thing but with minutes.
BackToCurrentMonth=Back to current month
PublicLinkToCreateSurvey=Public link to allow everybody to create a survey

View File

@ -0,0 +1,68 @@
# Dolibarr language file - fr_FR - opensurvey
CHARSET=UTF-8
Survey=Sondage
Surveys=Sondages
OrganizeYourMeetingEasily=Organiser vos rendez-vous ou votes facilement, librement. Sélectionnez d'abord le type de sondage...
NewSurvey=Nouveau sondage
NoSurveysInDatabase=%s sondage(s) en base.
OpenSurveyArea=Espace sondage
AddACommentForPoll=Vous pouvez ajouter un commentaire au sondage...
AddComment=Ajouter commentaire
CreatePoll=Créer sondage
PollTitle=Titre sondage
OpenSurveyYourName=Votre nom
OpenSurveyYourEMail=Votre adresse email
VotersCanModify=Les votants peuvent modifier les votes des autres
ToReceiveEMailForEachVote=Pour recevoir un email à chaque vote
TypeDate=Type date
TypeClassic=Type classique
YouAreInPollCreateArea=Vous êtes dans l'espace de création de sondage
FieldMandatory=Champ obligatoire
OpenSurveyDesc=Service en ligne permettant de planifier un rendez-vous ou réaliser un sondage rapidement et simplement.
OpenSurveyNoRegistration=Aucune inscription préalable n'est nécessaire.
OpenSurveyStep2=Sélectionner les dates parmis les jours libres (en vert). Les jours sélectionné sont bleus. Vou spouvez désélectionner un jour en cliquant à nouveau dessus.
RemoveAllDays=Efface tous les jours
CopyHoursOfFirstDay=Copier heures du premier jour
RemoveAllHours=Efface toutes les heures
SelectedDays=Jours sélectionnés
TheBestChoice=Le meilleur choix actuellement est
TheBestChoices=Les meilleurs choix actuellement sont
with=avec
OpenSurveyHowTo=Si vous acceptez de voter pour ce sondage, vous devez saisir votre nom, choisir les valeurs qui correspondent à votre choix (sans prêter attention aux choix des autres déjà saisis) et valider en cliquant sur le bouton + à la fin de la ligne.
InitiatorOfPoll=Initiateur du sondage
CommentsOfVoters=Commentaires des votants
ConfirmRemovalOfPoll=Etes vous sur de vouloir supprimer ce sondage (et tous ces votes)
RemovePoll=Suppression du sondage
PollManagement=Gestion du sondage
BackToHoursSetup=Retour configuration heures
UrlForSurvey=URL à communiquer pour accès direct au sondage
PollOnChoice=Vous êtes en train de créer un sondage à choix multiples. Renseigner les différents choix possible de votre sondage:
CheckBox=Case à cochée
YesNoList=Liste (vide/oui/non)
PourContreList=Liste (vide/pour/contre)
AddNewColumn=Ajouter nouvelle colonne
TitleChoice=Libellé du choix
InfoAfterCreate=Une fois la confirmation de la création de votre sondage réalisée, vous serez redirigé vers la page de vote du sondage.<br>Vous devriez de plus recevoir un email avec le lien de la page sondage pour diffusion auprès des votants.
ExportSpreadsheet=Exporter feuille de résultats
ExpireDate=Date expiration
NbOfVoters=Nb de votants
SurveyResults=Résultats
PollAdminDesc=Vous êtes habilités à modifier toutes les lignes de votes par le bouton "Editer". Vous pouvez supprimer une colonne ou ligne avec %s. Vous pouvez aussi ajouter une nouvelle colonne avec %s.
5MoreChoices=5 choix suplémentaires
Abstention=Abstention
Against=Contre
YouAreInivitedToVote=Vous êtes invité à vous prononcer sur ce vote/sondage
VoteNameAlreadyExists=Ce nom a déjà été utilisé pour ce vote
ErrorPollDoesNotExists=Erreur, le sondage <strong>%s</strong> n'existe pas.
OpenSurveyNothingToSetup=Aucune configuration particulière n'est requise.
PollWillExpire=Ce sondage expirera automatiquement <strong>%s</strong> jours après la date de dernier choix.
Removal date=Date d'expiration
AddADate=Ajouter une date
AddStartHour=Ajouter heure de début
AddEndHour=Ajouter heure de fin
votes=vote(s)
NoCommentYet=Pas de commentaires laissés pour le moment sur ce sondage
CanEditVotes=Modification des votes des autres autorisés
SelectDayDesc=Pour chaque jour, vous pouvez choisir, ou pas, les heures au format suivant :<br>- laisser vide,<br>- "8h", "8H" ou "8:00" pour définir uniquement une heure de début,<br>- "8-11", "8h-11h", "8H-11H" ou "8:00-11:00" pour définir une heure de début et de fin,<br>- "8h15-11h15", "8H15-11H15" ou "8:15-11:15" pour définir une heure de début et fin avec précision sur les minutes.
BackToCurrentMonth=Retour au mois en cours
PublicLinkToCreateSurvey=Lien publique pour permettre à tout le monde de créer un sondage

145
htdocs/opensurvey/list.php Executable file
View File

@ -0,0 +1,145 @@
<?php
/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/opensurvey/list.php
* \ingroup opensurvey
* \brief Page to list surveys
*/
require_once('../main.inc.php');
require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
$action=GETPOST('action');
$id=GETPOST('id');
if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="p.titre";
if ($page < 0) {
$page = 0;
}
$limit = $conf->liste_limit;
$offset = $limit * $page;
/*
* Actions
*/
if ($action == 'delete_confirm')
{
$db->begin();
$sql='DELETE FROM '.MAIN_DB_PREFIX."opensurvey_comments WHERE id_sondage_admin = '".$id."'";
dol_syslog("Delete poll sql=".$sql, LOG_DEBUG);
$resql=$db->query($sql);
$sql='DELETE FROM '.MAIN_DB_PREFIX."opensurvey_user_studs WHERE id_sondage_admin = '".$id."'";
dol_syslog("Delete poll sql=".$sql, LOG_DEBUG);
$resql=$db->query($sql);
$sql='DELETE FROM '.MAIN_DB_PREFIX."opensurvey_sondage WHERE id_sondage_admin = '".$id."'";
dol_syslog("Delete poll sql=".$sql, LOG_DEBUG);
$resql=$db->query($sql);
$db->commit();
}
/*
* View
*/
$form=new Form($db);
$langs->load("opensurvey@opensurvey");
llxHeader();
print '<div class=corps>'."\n";
print_fiche_titre($langs->trans("OpenSurveyArea"));
if ($action == 'delete')
{
print $form->formconfirm($_SERVER["PHP_SELF"].'?&id='.$id, $langs->trans("RemovePoll"), $langs->trans("ConfirmRemovalOfPoll",$id), 'delete_confirm', '', '', 1);
}
// tableau qui affiche tous les sondages de la base
print '<table class="liste">'."\n";
print '<tr class="liste_titre"><td>'. $langs->trans("Survey").'</td><td>'. $langs->trans("Type") .'</td><td>'. $langs->trans("Title") .'</td><td>'. $langs->trans("Author") .'</td><td align="center">'. $langs->trans("ExpireDate") .'</td><td align="center">'. $langs->trans("NbOfVoters") .'</td><td colspan=2>&nbsp;</td>'."\n";
$sql = "SELECT id_sondage, id_sondage_admin, mail_admin, format, origin, date_fin, titre, nom_admin";
$sql.= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as p";
// Count total nb of records
$nbtotalofrecords = 0;
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
$result = $db->query($sql);
$nbtotalofrecords = $db->num_rows($result);
}
$sql.= " ORDER BY $sortfield $sortorder ";
$sql.= " ".$db->plimit($conf->liste_limit+1, $offset);
$resql=$db->query($sql);
if (! $resql) dol_print_error($db);
$num=$db->num_rows($resql);
$i = 0; $var = true;
while ($i < min($num,$limit))
{
$obj=$db->fetch_object($resql);
$sql2='select COUNT(*) as nb from '.MAIN_DB_PREFIX."opensurvey_user_studs where id_sondage='".$db->escape($obj->id_sondage)."'";
$resql2=$db->query($sql2);
if ($resql2)
{
$obj2=$db->fetch_object($resql2);
$nbuser=$obj2->nb;
}
else dol_print_error($db);
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>';
print '<a href="'.dol_buildpath('/opensurvey/adminstuds.php',1).'?sondage='.$obj->id_sondage_admin.'">'.img_picto('','object_opensurvey@opensurvey').' '.$obj->id_sondage.'</a>';
print '</td><td>';
$type=($obj->format=='A' || $obj->format=='A+')?'classic':'date';
print img_picto('',dol_buildpath('/opensurvey/img/'.($type == 'classic'?'chart-32.png':'calendar-32.png'),1),'width="16"',1);
print ' '.$langs->trans($type=='classic'?"TypeClassic":"TypeDate");
print '</td><td>'.$obj->titre.'</td><td>'.$obj->nom_admin.'</td>';
print '<td align="center">'.dol_print_date($db->jdate($obj->date_fin),'day');
if ($db->jdate($obj->date_fin) < time()) { print ' '.img_warning(); }
print '</td>';
print'<td align="center">'.$nbuser.'</td>'."\n";
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?id='.$obj->id_sondage_admin.'&action=delete">'.img_picto('', 'delete.png').'</a></td>'."\n";
print '</tr>'."\n";
$i++;
}
print '</table>'."\n";
print '</div>'."\n";
llxFooter();
$db->close();
?>

View File

@ -0,0 +1,222 @@
<?php
/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/opensurvey/public/choix_autre.php
* \ingroup opensurvey
* \brief Page to create a new survey (choice selection)
*/
define("NOLOGIN",1); // This means this output page does not require to be logged.
define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
require_once('../../main.inc.php');
require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
require_once(DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php");
$erreur = false;
$testdate = true;
$date_selected = '';
$origin=GETPOST('origin','alpha');
/*
* Action
*/
// Set session vars
$erreur_injection = false;
if (isset($_SESSION["nbrecases"])) {
for ($i = 0; $i < $_SESSION["nbrecases"]; $i++) {
if (isset($_POST["choix"][$i])) {
$_SESSION["choix$i"]=$_POST["choix"][$i];
}
if (isset($_POST["typecolonne"][$i])) {
$_SESSION["typecolonne$i"]=$_POST["typecolonne"][$i];
}
}
} else { //nombre de cases par défaut
$_SESSION["nbrecases"]=5;
}
if (isset($_POST["ajoutcases"]) || isset($_POST["ajoutcases_x"])) {
$_SESSION["nbrecases"]=$_SESSION["nbrecases"]+5;
}
// Create survey into database
if (isset($_POST["confirmecreation"]) || isset($_POST["confirmecreation_x"]))
{
//recuperation des données de champs textes
$toutchoix = '';
for ($i = 0; $i < $_SESSION["nbrecases"] + 1; $i++)
{
if (! empty($_POST["choix"][$i]))
{
$toutchoix.=',';
$toutchoix.=str_replace(array(",","@"), " ", $_POST["choix"][$i]).(empty($_POST["typecolonne"][$i])?'':'@'.$_POST["typecolonne"][$i]);
}
}
$toutchoix=substr("$toutchoix",1);
$_SESSION["toutchoix"]=$toutchoix;
if (GETPOST('champdatefin'))
{
$registredate=explode("/",$_POST["champdatefin"]);
if (is_array($registredate) === false || count($registredate) !== 3) {
$testdate = false;
$date_selected = $_POST["champdatefin"];
} else {
$time = mktime(0,0,0,$registredate[1],$registredate[0],$registredate[2]);
if ($time === false || date('d/m/Y', $time) !== $_POST["champdatefin"]) {
$testdate = false;
$date_selected = $_POST["champdatefin"];
} else {
if (mktime(0,0,0,$registredate[1],$registredate[0],$registredate[2]) > time() + 250000) {
$_SESSION["champdatefin"]=mktime(0,0,0,$registredate[1],$registredate[0],$registredate[2]);
}
}
}
} else {
$_SESSION["champdatefin"]=time()+15552000;
}
if ($testdate === true)
{
//format du sondage AUTRE
$_SESSION["formatsondage"]="A";
$_SESSION["caneditsondage"]=$_SESSION["canedit"];
// Add into database
ajouter_sondage($origin);
} else {
$_POST["fin_sondage_autre"] = 'ok';
}
}
/*
* View
*/
$form=new Form($db);
$arrayofjs=array();
$arrayofcss=array('/opensurvey/css/style.css');
llxHeaderSurvey($langs->trans("OpenSurvey"), "", 0, 0, $arrayofjs, $arrayofcss);
if (empty($_SESSION['titre']) || empty($_SESSION['nom']) || empty($_SESSION['adresse']))
{
dol_print_error('',"You haven't filled the first section of the poll creation");
llxFooterSurvey();
exit;
}
//partie creation du sondage dans la base SQL
//On prépare les données pour les inserer dans la base
print '<form name="formulaire" action="#bas" method="POST" onkeypress="javascript:process_keypress(event)">'."\n";
print '<input type="hidden" name="origin" value="'.dol_escape_htmltag($origin).'">';
print '<div class="bandeautitre">'. $langs->trans("CreatePoll")." (2 / 2)" .'</div>'."\n";
print '<div class=corps>'."\n";
print '<br>'. $langs->trans("PollOnChoice") .'<br><br>'."\n";
print '<table>'."\n";
//affichage des cases texte de formulaire
for ($i = 0; $i < $_SESSION["nbrecases"]; $i++) {
$j = $i + 1;
if (isset($_SESSION["choix$i"]) === false) {
$_SESSION["choix$i"] = '';
}
print '<tr><td>'. $langs->trans("TitleChoice") .' '.$j.' : </td><td><input type="text" name="choix[]" size="40" maxlength="40" value="'.dol_escape_htmltag($_SESSION["choix$i"]).'" id="choix'.$i.'">';
$tmparray=array('checkbox'=>$langs->trans("CheckBox"),'yesno'=>$langs->trans("YesNoList"),'foragainst'=>$langs->trans("PourContreList"));
print ' &nbsp; '.$langs->trans("Type").' '.$form->selectarray("typecolonne[]", $tmparray, $_SESSION["typecolonne$i"]);
print '</td></tr>'."\n";
}
print '</table>'."\n";
//ajout de cases supplementaires
print '<table><tr>'."\n";
print '<td>'. $langs->trans("5MoreChoices") .'</td><td><input type="image" name="ajoutcases" value="Retour" src="images/add-16.png"></td>'."\n";
print '</tr></table>'."\n";
print'<br>'."\n";
print '<table><tr>'."\n";
print '<td></td><td><input type="submit" class="button" name="fin_sondage_autre" value="'.dol_escape_htmltag($langs->trans("NextStep")).'" src="images/next-32.png"></td>'."\n";
print '</tr></table>'."\n";
//test de remplissage des cases
$testremplissage = '';
for ($i=0;$i<$_SESSION["nbrecases"];$i++)
{
if (isset($_POST["choix"][$i]))
{
$testremplissage="ok";
}
}
//message d'erreur si aucun champ renseigné
if ($testremplissage != "ok" && (isset($_POST["fin_sondage_autre"]) || isset($_POST["fin_sondage_autre_x"]))) {
print "<br><font color=\"#FF0000\">" . $langs->trans("Enter at least one choice") . "</font><br><br>"."\n";
$erreur = true;
}
//message d'erreur si mauvaise date
if ($testdate === false) {
print "<br><font color=\"#FF0000\">" . _("Date must be have the format DD/MM/YYYY") . "</font><br><br>"."\n";
}
if ($erreur_injection) {
print "<font color=#FF0000>" . _("Characters \" < and > are not permitted") . "</font><br><br>\n";
}
if ((isset($_POST["fin_sondage_autre"]) || isset($_POST["fin_sondage_autre_x"])) && !$erreur && !$erreur_injection) {
//demande de la date de fin du sondage
print '<br>'."\n";
print '<div class=presentationdatefin>'."\n";
print '<br>'. _("Your poll will be automatically removed after 6 months.<br> You can fix another removal date for it.") .'<br><br>'."\n";
print _("Removal date (optional)") .' : <input type="text" name="champdatefin" value="'.$date_selected.'" size="10" maxlength="10"> '. _("(DD/MM/YYYY)") ."\n";
print '</div>'."\n";
print '<div class=presentationdatefin>'."\n";
print '<font color=#FF0000>'. $langs->trans("InfoAfterCreate") .'</font>'."\n";
print '</div>'."\n";
print '<br>'."\n";
print '<table>'."\n";
print '<tr><td>'. $langs->trans("CreatePoll") .'</td><td><input type="image" name="confirmecreation" src="images/add.png"></td></tr>'."\n";
print '</table>'."\n";
}
//fin du formulaire et bandeau de pied
print '</form>'."\n";
print '<a name=bas></a>'."\n";
print '<br><br><br>'."\n";
print '</div>'."\n";
llxFooterSurvey();
$db->close();
?>

View File

@ -0,0 +1,573 @@
<?php
/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/opensurvey/public/choix_date.php
* \ingroup opensurvey
* \brief Page to create a new survey (date selection)
*/
define("NOLOGIN",1); // This means this output page does not require to be logged.
define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
require_once('../../main.inc.php');
require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
require_once(DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php");
$origin=GETPOST('origin','alpha');
/*
* Actions
*/
// Insert survey
if (GETPOST('confirmation') || GETPOST('confirmation_x'))
{
if (is_array($_SESSION['totalchoixjour']))
{
for ($i = 0; $i < count($_SESSION["totalchoixjour"]); $i++) {
if ($_SESSION["horaires$i"][0] == "" && $_SESSION["horaires$i"][1] == "" && $_SESSION["horaires$i"][2] == "" && $_SESSION["horaires$i"][3] == "" && $_SESSION["horaires$i"][4] == "") {
$choixdate.=",";
$choixdate .= $_SESSION["totalchoixjour"][$i];
} else {
for ($j=0;$j<$_SESSION["nbrecaseshoraires"];$j++) {
if ($_SESSION["horaires$i"][$j]!="") {
$choixdate.=",";
$choixdate .= $_SESSION["totalchoixjour"][$i];
$choixdate.="@";
// On remplace la virgule et l'arobase pour ne pas avoir de problème par la suite
$choixdate .= str_replace(array(',', '@'), array('&#44;', '&#64;'), $_SESSION["horaires$i"][$j]);
}
}
}
}
}
else dol_print_error('','array not defined');
$_SESSION["toutchoix"]=substr("$choixdate",1);
ajouter_sondage($origin);
}
// Reset days
if (GETPOST('reset')) {
for ($i = 0; $i < count($_SESSION["totalchoixjour"]); $i++) {
for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
unset($_SESSION["horaires$i"][$j]);
}
}
unset($_SESSION["totalchoixjour"]);
unset($_SESSION["nbrecaseshoraires"]);
}
/*
* View
*/
if (! isset($_SESSION['nom']) && ! isset($_SESSION['adresse']) && ! isset($_SESSION['commentaires']) && ! isset($_SESSION['mail']))
{
dol_print_error('',"You haven't filled the first section of the poll creation");
exit;
}
$arrayofjs=array();
$arrayofcss=array('/opensurvey/css/style.css');
llxHeaderSurvey($langs->trans("OpenSurvey"), "", 0, 0, $arrayofjs, $arrayofcss);
//nombre de cases par défaut
if (! isset($_SESSION["nbrecaseshoraires"]))
{
$_SESSION["nbrecaseshoraires"]=5;
}
elseif ((GETPOST('ajoutcases') || GETPOST('ajoutcases_x')) && $_SESSION["nbrecaseshoraires"] == 5)
{
$_SESSION["nbrecaseshoraires"]=10;
}
//valeurs de la date du jour actuel
$jourAJ=date("j");
$moisAJ=date("n");
$anneeAJ=date("Y");
// Initialisation des jour, mois et année
if (! isset($_SESSION['jour'])) $_SESSION['jour']= date('j');
if (! isset($_SESSION['mois'])) $_SESSION['mois']= date('n');
if (! isset($_SESSION['annee'])) $_SESSION['annee']= date('Y');
//mise a jour des valeurs de session si bouton retour a aujourd'hui
if ((!issetAndNoEmpty('anneeavant_x') && !issetAndNoEmpty('anneeapres_x') && !issetAndNoEmpty('moisavant_x') && !issetAndNoEmpty('moisapres_x') && !issetAndNoEmpty('choixjourajout')) && !issetAndNoEmpty('choixjourretrait') || (issetAndNoEmpty('retourmois') || issetAndNoEmpty('retourmois_x'))){
$_SESSION["jour"]=date("j");
$_SESSION["mois"]=date("n");
$_SESSION["annee"]=date("Y");
}
//mise a jour des valeurs de session si mois avant
if (issetAndNoEmpty('moisavant') || issetAndNoEmpty('moisavant_x')) {
if ($_SESSION["mois"] == 1) {
$_SESSION["mois"] = 12;
$_SESSION["annee"] = $_SESSION["annee"]-1;
} else {
$_SESSION["mois"] -= 1;
}
//On sauvegarde les heures deja entrées
if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) {
for ($i = 0; $i < count($_SESSION["totalchoixjour"]); $i++) {
//affichage des 5 cases horaires
for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
$_SESSION["horaires$i"][$j] = $_POST["horaires$i"][$j];
}
}
}
}
//mise a jour des valeurs de session si mois apres
if (issetAndNoEmpty('moisapres') || issetAndNoEmpty('moisapres_x')) {
if ($_SESSION["mois"] == 12) {
$_SESSION["mois"] = 1;
$_SESSION["annee"] += 1;
} else {
$_SESSION["mois"] += 1;
}
//On sauvegarde les heures deja entrées
if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) {
for ($i = 0; $i < count($_SESSION["totalchoixjour"]); $i++) {
//affichage des 5 cases horaires
for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
$_SESSION["horaires$i"][$j] = $_POST["horaires$i"][$j];
}
}
}
}
//mise a jour des valeurs de session si annee avant
if (issetAndNoEmpty('anneeavant') || issetAndNoEmpty('anneeavant_x')) {
$_SESSION["annee"] -= 1;
//On sauvegarde les heures deja entrées
if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) {
for ($i = 0; $i < count($_SESSION["totalchoixjour"]); $i++) {
//affichage des 5 cases horaires
for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
$_SESSION["horaires$i"][$j] = $_POST["horaires$i"][$j];
}
}
}
}
//mise a jour des valeurs de session si annee apres
if (issetAndNoEmpty('anneeapres') || issetAndNoEmpty('anneeapres_x')) {
$_SESSION["annee"] += 1;
//On sauvegarde les heures deja entrées
if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) {
for ($i = 0; $i < count($_SESSION["totalchoixjour"]); $i++) {
//affichage des 5 cases horaires
for ($j = 0;$j < $_SESSION["nbrecaseshoraires"]; $j++) {
$_SESSION["horaires$i"][$j] = $_POST["horaires$i"][$j];
}
}
}
}
//valeurs du nombre de jour dans le mois et du premier jour du mois
$nbrejourmois = date("t", mktime(0, 0, 0, $_SESSION["mois"], 1, $_SESSION["annee"]));
$premierjourmois = date("N", mktime(0, 0, 0, $_SESSION["mois"], 1, $_SESSION["annee"])) - 1;
//le format du sondage est DATE
$_SESSION["formatsondage"] = "D";
$_SESSION["formatcanedit"] = $_SESSION["canedit"];
//traduction de la valeur du mois
if (is_integer($_SESSION["mois"]) && $_SESSION["mois"] > 0 && $_SESSION["mois"] < 13)
{
$motmois=dol_print_date(mktime(0, 0, 0, $_SESSION["mois"], 10), '%B');
}
else
{
$motmois=dol_print_date(dol_now(), '%B');
}
//Debut du formulaire et bandeaux de tete
print '<form name="formulaire" action="choix_date.php" method="POST" onkeypress="javascript:process_keypress(event)">'."\n";
print '<input type="hidden" name="origin" value="'.dol_escape_htmltag($origin).'">';
print '<div class="bandeautitre">'. $langs->trans("CreatePoll")." (2 / 2)" .'</div>'."\n";
//affichage de l'aide pour les jours
print '<div class="bodydate">'."\n";
print $langs->trans("OpenSurveyStep2")."\n";
print '</div>'."\n";
//debut du tableau qui affiche le calendrier
print '<center><div class="corps">'."\n";
print '<table align=center>'."\n";
print '<tr><td><input type="image" name="anneeavant" value="<<" src="images/rewind.png"></td><td><input type="image" name="moisavant" value="<" src="images/previous.png"></td>';
print '<td width="150px" align="center"> '.$motmois.' '.$_SESSION["annee"].'<br>';
print '<input type="image" name="retourmois" alt="'.dol_escape_htmltag($langs->trans("BackToCurrentMonth")).'" title="'.dol_escape_htmltag($langs->trans("BackToCurrentMonth")).'" value="" src="'.img_picto('', 'refresh','',0,1).'">';
print '</td><td><input type="image" name="moisapres" value=">" src="images/next.png"></td>';
print '<td><input type="image" name="anneeapres" value=">>" src="images/fforward.png"></td><td></td><td></td><td></td><td></td><td></td><td>';
print '</td></tr>'."\n";
print '</table>'."\n";
print '<table>'."\n";
print '<tr>'."\n";
//affichage des jours de la semaine en haut du tableau
for($i = 0; $i < 7; $i++)
{
print '<td align="center" class="joursemaine">'. dol_print_date(mktime(0,0,0,0, $i,10),'%A') .'</td>';
}
print '</tr>'."\n";
//ajout d'une entrée dans la variable de session qui contient toutes les dates
if (issetAndNoEmpty('choixjourajout')) {
if (!isset($_SESSION["totalchoixjour"])) {
$_SESSION["totalchoixjour"]=array();
}
// Test pour éviter les doublons dans la variable qui contient toutes les dates
$journeuf = true;
if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true && issetAndNoEmpty('choixjourajout') === true) {
for ($i = 0; $i < count($_SESSION["totalchoixjour"]); $i++) {
if ($_SESSION["totalchoixjour"][$i] == mktime(0, 0, 0, $_SESSION["mois"], $_POST["choixjourajout"][0], $_SESSION["annee"])) {
$journeuf=false;
}
}
}
// Si le test est passé, alors on insere la valeur dans la variable de session qui contient les dates
if ($journeuf && issetAndNoEmpty('choixjourajout') === true) {
array_push ($_SESSION["totalchoixjour"],mktime (0,0,0, $_SESSION["mois"], $_POST["choixjourajout"][0], $_SESSION["annee"]));
sort ($_SESSION["totalchoixjour"]);
$cle=array_search (mktime (0,0,0, $_SESSION["mois"], $_POST["choixjourajout"][0], $_SESSION["annee"]), $_SESSION["totalchoixjour"]);
//On sauvegarde les heures deja entrées
for ($i = 0; $i < $cle; $i++) {
for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
if (issetAndNoEmpty('horaires'.$i) === true && issetAndNoEmpty($i, $_POST['horaires'.$i]) === true) {
$_SESSION["horaires$i"][$j] = $_POST["horaires$i"][$j];
}
}
}
for ($i = $cle; $i < count($_SESSION["totalchoixjour"]); $i++) {
$k = $i + 1;
if (issetAndNoEmpty('horaires'.$i) === true && issetAndNoEmpty($i, $_POST['horaires'.$i]) === true) {
for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
$_SESSION["horaires$k"][$j] = $_POST["horaires$i"][$j];
}
}
}
unset($_SESSION["horaires$cle"]);
}
}
//retrait d'une entrée dans la variable de session qui contient toutes les dates
if (issetAndNoEmpty('choixjourretrait')) {
//On sauvegarde les heures deja entrées
for ($i = 0; $i < count($_SESSION["totalchoixjour"]); $i++) {
//affichage des 5 cases horaires
for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
$_SESSION["horaires$i"][$j] = $_POST["horaires$i"][$j];
}
}
for ($i = 0; $i < count($_SESSION["totalchoixjour"]); $i++) {
if ($_SESSION["totalchoixjour"][$i] == mktime(0, 0, 0, $_SESSION["mois"], $_POST["choixjourretrait"][0], $_SESSION["annee"])) {
for ($j = $i; $j < count($_SESSION["totalchoixjour"]); $j++) {
$k = $j+1;
$_SESSION["horaires$j"] = $_SESSION["horaires$k"];
}
array_splice($_SESSION["totalchoixjour"], $i,1);
}
}
}
//report des horaires dans toutes les cases
if (issetAndNoEmpty('reporterhoraires')) {
$_SESSION["horaires0"] = $_POST["horaires0"];
for ($i = 0; $i < count($_SESSION["totalchoixjour"]); $i++) {
$j = $i+1;
$_SESSION["horaires$j"] = $_SESSION["horaires$i"];
}
}
//report des horaires dans toutes les cases
if (issetAndNoEmpty('resethoraires')) {
for ($i = 0; $i < count($_SESSION["totalchoixjour"]); $i++) {
unset ($_SESSION["horaires$i"]);
}
}
// affichage du calendrier
print '<tr>'."\n";
for ($i = 0; $i < $nbrejourmois + $premierjourmois; $i++) {
$numerojour = $i-$premierjourmois+1;
// On saute a la ligne tous les 7 jours
if (($i%7) == 0 && $i != 0) {
print '</tr><tr>'."\n";
}
// On affiche les jours precedants en gris et incliquables
if ($i < $premierjourmois) {
print '<td class="avant"></td>'."\n";
} else {
if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true) {
for ($j = 0; $j < count($_SESSION["totalchoixjour"]); $j++) {
//affichage des boutons ROUGES
if (date("j", $_SESSION["totalchoixjour"][$j]) == $numerojour && date("n", $_SESSION["totalchoixjour"][$j]) == $_SESSION["mois"] && date("Y", $_SESSION["totalchoixjour"][$j]) == $_SESSION["annee"]) {
print '<td align="center" class="choisi"><input type="submit" class="bouton OFF" name="choixjourretrait[]" value="'.$numerojour.'"></td>'."\n";
$dejafait = $numerojour;
}
}
}
//Si pas de bouton ROUGE alors on affiche un bouton VERT ou GRIS avec le numéro du jour dessus
if (isset($dejafait) === false || $dejafait != $numerojour){
//bouton vert
if (($numerojour >= $jourAJ && $_SESSION["mois"] == $moisAJ && $_SESSION["annee"] == $anneeAJ) || ($_SESSION["mois"] > $moisAJ && $_SESSION["annee"] == $anneeAJ) || $_SESSION["annee"] > $anneeAJ) {
print '<td align="center" class="libre"><input type="submit" class="bouton ON" name="choixjourajout[]" value="'.$numerojour.'"></td>'."\n";
} else { //bouton gris
print '<td align="center" class="avant">'.$numerojour.'</td>'."\n";
}
}
}
}
//fin du tableau
print '</tr>'."\n";
print '</table>'."\n";
print '</div></center>'."\n";
//traitement de l'entrée des heures dans les cases texte
$errheure = $erreur = false;
if (issetAndNoEmpty('choixheures') || issetAndNoEmpty('choixheures_x')) {
//On sauvegarde les heures deja entrées
if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true && issetAndNoEmpty('nbrecaseshoraires', $_SESSION) === true) {
for ($i = 0; $i < count($_SESSION["totalchoixjour"]); $i++) {
//affichage des 5 cases horaires
for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
$_SESSION["horaires$i"][$j] = $_POST["horaires$i"][$j];
}
}
}
//affichage des horaires
if (issetAndNoEmpty('totalchoixjour', $_SESSION) === true && issetAndNoEmpty('nbrecaseshoraires', $_SESSION) === true) {
for ($i = 0; $i < count($_SESSION["totalchoixjour"]); $i++) {
//affichage des 5 cases horaires
for ($j = 0; $j < $_SESSION["nbrecaseshoraires"]; $j++) {
$case = $j + 1;
if (isset($_POST['horaires'.$i]) === false || isset($_POST['horaires'.$i][$j]) === false) {
$errheure[$i][$j]=true;
$erreur=true;
$_SESSION["horaires$i"][$j]=$_POST["horaires$i"][$j];
continue;
}
//si c'est un creneau type 8:00-11:00
if (preg_match("/(\d{1,2}:\d{2})-(\d{1,2}:\d{2})/", $_POST["horaires$i"][$j], $creneaux)) {
//on recupere les deux parties du preg_match qu'on redécoupe autour des ":"
$debutcreneau=explode(":", $creneaux[1]);
$fincreneau=explode(":", $creneaux[2]);
//comparaison des heures de fin et de debut
//si correctes, on entre les données dans la variables de session
if ($debutcreneau[0] < 24 && $fincreneau[0] < 24 && $debutcreneau[1] < 60 && $fincreneau[1] < 60 && ($debutcreneau[0] < $fincreneau[0] || ($debutcreneau[0] == $fincreneau[0] && $debutcreneau[1] < $fincreneau[1]))) {
$_SESSION["horaires$i"][$j] = $creneaux[1].'-'.$creneaux[2];
} else { //sinon message d'erreur et nettoyage de la case
$errheure[$i][$j]=true;
$erreur=true;
}
} elseif (preg_match(";^(\d{1,2}h\d{0,2})-(\d{1,2}h\d{0,2})$;i", $_POST["horaires$i"][$j], $creneaux)) { //si c'est un creneau type 8h00-11h00
//on recupere les deux parties du preg_match qu'on redécoupe autour des "H"
$debutcreneau=preg_split("/h/i", $creneaux[1]);
$fincreneau=preg_split("/h/i", $creneaux[2]);
//comparaison des heures de fin et de debut
//si correctes, on entre les données dans la variables de session
if ($debutcreneau[0] < 24 && $fincreneau[0] < 24 && $debutcreneau[1] < 60 && $fincreneau[1] < 60 && ($debutcreneau[0] < $fincreneau[0] || ($debutcreneau[0] == $fincreneau[0] && $debutcreneau[1] < $fincreneau[1]))) {
$_SESSION["horaires$i"][$j] = $creneaux[1].'-'.$creneaux[2];
} else { //sinon message d'erreur et nettoyage de la case
$errheure[$i][$j]=true;
$erreur=true;
}
} elseif (preg_match(";^(\d{1,2}):(\d{2})$;", $_POST["horaires$i"][$j], $heures)) { //si c'est une heure simple type 8:00
//si valeures correctes, on entre les données dans la variables de session
if ($heures[1] < 24 && $heures[2] < 60) {
$_SESSION["horaires$i"][$j] = $heures[0];
} else { //sinon message d'erreur et nettoyage de la case
$errheure[$i][$j]=true;
$erreur=true;
}
} elseif (preg_match(";^(\d{1,2})h(\d{0,2})$;i", $_POST["horaires$i"][$j], $heures)) { //si c'est une heure encore plus simple type 8h
//si valeures correctes, on entre les données dans la variables de session
if ($heures[1] < 24 && $heures[2] < 60) {
$_SESSION["horaires$i"][$j] = $heures[0];
} else { //sinon message d'erreur et nettoyage de la case
$errheure[$i][$j]=true;
$erreur=true;
}
} elseif (preg_match(";^(\d{1,2})-(\d{1,2})$;", $_POST["horaires$i"][$j], $heures)) { //si c'est un creneau simple type 8-11
//si valeures correctes, on entre les données dans la variables de session
if ($heures[1] < $heures[2] && $heures[1] < 24 && $heures[2] < 24) {
$_SESSION["horaires$i"][$j] = $heures[0];
} else { //sinon message d'erreur et nettoyage de la case
$errheure[$i][$j]=true;
$erreur=true;
}
} elseif (preg_match(";^(\d{1,2})h-(\d{1,2})h$;", $_POST["horaires$i"][$j], $heures)) { //si c'est un creneau H type 8h-11h
//si valeures correctes, on entre les données dans la variables de session
if ($heures[1] < $heures[2] && $heures[1] < 24 && $heures[2] < 24) {
$_SESSION["horaires$i"][$j] = $heures[0];
} else { //sinon message d'erreur et nettoyage de la case
$errheure[$i][$j]=true;
$erreur=true;
}
} elseif ($_POST["horaires$i"][$j]=="") { //Si la case est vide
unset($_SESSION["horaires$i"][$j]);
} else { //pour tout autre format, message d'erreur
//$errheure[$i][$j]=true;
//$erreur=true;
$_SESSION["horaires$i"][$j] = $_POST["horaires$i"][$j];
}
}
}
}
}
print '<div class="bodydate"><center>'."\n";
// affichage de tous les jours choisis
if (issetAndNoEmpty('totalchoixjour', $_SESSION) && (!issetAndNoEmpty('choixheures_x') || $erreur))
//if (1==1 || GETPOST($_SESSION['totalchoixjour']) && (! GETPOST('choixheures_x') || $erreur))
{
//affichage des jours
print '<br>'."\n";
print '<strong>'. $langs->trans("SelectedDays") .' :</strong>'."<br>\n";
print $langs->trans("SelectDayDesc")."<br>\n";
print '<table>'."\n";
print '<tr>'."\n";
print '<td></td>'."\n";
for ($i = 0; $i < $_SESSION["nbrecaseshoraires"]; $i++) {
$j = $i+1;
print '<td classe="somme">'. $langs->trans("Time") .' '.$j.'</center></td>'."\n";
}
if ($_SESSION["nbrecaseshoraires"] < 10) {
print '<td classe="somme"><input type="image" name="ajoutcases" src="images/add-16.png"></td>'."\n";
}
print '</tr>'."\n";
//affichage de la liste des jours choisis
for ($i=0;$i<count($_SESSION["totalchoixjour"]);$i++)
{
print '<tr>'."\n";
print '<td>'.dol_print_date($_SESSION["totalchoixjour"][$i], 'daytext').' ('.dol_print_date($_SESSION["totalchoixjour"][$i], '%A').')</td>';
$affichageerreurfindeligne=false;
//affichage des cases d'horaires
for ($j=0;$j<$_SESSION["nbrecaseshoraires"];$j++) {
//si on voit une erreur, le fond de la case est rouge
if (isset($errheure[$i][$j]) && $errheure[$i][$j]) {
print '<td><input type=text size="10" maxlength="11" name=horaires'.$i.'[] value="'.$_SESSION["horaires$i"][$j].'" style="background-color:#FF6666;"></td>'."\n";
$affichageerreurfindeligne=true;
} else { //sinon la case est vide normalement
if (issetAndNoEmpty('horaires'.$i, $_SESSION) === false || issetAndNoEmpty($j, $_SESSION['horaires'.$i]) === false) {
if (issetAndNoEmpty('horaires'.$i, $_SESSION) === true) {
$_SESSION["horaires$i"][$j] = '';
} else {
$_SESSION["horaires$i"] = array();
$_SESSION["horaires$i"][$j] = '';
}
}
print '<td><input type=text size="10" maxlength="11" name=horaires'.$i.'[] value="'.$_SESSION["horaires$i"][$j].'"></td>'."\n";
}
}
if ($affichageerreurfindeligne) {
print '<td><b><font color=#FF0000>'. _("Bad format!") .'</font></b></td>'."\n";
}
print '</tr>'."\n";
}
print '</table>'."\n";
//affichage des boutons de formulaire pour annuler, effacer les jours ou créer le sondage
print '<table>'."\n";
print '<tr>'."\n";
print '<td><input type="submit" class="button" name="reset" value="'. dol_escape_htmltag($langs->trans("RemoveAllDays")) .'"></td><td><input type="submit" class="button" name="reporterhoraires" value="'. dol_escape_htmltag($langs->trans("CopyHoursOfFirstDay")) .'"></td><td><input type="submit" class="button" name="resethoraires" value="'. dol_escape_htmltag($langs->trans("RemoveAllHours")) .'"></td></tr>'."\n";
print'<tr><td colspan="3"><br><br></td></tr>'."\n";
print '<tr><td colspan="3" align="center"><input type="submit" class="button" name="choixheures" value="'. $langs->trans("NextStep"). '"></td></tr>'."\n";
print '</table>'."\n";
//si un seul jour et aucunes horaires choisies, : message d'erreur
if ((GETPOST('choixheures') || GETPOST('choixheures_x')) && (count($_SESSION["totalchoixjour"])=="1" && $_POST["horaires0"][0]=="" && $_POST["horaires0"][1]=="" && $_POST["horaires0"][2]=="" && $_POST["horaires0"][3]=="" && $_POST["horaires0"][4]=="")) {
print '<table><tr><td colspan=3><font color=#FF0000>'. _("Enter more choices for the voters") .'</font><br></td></tr></table>'."\n";
$erreur=true;
}
}
//s'il n'y a pas d'erreur et que le bouton de creation est activé, on demande confirmation
if (!$erreur && (GETPOST('choixheures') || GETPOST('choixheures_x'))) {
$taille_tableau=sizeof($_SESSION["totalchoixjour"])-1;
$jour_arret = $_SESSION["totalchoixjour"][$taille_tableau]+200000;
$date_fin=dol_print_date($jour_arret, 'dayhourtext');
print '<br><div class="presentationdatefin">'. $langs->trans("PollWillExpire",2) .'</td></tr><tr><td><br>'. $langs->trans("RemovalDate") .' : <b> '.$date_fin.'</b><br>'."\n";
print '</div>'."\n";
print '<div class="presentationdatefin">'."\n";
print '<font color="#FF0000">'. _("Once you have confirmed the creation of your poll, you will be automatically redirected on the page of your poll. <br>Then, you will receive quickly an email contening the link to your poll for sending it to the voters.") .'</font>'."\n";
print'</div>'."\n";
// print'<p class=affichageexport>'."\n";
// print 'Pour finir la cr&eacute;ation du sondage, cliquez sur le bouton <img src="images/add-16.png" alt="ajout"> ci-dessous'."\n";
// print '</p>'."\n";
print '<table>'."\n";
print '<tr><td>'. $langs->trans("BackToHoursSetup") .'</td><td></td><td><input type="image" name="retourhoraires" src="images/back-32.png"></td></tr>'."\n";
print'<tr><td>'. $langs->trans("CreatePoll") .'</td><td></td><td><input type="image" name="confirmation" value="Valider la cr&eacute;ation" src="images/add.png"></td></tr>'."\n";
print '</table>'."\n";
}
print '</tr>'."\n";
print '</table>'."\n";
print '<a name=bas></a>'."\n";
//fin du formulaire et bandeau de pied
print '</form>'."\n";
//bandeau de pied
print '<br><br><br><br>'."\n";
print '</center></div>'."\n";
llxFooterSurvey();
$db->close();
?>

View File

@ -0,0 +1,199 @@
<?php
/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/opensurvey/public/create_survey.php
* \ingroup opensurvey
* \brief Page to create a new survey
*/
define("NOLOGIN",1); // This means this output page does not require to be logged.
define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
require_once('../../main.inc.php');
require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
require_once(DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php");
$langs->load("opensurvey@opensurvey");
$origin=GETPOST('origin','alpha');
// On teste toutes les variables pour supprimer l'ensemble des warnings PHP
// On transforme en entites html les données afin éviter les failles XSS
$post_var = array('titre', 'nom', 'adresse', 'commentaires', 'canedit', 'mailsonde', 'creation_sondage_date', 'creation_sondage_date_x', 'creation_sondage_autre', 'creation_sondage_autre_x');
foreach ($post_var as $var)
{
$$var = GETPOST($var);
}
// On initialise egalement la session car sinon bonjour les warning :-)
$session_var = array('titre', 'nom', 'adresse', 'commentaires', 'mailsonde', 'canedit');
foreach ($session_var as $var)
{
if (isset($_SESSION[$var])) $_SESSION[$var] = null;
}
// On initialise également les autres variables
$erreur_adresse = false;
$erreur_injection_titre = false;
$erreur_injection_nom = false;
$erreur_injection_commentaires = false;
$cocheplus = '';
$cochemail = '';
// Jump to correct page
if (GETPOST("creation_sondage_date") || GETPOST("creation_sondage_autre") || GETPOST("creation_sondage_date_x") || GETPOST("creation_sondage_autre_x"))
{
$_SESSION["titre"] = $titre;
$_SESSION["nom"] = $nom;
$_SESSION["adresse"] = $adresse;
$_SESSION["commentaires"] = $commentaires;
unset($_SESSION["canedit"]);
$_SESSION["canedit"] = $canedit;
unset($_SESSION["mailsonde"]);
if ($mailsonde !== null) {
$_SESSION["mailsonde"] = true;
} else {
$_SESSION["mailsonde"] = false;
}
if(validateEmail($adresse) === false) {
$erreur_adresse = true;
}
//var_dump($titre.' - '.$nom.' - '.$adresse.' - '.!$erreur_adresse.' - '.! $erreur_injection_titre.' - '.! $erreur_injection_commentaires.' - '.! $erreur_injection_nom.' - '.$creation_sondage_date.' - '.$creation_sondage_autre); exit;
if ($titre && $nom && $adresse && !$erreur_adresse && ! $erreur_injection_titre && ! $erreur_injection_commentaires && ! $erreur_injection_nom)
{
if (! empty($creation_sondage_date))
{
header("Location: choix_date.php".($origin?'?origin='.$origin:''));
exit();
}
if (! empty($creation_sondage_autre))
{
header("Location: choix_autre.php".($origin?'?origin='.$origin:''));
exit();
}
}
}
/*
* View
*/
$arrayofjs=array();
$arrayofcss=array('/opensurvey/css/style.css');
llxHeaderSurvey($langs->trans("OpenSurvey"), "", 0, 0, $arrayofjs, $arrayofcss);
print '<div class="bandeautitre">'. $langs->trans("CreatePoll").' (1 / 2)' .'</div>'."\n";
//debut du formulaire
print '<form name="formulaire" action="create_survey.php" method="POST" onkeypress="javascript:process_keypress(event)">'."\n";
print '<input type="hidden" name="origin" value="'.dol_escape_htmltag($origin).'">';
print '<div class=corps>'."\n";
print '<br>'. $langs->trans("YouAreInPollCreateArea") .'<br><br>'."\n";
//Affichage des différents champs textes a remplir
print '<table>'."\n";
print '<tr><td class="fieldrequired">'. $langs->trans("PollTitle") .'</td><td><input type="text" name="titre" size="40" maxlength="80" value="'.$_SESSION["titre"].'"></td>'."\n";
if (! $_SESSION["titre"] && (GETPOST('creation_sondage_date') || GETPOST('creation_sondage_autre') || GETPOST('creation_sondage_date_x') || GETPOST('creation_sondage_autre_x')))
{
print "<td><font color=\"#FF0000\">" . $langs->trans("FieldMandatory") . "</font></td>"."\n";
}
print '</tr>'."\n";
print '<tr><td>'. $langs->trans("Description") .'</td><td><textarea name="commentaires" rows="7" cols="40">'.$_SESSION["commentaires"].'</textarea></td>'."\n";
print '</tr>'."\n";
print '<tr><td class="fieldrequired">'. $langs->trans("OpenSurveyYourName") .'</td><td>';
print '<input type="text" name="nom" size="40" maxlength="40" value="'.$_SESSION["nom"].'"></td>'."\n";
if (! $_SESSION["nom"] && (GETPOST('creation_sondage_date') || GETPOST('creation_sondage_autre') || GETPOST('creation_sondage_date_x') || GETPOST('creation_sondage_autre_x')))
{
print "<td><font color=\"#FF0000\">" . $langs->trans("FieldMandatory") . "</font></td>"."\n";
}
print '</tr>'."\n";
print '<tr><td class="fieldrequired">'. $langs->trans("OpenSurveyYourEMail") .'</td><td>';
print '<input type="text" name="adresse" size="40" maxlength="64" value="'.$_SESSION["adresse"].'"></td>'."\n";
if (!$_SESSION["adresse"] && (GETPOST('creation_sondage_date') || GETPOST('creation_sondage_autre') || GETPOST('creation_sondage_date_x') || GETPOST('creation_sondage_autre_x')))
{
print "<td><font color=\"#FF0000\">" .$langs->trans("FieldMandatory") . " </font></td>"."\n";
} elseif ($erreur_adresse && (GETPOST('creation_sondage_date') || GETPOST('creation_sondage_autre') || GETPOST('creation_sondage_date_x') || GETPOST('creation_sondage_autre_x')))
{
print "<td><font color=\"#FF0000\">" . _("The address is not correct! (You should enter a valid email address in order to receive the link to your poll)") . "</font></td>"."\n";
}
print '</tr>'."\n";
print '</table>'."\n";
//focus javascript sur le premier champ
print '<script type="text/javascript">'."\n";
print 'document.formulaire.titre.focus();'."\n";
print '</script>'."\n";
print '<br>'."\n";
#affichage du cochage par défaut
$cocheplus='';
if ($_SESSION["canedit"]) $cocheplus="checked";
print '<input type="checkbox" name="canedit" '.$cocheplus.'>'. $langs->trans("VotersCanModify") .'<br>'."\n";
if ($_SESSION["mailsonde"]) $cochemail="checked";
print '<input type=checkbox name=mailsonde '.$cochemail.'>'. $langs->trans("ToReceiveEMailForEachVote") .'<br>'."\n";
if (GETPOST('choix_sondage'))
{
if (GETPOST('choix_sondage') == 'date') print '<input type="hidden" name="creation_sondage_date" value="date">';
else print '<input type="hidden" name="creation_sondage_autre" value="autre">';
print '<input type="hidden" name="choix_sondage" value="'.GETPOST('choix_sondage').'">';
print '<br><input type="submit" class="button" name="submit" value="'.$langs->trans("CreatePoll").' ('.(GETPOST('choix_sondage') == 'date'?$langs->trans("TypeDate"):$langs->trans("TypeClassic")).')">';
}
else
{
//affichage des boutons pour choisir sondage date ou autre
print '<br><table >'."\n";
print '<tr><td>'. _("Schedule an event") .'</td><td></td> '."\n";
print '<td><input type="image" name="creation_sondage_date" value="Trouver une date" src="images/calendar-32.png"></td></tr>'."\n";
print '<tr><td>'. _("Make a choice") .'</td><td></td> '."\n";
print '<td><input type="image" name="creation_sondage_autre" value="'. _('Make a poll') . '" src="images/chart-32.png"></td></tr>'."\n";
print '</table>'."\n";
}
print '<br><br><br>'."\n";
print '</div>'."\n";
print '</form>'."\n";
llxFooterSurvey();
$db->close();
?>

View File

@ -0,0 +1,154 @@
<?php
/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/opensurvey/public/exportcsv.php
* \ingroup opensurvey
* \brief Page to list surveys
*/
define("NOLOGIN",1); // This means this output page does not require to be logged.
define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
require_once('../../main.inc.php');
require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
require_once(DOL_DOCUMENT_ROOT."/opensurvey/class/opensurveysondage.class.php");
$action=GETPOST('action');
$numsondage = $numsondageadmin = '';
if (GETPOST('sondage'))
{
if (strlen(GETPOST('sondage')) == 24) // recuperation du numero de sondage admin (24 car.) dans l'URL
{
$numsondageadmin=GETPOST("sondage",'alpha');
$numsondage=substr($numsondageadmin, 0, 16);
}
else
{
$numsondageadmin='';
$numsondage=GETPOST("sondage",'alpha');
}
}
$object=new Opensurveysondage($db);
$result=$object->fetch(0,$numsondage);
if ($result <= 0) dol_print_error('','Failed to get survey id '.$numsondage);
/*
* Actions
*/
/*
* View
*/
$now=dol_now();
$nbcolonnes=substr_count($object->sujet,',')+1;
$toutsujet=explode(",",$object->sujet);
#$toutsujet=str_replace("°","'",$toutsujet);
// affichage des sujets du sondage
$input.=$langs->trans("Name").";";
for ($i=0;$toutsujet[$i];$i++)
{
if ($object->format=="D"||$object->format=="D+")
{
$input.=''.dol_print_date($toutsujet[$i],'dayhour').';';
} else {
$input.=''.$toutsujet[$i].';';
}
}
$input.="\r\n";
if (strpos($object->sujet,'@') !== false)
{
$input.=";";
for ($i=0;$toutsujet[$i];$i++)
{
$heures=explode("@",$toutsujet[$i]);
$input.=''.$heures[1].';';
}
$input.="\r\n";
}
$sql ='SELECT nom, reponses';
$sql.=' FROM '.MAIN_DB_PREFIX."opensurvey_user_studs";
$sql.=" WHERE id_sondage='" . $db->escape($numsondage) . "'";
$sql.=" ORDER BY id_users";
dol_syslog("sql=".$sql);
$resql=$db->query($sql);
if ($resql)
{
$num=$db->num_rows($resql);
$i=0;
while ($i < $num)
{
$obj=$db->fetch_object($resql);
// Le nom de l'utilisateur
$nombase=str_replace("°","'",$obj->nom);
$input.=$nombase.';';
//affichage des resultats
$ensemblereponses=$obj->reponses;
for ($k=0;$k<$nbcolonnes;$k++)
{
$car=substr($ensemblereponses,$k,1);
if ($car == "1")
{
$input.='OK;';
$somme[$k]++;
}
else if ($car == "2")
{
$input.='KO;';
$somme[$k]++;
}
else
{
$input.=';';
}
}
$input.="\r\n";
$i++;
}
}
else dol_print_error($db);
$filesize = strlen( $input );
$filename=$numsondage."_".dol_print_date($now,'%Y%m%d%H%M').".csv";
header( 'Content-Type: text/csv; charset=utf-8' );
header( 'Content-Length: '.$filesize );
header( 'Content-Disposition: attachment; filename="'.$filename.'"' );
header( 'Cache-Control: max-age=10' );
echo $input;
exit;
?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 901 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 845 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 587 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 804 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 829 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 777 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 753 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

View File

@ -0,0 +1,61 @@
<?php
/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1');
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
define("NOLOGIN",1); // This means this output page does not require to be logged.
define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
require_once('../../main.inc.php');
require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
require_once(DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php");
$origin=GETPOST('origin','alpha');
/*
* View
*/
$arrayofjs=array();
$arrayofcss=array('/opensurvey/css/style.css');
llxHeaderSurvey($langs->trans("OpenSurvey"), "", 0, 0, $arrayofjs, $arrayofcss);
print '<center>
<form name="formulaire" action="create_survey.php" method="POST">
<input type="hidden" name="origin" value="'.dol_escape_htmltag($origin).'">
<div id="interface-header" style="">
<p id="application-description" class="pp-gris-fonce2">'.$langs->trans("OpenSurveyDesc").' '.$langs->trans("OpenSurveyNoRegistration").'</p>
</div><br>';
print $langs->trans("OrganizeYourMeetingEasily").'
<div class="corps">
<br>
<div class="index_date"><div><img class="opacity" src="images/date.png" onclick="document.formulaire.date.click()"></div><button id="date" name="choix_sondage" value="date" type="submit" class="button orange bigrounded"><img src="images/calendar-32.png" alt=""><strong>&nbsp;Créer un sondage spécial dates</strong></button></div><div class="index_sondage"><div><img class="opacity" src="images/sondage2.png" onclick="document.formulaire.autre.click()"></div><button id="autre" name="choix_sondage" value="autre" type="submit" class="button blue bigrounded"><img src="images/chart-32.png" alt=""><strong>&nbsp;Créer un sondage classique</strong></button></div><div style="clear:both;"></div>
</div>
</form></center>';
llxFooterSurvey();
$db->close();
?>

View File

@ -0,0 +1,713 @@
<?php
/* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/opensurvey/public/studs.php
* \ingroup opensurvey
* \brief Page to list surveys
*/
define("NOLOGIN",1); // This means this output page does not require to be logged.
define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
require_once('../../main.inc.php');
require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
require_once(DOL_DOCUMENT_ROOT."/opensurvey/class/opensurveysondage.class.php");
require_once(DOL_DOCUMENT_ROOT."/opensurvey/fonctions.php");
// Init vars
$action=GETPOST('action');
$numsondage = $numsondageadmin = '';
if (GETPOST('sondage'))
{
if (strlen(GETPOST('sondage')) == 24) // recuperation du numero de sondage admin (24 car.) dans l'URL
{
$numsondageadmin=GETPOST("sondage",'alpha');
$numsondage=substr($numsondageadmin, 0, 16);
}
else
{
$numsondageadmin='';
$numsondage=GETPOST("sondage",'alpha');
}
}
$object=new Opensurveysondage($db);
$result=$object->fetch(0,$numsondage);
if ($result <= 0) dol_print_error('','Failed to get survey id '.$numsondage);
$nbcolonnes = substr_count($object->sujet, ',') + 1;
/*
* Actions
*/
$listofvoters=explode(',',$_SESSION["savevoter"]);
// Add comment
if (GETPOST('ajoutcomment'))
{
$error=0;
if (! GETPOST('comment'))
{
$error++;
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Comment")),'errors');
}
if (! GETPOST('commentuser'))
{
$error++;
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("User")),'errors');
}
if (! $error)
{
$comment = GETPOST("comment");
$comment_user = GETPOST('commentuser');
$sql = "INSERT INTO ".MAIN_DB_PREFIX."opensurvey_comments (id_sondage, comment, usercomment)";
$sql.= " VALUES ('".$db->escape($numsondage)."','".$db->escape($comment)."','".$db->escape($comment_user)."')";
$resql = $db->query($sql);
dol_syslog("sql=".$sql);
if (! $resql) dol_print_error($db);
}
}
// Add vote
if (isset($_POST["boutonp"]) || isset($_POST["boutonp_x"]))
{
//Si le nom est bien entré
if (GETPOST('nom'))
{
$nouveauchoix = '';
for ($i=0;$i<$nbcolonnes;$i++)
{
if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1')
{
$nouveauchoix.="1";
}
else if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2')
{
$nouveauchoix.="2";
}
else { // sinon c'est 0
$nouveauchoix.="0";
}
}
$nom=substr($_POST["nom"],0,64);
// Check if vote already exists
$sql = 'SELECT id_users, nom FROM '.MAIN_DB_PREFIX."opensurvey_user_studs WHERE id_sondage='".$db->escape($numsondage)."' AND nom = '".$db->escape($nom)."' ORDER BY id_users";
$resql = $db->query($sql);
$num_rows = $db->num_rows($resql);
if ($num_rows > 0)
{
setEventMessage($langs->trans("VoteNameAlreadyExists"),'errors');
$error++;
}
else
{
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'opensurvey_user_studs (nom, id_sondage, reponses)';
$sql.= " VALUES ('".$db->escape($nom)."', '".$db->escape($numsondage)."','".$db->escape($nouveauchoix)."')";
$resql=$db->query($sql);
if ($resql)
{
// Add voter to session
$_SESSION["savevoter"]=$nom.','.(empty($_SESSION["savevoter"])?'':$_SESSION["savevoter"]); // Save voter
$listofvoters=explode(',',$_SESSION["savevoter"]);
if (! empty($object->mailsonde))
{
include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
$cmailfile=new CMailFile("[".DOL_APPLICATION_TITLE."] ".$langs->trans("Poll").': '.$object->titre, $object->mail_admin, $conf->global->MAIN_MAIL_EMAIL_FROM, $nom." has filled a line.\nou can find your poll at the link:\n".getUrlSondage($numsondage));
$result=$cmailfile->sendfile();
if ($result)
{
}
else
{
}
}
}
else dol_print_error($db);
}
}
else
{
$err |= NAME_EMPTY;
}
}
// Update vote
$sql = 'SELECT * FROM '.MAIN_DB_PREFIX.'opensurvey_user_studs WHERE id_sondage='.$connect->Param('numsondage').' ORDER BY id_users';
$sql = $connect->Prepare($sql);
$user_studs = $connect->Execute($sql, array($numsondage));
$nblignes = $user_studs->RecordCount();
$testmodifier = false;
$ligneamodifier = -1;
for ($i=0; $i<$nblignes; $i++)
{
if (isset($_POST['modifierligne'.$i])) {
$ligneamodifier = $i;
}
//test pour voir si une ligne est a modifier
if (isset($_POST['validermodifier'.$i])) {
$modifier = $i;
$testmodifier = true;
}
}
if ($testmodifier)
{
//var_dump($_POST);exit;
$nouveauchoix = '';
for ($i=0;$i<$nbcolonnes;$i++)
{
//var_dump($_POST["choix$i"]);
if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1')
{
$nouveauchoix.="1";
}
else if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2')
{
$nouveauchoix.="2";
}
else { // sinon c'est 0
$nouveauchoix.="0";
}
}
$compteur=0;
while ($data = $user_studs->FetchNextObject(false) )
{
if ($compteur == $modifier)
{
$sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_user_studs";
$sql.= " SET reponses = '".$db->escape($nouveauchoix)."'";
$sql.= " WHERE nom = '".$db->escape($data->nom)."' AND id_users = '".$db->escape($data->id_users)."'";
$resql = $db->query($sql);
if ($resql <= 0)
{
dol_print_error($db);
exit;
}
if ($object->mailsonde=="yes")
{
// TODO Use CMailFile
//$headers="From: ".NOMAPPLICATION." <".ADRESSEMAILADMIN.">\r\nContent-Type: text/plain; charset=\"UTF-8\"\nContent-Transfer-Encoding: 8bit";
//mail ("$object->mail_admin", "[".NOMAPPLICATION."] " . _("Poll's participation") . " : $object->titre", "\"$data->nom\""."" . _("has filled a line.\nYou can find your poll at the link") . " :\n\n".getUrlSondage($numsondage)." \n\n" . _("Thanks for your confidence.") . "\n".NOMAPPLICATION,$headers);
}
}
$compteur++;
}
}
// Delete comment
$idcomment=GETPOST('deletecomment','int');
if ($idcomment)
{
$sql = 'DELETE FROM '.MAIN_DB_PREFIX.'opensurvey_comments WHERE id_comment = '.$idcomment;
$resql = $db->query($sql);
}
/*
* View
*/
$form=new Form($db);
$object=new OpenSurveySondage($db);
$arrayofjs=array();
$arrayofcss=array('/opensurvey/css/style.css');
llxHeaderSurvey($object->titre, "", 0, 0, $arrayofjs, $arrayofcss);
$res=$object->fetch(0,$numsondage);
if ($res <= 0)
{
print $langs->trans("ErrorPollDoesNotExists",$numsondage);
llxFooterSurvey();
exit;
}
// Define format of choices
$toutsujet=explode(",",$object->sujet);
$toutsujet=str_replace("°","'",$toutsujet);
$listofanswers=array();
foreach ($toutsujet as $value)
{
$tmp=explode('@',$value);
$listofanswers[]=array('label'=>$tmp[0],'format'=>($tmp[1]?$tmp[1]:'checkbox'));
}
print '<div class="survey_invitation">'.$langs->trans("YouAreInivitedToVote").'</div>';
print $langs->trans("OpenSurveyHowTo").'<br><br>';
print '<div class="corps"> '."\n";
//affichage du titre du sondage
$titre=str_replace("\\","",$object->titre);
print '<strong>'.$titre.'</strong><br>'."\n";
//affichage du nom de l'auteur du sondage
print $langs->trans("InitiatorOfPoll") .' : '.$object->nom_admin.'<br>'."\n";
//affichage des commentaires du sondage
if ($object->commentaires) {
print '<br>'.$langs->trans("Description") .' :<br>'."\n";
$commentaires=dol_nl2br($object->commentaires);
print $commentaires;
print '<br>'."\n";
}
print '</div>'."\n";
print '<form name="formulaire" action="studs.php?sondage='.$numsondage.'"'.'#bas" method="POST" onkeypress="javascript:process_keypress(event)">'."\n";
print '<input type="hidden" name="sondage" value="' . $numsondage . '"/>';
// Todo : add CSRF protection
print '<div class="cadre"> '."\n";
print '<br><br>'."\n";
// Debut de l'affichage des resultats du sondage
print '<table class="resultats">'."\n";
//recuperation des utilisateurs du sondage
$sql = 'SELECT * FROM '.MAIN_DB_PREFIX.'opensurvey_user_studs WHERE id_sondage='.$connect->Param('numsondage').' ORDER BY id_users';
$sql = $connect->Prepare($sql);
$user_studs = $connect->Execute($sql, array($numsondage));
//si le sondage est un sondage de date
if ($object->format=="D"||$object->format=="D+")
{
//affichage des sujets du sondage
print '<tr>'."\n";
print '<td></td>'."\n";
//affichage des années
$colspan=1;
for ($i=0;$i<count($toutsujet);$i++)
{
if (isset($toutsujet[$i+1]) && date('Y', intval($toutsujet[$i])) == date('Y', intval($toutsujet[$i+1]))) {
$colspan++;
} else {
print '<td colspan='.$colspan.' class="annee">'.date('Y', intval($toutsujet[$i])).'</td>'."\n";
$colspan=1;
}
}
print '</tr>'."\n";
print '<tr>'."\n";
print '<td></td>'."\n";
//affichage des mois
$colspan=1;
for ($i=0;$i<count($toutsujet);$i++) {
$cur = intval($toutsujet[$i]); // intval() est utiliser pour supprimer le suffixe @* qui déplaît logiquement à strftime()
if (isset($toutsujet[$i+1]) === false) {
$next = false;
} else {
$next = intval($toutsujet[$i+1]);
}
if ($next && dol_print_date($cur, "%B") == dol_print_date($next, "%B") && dol_print_date($cur, "%Y") == dol_print_date($next, "%Y")){
$colspan++;
} else {
print '<td colspan='.$colspan.' class="mois">'.dol_print_date($cur, "%B").'</td>'."\n";
$colspan=1;
}
}
print '</tr>'."\n";
print '<tr>'."\n";
print '<td></td>'."\n";
//affichage des jours
$colspan=1;
for ($i=0;$i<count($toutsujet);$i++) {
$cur = intval($toutsujet[$i]);
if (isset($toutsujet[$i+1]) === false) {
$next = false;
} else {
$next = intval($toutsujet[$i+1]);
}
if ($next && dol_print_date($cur, "%a %e") == dol_print_date($next,"%a %e") && dol_print_date($cur, "%B") == dol_print_date($next, "%B")) {
$colspan++;
} else {
print '<td colspan="'.$colspan.'" class="jour">'.dol_print_date($cur, "%a %e").'</td>'."\n";
$colspan=1;
}
}
print '</tr>'."\n";
//affichage des horaires
if (strpos($object->sujet, '@') !== false) {
print '<tr>'."\n";
print '<td></td>'."\n";
for ($i=0; isset($toutsujet[$i]); $i++) {
$heures=explode('@',$toutsujet[$i]);
if (isset($heures[1])) {
print '<td class="heure">'.$heures[1].'</td>'."\n";
} else {
print '<td class="heure"></td>'."\n";
}
}
print '</tr>'."\n";
}
}
else
{
$toutsujet=str_replace("°","'",$toutsujet);
//affichage des sujets du sondage
print '<tr>'."\n";
print '<td></td>'."\n";
for ($i=0; isset($toutsujet[$i]); $i++)
{
$tmp=explode('@',$toutsujet[$i]);
print '<td class="sujet">'.$tmp[0].'</td>'."\n";
}
print '</tr>'."\n";
}
// Loop on each answer
$sumfor = array();
$sumagainst = array();
$compteur = 0;
$sql = 'SELECT * FROM '.MAIN_DB_PREFIX.'opensurvey_user_studs WHERE id_sondage='.$connect->Param('numsondage').' ORDER BY id_users';
$sql = $connect->Prepare($sql);
$user_studs = $connect->Execute($sql, array($numsondage));
while ($data = $user_studs->FetchNextObject(false))
{
$ensemblereponses = $data->reponses;
$nombase=str_replace("°","'",$data->nom);
print '<tr>'."\n";
// ligne d'un usager pré-authentifié
$mod_ok = ($object->canedit || (! empty($nombase) && in_array($nombase, $listofvoters)));
// Name
print '<td class="nom">'.$nombase.'</td>'."\n";
// pour chaque colonne
for ($i=0; $i < $nbcolonnes; $i++)
{
$car = substr($ensemblereponses, $i, 1);
if ($compteur == $ligneamodifier)
{
print '<td class="vide">';
if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'],array('yesno','foragainst')))
{
print '<input type="checkbox" name="choix'.$i.'" value="1" ';
if (((string) $car) == '1') print 'checked="checked"';
print '>';
}
if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno')
{
$arraychoice=array('2'=>'&nbsp;','0'=>$langs->trans("No"),'1'=>$langs->trans("Yes"));
print $form->selectarray("choix".$i, $arraychoice, $car);
}
if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst')
{
$arraychoice=array('2'=>'&nbsp;','0'=>$langs->trans("Against"),'1'=>$langs->trans("For"));
print $form->selectarray("choix".$i, $arraychoice, $car);
}
print '</td>'."\n";
}
else
{
if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'],array('yesno','foragainst')))
{
if (((string) $car) == "1") print '<td class="ok">OK</td>'."\n";
else print '<td class="non">KO</td>'."\n";
// Total
if (isset($sumfor[$i]) === false) $sumfor[$i] = 0;
if (((string) $car) == "1") $sumfor[$i]++;
}
if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno')
{
if (((string) $car) == "1") print '<td class="ok">'.$langs->trans("Yes").'</td>'."\n";
else if (((string) $car) == "0") print '<td class="non">'.$langs->trans("No").'</td>'."\n";
else print '<td class="vide">&nbsp;</td>'."\n";
// Total
if (! isset($sumfor[$i])) $sumfor[$i] = 0;
if (! isset($sumagainst[$i])) $sumagainst[$i] = 0;
if (((string) $car) == "1") $sumfor[$i]++;
if (((string) $car) == "0") $sumagainst[$i]++;
}
if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst')
{
if (((string) $car) == "1") print '<td class="ok">'.$langs->trans("For").'</td>'."\n";
else if (((string) $car) == "0") print '<td class="non">'.$langs->trans("Against").'</td>'."\n";
else print '<td class="vide">&nbsp;</td>'."\n";
// Total
if (! isset($sumfor[$i])) $sumfor[$i] = 0;
if (! isset($sumagainst[$i])) $sumagainst[$i] = 0;
if (((string) $car) == "1") $sumfor[$i]++;
if (((string) $car) == "0") $sumagainst[$i]++;
}
}
}
// Button edit at end of line
if ($compteur != $ligneamodifier && $mod_ok)
{
print '<td class="casevide"><input type="submit" class="button" name="modifierligne'.$compteur.'" value="'.dol_escape_htmltag($langs->trans("Edit")).'"></td>'."\n";
}
//demande de confirmation pour modification de ligne
for ($i=0;$i<$nblignes;$i++) {
if (isset($_POST["modifierligne$i"])) {
if ($compteur == $i) {
print '<td class="casevide"><input type="submit" class="button" name="validermodifier'.$compteur.'" value="'.dol_escape_htmltag($langs->trans("Save")).'"></td>'."\n";
}
}
}
$compteur++;
print '</tr>'."\n";
}
// Add line to add new record
if ($ligneamodifier < 0 && (! isset($_SESSION['nom'])))
{
print '<tr>'."\n";
print '<td class="nom">'."\n";
if (isset($_SESSION['nom']))
{
print '<input type=hidden name="nom" value="'.$_SESSION['nom'].'">'.$_SESSION['nom']."\n";
} else {
print '<input type="text" name="nom" placeholder="'.dol_escape_htmltag($langs->trans("Name")).'" maxlength="64" size="24">'."\n";
}
print '</td>'."\n";
// affichage des cases de formulaire checkbox pour un nouveau choix
for ($i=0;$i<$nbcolonnes;$i++)
{
print '<td class="vide">';
if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'],array('yesno','foragainst')))
{
print '<input type="checkbox" name="choix'.$i.'" value="1"';
if (isset($_POST['choix'.$i]) && $_POST['choix'.$i] == '1' && is_error(NAME_EMPTY) )
{
print ' checked="checked"';
}
print '>';
}
if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno')
{
$arraychoice=array('2'=>'&nbsp;','0'=>$langs->trans("No"),'1'=>$langs->trans("Yes"));
print $form->selectarray("choix".$i, $arraychoice, GETPOST('choix'.$i));
}
if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst')
{
$arraychoice=array('2'=>'&nbsp;','0'=>$langs->trans("Against"),'1'=>$langs->trans("For"));
print $form->selectarray("choix".$i, $arraychoice, GETPOST('choix'.$i));
}
print '</td>'."\n";
}
// Affichage du bouton de formulaire pour inscrire un nouvel utilisateur dans la base
print '<td><input type="image" name="boutonp" value="' . $langs->trans('Vote') . '" src="'.dol_buildpath('/opensurvey/img/add-24.png',1).'"></td>'."\n";
print '</tr>'."\n";
}
// Select value of best choice (for checkbox columns only)
$nbofcheckbox=0;
for ($i=0; $i < $nbcolonnes; $i++)
{
if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] != 'checkbox') continue;
$nbofcheckbox++;
if (isset($sumfor[$i]))
{
if ($i == 0)
{
$meilleurecolonne = $sumfor[$i];
}
if (! isset($meilleurecolonne) || $sumfor[$i] > $meilleurecolonne)
{
$meilleurecolonne = $sumfor[$i];
}
}
}
// Show line total
print '<tr '.$bc[false].'>'."\n";
print '<td align="center">'. $langs->trans("Total") .'</td>'."\n";
for ($i = 0; $i < $nbcolonnes; $i++)
{
$showsumfor = isset($sumfor[$i])?$sumfor[$i]:'';
$showsumagainst = isset($sumagainst[$i])?$sumagainst[$i]:'';
if (empty($showsumfor)) $showsumfor = 0;
if (empty($showsumagainst)) $showsumagainst = 0;
print '<td>';
if (empty($listofanswers[$i]['format']) || ! in_array($listofanswers[$i]['format'],array('yesno','foragainst'))) print $showsumfor;
if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'yesno') print $langs->trans("Yes").': '.$showsumfor.'<br>'.$langs->trans("No").': '.$showsumagainst;
if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'foragainst') print $langs->trans("For").': '.$showsumfor.'<br>'.$langs->trans("Against").': '.$showsumagainst;
print '</td>'."\n";
}
print '</tr>';
// Show picto winnner
if ($nbofcheckbox >= 2)
{
print '<tr>'."\n";
print '<td class="somme"></td>'."\n";
for ($i=0; $i < $nbcolonnes; $i++)
{
//print 'xx'.(! empty($listofanswers[$i]['format'])).'-'.$sumfor[$i].'-'.$meilleurecolonne;
if (! empty($listofanswers[$i]['format']) && $listofanswers[$i]['format'] == 'checkbox' && isset($sumfor[$i]) && isset($meilleurecolonne) && $sumfor[$i] == $meilleurecolonne)
{
print '<td class="somme"><img src="'.dol_buildpath('/opensurvey/img/medaille.png',1).'"></td>'."\n";
} else {
print '<td class="somme"></td>'."\n";
}
}
print '</tr>'."\n";
}
print '</table>'."\n";
print '</div>'."\n";
$toutsujet=explode(",",$object->sujet);
$toutsujet=str_replace("°","'",$toutsujet);
$compteursujet=0;
$meilleursujet = '';
for ($i = 0; $i < $nbcolonnes; $i++) {
if (isset($sumfor[$i]) && isset($meilleurecolonne) && $sumfor[$i] == $meilleurecolonne) {
$meilleursujet.=", ";
if ($object->format=="D"||$object->format=="D+") {
$meilleursujetexport = $toutsujet[$i];
if (strpos($toutsujet[$i], '@') !== false) {
$toutsujetdate = explode("@", $toutsujet[$i]);
$meilleursujet .= dol_print_date($toutsujetdate[0],'daytext'). ' ('.dol_print_date($toutsujetdate[0],'%A').')' . _("for") . ' ' . $toutsujetdate[1];
} else {
$meilleursujet .= dol_print_date($toutsujet[$i],'daytext'). ' ('.dol_print_date($toutsujet[$i],'%A').')';
}
} else {
$tmps=explode('@',$toutsujet[$i]);
$meilleursujet .= $tmps[0];
}
$compteursujet++;
}
}
$meilleursujet=substr("$meilleursujet", 1);
$meilleursujet = str_replace("°", "'", $meilleursujet);
// Show best choice
if ($nbofcheckbox >= 2)
{
$vote_str = $langs->trans('votes');
print '<p class="affichageresultats">'."\n";
if ($compteursujet == "1" && isset($meilleurecolonne)) {
print '<img src="images/medaille.png" alt="Meilleur choix"> ' . $langs->trans('TheBestChoice') . ": <b>$meilleursujet</b> " . $langs->trans('with') . " <b>$meilleurecolonne </b>" . $vote_str . ".\n";
} elseif (isset($meilleurecolonne)) {
print '<img src="images/medaille.png" alt="Meilleur choix"> ' . $langs->trans('TheBestChoices') . ": <b>$meilleursujet</b> " . $langs->trans('with') . " <b>$meilleurecolonne </b>" . $vote_str . ".\n";
}
print '</p><br>';
}
print '<br>';
// Comment list
$sql = 'SELECT id_comment, usercomment, comment';
$sql.= ' FROM '.MAIN_DB_PREFIX.'opensurvey_comments';
$sql.= " WHERE id_sondage='".$db->escape($numsondage)."'";
$sql.= " ORDER BY id_comment";
$resql = $db->query($sql);
$num_rows=$db->num_rows($resql);
if ($num_rows > 0)
{
$i = 0;
print "<br><b>" . $langs->trans("CommentsOfVoters") . " :</b><br>\n";
while ( $i < $num_rows)
{
$obj=$db->fetch_object($resql);
print '<div class="comment"><span class="usercomment">';
if (in_array($obj->usercomment, $listofvoters)) print '<a href="'.$_SERVER["PHP_SELF"].'?deletecomment='.$obj->id_comment.'&sondage='.$numsondage.'"> '.img_picto('', 'delete.png').'</a> ';
print $obj->usercomment.' :</span> <span class="comment">'.dol_nl2br($obj->comment)."</span></div>";
$i++;
}
}
// Form to add comment
print '<div class="addcomment">' .$langs->trans("AddACommentForPoll") . "<br>\n";
print '<textarea name="comment" rows="2" cols="60"></textarea><br>'."\n";
print $langs->trans("Name") .' : ';
print '<input type="text" name="commentuser" maxlength="64" /> &nbsp; '."\n";
print '<input type="submit" class="button" name="ajoutcomment" value="'.dol_escape_htmltag($langs->trans("AddComment")).'"><br>'."\n";
print '</form>'."\n";
// Focus javascript sur la case de texte du formulaire
print '</div>'."\n";
print '<br><br>';
/*
// Define $urlwithroot
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
$message='';
$url=$urlwithouturlroot.dol_buildpath('/opensurvey/public/studs.php',1).'?sondage='.$numsondage;
$urlvcal='<a href="'.$url.'" target="_blank">'.$url.'</a>';
$message.=img_picto('','object_globe.png').' '.$langs->trans("UrlForSurvey").': '.$urlvcal;
print '<center>'.$message.'</center>';
*/
print '<a name="bas"></a>'."\n";
llxFooterSurvey();
$db->close();
?>

View File

@ -0,0 +1,22 @@
-- ============================================================================
-- Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
-- ============================================================================
ALTER TABLE llx_opensurvey_comments ADD INDEX idx_id_comment id_comment;
ALTER TABLE llx_opensurvey_comments ADD INDEX idx_id_sondage id_sondage;

View File

@ -0,0 +1,25 @@
-- ============================================================================
-- Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
-- ============================================================================
CREATE TABLE llx_opensurvey_comments (
id_comment INTEGER unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY,
id_sondage CHAR(16) NOT NULL,
comment text NOT NULL,
tms timestamp,
usercomment text
) ENGINE=InnoDB;

View File

@ -0,0 +1,19 @@
-- ============================================================================
-- Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
-- ============================================================================
ALTER TABLE llx_opensurvey_sondage ADD INDEX idx_id_sondage_admin id_sondage_admin;
ALTER TABLE llx_opensurvey_sondage ADD INDEX idx_date_fin date_fin;

View File

@ -0,0 +1,33 @@
-- ============================================================================
-- Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
-- ============================================================================
CREATE TABLE llx_opensurvey_sondage (
id_sondage VARCHAR(16) PRIMARY KEY,
id_sondage_admin CHAR(24),
commentaires text,
mail_admin VARCHAR(128),
nom_admin VARCHAR(64),
titre text,
date_fin datetime,
format VARCHAR(2),
mailsonde varchar(2) DEFAULT '0',
survey_link_visible integer DEFAULT 1,
canedit integer DEFAULT 0,
origin varchar(64),
tms timestamp,
sujet TEXT
) ENGINE=InnoDB;

View File

@ -0,0 +1,20 @@
-- ============================================================================
-- Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
-- ============================================================================
ALTER TABLE llx_opensurvey_user_studs ADD INDEX idx_id_users (id_users);
ALTER TABLE llx_opensurvey_user_studs ADD INDEX idx_nom (nom);
ALTER TABLE llx_opensurvey_user_studs ADD INDEX idx_id_sondage (id_sondage);

View File

@ -0,0 +1,24 @@
-- ============================================================================
-- Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
-- ============================================================================
CREATE TABLE llx_opensurvey_user_studs (
id_users INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY,
nom VARCHAR(64) NOT NULL,
id_sondage VARCHAR(16) NOT NULL,
reponses VARCHAR(100) NOT NULL,
tms timestamp
) ENGINE=InnoDB;