diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php
index 23c2614eb0f..7c33b5ee8eb 100644
--- a/htdocs/modulebuilder/template/myobject_list.php
+++ b/htdocs/modulebuilder/template/myobject_list.php
@@ -352,6 +352,12 @@ $newcardbutton='';
$newcardbutton.= '';
$newcardbutton.= '';
//}
+//else
+//{
+// $newcardbutton=''.$langs->trans('New');
+// $newcardbutton.= '';
+// $newcardbutton.= '';
+//}
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies', 0, $newcardbutton, '', $limit);
diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php
index 2e6789b3f89..807d550e35c 100644
--- a/htdocs/opensurvey/class/opensurveysondage.class.php
+++ b/htdocs/opensurvey/class/opensurveysondage.class.php
@@ -138,7 +138,6 @@ class Opensurveysondage extends CommonObject
// Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."opensurvey_sondage(";
-
$sql.= "id_sondage,";
$sql.= "commentaires,";
$sql.= "fk_user_creat,";
@@ -151,7 +150,6 @@ class Opensurveysondage extends CommonObject
$sql.= "allow_spy,";
$sql.= "sujet";
$sql.= ") VALUES (";
-
$sql.= "'".$this->db->escape($this->id_sondage)."',";
$sql.= " ".(empty($this->commentaires)?'NULL':"'".$this->db->escape($this->commentaires)."'").",";
$sql.= " ".$user->id.",";
@@ -163,7 +161,6 @@ class Opensurveysondage extends CommonObject
$sql.= " ".$this->db->escape($this->allow_comments).",";
$sql.= " ".$this->db->escape($this->allow_spy).",";
$sql.= " '".$this->db->escape($this->sujet)."'";
-
$sql.= ")";
$this->db->begin();
@@ -229,7 +226,7 @@ class Opensurveysondage extends CommonObject
$sql.= " t.sujet,";
$sql.= " t.tms";
$sql.= " FROM ".MAIN_DB_PREFIX."opensurvey_sondage as t";
- $sql.= " WHERE t.id_sondage = '".$this->db->escape($numsurvey)."'";
+ $sql.= " WHERE t.id_sondage = '".$this->db->escape($id ? $id : $numsurvey)."'";
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql=$this->db->query($sql);
@@ -359,11 +356,16 @@ class Opensurveysondage extends CommonObject
* @param string $numsondage Num sondage admin to delete
* @return int <0 if KO, >0 if OK
*/
- function delete(User $user, $notrigger, $numsondage)
+ function delete(User $user, $notrigger=0, $numsondage='')
{
global $conf, $langs;
$error=0;
+ if (empty($numsondage))
+ {
+ $numsondage = $this->id_sondage;
+ }
+
$this->db->begin();
if (! $error)
diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php
index ecb26047e52..cf52d83c680 100644
--- a/htdocs/opensurvey/list.php
+++ b/htdocs/opensurvey/list.php
@@ -27,8 +27,8 @@ 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";
-// Security check
-if (!$user->rights->opensurvey->read) accessforbidden();
+// Load translation files required by the page
+$langs->load("opensurvey");
$action = GETPOST('action','aZ09')?GETPOST('action','aZ09'):'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
$massaction = GETPOST('massaction','alpha'); // The bulk action (combo box choice into lists)
@@ -41,7 +41,6 @@ $backtopage = GETPOST('backtopage','alpha'); // Go back to a dedicated
$optioncss = GETPOST('optioncss','aZ'); // Option for the css output (always '' except when 'print')
$id=GETPOST('id','alpha');
-$numsondage= $id;
$search_ref = GETPOST('search_ref', 'alpha');
$search_title = GETPOST('search_title', 'alpha');
$search_status = GETPOST('search_status', 'alpha');
@@ -51,26 +50,87 @@ $limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
$sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST('sortorder','alpha');
$page = GETPOST('page','int');
-if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
+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;
$pageprev = $page - 1;
$pagenext = $page + 1;
+
+// Initialize technical objects
+$object = new Opensurveysondage($db);
+$opensurvey_static = new Opensurveysondage($db);
+
+$extrafields = new ExtraFields($db);
+$diroutputmassaction = $conf->opensurvey->dir_output . '/temp/massgeneration/'.$user->id;
+$hookmanager->initHooks(array('surveylist')); // Note that conf->hooks_modules contains array
+// Fetch optionals attributes and labels
+$extralabels = $extrafields->fetch_name_optionals_label('survey'); // Load $extrafields->attributes['myobject']
+$search_array_options = $extrafields->getOptionalsFromPost($object->table_element,'','search_');
+
+// Default sort order (if not yet defined by previous GETPOST)
if (! $sortfield) $sortfield="p.date_fin";
if (! $sortorder) $sortorder="DESC";
-// Load translation files required by the page
-$langs->load("opensurvey");
+// Security check
+if (!$user->rights->opensurvey->read) accessforbidden();
+
+// Definition of fields for list
+$arrayfields=array();
+foreach($object->fields 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']);
+}
+// 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]))
+ $arrayfields["ef.".$key]=array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key]<0)?0:1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], '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');
/*
* Actions
*/
-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
+if (GETPOST('cancel','alpha')) { $action='list'; $massaction=''; }
+if (! GETPOST('confirmmassaction','alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction=''; }
+
+$parameters=array();
+$reshook=$hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+
+if (empty($reshook))
{
- $search_status='';
- $search_title='';
- $search_ref='';
+ // 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';
+ $permtoread = $user->rights->opensurvey->read;
+ $permtodelete = $user->rights->opensurvey->write;
+ $uploaddir = $conf->opensurvey->dir_output;
+ include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
}
@@ -79,40 +139,15 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x',
*/
$form=new Form($db);
-$opensurvey_static = new Opensurveysondage($db);
$now = dol_now();
-llxHeader('', $langs->trans("OpenSurveyArea"));
-
-$param='';
-$fieldtosortuser=empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?'firstname':'lastname';
+//$help_url="EN:Module_MyObject|FR:Module_MyObject_FR|ES:Módulo_MyObject";
+$help_url='';
+$title = $langs->trans('OpenSurveyArea');
-
-
-
-
-
-
-
-
-$newcardbutton='';
-if (!$user->rights->opensurvey->creer)
-{
- $newcardbutton=''.$langs->trans('NewSurvey').'';
- $newcardbutton.= '';
- $newcardbutton.= '';
-}
-else
-{
- $newcardbutton=''.$langs->trans('NewSurvey');
- $newcardbutton.= '';
- $newcardbutton.= '';
-}
-
-
-$sql = "SELECT p.id_sondage, p.fk_user_creat, p.format, p.date_fin, p.status, p.titre, p.nom_admin,";
+$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";
@@ -122,44 +157,124 @@ if ($search_expired == 'expired') $sql.=" AND p.date_fin < '".$db->idate($now)."
if ($search_expired == 'opened') $sql.=" AND p.date_fin >= '".$db->idate($now)."'";
if ($search_ref) $sql.=natural_search("p.id_sondage", $search_ref);
if ($search_title) $sql.=natural_search("p.titre", $search_title);
-$sql.= $db->order($sortfield,$sortorder);
+// Add where from extra fields
+include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
+// Add where from hooks
+$parameters=array();
+$reshook=$hookmanager->executeHooks('printFieldListWhere', $parameters, $object); // Note that $action and $object may have been modified by hook
+$sql.=$hookmanager->resPrint;
+
+$sql.=$db->order($sortfield,$sortorder);
// Count total nb of records
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
- $result = $db->query($sql);
- $nbtotalofrecords = $db->num_rows($result);
- if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
+ $resql = $db->query($sql);
+ $nbtotalofrecords = $db->num_rows($resql);
+ if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0
{
$page = 0;
$offset = 0;
}
}
+// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
+if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords)
+{
+ $num = $nbtotalofrecords;
+}
+else
+{
+ $sql.= $db->plimit($limit+1, $offset);
-$sql.= $db->plimit($limit+1, $offset);
+ $resql=$db->query($sql);
+ if (! $resql)
+ {
+ dol_print_error($db);
+ exit;
+ }
-$resql=$db->query($sql);
-if (! $resql) dol_print_error($db);
+ $num = $db->num_rows($resql);
+}
-$num=$db->num_rows($resql);
+// Direct jump if only one record found
+if ($num == 1 && ! empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all)
+{
+ $obj = $db->fetch_object($resql);
+ $id = $obj->rowid;
+ header("Location: ".dol_buildpath('/opensurvey/card.php', 1).'?id='.$id);
+ exit;
+}
+llxHeader('', $title, $help_url);
+$arrayofselected=is_array($toselect)?$toselect:array();
+
+$param='';
+if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage);
+if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit);
+$fieldtosortuser=empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION)?'firstname':'lastname';
+
+if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss);
+// Add $param from extra fields
+include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
+
+// List of mass actions available
+$arrayofmassactions = array(
+ //'presend'=>$langs->trans("SendByMail"),
+ //'builddoc'=>$langs->trans("PDFMerge"),
+);
+if ($user->rights->opensurvey->write) $arrayofmassactions['predelete']=$langs->trans("Delete");
+if (GETPOST('nomassaction','int') || in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
+$massactionbutton=$form->selectMassAction('', $arrayofmassactions);
// List of surveys into database
-print '
';
+print ''."\n";
+
+print ''."\n";
+
+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=$user->rights->mymodule->read;
+ $delallowed=$user->rights->mymodule->create;
+
+ print $formfile->showdocuments('massfilesarea_mymodule','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'','','',null,$hidegeneratedfilelistifempty);
+}
// End of page
llxFooter();
diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php
index dac7f9ea126..c5e4c8648d7 100644
--- a/htdocs/societe/admin/societe.php
+++ b/htdocs/societe/admin/societe.php
@@ -29,7 +29,7 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
-$langs->loadLangs(array("admin", "other"));
+$langs->loadLangs(array("admin", "companies", "other"));
$action=GETPOST('action','alpha');
$value=GETPOST('value','alpha');
@@ -332,6 +332,7 @@ $dirsociete=array_merge(array('/core/modules/societe/'),$conf->modules_parts['so
print load_fiche_titre($langs->trans("CompanyCodeChecker"),'','');
+print '';
print '
'."\n";
print ''."\n";
print ' | '.$langs->trans("Name").' | ';
@@ -403,7 +404,7 @@ foreach ($dirsociete as $dirroot)
}
}
print '
';
-
+print '
';
print "
";
@@ -412,6 +413,7 @@ print "
";
print load_fiche_titre($langs->trans("AccountCodeManager"),'','');
+print '';
print '
';
print '';
print '| '.$langs->trans("Name").' | ';
@@ -473,6 +475,7 @@ foreach ($dirsociete as $dirroot)
}
}
print "
\n";
+print '
';
/*
@@ -504,6 +507,7 @@ else
dol_print_error($db);
}
+print '';
print '
';
print '';
print '| '.$langs->trans("Name").' | ';
@@ -619,12 +623,14 @@ foreach ($dirsociete as $dirroot)
}
}
print '
';
+print '
';
print '
';
//IDProf
print load_fiche_titre($langs->trans("CompanyIdProfChecker"),'','');
+print '';
print '
';
print '';
print '| '.$langs->trans("Name").' | ';
@@ -711,8 +717,10 @@ foreach($profid as $key => $val)
$i++;
}
-print "
\n";
+print "\n";
+print '
';
+print "
\n";
print load_fiche_titre($langs->trans("Other"),'','');
@@ -723,6 +731,7 @@ print '';