Merge branch '13.0' of git@github.com:Dolibarr/dolibarr.git into develop

Conflicts:
	htdocs/admin/mails_templates.php
	htdocs/core/actions_linkedfiles.inc.php
	htdocs/core/lib/functions.lib.php
	htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php
	htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php
	htdocs/societe/consumption.php
This commit is contained in:
Laurent Destailleur 2021-05-06 17:07:44 +02:00
commit bd5e141d26
12 changed files with 40 additions and 15 deletions

View File

@ -542,7 +542,7 @@ $cfg['ThemePerServer'] = FALSE; // allow diferent theme for each co
* %f will be replaced by a list of field names.
* (%t and %f only applies to DefaultQueryTable)
*/
$cfg['DefaultQueryTable'] = 'SELECT * FROM %t WHERE 1';
$cfg['DefaultQueryTable'] = 'SELECT * FROM %t WHERE 1 = 1';
$cfg['DefaultQueryDatabase'] = '';
/**

View File

@ -333,13 +333,13 @@ if (empty($reshook)) {
}
}
// Si verif ok et action add, on ajoute la ligne
// If previous test is ok action is add, we add the line
if ($ok && GETPOST('actionadd')) {
// Add new entry
$sql = "INSERT INTO ".$tabname[$id]." (";
// List of fields
$sql .= $tabfieldinsert[$id];
$sql .= ",active)";
$sql .= ", active, enabled)";
$sql .= " VALUES(";
// List of values
@ -390,7 +390,7 @@ if (empty($reshook)) {
}
$i++;
}
$sql .= ", 1)";
$sql .= ", 1, 1)";
dol_syslog("actionadd", LOG_DEBUG);
$result = $db->query($sql);

View File

@ -1680,6 +1680,28 @@ class Account extends CommonObject
$this->owner_address = 'Owner address';
$this->country_id = 1;
}
/**
* Function used to replace a thirdparty id with another one.
*
* @param DoliDB $db Database handler
* @param int $origin_id Old thirdparty id
* @param int $dest_id New thirdparty id
* @return bool
*/
public static function replaceThirdparty($db, $origin_id, $dest_id)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."bank_url SET url_id = ".((int) $dest_id)." WHERE url_id = ".((int) $origin_id)." AND type='company'";
if (!$db->query($sql))
{
//if ($ignoreerrors) return true; // TODO Not enough. If there is A-B on kept thirdarty and B-C on old one, we must get A-B-C after merge. Not A-B.
//$this->errors = $db->lasterror();
return false;
} else {
return true;
}
}
}

View File

@ -68,7 +68,7 @@ if (GETPOST('sendit', 'alpha') && !empty($conf->global->MAIN_UPLOAD_DOC)) {
} elseif (GETPOST('linkit', 'restricthtml') && !empty($conf->global->MAIN_UPLOAD_DOC)) {
$link = GETPOST('link', 'alpha');
if ($link) {
if (substr($link, 0, 7) != 'http://' && substr($link, 0, 8) != 'https://' && substr($link, 0, 7) != 'file://') {
if (substr($link, 0, 7) != 'http://' && substr($link, 0, 8) != 'https://' && substr($link, 0, 7) != 'file://' && substr($link, 0, 7) != 'davs://') {
$link = 'http://'.$link;
}
dol_add_file_process($upload_dir, 0, 1, 'userfile', null, $link, '', 0);

View File

@ -2029,7 +2029,7 @@ class FormFile
print '<td class="center">'.dol_print_date($link->datea, "dayhour", "tzuser").'</td>';
print '<td class="center"></td>';
print '<td class="right">';
print '<a href="'.$_SERVER['PHP_SELF'].'?action=update&linkid='.$link->id.$param.'" class="editfilelink editfielda reposition" >'.img_edit().'</a>'; // id= is included into $param
print '<a href="'.$_SERVER['PHP_SELF'].'?action=update&linkid='.$link->id.$param.'&token='.newToken().'" class="editfilelink editfielda reposition" >'.img_edit().'</a>'; // id= is included into $param
if ($permissiontodelete) {
print ' &nbsp; <a class="deletefilelink" href="'.$_SERVER['PHP_SELF'].'?action=delete&token='.newToken().'&linkid='.$link->id.$param.'">'.img_delete().'</a>'; // id= is included into $param
} else {

View File

@ -9386,7 +9386,8 @@ function getDictvalue($tablename, $field, $id, $checkentity = false, $rowidfield
if (!isset($dictvalues[$tablename])) {
$dictvalues[$tablename] = array();
$sql = 'SELECT * FROM '.$tablename.' WHERE 1'; // Here select * is allowed as it is generic code and we don't have list of fields
$sql = 'SELECT * FROM '.$tablename.' WHERE 1 = 1'; // Here select * is allowed as it is generic code and we don't have list of fields
if ($checkentity) {
$sql .= ' AND entity IN (0,'.getEntity($tablename).')';
}
@ -9675,6 +9676,7 @@ function dolGetButtonAction($label, $html = '', $actionType = 'default', $url =
$class = 'butAction';
if ($actionType == 'danger' || $actionType == 'delete') {
$class = 'butActionDelete';
if (strpos($url, 'token=') === false) $url .= '&token='.newToken();
}
$attr = array(

View File

@ -231,10 +231,10 @@ class pdf_cornas extends ModelePDFSuppliersOrders
$objphoto->fetch($object->lines[$i]->fk_product);
if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {
$pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/";
$pdir = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/";
$dir = $conf->product->dir_output.'/'.$pdir;
} else {
$pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
$pdir = get_exdir($objphoto->id, 0, 0, 0, $objphoto, 'product');
$dir = $conf->product->dir_output.'/'.$pdir;
}

View File

@ -246,13 +246,12 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$objphoto->fetch($object->lines[$i]->fk_product);
if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {
$pdir = get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/";
$pdir = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$object->lines[$i]->fk_product."/photos/";
$dir = $conf->product->dir_output.'/'.$pdir;
} else {
$pdir = get_exdir(0, 2, 0, 0, $objphoto, 'product').dol_sanitizeFileName($objphoto->ref).'/';
$pdir = get_exdir($objphoto->id, 0, 0, 0, $objphoto, 'product');
$dir = $conf->product->dir_output.'/'.$pdir;
}
$realpath = '';
foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
$filename = $obj['photo'];

View File

@ -587,4 +587,5 @@ insert into llx_c_actioncomm (id, code, type, libelle, module, active, position)
-- VMYSQL4.3 ALTER TABLE llx_accounting_bookkeeping MODIFY COLUMN montant double(24,8) NULL;
-- VPGSQL8.2 ALTER TABLE llx_accounting_bookkeeping ALTER COLUMN montant DROP NOT NULL;
ALTER TABLE llx_export_model MODIFY COLUMN type varchar(64);

View File

@ -270,7 +270,8 @@ if (empty($reshook)) {
'Product' => '/product/class/product.class.php',
'Project' => '/projet/class/project.class.php',
'Ticket' => '/ticket/class/ticket.class.php',
'User' => '/user/class/user.class.php'
'User' => '/user/class/user.class.php',
'Account' => '/compta/bank/class/account.class.php',
);
//First, all core objects must update their tables

View File

@ -352,7 +352,7 @@ if (!empty($sql_select)) {
$sql .= " AND ".$doc_number." LIKE '%".$db->escape($sref)."%'";
}
if ($sprod_fulldescr) {
$sql .= " AND (d.description LIKE '%".$db->escape($sprod_fulldescr)."%'";
$sql .= " AND (d.description LIKE '%".$db->escape($sprod_fulldescr)."%' OR d.description LIKE '%".$db->escape(dol_htmlentities($sprod_fulldescr))."%'";
if (GETPOST('type_element') != 'fichinter') {
$sql .= " OR p.ref LIKE '%".$db->escape($sprod_fulldescr)."%'";
}

View File

@ -3399,7 +3399,7 @@ class User extends CommonObject
$sql .= " WHERE t.entity IN (".getEntity('user').")";
}
} else {
$sql .= " WHERE 1";
$sql .= " WHERE 1 = 1";
}
// Manage filter