Skip to content

Commit

Permalink
Merge branch '18.0' into fix_32835
Browse files Browse the repository at this point in the history
  • Loading branch information
FHenry authored Feb 7, 2025
2 parents 60f3a07 + 28d588f commit 74c798c
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 34 deletions.
6 changes: 3 additions & 3 deletions htdocs/accountancy/admin/categories_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@

// Requests to extract data
$tabsql = array();
$tabsql[32] = "SELECT a.rowid as rowid, a.code as code, a.label, a.range_account, a.category_type, a.formula, a.position as position, a.fk_country as country_id, c.code as country_code, c.label as country, a.active FROM ".MAIN_DB_PREFIX."c_accounting_category as a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_country=c.rowid and c.active=1";
$tabsql[32] = "SELECT a.rowid as rowid, a.code as code, a.label, a.range_account, a.category_type, a.formula, a.position as position, a.fk_country as country_id, c.code as country_code, c.label as country, a.active FROM ".MAIN_DB_PREFIX."c_accounting_category as a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_country=c.rowid AND c.active=1 AND a.entity IN (".getEntity('c_accounting_category').")";

// Criteria to sort dictionaries
$tabsqlsort = array();
Expand All @@ -99,11 +99,11 @@

// Name of editing fields for record modification
$tabfieldvalue = array();
$tabfieldvalue[32] = "code,label,range_account,category_type,formula,position,country_id";
$tabfieldvalue[32] = "code,label,range_account,category_type,formula,position,country_id,entity";

// Name of the fields in the table for inserting a record
$tabfieldinsert = array();
$tabfieldinsert[32] = "code,label,range_account,category_type,formula,position,fk_country";
$tabfieldinsert[32] = "code,label,range_account,category_type,formula,position,fk_country,entity";

// Name of the rowid if the field is not of type autoincrement
// Example: "" if id field is "rowid" and has autoincrement on
Expand Down
6 changes: 6 additions & 0 deletions htdocs/comm/action/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,12 @@
if ($usergroup > 0) {
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ugu ON ugu.fk_user = ar.fk_element";
}

// Add table from hooks
$parameters = array();
$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
$sql .= $hookmanager->resPrint;

$sql .= " WHERE a.entity IN (".getEntity('agenda').")";
// Condition on actioncode
if (!empty($actioncode)) {
Expand Down
48 changes: 26 additions & 22 deletions htdocs/core/class/html.formticket.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ function(response) {

// Type of Ticket
print '<tr><td class="titlefield"><span class="fieldrequired"><label for="selecttype_code">'.$langs->trans("TicketTypeRequest").'</span></label></td><td>';
$this->selectTypesTickets((GETPOST('type_code', 'alpha') ? GETPOST('type_code', 'alpha') : $this->type_code), 'type_code', '', 2, 1, 0, 0, 'minwidth200');
$this->selectTypesTickets((GETPOST('type_code', 'alpha') ? GETPOST('type_code', 'alpha') : $this->type_code), 'type_code', '', 2, 'ifone', 0, 0, 'minwidth200');
print '</td></tr>';

// Group => Category
Expand All @@ -342,12 +342,12 @@ function(response) {
$filter = 'public=1';
}
$selected = (GETPOST('category_code') ? GETPOST('category_code') : $this->category_code);
$this->selectGroupTickets($selected, 'category_code', $filter, 2, 1, 0, 0, 'minwidth200');
$this->selectGroupTickets($selected, 'category_code', $filter, 2, 'ifone', 0, 0, 'minwidth200');
print '</td></tr>';

// Severity => Priority
print '<tr><td><span class="fieldrequired"><label for="selectseverity_code">'.$langs->trans("TicketSeverity").'</span></label></td><td>';
$this->selectSeveritiesTickets((GETPOST('severity_code') ? GETPOST('severity_code') : $this->severity_code), 'severity_code', '', 2, 1);
$this->selectSeveritiesTickets((GETPOST('severity_code') ? GETPOST('severity_code') : $this->severity_code), 'severity_code', '', 2, 'ifone');
print '</td></tr>';

if (!empty($conf->knowledgemanagement->enabled)) {
Expand Down Expand Up @@ -690,8 +690,8 @@ function(response) {
* @param string|array $selected Id of preselected field or array of Ids
* @param string $htmlname Nom de la zone select
* @param string $filtertype To filter on field type in llx_c_ticket_type (array('code'=>xx,'label'=>zz))
* @param int $format 0=id+libelle, 1=code+code, 2=code+libelle, 3=id+code
* @param int $empty 1=peut etre vide, 0 sinon
* @param int $format 0=id+label, 1=code+code, 2=code+label, 3=id+code
* @param int|string $empty 1 = can be empty or 'string' to show the string as the empty value, 0 = can't be empty, 'ifone' = can be empty but autoselected if there is one only
* @param int $noadmininfo 0=Add admin info, 1=Disable admin info
* @param int $maxlength Max length of label
* @param string $morecss More CSS
Expand All @@ -715,9 +715,9 @@ public function selectTypesTickets($selected = '', $htmlname = 'tickettype', $fi

$ticketstat->loadCacheTypesTickets();

print '<select id="select'.$htmlname.'" class="flat minwidth100'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.($multiselect?'[]':'').'"'.($multiselect?' multiple':'').'>';
if ($empty && !$multiselect) {
print '<option value="">&nbsp;</option>';
print '<select id="select'.$htmlname.'" class="flat minwidth100'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.($multiselect ? '[]' : '').'"'.($multiselect ? ' multiple' : '').'>';
if ($empty) {
print '<option value="">'.((is_numeric($empty) || $empty == 'ifone') ? '&nbsp;' : $empty).'</option>';
}

if (is_array($ticketstat->cache_types_tickets) && count($ticketstat->cache_types_tickets)) {
Expand Down Expand Up @@ -755,6 +755,8 @@ public function selectTypesTickets($selected = '', $htmlname = 'tickettype', $fi
print ' selected="selected"';
} elseif ($arraytypes['use_default'] == "1" && empty($selected) && !$multiselect) {
print ' selected="selected"';
} elseif (count($ticketstat->cache_types_tickets) == 1 && (!$empty || $empty == 'ifone')) { // If only 1 choice, we autoselect it
print ' selected="selected"';
}

print '>';
Expand Down Expand Up @@ -813,10 +815,10 @@ public function selectGroupTickets($selected = '', $htmlname = 'ticketcategory',
$ticketstat = new Ticket($this->db);
$ticketstat->loadCacheCategoriesTickets($publicgroups ? 1 : -1); // get list of active ticket groups

if ($use_multilevel <= 0) {
if ($use_multilevel <= 0) { // Only one combo list to select the group of ticket (default)
print '<select id="select'.$htmlname.'" class="flat minwidth100'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'">';
if ($empty) {
print '<option value="">&nbsp;</option>';
print '<option value="">'.((is_numeric($empty) || $empty == 'ifone') ? '&nbsp;' : $empty).'</option>';
}

if (is_array($ticketstat->cache_category_tickets) && count($ticketstat->cache_category_tickets)) {
Expand Down Expand Up @@ -861,9 +863,9 @@ public function selectGroupTickets($selected = '', $htmlname = 'ticketcategory',
print ' selected="selected"';
} elseif (isset($selected) && $selected == $id) {
print ' selected="selected"';
} elseif ($arraycategories['use_default'] == "1" && !$selected && !$empty) {
} elseif ($arraycategories['use_default'] == "1" && !$selected && (!$empty || $empty == 'ifone')) {
print ' selected="selected"';
} elseif (count($ticketstat->cache_category_tickets) == 1) {
} elseif (count($ticketstat->cache_category_tickets) == 1 && (!$empty || $empty == 'ifone')) {
print ' selected="selected"';
}

Expand Down Expand Up @@ -1135,14 +1137,14 @@ public function selectGroupTickets($selected = '', $htmlname = 'ticketcategory',
/**
* Return html list of ticket severitys (priorities)
*
* @param string $selected Id severity pre-selected
* @param string $htmlname Name of the select area
* @param string $filtertype To filter on field type in llx_c_ticket_severity (array('code'=>xx,'label'=>zz))
* @param int $format 0 = id+label, 1 = code+code, 2 = code+label, 3 = id+code
* @param int $empty 1 = can be empty, 0 = or not
* @param int $noadmininfo 0 = add admin info, 1 = disable admin info
* @param int $maxlength Max length of label
* @param string $morecss More CSS
* @param string $selected Id severity pre-selected
* @param string $htmlname Name of the select area
* @param string $filtertype To filter on field type in llx_c_ticket_severity (array('code'=>xx,'label'=>zz))
* @param int $format 0 = id+label, 1 = code+code, 2 = code+label, 3 = id+code
* @param int|string $empty 1 = can be empty or 'string' to show the string as the empty value, 0 = can't be empty, 'ifone' = can be empty but autoselected if there is one only
* @param int $noadmininfo 0 = add admin info, 1 = disable admin info
* @param int $maxlength Max length of label
* @param string $morecss More CSS
* @return void
*/
public function selectSeveritiesTickets($selected = '', $htmlname = 'ticketseverity', $filtertype = '', $format = 0, $empty = 0, $noadmininfo = 0, $maxlength = 0, $morecss = '')
Expand All @@ -1163,7 +1165,7 @@ public function selectSeveritiesTickets($selected = '', $htmlname = 'ticketsever

print '<select id="select'.$htmlname.'" class="flat minwidth100'.($morecss ? ' '.$morecss : '').'" name="'.$htmlname.'">';
if ($empty) {
print '<option value="">&nbsp;</option>';
print '<option value="">'.((is_numeric($empty) || $empty == 'ifone') ? '&nbsp;' : $empty).'</option>';
}

if (is_array($ticketstat->cache_severity_tickets) && count($ticketstat->cache_severity_tickets)) {
Expand Down Expand Up @@ -1199,7 +1201,9 @@ public function selectSeveritiesTickets($selected = '', $htmlname = 'ticketsever
print ' selected="selected"';
} elseif (isset($selected) && $selected == $id) {
print ' selected="selected"';
} elseif ($arrayseverities['use_default'] == "1" && empty($selected)) {
} elseif ($arrayseverities['use_default'] == "1" && empty($selected) && (!$empty || $empty == 'ifone')) {
print ' selected="selected"';
} elseif (count($ticketstat->cache_severity_tickets) == 1 && (!$empty || $empty == 'ifone')) { // If only 1 choice, we autoselect it
print ' selected="selected"';
}

Expand Down
2 changes: 1 addition & 1 deletion htdocs/core/lib/files.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1448,7 +1448,7 @@ function dol_delete_file($file, $disableglob = 0, $nophperrors = 0, $nohook = 0,
}
}
} else {
$ok = false; // to avoid false positive
$ok = true; // nothing to delete when glob is on must return ok
dol_syslog("No files to delete found", LOG_DEBUG);
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion htdocs/expedition/dispatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@
setEventMessages($error, $errors, 'errors');
} else {
$db->commit();
setEventMessages($langs->trans("ReceptionUpdated"), null);
setEventMessages($langs->trans("ShipmentUpdated"), null);

header("Location: ".DOL_URL_ROOT.'/expedition/dispatch.php?id='.$object->id);
exit;
Expand Down
10 changes: 5 additions & 5 deletions htdocs/fourn/class/fournisseur.commande.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2302,9 +2302,9 @@ public function delete(User $user, $notrigger = 0)
}
}

$main = MAIN_DB_PREFIX.'commande_fournisseurdet';
$main = $this->db->prefix().'commande_fournisseurdet';
$ef = $main."_extrafields";
$sql = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_commande = ".((int) $this->id).")";
$sql = "DELETE FROM ".$this->db->sanitize($ef)." WHERE fk_object IN (SELECT rowid FROM ".$this->db->sanitize($main)." WHERE fk_commande = ".((int) $this->id).")";
dol_syslog(get_class($this)."::delete extrafields lines", LOG_DEBUG);
if (!$this->db->query($sql)) {
$this->error = $this->db->lasterror();
Expand All @@ -2313,7 +2313,7 @@ public function delete(User $user, $notrigger = 0)
}

if (!$error) {
$sql1 = "UPDATE ".$this->db->prefix()."commandedet SET fk_commandefourndet = NULL WHERE fk_commandefourndet IN (SELECT rowid FROM ".$main." WHERE fk_commande = ".((int) $this->id).")";
$sql1 = "UPDATE ".$this->db->prefix()."commandedet SET fk_commandefourndet = NULL WHERE fk_commandefourndet IN (SELECT rowid FROM ".$this->db->sanitize($main)." WHERE fk_commande = ".((int) $this->id).")";
dol_syslog(__METHOD__." linked order lines", LOG_DEBUG);
if (!$this->db->query($sql1)) {
$error++;
Expand All @@ -2322,15 +2322,15 @@ public function delete(User $user, $notrigger = 0)
}
}

$sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseurdet WHERE fk_commande =".((int) $this->id);
$sql = "DELETE FROM ".$this->db->prefix()."commande_fournisseurdet WHERE fk_commande =".((int) $this->id);
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
if (!$this->db->query($sql)) {
$this->error = $this->db->lasterror();
$this->errors[] = $this->db->lasterror();
$error++;
}

$sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseur WHERE rowid =".((int) $this->id);
$sql = "DELETE FROM ".$this->db->prefix()."commande_fournisseur WHERE rowid =".((int) $this->id);
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
if ($resql = $this->db->query($sql)) {
if ($this->db->affected_rows($resql) < 1) {
Expand Down
1 change: 1 addition & 0 deletions htdocs/langs/en_US/sendings.lang
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ NoProductToShipFoundIntoStock=No product to ship found in warehouse <b>%s</b>. C
WeightVolShort=Weight/Vol.
ValidateOrderFirstBeforeShipment=You must first validate the order before being able to make shipments.
NoLineGoOnTabToAddSome=No line, go on tab "%s" to add
ShipmentUpdated=Shipment successfully updated

# Sending methods
# ModelDocument
Expand Down
2 changes: 1 addition & 1 deletion htdocs/projet/tasks/task.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
$upload_dir = $conf->project->dir_output."/".dol_sanitizeFileName($projectstatic->ref)."/".dol_sanitizeFileName($object->ref);
$file = $upload_dir.'/'.dol_sanitizeFileName(GETPOST('file'));

$ret = dol_delete_file($file);
$ret = dol_delete_file($file, 1);
if ($ret) {
setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs');
} else {
Expand Down
2 changes: 1 addition & 1 deletion test/phpunit/FilesLibTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ public function testDolCopyMoveDelete()
// Again to test there is error when deleting a non existing file with option disableglob
$result=dol_delete_file($conf->admin->dir_temp.'/file3.csv', 1, 1);
print __METHOD__." result=".$result."\n";
$this->assertFalse($result, 'delete file that does not exists with disableglo must return ko');
$this->assertFalse($result, 'delete file that does not exists with disabling glob must return ko');

// Again to test there is no error when deleting a non existing file without option disableglob
$result=dol_delete_file($conf->admin->dir_temp.'/file3csv', 0, 1);
Expand Down

0 comments on commit 74c798c

Please sign in to comment.