Skip to content

Commit

Permalink
Merge pull request Evarisk#1011 from evarisk-micka/add_signature_func…
Browse files Browse the repository at this point in the history
…tionnal

Evarisk#1009 [Signature] add: view and rework getNomUrl to display frozen data
  • Loading branch information
nicolas-eoxia authored Jul 19, 2024
2 parents e96a34f + 2043fc9 commit f8337b9
Show file tree
Hide file tree
Showing 4 changed files with 147 additions and 27 deletions.
147 changes: 139 additions & 8 deletions class/saturnesignature.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ class SaturneSignature extends SaturneObject
'import_key' => ['type' => 'varchar(14)', 'label' => 'ImportId', 'enabled' => 1, 'position' => 40, 'notnull' => 0, 'visible' => 0],
'status' => ['type' => 'smallint', 'label' => 'Status', 'enabled' => 1, 'position' => 50, 'notnull' => 0, 'visible' => 1, 'index' => 1],
'role' => ['type' => 'varchar(255)', 'label' => 'Role', 'enabled' => 1, 'position' => 60, 'notnull' => 0, 'visible' => 3],
'civility' => ['type' => 'varchar(6)', 'label' => 'Civility', 'enabled' => 0, 'position' => 61, 'notnull' => 0, 'visible' => 0],
'gender' => ['type' => 'varchar(10)', 'label' => 'Gender', 'enabled' => 1, 'position' => 61, 'notnull' => 0, 'visible' => 3],
'civility' => ['type' => 'varchar(6)', 'label' => 'Civility', 'enabled' => 1, 'position' => 62, 'notnull' => 0, 'visible' => 3],
'firstname' => ['type' => 'varchar(255)', 'label' => 'Firstname', 'enabled' => 1, 'position' => 70, 'notnull' => 0, 'visible' => 3],
'lastname' => ['type' => 'varchar(255)', 'label' => 'Lastname', 'enabled' => 1, 'position' => 80, 'notnull' => 0, 'visible' => 3],
'job' => ['type' => 'varchar(128)', 'label' => 'PostOrFunction', 'enabled' => 0, 'position' => 81, 'notnull' => 0, 'visible' => 0],
'job' => ['type' => 'varchar(128)', 'label' => 'PostOrFunction', 'enabled' => 1, 'position' => 81, 'notnull' => 0, 'visible' => 3],
'email' => ['type' => 'varchar(255)', 'label' => 'Email', 'enabled' => 1, 'position' => 90, 'notnull' => 0, 'visible' => 3],
'phone' => ['type' => 'varchar(255)', 'label' => 'Phone', 'enabled' => 1, 'position' => 100, 'notnull' => 0, 'visible' => 3],
'society_name' => ['type' => 'varchar(255)', 'label' => 'SocietyName', 'enabled' => 1, 'position' => 110, 'notnull' => 0, 'visible' => 3],
Expand Down Expand Up @@ -153,6 +154,11 @@ class SaturneSignature extends SaturneObject
*/
public ?string $role;

/**
* @var string|null Gender
*/
public ?string $gender = '';

/**
* @var string|null Civility
*/
Expand Down Expand Up @@ -470,7 +476,6 @@ public function setSignatory(int $fk_object, string $object_type, string $elemen
$signatory_data = '';
if ($element_type == 'user') {
$signatory_data = new User($this->db);

$signatory_data->fetch($element_id);

if ($signatory_data->socid > 0) {
Expand All @@ -480,10 +485,11 @@ public function setSignatory(int $fk_object, string $object_type, string $elemen
$this->society_name = $conf->global->MAIN_INFO_SOCIETE_NOM;
}

$this->phone = $signatory_data->user_mobile;
$this->phone = (!empty($signatory_data->user_mobile) ? $signatory_data->user_mobile : $signatory_data->office_phone);
$this->gender = $signatory_data->gender;
$this->job = $signatory_data->job;
} elseif ($element_type == 'socpeople') {
$signatory_data = new Contact($this->db);

$signatory_data->fetch($element_id);
if (!is_object($signatory_data)) {
$signatory_data = new stdClass();
Expand All @@ -492,11 +498,12 @@ public function setSignatory(int $fk_object, string $object_type, string $elemen
$society->fetch($signatory_data->socid);

$this->society_name = $society->name;
$this->phone = $signatory_data->phone_mobile;
$this->phone = (!empty($signatory_data->phone_mobile) ? $signatory_data->phone_mobile : (!empty($signatory_data->phone_pro) ? $signatory_data->phone_pro : $signatory_data->phone_perso));
$this->job = $signatory_data->poste;
}

$this->status = self::STATUS_REGISTERED;

$this->status = self::STATUS_REGISTERED;
$this->civility = $signatory_data->civility_code;
$this->firstname = $signatory_data->firstname;
$this->lastname = $signatory_data->lastname;
$this->email = $signatory_data->email;
Expand Down Expand Up @@ -755,4 +762,128 @@ public function createFromClone(User $user, int $fromID, int $objectID): int
return -1;
}
}

/**
* Return a link to the object card (with optionaly the picto)
*
* @param int $withpicto Include picto in link (0 = No picto, 1 = Include picto into link, 2 = Only picto)
* @param string $option On what the link point to ('nolink', ...)
* @param int $notooltip 1 = Disable tooltip
* @param string $morecss Add more css on link
* @param int $save_lastsearch_value -1 = Auto, 0 = No save of lastsearch_values when clicking, 1 = Save lastsearch_values whenclicking
* @param int $addLabel 0 = Default, 1 = Add label into string, >1 = Add first chars into string
* @return string String with URL
*/
public function getNomUrl(int $withpicto = 0, string $option = '', int $notooltip = 0, string $morecss = '', int $save_lastsearch_value = -1, int $addLabel = 0): string
{
global $action, $conf, $hookmanager, $langs;

if (!empty($conf->dol_no_mouse_hover)) {
$notooltip = 1; // Force disable tooltips
}

$result = '';
$picto = $this->element_type == 'socpeople' ? 'contact' : 'user';
if ($this->element_type == 'user') {
$user = new User($this->db);
$url = dol_buildpath('/user/card.php?id=' . $this->element_id, 1);
$user->fetch($this->element_id);
} else {
$contact = new Contact($this->db);
$url = dol_buildpath('/contact/card.php?id=' . $this->element_id, 1);
$contact->fetch($this->element_id);
}

$label = img_picto('', $picto) . ' <u>' . $langs->trans(ucfirst($picto)) . '</u>';
if (isset($this->status)) {
$label .= ' ' . $this->getLibStatut(5);
}
$label .= '<br>';
$label .= '<b>' . $langs->trans('Name') . ' : </b> ' . $this->firstname . ' ' . $this->lastname;
if ($this->element_type == 'user') {
$label .= (!empty($this->gender) ? '<br><b>' . $langs->trans('Gender') . ' : </b> ' . $langs->trans('Gender' . $this->gender) : '');
$label .= '<br><b>' . $langs->trans('Login') . ' : </b> ' . $user->login;
}
$label .= (!empty($this->job) ? '<br><b>' . $langs->trans('PostOrFunction') . ' : </b> ' . $this->job : '');
$label .= (!empty($this->email) ? '<br><b>' . $langs->trans('Email') . ' : </b> ' . $this->email : '');
$label .= (!empty($this->phone) ? '<br><b>' . $langs->trans('Phone') . ' : </b> ' . $this->phone : '');
if ($this->element_type == 'socpeople') {
$label .= (!empty($contact->address) ? '<br><b>' . $langs->trans('Address') . ' : </b> ' . $contact->address : '');
} else {
$label .= '<br><b>' . $langs->trans('Administrator') . ' : </b> ' . ($user->admin > 0 ? $langs->trans('Yes') : $langs->trans('No'));
$label .= '<br><b>' . $langs->trans('Type') . ' : </b> ' . ($user->employee > 0 ? $langs->trans('InternalUser') : $langs->trans('ExternalUser'));
}

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';
}
}

$linkclose = '';
if (empty($notooltip)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$label = $langs->trans('Show' . ucfirst($this->element));
$linkclose .= ' alt="' . dol_escape_htmltag($label, 1) . '"';
}
$linkclose .= ' title="' . dol_escape_htmltag($label, 1) . '"';
$linkclose .= ' class="classfortooltip' . ($morecss ? ' ' . $morecss : '') . '"';
} else {
$linkclose = ($morecss ? ' class="' . $morecss . '"' : '');
}

if ($option == 'nolink') {
$linkstart = '<span';
} else {
$linkstart = '<a href="' . $url . '"';
}
if ($option == 'blank') {
$linkstart .= 'target=_blank';
}
$linkstart .= $linkclose . '>';
if ($option == 'nolink' || empty($url)) {
$linkend = '</span>';
} else {
$linkend = '</a>';
}

$result .= $linkstart;

if ($withpicto > 0) {
$result .= img_picto('', $picto) . ' ';
} else {
if (!empty($this->gender)) {
$picto = '<!-- picto photo user --><span class="nopadding userimg' . ($morecss ? ' '.$morecss : '') . '">' . Form::showphoto('userphoto', $this, 0, 0, 0, 'userphotosmall', 'mini', 0, 1) . '</span>';
$result .= $picto;
} else {
$result .= img_picto('', $picto) . ' ';
}
}

if ($withpicto != 2) {
$result .= (!empty($this->civility) ? $this->civility . ' ' : '') . $this->lastname . ' ' . $this->firstname;
}

$result .= $linkend;

if ($withpicto != 2) {
$result .= (($addLabel && property_exists($this, 'label')) ? '<span class="opacitymedium">' . ' - ' . dol_trunc($this->label, ($addLabel > 1 ? $addLabel : 0)) . '</span>' : '');
}

$hookmanager->initHooks([$this->element . 'dao']);
$parameters = ['id' => $this->id, 'getnomurl' => $result];
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks.
if ($reshook > 0) {
$result = $hookmanager->resPrint;
} else {
$result .= $hookmanager->resPrint;
}

return $result;
}
}
23 changes: 5 additions & 18 deletions core/tpl/attendants/attendants_table_view.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
}
print '<td class="center">' . $langs->trans('SignatureLink') . '</td>';
print '<td class="center">' . $langs->trans('SendMailDate') . '</td>';
print '<td class="' . ($conf->browser->layout != 'classic' ? 'hidden': '') .'">' . $langs->trans('SignatureDate') . '</td>';
print '<td class="' . ($conf->browser->layout != 'classic' ? 'hidden': '') . '">' . $langs->trans('SignatureDate') . '</td>';
print '<td class="center">' . $langs->trans('Status') . '</td>';
print '<td class="center">' . $langs->trans('Attendance') . '</td>';
print '<td class="center">' . $langs->trans('SignatureActions') . '</td>';
Expand Down Expand Up @@ -77,22 +77,9 @@
}
}
print '</td><td>';
if ($element->element_type == 'user') {
$usertmp->fetch($element->element_id);
print $usertmp->getNomUrl(1, ($conf->browser->layout != 'classic' ? 'nolink': ''), 0, 0, 24, 1);
if (!empty($usertmp->job)) {
print ' - ' . $usertmp->job;
}
} else {
$contact->fetch($element->element_id);
if ($conf->browser->layout != 'classic') {
print img_picto('', 'company') . ' ' . $contact->getFullName($langs, 1);
} else {
print $contact->getNomUrl(1);
}
if (!empty($contact->job)) {
print ' - ' . $contact->job;
}
print $element->getNomUrl(-1, 'blank');
if (!empty($element->job)) {
print ' - ' . $element->job;
}
if ($attendantTableMode == 'simple') {
print '</td><td class="center ' . ($conf->browser->layout != 'classic' && $object->status > $object::STATUS_DRAFT ? 'hidden': '') . '">';
Expand All @@ -109,7 +96,7 @@
}
print '</td><td class="center">';
if ($object->status == $object::STATUS_VALIDATED && $element->signature == '') {
if (dol_strlen($element->email) || dol_strlen($usertmp->email) || dol_strlen($contact->email)) {
if (dol_strlen($element->email)) {
print dol_print_date($element->last_email_sent_date, 'dayhour', 'tzuser');
require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php';
$nbEmailSent = 0;
Expand Down
1 change: 1 addition & 0 deletions sql/signature/llx_saturne_object_signature.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ CREATE TABLE llx_saturne_object_signature(
import_key varchar(14),
status integer NOT NULL,
role varchar(255),
gender varchar(10),
civility varchar(6),
firstname varchar(255),
lastname varchar(255),
Expand Down
3 changes: 2 additions & 1 deletion sql/update.sql
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ DROP TABLE `llx_digiriskdolibarr_digiriskdocuments_extrafields`;
ALTER TABLE `llx_saturne_object_documents` CHANGE json json longtext;

-- 1.6.0
ALTER TABLE `llx_saturne_object_signature` ADD `civility` VARCHAR(6) AFTER `role`;
ALTER TABLE `llx_saturne_object_signature` ADD `gender` VARCHAR(10) AFTER `role`;
ALTER TABLE `llx_saturne_object_signature` ADD `civility` VARCHAR(6) AFTER `gender`;
ALTER TABLE `llx_saturne_object_signature` ADD `job` VARCHAR(128) AFTER `lastname`;
ALTER TABLE `llx_saturne_object_signature` ADD `json` longtext NULL AFTER `attendance`;

0 comments on commit f8337b9

Please sign in to comment.