';
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index 322deadfee3..e0c2ca59835 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -1252,7 +1252,7 @@ class Propal extends CommonObject
$sql.= ", p.datep as dp";
$sql.= ", p.fin_validite as dfv";
$sql.= ", p.date_livraison as date_livraison";
- $sql.= ", p.model_pdf, p.ref_client, p.extraparams";
+ $sql.= ", p.model_pdf, p.last_main_doc, p.ref_client, p.extraparams";
$sql.= ", p.note_private, p.note_public";
$sql.= ", p.fk_projet, p.fk_statut";
$sql.= ", p.fk_user_author, p.fk_user_valid, p.fk_user_cloture";
@@ -1306,6 +1306,7 @@ class Propal extends CommonObject
$this->socid = $obj->fk_soc;
$this->fk_project = $obj->fk_projet;
$this->modelpdf = $obj->model_pdf;
+ $this->last_main_doc = $obj->last_main_doc;
$this->note = $obj->note_private; // TODO deprecated
$this->note_private = $obj->note_private;
$this->note_public = $obj->note_public;
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index 8937d2c16c2..d3f2feac763 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -1553,7 +1553,7 @@ class Commande extends CommonOrder
$sql.= ', c.fk_shipping_method';
$sql.= ', c.fk_warehouse';
$sql.= ', c.fk_projet, c.remise_percent, c.remise, c.remise_absolue, c.source, c.facture as billed';
- $sql.= ', c.note_private, c.note_public, c.ref_client, c.ref_ext, c.ref_int, c.model_pdf, c.fk_delivery_address, c.extraparams';
+ $sql.= ', c.note_private, c.note_public, c.ref_client, c.ref_ext, c.ref_int, c.model_pdf, c.last_main_doc, c.fk_delivery_address, c.extraparams';
$sql.= ', c.fk_incoterms, c.location_incoterms';
$sql.= ", c.fk_multicurrency, c.multicurrency_code, c.multicurrency_tx, c.multicurrency_total_ht, c.multicurrency_total_tva, c.multicurrency_total_ttc";
$sql.= ", i.libelle as libelle_incoterms";
@@ -1608,6 +1608,7 @@ class Commande extends CommonOrder
$this->note_public = $obj->note_public;
$this->fk_project = $obj->fk_projet;
$this->modelpdf = $obj->model_pdf;
+ $this->last_main_doc = $obj->last_main_doc;
$this->mode_reglement_id = $obj->fk_mode_reglement;
$this->mode_reglement_code = $obj->mode_reglement_code;
$this->mode_reglement = $obj->mode_reglement_libelle;
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index f38387db3ed..a6f37ae4fc3 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -4378,7 +4378,7 @@ else if ($id > 0 || ! empty($ref))
// Show online payment link
$useonlinepayment = (! empty($conf->paypal->enabled) || ! empty($conf->stripe->enabled) || ! empty($conf->paybox->enabled));
- if ($object->statut != 0 && $useonlinepayment)
+ if ($object->statut != Facture::STATUS_DRAFT && $useonlinepayment)
{
print '
';
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index 826d13fecd6..2200ce1f659 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -1193,7 +1193,7 @@ class Facture extends CommonInvoice
$sql.= ', f.datec as datec';
$sql.= ', f.date_valid as datev';
$sql.= ', f.tms as datem';
- $sql.= ', f.note_private, f.note_public, f.fk_statut, f.paye, f.close_code, f.close_note, f.fk_user_author, f.fk_user_valid, f.model_pdf';
+ $sql.= ', f.note_private, f.note_public, f.fk_statut, f.paye, f.close_code, f.close_note, f.fk_user_author, f.fk_user_valid, f.model_pdf, f.last_main_doc,';
$sql.= ', f.fk_facture_source';
$sql.= ', f.fk_mode_reglement, f.fk_cond_reglement, f.fk_projet, f.extraparams';
$sql.= ', f.situation_cycle_ref, f.situation_counter, f.situation_final';
@@ -1262,6 +1262,7 @@ class Facture extends CommonInvoice
$this->user_author = $obj->fk_user_author;
$this->user_valid = $obj->fk_user_valid;
$this->modelpdf = $obj->model_pdf;
+ $this->last_main_doc = $obj->last_main_doc;
$this->situation_cycle_ref = $obj->situation_cycle_ref;
$this->situation_counter = $obj->situation_counter;
$this->situation_final = $obj->situation_final;
diff --git a/htdocs/core/actions_builddoc.inc.php b/htdocs/core/actions_builddoc.inc.php
index bd86c5cb80c..b4ac3794348 100644
--- a/htdocs/core/actions_builddoc.inc.php
+++ b/htdocs/core/actions_builddoc.inc.php
@@ -91,7 +91,7 @@ if ($action == 'builddoc' && $permissioncreate)
}
else
{
- if (empty($donotredirect)) // This is se when include is done by bulk action "Bill Orders"
+ if (empty($donotredirect)) // This is use when include is done by bulk action "Bill Orders"
{
setEventMessages($langs->trans("FileGenerated"), null);
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index c410bc4b361..d824492d22c 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -4047,13 +4047,14 @@ abstract class CommonObject
if (in_array(get_class($this), array('Adherent')))
{
- $arrayofrecords = array(); // The write_file of templates of adherent class need this
+ $arrayofrecords = array(); // The write_file of templates of adherent class need this var
$resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, $moreparams);
}
else
{
$resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $moreparams);
}
+ // After call of write_file $obj->result['fullpath'] is set with generated file. It will be used to update the ECM database index.
if ($resultwritefile > 0)
{
@@ -4080,9 +4081,19 @@ abstract class CommonObject
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
$ecmfile=new EcmFiles($this->db);
$result = $ecmfile->fetch(0, '', ($rel_dir?$rel_dir.'/':'').$filename);
+
+ if (! empty($conf->global->PROPOSAL_USE_ONLINE_SIGN))
+ {
+ if (empty($ecmfile->share)) // Because object not found or share not set yet
+ {
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
+ $ecmfile->share = getRandomPassword(true);
+ }
+ }
+
if ($result > 0)
{
- $ecmfile->label = md5_file(dol_osencode($destfull));
+ $ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content
$ecmfile->fullpath_orig = '';
$ecmfile->gen_or_uploaded = 'generated';
$ecmfile->description = ''; // indexed content
@@ -4097,7 +4108,7 @@ abstract class CommonObject
{
$ecmfile->filepath = $rel_dir;
$ecmfile->filename = $filename;
- $ecmfile->label = md5_file(dol_osencode($destfull));
+ $ecmfile->label = md5_file(dol_osencode($destfull)); // hash of file content
$ecmfile->fullpath_orig = '';
$ecmfile->gen_or_uploaded = 'generated';
$ecmfile->description = ''; // indexed content
@@ -4108,6 +4119,21 @@ abstract class CommonObject
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
}
}
+
+ /*$this->result['fullname']=$destfull;
+ $this->result['filepath']=$ecmfile->filepath;
+ $this->result['filename']=$ecmfile->filename;*/
+
+ // Update the last_main_doc field into main object
+ $update_main_doc_field=0;
+ if (! empty($obj->update_main_doc_field)) $update_main_doc_field=1;
+ if ($update_main_doc_field && ! empty($this->table_element))
+ {
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element." SET last_main_doc = '".($ecmfile->filepath.'/'.$ecmfile->filename)."'";
+ $sql.= ' WHERE rowid = '.$this->id;
+ $resql = $this->db->query($sql);
+ if (! $resql) dol_print_error($this->db);
+ }
}
}
else
diff --git a/htdocs/core/lib/payments.lib.php b/htdocs/core/lib/payments.lib.php
index aaaa0934890..3a398e50f69 100644
--- a/htdocs/core/lib/payments.lib.php
+++ b/htdocs/core/lib/payments.lib.php
@@ -99,7 +99,7 @@ function showOnlinePaymentUrl($type,$ref)
{
global $conf, $langs;
- $langs->load("PAYMENT");
+ $langs->load("payment");
$langs->load("paybox");
$servicename='Online';
@@ -110,7 +110,6 @@ function showOnlinePaymentUrl($type,$ref)
return $out;
}
-
/**
* Return string with full Url
*
diff --git a/htdocs/core/lib/signature.lib.php b/htdocs/core/lib/signature.lib.php
new file mode 100644
index 00000000000..b11d809caf2
--- /dev/null
+++ b/htdocs/core/lib/signature.lib.php
@@ -0,0 +1,94 @@
+
+ *
+ * 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
.
+ * or see http://www.gnu.org/
+ */
+
+/**
+ * Return string with full Url
+ *
+ * @param string $type Type of URL ('proposal', ...)
+ * @param string $ref Ref of object
+ * @return string Url string
+ */
+function showOnlineSignatureUrl($type,$ref)
+{
+ global $conf, $langs;
+
+ $langs->load("payment");
+ $langs->load("paybox");
+ $servicename='Online';
+
+ $out = img_picto('','object_globe.png').' '.$langs->trans("ToOfferALinkForOnlineSignature",$servicename).'
';
+ $url = getOnlineSignatureUrl(0, $type, $ref);
+ $out.= '
';
+ $out.= ajax_autoselect("onlinesignatureurl", 0);
+ return $out;
+}
+
+
+/**
+ * Return string with full Url
+ *
+ * @param int $mode 0=True url, 1=Url formated with colors
+ * @param string $type Type of URL ('proposal', ...)
+ * @param string $ref Ref of object
+ * @return string Url string
+ */
+function getOnlineSignatureUrl($mode, $type, $ref='')
+{
+ global $conf, $db, $langs;
+
+ $ref=str_replace(' ','',$ref);
+ $out='';
+
+ if ($type == 'proposal')
+ {
+ $out=DOL_MAIN_URL_ROOT.'/public/onlinesign/newonlinesign.php?source=proposal&ref='.($mode?'
':'');
+ if ($mode == 1) $out.='proposal_ref';
+ if ($mode == 0) $out.=urlencode($ref);
+ $out.=($mode?'':'');
+ if ($mode == 1) $out.='&hashp=
hash_of_file';
+ else
+ {
+ include_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
+ $propaltmp=new Propal($db);
+ $res = $propaltmp->fetch(0, $ref);
+ if ($res <= 0) return 'FailedToGetProposal';
+
+ include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
+ $ecmfile=new EcmFiles($db);
+
+ $ecmfile->fetch(0, '', $propaltmp->last_main_doc);
+
+ $hashp=$ecmfile->share;
+ if (empty($hashp))
+ {
+ $out = $langs->trans("FeatureOnlineSignDisabled");
+ return $out;
+ }
+ else
+ {
+ $out.='&hashp='.$hashp;
+ }
+ }
+ }
+
+ // For multicompany
+ if (! empty($out)) $out.="&entity=".$conf->entity; // Check the entity because He may be the same reference in several entities
+
+ return $out;
+}
diff --git a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
index f5ab606f404..45568f5eadf 100644
--- a/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
+++ b/htdocs/core/modules/commande/doc/pdf_einstein.modules.php
@@ -56,6 +56,11 @@ class pdf_einstein extends ModelePDFCommandes
*/
public $description;
+ /**
+ * @var int Save the name of generated file as the main doc when generating a doc with this template
+ */
+ public $update_main_doc_field;
+
/**
* @var string document type
*/
@@ -100,8 +105,9 @@ class pdf_einstein extends ModelePDFCommandes
$this->db = $db;
$this->name = "einstein";
$this->description = $langs->trans('PDFEinsteinDescription');
+ $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
- // Dimension page pour format A4
+ // Dimension page
$this->type = 'pdf';
$formatarray=pdf_getFormat();
$this->page_largeur = $formatarray['width'];
@@ -599,7 +605,7 @@ class pdf_einstein extends ModelePDFCommandes
@chmod($file, octdec($conf->global->MAIN_UMASK));
$this->result = array('fullpath'=>$file);
-
+
return 1; // Pas d'erreur
}
else
diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
index 2d5a27bb3df..f5d6ec70f04 100644
--- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
+++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php
@@ -45,6 +45,7 @@ class pdf_crabe extends ModelePDFFactures
var $db;
var $name;
var $description;
+ var $update_main_doc_field; // Save the name of generated file as the main doc when generating a doc with this template
var $type;
var $phpmin = array(4,3,0); // Minimum version of PHP required by module
@@ -86,7 +87,9 @@ class pdf_crabe extends ModelePDFFactures
$this->db = $db;
$this->name = "crabe";
$this->description = $langs->trans('PDFCrabeDescription');
+ $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
+ // Dimensiont page
$this->type = 'pdf';
$formatarray=pdf_getFormat();
$this->page_largeur = $formatarray['width'];
@@ -702,7 +705,7 @@ class pdf_crabe extends ModelePDFFactures
@chmod($file, octdec($conf->global->MAIN_UMASK));
$this->result = array('fullpath'=>$file);
-
+
return 1; // No error
}
else
diff --git a/htdocs/core/modules/propale/doc/pdf_azur.modules.php b/htdocs/core/modules/propale/doc/pdf_azur.modules.php
index 0c9a39a3fea..3e7a0130a04 100644
--- a/htdocs/core/modules/propale/doc/pdf_azur.modules.php
+++ b/htdocs/core/modules/propale/doc/pdf_azur.modules.php
@@ -43,6 +43,7 @@ class pdf_azur extends ModelePDFPropales
var $db;
var $name;
var $description;
+ var $update_main_doc_field; // Save the name of generated file as the main doc when generating a doc with this template
var $type;
var $phpmin = array(4,3,0); // Minimum version of PHP required by module
@@ -74,8 +75,9 @@ class pdf_azur extends ModelePDFPropales
$this->db = $db;
$this->name = "azur";
$this->description = $langs->trans('DocModelAzurDescription');
+ $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
- // Dimension page pour format A4
+ // Dimension page
$this->type = 'pdf';
$formatarray=pdf_getFormat();
$this->page_largeur = $formatarray['width'];
@@ -760,7 +762,7 @@ class pdf_azur extends ModelePDFPropales
@chmod($file, octdec($conf->global->MAIN_UMASK));
$this->result = array('fullpath'=>$file);
-
+
return 1; // Pas d'erreur
}
else
diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php
index 540c30ec286..8308d7c7315 100644
--- a/htdocs/ecm/class/ecmfiles.class.php
+++ b/htdocs/ecm/class/ecmfiles.class.php
@@ -48,7 +48,7 @@ class EcmFiles //extends CommonObject
*/
public $ref; // hash of file path
public $label; // hash of file content (md5_file(dol_osencode($destfull))
- public $share; // hash for file sharing. empty by default
+ public $share; // hash for file sharing, empty by default (example: getRandomPassword(true))
public $entity;
public $filename;
public $filepath;
diff --git a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql
index b02fb81495b..e21bebac13f 100644
--- a/htdocs/install/mysql/migration/6.0.0-7.0.0.sql
+++ b/htdocs/install/mysql/migration/6.0.0-7.0.0.sql
@@ -79,6 +79,20 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value
ALTER TABLE llx_ecm_files MODIFY label varchar(128) NOT NULL;
ALTER TABLE llx_ecm_files ADD COLUMN share varchar(128) NULL after label;
+ALTER TABLE llx_ecm_files ADD COLUMN src_object_type varchar(32);
+ALTER TABLE llx_ecm_files ADD COLUMN src_object_id integer;
+
+
+ALTER TABLE llx_propal ADD COLUMN last_main_doc varchar(255);
+ALTER TABLE llx_commande ADD COLUMN last_main_doc varchar(255);
+ALTER TABLE llx_facture ADD COLUMN last_main_doc varchar(255);
+ALTER TABLE llx_contrat ADD COLUMN last_main_doc varchar(255);
+ALTER TABLE llx_expedition ADD COLUMN last_main_doc varchar(255);
+ALTER TABLE llx_fichinter ADD COLUMN last_main_doc varchar(255);
+ALTER TABLE llx_livraison ADD COLUMN last_main_doc varchar(255);
+ALTER TABLE llx_supplier_proposal ADD COLUMN last_main_doc varchar(255);
+ALTER TABLE llx_facture_fourn ADD COLUMN last_main_doc varchar(255);
+ALTER TABLE llx_commande_fournisseur ADD COLUMN last_main_doc varchar(255);
ALTER TABLE llx_c_paiement ADD COLUMN position integer NOT NULL DEFAULT 0;
diff --git a/htdocs/install/mysql/tables/llx_commande.sql b/htdocs/install/mysql/tables/llx_commande.sql
index 98740c232ac..b6708de3783 100644
--- a/htdocs/install/mysql/tables/llx_commande.sql
+++ b/htdocs/install/mysql/tables/llx_commande.sql
@@ -54,6 +54,7 @@ create table llx_commande
note_private text,
note_public text,
model_pdf varchar(255),
+ last_main_doc varchar(255), -- relative filepath+filename of last main generated document
facture tinyint default 0,
fk_account integer, -- bank account
diff --git a/htdocs/install/mysql/tables/llx_commande_fournisseur.sql b/htdocs/install/mysql/tables/llx_commande_fournisseur.sql
index 6d291dcfa00..87124697a57 100644
--- a/htdocs/install/mysql/tables/llx_commande_fournisseur.sql
+++ b/htdocs/install/mysql/tables/llx_commande_fournisseur.sql
@@ -57,6 +57,7 @@ create table llx_commande_fournisseur
note_private text,
note_public text,
model_pdf varchar(255),
+ last_main_doc varchar(255), -- relative filepath+filename of last main generated document
date_livraison datetime default NULL,
fk_account integer, -- bank account
diff --git a/htdocs/install/mysql/tables/llx_contrat.sql b/htdocs/install/mysql/tables/llx_contrat.sql
index 67c535ef6f2..606c0e78f8f 100644
--- a/htdocs/install/mysql/tables/llx_contrat.sql
+++ b/htdocs/install/mysql/tables/llx_contrat.sql
@@ -44,6 +44,7 @@ create table llx_contrat
note_private text,
note_public text,
model_pdf varchar(255),
+ last_main_doc varchar(255), -- relative filepath+filename of last main generated document
import_key varchar(14),
extraparams varchar(255)
)ENGINE=innodb;
diff --git a/htdocs/install/mysql/tables/llx_ecm_files.sql b/htdocs/install/mysql/tables/llx_ecm_files.sql
index 5360660a7bc..4af969b8ccc 100644
--- a/htdocs/install/mysql/tables/llx_ecm_files.sql
+++ b/htdocs/install/mysql/tables/llx_ecm_files.sql
@@ -19,12 +19,14 @@
CREATE TABLE llx_ecm_files
(
rowid integer AUTO_INCREMENT PRIMARY KEY,
- ref varchar(128), -- contains a hash id from filename+filepath
+ ref varchar(128), -- contains hash from filename+filepath
label varchar(128) NOT NULL, -- contains hash of file content
- share varchar(128) NULL, -- contains a hash for file sharing
+ share varchar(128) NULL, -- contains hash for file sharing
entity integer DEFAULT 1 NOT NULL, -- multi company id
filepath varchar(255) NOT NULL, -- relative to dolibarr document dir. Example module/def
filename varchar(255) NOT NULL, -- file name only without any directory
+ src_object_type varchar(32), -- Source object type ('proposal', 'invoice', ...)
+ src_object_id integer, -- Source object id
fullpath_orig varchar(750), -- full path of original filename, when file is uploaded from a local computer
description text,
keywords varchar(750), -- list of keywords, separated with comma. Must be limited to most important keywords.
diff --git a/htdocs/install/mysql/tables/llx_expedition.sql b/htdocs/install/mysql/tables/llx_expedition.sql
index 088e4893c06..cdf3f253892 100644
--- a/htdocs/install/mysql/tables/llx_expedition.sql
+++ b/htdocs/install/mysql/tables/llx_expedition.sql
@@ -54,6 +54,8 @@ create table llx_expedition
note_private text,
note_public text,
model_pdf varchar(255),
+ last_main_doc varchar(255), -- relative filepath+filename of last main generated document
+
fk_incoterms integer, -- for incoterms
location_incoterms varchar(255), -- for incoterms
diff --git a/htdocs/install/mysql/tables/llx_facture.sql b/htdocs/install/mysql/tables/llx_facture.sql
index 014572cd7e6..c0783a7bbd8 100644
--- a/htdocs/install/mysql/tables/llx_facture.sql
+++ b/htdocs/install/mysql/tables/llx_facture.sql
@@ -77,6 +77,7 @@ create table llx_facture
note_private text,
note_public text,
model_pdf varchar(255),
+ last_main_doc varchar(255), -- relative filepath+filename of last main generated document
fk_incoterms integer, -- for incoterms
location_incoterms varchar(255), -- for incoterms
diff --git a/htdocs/install/mysql/tables/llx_facture_fourn.sql b/htdocs/install/mysql/tables/llx_facture_fourn.sql
index 1b7d0a11e1a..89d0ddc9478 100644
--- a/htdocs/install/mysql/tables/llx_facture_fourn.sql
+++ b/htdocs/install/mysql/tables/llx_facture_fourn.sql
@@ -71,6 +71,8 @@ create table llx_facture_fourn
fk_incoterms integer, -- for incoterms
location_incoterms varchar(255), -- for incoterms
model_pdf varchar(255),
+ last_main_doc varchar(255), -- relative filepath+filename of last main generated document
+
import_key varchar(14),
extraparams varchar(255), -- for stock other parameters with json format
diff --git a/htdocs/install/mysql/tables/llx_fichinter.sql b/htdocs/install/mysql/tables/llx_fichinter.sql
index 0ec67d6585c..5bc5741c014 100644
--- a/htdocs/install/mysql/tables/llx_fichinter.sql
+++ b/htdocs/install/mysql/tables/llx_fichinter.sql
@@ -42,6 +42,7 @@ create table llx_fichinter
note_private text,
note_public text,
model_pdf varchar(255),
+ last_main_doc varchar(255), -- relative filepath+filename of last main generated document
import_key varchar(14),
extraparams varchar(255) -- for other parameters with json format
)ENGINE=innodb;
diff --git a/htdocs/install/mysql/tables/llx_livraison.sql b/htdocs/install/mysql/tables/llx_livraison.sql
index 6b09303f94d..d5848eb708e 100644
--- a/htdocs/install/mysql/tables/llx_livraison.sql
+++ b/htdocs/install/mysql/tables/llx_livraison.sql
@@ -40,6 +40,7 @@ create table llx_livraison
note_private text,
note_public text,
model_pdf varchar(255),
+ last_main_doc varchar(255), -- relative filepath+filename of last main generated document
fk_incoterms integer, -- for incoterms
location_incoterms varchar(255), -- for incoterms
diff --git a/htdocs/install/mysql/tables/llx_propal.sql b/htdocs/install/mysql/tables/llx_propal.sql
index 5d284ed84a2..e4c997b940a 100644
--- a/htdocs/install/mysql/tables/llx_propal.sql
+++ b/htdocs/install/mysql/tables/llx_propal.sql
@@ -39,7 +39,7 @@ create table llx_propal
date_valid datetime, -- date de validation
date_cloture datetime, -- date de cloture
fk_user_author integer, -- user making creation
- fk_user_modif integer, -- user making last change
+ fk_user_modif integer, -- user making last change
fk_user_valid integer, -- user validating
fk_user_cloture integer, -- user closing (signed or not)
fk_statut smallint DEFAULT 0 NOT NULL, -- 0=draft, 1=validated, 2=accepted, 3=refused, 4=billed/closed
@@ -60,7 +60,10 @@ create table llx_propal
note_private text,
note_public text,
- model_pdf varchar(255),
+
+ model_pdf varchar(255), -- last template used to generate main document
+ last_main_doc varchar(255), -- relative filepath+filename of last main generated document
+
date_livraison date DEFAULT NULL, -- delivery date
fk_shipping_method integer, -- shipping method id
fk_availability integer NULL,
diff --git a/htdocs/install/mysql/tables/llx_supplier_proposal.sql b/htdocs/install/mysql/tables/llx_supplier_proposal.sql
index 13d9ba3a59a..458cebe1d33 100644
--- a/htdocs/install/mysql/tables/llx_supplier_proposal.sql
+++ b/htdocs/install/mysql/tables/llx_supplier_proposal.sql
@@ -47,7 +47,9 @@ CREATE TABLE llx_supplier_proposal (
fk_mode_reglement integer DEFAULT NULL,
note_private text,
note_public text,
- model_pdf varchar(255) DEFAULT NULL,
+ model_pdf varchar(255) DEFAULT NULL,
+ last_main_doc varchar(255), -- relative filepath+filename of last main generated document
+
date_livraison date DEFAULT NULL,
fk_shipping_method integer DEFAULT NULL,
import_key varchar(14) DEFAULT NULL,
diff --git a/htdocs/langs/en_US/commercial.lang b/htdocs/langs/en_US/commercial.lang
index deb66143b82..4b2386e04d0 100644
--- a/htdocs/langs/en_US/commercial.lang
+++ b/htdocs/langs/en_US/commercial.lang
@@ -70,3 +70,9 @@ Stats=Sales statistics
StatusProsp=Prospect status
DraftPropals=Draft commercial proposals
NoLimit=No limit
+ToOfferALinkForOnlineSignature=Link for online signature
+WelcomeOnOnlineSignaturePage=Welcome on the page to accept commerical proposals from %s
+ThisScreenAllowsYouToSignDocFrom=This screen allow you to accept and sign, or refuse, a quote/commercial proposal
+ThisIsInformationOnDocumentToSign=This is information on document to accept or refuse
+SignatureProposalRef=Signature of quote/commerical proposal %s
+FeatureOnlineSignDisabled=Feature for online signing disabled or document generated before the feature was enabled
\ No newline at end of file
diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php
index 63617076a1b..6c9b4b154bf 100644
--- a/htdocs/public/onlinesign/newonlinesign.php
+++ b/htdocs/public/onlinesign/newonlinesign.php
@@ -62,14 +62,16 @@ $action=GETPOST('action','alpha');
// currency (iso code)
$suffix=GETPOST("suffix",'alpha');
-$SOURCE=GETPOST("source",'alpha');
+$source=GETPOST("source",'alpha');
$ref=$REF=GETPOST("ref",'alpha');
+if (empty($source)) $source='proposal';
+
if (! $action)
{
if ($source && ! $ref)
{
- dol_print_error('',$langs->trans('ErrorBadParameters')." - ref");
+ print $langs->trans('ErrorBadParameters')." - ref missing";
exit;
}
}
@@ -90,10 +92,10 @@ $urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than cur
// Complete urls for post treatment
$SECUREKEY=GETPOST("securekey"); // Secure key
-if (! empty($SOURCE))
+if (! empty($source))
{
- $urlok.='source='.urlencode($SOURCE).'&';
- $urlko.='source='.urlencode($SOURCE).'&';
+ $urlok.='source='.urlencode($source).'&';
+ $urlko.='source='.urlencode($source).'&';
}
if (! empty($REF))
{
@@ -113,7 +115,7 @@ if (! empty($entity))
$urlok=preg_replace('/&$/','',$urlok); // Remove last &
$urlko=preg_replace('/&$/','',$urlko); // Remove last &
-
+$creditor = $mysoc->name;
/*
@@ -141,10 +143,10 @@ $conf->dol_hide_leftmenu=1;
llxHeader($head, $langs->trans("OnlineSignature"), '', '', 0, 0, '', '', '', 'onlinepaymentbody');
// Check link validity
-if (! empty($SOURCE) && in_array($ref, array('member_ref', 'contractline_ref', 'invoice_ref', 'order_ref', '')))
+if (! empty($source) && in_array($ref, array('member_ref', 'contractline_ref', 'invoice_ref', 'order_ref', '')))
{
$langs->load("errors");
- dol_print_error_email('BADREFINONLINESIGNFORM', $langs->trans("ErrorBadLinkSourceSetButBadValueForRef", $SOURCE, $ref));
+ dol_print_error_email('BADREFINONLINESIGNFORM', $langs->trans("ErrorBadLinkSourceSetButBadValueForRef", $source, $ref));
llxFooter();
$db->close();
exit;
@@ -205,7 +207,7 @@ if (! empty($conf->global->ONLINE_SIGN_NEWFORM_TEXT))
}
if (empty($text))
{
- $text.='
'.$langs->trans("WelcomeOnOnlineSignaturePage").' |
'."\n";
+ $text.='
'.$langs->trans("WelcomeOnOnlineSignaturePage", $mysoc->name).' |
'."\n";
$text.='
'.$langs->trans("ThisScreenAllowsYouToSignDocFrom",$creditor).'
|
'."\n";
}
print $text;
@@ -219,45 +221,24 @@ $found=false;
$error=0;
$var=false;
-// Free payment
-if (! GETPOST("source"))
-{
- $found=true;
- $tag=GETPOST("tag");
- $fulltag=$tag;
-
- // Creditor
-
- print '
| '.$langs->trans("Creditor");
- print ' | '.$creditor.'';
- print '';
- print ' |
'."\n";
-
-
-
- // We do not add fields shipToName, shipToStreet, shipToCity, shipToState, shipToCountryCode, shipToZip, shipToStreet2, phoneNum
- // as they don't exists (buyer is unknown, tag is free).
-}
-
-
// Payment on customer order
-if (GETPOST("source") == 'order')
+if ($source == 'proposal')
{
$found=true;
- $langs->load("orders");
+ $langs->load("proposal");
- require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
+ require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
- $order=new Commande($db);
- $result=$order->fetch('',$ref);
- if ($result < 0)
+ $proposal=new Propal($db);
+ $result=$proposal->fetch('',$ref);
+ if ($result <= 0)
{
- $mesg=$order->error;
+ $mesg=$proposal->error;
$error++;
}
else
{
- $result=$order->fetch_thirdparty($order->socid);
+ $result=$proposal->fetch_thirdparty($proposal->socid);
}
// Creditor
@@ -270,336 +251,21 @@ if (GETPOST("source") == 'order')
// Debitor
print '
| '.$langs->trans("ThirdParty");
- print ' | '.$order->thirdparty->name.'';
+ print ' | '.$proposal->thirdparty->name.'';
// Object
- $text=''.$langs->trans("PaymentOrderRef",$order->ref).'';
+ $text=''.$langs->trans("SignatureProposalRef",$proposal->ref).'';
print ' |
| '.$langs->trans("Designation");
print ' | '.$text;
print '';
- print '';
+ print '';
print ' |
'."\n";
}
-// Payment on customer invoice
-if (GETPOST("source") == 'invoice')
-{
- $found=true;
- $langs->load("bills");
-
- require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
-
- $invoice=new Facture($db);
- $result=$invoice->fetch('',$ref);
- if ($result < 0)
- {
- $mesg=$invoice->error;
- $error++;
- }
- else
- {
- $result=$invoice->fetch_thirdparty($invoice->socid);
- }
-
- if ($action != 'dosign') // Do not change amount if we just click on first dosign
- {
- $amount=price2num($invoice->total_ttc - $invoice->getSommePaiement());
- if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int');
- $amount=price2num($amount);
- }
-
- // Creditor
-
- print '
| '.$langs->trans("Creditor");
- print ' | '.$creditor.'';
- print '';
- print ' |
'."\n";
-
- // Debitor
-
- print '
| '.$langs->trans("ThirdParty");
- print ' | '.$invoice->thirdparty->name.'';
-
- // Object
-
- $text=''.$langs->trans("PaymentInvoiceRef",$invoice->ref).'';
- print ' |
| '.$langs->trans("Designation");
- print ' | '.$text;
- print '';
- print '';
- print ' |
'."\n";
-
-}
-
-// Payment on contract line
-if (GETPOST("source") == 'contractline')
-{
- $found=true;
- $langs->load("contracts");
-
- require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
-
- $contractline=new ContratLigne($db);
- $result=$contractline->fetch('',$ref);
- if ($result < 0)
- {
- $mesg=$contractline->error;
- $error++;
- }
- else
- {
- if ($contractline->fk_contrat > 0)
- {
- $contract=new Contrat($db);
- $result=$contract->fetch($contractline->fk_contrat);
- if ($result > 0)
- {
- $result=$contract->fetch_thirdparty($contract->socid);
- }
- else
- {
- $mesg=$contract->error;
- $error++;
- }
- }
- else
- {
- $mesg='ErrorRecordNotFound';
- $error++;
- }
- }
-
- if ($action != 'dosign') // Do not change amount if we just click on first dosign
- {
- $amount=$contractline->total_ttc;
- if ($contractline->fk_product)
- {
- $product=new Product($db);
- $result=$product->fetch($contractline->fk_product);
-
- // We define price for product (TODO Put this in a method in product class)
- if (! empty($conf->global->PRODUIT_MULTIPRICES))
- {
- $pu_ht = $product->multiprices[$contract->thirdparty->price_level];
- $pu_ttc = $product->multiprices_ttc[$contract->thirdparty->price_level];
- $price_base_type = $product->multiprices_base_type[$contract->thirdparty->price_level];
- }
- else
- {
- $pu_ht = $product->price;
- $pu_ttc = $product->price_ttc;
- $price_base_type = $product->price_base_type;
- }
-
- $amount=$pu_ttc;
- if (empty($amount))
- {
- dol_print_error('','ErrorNoPriceDefinedForThisProduct');
- exit;
- }
- }
- if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int');
- $amount=price2num($amount);
- }
-
- $qty=1;
- if (GETPOST('qty')) $qty=GETPOST('qty');
-
- // Creditor
-
- print '
| '.$langs->trans("Creditor");
- print ' | '.$creditor.'';
- print '';
- print ' |
'."\n";
-
- // Debitor
-
- print '
| '.$langs->trans("ThirdParty");
- print ' | '.$contract->thirdparty->name.'';
-
- // Object
-
- $text=''.$langs->trans("PaymentRenewContractId",$contract->ref,$contractline->ref).'';
- if ($contractline->fk_product)
- {
- $text.=' '.$product->ref.($product->label?' - '.$product->label:'');
- }
- if ($contractline->description) $text.=' '.dol_htmlentitiesbr($contractline->description);
- //if ($contractline->date_fin_validite) {
- // $text.=' '.$langs->trans("DateEndPlanned").': ';
- // $text.=dol_print_date($contractline->date_fin_validite);
- //}
- if ($contractline->date_fin_validite)
- {
- $text.=' '.$langs->trans("ExpiredSince").': '.dol_print_date($contractline->date_fin_validite);
- }
-
- print ' |
| '.$langs->trans("Designation");
- print ' | '.$text;
- print '';
- print '';
- print ' |
'."\n";
-
- // Quantity
-
- $label=$langs->trans("Quantity");
- $qty=1;
- $duration='';
- if ($contractline->fk_product)
- {
- if ($product->isService() && $product->duration_value > 0)
- {
- $label=$langs->trans("Duration");
-
- // TODO Put this in a global method
- if ($product->duration_value > 1)
- {
- $dur=array("h"=>$langs->trans("Hours"),"d"=>$langs->trans("DurationDays"),"w"=>$langs->trans("DurationWeeks"),"m"=>$langs->trans("DurationMonths"),"y"=>$langs->trans("DurationYears"));
- }
- else
- {
- $dur=array("h"=>$langs->trans("Hour"),"d"=>$langs->trans("DurationDay"),"w"=>$langs->trans("DurationWeek"),"m"=>$langs->trans("DurationMonth"),"y"=>$langs->trans("DurationYear"));
- }
- $duration=$product->duration_value.' '.$dur[$product->duration_unit];
- }
- }
- print '
| '.$label.' | ';
- print ''.($duration?$duration:$qty).'';
- print '';
- print ' |
'."\n";
-
- // Amount
-
- print '
| '.$langs->trans("Amount");
- if (empty($amount)) print ' ('.$langs->trans("ToComplete").')';
- print ' | ';
- if (empty($amount) || ! is_numeric($amount))
- {
- print '';
- print '';
- }
- else {
- print ''.price($amount).'';
- print '';
- print '';
- }
- // Currency
- print ' '.$langs->trans("Currency".$currency).'';
- print '';
- print ' |
'."\n";
-
-}
-
-// Payment on member subscription
-if (GETPOST("source") == 'membersubscription')
-{
- $found=true;
- $langs->load("members");
-
- require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
- require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
-
- $member=new Adherent($db);
- $result=$member->fetch('',$ref);
- if ($result < 0)
- {
- $mesg=$member->error;
- $error++;
- }
- else
- {
- $subscription=new Subscription($db);
- }
-
- if ($action != 'dosign') // Do not change amount if we just click on first dosign
- {
- $amount=$subscription->total_ttc;
- if (GETPOST("amount",'int')) $amount=GETPOST("amount",'int');
- $amount=price2num($amount);
- }
-
- $fulltag='MEM='.$member->id.'.DAT='.dol_print_date(dol_now(),'%Y%m%d%H%M');
- if (! empty($TAG)) { $tag=$TAG; $fulltag.='.TAG='.$TAG; }
- $fulltag=dol_string_unaccent($fulltag);
-
- // Creditor
-
- print '
| '.$langs->trans("Creditor");
- print ' | '.$creditor.'';
- print '';
- print ' |
'."\n";
-
- // Debitor
-
- print '
| '.$langs->trans("Member");
- print ' | ';
- if ($member->morphy == 'mor' && ! empty($member->societe)) print $member->societe;
- else print $member->getFullName($langs);
- print '';
-
- // Object
-
- $text=''.$langs->trans("PaymentSubscription").'';
- print ' |
| '.$langs->trans("Designation");
- print ' | '.$text;
- print '';
- print '';
- print ' |
'."\n";
-
- if ($member->last_subscription_date || $member->last_subscription_amount)
- {
- // Last subscription date
-
- print '
| '.$langs->trans("LastSubscriptionDate");
- print ' | '.dol_print_date($member->last_subscription_date,'day');
- print ' |
'."\n";
-
- // Last subscription amount
-
- print '
| '.$langs->trans("LastSubscriptionAmount");
- print ' | '.price($member->last_subscription_amount);
- print ' |
'."\n";
-
- if (empty($amount) && ! GETPOST('newamount')) $_GET['newamount']=$member->last_subscription_amount;
- }
-
- // Amount
-
- print '
| '.$langs->trans("Amount");
- if (empty($amount))
- {
- print ' ('.$langs->trans("ToComplete");
- if (! empty($conf->global->MEMBER_EXT_URL_SUBSCRIPTION_INFO)) print ' - '.$langs->trans("SeeHere").'';
- print ')';
- }
- print ' | ';
- if (empty($amount) || ! is_numeric($amount))
- {
- $valtoshow=GETPOST("newamount",'int');
- if (! empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) $valtoshow=max($conf->global->MEMBER_MIN_AMOUNT,$valtoshow);
- print '';
- print '';
- }
- else {
- $valtoshow=$amount;
- if (! empty($conf->global->MEMBER_MIN_AMOUNT) && $valtoshow) $valtoshow=max($conf->global->MEMBER_MIN_AMOUNT,$valtoshow);
- print ''.price($valtoshow).'';
- print '';
- print '';
- }
- // Currency
- print ' '.$langs->trans("Currency".$currency).'';
- print '';
- print ' |
'."\n";
-
-}
-
-
-
if (! $found && ! $mesg) $mesg=$langs->trans("ErrorBadParameters");
@@ -617,7 +283,7 @@ if ($action != 'dosign')
}
else
{
- dol_print_error_email('ERRORNEWONLINESIGNPAYPAL');
+ dol_print_error_email('ERRORNEWONLINESIGN');
}
}
else
diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php
index 175f3e1510e..e7e593fb831 100644
--- a/htdocs/public/payment/newpayment.php
+++ b/htdocs/public/payment/newpayment.php
@@ -673,7 +673,7 @@ if ($source == 'order')
$order=new Commande($db);
$result=$order->fetch('',$ref);
- if ($result < 0)
+ if ($result <= 0)
{
$mesg=$order->error;
$error++;
@@ -788,7 +788,7 @@ if ($source == 'invoice')
$invoice=new Facture($db);
$result=$invoice->fetch('',$ref);
- if ($result < 0)
+ if ($result <= 0)
{
$mesg=$invoice->error;
$error++;
@@ -911,7 +911,7 @@ if ($source == 'contractline')
$contractline=new ContratLigne($db);
$result=$contractline->fetch('',$ref);
- if ($result < 0)
+ if ($result <= 0)
{
$mesg=$contractline->error;
$error++;
@@ -1116,7 +1116,7 @@ if ($source == 'membersubscription')
$member=new Adherent($db);
$result=$member->fetch('',$ref);
- if ($result < 0)
+ if ($result <= 0)
{
$mesg=$member->error;
$error++;