Skip to content

Commit

Permalink
Merge pull request Dolibarr#31904 from IC-Mathieu/FIx_go_back_status
Browse files Browse the repository at this point in the history
FIX go back status Dolibarr#24944
  • Loading branch information
eldy authored Feb 12, 2025
2 parents a93053e + b6b5321 commit 86c4c0c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
12 changes: 12 additions & 0 deletions htdocs/don/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,15 @@
$object->setProject($projectid);
}

if ($action == 'set_validate' && $permissiontoadd) {
$object->fetch($id);
if ($object->reopen($user) >= 0) {
$action = '';
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
}

if ($action == 'update_extras' && $permissiontoadd) {
$object->oldcopy = dol_clone($object, 2);

Expand Down Expand Up @@ -916,6 +925,9 @@
if ($object->status == $object::STATUS_VALIDATED && round($remaintopay) == 0 && $object->paid == 0 && $user->hasRight('don', 'creer')) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=set_paid&token='.newToken().'">'.$langs->trans("ClassifyPaid")."</a></div>";
}
if ($object->status == $object::STATUS_PAID && $object->paid == 1 && $user->hasRight('don', 'creer')) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=set_validate&token='.newToken().'">'.$langs->trans("ReOpen")."</a></div>";
}

// Delete
if ($user->hasRight('don', 'supprimer')) {
Expand Down
15 changes: 14 additions & 1 deletion htdocs/don/class/don.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -859,9 +859,22 @@ public function set_cancel($id)
public function reopen($user, $notrigger = 0)
{
// Protection
if ($this->status != self::STATUS_CANCELED) {
if ($this->status != self::STATUS_CANCELED && $this->status != self::STATUS_PAID) {
return 0;
}
if ($this->statut == self::STATUS_PAID) {
$sql = "UPDATE " . MAIN_DB_PREFIX . "don SET paid = 0 WHERE rowid = " . ((int) $this->id);

$resql = $this->db->query($sql);
if ($resql) {
if ($this->db->affected_rows($resql)) {
$this->paid = 0;
} else {
dol_print_error($this->db);
return -1;
}
}
}

return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'DON_REOPEN');
}
Expand Down

0 comments on commit 86c4c0c

Please sign in to comment.