Skip to content

Commit

Permalink
[DigiriskSignature] add : send action
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-eoxia committed Jul 12, 2021
1 parent 8f23646 commit 8700a76
Show file tree
Hide file tree
Showing 8 changed files with 255 additions and 60 deletions.
30 changes: 20 additions & 10 deletions class/digirisksignature.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,18 @@ public function delete(User $user, $notrigger = false)
* @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
* @return int <0 if KO, >0 if OK
*/
public function setPendingSignature($user, $notrigger = 0)
{
return $this->setStatusCommon($user, self::STATUS_PENDING_SIGNATURE, $notrigger, 'DIGIRISKSIGNATURE_PENDING_SIGNATURE');
}

/**
* Set draft status
*
* @param User $user Object user that modify
* @param int $notrigger 1=Does not execute triggers, 0=Execute triggers
* @return int <0 if KO, >0 if OK
*/
public function setSigned($user, $notrigger = 0)
{
return $this->setStatusCommon($user, self::STATUS_SIGNED, $notrigger, 'DIGIRISKSIGNATURE_SIGNED');
Expand Down Expand Up @@ -409,17 +421,19 @@ public function LibStatut($status, $mode = 0)
{
global $langs;
//$langs->load("digiriskdolibarr@digiriskdolibarr");
$this->labelStatus[self::STATUS_DELETED] = $langs->trans('Deleted');
$this->labelStatus[self::STATUS_REGISTERED] = $langs->trans('Registered');
$this->labelStatus[self::STATUS_SIGNATURE_REQUEST] = $langs->trans('SignatureRequest');
$this->labelStatus[self::STATUS_PENDING_SIGNATURE] = $langs->trans('PendingSignature');
$this->labelStatusShort[self::STATUS_DENIED] = $langs->trans('Denied');
$this->labelStatusShort[self::STATUS_SIGNED] = $langs->trans('Signed');
$this->labelStatusShort[self::STATUS_UNSIGNED] = $langs->trans('Unsigned');
$this->labelStatusShort[self::STATUS_ABSENT] = $langs->trans('Absent');
$this->labelStatusShort[self::STATUS_JUSTIFIED_ABSENT] = $langs->trans('JustifiedAbsent');
$this->labelStatus[self::STATUS_DENIED] = $langs->trans('Denied');
$this->labelStatus[self::STATUS_SIGNED] = $langs->trans('Signed');
$this->labelStatus[self::STATUS_UNSIGNED] = $langs->trans('Unsigned');
$this->labelStatus[self::STATUS_ABSENT] = $langs->trans('Absent');
$this->labelStatus[self::STATUS_JUSTIFIED_ABSENT] = $langs->trans('JustifiedAbsent');
}

$statusType = 'status'.$status;
if ($status == self::STATUS_SIGNED) $statusType = 'status4';
if ($status == self::STATUS_ABSENT) $statusType = 'status8';

return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
Expand Down Expand Up @@ -500,19 +514,15 @@ function setSignatory($fk_object, $element_type, $element_ids, $role = "")
*/
function fetchSignatory($role = "", $fk_object)
{
$filter = array('fk_object' => $fk_object, 'status' => 1);
$filter = array('customsql' => ' role="' . $role . '" AND fk_object=' . $fk_object . ' AND status!=0');
if (strlen($role)) {
$filter['role'] = $role;

return $this->fetchAll('', '', 0, 0, $filter, 'AND');
} else {

$signatories = $this->fetchAll('', '', 0, 0, $filter, 'AND');
if (!empty ($signatories) && $signatories > 0) {
foreach($signatories as $signatory) {
$signatoriesArray[$signatory->role][$signatory->id] = $signatory;
}

return $signatoriesArray;
} else {
return 0;
Expand Down
21 changes: 21 additions & 0 deletions core/tpl/digiriskdolibarr_signature_action_view.tpl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<div class="wpeo-dropdown">
<div class="dropdown-toggle wpeo-button button-main"><span><?php echo $langs->trans('ActionsSignature'); ?></span> <i class="fas fa-caret-down"></i></div>
<ul class="dropdown-content">
<li class="dropdown-item"></li>
<li class="dropdown-item">
<div class="signature-absent wpeo-button button-primary" value="<?php echo $element->id ?>">
<span><?php echo $langs->trans('Absent'); ?></span>
</div>
</li>
<li class="dropdown-item">
<div class="signature-email wpeo-button button-primary" value="<?php echo $element->id ?>">
<span><i class="fas fa-at"></i> <?php echo $langs->trans('SendEmail'); ?></span>
</div>
</li>
</ul>
</div>





23 changes: 3 additions & 20 deletions core/tpl/digiriskdolibarr_signature_view.tpl.php
Original file line number Diff line number Diff line change
@@ -1,25 +1,6 @@
<div class="wpeo-dropdown">
<div class="dropdown-toggle wpeo-button button-main"><span>Label</span><i class="button-icon fas fa-caret-down"></i></div>
<ul class="dropdown-content">
<li class="dropdown-item">envoyer mail

</li>
<li class="dropdown-item">
<div class="signature-absent wpeo-button button-primary" value="<?php echo $element->id ?>">
<span><?php echo $langs->trans('Absent'); ?></span>
</div>
</li>
<li class="dropdown-item">
<div class="signature-email wpeo-button button-primary" value="<?php echo $element->id ?>">
<span><?php echo $langs->trans('SendEmail'); ?></span>
</div>
</li>
</ul>
</div>

<?php if (empty($element->signature)) : ?>
<div class="wpeo-button button-blue wpeo-modal-event modal-signature-open modal-open" value="<?php echo $element->id ?>">
<span><?php echo $langs->trans('Sign'); ?></span>
<span><i class="fas fa-signature"></i> <?php echo $langs->trans('Sign'); ?></span>
</div>
<?php else : ?>
<img class="wpeo-modal-event modal-signature-open modal-open" value="<?php echo $element->id ?>" src='<?php echo $element->signature ?>' width="100px" height="100px" style="border: #0b419b solid 2px">
Expand Down Expand Up @@ -47,6 +28,8 @@
<span><?php echo $langs->trans('Cancel'); ?></span>
</div>
<div class="signature-validate wpeo-button button-primary" value="<?php echo $element->id ?>">
<input type="hidden" id="redirect<?php echo $element->id ?>" value="<?php echo $url ?>">
<input type="hidden" id="zone<?php echo $element->id ?>" value="<?php echo $zone ?>">
<span><?php echo $langs->trans('Validate'); ?></span>
</div>
</div>
Expand Down
37 changes: 35 additions & 2 deletions js/digiriskdolibarr.js.php
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,7 @@
jQuery( document ).on( 'click', '.signature-erase', window.eoxiaJS.signature.clearCanvas );
jQuery( document ).on( 'click', '.signature-validate', window.eoxiaJS.signature.createSignature );
jQuery( document ).on( 'click', '.signature-absent', window.eoxiaJS.signature.setAbsent );
jQuery( document ).on( 'click', '.signature-email', window.eoxiaJS.signature.sendEmail );
};

window.eoxiaJS.signature.modalSignatureOpened = function( triggeredElement ) {
Expand Down Expand Up @@ -866,6 +867,7 @@
window.eoxiaJS.signature.createSignature = function() {
let elementSignatory = $(this).attr('value');
let elementRedirect = $(this).find('#redirect' + elementSignatory).attr('value');
let elementZone = $(this).find('#zone' + elementSignatory).attr('value');

var signatoryIDPost = '';
if (elementSignatory !== 0) {
Expand All @@ -876,9 +878,19 @@
var signature = $(this).closest( '.wpeo-modal' ).find( 'canvas' )[0].toDataURL();
}

var url = '';
var type = '';
if (elementZone == "private") {
url = document.URL + '&action=addSignature' + signatoryIDPost;
type = "POST"
} else {
url = document.URL + '?action=addSignature' + signatoryIDPost;
type = "GET";
}

$.ajax({
url: document.URL + '?action=addSignature' + signatoryIDPost,
type: "POST",
url: url,
type: type,
processData: false,
contentType: 'application/octet-stream',
data: signature,
Expand All @@ -903,6 +915,27 @@
type: "POST",
processData: false,
contentType: false,
success: function() {
window.location.reload();
},
error: function ( ) {
}
});
};

window.eoxiaJS.signature.sendEmail = function() {
let elementSignatory = $(this).attr('value');

var signatoryIDPost = '';
if (elementSignatory !== 0) {
signatoryIDPost = '&signatoryID=' + elementSignatory;
}

$.ajax({
url: document.URL + '&action=send' + signatoryIDPost,
type: "POST",
processData: false,
contentType: false,
success: function() {
//window.location.reload();
},
Expand Down
11 changes: 11 additions & 0 deletions langs/fr_FR/digiriskdolibarr.lang
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ PreventionPlanDocumentGeneratedWithDolibarr = Plan de prévention généré avec
# Data - Donnée

PreventionPlan = Plan de prévention
PreventionPlanList = Liste des plans de prévention
PreventionPlanLine = risque(s)
PriorVisit = Visite préliminaire
PriorVisitYesNo = Visite préliminaire effectuée
Expand All @@ -302,6 +303,7 @@ Schedule = Horaires
PreventionPlanSchedule = Horaires du plan de prévention
SelectUser = Sélectionner un utilisateur
Attendants = Participants
ModifyPreventionPlan = Modifier le plan de prévention

#
# FirePermit - Permis de feu
Expand Down Expand Up @@ -744,8 +746,17 @@ Signed = Signé
Unsigned = Non signé
Absent = Absent
JustifiedAbsent = Absence justifiée
SignatureDate = Date de signature
PublicID = ID pubic
ActionsSignature = Actions
SendEmail = Envoyer un email
WelcomeOnOnlineSignaturePage = Bienvenue sur la page de signature des documents
ThisIsInformationOnDocumentToSign = Voici les informations sur le document a signé
DigiriskSignature = Signature Digirisk
SignaturePublicAccess = Une interface publique ne nécessitant aucune identification est disponible à l'url suivante
SignatureActivatePublicInterface = Activer l'interface publique
SignatureShowCompanyLogo = Afficher le logo de la société dans l'interface publique
SignatureShowCompanyLogoHelp = Activez cette option pour masquer le logo de la société dans les pages de l'interface publique

#
# Ticket - Interface publique ticket
Expand Down
23 changes: 23 additions & 0 deletions lib/digiriskdolibarr_function.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1112,3 +1112,26 @@ function llxHeaderSignature($title, $head = "", $disablejs = 0, $disablehead = 0

print '</div>';
}

/**
* Return string with full Url. The file qualified is the one defined by relative path in $object->last_main_doc
*
* @param Object $object Object
* @return string Url string
*/
function showDirectPublicLinkSignature($object)
{
global $conf, $langs;

$url = dol_buildpath('/custom/digiriskdolibarr/public/signature/index.php', 3);

$out = '';
if (empty($conf->global->DIGIRISKDOLIBARR_SIGNATURE_ENABLE_PUBLIC_INTERFACE)) {
$out .= '<span class="opacitymedium">'.$langs->trans("PublicInterfaceNotEnabled").'</span>';
} else {
$out .= img_picto('', 'object_globe.png').' '.$langs->trans("SignaturePublicAccess").' :<br>';
$out .= '<a href="'.$url.'" target="_blank">'.$url.'</a>';
}

return $out;
}
Loading

0 comments on commit 8700a76

Please sign in to comment.