diff --git a/htdocs/product/stock/replenishorders.php b/htdocs/product/stock/replenishorders.php index c39f498d9b6..5ca7debbef6 100644 --- a/htdocs/product/stock/replenishorders.php +++ b/htdocs/product/stock/replenishorders.php @@ -38,8 +38,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $langs->loadLangs(array('products', 'stocks', 'orders')); // Security check -if ($user->socid) $socid=$user->socid; -$result=restrictedArea($user, 'produit|service'); +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'produit|service'); $sall = GETPOST('search_all', 'alphanohtml'); $sref = GETPOST('search_ref', 'alpha'); @@ -53,7 +53,7 @@ $search_datemonth = GETPOST('search_datemonth', 'int'); $search_dateday = GETPOST('search_dateday', 'int'); $search_date = dol_mktime(0, 0, 0, $search_datemonth, $search_dateday, $search_dateyear); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); if (!$sortorder) $sortorder = 'DESC'; @@ -69,16 +69,16 @@ $offset = $limit * $page; if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers { - $sall=""; - $sref=""; - $snom=""; - $suser=""; - $sttc=""; - $search_date=''; - $search_datemonth=''; - $search_dateday=''; - $search_dateyear=''; - $sproduct=0; + $sall = ""; + $sref = ""; + $snom = ""; + $suser = ""; + $sttc = ""; + $search_date = ''; + $search_datemonth = ''; + $search_dateday = ''; + $search_dateyear = ''; + $sproduct = 0; } @@ -109,40 +109,40 @@ dol_fiche_head($head, 'replenishorders', '', -1, ''); $commandestatic = new CommandeFournisseur($db); $sql = 'SELECT s.rowid as socid, s.nom as name, cf.date_creation as dc,'; -$sql.= ' cf.rowid, cf.ref, cf.fk_statut, cf.total_ttc, cf.fk_user_author,'; -$sql.= ' u.login'; -$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'commande_fournisseur as cf'; -$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON cf.fk_user_author = u.rowid'; +$sql .= ' cf.rowid, cf.ref, cf.fk_statut, cf.total_ttc, cf.fk_user_author,'; +$sql .= ' u.login'; +$sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'commande_fournisseur as cf'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON cf.fk_user_author = u.rowid'; if (!$user->rights->societe->client->voir && !$socid) { - $sql.= ', ' . MAIN_DB_PREFIX . 'societe_commerciaux as sc'; + $sql .= ', '.MAIN_DB_PREFIX.'societe_commerciaux as sc'; } -$sql.= ' WHERE cf.fk_soc = s.rowid '; -$sql.= ' AND cf.entity = ' . $conf->entity; +$sql .= ' WHERE cf.fk_soc = s.rowid '; +$sql .= ' AND cf.entity = '.$conf->entity; if ($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) { $sql .= ' AND cf.fk_statut < 3'; -} elseif ($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER|| !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) { - $sql .= ' AND cf.fk_statut < 6'; // We want also status 5, we will keep them visible if dispatching is not yet finished (tested with function dolDispatchToDo). +} elseif ($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) { + $sql .= ' AND cf.fk_statut < 6'; // We want also status 5, we will keep them visible if dispatching is not yet finished (tested with function dolDispatchToDo). } else { $sql .= ' AND cf.fk_statut < 5'; } if (!$user->rights->societe->client->voir && !$socid) { - $sql .= ' AND s.rowid = sc.fk_soc AND sc.fk_user = ' . $user->id; + $sql .= ' AND s.rowid = sc.fk_soc AND sc.fk_user = '.$user->id; } if ($sref) $sql .= natural_search('cf.ref', $sref); if ($snom) $sql .= natural_search('s.nom', $snom); if ($suser) $sql .= natural_search('u.login', $suser); if ($sttc) $sql .= natural_search('cf.total_ttc', $sttc, 1); -$sql.= dolSqlDateFilter('cf.date_creation', $search_dateday, $search_datemonth, $search_dateyear); -if ($sall) $sql .= natural_search(array('cf.ref','cf.note'), $sall); -if (!empty($socid)) $sql .= ' AND s.rowid = ' . $socid; +$sql .= dolSqlDateFilter('cf.date_creation', $search_dateday, $search_datemonth, $search_dateyear); +if ($sall) $sql .= natural_search(array('cf.ref', 'cf.note'), $sall); +if (!empty($socid)) $sql .= ' AND s.rowid = '.$socid; if (GETPOST('statut', 'int')) { - $sql .= ' AND fk_statut = ' . GETPOST('statut', 'int'); + $sql .= ' AND fk_statut = '.GETPOST('statut', 'int'); } $sql .= ' GROUP BY cf.rowid, cf.ref, cf.date_creation, cf.fk_statut'; $sql .= ', cf.total_ttc, cf.fk_user_author, u.login, s.rowid, s.nom'; $sql .= $db->order($sortfield, $sortorder); -if (! $sproduct) { - $sql .= $db->plimit($limit+1, $offset); +if (!$sproduct) { + $sql .= $db->plimit($limit + 1, $offset); } $resql = $db->query($sql); @@ -155,17 +155,17 @@ if ($resql) print_barre_liste('', $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', $num, 0, ''); - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($sref) $param.='&search_ref='.urlencode($sref); - if ($snom) $param.='&search_nom='.urlencode($snom); - if ($suser) $param.='&search_user='.urlencode($suser); - if ($sttc) $param.='&search_ttc='.urlencode($sttc); - if ($search_dateyear) $param.='&search_dateyear='.urlencode($search_dateyear); - if ($search_datemonth) $param.='&search_datemonth='.urlencode($search_datemonth); - if ($search_dateday) $param.='&search_dateday='.urlencode($search_dateday); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($sref) $param .= '&search_ref='.urlencode($sref); + if ($snom) $param .= '&search_nom='.urlencode($snom); + if ($suser) $param .= '&search_user='.urlencode($suser); + if ($sttc) $param .= '&search_ttc='.urlencode($sttc); + if ($search_dateyear) $param .= '&search_dateyear='.urlencode($search_dateyear); + if ($search_datemonth) $param .= '&search_datemonth='.urlencode($search_datemonth); + if ($search_dateday) $param .= '&search_dateday='.urlencode($search_dateday); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); print '
'; @@ -174,16 +174,16 @@ if ($resql) print ''; print ''. - ''. + ''. ''. ''. - ''. + ''. ''. ''. - ''. + ''. ''. ''. - ''. + ''. ''. ''. $form->selectDate($search_date, 'search_date', 0, 0, 1, '', 1, 0, 0, ''). @@ -260,7 +260,7 @@ if ($resql) $userstatic = new User($db); - while ($i < min($num, $sproduct?$num:$conf->liste_limit)) + while ($i < min($num, $sproduct ? $num : $conf->liste_limit)) { $obj = $db->fetch_object($resql); @@ -276,11 +276,11 @@ if ($resql) print ''; // Company - $href = DOL_URL_ROOT . '/fourn/card.php?socid=' . $obj->socid; + $href = DOL_URL_ROOT.'/fourn/card.php?socid='.$obj->socid; print ''. - ''. - img_object($langs->trans('ShowCompany'), 'company'). ' '. - $obj->name . ''; + ''. + img_object($langs->trans('ShowCompany'), 'company').' '. + $obj->name.''; // Author $userstatic->id = $obj->fk_user_author; @@ -288,7 +288,7 @@ if ($resql) if ($userstatic->id) { $txt = $userstatic->getLoginUrl(1); } else { - $txt = ' '; + $txt = ' '; } print ''.$txt.''; // Amount @@ -296,9 +296,9 @@ if ($resql) // Date if ($obj->dc) { - $date = dol_print_date($db->jdate($obj->dc), 'dayhour'); + $date = dol_print_date($db->jdate($obj->dc), 'dayhour'); } else { - $date = '-'; + $date = '-'; } print ''.$date.''; // Statut diff --git a/htdocs/product/stock/valo.php b/htdocs/product/stock/valo.php index e814bdfaac0..816d97351b4 100644 --- a/htdocs/product/stock/valo.php +++ b/htdocs/product/stock/valo.php @@ -30,19 +30,19 @@ require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; $langs->load("stocks"); // Security check -$result=restrictedArea($user, 'stock'); +$result = restrictedArea($user, 'stock'); -$sref=GETPOST("sref", 'alpha'); -$snom=GETPOST("snom", 'alpha'); -$sall=trim((GETPOST('search_all', 'alphanohtml')!='')?GETPOST('search_all', 'alphanohtml'):GETPOST('sall', 'alphanohtml')); +$sref = GETPOST("sref", 'alpha'); +$snom = GETPOST("snom", 'alpha'); +$sall = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml')); $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); -if (! $sortfield) $sortfield="e.ref"; -if (! $sortorder) $sortorder="ASC"; +if (!$sortfield) $sortfield = "e.ref"; +if (!$sortorder) $sortorder = "ASC"; $page = $_GET["page"]; if ($page < 0) $page = 0; -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $offset = $limit * $page; $year = strftime("%Y", time()); @@ -53,23 +53,23 @@ $year = strftime("%Y", time()); */ $sql = "SELECT e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays,"; -$sql.= " SUM(ps.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue"; -$sql.= " FROM ".MAIN_DB_PREFIX."entrepot as e"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON e.rowid = ps.fk_entrepot"; -$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; -$sql.= " WHERE e.entity IN (".getEntity('stock').")"; -if ($sref) $sql.= natural_search("e.ref", $sref); +$sql .= " SUM(ps.pmp * ps.reel) as estimatedvalue, SUM(p.price * ps.reel) as sellvalue"; +$sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON e.rowid = ps.fk_entrepot"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product as p ON ps.fk_product = p.rowid"; +$sql .= " WHERE e.entity IN (".getEntity('stock').")"; +if ($sref) $sql .= natural_search("e.ref", $sref); if ($sall) { - $sql.= " AND (e.ref LIKE '%".$db->escape($sall)."%'"; - $sql.= " OR e.description LIKE '%".$db->escape($sall)."%'"; - $sql.= " OR e.lieu LIKE '%".$db->escape($sall)."%'"; - $sql.= " OR e.address LIKE '%".$db->escape($sall)."%'"; - $sql.= " OR e.town LIKE '%".$db->escape($sall)."%')"; + $sql .= " AND (e.ref LIKE '%".$db->escape($sall)."%'"; + $sql .= " OR e.description LIKE '%".$db->escape($sall)."%'"; + $sql .= " OR e.lieu LIKE '%".$db->escape($sall)."%'"; + $sql .= " OR e.address LIKE '%".$db->escape($sall)."%'"; + $sql .= " OR e.town LIKE '%".$db->escape($sall)."%')"; } -$sql.= " GROUP BY e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays"; -$sql.= $db->order($sortfield, $sortorder); -$sql.= $db->plimit($limit + 1, $offset); +$sql .= " GROUP BY e.rowid, e.ref, e.statut, e.lieu, e.address, e.zip, e.town, e.fk_pays"; +$sql .= $db->order($sortfield, $sortorder); +$sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); if ($result) @@ -78,7 +78,7 @@ if ($result) $i = 0; - $help_url='EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; + $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks'; llxHeader("", $langs->trans("EnhancedValueOfWarehouses"), $help_url); print_barre_liste($langs->trans("EnhancedValueOfWarehouses"), $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, '', $num); @@ -94,9 +94,9 @@ if ($result) if ($num) { - $entrepot=new Entrepot($db); + $entrepot = new Entrepot($db); $total = $totalsell = 0; - $var=false; + $var = false; while ($i < min($num, $limit)) { $objp = $db->fetch_object($result); @@ -136,17 +136,17 @@ if ($result) print '
'; - $file='entrepot-'.$year.'.png'; + $file = 'entrepot-'.$year.'.png'; if (file_exists($conf->stock->dir_temp.'/'.$file)) { - $url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&file='.$file; + $url = DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&file='.$file; print ''; } - $file='entrepot-'.($year-1).'.png'; + $file = 'entrepot-'.($year - 1).'.png'; if (file_exists($conf->stock->dir_temp.'/'.$file)) { - $url=DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&file='.$file; + $url = DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&file='.$file; print '
'; } } diff --git a/htdocs/projet/info.php b/htdocs/projet/info.php index c28460e1045..ddb7673dece 100644 --- a/htdocs/projet/info.php +++ b/htdocs/projet/info.php @@ -36,34 +36,34 @@ $ref = GETPOST('ref', 'alpha'); $socid = GETPOST('socid', 'int'); $action = GETPOST('action', 'aZ09'); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", "alpha"); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); $page = is_numeric($page) ? $page : 0; $page = $page == -1 ? 0 : $page; -if (! $sortfield) $sortfield="a.datep,a.id"; -if (! $sortorder) $sortorder="DESC"; -$offset = $limit * $page ; +if (!$sortfield) $sortfield = "a.datep,a.id"; +if (!$sortorder) $sortorder = "DESC"; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (GETPOST('actioncode', 'array')) { - $actioncode=GETPOST('actioncode', 'array', 3); - if (! count($actioncode)) $actioncode='0'; + $actioncode = GETPOST('actioncode', 'array', 3); + if (!count($actioncode)) $actioncode = '0'; } else { - $actioncode=GETPOST("actioncode", "alpha", 3)?GETPOST("actioncode", "alpha", 3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); + $actioncode = GETPOST("actioncode", "alpha", 3) ?GETPOST("actioncode", "alpha", 3) : (GETPOST("actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT)); } -$search_agenda_label=GETPOST('search_agenda_label'); +$search_agenda_label = GETPOST('search_agenda_label'); // Security check $id = GETPOST("id", 'int'); -$socid=0; +$socid = 0; //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. -$result=restrictedArea($user, 'projet', $id, ''); +$result = restrictedArea($user, 'projet', $id, ''); if (!$user->rights->projet->lire) accessforbidden(); @@ -149,20 +149,20 @@ dol_fiche_end(); // Actions buttons -$out=''; -$permok=$user->rights->agenda->myactions->create; +$out = ''; +$permok = $user->rights->agenda->myactions->create; if ($permok) { - $out.='&projectid='.$object->id; + $out .= '&projectid='.$object->id; } //print '
'; -$morehtmlcenter=''; -if (! empty($conf->agenda->enabled)) +$morehtmlcenter = ''; +if (!empty($conf->agenda->enabled)) { - $addActionBtnRight = ! empty($user->rights->agenda->myactions->create) || ! empty($user->rights->agenda->allactions->create); - $morehtmlcenter.= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $addActionBtnRight); + $addActionBtnRight = !empty($user->rights->agenda->myactions->create) || !empty($user->rights->agenda->allactions->create); + $morehtmlcenter .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id), '', $addActionBtnRight); } //print '
'; diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php index e1bf458b6e4..d0f85eb9fe2 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -50,56 +50,56 @@ $extrafields = new ExtraFields($db); // fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -$search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); -if (! is_array($search_array_options)) $search_array_options = array(); -$search_ref=GETPOST("search_ref"); -$search_type=GETPOST("search_type"); +$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); +if (!is_array($search_array_options)) $search_array_options = array(); +$search_ref = GETPOST("search_ref"); +$search_type = GETPOST("search_type"); -$filter=array(); +$filter = array(); -if ($search_ref != ''){ - $param.='&search_ref='.$search_ref; - $filter['t.ref']=$search_ref; +if ($search_ref != '') { + $param .= '&search_ref='.$search_ref; + $filter['t.ref'] = $search_ref; } -if ($search_type != ''){ - $param.='&search_type='.$search_type; - $filter['ty.label']=$search_type; +if ($search_type != '') { + $param .= '&search_type='.$search_type; + $filter['ty.label'] = $search_type; } -if ($search_label != '') $param.='&search_label='.$search_label; +if ($search_label != '') $param .= '&search_label='.$search_label; // Add $param from extra fields foreach ($search_array_options as $key => $val) { - $crit=$val; - $tmpkey=preg_replace('/search_options_/', '', $key); - $typ=$extrafields->attributes[$object->table_element]['type'][$tmpkey]; + $crit = $val; + $tmpkey = preg_replace('/search_options_/', '', $key); + $typ = $extrafields->attributes[$object->table_element]['type'][$tmpkey]; if ($val != '') { - $param.='&search_options_'.$tmpkey.'='.urlencode($val); + $param .= '&search_options_'.$tmpkey.'='.urlencode($val); } - $mode_search=0; - if (in_array($typ, array('int','double','real'))) $mode_search=1; // Search on a numeric - if (in_array($typ, array('sellist','link')) && $crit != '0' && $crit != '-1') $mode_search=2; // Search on a foreign key int - if ($crit != '' && (! in_array($typ, array('select','sellist')) || $crit != '0') && (! in_array($typ, array('link')) || $crit != '-1')) + $mode_search = 0; + if (in_array($typ, array('int', 'double', 'real'))) $mode_search = 1; // Search on a numeric + if (in_array($typ, array('sellist', 'link')) && $crit != '0' && $crit != '-1') $mode_search = 2; // Search on a foreign key int + if ($crit != '' && (!in_array($typ, array('select', 'sellist')) || $crit != '0') && (!in_array($typ, array('link')) || $crit != '-1')) { $filter['ef.'.$tmpkey] = natural_search('ef.'.$tmpkey, $crit, $mode_search); } } -if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; $hookmanager->initHooks(array('resourcelist')); -if (empty($sortorder)) $sortorder="ASC"; -if (empty($sortfield)) $sortfield="t.ref"; +if (empty($sortorder)) $sortorder = "ASC"; +if (empty($sortfield)) $sortfield = "t.ref"; if (empty($arch)) $arch = 0; -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $page = GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $limit * $page ; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if( ! $user->rights->resource->read) { +if (!$user->rights->resource->read) { accessforbidden(); } $arrayfields = array( @@ -115,10 +115,10 @@ $arrayfields = array( // 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) + 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])); + 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');