Merge branch 'Dolibarr:develop' into SELECT_PRODUITS_LIST

This commit is contained in:
marcusdeangabriel
2023-03-21 10:43:13 +01:00
committed by GitHub
24 changed files with 422 additions and 128 deletions

View File

@@ -12,7 +12,7 @@
* Copyright (C) 2017 ATM Consulting <support@atm-consulting.fr>
* Copyright (C) 2017-2019 Nicolas ZABOURI <info@inovea-conseil.com>
* Copyright (C) 2017 Rui Strecht <rui.strecht@aliartalentos.com>
* Copyright (C) 2018-2021 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2018-2023 Frédéric France <frederic.france@netlogic.fr>
* Copyright (C) 2018 Josep Lluís Amador <joseplluis@lliuretic.cat>
* Copyright (C) 2023 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2021 Grégory Blémand <gregory.blemand@atm-consulting.fr>
@@ -183,6 +183,7 @@ abstract class CommonObject
public $fk_project;
/**
* @var Project The related project object
* @deprecated
* @see project
*/

View File

@@ -191,23 +191,23 @@ class Form
/**
* Output value of a field for an editable field
*
* @param string $text Text of label (not used in this function)
* @param string $htmlname Name of select field
* @param string $value Value to show/edit
* @param object $object Object (that we want to show)
* @param boolean $perm Permission to allow button to edit parameter
* @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols%', 'datepicker' ('day' do not work, don't know why), 'dayhour' or 'datehourpicker', 'ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols', 'select;xkey:xval,ykey:yval,...')
* @param string $editvalue When in edit mode, use this value as $value instead of value (for example, you can provide here a formated price instead of numeric value). Use '' to use same than $value
* @param object $extObject External object ???
* @param mixed $custommsg String or Array of custom messages : eg array('success' => 'MyMessage', 'error' => 'MyMessage')
* @param string $moreparam More param to add on the form on action href URL parameter
* @param int $notabletag Do no output table tags
* @param string $formatfunc Call a specific function to output field in view mode (For example: 'dol_print_email')
* @param string $paramid Key of parameter for id ('id', 'socid')
* @param string $gm 'auto' or 'tzuser' or 'tzuserrel' or 'tzserver' (when $typeofdata is a date)
* @param array $moreoptions Array with more options. For example array('addnowlink'=>1), array('valuealreadyhtmlescaped'=>1)
* @param string $editaction [=''] use GETPOST default action or set action to edit mode
* @return string HTML edit field
* @param string $text Text of label (not used in this function)
* @param string $htmlname Name of select field
* @param string $value Value to show/edit
* @param object $object Object (that we want to show)
* @param boolean $perm Permission to allow button to edit parameter
* @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols%', 'datepicker' ('day' do not work, don't know why), 'dayhour' or 'datehourpicker', 'ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols', 'select;xkey:xval,ykey:yval,...')
* @param string $editvalue When in edit mode, use this value as $value instead of value (for example, you can provide here a formated price instead of numeric value, or a select combo). Use '' to use same than $value
* @param object $extObject External object ???
* @param mixed $custommsg String or Array of custom messages : eg array('success' => 'MyMessage', 'error' => 'MyMessage')
* @param string $moreparam More param to add on the form on action href URL parameter
* @param int $notabletag Do no output table tags
* @param string $formatfunc Call a specific method of $object->$formatfunc to output field in view mode (For example: 'dol_print_email')
* @param string $paramid Key of parameter for id ('id', 'socid')
* @param string $gm 'auto' or 'tzuser' or 'tzuserrel' or 'tzserver' (when $typeofdata is a date)
* @param array $moreoptions Array with more options. For example array('addnowlink'=>1), array('valuealreadyhtmlescaped'=>1)
* @param string $editaction [=''] use GETPOST default action or set action to edit mode
* @return string HTML edit field
*/
public function editfieldval($text, $htmlname, $value, $object, $perm, $typeofdata = 'string', $editvalue = '', $extObject = null, $custommsg = null, $moreparam = '', $notabletag = 1, $formatfunc = '', $paramid = 'id', $gm = 'auto', $moreoptions = array(), $editaction = '')
{
@@ -310,6 +310,8 @@ class Form
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
$doleditor = new DolEditor($htmlname, ($editvalue ? $editvalue : $value), (empty($tmp[2]) ? '' : $tmp[2]), (empty($tmp[3]) ? '100' : $tmp[3]), (empty($tmp[1]) ? 'dolibarr_notes' : $tmp[1]), 'In', (empty($tmp[5]) ? 0 : $tmp[5]), (isset($tmp[8]) ? ($tmp[8] ? true : false) : true), true, (empty($tmp[6]) ? '20' : $tmp[6]), (empty($tmp[7]) ? '100' : $tmp[7]));
$ret .= $doleditor->Create(1);
} elseif ($typeofdata == 'asis') {
$ret .= ($editvalue ? $editvalue : $value);
}
if (empty($notabletag)) {
$ret .= '</td>';
@@ -7970,7 +7972,13 @@ class Form
}
// Add where from hooks
$parameters = array();
$parameters = array(
'object' => $objecttmp,
'htmlname' => $htmlname,
'filter' => $filter,
'searchkey' => $searchkey
);
$reshook = $hookmanager->executeHooks('selectForFormsListWhere', $parameters); // Note that $action and $object may have been modified by hook
if (!empty($hookmanager->resPrint)) {
$sql .= $hookmanager->resPrint;

View File

@@ -989,15 +989,15 @@ class FormCompany extends Form
// phpcs:enable
$tax = get_localtax_by_third($local);
$num = $this->db->num_rows($tax);
$i = 0;
if ($num) {
if ($tax) {
$valors = explode(":", $tax);
$nbvalues = count($valors);
if (count($valors) > 1) {
if ($nbvalues > 1) {
//montar select
print '<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">';
while ($i <= (count($valors)) - 1) {
$i = 0;
while ($i < $nbvalues) {
if ($selected == $valors[$i]) {
print '<option value="'.$valors[$i].'" selected>';
} else {
@@ -1007,7 +1007,7 @@ class FormCompany extends Form
print '</option>';
$i++;
}
print'</select>';
print '</select>';
}
}
}

View File

@@ -6190,30 +6190,30 @@ function isOnlyOneLocalTax($local)
/**
* Get values of localtaxes (1 or 2) for company country for the common vat with the highest value
*
* @param int $local LocalTax to get
* @return number Values of localtax
* @param int $local LocalTax to get
* @return string Values of localtax (Can be '20', '-19:-15:-9')
*/
function get_localtax_by_third($local)
{
global $db, $mysoc;
$sql = "SELECT t.localtax1, t.localtax2 ";
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t inner join ".MAIN_DB_PREFIX."c_country as c ON c.rowid=t.fk_pays";
$sql .= " WHERE c.code = '".$db->escape($mysoc->country_code)."' AND t.active = 1 AND t.taux=(";
$sql .= " SELECT max(tt.taux) FROM ".MAIN_DB_PREFIX."c_tva as tt inner join ".MAIN_DB_PREFIX."c_country as c ON c.rowid=tt.fk_pays";
$sql .= " WHERE c.code = '".$db->escape($mysoc->country_code)."' AND tt.active = 1";
$sql .= " )";
$sql = " SELECT t.localtax".$local." as localtax";
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t INNER JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = t.fk_pays";
$sql .= " WHERE c.code = '".$db->escape($mysoc->country_code)."' AND t.active = 1 AND t.taux = (";
$sql .= "SELECT MAX(tt.taux) FROM ".MAIN_DB_PREFIX."c_tva as tt INNER JOIN ".MAIN_DB_PREFIX."c_country as c ON c.rowid = tt.fk_pays";
$sql .= " WHERE c.code = '".$db->escape($mysoc->country_code)."' AND tt.active = 1)";
$sql .= " AND t.localtax".$local."_type <> '0'";
$sql .= " ORDER BY t.rowid DESC";
$resql = $db->query($sql);
if ($resql) {
$obj = $db->fetch_object($resql);
if ($local == 1) {
return $obj->localtax1;
} elseif ($local == 2) {
return $obj->localtax2;
}
return $obj->localtax;
} else {
return 'Error';
}
return 0;
return '0';
}
@@ -6322,10 +6322,12 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisi
}
$sql .= ", ".MAIN_DB_PREFIX."c_country as c";
if ($mysoc->country_code == 'ES') {
$sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($buyer->country_code)."'"; // local tax in spain use the buyer country ??
if (!empty($mysoc) && $mysoc->country_code == 'ES') {
$countrycodetouse = ((empty($buyer) || empty($buyer->country_code)) ? $mysoc->country_code : $buyer->country_code);
$sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($countrycodetouse)."'"; // local tax in spain use the buyer country ??
} else {
$sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape(empty($seller->country_code) ? $mysoc->country_code : $seller->country_code)."'";
$countrycodetouse = ((empty($seller) || empty($seller->country_code)) ? $mysoc->country_code : $seller->country_code);
$sql .= " WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($countrycodetouse)."'";
}
$sql .= " AND t.taux = ".((float) $vatratecleaned)." AND t.active = 1";
if ($vatratecode) {