Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
66daa3ffed
5 changed files with 92 additions and 4 deletions
|
|
@ -123,6 +123,11 @@ if ($id > 0 || !empty($ref)) {
|
|||
|
||||
// Define variables to determine what the current user can do on the members
|
||||
$permissiontoaddmember = $user->hasRight('adherent', 'creer');
|
||||
$permissiontoeditextra = $permissiontoaddmember;
|
||||
if (GETPOST('attribute', 'aZ09') && isset($extrafields->attributes[$object->table_element]['perms'][GETPOST('attribute', 'aZ09')])) {
|
||||
// For action 'update_extras', is there a specific permission set for the attribute to update
|
||||
$permissiontoeditextra = dol_eval((string) $extrafields->attributes[$object->table_element]['perms'][GETPOST('attribute', 'aZ09')]);
|
||||
}
|
||||
|
||||
// Security check
|
||||
$result = restrictedArea($user, 'adherent', $object->id, '', '', 'socid', 'rowid', 0);
|
||||
|
|
@ -138,6 +143,28 @@ if ($reshook < 0) {
|
|||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
}
|
||||
|
||||
if (empty($reshook) && $action == 'update_extras' && $permissiontoeditextra) {
|
||||
$error = 0;
|
||||
$object->oldcopy = dol_clone($object, 2); // @phan-suppress-current-line PhanTypeMismatchProperty
|
||||
$attribute_name = GETPOST('attribute', 'aZ09');
|
||||
|
||||
// Fill array 'array_options' with data from update form
|
||||
$ret = $extrafields->setOptionalsFromPost(null, $object, $attribute_name);
|
||||
if ($ret < 0) {
|
||||
$error++;
|
||||
}
|
||||
if (!$error) {
|
||||
$result = $object->updateExtraField($attribute_name, 'MEMBER_MODIFY');
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
if ($error) {
|
||||
$action = 'edit_extras';
|
||||
}
|
||||
}
|
||||
|
||||
// Create third party from a member
|
||||
if (empty($reshook) && $action == 'confirm_create_thirdparty' && $confirm == 'yes' && $user->hasRight('societe', 'creer')) {
|
||||
if ($result > 0) {
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ ALTER TABLE llx_categorie_project_task DROP FOREIGN KEY fk_categorie_project_tas
|
|||
-- VPGSQL8.2 DROP INDEX idx_categorie_project_fk_task;
|
||||
ALTER TABLE llx_categorie_project_task ADD INDEX idx_categorie_project_fk_task (fk_project_task);
|
||||
ALTER TABLE llx_categorie_project_task ADD CONSTRAINT fk_categorie_project_task_rowid FOREIGN KEY (fk_project_task) REFERENCES llx_projet_task (rowid);
|
||||
ALTER TABLE llx_stock_mouvement ADD INDEX idx_stock_mouvement_batch_entrepot_type_datem (batch, fk_entrepot, type_mouvement, datem);
|
||||
|
||||
-- V24 migration
|
||||
ALTER TABLE llx_expensereport_det ADD COLUMN tcheck_file integer DEFAULT NULL after fk_ecm_files;
|
||||
|
|
|
|||
|
|
@ -21,3 +21,5 @@
|
|||
ALTER TABLE llx_stock_mouvement ADD INDEX idx_stock_mouvement_fk_product (fk_product);
|
||||
|
||||
ALTER TABLE llx_stock_mouvement ADD INDEX idx_stock_mouvement_fk_entrepot (fk_entrepot);
|
||||
|
||||
ALTER TABLE llx_stock_mouvement ADD INDEX idx_stock_mouvement_batch_entrepot_type_datem (batch, fk_entrepot, type_mouvement, datem);
|
||||
|
|
|
|||
|
|
@ -126,6 +126,57 @@ function fail($message)
|
|||
die($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an invoice line and the TakePOS supplement lines attached to it.
|
||||
*
|
||||
* @param Facture $invoice Invoice object
|
||||
* @param int $lineid Line id to delete
|
||||
* @return int Return integer <0 if KO, >0 if OK
|
||||
*/
|
||||
function takeposDeleteLineWithChildren($invoice, $lineid)
|
||||
{
|
||||
$lineid = (int) $lineid;
|
||||
if ($lineid <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
$childrenbyparent = array();
|
||||
if (is_array($invoice->lines)) {
|
||||
foreach ($invoice->lines as $line) {
|
||||
$parentid = (int) $line->fk_parent_line;
|
||||
if ($parentid > 0) {
|
||||
$childrenbyparent[$parentid][] = (int) $line->id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$linestodelete = array();
|
||||
$stack = array($lineid);
|
||||
while (!empty($stack)) {
|
||||
$currentlineid = array_pop($stack);
|
||||
if (in_array($currentlineid, $linestodelete, true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$linestodelete[] = $currentlineid;
|
||||
if (!empty($childrenbyparent[$currentlineid])) {
|
||||
foreach ($childrenbyparent[$currentlineid] as $childlineid) {
|
||||
$stack[] = $childlineid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Delete supplements before their parent line so no orphan line remains visible on receipts.
|
||||
foreach (array_reverse($linestodelete) as $deletelineid) {
|
||||
$result = $invoice->deleteLine($deletelineid);
|
||||
if ($result < 0) {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
$number = (float) GETPOST('number', 'alpha');
|
||||
|
|
@ -1016,7 +1067,10 @@ if (empty($reshook)) {
|
|||
$db->begin();
|
||||
|
||||
if ($idline > 0 && $placeid > 0) { // If invoice exists and a line is selected.
|
||||
$invoice->deleteLine($idline);
|
||||
$result = takeposDeleteLineWithChildren($invoice, $idline);
|
||||
if ($result < 0) {
|
||||
dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
|
||||
}
|
||||
$invoice->fetch($placeid);
|
||||
} elseif ($placeid > 0) { // If invoice exists but no line selected (delete from another device or with no line selected), proceed to delete the last line.
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facturedet where fk_facture = ".((int) $placeid)." ORDER BY rowid DESC";
|
||||
|
|
@ -1024,7 +1078,10 @@ if (empty($reshook)) {
|
|||
$obj = $db->fetch_object($resql);
|
||||
if ($obj) {
|
||||
$deletelineid = $obj->rowid;
|
||||
$invoice->deleteLine($deletelineid);
|
||||
$result = takeposDeleteLineWithChildren($invoice, $deletelineid);
|
||||
if ($result < 0) {
|
||||
dol_htmloutput_errors($invoice->error, $invoice->errors, 1);
|
||||
}
|
||||
}
|
||||
$invoice->fetch($placeid);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2015 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2024-2026 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2026 MDW <mdeweerd@users.noreply.github.com>
|
||||
*
|
||||
* 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
|
||||
|
|
@ -62,7 +63,7 @@ if (($object->id != $user->id) && (!$user->hasRight("user", "user", "read"))) {
|
|||
if ($object->id == $user->id) {
|
||||
$permissionnote = $user->hasRight("user", "self", "write"); // Used by the include of actions_setnotes.inc.php
|
||||
} else {
|
||||
$permissionnote = $user->hasRight("user", "user", "write")); // Used by the include of actions_setnotes.inc.php
|
||||
$permissionnote = $user->hasRight("user", "user", "write"); // Used by the include of actions_setnotes.inc.php
|
||||
}
|
||||
|
||||
// Security check
|
||||
|
|
@ -81,7 +82,7 @@ $result = restrictedArea($user, 'user', $id, 'user&user', $feature2);
|
|||
/*
|
||||
* Actions
|
||||
*/
|
||||
$parameters = array('id'=>$socid);
|
||||
$parameters = array('id' => $socid);
|
||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook < 0) {
|
||||
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||
|
|
|
|||
Loading…
Reference in a new issue