';
print '
'; // ancre
diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php
index f4823ae9b6f..984dde7389b 100644
--- a/htdocs/asset/class/asset.class.php
+++ b/htdocs/asset/class/asset.class.php
@@ -170,8 +170,12 @@ class Asset extends CommonObject
$this->db = $db;
- if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) $this->fields['rowid']['visible'] = 0;
- if (empty($conf->multicompany->enabled)) $this->fields['entity']['enabled'] = 0;
+ if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID)) {
+ $this->fields['rowid']['visible'] = 0;
+ }
+ if (empty($conf->multicompany->enabled)) {
+ $this->fields['entity']['enabled'] = 0;
+ }
}
/**
@@ -304,7 +308,9 @@ class Asset extends CommonObject
global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager;
- if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
+ if (!empty($conf->dol_no_mouse_hover)) {
+ $notooltip = 1; // Force disable tooltips
+ }
$result = '';
$companylink = '';
@@ -315,33 +321,40 @@ class Asset extends CommonObject
$url = dol_buildpath('/asset/card.php', 1).'?id='.$this->id;
- if ($option != 'nolink')
- {
+ if ($option != 'nolink') {
// Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
- if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
- if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
+ if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ $add_save_lastsearch_values = 1;
+ }
+ if ($add_save_lastsearch_values) {
+ $url .= '&save_lastsearch_values=1';
+ }
}
$linkclose = '';
- if (empty($notooltip))
- {
- if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
- {
+ if (empty($notooltip)) {
+ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$label = $langs->trans("ShowAssets");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
$linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
- } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
+ } else {
+ $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
+ }
$linkstart = '
';
$linkend = '';
$result .= $linkstart;
- if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
- if ($withpicto != 2) $result .= $this->ref;
+ if ($withpicto) {
+ $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
+ }
+ if ($withpicto != 2) {
+ $result .= $this->ref;
+ }
$result .= $linkend;
//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
@@ -381,7 +394,9 @@ class Asset extends CommonObject
$labelStatusShort[self::STATUS_VALIDATED] = $langs->trans('Enabled');
$statusType = 'status0';
- if ($status == self::STATUS_VALIDATED) $statusType = 'status4';
+ if ($status == self::STATUS_VALIDATED) {
+ $statusType = 'status4';
+ }
return dolGetStatus($labelStatus[$status], $labelStatusShort[$status], '', $statusType, $mode);
}
@@ -399,28 +414,23 @@ class Asset extends CommonObject
$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' as t';
$sql .= ' WHERE t.rowid = '.$id;
$result = $this->db->query($sql);
- if ($result)
- {
- if ($this->db->num_rows($result))
- {
+ if ($result) {
+ if ($this->db->num_rows($result)) {
$obj = $this->db->fetch_object($result);
$this->id = $obj->rowid;
- if ($obj->fk_user_author)
- {
+ if ($obj->fk_user_author) {
$cuser = new User($this->db);
$cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser;
}
- if ($obj->fk_user_valid)
- {
+ if ($obj->fk_user_valid) {
$vuser = new User($this->db);
$vuser->fetch($obj->fk_user_valid);
$this->user_validation = $vuser;
}
- if ($obj->fk_user_cloture)
- {
+ if ($obj->fk_user_cloture) {
$cluser = new User($this->db);
$cluser->fetch($obj->fk_user_cloture);
$this->user_cloture = $cluser;
diff --git a/htdocs/asset/class/asset_type.class.php b/htdocs/asset/class/asset_type.class.php
index 5af5f3d7591..d0fa0a9c585 100644
--- a/htdocs/asset/class/asset_type.class.php
+++ b/htdocs/asset/class/asset_type.class.php
@@ -131,27 +131,25 @@ class AssetType extends CommonObject
dol_syslog("Asset_type::create", LOG_DEBUG);
$result = $this->db->query($sql);
- if ($result)
- {
+ if ($result) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."asset_type");
$result = $this->update($user, 1);
- if ($result < 0)
- {
+ if ($result < 0) {
$this->db->rollback();
return -3;
}
- if (!$notrigger)
- {
+ if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('ASSET_TYPE_CREATE', $user);
- if ($result < 0) { $error++; }
+ if ($result < 0) {
+ $error++;
+ }
// End call triggers
}
- if (!$error)
- {
+ if (!$error) {
$this->db->commit();
return $this->id;
} else {
@@ -193,30 +191,27 @@ class AssetType extends CommonObject
$sql .= " WHERE rowid =".$this->id;
$result = $this->db->query($sql);
- if ($result)
- {
+ if ($result) {
$action = 'update';
// Actions on extra fields
- if (!$error)
- {
+ if (!$error) {
$result = $this->insertExtraFields();
- if ($result < 0)
- {
+ if ($result < 0) {
$error++;
}
}
- if (!$error && !$notrigger)
- {
+ if (!$error && !$notrigger) {
// Call trigger
$result = $this->call_trigger('ASSET_TYPE_MODIFY', $user);
- if ($result < 0) { $error++; }
+ if ($result < 0) {
+ $error++;
+ }
// End call triggers
}
- if (!$error)
- {
+ if (!$error) {
$this->db->commit();
return 1;
} else {
@@ -246,11 +241,12 @@ class AssetType extends CommonObject
$sql .= " WHERE rowid = ".$this->id;
$resql = $this->db->query($sql);
- if ($resql)
- {
+ if ($resql) {
// Call trigger
$result = $this->call_trigger('ASSET_TYPE_DELETE', $user);
- if ($result < 0) { $error++; $this->db->rollback(); return -2; }
+ if ($result < 0) {
+ $error++; $this->db->rollback(); return -2;
+ }
// End call triggers
$this->db->commit();
@@ -277,10 +273,8 @@ class AssetType extends CommonObject
dol_syslog("Asset_type::fetch", LOG_DEBUG);
$resql = $this->db->query($sql);
- if ($resql)
- {
- if ($this->db->num_rows($resql))
- {
+ if ($resql) {
+ if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
@@ -317,15 +311,12 @@ class AssetType extends CommonObject
$sql .= " WHERE entity IN (".getEntity('asset_type').")";
$resql = $this->db->query($sql);
- if ($resql)
- {
+ if ($resql) {
$nump = $this->db->num_rows($resql);
- if ($nump)
- {
+ if ($nump) {
$i = 0;
- while ($i < $nump)
- {
+ while ($i < $nump) {
$obj = $this->db->fetch_object($resql);
$assettypes[$obj->rowid] = $langs->trans($obj->label);
@@ -357,18 +348,16 @@ class AssetType extends CommonObject
$sql .= " FROM ".MAIN_DB_PREFIX."asset as a";
$sql .= " WHERE a.entity IN (".getEntity('asset').")";
$sql .= " AND a.fk_asset_type = ".$this->id;
- if (!empty($excludefilter)) $sql .= ' AND ('.$excludefilter.')';
+ if (!empty($excludefilter)) {
+ $sql .= ' AND ('.$excludefilter.')';
+ }
dol_syslog(get_class($this)."::listAssetsForGroup", LOG_DEBUG);
$resql = $this->db->query($sql);
- if ($resql)
- {
- while ($obj = $this->db->fetch_object($resql))
- {
- if (!array_key_exists($obj->rowid, $ret))
- {
- if ($mode < 2)
- {
+ if ($resql) {
+ while ($obj = $this->db->fetch_object($resql)) {
+ if (!array_key_exists($obj->rowid, $ret)) {
+ if ($mode < 2) {
$assetstatic = new Asset($this->db);
if ($mode == 1) {
$assetstatic->fetch($obj->rowid, '', '', '', false, false);
@@ -376,7 +365,9 @@ class AssetType extends CommonObject
$assetstatic->fetch($obj->rowid);
}
$ret[$obj->rowid] = $assetstatic;
- } else $ret[$obj->rowid] = $obj->rowid;
+ } else {
+ $ret[$obj->rowid] = $obj->rowid;
+ }
}
}
@@ -410,8 +401,12 @@ class AssetType extends CommonObject
$linkend = '';
$result .= $linkstart;
- if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
- if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($this->label, $maxlen) : $this->label);
+ if ($withpicto) {
+ $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
+ }
+ if ($withpicto != 2) {
+ $result .= ($maxlen ?dol_trunc($this->label, $maxlen) : $this->label);
+ }
$result .= $linkend;
return $result;
diff --git a/htdocs/asset/document.php b/htdocs/asset/document.php
index 32a4163dd12..e5db1465fb6 100644
--- a/htdocs/asset/document.php
+++ b/htdocs/asset/document.php
@@ -41,8 +41,7 @@ $action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm', 'alpha');
// Security check
-if ($user->socid)
-{
+if ($user->socid) {
$socid = $user->socid;
}
$result=restrictedArea($user, 'asset', $id, '');
@@ -52,16 +51,21 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
-if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
+if (empty($page) || $page == -1) {
+ $page = 0;
+} // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
-if (!$sortorder) $sortorder = "ASC";
-if (!$sortfield) $sortfield = "name";
+if (!$sortorder) {
+ $sortorder = "ASC";
+}
+if (!$sortfield) {
+ $sortfield = "name";
+}
$object = new Asset($db);
-if ($object->fetch($id))
-{
+if ($object->fetch($id)) {
$upload_dir = $conf->asset->dir_output."/".dol_sanitizeFileName($object->ref);
}
@@ -85,10 +89,8 @@ $form = new Form($db);
-if ($id > 0 || !empty($ref))
-{
- if ($object->fetch($id, $ref) > 0)
- {
+if ($id > 0 || !empty($ref)) {
+ if ($object->fetch($id, $ref) > 0) {
$upload_dir = $conf->asset->multidir_output[$object->entity].'/'.dol_sanitizeFileName($object->ref);
$head = asset_prepare_head($object);
@@ -97,8 +99,7 @@ if ($id > 0 || !empty($ref))
// Build file list
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
$totalsize = 0;
- foreach ($filearray as $key => $file)
- {
+ foreach ($filearray as $key => $file) {
$totalsize += $file['size'];
}
diff --git a/htdocs/asset/info.php b/htdocs/asset/info.php
index d211cf0dbad..f6d34454ad4 100644
--- a/htdocs/asset/info.php
+++ b/htdocs/asset/info.php
@@ -29,12 +29,14 @@ require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php';
// Load translation files required by the page
$langs->loadLangs(array("asset"));
-$id = GETPOST('id', 'int');
+$id = GETPOSTINT('id');
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09');
// Security check
-if ($user->socid) $socid = $user->socid;
+if ($user->socid) {
+ $socid = $user->socid;
+}
$result = restrictedArea($user, 'asset', $id);
$object = new Asset($db);
diff --git a/htdocs/asset/list.php b/htdocs/asset/list.php
index cffcc8a962d..9cd00f181c1 100644
--- a/htdocs/asset/list.php
+++ b/htdocs/asset/list.php
@@ -50,7 +50,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 == -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
+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;
@@ -68,14 +70,20 @@ $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) $socid = $user->socid;
-if ($user->socid > 0) // Protection if external user
-{
+if ($user->socid) {
+ $socid = $user->socid;
+}
+if ($user->socid > 0) {
+ // Protection if external user
//$socid = $user->socid;
accessforbidden();
}
@@ -86,30 +94,31 @@ $result = restrictedArea($user, 'asset', $id);
// Initialize array of search criterias
$search_all = GETPOST("search_all", 'alpha');
$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 fields for list
$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'])) $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), 'position'=>$val['position']);
+ if (!empty($val['visible'])) {
+ $arrayfields['t.'.$key] = array('label'=>$val['label'], 'checked'=>(($val['visible'] < 0) ? 0 : 1), 'enabled'=>($val['enabled'] && ($val['visible'] != 3)), '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 (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],
@@ -132,31 +141,33 @@ $permissiontodelete = $user->rights->asset->delete;
* 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
}
@@ -185,13 +196,14 @@ $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("Assets"));
// 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();
@@ -199,20 +211,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);
//$sql.= dolSqlDateFilter("t.field", $search_xxxday, $search_xxxmonth, $search_xxxyear);
// Add where from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
@@ -225,7 +249,7 @@ $sql .= $hookmanager->resPrint;
$sql.= " GROUP BY "
foreach($object->fields as $key => $val)
{
- $sql.='t.'.$key.', ';
+ $sql.='t.'.$key.', ';
}
// Add fields from extrafields
if (! empty($extrafields->attributes[$object->table_element]['label'])) {
@@ -242,26 +266,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;
}
@@ -270,8 +292,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.'/asset/card.php?id='.$id);
@@ -302,14 +323,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';
@@ -318,12 +349,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 '
';*/
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
-if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint;
-else $moreforfilter = $hookmanager->resPrint;
+if (empty($reshook)) {
+ $moreforfilter .= $hookmanager->resPrint;
+} else {
+ $moreforfilter = $hookmanager->resPrint;
+}
-if (!empty($moreforfilter))
-{
+if (!empty($moreforfilter)) {
print '
';
-foreach ($object->fields as $key => $val)
-{
+foreach ($object->fields as $key => $val) {
$cssforfield = (empty($val['css']) ? '' : $val['css']);
- if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
- elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
- elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
- elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right';
- if (!empty($arrayfields['t.'.$key]['checked']))
- {
+ if ($key == 'status') {
+ $cssforfield .= ($cssforfield ? ' ' : '').'center';
+ } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
+ $cssforfield .= ($cssforfield ? ' ' : '').'center';
+ } elseif (in_array($val['type'], array('timestamp'))) {
+ $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
+ } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') {
+ $cssforfield .= ($cssforfield ? ' ' : '').'right';
+ }
+ if (!empty($arrayfields['t.'.$key]['checked'])) {
print '| ';
- if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
- elseif (strpos($val['type'], 'integer:') === 0) {
+ if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
+ print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1);
+ } elseif (strpos($val['type'], 'integer:') === 0) {
print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1);
- } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print '';
+ } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) {
+ print '';
+ }
print ' | ';
}
}
@@ -411,15 +457,18 @@ print ''."\n";
// Fields title label
// --------------------------------------------------------------------
print '';
-foreach ($object->fields as $key => $val)
-{
+foreach ($object->fields as $key => $val) {
$cssforfield = (empty($val['css']) ? '' : $val['css']);
- if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
- elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
- elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
- elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right';
- if (!empty($arrayfields['t.'.$key]['checked']))
- {
+ if ($key == 'status') {
+ $cssforfield .= ($cssforfield ? ' ' : '').'center';
+ } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
+ $cssforfield .= ($cssforfield ? ' ' : '').'center';
+ } elseif (in_array($val['type'], array('timestamp'))) {
+ $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
+ } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') {
+ $cssforfield .= ($cssforfield ? ' ' : '').'right';
+ }
+ if (!empty($arrayfields['t.'.$key]['checked'])) {
print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n";
}
}
@@ -436,11 +485,11 @@ print '
'."\n";
// Detect if we need a fetch on each output line
$needToFetchEachLine = 0;
-if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0)
-{
- foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val)
- {
- if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object
+if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
+ foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
+ if (preg_match('/\$object/', $val)) {
+ $needToFetchEachLine++; // There is at least one compute field that use $object
+ }
}
}
@@ -449,37 +498,50 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co
// --------------------------------------------------------------------
$i = 0;
$totalarray = array();
-while ($i < ($limit ? min($num, $limit) : $num))
-{
+while ($i < ($limit ? min($num, $limit) : $num)) {
$obj = $db->fetch_object($resql);
- if (empty($obj)) break; // Should not happen
+ if (empty($obj)) {
+ break; // Should not happen
+ }
// Store properties in $object
$object->setVarsFromFetchObj($obj);
// Show here line of result
print '';
- foreach ($object->fields as $key => $val)
- {
+ foreach ($object->fields as $key => $val) {
$cssforfield = (empty($val['css']) ? '' : $val['css']);
- if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center';
- elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center';
+ if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) {
+ $cssforfield .= ($cssforfield ? ' ' : '').'center';
+ } elseif ($key == 'status') {
+ $cssforfield .= ($cssforfield ? ' ' : '').'center';
+ }
- if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
- elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
+ if (in_array($val['type'], array('timestamp'))) {
+ $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
+ } elseif ($key == 'ref') {
+ $cssforfield .= ($cssforfield ? ' ' : '').'nowrap';
+ }
- if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') $cssforfield .= ($cssforfield ? ' ' : '').'right';
+ if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $key != 'status') {
+ $cssforfield .= ($cssforfield ? ' ' : '').'right';
+ }
- if (!empty($arrayfields['t.'.$key]['checked']))
- {
+ if (!empty($arrayfields['t.'.$key]['checked'])) {
print '| ';
- if ($key == 'status') print $object->getLibStatut(5);
- else print $object->showOutputField($val, $key, $object->$key, '');
+ if ($key == 'status') {
+ print $object->getLibStatut(5);
+ } else {
+ print $object->showOutputField($val, $key, $object->$key, '');
+ }
print ' | ';
- if (!$i) $totalarray['nbfield']++;
- if (!empty($val['isameasure']))
- {
- if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
+ if (!empty($val['isameasure'])) {
+ if (!$i) {
+ $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key;
+ }
$totalarray['val']['t.'.$key] += $object->$key;
}
}
@@ -492,14 +554,17 @@ while ($i < ($limit ? min($num, $limit) : $num))
print $hookmanager->resPrint;
// Action column
print '';
- if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
- {
+ 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($object->id, $arrayofselected)) $selected = 1;
+ if (in_array($object->id, $arrayofselected)) {
+ $selected = 1;
+ }
print '';
}
print ' | ';
- if (!$i) $totalarray['nbfield']++;
+ if (!$i) {
+ $totalarray['nbfield']++;
+ }
print '
'."\n";
@@ -510,10 +575,13 @@ while ($i < ($limit ? min($num, $limit) : $num))
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
// If no record found
-if ($num == 0)
-{
+if ($num == 0) {
$colspan = 1;
- foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
+ foreach ($arrayfields as $key => $val) {
+ if (!empty($val['checked'])) {
+ $colspan++;
+ }
+ }
print '| '.$langs->trans("NoRecordFound").' |
';
}
@@ -529,10 +597,11 @@ print ''."\n";
print ''."\n";
-if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords))
-{
+if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) {
$hidegeneratedfilelistifempty = 1;
- if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0;
+ 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);
diff --git a/htdocs/asset/note.php b/htdocs/asset/note.php
index 514e05bff72..752591ade9e 100644
--- a/htdocs/asset/note.php
+++ b/htdocs/asset/note.php
@@ -52,10 +52,14 @@ $extrafields->fetch_name_optionals_label($object->table_element);
// Load object
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
-if ($id > 0 || !empty($ref)) $upload_dir = $conf->asset->multidir_output[$object->entity]."/".$object->id;
+if ($id > 0 || !empty($ref)) {
+ $upload_dir = $conf->asset->multidir_output[$object->entity]."/".$object->id;
+}
// Security check
-if (!empty($user->socid)) $socid = $user->socid;
+if (!empty($user->socid)) {
+ $socid = $user->socid;
+}
$result = restrictedArea($user, 'asset', $id);
$permissionnote = 1;
@@ -79,8 +83,7 @@ $form = new Form($db);
$help_url = '';
llxHeader('', $langs->trans('Assets'), $help_url);
-if ($id > 0 || !empty($ref))
-{
+if ($id > 0 || !empty($ref)) {
$object->fetch_thirdparty();
$head = asset_prepare_head($object);
@@ -101,35 +104,35 @@ if ($id > 0 || !empty($ref))
// Project
if (! empty($conf->projet->enabled))
{
- $langs->load("projects");
- $morehtmlref.='
'.$langs->trans('Project') . ' ';
- if ($user->rights->asset->creer)
- {
- if ($action != 'classify')
- //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
- $morehtmlref.=' : ';
- if ($action == 'classify') {
- //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
- $morehtmlref.='';
- } else {
- $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
- }
- } else {
- if (! empty($object->fk_project)) {
- $proj = new Project($db);
- $proj->fetch($object->fk_project);
- $morehtmlref.='';
- $morehtmlref.=$proj->ref;
- $morehtmlref.='';
- } else {
- $morehtmlref.='';
- }
- }
+ $langs->load("projects");
+ $morehtmlref.='
'.$langs->trans('Project') . ' ';
+ if ($user->rights->asset->creer)
+ {
+ if ($action != 'classify')
+ //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
+ $morehtmlref.=' : ';
+ if ($action == 'classify') {
+ //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
+ $morehtmlref.='';
+ } else {
+ $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
+ }
+ } else {
+ if (! empty($object->fk_project)) {
+ $proj = new Project($db);
+ $proj->fetch($object->fk_project);
+ $morehtmlref.='';
+ $morehtmlref.=$proj->ref;
+ $morehtmlref.='';
+ } else {
+ $morehtmlref.='';
+ }
+ }
}*/
$morehtmlref .= '';
diff --git a/htdocs/asset/type.php b/htdocs/asset/type.php
index 38969d65182..5955548b5e2 100644
--- a/htdocs/asset/type.php
+++ b/htdocs/asset/type.php
@@ -26,9 +26,15 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/asset.lib.php';
require_once DOL_DOCUMENT_ROOT.'/asset/class/asset.class.php';
require_once DOL_DOCUMENT_ROOT.'/asset/class/asset_type.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
-if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
-if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
-if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
+if (!empty($conf->accounting->enabled)) {
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
+}
+if (!empty($conf->accounting->enabled)) {
+ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
+}
+if (!empty($conf->accounting->enabled)) {
+ require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
+}
// Load translation files required by the page
$langs->load("assets");
@@ -44,12 +50,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST("sortfield", 'alpha');
$sortorder = GETPOST("sortorder", 'alpha');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
-if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
+if (empty($page) || $page == -1) {
+ $page = 0;
+} // If $page is not defined, or '' or -1
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
-if (!$sortorder) { $sortorder = "DESC"; }
-if (!$sortfield) { $sortfield = "a.label"; }
+if (!$sortorder) {
+ $sortorder = "DESC";
+}
+if (!$sortfield) {
+ $sortfield = "a.label";
+}
$label = GETPOST("label", "alpha");
$accountancy_code_asset = GETPOST('accountancy_code_asset', 'string');
@@ -67,8 +79,7 @@ $extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
$extrafields->fetch_name_optionals_label($object->table_element);
-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('button_removefilter_x', 'alpha') || GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
$type = "";
$sall = "";
}
@@ -86,15 +97,13 @@ $permissiontoadd = $user->rights->asset->setup_advance;
if ($cancel) {
$action = '';
- if (!empty($backtopage))
- {
+ if (!empty($backtopage)) {
header("Location: ".$backtopage);
exit;
}
}
-if ($action == 'add' && $user->rights->asset->write)
-{
+if ($action == 'add' && $user->rights->asset->write) {
$object->label = trim($label);
$object->accountancy_code_asset = trim($accountancy_code_asset);
$object->accountancy_code_depreciation_asset = trim($accountancy_code_depreciation_asset);
@@ -103,7 +112,9 @@ if ($action == 'add' && $user->rights->asset->write)
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object);
- if ($ret < 0) $error++;
+ if ($ret < 0) {
+ $error++;
+ }
if (empty($object->label)) {
$error++;
@@ -121,11 +132,9 @@ if ($action == 'add' && $user->rights->asset->write)
}
}
- if (!$error)
- {
+ if (!$error) {
$id = $object->create($user);
- if ($id > 0)
- {
+ if ($id > 0) {
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
} else {
@@ -137,8 +146,7 @@ if ($action == 'add' && $user->rights->asset->write)
}
}
-if ($action == 'update' && $user->rights->asset->write)
-{
+if ($action == 'update' && $user->rights->asset->write) {
$object->fetch($rowid);
$object->oldcopy = clone $object;
@@ -151,12 +159,13 @@ if ($action == 'update' && $user->rights->asset->write)
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost(null, $object);
- if ($ret < 0) $error++;
+ if ($ret < 0) {
+ $error++;
+ }
$ret = $object->update($user);
- if ($ret >= 0 && !count($object->errors))
- {
+ if ($ret >= 0 && !count($object->errors)) {
setEventMessages($langs->trans("AssetTypeModified"), null, 'mesgs');
} else {
setEventMessages($object->error, $object->errors, 'errors');
@@ -166,13 +175,11 @@ if ($action == 'update' && $user->rights->asset->write)
exit;
}
-if ($action == 'confirm_delete' && $user->rights->asset->write)
-{
+if ($action == 'confirm_delete' && $user->rights->asset->write) {
$object->fetch($rowid);
$res = $object->delete();
- if ($res > 0)
- {
+ if ($res > 0) {
setEventMessages($langs->trans("AssetsTypeDeleted"), null, 'mesgs');
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
@@ -194,8 +201,7 @@ llxHeader('', $langs->trans("AssetsTypeSetup"), $helpurl);
// List of asset type
-if (!$rowid && $action != 'create' && $action != 'edit')
-{
+if (!$rowid && $action != 'create' && $action != 'edit') {
//print dol_get_fiche_head('');
$sql = "SELECT d.rowid, d.label as label, d.accountancy_code_asset, d.accountancy_code_depreciation_asset, d.accountancy_code_depreciation_expense, d.note";
@@ -203,8 +209,7 @@ if (!$rowid && $action != 'create' && $action != 'edit')
$sql .= " WHERE d.entity IN (".getEntity('asset_type').")";
$result = $db->query($sql);
- if ($result)
- {
+ if ($result) {
$num = $db->num_rows($result);
$nbtotalofrecords = $num;
@@ -213,7 +218,9 @@ if (!$rowid && $action != 'create' && $action != 'edit')
$param = '';
print '