dolibarr  16.0.5
signature.lib.php
1 <?php
27 function showOnlineSignatureUrl($type, $ref)
28 {
29  global $conf, $langs;
30 
31  // Load translation files required by the page
32  $langs->loadLangs(array("payment", "paybox"));
33 
34  $servicename = 'Online';
35 
36  $out = img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans("ToOfferALinkForOnlineSignature", $servicename).'</span><br>';
37  $url = getOnlineSignatureUrl(0, $type, $ref);
38  $out .= '<div class="urllink">';
39  if ($url == $langs->trans("FeatureOnlineSignDisabled")) {
40  $out .= $url;
41  } else {
42  $out .= '<input type="text" id="onlinesignatureurl" class="quatrevingtpercentminusx" value="'.$url.'">';
43  }
44  $out .= '<a class="" href="'.$url.'" target="_blank" rel="noopener noreferrer">'.img_picto('', 'globe', 'class="paddingleft"').'</a>';
45  $out .= '</div>';
46  $out .= ajax_autoselect("onlinesignatureurl", 0);
47  return $out;
48 }
49 
50 
60 function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1)
61 {
62  global $conf, $object, $dolibarr_main_url_root;
63 
64  $ref = str_replace(' ', '', $ref);
65  $out = '';
66 
67  // Define $urlwithroot
68  $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
69  $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
70  //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
71 
72  $urltouse = DOL_MAIN_URL_ROOT;
73  if ($localorexternal) {
74  $urltouse = $urlwithroot;
75  }
76 
77  $securekeyseed = '';
78 
79  if ($type == 'proposal') {
80  $securekeyseed = isset($conf->global->PROPOSAL_ONLINE_SIGNATURE_SECURITY_TOKEN) ? $conf->global->PROPOSAL_ONLINE_SIGNATURE_SECURITY_TOKEN : '';
81 
82  $out = $urltouse.'/public/onlinesign/newonlinesign.php?source=proposal&ref='.($mode ? '<span style="color: #666666">' : '');
83  if ($mode == 1) {
84  $out .= 'proposal_ref';
85  }
86  if ($mode == 0) {
87  $out .= urlencode($ref);
88  }
89  $out .= ($mode ? '</span>' : '');
90  if ($mode == 1) {
91  $out .= "hash('".$securekeyseed."' + '".$type."' + proposal_ref)";
92  } else {
93  $out .= '&securekey='.dol_hash($securekeyseed.$type.$ref.(empty($conf->multicompany->enabled) ? '' : $object->entity), '0');
94  }
95  /*
96  if ($mode == 1) {
97  $out .= '&hashp=<span style="color: #666666">hash_of_file</span>';
98  } else {
99  include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
100  $propaltmp = new Propal($db);
101  $res = $propaltmp->fetch(0, $ref);
102  if ($res <= 0) {
103  return 'FailedToGetProposal';
104  }
105 
106  include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
107  $ecmfile = new EcmFiles($db);
108 
109  $ecmfile->fetch(0, '', $propaltmp->last_main_doc);
110 
111  $hashp = $ecmfile->share;
112  if (empty($hashp)) {
113  $out = $langs->trans("FeatureOnlineSignDisabled");
114  return $out;
115  } else {
116  $out .= '&hashp='.$hashp;
117  }
118  }*/
119  }
120 
121  // For multicompany
122  if (!empty($out) && !empty($conf->multicompany->enabled)) {
123  $out .= "&entity=".$object->entity; // Check the entity because we may have the same reference in several entities
124  }
125 
126  return $out;
127 }
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3866
ajax_autoselect
ajax_autoselect($htmlname, $addlink='', $textonlink='Link')
Make content of an input box selected when we click into input field.
Definition: functions.lib.php:9667