--- /tmp/dsg/dolibarr/htdocs/opensurvey/github_card.php +++ /tmp/dsg/dolibarr/htdocs/opensurvey/client_card.php @@ -1,7 +1,7 @@ * Copyright (C) 2014 Marcos García - * Copyright (C) 2018-2020 Frédéric France + * Copyright (C) 2018 Frédéric France * * 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 @@ -41,15 +41,16 @@ $numsondage = ''; if (GETPOST('id')) { - $numsondage = (string) GETPOST('id', 'alpha'); + $numsondage = GETPOST('id', 'alpha'); } $object = new Opensurveysondage($db); $result = $object->fetch(0, $numsondage); -if ($result <= 0) { - dol_print_error($db, $object->error); - exit; +if ($result <= 0) +{ + dol_print_error($db, $object->error); + exit; } $expiredate = dol_mktime(0, 0, 0, GETPOST('expiremonth'), GETPOST('expireday'), GETPOST('expireyear')); @@ -66,108 +67,113 @@ if (empty($reshook)) { - if ($cancel) $action = ''; - - // Delete - if ($action == 'delete_confirm') - { - // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); - - $result = $object->delete($user, '', $numsondage); - - header('Location: '.dol_buildpath('/opensurvey/list.php', 1)); - exit(); - } - - // Close - if ($action == 'close') - { - $object->status = Opensurveysondage::STATUS_CLOSED; - $object->update($user); - } - - // Reopend - if ($action == 'reopen') - { - $object->status = Opensurveysondage::STATUS_VALIDATED; - $object->update($user); - } - - // Update - if ($action == 'update') - { - // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); - - $error = 0; - - if (!GETPOST('nouveautitre')) - { - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Title")), null, 'errors'); - $error++; - $action = 'edit'; - } - - if (!$error) - { - $object->title = (string) GETPOST('nouveautitre', 'alphanohtml'); - $object->description = (string) GETPOST('nouveauxcommentaires', 'restricthtml'); - $object->mail_admin = (string) GETPOST('nouvelleadresse', 'alpha'); - $object->date_fin = $expiredate; - $object->allow_comments = GETPOST('cancomment', 'aZ09') == 'on' ? 1 : 0; - $object->allow_spy = GETPOST('canseeothersvote', 'aZ09') == 'on' ? 1 : 0; - $object->mailsonde = GETPOST('mailsonde', 'aZ09') == 'on' ? 1 : 0; - - $res = $object->update($user); - if ($res < 0) { - setEventMessages($object->error, $object->errors, 'errors'); - $action = 'edit'; - } - } - } - - // Add comment - if (GETPOST('ajoutcomment')) - { - $error = 0; - - if (!GETPOST('comment')) { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Comment")), null, 'errors'); - } - if (!GETPOST('commentuser')) { - $error++; - setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("User")), null, 'errors'); - } - - if (!$error) { - $comment = (string) GETPOST("comment", "restricthtml"); - $comment_user = (string) GETPOST('commentuser', "restricthtml"); - - $resql = $object->addComment($comment, $comment_user); - - if (!$resql) - { - setEventMessages($langs->trans('ErrorInsertingComment'), null, 'errors'); - } - } - } - - // Delete comment - $idcomment = GETPOST('deletecomment', 'int'); - if ($idcomment) - { - // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); - - $resql = $object->deleteComment($idcomment); - } - - if ($action == 'edit') { - // Security check - if (!$user->rights->opensurvey->write) accessforbidden(); - } + if ($cancel) $action = ''; + + // Delete + if ($action == 'delete_confirm') + { + // Security check + if (!$user->rights->opensurvey->write) accessforbidden(); + + $result = $object->delete($user, '', $numsondage); + + header('Location: '.dol_buildpath('/opensurvey/list.php', 1)); + exit(); + } + + // Close + if ($action == 'close') + { + $object->status = Opensurveysondage::STATUS_CLOSED; + $object->update($user); + } + + // Reopend + if ($action == 'reopen') + { + $object->status = Opensurveysondage::STATUS_VALIDATED; + $object->update($user); + } + + // Update + if ($action == 'update') + { + // Security check + if (!$user->rights->opensurvey->write) accessforbidden(); + + $error = 0; + + if (!GETPOST('nouveautitre')) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Title")), null, 'errors'); + $error++; + $action = 'edit'; + } + + if (!$error) + { + $object->titre = GETPOST('nouveautitre', 'nohtml'); + $object->commentaires = GETPOST('nouveauxcommentaires', 'restricthtml'); + $object->description = GETPOST('nouveauxcommentaires', 'restricthtml'); + $object->mail_admin = GETPOST('nouvelleadresse', 'alpha'); + $object->date_fin = $expiredate; + $object->allow_comments = GETPOST('cancomment', 'alpha') == 'on' ? true : false; + $object->allow_spy = GETPOST('canseeothersvote', 'alpha') == 'on' ? true : false; + $object->mailsonde = GETPOST('mailsonde', 'alpha') == 'on' ? true : false; + + $res = $object->update($user); + if ($res < 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + $action = 'edit'; + } + } + } + + // Add comment + if (GETPOST('ajoutcomment')) + { + $error = 0; + + if (!GETPOST('comment')) + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Comment")), null, 'errors'); + } + if (!GETPOST('commentuser')) + { + $error++; + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("User")), null, 'errors'); + } + + if (!$error) + { + $comment = GETPOST("comment"); + $comment_user = GETPOST('commentuser'); + + $resql = $object->addComment($comment, $comment_user); + + if (!$resql) + { + setEventMessages($langs->trans('ErrorInsertingComment'), null, 'errors'); + } + } + } + + // Delete comment + $idcomment = GETPOST('deletecomment', 'int'); + if ($idcomment) + { + // Security check + if (!$user->rights->opensurvey->write) accessforbidden(); + + $resql = $object->deleteComment($idcomment); + } + + if ($action == 'edit') { + // Security check + if (!$user->rights->opensurvey->write) accessforbidden(); + } } @@ -183,7 +189,7 @@ $userstatic->fetch($object->fk_user_creat); } -$title = $object->title." - ".$langs->trans('Card'); +$title = $object->titre." - ".$langs->trans('Card'); $helpurl = ''; $arrayofjs = array(); $arrayofcss = array('/opensurvey/css/style.css'); @@ -208,7 +214,7 @@ $head = opensurvey_prepare_head($object); -print dol_get_fiche_head($head, 'general', $langs->trans("Survey"), -1, 'poll'); +dol_fiche_head($head, 'general', $langs->trans("Survey"), -1, 'poll'); $morehtmlref = ''; @@ -234,8 +240,9 @@ print $langs->trans("Title").''; if ($action == 'edit') { - print ''; -} else print dol_htmlentities($object->title); + print ''; +} +else print dol_htmlentities($object->titre); print ''; // Description @@ -244,7 +251,9 @@ { $doleditor = new DolEditor('nouveauxcommentaires', $object->description, '', 120, 'dolibarr_notes', 'In', 1, 1, 1, ROWS_7, '90%'); $doleditor->Create(0, ''); -} else { +} +else +{ print (dol_textishtml($object->description) ? $object->description : dol_nl2br($object->description, 1, true)); } print ''; @@ -256,7 +265,8 @@ if ($action == 'edit') { print ''; - } else print dol_print_email($object->mail_admin, 0, 0, 1); + } + else print dol_print_email($object->mail_admin, 0, 0, 1); print ''; } @@ -265,7 +275,8 @@ if ($action == 'edit') { print 'mailsonde ? 'checked="checked"' : '').'">'; -} else { +} +else { print yn($object->mailsonde); //If option is active and linked user does not have an email, we show a warning @@ -282,7 +293,8 @@ if ($action == 'edit') { print 'allow_comments ? 'checked="checked"' : '').'">'; -} else print yn($object->allow_comments); +} +else print yn($object->allow_comments); print ''; // Users can see others vote @@ -290,15 +302,17 @@ if ($action == 'edit') { print 'allow_spy ? 'checked="checked"' : '').'">'; -} else print yn($object->allow_spy); +} +else print yn($object->allow_spy); print ''; // Expire date print ''.$langs->trans('ExpireDate').''; if ($action == 'edit') print $form->selectDate($expiredate ? $expiredate : $object->date_fin, 'expire', 0, 0, 0, '', 1, 0); -else { - print dol_print_date($object->date_fin, 'day'); - if ($object->date_fin && $object->date_fin < dol_now() && $object->status == Opensurveysondage::STATUS_VALIDATED) print img_warning($langs->trans("Expired")); +else +{ + print dol_print_date($object->date_fin, 'day'); + if ($object->date_fin && $object->date_fin < dol_now() && $object->status == Opensurveysondage::STATUS_VALIDATED) print img_warning($langs->trans("Expired")); } print ''; @@ -330,14 +344,14 @@ print ''; -print dol_get_fiche_end(); +dol_fiche_end(); if ($action == 'edit') { print '
'; - print ''; + print ''; print '   '; - print ''; + print ''; print '
'; } @@ -351,22 +365,22 @@ print '
'; if ($action != 'edit' && $user->rights->opensurvey->write) { - //Modify button - print ''.$langs->trans("Modify").''; - - if ($object->status == Opensurveysondage::STATUS_VALIDATED) - { - //Close button - print ''.$langs->trans("Close").''; - } - if ($object->status == Opensurveysondage::STATUS_CLOSED) - { - //Opened button - print ''.$langs->trans("ReOpen").''; - } + //Modify button + print ''.$langs->trans("Modify").''; + + if ($object->status == Opensurveysondage::STATUS_VALIDATED) + { + //Close button + print ''.$langs->trans("Close").''; + } + if ($object->status == Opensurveysondage::STATUS_CLOSED) + { + //Opened button + print ''.$langs->trans("ReOpen").''; + } //Delete button - print ''.$langs->trans('Delete').''; + print ''.$langs->trans('Delete').''; } print '
'; @@ -395,8 +409,10 @@ print dol_htmlentities($comment->usercomment).': '.dol_nl2br(dol_htmlentities($comment->comment))."
"; } -} else { - print ''.$langs->trans("NoCommentYet").'
'; +} +else +{ + print $langs->trans("NoCommentYet").'
'; } print '
'; --- /tmp/dsg/dolibarr/htdocs/opensurvey/github_exportcsv.php +++ /tmp/dsg/dolibarr/htdocs/opensurvey/client_exportcsv.php @@ -108,11 +108,14 @@ { $input .= 'OK;'; $somme[$k]++; - } elseif ($car == "2") + } + elseif ($car == "2") { $input .= 'KO;'; $somme[$k]++; - } else { + } + else + { $input .= ';'; } } @@ -120,7 +123,8 @@ $input .= "\r\n"; $i++; } -} else dol_print_error($db); +} +else dol_print_error($db); $filesize = strlen($input); --- /tmp/dsg/dolibarr/htdocs/opensurvey/github_fonctions.php +++ /tmp/dsg/dolibarr/htdocs/opensurvey/client_fonctions.php @@ -77,9 +77,10 @@ //$replacemainarea = (empty($conf->dol_hide_leftmenu) ? '
' : '').'
'; - top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss, 0, 1); // Show html headers - + top_htmlhead($head, $title, $disablejs, $disablehead, $arrayofjs, $arrayofcss); // Show html headers print ''; + + print ''."\n"; print '
'."\n"; @@ -89,6 +90,7 @@ print "\n"; // Show logo (search order: logo defined by PAYMENT_LOGO_suffix, then PAYMENT_LOGO, then small company logo, large company logo, theme logo, common logo) + $width = 0; // Define logo and logosmall $logosmall = $mysoc->logo_small; $logo = $mysoc->logo; @@ -100,10 +102,13 @@ { $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/thumbs/'.$logosmall); - } elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) + $width = 150; + } + elseif (!empty($logo) && is_readable($conf->mycompany->dir_output.'/logos/'.$logo)) { $urllogo = DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); $urllogofull = $dolibarr_main_url_root.'/viewimage.php?modulepart=mycompany&entity='.$conf->entity.'&file='.urlencode('logos/'.$logo); + $width = 150; } // Output html code for logo @@ -112,10 +117,11 @@ print '
'; print '
'; print ''; print '
'; if (empty($conf->global->MAIN_HIDE_POWERED_BY)) { - print ''; + print ''; } print '
'; } @@ -237,10 +243,11 @@ // Insert survey $opensurveysondage = new Opensurveysondage($db); $opensurveysondage->id_sondage = $sondage; - $opensurveysondage->description = $_SESSION['description']; + $opensurveysondage->commentaires = $_SESSION['commentaires']; + $opensurveysondage->description = $_SESSION['commentaires']; $opensurveysondage->mail_admin = $_SESSION['adresse']; $opensurveysondage->nom_admin = $_SESSION['nom']; - $opensurveysondage->title = $_SESSION['title']; + $opensurveysondage->titre = $_SESSION['titre']; $opensurveysondage->date_fin = $_SESSION['champdatefin']; $opensurveysondage->format = $_SESSION['formatsondage']; $opensurveysondage->mailsonde = $_SESSION['mailsonde']; @@ -254,10 +261,10 @@ dol_print_error($db); } - unset($_SESSION["title"]); + unset($_SESSION["titre"]); unset($_SESSION["nom"]); unset($_SESSION["adresse"]); - unset($_SESSION["description"]); + unset($_SESSION["commentaires"]); unset($_SESSION["mailsonde"]); unset($_SESSION['allow_comments']); unset($_SESSION['allow_spy']); --- /tmp/dsg/dolibarr/htdocs/opensurvey/github_index.php +++ /tmp/dsg/dolibarr/htdocs/opensurvey/client_index.php @@ -52,7 +52,8 @@ { $obj = $db->fetch_object($resql); $nbsondages = $obj->nb; -} else dol_print_error($db, ''); +} +else dol_print_error($db, ''); $title = $langs->trans("OpenSurveyArea"); --- /tmp/dsg/dolibarr/htdocs/opensurvey/github_list.php +++ /tmp/dsg/dolibarr/htdocs/opensurvey/client_list.php @@ -36,7 +36,7 @@ $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list -$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'opensurveylist'; // To manage different context of search +$contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'myobjectlist'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') @@ -47,8 +47,8 @@ // Load variable for pagination $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; -$sortfield = GETPOST('sortfield', 'aZ09comma'); -$sortorder = GETPOST('sortorder', 'aZ09comma'); +$sortfield = GETPOST('sortfield', 'alpha'); +$sortorder = GETPOST('sortorder', 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; @@ -77,15 +77,15 @@ $arrayfields = array(); foreach ($arrayfields as $key => $val) { - // If $val['visible']==0, then we never show the field - if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); + // If $val['visible']==0, then we never show the field + if (!empty($val['visible'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>$val['enabled'], 'position'=>$val['position']); } // Extra fields if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) - { - if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) + { + if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) { $arrayfields["ef.".$key] = array( 'label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), @@ -93,7 +93,7 @@ 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]) ); } - } + } } $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); @@ -116,29 +116,29 @@ if (empty($reshook)) { - // Selection of new fields - include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; - - // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers - { - $search_status = ''; - $search_title = ''; - $search_ref = ''; - $toselect = ''; - $search_array_options = array(); - } - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') - || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) - { - $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation - } - - // Mass actions - $objectclass = 'Opensurveysondage'; - $objectlabel = 'Opensurveysondage'; - $uploaddir = $conf->opensurvey->dir_output; - include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + // Selection of new fields + include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; + + // Purge search criteria + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers + { + $search_status = ''; + $search_title = ''; + $search_ref = ''; + $toselect = ''; + $search_array_options = array(); + } + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) + { + $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation + } + + // Mass actions + $objectclass = 'Opensurveysondage'; + $objectlabel = 'Opensurveysondage'; + $uploaddir = $conf->opensurvey->dir_output; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } @@ -155,7 +155,7 @@ $title = $langs->trans('OpenSurveyArea'); -$sql = "SELECT p.id_sondage as rowid, p.fk_user_creat, p.format, p.date_fin, p.status, p.titre as title, p.nom_admin, p.tms,"; +$sql = "SELECT p.id_sondage as rowid, p.fk_user_creat, p.format, p.date_fin, p.status, p.titre, p.nom_admin,"; $sql .= " u.login, u.firstname, u.lastname"; $sql .= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user u ON u.rowid = p.fk_user_creat"; @@ -190,17 +190,19 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords) { $num = $nbtotalofrecords; -} else { - $sql .= $db->plimit($limit + 1, $offset); - - $resql = $db->query($sql); - if (!$resql) - { - dol_print_error($db); - exit; - } - - $num = $db->num_rows($resql); +} +else +{ + $sql .= $db->plimit($limit + 1, $offset); + + $resql = $db->query($sql); + if (!$resql) + { + dol_print_error($db); + exit; + } + + $num = $db->num_rows($resql); } // Direct jump if only one record found @@ -231,8 +233,8 @@ // List of mass actions available $arrayofmassactions = array( - //'presend'=>$langs->trans("SendByMail"), - //'builddoc'=>$langs->trans("PDFMerge"), + //'presend'=>$langs->trans("SendByMail"), + //'builddoc'=>$langs->trans("PDFMerge"), ); if ($permissiontodelete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); @@ -263,8 +265,8 @@ if ($sall) { - foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); - print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; + foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); + print '
'.$langs->trans("FilterOnInto", $sall).join(', ', $fieldstosearchall).'
'; } $moreforfilter = ''; @@ -297,7 +299,6 @@ print ''; print ''; print ''; -print ''; print ''; print ''; print ''; @@ -328,7 +329,6 @@ print_liste_field_titre("Author", $_SERVER["PHP_SELF"], "u.".$fieldtosortuser, $param, "", "", $sortfield, $sortorder); print_liste_field_titre("NbOfVoters", $_SERVER["PHP_SELF"], "", $param, "", 'align="right"', $sortfield, $sortorder); print_liste_field_titre("ExpireDate", $_SERVER["PHP_SELF"], "p.date_fin", $param, "", 'align="center"', $sortfield, $sortorder); -print_liste_field_titre("DateLastModification", $_SERVER["PHP_SELF"], "p.tms", $param, "", 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "p.status", $param, "", 'align="center"', $sortfield, $sortorder); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; @@ -351,17 +351,18 @@ $obj = $db->fetch_object($resql); if (empty($obj)) break; // Should not happen - $sql2 = 'select COUNT(*) as nb from '.MAIN_DB_PREFIX."opensurvey_user_studs where id_sondage='".$db->escape($obj->rowid)."'"; + $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); + } + else dol_print_error($db); $opensurvey_static->id = $obj->rowid; $opensurvey_static->ref = $obj->rowid; - $opensurvey_static->title = $obj->title; + $opensurvey_static->title = $obj->titre; $opensurvey_static->status = $obj->status; $opensurvey_static->date_fin = $db->jdate($obj->date_fin); @@ -375,7 +376,7 @@ if (!$i) $totalarray['nbfield']++; // Title - print ''.dol_htmlentities($obj->title).''; + print ''.dol_htmlentities($obj->titre).''; if (!$i) $totalarray['nbfield']++; // Type @@ -408,10 +409,6 @@ print ''.dol_print_date($db->jdate($obj->date_fin), 'day'); if ($db->jdate($obj->date_fin) < $now && $obj->status == Opensurveysondage::STATUS_VALIDATED) { print img_warning($langs->trans("Expired")); } - print ''; - if (!$i) $totalarray['nbfield']++; - - print ''.dol_print_date($db->jdate($obj->tms), 'dayhour'); print ''; if (!$i) $totalarray['nbfield']++; @@ -428,9 +425,9 @@ print ''; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { - $selected = 0; - if (in_array($obj->rowid, $arrayofselected)) $selected = 1; - print ''; + $selected = 0; + if (in_array($obj->rowid, $arrayofselected)) $selected = 1; + print ''; } print ''; if (!$i) $totalarray['nbfield']++; @@ -465,21 +462,21 @@ if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { - $hidegeneratedfilelistifempty = 1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; - - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; - $formfile = new FormFile($db); - - // Show list of available documents - $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; - $urlsource .= str_replace('&', '&', $param); - - $filedir = $diroutputmassaction; - $genallowed = $permissiontoread; - $delallowed = $permissiontoadd; - - print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); + $hidegeneratedfilelistifempty = 1; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; + + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; + $formfile = new FormFile($db); + + // Show list of available documents + $urlsource = $_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder; + $urlsource .= str_replace('&', '&', $param); + + $filedir = $diroutputmassaction; + $genallowed = $permissiontoread; + $delallowed = $permissiontoadd; + + print $formfile->showdocuments('massfilesarea_mymodule', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); } // End of page --- /tmp/dsg/dolibarr/htdocs/opensurvey/github_results.php +++ /tmp/dsg/dolibarr/htdocs/opensurvey/client_results.php @@ -58,7 +58,7 @@ $nbcolonnes = substr_count($object->sujet, ',') + 1; // Add vote -if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // boutonp for chrome, boutonp.x for firefox +if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // boutonp for chrom, boutonp.x for firefox { if (GETPOST('nom')) { @@ -70,10 +70,12 @@ if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1') { $nouveauchoix .= "1"; - } elseif (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2') + } + elseif (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2') { $nouveauchoix .= "2"; - } else { // sinon c'est 0 + } + else { // sinon c'est 0 $nouveauchoix .= "0"; } } @@ -91,7 +93,9 @@ { setEventMessages($langs->trans("VoteNameAlreadyExists"), null, 'errors'); $error++; - } else { + } + 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); @@ -131,10 +135,12 @@ if (isset($_POST["choix$i"]) && $_POST["choix$i"] == '1') { $nouveauchoix .= "1"; - } elseif (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2') + } + elseif (isset($_POST["choix$i"]) && $_POST["choix$i"] == '2') { $nouveauchoix .= "2"; - } else { // sinon c'est 0 + } + else { // sinon c'est 0 $nouveauchoix .= "0"; } } @@ -158,7 +164,7 @@ //on rajoute la valeur a la fin de tous les sujets deja entrés $nouveauxsujets .= ','; - $nouveauxsujets .= str_replace(array(",", "@"), " ", GETPOST("nouvellecolonne")).(empty($_POST["typecolonne"]) ? '' : '@'.GETPOST("typecolonne")); + $nouveauxsujets .= str_replace(array(",", "@"), " ", $_POST["nouvellecolonne"]).(empty($_POST["typecolonne"]) ? '' : '@'.$_POST["typecolonne"]); //mise a jour avec les nouveaux sujets dans la base $sql = 'UPDATE '.MAIN_DB_PREFIX."opensurvey_sondage"; @@ -186,27 +192,25 @@ if (isset($_POST["nouvelleheuredebut"]) && $_POST["nouvelleheuredebut"] != "vide") { $nouvelledate .= "@"; - $nouvelledate .= GETPOST("nouvelleheuredebut"); + $nouvelledate .= $_POST["nouvelleheuredebut"]; $nouvelledate .= "h"; if ($_POST["nouvelleminutedebut"] != "vide") { - $nouvelledate .= GETPOST("nouvelleminutedebut"); + $nouvelledate .= $_POST["nouvelleminutedebut"]; } } if (isset($_POST["nouvelleheurefin"]) && $_POST["nouvelleheurefin"] != "vide") { $nouvelledate .= "-"; - $nouvelledate .= GETPOST("nouvelleheurefin"); + $nouvelledate .= $_POST["nouvelleheurefin"]; $nouvelledate .= "h"; if ($_POST["nouvelleminutefin"] != "vide") { - $nouvelledate .= GETPOST("nouvelleminutefin"); - } - } - - if (GETPOST("nouvelleheuredebut") == "vide" || (GETPOSTISSET("nouvelleheuredebut") && GETPOSTISSET("nouvelleheurefin") - && (GETPOST("nouvelleheuredebut") < GETPOST("nouvelleheurefin") || (GETPOST("nouvelleheuredebut") == GETPOST("nouvelleheurefin") - && (GETPOST("nouvelleminutedebut") < GETPOST("nouvelleminutefin")))))) { + $nouvelledate .= $_POST["nouvelleminutefin"]; + } + } + + if ($_POST["nouvelleheuredebut"] == "vide" || (isset($_POST["nouvelleheuredebut"]) && isset($_POST["nouvelleheurefin"]) && (($_POST["nouvelleheuredebut"] < $_POST["nouvelleheurefin"]) || (($_POST["nouvelleheuredebut"] == $_POST["nouvelleheurefin"]) && ($_POST["nouvelleminutedebut"] < $_POST["nouvelleminutefin"]))))) { $erreur_ajout_date = false; } else { $erreur_ajout_date = "yes"; @@ -257,7 +261,9 @@ } $adresseadmin = $object->mail_admin; - } else { + } + else + { $erreur_ajout_date = "yes"; } } @@ -395,7 +401,7 @@ exit; } -$title = $object->title." - ".$langs->trans('Card'); +$title = $object->titre." - ".$langs->trans('Card'); $helpurl = ''; $arrayofjs = array(); $arrayofcss = array('/opensurvey/css/style.css'); @@ -419,7 +425,7 @@ $head = opensurvey_prepare_head($object); -print dol_get_fiche_head($head, 'preview', $langs->trans("Survey"), -1, 'poll'); +dol_fiche_head($head, 'preview', $langs->trans("Survey"), -1, 'poll'); $morehtmlref = ''; @@ -443,20 +449,17 @@ print ''; $adresseadmin = $object->mail_admin; print $langs->trans("Title").''; -if ($action == 'edit') { - print ''; -} else { - print dol_htmlentities($object->title); -} +if ($action == 'edit') +{ + print ''; +} +else print dol_htmlentities($object->titre); print ''; // Expire date print ''.$langs->trans('ExpireDate').''; if ($action == 'edit') print $form->selectDate($expiredate ? $expiredate : $object->date_fin, 'expire', 0, 0, 0, '', 1, 0); -else { - print dol_print_date($object->date_fin, 'day'); - if ($object->date_fin && $object->date_fin < dol_now() && $object->status == Opensurveysondage::STATUS_VALIDATED) print img_warning($langs->trans("Expired")); -} +else print dol_print_date($object->date_fin, 'day'); print ''; // Author @@ -496,7 +499,7 @@ print '
'; -print dol_get_fiche_end(); +dol_fiche_end(); print ''."\n"; @@ -532,9 +535,11 @@ print $langs->trans("Type").' '.$form->selectarray("typecolonne", $tmparray, GETPOST('typecolonne')).'

'; print ''; print '     '; - print ''; + print ''; print '

'."\n"; - } else { + } + else + { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; $formother = new FormOther($db); @@ -585,7 +590,7 @@ print '

'; print' '."\n"; print '   '; - print ''; + print ''; } print ''."\n"; @@ -750,7 +755,9 @@ print ''."\n"; } -} else { +} +else +{ // Show titles print ''."\n"; print ''."\n"; @@ -836,7 +843,9 @@ if (((string) $car) == "0") $sumagainst[$i]++; } } - } else { + } + else + { //sinon on remplace les choix de l'utilisateur par une ligne de checkbox pour recuperer de nouvelles valeurs if ($compteur == $ligneamodifier) { @@ -862,7 +871,9 @@ } print ''."\n"; } - } else { + } + else + { for ($i = 0; $i < $nbcolonnes; $i++) { $car = substr($ensemblereponses, $i, 1); @@ -909,13 +920,13 @@ //demande de confirmation pour modification de ligne for ($i = 0; $i < $nblines; $i++) { - if (GETPOSTISSET("modifierligne".$i)) + if (isset($_POST["modifierligne".$i])) { if ($compteur == $i) { print ''; print ''; - print ''; + print ''; print ''."\n"; } } @@ -940,7 +951,7 @@ if (empty($listofanswers[$i]['format']) || !in_array($listofanswers[$i]['format'], array('yesno', 'foragainst'))) { print ''."\n"; + print ''."\n"; print ''."\n"; } @@ -1020,7 +1031,7 @@ } // S'il a oublié de remplir un nom -if (GETPOSTISSET("boutonp") && GETPOST("nom") == "") { +if (isset($_POST["boutonp"]) && $_POST["nom"] == "") { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Name")), null, 'errors'); } @@ -1050,13 +1061,15 @@ if ($object->format == "D") { $meilleursujetexport = $toutsujet[$i]; //var_dump($toutsujet); - if (strpos($toutsujet[$i], '@') !== false) { + if (strpos($toutsujet[$i], '@') !== false) { $toutsujetdate = explode("@", $toutsujet[$i]); $meilleursujet .= dol_print_date($toutsujetdate[0], 'daytext').($toutsujetdate[0] ? ' ('.dol_print_date($toutsujetdate[0], '%A').')' : '').' - '.$toutsujetdate[1]; } else { $meilleursujet .= dol_print_date($toutsujet[$i], 'daytext').($toutsujet[$i] ? ' ('.dol_print_date($toutsujet[$i], '%A').')' : ''); } - } else { + } + else + { $tmps = explode('@', $toutsujet[$i]); $meilleursujet .= dol_htmlentities($tmps[0]); }