mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-08 00:52:01 +01:00
Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
@@ -480,6 +480,13 @@ print $form->textwithpicto($langs->trans("WatermarkOnDraftContractCards"), $html
|
||||
print '<input class="flat minwidth200" type="text" name="SHIPPING_DRAFT_WATERMARK" value="'.dol_escape_htmltag(getDolGlobalString('SHIPPING_DRAFT_WATERMARK')).'">';
|
||||
print "</td></tr>\n";
|
||||
|
||||
// Allow OnLine Sign
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("AllowOnLineSign").'</td>';
|
||||
print '<td class="center">';
|
||||
print ajax_constantonoff('EXPEDITION_ALLOW_ONLINESIGN', array(), null, 0, 0, 0, 2, 0, 1);
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print $form->buttonsSaveCancel("Modify", '');
|
||||
|
||||
@@ -102,6 +102,12 @@ if ($action == 'add' && !empty($permissiontoadd)) {
|
||||
$value = GETPOST($key, $tmparray[1]);
|
||||
} else {
|
||||
$value = GETPOST($key, 'nohtml');
|
||||
if (!empty($object->fields[$key]['arrayofkeyval']) && !empty($object->fields[$key]['multiinput'])) {
|
||||
$tmparraymultiselect = GETPOST($key.'_multiselect', 'array');
|
||||
foreach ($tmparraymultiselect as $tmpvalue) {
|
||||
$value .= (!empty($value) ? "," : "").$tmpvalue;
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif (preg_match('/^html/', $object->fields[$key]['type'])) {
|
||||
$tmparray = explode(':', $object->fields[$key]['type']);
|
||||
@@ -255,6 +261,12 @@ if ($action == 'update' && !empty($permissiontoadd)) {
|
||||
$value = GETPOST($key, $tmparray[1]);
|
||||
} else {
|
||||
$value = GETPOST($key, 'nohtml');
|
||||
if (!empty($object->fields[$key]['arrayofkeyval']) && !empty($object->fields[$key]['multiinput'])) {
|
||||
$tmparraymultiselect = GETPOST($key.'_multiselect', 'array');
|
||||
foreach ($tmparraymultiselect as $keytmp => $tmpvalue) {
|
||||
$value .= (!empty($value) ? "," : "").$tmpvalue;
|
||||
}
|
||||
}
|
||||
}
|
||||
} elseif (preg_match('/^html/', $object->fields[$key]['type'])) {
|
||||
$tmparray = explode(':', $object->fields[$key]['type']);
|
||||
|
||||
110
htdocs/core/ajax/editinline.php
Normal file
110
htdocs/core/ajax/editinline.php
Normal file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/ajax/editinline.php
|
||||
* \brief Save edit inline changes
|
||||
*/
|
||||
|
||||
|
||||
if (!defined('NOTOKENRENEWAL')) {
|
||||
define('NOTOKENRENEWAL', '1'); // Disables token renewal
|
||||
}
|
||||
if (!defined('NOREQUIREMENU')) {
|
||||
define('NOREQUIREMENU', '1');
|
||||
}
|
||||
if (!defined('NOREQUIREAJAX')) {
|
||||
define('NOREQUIREAJAX', '1');
|
||||
}
|
||||
if (!defined('NOREQUIRESOC')) {
|
||||
define('NOREQUIRESOC', '1');
|
||||
}
|
||||
|
||||
// Load Dolibarr environment
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/website2.lib.php';
|
||||
|
||||
|
||||
$action = GETPOST('action', 'alpha');
|
||||
$website_ref = GETPOST('website_ref');
|
||||
$page_id = GETPOST('page_id');
|
||||
$content = GETPOST('content', 'none');
|
||||
$element_id = GETPOST('element_id');
|
||||
$element_type = GETPOST('element_type');
|
||||
|
||||
$usercanmodify = $user->hasRight('website', 'write');
|
||||
if (!$usercanmodify) {
|
||||
print "You don't have permission for this action.";
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
top_httphead();
|
||||
|
||||
if (!empty($action) && $action === 'updatedElementContent' && $usercanmodify && !empty($content) && !empty($element_id) && !empty($website_ref) && !empty($page_id)) {
|
||||
// Page object
|
||||
$objectpage = new WebsitePage($db);
|
||||
$res = $objectpage->fetch($page_id);
|
||||
if (!$res) {
|
||||
print "Cannot find page with ID = " . $page_id . ".";
|
||||
exit;
|
||||
}
|
||||
|
||||
// Website object
|
||||
$objectwebsite = new Website($db);
|
||||
$res = $objectwebsite->fetch($objectpage->fk_website);
|
||||
if (!$res) {
|
||||
print "Cannot find website with REF " . $objectpage->fk_website . ".";
|
||||
exit;
|
||||
}
|
||||
|
||||
$db->begin();
|
||||
$error = 0;
|
||||
|
||||
// Replace element content into database and tpl file
|
||||
$objectpage->content = preg_replace('/<' . $element_type . '[^>]*id="' . $element_id . '"[^>]*>\K(.*?)(?=<\/' . $element_type . '>)/s', $content, $objectpage->content, 1);
|
||||
$res = $objectpage->update($user);
|
||||
if ($res) {
|
||||
global $dolibarr_main_data_root;
|
||||
$pathofwebsite = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$website_ref;
|
||||
$filetpl = $pathofwebsite.'/page'.$objectpage->id.'.tpl.php';
|
||||
|
||||
$result = dolSavePageContent($filetpl, $objectwebsite, $objectpage, 1);
|
||||
if (!$result) {
|
||||
print "Failed to write file " . $filetpl . ".";
|
||||
$error++;
|
||||
}
|
||||
} else {
|
||||
print "Failed to save changes error " . $objectpage->error . ".";
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$db->commit();
|
||||
print "Changes are saved for " . $element_type . " with id " . $element_id;
|
||||
} else {
|
||||
$db->rollback();
|
||||
}
|
||||
|
||||
$db->close();
|
||||
}
|
||||
@@ -678,6 +678,152 @@ if ($action == "importSignature") {
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
} elseif ($mode == 'expedition') {
|
||||
require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/pdf.lib.php';
|
||||
|
||||
$object = new Expedition($db);
|
||||
$object->fetch(0, $ref);
|
||||
|
||||
$upload_dir = $conf->expedition->dir_output."/sending/";
|
||||
$upload_dir .= '/'.dol_sanitizeFileName($object->ref).'/';
|
||||
|
||||
$langs->loadLangs(array("main", "companies"));
|
||||
|
||||
$default_font_size = pdf_getPDFFontSize($langs); // Must be after pdf_getInstance
|
||||
$default_font = pdf_getPDFFont($langs); // Must be
|
||||
|
||||
$date = dol_print_date(dol_now(), "%Y%m%d%H%M%S");
|
||||
$filename = "signatures/" . $date . "_signature.png";
|
||||
if (!is_dir($upload_dir . "signatures/")) {
|
||||
if (!dol_mkdir($upload_dir . "signatures/")) {
|
||||
$response = "Error mkdir. Failed to create dir " . $upload_dir . "signatures/";
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$return = file_put_contents($upload_dir . $filename, $data);
|
||||
if ($return == false) {
|
||||
$error++;
|
||||
$response = 'Error file_put_content: failed to create signature file.';
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$last_main_doc_file = $object->last_main_doc;
|
||||
// Defined modele of doc
|
||||
if (empty($last_main_doc_file) || !dol_is_file(DOL_DATA_ROOT.'/'.$object->last_main_doc)) {
|
||||
// It seems document has never been generated, or was generated and then deleted.
|
||||
// So we try to regenerate it with its default template.
|
||||
$defaulttemplate = ''; // We force the use an empty string instead of $object->model_pdf to be sure to use a "main" default template and not the last one used.
|
||||
$object->generateDocument($defaulttemplate, $langs);
|
||||
}
|
||||
$last_main_doc_file = $object->last_main_doc;
|
||||
$directdownloadlink = $object->getLastMainDocLink('expedition'); // url to download the $object->last_main_doc
|
||||
if (preg_match('/\.pdf/i', $last_main_doc_file)) {
|
||||
// TODO Use the $last_main_doc_file to defined the $newpdffilename and $sourcefile
|
||||
$newpdffilename = $upload_dir . $ref . "_signed-" . $date . ".pdf";
|
||||
$sourcefile = $upload_dir . $ref . ".pdf";
|
||||
|
||||
|
||||
if (dol_is_file($sourcefile)) {
|
||||
// We build the new PDF
|
||||
$pdf = pdf_getInstance();
|
||||
if (class_exists('TCPDF')) {
|
||||
$pdf->setPrintHeader(false);
|
||||
$pdf->setPrintFooter(false);
|
||||
}
|
||||
$pdf->SetFont(pdf_getPDFFont($langs));
|
||||
|
||||
if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
|
||||
$pdf->SetCompression(false);
|
||||
}
|
||||
|
||||
//$pdf->Open();
|
||||
$pagecount = $pdf->setSourceFile($sourcefile); // original PDF
|
||||
|
||||
$param = array();
|
||||
$param['online_sign_name'] = $online_sign_name;
|
||||
$param['pathtoimage'] = $upload_dir . $filename;
|
||||
|
||||
$s = array(); // Array with size of each page. Example array(w'=>210, 'h'=>297);
|
||||
for ($i = 1; $i < ($pagecount + 1); $i++) {
|
||||
try {
|
||||
$tppl = $pdf->importPage($i);
|
||||
$s = $pdf->getTemplatesize($tppl);
|
||||
$pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L');
|
||||
$pdf->useTemplate($tppl);
|
||||
|
||||
if (getDolGlobalString("SHIPMENT_SIGNATURE_ON_ALL_PAGES")) {
|
||||
// A signature image file is 720 x 180 (ratio 1/4) but we use only the size into PDF
|
||||
// TODO Get position of box from PDF template
|
||||
|
||||
$param['xforimgstart'] = 111;
|
||||
$param['yforimgstart'] = (empty($s['h']) ? 250 : $s['h'] - 60);
|
||||
$param['wforimg'] = $s['w'] - ($param['xforimgstart'] + 16);
|
||||
|
||||
dolPrintSignatureImage($pdf, $langs, $param);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
dol_syslog("Error when manipulating some PDF by onlineSign: " . $e->getMessage(), LOG_ERR);
|
||||
$response = $e->getMessage();
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (!getDolGlobalString("SHIPMENT_SIGNATURE_ON_ALL_PAGES")) {
|
||||
// A signature image file is 720 x 180 (ratio 1/4) but we use only the size into PDF
|
||||
// TODO Get position of box from PDF template
|
||||
|
||||
$param['xforimgstart'] = 111;
|
||||
$param['yforimgstart'] = (empty($s['h']) ? 250 : $s['h'] - 60);
|
||||
$param['wforimg'] = $s['w'] - ($param['xforimgstart'] + 16);
|
||||
|
||||
dolPrintSignatureImage($pdf, $langs, $param);
|
||||
}
|
||||
|
||||
//$pdf->Close();
|
||||
$pdf->Output($newpdffilename, "F");
|
||||
|
||||
// Index the new file and update the last_main_doc property of object.
|
||||
$object->indexFile($newpdffilename, 1);
|
||||
}
|
||||
if (!$error) {
|
||||
$response = "success";
|
||||
}
|
||||
} elseif (preg_match('/\.odt/i', $last_main_doc_file)) {
|
||||
// Adding signature on .ODT not yet supported
|
||||
// TODO
|
||||
} else {
|
||||
// Document format not supported to insert online signature.
|
||||
// We should just create an image file with the signature.
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$db->begin();
|
||||
|
||||
$sql = "UPDATE " . MAIN_DB_PREFIX . "expedition";
|
||||
$sql .= " SET signed_status = " . ((int) $object::STATUS_SIGNED) ;
|
||||
$sql .= " WHERE rowid = " . ((int) $object->id);
|
||||
|
||||
dol_syslog(__FILE__, LOG_DEBUG);
|
||||
$resql = $db->query($sql);
|
||||
if (!$resql) {
|
||||
$error++;
|
||||
} else {
|
||||
$num = $db->affected_rows($resql);
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$db->commit();
|
||||
$response = "success";
|
||||
setEventMessages("ExpeditionSigned", null, 'warnings');
|
||||
} else {
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$error++;
|
||||
|
||||
@@ -7257,6 +7257,7 @@ abstract class CommonObject
|
||||
$validationClass = ' --success'; // the -- is use as class state in css : .--success can't be be defined alone it must be define with another class like .my-class.--success or input.--success
|
||||
}
|
||||
|
||||
$valuemultiselectinput = array();
|
||||
$out = '';
|
||||
$type = '';
|
||||
$isDependList = 0;
|
||||
@@ -7303,7 +7304,19 @@ abstract class CommonObject
|
||||
// Special case that force options and type ($type can be integer, varchar, ...)
|
||||
if (!empty($this->fields[$key]['arrayofkeyval']) && is_array($this->fields[$key]['arrayofkeyval'])) {
|
||||
$param['options'] = $this->fields[$key]['arrayofkeyval'];
|
||||
$type = (($this->fields[$key]['type'] == 'checkbox') ? $this->fields[$key]['type'] : 'select');
|
||||
// Special case that prevent to force $type to have multiple input
|
||||
if (empty($this->fields[$key]['multiinput'])) {
|
||||
$type = (($this->fields[$key]['type'] == 'checkbox') ? $this->fields[$key]['type'] : 'select');
|
||||
} else {
|
||||
$valuearray = explode(",", $value);
|
||||
foreach ($valuearray as $keytmp => $valuetmp) {
|
||||
if (!empty($this->fields[$key]['arrayofkeyval'][$valuetmp])) {
|
||||
$valuemultiselectinput[] = $valuetmp;
|
||||
unset($valuearray[$keytmp]);
|
||||
}
|
||||
}
|
||||
$value = implode(',', $valuearray);
|
||||
}
|
||||
}
|
||||
|
||||
$label = $this->fields[$key]['label'];
|
||||
@@ -7403,9 +7416,13 @@ abstract class CommonObject
|
||||
$out = '<input type="text" class="flat '.$morecss.'" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam ? $moreparam : '').($autofocusoncreate ? ' autofocus' : '').'>';
|
||||
} elseif (preg_match('/^text/', (string) $type)) {
|
||||
if (!preg_match('/search_/', $keyprefix)) { // If keyprefix is search_ or search_options_, we must just use a simple text field
|
||||
if (!empty($param['options'])) {
|
||||
$out .= "<br>";
|
||||
$out .= $form->multiselectarray($keyprefix.$key.$keysuffix."_multiselect", $param['options'], (GETPOSTISSET($keyprefix.$key.$keysuffix."_multiselect") ? GETPOST($keyprefix.$key.$keysuffix."_multiselect") : $valuemultiselectinput), 0, 0, "flat maxwidthonphone".$morecss, 0, '90%', '', '', '', ((!empty($conf->use_javascript_ajax) && !getDolGlobalString('MAIN_EXTRAFIELDS_DISABLE_SELECT2')) ? 1 : -1));
|
||||
}
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
$doleditor = new DolEditor($keyprefix.$key.$keysuffix, $value, '', 200, 'dolibarr_notes', 'In', false, false, false, ROWS_5, '90%');
|
||||
$out = (string) $doleditor->Create(1, '', true, '', '', '', $morecss);
|
||||
$out .= (string) $doleditor->Create(1, '', true, '', '', '', $morecss);
|
||||
} else {
|
||||
$out = '<input type="text" class="flat '.$morecss.' maxwidthonsmartphone" name="'.$keyprefix.$key.$keysuffix.'" id="'.$keyprefix.$key.$keysuffix.'" value="'.dol_escape_htmltag($value).'" '.($moreparam ? $moreparam : '').'>';
|
||||
}
|
||||
@@ -7965,7 +7982,9 @@ abstract class CommonObject
|
||||
$type = 'varchar'; // convert varchar(xx) int varchar
|
||||
}
|
||||
if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) {
|
||||
$type = (($this->fields[$key]['type'] == 'checkbox') ? $this->fields[$key]['type'] : 'select');
|
||||
if (empty($this->fields[$key]['multiinput'])) {
|
||||
$type = (($this->fields[$key]['type'] == 'checkbox') ? $this->fields[$key]['type'] : 'select');
|
||||
}
|
||||
}
|
||||
if (preg_match('/^integer:(.*):(.*)/i', $val['type'], $reg)) {
|
||||
$type = 'link';
|
||||
|
||||
@@ -890,7 +890,11 @@ class FormFile
|
||||
} else {
|
||||
$out .= '<span class="spanoverflow">';
|
||||
}
|
||||
$out .= '<a class="documentdownload paddingright" href="'.$documenturl.'?modulepart='.$modulepart.'&file='.urlencode($relativepath).($param ? '&'.$param : '').'"';
|
||||
$out .= '<a class="documentdownload paddingright" ';
|
||||
if (getDolGlobalInt('MAIN_DISABLE_FORCE_SAVEAS') == 2) {
|
||||
$out .= 'target="_blank" ';
|
||||
}
|
||||
$out .= 'href="'.$documenturl.'?modulepart='.$modulepart.'&file='.urlencode($relativepath).($param ? '&'.$param : '').'"';
|
||||
|
||||
$mime = dol_mimetype($relativepath, '', 0);
|
||||
if (preg_match('/text/', $mime)) {
|
||||
@@ -1081,8 +1085,8 @@ class FormFile
|
||||
$out .= '<!-- html.formfile::getDocumentsLink -->'."\n";
|
||||
if (!empty($file_list)) {
|
||||
$out = '<dl class="dropdown inline-block">
|
||||
<dt><a data-ajax="false" href="#" onClick="return false;">'.img_picto('', 'listlight', '', 0, 0, 0, '', $morecss).'</a></dt>
|
||||
<dd><div class="multichoicedoc" style="position:absolute;left:100px;" ><ul class="ulselectedfields">';
|
||||
<dt><a data-ajax="false" href="#" onClick="return false;">'.img_picto('', 'listlight', '', 0, 0, 0, '', $morecss).'</a></dt>
|
||||
<dd><div class="multichoicedoc" style="position:absolute;left:100px;" ><ul class="ulselectedfields">';
|
||||
$tmpout = '';
|
||||
|
||||
// Loop on each file found
|
||||
@@ -1129,7 +1133,11 @@ class FormFile
|
||||
}
|
||||
|
||||
// Download
|
||||
$tmpout .= '<li class="nowrap"><a class="pictopreview nowrap" href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($relativepath).'"';
|
||||
$tmpout .= '<li class="nowrap"><a class="pictopreview nowrap" ';
|
||||
if (getDolGlobalInt('MAIN_DISABLE_FORCE_SAVEAS') == 2) {
|
||||
$tmpout .= 'target="_blank" ';
|
||||
}
|
||||
$tmpout .= 'href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($relativepath).'"';
|
||||
$mime = dol_mimetype($relativepath, '', 0);
|
||||
if (preg_match('/text/', $mime)) {
|
||||
$tmpout .= ' target="_blank" rel="noopener noreferrer"';
|
||||
@@ -1141,7 +1149,7 @@ class FormFile
|
||||
}
|
||||
$out .= $tmpout;
|
||||
$out .= '</ul></div></dd>
|
||||
</dl>';
|
||||
</dl>';
|
||||
|
||||
if (!$found) {
|
||||
$out = '';
|
||||
@@ -1373,7 +1381,11 @@ class FormFile
|
||||
|
||||
// Show file name with link to download
|
||||
//print "XX".$file['name']; //$file['name'] must be utf8
|
||||
print '<a class="paddingright valignmiddle" href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart;
|
||||
print '<a class="paddingright valignmiddle" ';
|
||||
if (getDolGlobalInt('MAIN_DISABLE_FORCE_SAVEAS') == 2) {
|
||||
print 'target="_blank" ';
|
||||
}
|
||||
print 'href="'.DOL_URL_ROOT.'/document.php?modulepart='.$modulepart;
|
||||
if ($forcedownload) {
|
||||
print '&attachment=1';
|
||||
}
|
||||
@@ -1949,7 +1961,11 @@ class FormFile
|
||||
// Check if document source has external module part, if it the case use it for module part on document.php
|
||||
print '<td>';
|
||||
//print "XX".$file['name']; //$file['name'] must be utf8
|
||||
print '<a href="'.DOL_URL_ROOT.'/document.php?modulepart='.urlencode($modulepart);
|
||||
print '<a ';
|
||||
if (getDolGlobalInt('MAIN_DISABLE_FORCE_SAVEAS') == 2) {
|
||||
print 'target="_blank" ';
|
||||
}
|
||||
print 'href="'.DOL_URL_ROOT.'/document.php?modulepart='.urlencode($modulepart);
|
||||
if ($forcedownload) {
|
||||
print '&attachment=1';
|
||||
}
|
||||
|
||||
@@ -2743,6 +2743,14 @@ if ($action == 'create') {
|
||||
$linktoelem = $form->showLinkToObjectBlock($object, null, array('shipping'));
|
||||
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
|
||||
|
||||
// Show online signature link
|
||||
$useonlinesignature = getDolGlobalInt('EXPEDITION_ALLOW_ONLINESIGN');
|
||||
|
||||
if ($object->statut != Expedition::STATUS_DRAFT && $useonlinesignature) {
|
||||
print '<br><!-- Link to sign -->';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/signature.lib.php';
|
||||
print showOnlineSignatureUrl('expedition', $object->ref, $object).'<br>';
|
||||
}
|
||||
|
||||
print '</div><div class="fichehalfright">';
|
||||
|
||||
|
||||
@@ -224,6 +224,11 @@ class Expedition extends CommonObject
|
||||
public $multicurrency_total_tva;
|
||||
public $multicurrency_total_ttc;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $signed_status = 0;
|
||||
|
||||
/**
|
||||
* Draft status
|
||||
*/
|
||||
@@ -260,6 +265,18 @@ class Expedition extends CommonObject
|
||||
const STATUS_SHIPMENT_IN_PROGRESS = 3;
|
||||
|
||||
|
||||
/**
|
||||
* No signature
|
||||
*/
|
||||
const STATUS_NO_SIGNATURE = 0;
|
||||
|
||||
/**
|
||||
* Signed status
|
||||
*/
|
||||
const STATUS_SIGNED = 1;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@@ -603,6 +620,7 @@ class Expedition extends CommonObject
|
||||
$sql .= ", e.fk_shipping_method, e.tracking_number";
|
||||
$sql .= ", e.note_private, e.note_public";
|
||||
$sql .= ', e.fk_incoterms, e.location_incoterms';
|
||||
$sql .= ', e.signed_status';
|
||||
$sql .= ', i.libelle as label_incoterms';
|
||||
$sql .= ', s.libelle as shipping_method';
|
||||
$sql .= ", el.fk_source as origin_id, el.sourcetype as origin_type";
|
||||
@@ -653,7 +671,7 @@ class Expedition extends CommonObject
|
||||
$this->origin_id = $obj->origin_id;
|
||||
$this->billed = $obj->billed;
|
||||
$this->fk_project = $obj->fk_project;
|
||||
|
||||
$this->signed_status = $obj->signed_status;
|
||||
$this->trueWeight = $obj->weight;
|
||||
$this->weight_units = $obj->weight_units;
|
||||
|
||||
|
||||
@@ -77,14 +77,17 @@ WelcomeOnOnlineSignaturePageProposal=Welcome to the page to accept commercial pr
|
||||
WelcomeOnOnlineSignaturePageContract=Welcome to %s Contract PDF Signing Page
|
||||
WelcomeOnOnlineSignaturePageFichinter=Welcome to %s Intervention PDF Signing Page
|
||||
WelcomeOnOnlineSignaturePageSociete_rib=Welcome to %s SEPA mandate PDF Signing Page
|
||||
WelcomeOnOnlineSignaturePageExpedition=Welcome to %s Shipment PDF Signing Page
|
||||
ThisScreenAllowsYouToSignDocFromProposal=This screen allow you to accept and sign, or refuse, a quote/commercial proposal
|
||||
ThisScreenAllowsYouToSignDocFromContract=This screen allow you to sign contract on PDF format online.
|
||||
ThisScreenAllowsYouToSignDocFromFichinter=This screen allow you to sign intervention on PDF format online.
|
||||
ThisScreenAllowsYouToSignDocFromSociete_rib=This screen allow you to sign SEPA Mandate on PDF format online.
|
||||
ThisScreenAllowsYouToSignDocFromExpedition=This screen allow you to sign shipment on PDF format online.
|
||||
ThisIsInformationOnDocumentToSignProposal=This is information on document to accept or refuse
|
||||
ThisIsInformationOnDocumentToSignContract=This is information on contract to sign
|
||||
ThisIsInformationOnDocumentToSignFichinter=This is information on intervention to sign
|
||||
ThisIsInformationOnDocumentToSignSociete_rib=This is information on SEPA Mandate to sign
|
||||
ThisIsInformationOnDocumentToSignExpedition= This is information on shipment to sign
|
||||
SignatureProposalRef=Signature of quote/commercial proposal %s
|
||||
SignatureContractRef=Signature of contract %s
|
||||
SignatureFichinterRef=Signature of intervention %s
|
||||
|
||||
@@ -122,3 +122,5 @@ SignSociete_rib=Sign mandate
|
||||
SignPropal=Accept proposal
|
||||
Signed=signed
|
||||
SignedOnly=Signed only
|
||||
ExpeditionSigned=Shipment signed
|
||||
SignExpedition=Sign shipment
|
||||
|
||||
@@ -54,6 +54,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
|
||||
|
||||
// Load translation files
|
||||
$langs->loadLangs(array("main", "other", "dict", "bills", "companies", "errors", "members", "paybox", "stripe", "propal", "commercial"));
|
||||
@@ -122,7 +123,6 @@ $urlko = preg_replace('/&$/', '', $urlko); // Remove last &
|
||||
$creditor = $mysoc->name;
|
||||
|
||||
$type = $source;
|
||||
|
||||
if (!$action) {
|
||||
if ($source && !$ref) {
|
||||
httponly_accessforbidden($langs->trans('ErrorBadParameters')." - ref missing", 400, 1);
|
||||
@@ -160,6 +160,10 @@ if ($source == 'proposal') {
|
||||
require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
|
||||
$object = new CompanyBankAccount($db);
|
||||
$result = $object->fetch(0, $ref);
|
||||
} elseif ($source == 'expedition') {
|
||||
require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php';
|
||||
$object = new Expedition($db);
|
||||
$result = $object->fetch(0, $ref);
|
||||
} else {
|
||||
httponly_accessforbidden($langs->trans('ErrorBadParameters')." - Bad value for source. Value not supported.", 400, 1);
|
||||
}
|
||||
@@ -319,6 +323,9 @@ if (empty($text)) {
|
||||
} elseif ($source == 'fichinter') {
|
||||
$text .= '<tr><td class="textpublicpayment"><br><strong>'.$langs->trans("WelcomeOnOnlineSignaturePageFichinter", $mysoc->name).'</strong></td></tr>'."\n";
|
||||
$text .= '<tr><td class="textpublicpayment opacitymedium">'.$langs->trans("ThisScreenAllowsYouToSignDocFromFichinter", $creditor).'<br><br></td></tr>'."\n";
|
||||
} elseif ($source == 'expedition') {
|
||||
$text .= '<tr><td class="textpublicpayment"><br><strong>'.$langs->trans("WelcomeOnOnlineSignaturePageExpedition", $mysoc->name).'</strong></td></tr>'."\n";
|
||||
$text .= '<tr><td class="textpublicpayment opacitymedium">'.$langs->trans("ThisScreenAllowsYouToSignDocFromExpedition", $creditor).'<br><br></td></tr>'."\n";
|
||||
} else {
|
||||
$text .= '<tr><td class="textpublicpayment"><br><strong>'.$langs->trans("WelcomeOnOnlineSignaturePage".dol_ucfirst($source), $mysoc->name).'</strong></td></tr>'."\n";
|
||||
$text .= '<tr><td class="textpublicpayment opacitymedium">'.$langs->trans("ThisScreenAllowsYouToSignDocFrom".dol_ucfirst($source), $creditor).'<br><br></td></tr>'."\n";
|
||||
@@ -335,6 +342,8 @@ if ($source == 'proposal') {
|
||||
print '<tr><td align="left" colspan="2" class="opacitymedium">'.$langs->trans("ThisIsInformationOnDocumentToSignContract").' :</td></tr>'."\n";
|
||||
} elseif ($source == 'fichinter') {
|
||||
print '<tr><td align="left" colspan="2" class="opacitymedium">'.$langs->trans("ThisIsInformationOnDocumentToSignFichinter").' :</td></tr>'."\n";
|
||||
} elseif ($source == 'expedition') {
|
||||
print '<tr><td align="left" colspan="2" class="opacitymedium">'.$langs->trans("ThisIsInformationOnDocumentToSignExpedition").' :</td></tr>'."\n";
|
||||
} else {
|
||||
print '<tr><td align="left" colspan="2" class="opacitymedium">'.$langs->trans("ThisIsInformationOnDocumentToSign".dol_ucfirst($source)).' :</td></tr>'."\n";
|
||||
}
|
||||
@@ -590,6 +599,53 @@ if ($source == 'proposal') {
|
||||
print $langs->trans("DownloadDocument").'</a>';
|
||||
}
|
||||
}
|
||||
} elseif ($source == 'expedition') {
|
||||
// Signature on expedition
|
||||
$found = true;
|
||||
$langs->load("fichinter");
|
||||
|
||||
$result = $object->fetch_thirdparty($object->socid);
|
||||
|
||||
// Proposer
|
||||
print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("Proposer");
|
||||
print '</td><td class="CTableRow2">';
|
||||
print img_picto('', 'company', 'class="pictofixedwidth"');
|
||||
print '<b>'.$creditor.'</b>';
|
||||
print '<input type="hidden" name="creditor" value="'.$creditor.'">';
|
||||
print '</td></tr>'."\n";
|
||||
|
||||
// Target
|
||||
print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("ThirdParty");
|
||||
print '</td><td class="CTableRow2">';
|
||||
print img_picto('', 'company', 'class="pictofixedwidth"');
|
||||
print '<b>'.$object->thirdparty->name.'</b>';
|
||||
print '</td></tr>'."\n";
|
||||
|
||||
// Object
|
||||
$text = '<b>'.$langs->trans("SignatureFichinterRef", $object->ref).'</b>';
|
||||
print '<tr class="CTableRow2"><td class="CTableRow2">'.$langs->trans("Designation");
|
||||
print '</td><td class="CTableRow2">'.$text;
|
||||
|
||||
$last_main_doc_file = $object->last_main_doc;
|
||||
if (empty($last_main_doc_file) || !dol_is_file(DOL_DATA_ROOT.'/'.$object->last_main_doc)) {
|
||||
// It seems document has never been generated, or was generated and then deleted.
|
||||
// So we try to regenerate it with its default template.
|
||||
$defaulttemplate = ''; // We force the use an empty string instead of $object->model_pdf to be sure to use a "main" default template and not the last one used.
|
||||
$object->generateDocument($defaulttemplate, $langs);
|
||||
}
|
||||
$directdownloadlink = $object->getLastMainDocLink('', 0, 0);
|
||||
if ($directdownloadlink) {
|
||||
print '<br><a href="'.$directdownloadlink.'">';
|
||||
print img_mime($object->last_main_doc, '');
|
||||
if ($message == "signed") {
|
||||
print $langs->trans("DownloadSignedDocument").'</a>';
|
||||
} else {
|
||||
print $langs->trans("DownloadDocument").'</a>';
|
||||
}
|
||||
}
|
||||
print '<input type="hidden" name="source" value="'.GETPOST("source", 'alpha').'">';
|
||||
print '<input type="hidden" name="ref" value="'.$object->ref.'">';
|
||||
print '</td></tr>'."\n";
|
||||
} else {
|
||||
$found = true;
|
||||
$langs->load('companies');
|
||||
@@ -769,6 +825,12 @@ if ($action == "dosign" && empty($cancel)) {
|
||||
} else {
|
||||
print '<input type="submit" class="butAction small wraponsmartphone marginbottomonly marginleftonly marginrightonly reposition" value="'.$langs->trans("SignFichinter").'">';
|
||||
}
|
||||
} elseif ($source == 'expedition') {
|
||||
if ($message == 'signed' || $object->signed_status == Expedition::STATUS_SIGNED) {
|
||||
print '<span class="ok">'.$langs->trans("ExpeditionSigned").'</span>';
|
||||
} else {
|
||||
print '<input type="submit" class="butAction small wraponsmartphone marginbottomonly marginleftonly marginrightonly reposition" value="'.$langs->trans("SignExpedition").'">';
|
||||
}
|
||||
} else {
|
||||
if ($message == 'signed') {
|
||||
print '<span class="ok">'.$langs->trans(dol_ucfirst($source)."Signed").'</span>';
|
||||
|
||||
@@ -3491,12 +3491,58 @@ if (!GETPOST('hide_websitemenu')) {
|
||||
// ...
|
||||
//});
|
||||
|
||||
CKEDITOR.instances[idtouse].on(\'change\', function() {
|
||||
$(this.element.$).addClass(\'modified\');
|
||||
})
|
||||
} else {
|
||||
console.warn("A html section has the contenteditable=true attribute but has no id attribute");
|
||||
}
|
||||
})
|
||||
|
||||
isEditingEnabled = true;
|
||||
|
||||
// Trigger the function when clicking outside the elements with contenteditable=true attribute
|
||||
$(document).on(\'click\', function(e) {
|
||||
var target = $(e.target);
|
||||
// Check if the click is outside the elements with contenteditable=true attribute
|
||||
if (!target.closest(\'[contenteditable="true"]\').length) {
|
||||
// Repeat through the elements with contenteditable="true" attribute
|
||||
$(\'[contenteditable="true"]\').each(function() {
|
||||
var idToUse = $(this).attr(\'id\');
|
||||
var elementType = $(this).prop("tagName").toLowerCase(); // Get the tag name (div, section, footer...)
|
||||
var instance = CKEDITOR.instances[idToUse];
|
||||
// Check if the element has been modified
|
||||
if ($(this).hasClass(\'modified\')) {
|
||||
var content = instance.getData();
|
||||
content = "\\n" + content;
|
||||
|
||||
// Retrieving the content and ID of the element
|
||||
var elementId = $(this).attr(\'id\');
|
||||
|
||||
// Sending data via AJAX
|
||||
$.ajax({
|
||||
type: \'POST\',
|
||||
url: \'' . DOL_URL_ROOT . '/core/ajax/editinline.php\',
|
||||
data: {
|
||||
website_ref: \''.$website->ref.'\',
|
||||
page_id: \'' . $websitepage->id . '\',
|
||||
content: content,
|
||||
element_id: elementId,
|
||||
element_type: elementType,
|
||||
action: \'updatedElementContent\',
|
||||
token: \'' . newToken() . '\'
|
||||
},
|
||||
success: function(response) {
|
||||
console.log(response);
|
||||
}
|
||||
});
|
||||
|
||||
$(this).removeClass(\'modified\');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
console.log("Disable inline edit");
|
||||
for(name in CKEDITOR.instances) {
|
||||
|
||||
Reference in New Issue
Block a user