Merge pull request #15252 from frederic34/specimencommon

initSpecimenCommon
This commit is contained in:
Laurent Destailleur 2020-11-02 09:29:48 +01:00 committed by GitHub
commit ea3106cd07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8285,22 +8285,31 @@ abstract class CommonObject
* Initialise object with example values * Initialise object with example values
* Id must be 0 if object instance is a specimen * Id must be 0 if object instance is a specimen
* *
* @return void * @return int
*/ */
public function initAsSpecimenCommon() public function initAsSpecimenCommon()
{ {
global $user; global $user;
$this->id = 0; $this->id = 0;
if (array_key_exists('label', $this->fields)) $this->label = 'This is label'; $this->specimen = 1;
if (array_key_exists('note_public', $this->fields)) $this->note_public = 'Public note'; $fields = array(
if (array_key_exists('note_private', $this->fields)) $this->note_private = 'Private note'; 'label' => 'This is label',
if (array_key_exists('date_creation', $this->fields)) $this->date_creation = (dol_now() - 3600 * 24); 'ref' => 'ABCD1234',
if (array_key_exists('date_modification', $this->fields)) $this->date_modification = (dol_now() - 3600 * 24); 'description' => 'This is a description',
if (array_key_exists('fk_user_creat', $this->fields)) $this->fk_user_creat = $user->id; 'qty' => 123.12,
if (array_key_exists('fk_user_modif', $this->fields)) $this->fk_user_modif = $user->id; 'note_public' => 'Public note',
if (array_key_exists('date', $this->fields)) $this->date = dol_now(); 'note_private' => 'Private note',
// ... 'date_creation' => (dol_now() - 3600 * 48),
'date_modification' => (dol_now() - 3600 * 24),
'fk_user_creat' => $user->id,
'fk_user_modif' => $user->id,
'date' => dol_now(),
);
foreach ($fields as $key => $value) {
if (array_key_exists($key, $this->fields)) $this->{$key} = $value;
}
return 1;
} }