dolibarr  16.0.5
signature.lib.php
1 <?php
28 function showOnlineSignatureUrl($type, $ref, $obj = null)
29 {
30  global $conf, $langs;
31 
32  // Load translation files required by the page
33  $langs->loadLangs(array("payment", "paybox"));
34 
35  $servicename = 'Online';
36 
37  $out = img_picto('', 'globe').' <span class="opacitymedium">'.$langs->trans("ToOfferALinkForOnlineSignature", $servicename).'</span><br>';
38  $url = getOnlineSignatureUrl(0, $type, $ref, $obj);
39  $out .= '<div class="urllink">';
40  if ($url == $langs->trans("FeatureOnlineSignDisabled")) {
41  $out .= $url;
42  } else {
43  $out .= '<input type="text" id="onlinesignatureurl" class="quatrevingtpercentminusx" value="'.$url.'">';
44  }
45  $out .= '<a class="" href="'.$url.'" target="_blank" rel="noopener noreferrer">'.img_picto('', 'globe', 'class="paddingleft"').'</a>';
46  $out .= '</div>';
47  $out .= ajax_autoselect("onlinesignatureurl", 0);
48  return $out;
49 }
50 
51 
62 function getOnlineSignatureUrl($mode, $type, $ref = '', $localorexternal = 1, $obj = null)
63 {
64  global $conf, $dolibarr_main_url_root;
65 
66  if (empty($obj)) {
67  // For compatibility with 15.0 -> 19.0
68  global $object;
69  if (empty($object)) {
70  $obj = new stdClass();
71  } else {
72  dol_syslog(__METHOD__." using global object is deprecated, please give obj as argument", LOG_WARNING);
73  $obj = $object;
74  }
75  }
76 
77  $ref = str_replace(' ', '', $ref);
78  $out = '';
79 
80  // Define $urlwithroot
81  $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
82  $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
83  //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
84 
85  $urltouse = DOL_MAIN_URL_ROOT;
86  if ($localorexternal) {
87  $urltouse = $urlwithroot;
88  }
89 
90  $securekeyseed = '';
91 
92  if ($type == 'proposal') {
93  $securekeyseed = getDolGlobalString('PROPOSAL_ONLINE_SIGNATURE_SECURITY_TOKEN');
94 
95  $out = $urltouse.'/public/onlinesign/newonlinesign.php?source=proposal&ref='.($mode ? '<span style="color: #666666">' : '');
96  if ($mode == 1) {
97  $out .= 'proposal_ref';
98  }
99  if ($mode == 0) {
100  $out .= urlencode($ref);
101  }
102  $out .= ($mode ? '</span>' : '');
103  if ($mode == 1) {
104  $out .= "hash('".$securekeyseed."' + '".$type."' + proposal_ref)";
105  } else {
106  $out .= '&securekey='.dol_hash($securekeyseed.$type.$ref.(empty($conf->multicompany->enabled) ? '' : $obj->entity), '0');
107  }
108  /*
109  if ($mode == 1) {
110  $out .= '&hashp=<span style="color: #666666">hash_of_file</span>';
111  } else {
112  include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
113  $propaltmp = new Propal($db);
114  $res = $propaltmp->fetch(0, $ref);
115  if ($res <= 0) {
116  return 'FailedToGetProposal';
117  }
118 
119  include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
120  $ecmfile = new EcmFiles($db);
121 
122  $ecmfile->fetch(0, '', $propaltmp->last_main_doc);
123 
124  $hashp = $ecmfile->share;
125  if (empty($hashp)) {
126  $out = $langs->trans("FeatureOnlineSignDisabled");
127  return $out;
128  } else {
129  $out .= '&hashp='.$hashp;
130  }
131  }*/
132  }
133 
134  // For multicompany
135  if (!empty($out) && !empty($conf->multicompany->enabled)) {
136  $out .= "&entity=".((int) $obj->entity); // Check the entity of object because we may have the same reference in several entities
137  }
138 
139  return $out;
140 }
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:3880
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1603
getDolGlobalString
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
Definition: functions.lib.php:80
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:9681