initSpecimenCommon
This commit is contained in:
parent
2b465a9f2c
commit
a1016d79a2
@ -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 * 24),
|
||||||
|
'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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user