Work on common core code

This commit is contained in:
Laurent Destailleur 2017-11-03 17:20:08 +01:00
parent 4ac8cb9168
commit cd70e1506b
7 changed files with 23 additions and 12 deletions

View File

@ -87,6 +87,7 @@ if ($action == 'update' && ! empty($permissiontoadd))
{
foreach ($object->fields as $key => $val)
{
if (! GETPOSTISSET($key)) continue; // The field was not submited to be edited
if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields
$value = GETPOST($key,'alpha');

View File

@ -1396,7 +1396,7 @@ abstract class CommonObject
}
/**
* Load properties id_previous and id_next
* Load properties id_previous and id_next by comparing $fieldid with $this->ref
*
* @param string $filter Optional filter. Example: " AND (t.field1 = 'aa' OR t.field2 = 'bb')"
* @param string $fieldid Name of field to use for the select MAX and MIN
@ -1433,7 +1433,7 @@ abstract class CommonObject
if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to entity
if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql.= ' AND te.entity IN ('.getEntity($this->element, 1).')';
//print $filter.' '.$sql."<br>";
//print 'filter = '.$filter.' -> '.$sql."<br>";
$result = $this->db->query($sql);
if (! $result)
{
@ -6044,7 +6044,7 @@ abstract class CommonObject
}
/**
* Function to load data into current object this
* Function to load data from a SQL pointer into properties of current object $this
*
* @param stdClass $obj Contain data of object from database
*/
@ -6082,8 +6082,10 @@ abstract class CommonObject
{
$this->{$field} = $obj->{$field};
}
}
// If there is no 'ref' field, we force property ->ref to ->id for a better compatibility with common functions.
if (! isset($this->fields['ref']) && isset($this->id)) $this->ref = $this->id;
}
/**

View File

@ -6158,13 +6158,13 @@ class Form
/**
* Return a HTML area with the reference of object and a navigation bar for a business object
* Note: To add a particular filter on select, you can have $object->next_prev_filter set to add SQL criterias.
* Note: To complete search with a particular filter on select, you can set $object->next_prev_filter set to define SQL criterias.
*
* @param object $object Object to show.
* @param string $paramid Name of parameter to use to name the id into the URL next/previous link.
* @param string $morehtml More html content to output just before the nav bar.
* @param int $shownav Show Condition (navigation is shown if value is 1).
* @param string $fieldid Name of field id into database to use for select next and previous (we make the select max and min on this field). Use 'none' to disable next/prev.
* @param string $fieldid Name of field id into database to use for select next and previous (we make the select max and min on this field compared to $object->ref). Use 'none' to disable next/prev.
* @param string $fieldref Name of field ref of object (object->ref) to show or 'none' to not show ref.
* @param string $morehtmlref More html to show after ref.
* @param string $moreparam More param to add in nav link url. Must start with '&...'.
@ -6194,7 +6194,7 @@ class Form
if ($shownav)
{
//print "paramid=$paramid,morehtml=$morehtml,shownav=$shownav,$fieldid,$fieldref,$morehtmlref,$moreparam";
$object->load_previous_next_ref((isset($object->next_prev_filter)?$object->next_prev_filter:''),$fieldid,$nodbprefix);
$object->load_previous_next_ref((isset($object->next_prev_filter)?$object->next_prev_filter:''), $fieldid, $nodbprefix);
$navurl = $_SERVER["PHP_SELF"];
// Special case for project/task page

View File

@ -26,7 +26,9 @@
foreach($object->fields as $key => $val)
{
if (abs($val['visible']) != 1) continue; // Discard such field from form
// Discard if extrafield is a hidden field on form
if (abs($val['visible']) != 1) continue;
if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled']) continue; // We don't want this field
print '<tr id="field_'.$key.'">';

View File

@ -26,7 +26,9 @@
foreach($object->fields as $key => $val)
{
if (abs($val['visible']) != 1) continue; // Discard such field from form
// Discard if extrafield is a hidden field on form
if (abs($val['visible']) != 1) continue;
if (array_key_exists('enabled', $val) && isset($val['enabled']) && ! $val['enabled']) continue; // We don't want this field
print '<tr><td';

View File

@ -54,4 +54,5 @@ ExportSite=Export site
IDOfPage=Id of page
WebsiteAccount=Web site account
WebsiteAccounts=Web site accounts
AddWebsiteAccount=Create web site account
AddWebsiteAccount=Create web site account
BackToListOfThirdParty=Back to list for Third Party

View File

@ -219,6 +219,8 @@ if (($id || $ref) && $action == 'edit')
// Part to show record
if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create')))
{
if ($object->fk_soc >0 && empty($socid)) $socid = $object->fk_soc;
$res = $object->fetch_optionals($object->id, $extralabels);
$head = websiteaccountPrepareHead($object);
@ -259,7 +261,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
// Object card
// ------------------------------------------------------------
$linkback='';
if ($socid) $linkback = '<a href="' .DOL_URL_ROOT.'/societe/website.php?socid='.$socid.'&restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
if ($socid) $linkback = '<a href="' .DOL_URL_ROOT.'/societe/website.php?socid='.$socid.'&restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToListOfThirdParty") . '</a>';
if ($fk_website) $linkback = '<a href="' .DOL_URL_ROOT.'/website/website_card.php?fk_website='.$fk_website.'&restore_lastsearch_values=1' . (! empty($socid) ? '&socid=' . $socid : '') . '">' . $langs->trans("BackToList") . '</a>';
$morehtmlref='<div class="refidno">';
@ -306,8 +308,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
*/
$morehtmlref.='</div>';
if ($socid > 0) $object->next_prev_filter = 'te.fk_soc = '.$socid;
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'rowid', $morehtmlref);
print '<div class="fichecenter">';