/** * Load an object from its id and create a new one in database * * @param int $fromid Id of object to clone * @return int New id of clone */ function createFromClone($fromid) { global $user, $langs; $error = 0; $object = new PaymentDonation($this->db); $object->context['createfromclone'] = 'createfromclone'; $this->db->begin(); // Load source object $object->fetch($fromid); $object->id = 0; $object->statut = 0; // Clear fields // ... // Create clone $result = $object->create($user); // Other options if ($result < 0) { $this->error = $object->error; $error++; } if (!$error) { } unset($this->context['createfromclone']); // End if (!$error) { $this->db->commit(); return $object->id; } else { $this->db->rollback(); return -1; } }
} $langs->load('bills'); $langs->load('banks'); $langs->load('companies'); // Security check $id = GETPOST('rowid') ? GETPOST('rowid', 'int') : GETPOST('id', 'int'); $action = GETPOST("action"); $confirm = GETPOST('confirm'); if ($user->societe_id) { $socid = $user->societe_id; } // TODO Add rule to restrict access payment //$result = restrictedArea($user, 'facture', $id,''); $payment = new PaymentDonation($db); if ($id > 0) { $result = $payment->fetch($id); if (!$result) { dol_print_error($db, 'Failed to get payment id ' . $id); } } /* * Actions */ // Delete payment if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->don->supprimer) { $db->begin(); $result = $payment->delete($user); if ($result > 0) { $db->commit(); header("Location: " . DOL_URL_ROOT . "/don/index.php"); exit;