';
print '';
// Page
$texthelp = $langs->trans("PageUrlForDefaultValues");
-if ($mode == 'createform') $texthelp .= $langs->trans("PageUrlForDefaultValuesCreate", 'societe/card.php', 'societe/card.php?abc=val1&def=val2');
-else $texthelp .= $langs->trans("PageUrlForDefaultValuesList", 'societe/list.php', 'societe/list.php?abc=val1&def=val2');
+if ($mode == 'createform') {
+ $texthelp .= $langs->trans("PageUrlForDefaultValuesCreate", 'societe/card.php', 'societe/card.php?abc=val1&def=val2');
+} else {
+ $texthelp .= $langs->trans("PageUrlForDefaultValuesList", 'societe/list.php', 'societe/list.php?abc=val1&def=val2');
+}
$texthelp .= ' '.$langs->trans("AlsoDefaultValuesAreEffectiveForActionCreate");
$texturl = $form->textwithpicto($langs->trans("RelativeURL"), $texthelp);
print_liste_field_titre($texturl, $_SERVER["PHP_SELF"], 'page,param', '', $param, '', $sortfield, $sortorder);
// Field
$texthelp = $langs->trans("TheKeyIsTheNameOfHtmlField");
-if ($mode != 'sortorder')
-{
+if ($mode != 'sortorder') {
$textkey = $form->textwithpicto($langs->trans("Field"), $texthelp);
} else {
$texthelp = 'field or alias.field';
@@ -260,15 +275,12 @@ if ($mode != 'sortorder')
}
print_liste_field_titre($textkey, $_SERVER["PHP_SELF"], 'param', '', $param, '', $sortfield, $sortorder);
// Value
-if ($mode != 'focus' && $mode != 'mandatory')
-{
- if ($mode != 'sortorder')
- {
+if ($mode != 'focus' && $mode != 'mandatory') {
+ if ($mode != 'sortorder') {
$substitutionarray = getCommonSubstitutionArray($langs, 2, array('object', 'objectamount')); // Must match list into GETPOST
unset($substitutionarray['__USER_SIGNATURE__']);
$texthelp = $langs->trans("FollowingConstantsWillBeSubstituted").' ';
- foreach ($substitutionarray as $key => $val)
- {
+ foreach ($substitutionarray as $key => $val) {
$texthelp .= $key.' -> '.$val.' ';
}
$textvalue = $form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, 'subsitutiontooltip');
@@ -279,8 +291,11 @@ if ($mode != 'focus' && $mode != 'mandatory')
print_liste_field_titre($textvalue, $_SERVER["PHP_SELF"], 'value', '', $param, '', $sortfield, $sortorder);
}
// Entity
-if (!empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,page', '', $param, '', $sortfield, $sortorder);
-else print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
+if (!empty($conf->multicompany->enabled) && !$user->entity) {
+ print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,page', '', $param, '', $sortfield, $sortorder);
+} else {
+ print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
+}
// Actions
print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
print " \n";
@@ -299,15 +314,13 @@ print '';
print ' ';
print ' ';
// Value
-if ($mode != 'focus' && $mode != 'mandatory')
-{
+if ($mode != 'focus' && $mode != 'mandatory') {
print '';
print ' ';
print ' ';
}
// Limit to superadmin
-if (!empty($conf->multicompany->enabled) && !$user->entity)
-{
+if (!empty($conf->multicompany->enabled) && !$user->entity) {
print '';
print ' '; // We see environment, but to change it we must switch on other entity
print ' ';
@@ -318,7 +331,9 @@ if (!empty($conf->multicompany->enabled) && !$user->entity)
}
print '';
$disabled = '';
-if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) $disabled = ' disabled="disabled"';
+if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) {
+ $disabled = ' disabled="disabled"';
+}
print ' ';
print " \n";
print '';
@@ -333,13 +348,11 @@ $sql .= $db->order($sortfield, $sortorder);
dol_syslog("translation::select from table", LOG_DEBUG);
$result = $db->query($sql);
-if ($result)
-{
+if ($result) {
$num = $db->num_rows($result);
$i = 0;
- while ($i < $num)
- {
+ while ($i < $num) {
$obj = $db->fetch_object($result);
print "\n";
@@ -348,27 +361,35 @@ if ($result)
// Page
print '';
- if ($action != 'edit' || GETPOST('rowid', 'int') != $obj->rowid) print $obj->page;
- else print ' ';
+ if ($action != 'edit' || GETPOST('rowid', 'int') != $obj->rowid) {
+ print $obj->page;
+ } else {
+ print ' ';
+ }
print ' '."\n";
// Field
print '';
- if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print $obj->param;
- else print ' ';
+ if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) {
+ print $obj->param;
+ } else {
+ print ' ';
+ }
print ' '."\n";
// Value
- if ($mode != 'focus' && $mode != 'mandatory')
- {
+ if ($mode != 'focus' && $mode != 'mandatory') {
print '';
/*print ' ';
- print ' ';
- print ' ';
- print ' ';
- */
- if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print dol_escape_htmltag($obj->value);
- else print ' ';
+ print ' ';
+ print ' ';
+ print ' ';
+ */
+ if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) {
+ print dol_escape_htmltag($obj->value);
+ } else {
+ print ' ';
+ }
print ' ';
}
@@ -376,8 +397,7 @@ if ($result)
// Actions
print '';
- if ($action != 'edit' || GETPOST('rowid') != $obj->rowid)
- {
+ if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) {
print ''.img_edit().' ';
print ''.img_delete().' ';
} else {
diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php
index 90ea5f290b6..6c0cd230cc9 100644
--- a/htdocs/admin/delais.php
+++ b/htdocs/admin/delais.php
@@ -30,134 +30,138 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
// Load translation files required by the page
$langs->load("admin");
-if (!$user->admin) accessforbidden();
+if (!$user->admin) {
+ accessforbidden();
+}
$action = GETPOST('action', 'aZ09');
-if (empty($action)) $action = 'edit';
+if (empty($action)) {
+ $action = 'edit';
+}
// Define list of managed delays
$modules = array(
- 'agenda' => array(
- array(
- 'code' => 'MAIN_DELAY_ACTIONS_TODO',
- 'img' => 'action'
- )
- ),
- 'projet' => array(
- array(
- 'code' => 'MAIN_DELAY_PROJECT_TO_CLOSE',
- 'img' => 'project'
- ),
- array(
- 'code' => 'MAIN_DELAY_TASKS_TODO',
- 'img' => 'projecttask'
- )
- ),
- 'propal' => array(
- array(
- 'code' => 'MAIN_DELAY_PROPALS_TO_CLOSE',
- 'img' => 'propal'
- ),
- array(
- 'code' => 'MAIN_DELAY_PROPALS_TO_BILL',
- 'img' => 'propal'
- )
- ),
- 'commande' => array(
- array(
- 'code' => 'MAIN_DELAY_ORDERS_TO_PROCESS',
- 'img' => 'order'
- )
- ),
- 'facture' => array(
- array(
- 'code' => 'MAIN_DELAY_CUSTOMER_BILLS_UNPAYED',
- 'img' => 'bill'
- )
- ),
- 'fournisseur' => array(
- array(
- 'code' => 'MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS',
- 'img' => 'order'
- ),
- array(
- 'code' => 'MAIN_DELAY_SUPPLIER_BILLS_TO_PAY',
- 'img' => 'bill'
- )
- ),
- 'service' => array(
- array(
- 'code' => 'MAIN_DELAY_NOT_ACTIVATED_SERVICES',
- 'img' => 'service'
- ),
- array(
- 'code' => 'MAIN_DELAY_RUNNING_SERVICES',
- 'img' => 'service'
- )
- ),
- 'banque' => array(
- array(
- 'code' => 'MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE',
- 'img' => 'account'
- ),
- array(
- 'code' => 'MAIN_DELAY_CHEQUES_TO_DEPOSIT',
- 'img' => 'account'
- )
- ),
- 'adherent' => array(
- array(
- 'code' => 'MAIN_DELAY_MEMBERS',
- 'img' => 'user'
- )
- ),
- 'expensereport' => array(
- array(
- 'code' => 'MAIN_DELAY_EXPENSEREPORTS',
- 'img' => 'trip'
- ),
- /* TODO Enable this
- array(
- 'code' => 'MAIN_DELAY_EXPENSEREPORTS_TO_PAY',
- 'img' => 'trip'
- )*/
- ),
- 'holiday' => array(
- array(
- 'code' => 'MAIN_DELAY_HOLIDAYS',
- 'img' => 'holiday'
- ),
- ),
+ 'agenda' => array(
+ array(
+ 'code' => 'MAIN_DELAY_ACTIONS_TODO',
+ 'img' => 'action'
+ )
+ ),
+ 'projet' => array(
+ array(
+ 'code' => 'MAIN_DELAY_PROJECT_TO_CLOSE',
+ 'img' => 'project'
+ ),
+ array(
+ 'code' => 'MAIN_DELAY_TASKS_TODO',
+ 'img' => 'projecttask'
+ )
+ ),
+ 'propal' => array(
+ array(
+ 'code' => 'MAIN_DELAY_PROPALS_TO_CLOSE',
+ 'img' => 'propal'
+ ),
+ array(
+ 'code' => 'MAIN_DELAY_PROPALS_TO_BILL',
+ 'img' => 'propal'
+ )
+ ),
+ 'commande' => array(
+ array(
+ 'code' => 'MAIN_DELAY_ORDERS_TO_PROCESS',
+ 'img' => 'order'
+ )
+ ),
+ 'facture' => array(
+ array(
+ 'code' => 'MAIN_DELAY_CUSTOMER_BILLS_UNPAYED',
+ 'img' => 'bill'
+ )
+ ),
+ 'fournisseur' => array(
+ array(
+ 'code' => 'MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS',
+ 'img' => 'order'
+ ),
+ array(
+ 'code' => 'MAIN_DELAY_SUPPLIER_BILLS_TO_PAY',
+ 'img' => 'bill'
+ )
+ ),
+ 'service' => array(
+ array(
+ 'code' => 'MAIN_DELAY_NOT_ACTIVATED_SERVICES',
+ 'img' => 'service'
+ ),
+ array(
+ 'code' => 'MAIN_DELAY_RUNNING_SERVICES',
+ 'img' => 'service'
+ )
+ ),
+ 'banque' => array(
+ array(
+ 'code' => 'MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE',
+ 'img' => 'account'
+ ),
+ array(
+ 'code' => 'MAIN_DELAY_CHEQUES_TO_DEPOSIT',
+ 'img' => 'account'
+ )
+ ),
+ 'adherent' => array(
+ array(
+ 'code' => 'MAIN_DELAY_MEMBERS',
+ 'img' => 'user'
+ )
+ ),
+ 'expensereport' => array(
+ array(
+ 'code' => 'MAIN_DELAY_EXPENSEREPORTS',
+ 'img' => 'trip'
+ ),
+ /* TODO Enable this
+ array(
+ 'code' => 'MAIN_DELAY_EXPENSEREPORTS_TO_PAY',
+ 'img' => 'trip'
+ )*/
+ ),
+ 'holiday' => array(
+ array(
+ 'code' => 'MAIN_DELAY_HOLIDAYS',
+ 'img' => 'holiday'
+ ),
+ ),
);
$labelmeteo = array(0=>$langs->trans("No"), 1=>$langs->trans("Yes"), 2=>$langs->trans("OnMobileOnly"));
if (!isset($conf->global->MAIN_DELAY_PROJECT_TO_CLOSE)) {
- $conf->global->MAIN_DELAY_PROJECT_TO_CLOSE = 7; // Must be same value than into conf.class.php
+ $conf->global->MAIN_DELAY_PROJECT_TO_CLOSE = 7; // Must be same value than into conf.class.php
}
if (!isset($conf->global->MAIN_DELAY_TASKS_TODO)) {
- $conf->global->MAIN_DELAY_TASKS_TODO = 7; // Must be same value than into conf.class.php
+ $conf->global->MAIN_DELAY_TASKS_TODO = 7; // Must be same value than into conf.class.php
}
if (!isset($conf->global->MAIN_DELAY_MEMBERS)) {
- $conf->global->MAIN_DELAY_MEMBERS = 0; // Must be same value than into conf.class.php
+ $conf->global->MAIN_DELAY_MEMBERS = 0; // Must be same value than into conf.class.php
}
if (!isset($conf->global->MAIN_DELAY_ACTIONS_TODO)) {
- $conf->global->MAIN_DELAY_ACTIONS_TODO = 7; // Must be same value than into conf.class.php
+ $conf->global->MAIN_DELAY_ACTIONS_TODO = 7; // Must be same value than into conf.class.php
}
if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
- $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
+ $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
}
if (!isset($conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS)) {
- $conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS = 7;
+ $conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS = 7;
}
if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
- $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
+ $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
}
if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
- $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
+ $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
}
if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
- $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
+ $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2;
}
@@ -166,32 +170,31 @@ if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) {
* Actions
*/
-if ($action == 'update')
-{
- foreach ($modules as $module => $delays)
- {
- if (!empty($conf->$module->enabled))
- {
- foreach ($delays as $delay)
- {
- if (GETPOST($delay['code']) != '')
- {
- dolibarr_set_const($db, $delay['code'], GETPOST($delay['code']), 'chaine', 0, '', $conf->entity);
- }
- }
- }
- }
+if ($action == 'update') {
+ foreach ($modules as $module => $delays) {
+ if (!empty($conf->$module->enabled)) {
+ foreach ($delays as $delay) {
+ if (GETPOST($delay['code']) != '') {
+ dolibarr_set_const($db, $delay['code'], GETPOST($delay['code']), 'chaine', 0, '', $conf->entity);
+ }
+ }
+ }
+ }
- dolibarr_set_const($db, "MAIN_DISABLE_METEO", $_POST["MAIN_DISABLE_METEO"], 'chaine', 0, '', $conf->entity);
- dolibarr_set_const($db, "MAIN_USE_METEO_WITH_PERCENTAGE", GETPOST("MAIN_USE_METEO_WITH_PERCENTAGE"), 'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, "MAIN_DISABLE_METEO", $_POST["MAIN_DISABLE_METEO"], 'chaine', 0, '', $conf->entity);
+ dolibarr_set_const($db, "MAIN_USE_METEO_WITH_PERCENTAGE", GETPOST("MAIN_USE_METEO_WITH_PERCENTAGE"), 'chaine', 0, '', $conf->entity);
- // For update value with percentage
- $plus = '';
- if (!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $plus = '_PERCENTAGE';
- // Update values
- for ($i = 0; $i < 4; $i++) {
- if (GETPOSTISSET('MAIN_METEO'.$plus.'_LEVEL'.$i)) dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'), 'chaine', 0, '', $conf->entity);
- }
+ // For update value with percentage
+ $plus = '';
+ if (!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) {
+ $plus = '_PERCENTAGE';
+ }
+ // Update values
+ for ($i = 0; $i < 4; $i++) {
+ if (GETPOSTISSET('MAIN_METEO'.$plus.'_LEVEL'.$i)) {
+ dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'), 'chaine', 0, '', $conf->entity);
+ }
+ }
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
@@ -213,158 +216,165 @@ print ''.$langs->transnoentities("DelaysOfToleranceD
print " ".$langs->trans("OnlyActiveElementsAreShown", DOL_URL_ROOT.'/admin/modules.php')." \n";
print " \n";
-if ($action == 'edit')
-{
- print ' ';
- print '';
- print img_weather($text, 1, $options);
- print ' <= ';
- print '
';
- print img_weather($text, 2, $options);
- print ' <= ';
- print '
';
- print img_weather($text, 3, $options);
- print ' <= ';
- print '
';
- print '';
+ print '';
- print '';
+ print '';
- print 'global->MAIN_USE_METEO_WITH_PERCENTAGE) ? 'style="display:none;"' : '').'>';
+ print '
global->MAIN_USE_METEO_WITH_PERCENTAGE) ? 'style="display:none;"' : '').'>';
- print '
';
+ print '
';
- print '
';
+ print '
';
- ?>
+ ?>
'."\n";
@@ -545,8 +545,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print ' ';
print '';
// List filters
- foreach ($object->filters as $rulefilter)
- {
+ foreach ($object->filters as $rulefilter) {
$rulefilterobj = new EmailCollectorFilter($db);
$rulefilterobj->fetch($rulefilter['id']);
@@ -580,9 +579,15 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
'loadthirdparty'=>$langs->trans('LoadThirdPartyFromName', $langs->transnoentities("ThirdPartyName")),
'loadandcreatethirdparty'=>$langs->trans('LoadThirdPartyFromNameOrCreate', $langs->transnoentities("ThirdPartyName")),
'recordevent'=>'RecordEvent');
- if ($conf->projet->enabled) $arrayoftypes['project'] = 'CreateLeadAndThirdParty';
- if ($conf->ticket->enabled) $arrayoftypes['ticket'] = 'CreateTicketAndThirdParty';
- if ($conf->recruitment->enabled) $arrayoftypes['candidature'] = 'CreateCandidature';
+ if ($conf->projet->enabled) {
+ $arrayoftypes['project'] = 'CreateLeadAndThirdParty';
+ }
+ if ($conf->ticket->enabled) {
+ $arrayoftypes['ticket'] = 'CreateTicketAndThirdParty';
+ }
+ if ($conf->recruitment->enabled) {
+ $arrayoftypes['candidature'] = 'CreateCandidature';
+ }
// support hook for add action
$parameters = array('arrayoftypes' => $arrayoftypes);
@@ -591,7 +596,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
if ($res) {
$arrayoftypes = $hookmanager->resArray;
} else {
- foreach ($hookmanager->resArray as $k=>$desc) {
+ foreach ($hookmanager->resArray as $k => $desc) {
$arrayoftypes[$k] = $desc;
}
}
@@ -611,8 +616,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
$table_element_line = 'emailcollector_emailcollectoraction';
$fk_element = 'position';
$i = 0;
- foreach ($object->actions as $ruleaction)
- {
+ foreach ($object->actions as $ruleaction) {
$ruleactionobj = new EmailcollectorAction($db);
$ruleactionobj->fetch($ruleaction['id']);
@@ -620,16 +624,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '';
print '';
print $langs->trans($arrayoftypes[$ruleaction['type']]);
- if (in_array($ruleaction['type'], array('recordevent')))
- {
+ if (in_array($ruleaction['type'], array('recordevent'))) {
print $form->textwithpicto('', $langs->transnoentitiesnoconv('IfTrackingIDFoundEventWillBeLinked'));
} elseif (in_array($ruleaction['type'], array('loadthirdparty', 'loadandcreatethirdparty'))) {
print $form->textwithpicto('', $langs->transnoentitiesnoconv('EmailCollectorLoadThirdPartyHelp'));
}
print ' ';
print '';
- if ($action == 'editoperation' && $ruleaction['id'] == $operationid)
- {
+ if ($action == 'editoperation' && $ruleaction['id'] == $operationid) {
print ' ';
print ' ';
print ' ';
@@ -640,8 +642,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print ' ';
// Move up/down
print '';
- if ($i > 0)
- {
+ if ($i > 0) {
print ''.img_up('default', 0, 'imgupforline').' ';
}
if ($i < count($object->actions) - 1) {
@@ -681,10 +682,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print ''."\n";
$parameters = array();
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
- if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+ if ($reshook < 0) {
+ setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+ }
- if (empty($reshook))
- {
+ if (empty($reshook)) {
// Edit
print '
';
@@ -703,8 +705,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
print '
'."\n";
}
- if (!empty($debuginfo))
- {
+ if (!empty($debuginfo)) {
print info_admin($debuginfo);
}
}
diff --git a/htdocs/admin/emailcollector_list.php b/htdocs/admin/emailcollector_list.php
index e85a9652075..09a790a9f68 100644
--- a/htdocs/admin/emailcollector_list.php
+++ b/htdocs/admin/emailcollector_list.php
@@ -51,7 +51,9 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
-if (empty($page) || $page < 0 || 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
+if (empty($page) || $page < 0 || 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;
@@ -70,13 +72,16 @@ $extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
// Default sort order (if not yet defined by previous GETPOST)
-if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
-if (!$sortorder) $sortorder = "ASC";
+if (!$sortfield) {
+ $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition.
+}
+if (!$sortorder) {
+ $sortorder = "ASC";
+}
// Security check
$socid = 0;
-if ($user->socid > 0) // Protection if external user
-{
+if ($user->socid > 0) { // Protection if external user
//$socid = $user->socid;
accessforbidden();
}
@@ -85,22 +90,23 @@ if ($user->socid > 0) // Protection if external user
// Initialize array of search criterias
$search_all = GETPOST("search_all", 'alphanohtml');
$search = array();
-foreach ($object->fields as $key => $val)
-{
- if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha');
+foreach ($object->fields as $key => $val) {
+ if (GETPOST('search_'.$key, 'alpha') !== '') {
+ $search[$key] = GETPOST('search_'.$key, 'alpha');
+ }
}
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array();
-foreach ($object->fields as $key => $val)
-{
- if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label'];
+foreach ($object->fields as $key => $val) {
+ if ($val['searchall']) {
+ $fieldstosearchall['t.'.$key] = $val['label'];
+ }
}
// Definition of array of fields for columns
$arrayfields = array();
-foreach ($object->fields as $key => $val)
-{
+foreach ($object->fields as $key => $val) {
// If $val['visible']==0, then we never show the field
if (!empty($val['visible'])) {
$visible = dol_eval($val['visible'], 1);
@@ -113,10 +119,8 @@ foreach ($object->fields as $key => $val)
}
}
// 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 (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],
@@ -138,8 +142,12 @@ $permissiontoread = $user->admin;
$permissiontoadd = $user->admin;
$permissiontodelete = $user->admin;
-if (!$user->admin) accessforbidden();
-if (empty($conf->emailcollector->enabled)) accessforbidden('Module not enabled');
+if (!$user->admin) {
+ accessforbidden();
+}
+if (empty($conf->emailcollector->enabled)) {
+ accessforbidden('Module not enabled');
+}
@@ -147,31 +155,33 @@ if (empty($conf->emailcollector->enabled)) accessforbidden('Module not enabled')
* Actions
*/
-if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
-if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
+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 ($reshook < 0) {
+ setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+}
-if (empty($reshook))
-{
+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
- {
- foreach ($object->fields as $key => $val)
- {
+ 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
+ foreach ($object->fields as $key => $val) {
$search[$key] = '';
}
$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'))
- {
+ || 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
}
@@ -197,13 +207,14 @@ $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("EmailCollector")
// Build and execute select
// --------------------------------------------------------------------
$sql = 'SELECT ';
-foreach ($object->fields as $key => $val)
-{
+foreach ($object->fields as $key => $val) {
$sql .= 't.'.$key.', ';
}
// Add fields from extrafields
if (!empty($extrafields->attributes[$object->table_element]['label'])) {
- foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
+ foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
+ $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : '');
+ }
}
// Add fields from hooks
$parameters = array();
@@ -211,20 +222,32 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje
$sql .= preg_replace('/^,/', '', $hookmanager->resPrint);
$sql = preg_replace('/,\s*$/', '', $sql);
$sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t";
-if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
-if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
-else $sql .= " WHERE 1 = 1";
-foreach ($search as $key => $val)
-{
- if ($key == 'status' && $search[$key] == -1) continue;
+if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)";
+}
+if ($object->ismultientitymanaged == 1) {
+ $sql .= " WHERE t.entity IN (".getEntity($object->element).")";
+} else {
+ $sql .= " WHERE 1 = 1";
+}
+foreach ($search as $key => $val) {
+ if ($key == 'status' && $search[$key] == -1) {
+ continue;
+ }
$mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
if (strpos($object->fields[$key]['type'], 'integer:') === 0) {
- if ($search[$key] == '-1') $search[$key] = '';
+ if ($search[$key] == '-1') {
+ $search[$key] = '';
+ }
$mode_search = 2;
}
- if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
+ if ($search[$key] != '') {
+ $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search));
+ }
+}
+if ($search_all) {
+ $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
}
-if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
// Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
// Add where from hooks
@@ -253,26 +276,24 @@ $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
$nbtotalofrecords = '';
-if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
-{
+if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$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
- {
+ 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 || empty($limit)))
-{
+if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
$num = $nbtotalofrecords;
} else {
- if ($limit) $sql .= $db->plimit($limit + 1, $offset);
+ if ($limit) {
+ $sql .= $db->plimit($limit + 1, $offset);
+ }
$resql = $db->query($sql);
- if (!$resql)
- {
+ if (!$resql) {
dol_print_error($db);
exit;
}
@@ -281,8 +302,7 @@ if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit
}
// Direct jump if only one record found
-if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page)
-{
+if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) {
$obj = $db->fetch_object($resql);
$id = $obj->rowid;
header("Location: ".DOL_URL_ROOT.'/emailcollector/emailcollector_card.php?id='.$id);
@@ -313,14 +333,24 @@ jQuery(document).ready(function() {
$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);
-foreach ($search as $key => $val)
-{
- if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey);
- else $param .= '&search_'.$key.'='.urlencode($search[$key]);
+if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
+ $param .= '&contextpage='.urlencode($contextpage);
+}
+if ($limit > 0 && $limit != $conf->liste_limit) {
+ $param .= '&limit='.urlencode($limit);
+}
+foreach ($search as $key => $val) {
+ if (is_array($search[$key]) && count($search[$key])) {
+ foreach ($search[$key] as $skey) {
+ $param .= '&search_'.$key.'[]='.urlencode($skey);
+ }
+ } else {
+ $param .= '&search_'.$key.'='.urlencode($search[$key]);
+ }
+}
+if ($optioncss != '') {
+ $param .= '&optioncss='.urlencode($optioncss);
}
-if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
@@ -329,12 +359,18 @@ $arrayofmassactions = array(
//'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();
+if ($permissiontodelete) {
+ $arrayofmassactions['predelete'] = ' '.$langs->trans("Delete");
+}
+if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
+ $arrayofmassactions = array();
+}
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
print '