diff --git a/htdocs/admin/system/perf.php b/htdocs/admin/system/perf.php
index 0bdb442863d..f43bc3bf49a 100644
--- a/htdocs/admin/system/perf.php
+++ b/htdocs/admin/system/perf.php
@@ -51,6 +51,9 @@ print load_fiche_titre($langs->trans("PerfDolibarr"), '', 'title_setup');
print ''.$langs->trans("YouMayFindPerfAdviceHere", 'https://wiki.dolibarr.org/index.php/FAQ_Increase_Performance').' ('.$langs->trans("Reload").')
';
+print '
';
+print '
';
-print '| ';
+print ' | ';
print ' ';
print ' ';
print '';
print ' | ';
-print '';
+print ' | ';
print '';
diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php
index a07bc4850f0..ee25ea86eff 100644
--- a/htdocs/commande/list.php
+++ b/htdocs/commande/list.php
@@ -320,6 +320,8 @@ if (empty($reshook)) {
$db->begin();
+ $nbOrders = is_array($orders) ? count($orders) : 1;
+
foreach ($orders as $id_order) {
$cmd = new Commande($db);
if ($cmd->fetch($id_order) <= 0) {
@@ -455,10 +457,11 @@ if (empty($reshook)) {
$objecttmp->context['createfromclone'];
- $rang = $lines[$i]->rang;
+ $rang = ($nbOrders > 1) ? -1 : $lines[$i]->rang;
//there may already be rows from previous orders
- if (!empty($createbills_onebythird))
+ if (!empty($createbills_onebythird)) {
$rang = $TFactThirdNbLines[$cmd->socid];
+ }
$result = $objecttmp->addline(
$desc,
diff --git a/htdocs/core/ajax/onlineSign.php b/htdocs/core/ajax/onlineSign.php
index 994ba5c42f3..5f3cc281f90 100644
--- a/htdocs/core/ajax/onlineSign.php
+++ b/htdocs/core/ajax/onlineSign.php
@@ -69,10 +69,10 @@ $type = $mode;
// Check securitykey
$securekeyseed = '';
if ($type == 'proposal') {
- $securekeyseed = $conf->global->PROPOSAL_ONLINE_SIGNATURE_SECURITY_TOKEN;
+ $securekeyseed = isset($conf->global->PROPOSAL_ONLINE_SIGNATURE_SECURITY_TOKEN) ? $conf->global->PROPOSAL_ONLINE_SIGNATURE_SECURITY_TOKEN : '';
}
-if (!dol_verifyHash($securekeyseed.$type.$ref, $SECUREKEY, '0')) {
+if (empty($SECUREKEY) || !dol_verifyHash($securekeyseed.$type.$ref, $SECUREKEY, '0')) {
http_response_code(403);
print 'Bad value for securitykey. Value provided '.dol_escape_htmltag($SECUREKEY).' does not match expected value for ref='.dol_escape_htmltag($ref);
exit(-1);
@@ -122,28 +122,40 @@ if ($action == "importSignature") {
}
if (!$error) {
- $newpdffilename = $upload_dir.$ref."_signed-".$date.".pdf";
+ // Defined modele of doc
+ $directdownloadlink = $object->getLastMainDocLink('proposal');
- $pdf = pdf_getInstance();
- $pdf->Open();
- $pdf->AddPage();
- $pagecount = $pdf->setSourceFile($upload_dir.$ref.".pdf"); // original PDF
+ if (preg_match('/\.pdf/i', $directdownloadlink)) {
+ $newpdffilename = $upload_dir.$ref."_signed-".$date.".pdf";
+ $sourcefile = $upload_dir.$ref.".pdf";
- for ($i=1;$i<($pagecount+1);$i++) {
- if ($i>1) $pdf->AddPage();
- $tppl=$pdf->importPage($i);
- $pdf->useTemplate($tppl);
+ if (dol_is_file($sourcefile)) {
+ $pdf = pdf_getInstance();
+ $pdf->Open();
+ $pdf->AddPage();
+ $pagecount = $pdf->setSourceFile($sourcefile); // original PDF
+
+ for ($i=1; $i<($pagecount+1); $i++) {
+ if ($i>1) $pdf->AddPage();
+ $tppl=$pdf->importPage($i);
+ $pdf->useTemplate($tppl);
+ }
+
+ $pdf->Image($upload_dir.$filename, 129, 239.6, 60, 15); // FIXME Position will be wrong with non A4 format. Use a value from width and height of page minus relative offset.
+ $pdf->Close();
+ $pdf->Output($newpdffilename, "F");
+
+ // Index the new file and update the last_main_doc property of object.
+ $object->indexFile($newpdffilename, 1);
+ }
+ } else {
+ // Adding signature on doc not yet supported
}
+ }
- $pdf->Image($upload_dir.$filename, 129, 239.6, 60, 15); // FIXME Position will be wrong with non A4 format. Use a value from width and height of page minus relative offset.
- $pdf->Close();
- $pdf->Output($newpdffilename, "F");
-
+ if (!$error) {
$db->begin();
- // Index the new file and update the last_main_doc property of object.
- $object->indexFile($newpdffilename, 1);
-
$online_sign_ip = getUserRemoteIP();
$online_sign_name = ''; // TODO Ask name on form to sign
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index c16594b94e5..79b6932c72c 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -602,6 +602,8 @@ abstract class CommonObject
// No constructor as it is an abstract class
+
+
/**
* Check an object id/ref exists
* If you don't need/want to instantiate object and just need to know if object exists, use this method instead of fetch
@@ -648,6 +650,7 @@ abstract class CommonObject
return -1;
}
+
/**
* Method to output saved errors
*
@@ -5530,7 +5533,9 @@ abstract class CommonObject
* Index a file into the ECM database
*
* @param string $destfull Full path of file to index
- * @param int $update_main_doc_field Update field main_doc file into table of object
+ * @param int $update_main_doc_field Update field main_doc fied into the table of object.
+ * This param is set when called for a document generation if document generator hase
+ * ->update_main_doc_field set and returns ->result['fullpath'].
* @return int <0 if KO, >0 if OK
*/
public function indexFile($destfull, $update_main_doc_field)
@@ -8907,7 +8912,7 @@ abstract class CommonObject
}
}
} else {
- $this->{$field} = !empty($obj->{$field}) ? $obj->{$field} : null;
+ $this->{$field} = isset($obj->{$field}) ? $obj->{$field} : null;
}
}
diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php
index 72b2b2d2ed8..773638a5b79 100644
--- a/htdocs/core/class/extrafields.class.php
+++ b/htdocs/core/class/extrafields.class.php
@@ -2071,6 +2071,7 @@ class ExtraFields
}
if (!empty($onlykey) && $onlykey == '@GETPOSTISSET' && !GETPOSTISSET('options_'.$key) && (! in_array($this->attributes[$object->table_element]['type'][$key], array('boolean', 'chkbxlst')))) {
+ //when unticking boolean field, it's not set in POST
continue;
}
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 6d87116fd6b..a529bed6a6e 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -5458,9 +5458,10 @@ function print_fleche_navigation($page, $file, $options = '', $nextpage = 0, $be
* @param boolean $addpercent Add a percent % sign in output
* @param int $info_bits Miscellaneous information on vat (0=Default, 1=French NPR vat)
* @param int $usestarfornpr -1=Never show, 0 or 1=Use '*' for NPR vat rates
+ * @param int $html Used for html output
* @return string String with formated amounts ('19,6' or '19,6%' or '8.5% (NPR)' or '8.5% *' or '19,6 (CODEX)')
*/
-function vatrate($rate, $addpercent = false, $info_bits = 0, $usestarfornpr = 0)
+function vatrate($rate, $addpercent = false, $info_bits = 0, $usestarfornpr = 0, $html = 0)
{
$morelabel = '';
@@ -5468,9 +5469,11 @@ function vatrate($rate, $addpercent = false, $info_bits = 0, $usestarfornpr = 0)
$rate = str_replace('%', '', $rate);
$addpercent = true;
}
+ $reg = array();
if (preg_match('/\((.*)\)/', $rate, $reg)) {
$morelabel = ' ('.$reg[1].')';
$rate = preg_replace('/\s*'.preg_quote($morelabel, '/').'/', '', $rate);
+ $morelabel = ' '.($html ? '' : '').'('.$reg[1].')'.($html ? '' : '');
}
if (preg_match('/\*/', $rate)) {
$rate = str_replace('*', '', $rate);
diff --git a/htdocs/core/lib/invoice.lib.php b/htdocs/core/lib/invoice.lib.php
index 580e30db650..ea53ae065e3 100644
--- a/htdocs/core/lib/invoice.lib.php
+++ b/htdocs/core/lib/invoice.lib.php
@@ -954,6 +954,7 @@ function getCustomerInvoiceUnpaidOpenTable($maxCount = 500, $socid = 0)
$i++;
$total += $obj->total_ht;
$total_ttc += $obj->total_ttc;
+ $totalam += $obj->am;
continue;
}
diff --git a/htdocs/core/modules/modResource.class.php b/htdocs/core/modules/modResource.class.php
index b43ead29e7f..1d1d37ac240 100644
--- a/htdocs/core/modules/modResource.class.php
+++ b/htdocs/core/modules/modResource.class.php
@@ -239,22 +239,26 @@ class modResource extends DolibarrModules
$this->export_code[$r] = $this->rights_class.'_'.$r;
$this->export_label[$r] = "ResourceSingular"; // Translation key (used only if key ExportDataset_xxx_z not found)
$this->export_permission[$r] = array(array("resource", "read"));
- $this->export_fields_array[$r] = array('r.rowid'=>'IdResource', 'r.ref'=>'ResourceFormLabel_ref', 'c.code'=>'ResourceTypeCode', 'c.label'=>'ResourceType', 'r.description'=>'ResourceFormLabel_description', 'r.note_private'=>"NotePrivate", 'r.note_public'=>"NotePublic", 'r.asset_number'=>'AssetNumber', 'r.datec'=>"DateCreation", 'r.tms'=>"DateLastModification");
+
+ $this->export_fields_array[$r] = array('r.rowid'=>'IdResource', 'r.ref'=>'ResourceFormLabel_ref', 'c.rowid'=>'ResourceTypeID', 'c.code'=>'ResourceTypeCode', 'c.label'=>'ResourceTypeLabel', 'r.description'=>'ResourceFormLabel_description', 'r.note_private'=>"NotePrivate", 'r.note_public'=>"NotePublic", 'r.asset_number'=>'AssetNumber', 'r.datec'=>"DateCreation", 'r.tms'=>"DateLastModification");
$this->export_TypeFields_array[$r] = array('r.rowid'=>'List:resource:ref', 'r.ref'=>'Text', 'r.asset_number'=>'Text', 'r.description'=>'Text', 'c.code'=>'Text', 'c.label'=>'List:c_type_resource:label', 'r.datec'=>'Date', 'r.tms'=>'Date', 'r.note_private'=>'Text', 'r.note_public'=>'Text');
$this->export_entities_array[$r] = array('r.rowid'=>'resource', 'r.ref'=>'resource', 'c.code'=>'resource', 'c.label'=>'resource', 'r.description'=>'resource', 'r.note_private'=>"resource", 'r.resource'=>"resource", 'r.asset_number'=>'resource', 'r.datec'=>"resource", 'r.tms'=>"resource");
+
$keyforselect = 'resource';
$keyforelement = 'resource';
$keyforaliasextra = 'extra';
+
include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
$this->export_dependencies_array[$r] = array('resource'=>array('r.rowid')); // We must keep this until the aggregate_array is used. To add unique key if we ask a field of a child to avoid the DISTINCT to discard them.
$this->export_sql_start[$r] = 'SELECT DISTINCT ';
$this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'resource as r';
- $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_resource as c ON c.rowid=r.fk_code_type_resource';
+ $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_type_resource as c ON c.code = r.fk_code_type_resource';
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'resource_extrafields as extra ON extra.fk_object = r.rowid';
$this->export_sql_end[$r] .= ' WHERE r.entity IN ('.getEntity('resource').')';
+
// Imports
//--------
$r = 0;
diff --git a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php
index 6f91d676949..7f2e0733e9d 100644
--- a/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php
+++ b/htdocs/core/modules/propale/doc/doc_generic_proposal_odt.modules.php
@@ -71,6 +71,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales
$this->db = $db;
$this->name = "ODT templates";
$this->description = $langs->trans("DocumentModelOdt");
+ $this->update_main_doc_field = 1; // Save the name of generated file as the main doc when generating a doc with this template
$this->scandir = 'PROPALE_ADDON_PDF_ODT_PATH'; // Name of constant that is used to save list of directories to scan
// Page size for A4 format
diff --git a/htdocs/core/modules/propale/modules_propale.php b/htdocs/core/modules/propale/modules_propale.php
index ee7df804c59..dcb386947a3 100644
--- a/htdocs/core/modules/propale/modules_propale.php
+++ b/htdocs/core/modules/propale/modules_propale.php
@@ -67,7 +67,7 @@ abstract class ModelePDFPropales extends CommonDocGenerator
/**
- * Classe mere des modeles de numerotation des references de propales
+ * Parent class for numbering rules of proposals
*/
abstract class ModeleNumRefPropales
{
diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php
index d4130d1b220..333315b98c5 100644
--- a/htdocs/fourn/class/fournisseur.product.class.php
+++ b/htdocs/fourn/class/fournisseur.product.class.php
@@ -960,7 +960,7 @@ class ProductFournisseur extends Product
public function display_price_product_fournisseur($showunitprice = 1, $showsuptitle = 1, $maxlen = 0, $notooltip = 0, $productFournList = array())
{
// phpcs:enable
- global $langs;
+ global $conf, $langs;
$out = '';
$langs->load("suppliers");
@@ -978,7 +978,7 @@ class ProductFournisseur extends Product
}
$out .= '';
} else {
- $out = ($showunitprice ? price($this->fourn_unitprice * (1 - $this->fourn_remise_percent / 100) + $this->fourn_remise).' '.$langs->trans("HT").' (' : '');
+ $out = ($showunitprice ? price($this->fourn_unitprice * (1 - $this->fourn_remise_percent / 100) + $this->fourn_remise, 0, $langs, 1, -1, -1, $conf->currency).' '.$langs->trans("HT").' (' : '');
$out .= ($showsuptitle ? ''.$langs->trans("Supplier").': ' : '').$this->getSocNomUrl(1, 'supplier', $maxlen, $notooltip).' / '.$langs->trans("SupplierRef").': '.$this->ref_supplier;
$out .= ($showunitprice ? ')' : '');
}
diff --git a/htdocs/langs/en_US/languages.lang b/htdocs/langs/en_US/languages.lang
index 6de4824ecea..9350efef602 100644
--- a/htdocs/langs/en_US/languages.lang
+++ b/htdocs/langs/en_US/languages.lang
@@ -40,6 +40,7 @@ Language_es_AR=Spanish (Argentina)
Language_es_BO=Spanish (Bolivia)
Language_es_CL=Spanish (Chile)
Language_es_CO=Spanish (Colombia)
+Language_es_CR=Spanish (Costa Rica)
Language_es_DO=Spanish (Dominican Republic)
Language_es_EC=Spanish (Ecuador)
Language_es_GT=Spanish (Guatemala)
diff --git a/htdocs/product/price.php b/htdocs/product/price.php
index bf85d5dd15b..618e5cc6a78 100644
--- a/htdocs/product/price.php
+++ b/htdocs/product/price.php
@@ -1177,7 +1177,7 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_
if (empty($positiverates)) {
$positiverates = '0';
}
- echo vatrate($positiverates.($object->default_vat_code ? ' ('.$object->default_vat_code.')' : ''), '%', $object->tva_npr);
+ echo vatrate($positiverates.($object->default_vat_code ? ' ('.$object->default_vat_code.')' : ''), '%', $object->tva_npr, 0, 1);
/*
if ($object->default_vat_code)
{
diff --git a/htdocs/public/onlinesign/newonlinesign.php b/htdocs/public/onlinesign/newonlinesign.php
index d1020dc2c1d..5e920444c35 100644
--- a/htdocs/public/onlinesign/newonlinesign.php
+++ b/htdocs/public/onlinesign/newonlinesign.php
@@ -328,7 +328,7 @@ if ($source == 'proposal') {
// Object
$text = ''.$langs->trans("SignatureProposalRef", $proposal->ref).'';
- print ' |