2004-10-19 22:35:36 +02:00
|
|
|
<?php
|
2018-09-09 09:36:12 +02:00
|
|
|
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
|
|
|
|
* Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
2018-10-27 14:43:12 +02:00
|
|
|
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
2018-09-09 09:36:12 +02:00
|
|
|
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
2019-01-28 21:39:22 +01:00
|
|
|
* Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro@open-dsi.fr>
|
2019-01-18 11:20:36 +01:00
|
|
|
* Copyright (C) 2018-2019 Thibault FOUCART <support@ptibogxiv.net>
|
2020-11-22 20:59:34 +01:00
|
|
|
* Copyright (C) 2018-2020 Frédéric France <frederic.france@netlogic.fr>
|
2002-12-19 19:55:38 +01:00
|
|
|
*
|
|
|
|
|
* 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
|
2013-01-16 15:36:08 +01:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2002-12-19 19:55:38 +01:00
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2019-09-23 21:55:30 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2002-12-19 19:55:38 +01:00
|
|
|
*/
|
2004-09-04 17:56:12 +02:00
|
|
|
|
2005-08-11 22:28:11 +02:00
|
|
|
/**
|
2015-03-25 22:37:14 +01:00
|
|
|
* \file htdocs/don/card.php
|
2015-03-22 08:20:19 +01:00
|
|
|
* \ingroup donations
|
|
|
|
|
* \brief Page of donation card
|
2008-11-14 12:56:47 +01:00
|
|
|
*/
|
2004-09-04 17:56:12 +02:00
|
|
|
|
2015-03-20 06:36:48 +01:00
|
|
|
require '../main.inc.php';
|
2019-11-13 19:35:39 +01:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/modules/dons/modules_don.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmargin.class.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
2022-06-14 17:53:17 +02:00
|
|
|
if (!empty($conf->project->enabled)) {
|
2020-10-31 14:32:18 +01:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
2013-06-14 22:33:01 +02:00
|
|
|
}
|
2015-03-16 06:29:15 +01:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
2002-12-19 19:55:38 +01:00
|
|
|
|
2021-03-01 11:18:14 +01:00
|
|
|
$langs->loadLangs(array("bills", "companies", "donations", "users"));
|
2004-09-04 17:56:12 +02:00
|
|
|
|
2019-11-13 19:35:39 +01:00
|
|
|
$id = GETPOST('rowid') ?GETPOST('rowid', 'int') : GETPOST('id', 'int');
|
2020-09-16 19:39:50 +02:00
|
|
|
$action = GETPOST('action', 'aZ09');
|
2019-11-13 19:35:39 +01:00
|
|
|
$cancel = GETPOST('cancel', 'alpha');
|
2020-11-03 14:19:54 +01:00
|
|
|
$confirm = GETPOST('confirm', 'alpha');
|
|
|
|
|
|
|
|
|
|
$amount = price2num(GETPOST('amount', 'alphanohtml'), 'MT');
|
2019-11-13 19:35:39 +01:00
|
|
|
$donation_date = dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
|
2016-12-20 21:39:42 +01:00
|
|
|
$projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0);
|
2020-11-22 20:59:34 +01:00
|
|
|
$public_donation = (int) GETPOST("public", 'int');
|
2017-06-07 16:44:04 +02:00
|
|
|
|
2015-03-16 06:29:15 +01:00
|
|
|
$object = new Don($db);
|
2015-03-21 06:21:34 +01:00
|
|
|
$extrafields = new ExtraFields($db);
|
|
|
|
|
|
2012-02-01 14:20:22 +01:00
|
|
|
// Security check
|
|
|
|
|
$result = restrictedArea($user, 'don', $id);
|
|
|
|
|
|
2015-03-26 20:43:34 +01:00
|
|
|
// fetch optionals attributes and labels
|
2019-10-06 14:41:52 +02:00
|
|
|
$extrafields->fetch_name_optionals_label($object->table_element);
|
2021-06-14 14:24:21 +02:00
|
|
|
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
|
2015-03-26 20:43:34 +01:00
|
|
|
|
2017-06-10 12:56:28 +02:00
|
|
|
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
2019-11-13 19:35:39 +01:00
|
|
|
$hookmanager->initHooks(array('doncard', 'globalcard'));
|
Add: hooks and triggers for a lot of core modules (action/calendrier, deplacement, dons, tva, contact/tiers, contrat, product lines, expedition, fournisseur commandes et factures, fiche intervention, projet et taches)
Signed-off-by: Stephen L. <lrq3000@gmail.com>
2012-08-14 15:50:45 +02:00
|
|
|
|
2020-11-03 14:19:54 +01:00
|
|
|
$upload_dir = $conf->don->dir_output;
|
|
|
|
|
$permissiontoadd = $user->rights->don->creer;
|
|
|
|
|
|
2020-06-18 03:32:13 +02:00
|
|
|
|
2006-01-14 15:36:21 +01:00
|
|
|
/*
|
|
|
|
|
* Actions
|
|
|
|
|
*/
|
2015-05-13 17:53:25 +02:00
|
|
|
|
2020-11-03 14:19:54 +01:00
|
|
|
$parameters = array();
|
|
|
|
|
|
2015-03-26 20:43:34 +01:00
|
|
|
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some
|
2021-02-25 22:18:34 +01:00
|
|
|
if ($reshook < 0) {
|
|
|
|
|
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
|
|
|
|
}
|
2008-11-15 19:20:40 +01:00
|
|
|
|
2021-09-02 21:35:36 +02:00
|
|
|
if (empty($reshook)) {
|
|
|
|
|
$backurlforlist = DOL_URL_ROOT.'/don/list.php';
|
|
|
|
|
|
|
|
|
|
if (empty($backtopage) || ($cancel && empty($id))) {
|
|
|
|
|
if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
|
|
|
|
|
if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
|
|
|
|
|
$backtopage = $backurlforlist;
|
|
|
|
|
} else {
|
|
|
|
|
$backtopage = DOL_URL_ROOT.'/don/card.php?id='.((!empty($id) && $id > 0) ? $id : '__ID__');
|
2020-11-03 14:19:54 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-06-14 14:24:21 +02:00
|
|
|
|
2021-09-02 21:35:36 +02:00
|
|
|
if ($cancel) {
|
|
|
|
|
if (!empty($backtopageforcancel)) {
|
|
|
|
|
header("Location: ".$backtopageforcancel);
|
|
|
|
|
exit;
|
|
|
|
|
} elseif (!empty($backtopage)) {
|
|
|
|
|
header("Location: ".$backtopage);
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
$action = '';
|
2010-04-05 03:25:44 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-02 21:35:36 +02:00
|
|
|
// Action reopen object
|
|
|
|
|
if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd) {
|
|
|
|
|
$object->fetch($id);
|
2010-02-13 17:28:03 +01:00
|
|
|
|
2021-09-02 21:35:36 +02:00
|
|
|
$result = $object->reopen($user);
|
|
|
|
|
if ($result >= 0) {
|
|
|
|
|
// Define output language
|
|
|
|
|
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
|
|
|
|
if (method_exists($object, 'generateDocument')) {
|
|
|
|
|
$outputlangs = $langs;
|
|
|
|
|
$newlang = '';
|
|
|
|
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
|
|
|
|
|
$newlang = GETPOST('lang_id', 'aZ09');
|
|
|
|
|
}
|
|
|
|
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
|
|
|
|
|
$newlang = $object->thirdparty->default_lang;
|
|
|
|
|
}
|
|
|
|
|
if (!empty($newlang)) {
|
|
|
|
|
$outputlangs = new Translate("", $conf);
|
|
|
|
|
$outputlangs->setDefaultLang($newlang);
|
|
|
|
|
}
|
|
|
|
|
$model = $object->model_pdf;
|
|
|
|
|
$ret = $object->fetch($id); // Reload to get new records
|
|
|
|
|
|
|
|
|
|
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-02-13 17:28:03 +01:00
|
|
|
|
2021-09-02 21:35:36 +02:00
|
|
|
header("Location: ".$_SERVER["PHP_SELF"].'?id='.$object->id);
|
|
|
|
|
exit;
|
|
|
|
|
} else {
|
|
|
|
|
setEventMessages($object->error, $object->errors, 'errors');
|
2022-01-10 17:55:45 +01:00
|
|
|
$action = 'create';
|
2021-09-02 21:35:36 +02:00
|
|
|
}
|
2010-02-13 17:28:03 +01:00
|
|
|
}
|
2008-11-15 19:20:40 +01:00
|
|
|
|
2015-03-16 06:29:15 +01:00
|
|
|
|
2021-09-02 21:35:36 +02:00
|
|
|
// Action update object
|
|
|
|
|
if ($action == 'update') {
|
|
|
|
|
if (!empty($cancel)) {
|
|
|
|
|
header("Location: ".$_SERVER['PHP_SELF']."?id=".urlencode($id));
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$error = 0;
|
|
|
|
|
|
|
|
|
|
if (empty($donation_date)) {
|
|
|
|
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
|
|
|
|
|
$action = "create";
|
2021-02-25 22:18:34 +01:00
|
|
|
$error++;
|
|
|
|
|
}
|
2015-03-16 06:29:15 +01:00
|
|
|
|
2021-09-02 21:35:36 +02:00
|
|
|
if (empty($amount)) {
|
|
|
|
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors');
|
|
|
|
|
$action = "create";
|
|
|
|
|
$error++;
|
2008-11-15 19:20:40 +01:00
|
|
|
}
|
2004-09-04 17:56:12 +02:00
|
|
|
|
2021-09-02 21:35:36 +02:00
|
|
|
if (!$error) {
|
|
|
|
|
$object->fetch($id);
|
|
|
|
|
|
|
|
|
|
$object->firstname = (string) GETPOST("firstname", 'alpha');
|
|
|
|
|
$object->lastname = (string) GETPOST("lastname", 'alpha');
|
|
|
|
|
$object->societe = (string) GETPOST("societe", 'alpha');
|
|
|
|
|
$object->address = (string) GETPOST("address", 'alpha');
|
2022-01-10 17:55:45 +01:00
|
|
|
$object->amount = price2num(GETPOST("amount", 'alpha'), '', 2);
|
2021-09-02 21:35:36 +02:00
|
|
|
$object->town = (string) GETPOST("town", 'alpha');
|
|
|
|
|
$object->zip = (string) GETPOST("zipcode", 'alpha');
|
|
|
|
|
$object->country_id = (int) GETPOST('country_id', 'int');
|
|
|
|
|
$object->email = (string) GETPOST("email", 'alpha');
|
|
|
|
|
$object->date = $donation_date;
|
|
|
|
|
$object->public = $public_donation;
|
|
|
|
|
$object->fk_project = (int) GETPOST("fk_project", 'int');
|
|
|
|
|
$object->modepaymentid = (int) GETPOST('modepayment', 'int');
|
|
|
|
|
|
|
|
|
|
// Fill array 'array_options' with data from add form
|
2021-12-08 18:27:03 +01:00
|
|
|
$ret = $extrafields->setOptionalsFromPost(null, $object, '@GETPOSTISSET');
|
2021-09-02 21:35:36 +02:00
|
|
|
if ($ret < 0) {
|
|
|
|
|
$error++;
|
|
|
|
|
}
|
2021-06-14 14:24:21 +02:00
|
|
|
|
2021-09-02 21:35:36 +02:00
|
|
|
if ($object->update($user) > 0) {
|
|
|
|
|
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
|
|
|
|
exit;
|
2022-01-10 17:55:45 +01:00
|
|
|
} else {
|
|
|
|
|
setEventMessages($object->error, $object->errors, 'errors');
|
|
|
|
|
$action = "create";
|
2021-09-02 21:35:36 +02:00
|
|
|
}
|
|
|
|
|
}
|
2010-04-05 03:25:44 +02:00
|
|
|
}
|
|
|
|
|
|
2010-02-13 17:28:03 +01:00
|
|
|
|
2021-09-02 21:35:36 +02:00
|
|
|
// Action add/create object
|
|
|
|
|
if ($action == 'add') {
|
|
|
|
|
if (!empty($cancel)) {
|
|
|
|
|
header("Location: index.php");
|
|
|
|
|
exit;
|
|
|
|
|
}
|
2010-02-13 17:28:03 +01:00
|
|
|
|
2021-09-02 21:35:36 +02:00
|
|
|
$error = 0;
|
2008-11-15 19:20:40 +01:00
|
|
|
|
2021-09-02 21:35:36 +02:00
|
|
|
if (!empty($conf->societe->enabled) && !empty($conf->global->DONATION_USE_THIRDPARTIES) && !(GETPOST("socid", 'int') > 0)) {
|
|
|
|
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("ThirdParty")), null, 'errors');
|
|
|
|
|
$action = "create";
|
2021-02-25 22:18:34 +01:00
|
|
|
$error++;
|
|
|
|
|
}
|
2021-09-02 21:35:36 +02:00
|
|
|
if (empty($donation_date)) {
|
|
|
|
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
|
|
|
|
|
$action = "create";
|
|
|
|
|
$error++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (empty($amount)) {
|
|
|
|
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors');
|
|
|
|
|
$action = "create";
|
|
|
|
|
$error++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!$error) {
|
|
|
|
|
$object->socid = (int) GETPOST("socid", 'int');
|
|
|
|
|
$object->firstname = (string) GETPOST("firstname", 'alpha');
|
|
|
|
|
$object->lastname = (string) GETPOST("lastname", 'alpha');
|
|
|
|
|
$object->societe = (string) GETPOST("societe", 'alpha');
|
|
|
|
|
$object->address = (string) GETPOST("address", 'alpha');
|
2022-01-10 17:55:45 +01:00
|
|
|
$object->amount = price2num(GETPOST("amount", 'alpha'), '', 2);
|
2021-09-02 21:35:36 +02:00
|
|
|
$object->zip = (string) GETPOST("zipcode", 'alpha');
|
|
|
|
|
$object->town = (string) GETPOST("town", 'alpha');
|
|
|
|
|
$object->country_id = (int) GETPOST('country_id', 'int');
|
|
|
|
|
$object->email = (string) GETPOST('email', 'alpha');
|
|
|
|
|
$object->date = $donation_date;
|
|
|
|
|
$object->note_private = (string) GETPOST("note_private", 'restricthtml');
|
|
|
|
|
$object->note_public = (string) GETPOST("note_public", 'restricthtml');
|
|
|
|
|
$object->public = $public_donation;
|
|
|
|
|
$object->fk_project = (int) GETPOST("fk_project", 'int');
|
|
|
|
|
$object->modepaymentid = (int) GETPOST('modepayment', 'int');
|
|
|
|
|
|
|
|
|
|
// Fill array 'array_options' with data from add form
|
|
|
|
|
$ret = $extrafields->setOptionalsFromPost(null, $object);
|
|
|
|
|
if ($ret < 0) {
|
|
|
|
|
$error++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$res = $object->create($user);
|
|
|
|
|
if ($res > 0) {
|
|
|
|
|
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$res);
|
|
|
|
|
exit;
|
|
|
|
|
} else {
|
|
|
|
|
setEventMessages($object->error, $object->errors, 'errors');
|
2022-01-10 17:55:45 +01:00
|
|
|
$action = "create";
|
2021-09-02 21:35:36 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-03-16 06:29:15 +01:00
|
|
|
|
2021-09-02 21:35:36 +02:00
|
|
|
// Action delete object
|
|
|
|
|
if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights->don->supprimer) {
|
|
|
|
|
$object->fetch($id);
|
|
|
|
|
$result = $object->delete($user);
|
|
|
|
|
if ($result > 0) {
|
|
|
|
|
header("Location: index.php");
|
2008-11-15 19:20:40 +01:00
|
|
|
exit;
|
2020-05-21 15:05:19 +02:00
|
|
|
} else {
|
2021-09-02 21:35:36 +02:00
|
|
|
dol_syslog($object->error, LOG_DEBUG);
|
2015-05-18 23:04:49 +02:00
|
|
|
setEventMessages($object->error, $object->errors, 'errors');
|
|
|
|
|
}
|
2008-11-15 19:20:40 +01:00
|
|
|
}
|
2021-06-14 14:24:21 +02:00
|
|
|
|
2021-09-02 21:35:36 +02:00
|
|
|
// Action validation
|
|
|
|
|
if ($action == 'valid_promesse') {
|
|
|
|
|
$object->fetch($id);
|
|
|
|
|
if ($object->valid_promesse($id, $user->id) >= 0) {
|
|
|
|
|
setEventMessages($langs->trans("DonationValidated", $object->ref), null);
|
|
|
|
|
$action = '';
|
|
|
|
|
} else {
|
|
|
|
|
setEventMessages($object->error, $object->errors, 'errors');
|
|
|
|
|
}
|
2020-10-31 14:32:18 +01:00
|
|
|
}
|
2021-06-14 14:24:21 +02:00
|
|
|
|
2021-09-02 21:35:36 +02:00
|
|
|
// Action cancel
|
|
|
|
|
if ($action == 'set_cancel') {
|
|
|
|
|
$object->fetch($id);
|
|
|
|
|
if ($object->set_cancel($id) >= 0) {
|
|
|
|
|
$action = '';
|
|
|
|
|
} else {
|
|
|
|
|
setEventMessages($object->error, $object->errors, 'errors');
|
|
|
|
|
}
|
2020-10-31 14:32:18 +01:00
|
|
|
}
|
2021-06-14 14:24:21 +02:00
|
|
|
|
2021-09-02 21:35:36 +02:00
|
|
|
// Action set paid
|
|
|
|
|
if ($action == 'set_paid') {
|
|
|
|
|
$object->fetch($id);
|
|
|
|
|
if ($object->setPaid($id, $modepayment) >= 0) {
|
|
|
|
|
$action = '';
|
|
|
|
|
} else {
|
|
|
|
|
setEventMessages($object->error, $object->errors, 'errors');
|
|
|
|
|
}
|
|
|
|
|
} elseif ($action == 'classin' && $user->rights->don->creer) {
|
|
|
|
|
$object->fetch($id);
|
|
|
|
|
$object->setProject($projectid);
|
2020-10-31 14:32:18 +01:00
|
|
|
}
|
2018-05-10 14:15:52 +02:00
|
|
|
|
2021-06-14 14:24:21 +02:00
|
|
|
|
2021-09-02 21:35:36 +02:00
|
|
|
// Actions to build doc
|
|
|
|
|
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
|
2018-05-10 14:15:52 +02:00
|
|
|
|
|
|
|
|
|
2021-09-02 21:35:36 +02:00
|
|
|
// Remove file in doc form
|
|
|
|
|
/*if ($action == 'remove_file')
|
2015-08-25 08:09:14 +02:00
|
|
|
{
|
2021-09-02 21:35:36 +02:00
|
|
|
$object = new Don($db, 0, GETPOST('id', 'int'));
|
|
|
|
|
if ($object->fetch($id))
|
|
|
|
|
{
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
|
|
|
|
|
|
|
|
|
$object->fetch_thirdparty();
|
|
|
|
|
|
|
|
|
|
$langs->load("other");
|
|
|
|
|
$upload_dir = $conf->don->dir_output;
|
|
|
|
|
$file = $upload_dir . '/' . GETPOST('file');
|
|
|
|
|
$ret=dol_delete_file($file,0,0,0,$object);
|
|
|
|
|
if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
|
|
|
|
|
else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
|
|
|
|
|
$action='';
|
|
|
|
|
}
|
2015-08-25 08:09:14 +02:00
|
|
|
}
|
2021-09-02 21:35:36 +02:00
|
|
|
*/
|
2002-12-19 19:55:38 +01:00
|
|
|
|
2021-09-02 21:35:36 +02:00
|
|
|
/*
|
|
|
|
|
* Build doc
|
|
|
|
|
*/
|
|
|
|
|
/*
|
|
|
|
|
if ($action == 'builddoc')
|
2008-11-14 12:56:47 +01:00
|
|
|
{
|
2021-09-02 21:35:36 +02:00
|
|
|
$object = new Don($db);
|
|
|
|
|
$result=$object->fetch($id);
|
|
|
|
|
|
|
|
|
|
// Save last template used to generate document
|
|
|
|
|
if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha'));
|
|
|
|
|
|
|
|
|
|
// Define output language
|
|
|
|
|
$outputlangs = $langs;
|
|
|
|
|
$newlang='';
|
|
|
|
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
|
|
|
|
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->thirdparty->default_lang;
|
|
|
|
|
if (! empty($newlang))
|
|
|
|
|
{
|
|
|
|
|
$outputlangs = new Translate("",$conf);
|
|
|
|
|
$outputlangs->setDefaultLang($newlang);
|
|
|
|
|
}
|
|
|
|
|
$result=don_create($db, $object->id, '', $object->model_pdf, $outputlangs);
|
|
|
|
|
if ($result <= 0)
|
|
|
|
|
{
|
|
|
|
|
dol_print_error($db,$result);
|
|
|
|
|
exit;
|
|
|
|
|
}
|
2008-11-14 12:56:47 +01:00
|
|
|
}
|
2021-09-02 21:35:36 +02:00
|
|
|
*/
|
2005-11-11 21:11:57 +01:00
|
|
|
}
|
|
|
|
|
|
2002-12-19 19:55:38 +01:00
|
|
|
|
2008-11-14 12:56:47 +01:00
|
|
|
/*
|
|
|
|
|
* View
|
|
|
|
|
*/
|
2002-12-19 19:55:38 +01:00
|
|
|
|
2021-06-14 14:24:21 +02:00
|
|
|
$title = $langs->trans("Donation");
|
|
|
|
|
|
2021-03-29 21:38:59 +02:00
|
|
|
$help_url = 'EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones|DE:Modul_Spenden';
|
2021-03-16 13:32:38 +01:00
|
|
|
|
2021-06-14 14:24:21 +02:00
|
|
|
llxHeader('', $title, $help_url);
|
2002-12-19 19:55:38 +01:00
|
|
|
|
2019-11-13 19:35:39 +01:00
|
|
|
$form = new Form($db);
|
2008-01-20 14:53:02 +01:00
|
|
|
$formfile = new FormFile($db);
|
2011-11-08 10:18:45 +01:00
|
|
|
$formcompany = new FormCompany($db);
|
2022-06-14 17:53:17 +02:00
|
|
|
if (!empty($conf->project->enabled)) {
|
2021-02-25 22:18:34 +01:00
|
|
|
$formproject = new FormProjets($db);
|
|
|
|
|
}
|
2004-09-04 17:56:12 +02:00
|
|
|
|
2022-07-11 00:05:50 +02:00
|
|
|
if ($action == 'create') {
|
2020-04-24 23:56:57 +02:00
|
|
|
print load_fiche_titre($langs->trans("AddDonation"), '', 'object_donation');
|
2008-11-15 19:20:40 +01:00
|
|
|
|
2019-11-13 19:35:39 +01:00
|
|
|
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
2019-12-18 23:12:31 +01:00
|
|
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
2008-11-15 19:20:40 +01:00
|
|
|
print '<input type="hidden" name="action" value="add">';
|
2015-05-18 22:25:51 +02:00
|
|
|
|
2020-10-22 22:50:03 +02:00
|
|
|
print dol_get_fiche_head('');
|
2015-05-18 22:25:51 +02:00
|
|
|
|
2019-11-05 21:24:41 +01:00
|
|
|
print '<table class="border centpercent">';
|
2015-05-20 06:38:36 +02:00
|
|
|
print '<tbody>';
|
2008-11-15 19:20:40 +01:00
|
|
|
|
2018-09-12 17:45:38 +02:00
|
|
|
// Ref
|
2021-03-01 11:18:14 +01:00
|
|
|
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans('Ref').'</td><td>'.$langs->trans('Draft').'</td></tr>';
|
2018-09-12 17:45:38 +02:00
|
|
|
|
|
|
|
|
// Company
|
2021-02-25 22:18:34 +01:00
|
|
|
if (!empty($conf->societe->enabled) && !empty($conf->global->DONATION_USE_THIRDPARTIES)) {
|
2018-09-12 17:45:38 +02:00
|
|
|
// Thirdparty
|
2021-03-02 02:06:09 +01:00
|
|
|
if ($soc->id > 0) {
|
2021-03-01 11:18:14 +01:00
|
|
|
print '<td class="fieldrequired">'.$langs->trans('ThirdParty').'</td>';
|
|
|
|
|
print '<td>';
|
2018-09-12 17:45:38 +02:00
|
|
|
print $soc->getNomUrl(1);
|
2019-11-13 19:35:39 +01:00
|
|
|
print '<input type="hidden" name="socid" value="'.$soc->id.'">';
|
2018-09-12 17:45:38 +02:00
|
|
|
// Outstanding Bill
|
2019-08-29 00:45:02 +02:00
|
|
|
$arrayoutstandingbills = $soc->getOutstandingBills();
|
|
|
|
|
$outstandingBills = $arrayoutstandingbills['opened'];
|
2019-11-13 19:35:39 +01:00
|
|
|
print ' ('.$langs->trans('CurrentOutstandingBill').': ';
|
2018-09-12 17:45:38 +02:00
|
|
|
print price($outstandingBills, '', $langs, 0, 0, -1, $conf->currency);
|
2021-02-25 22:18:34 +01:00
|
|
|
if ($soc->outstanding_limit != '') {
|
|
|
|
|
if ($outstandingBills > $soc->outstanding_limit) {
|
|
|
|
|
print img_warning($langs->trans("OutstandingBillReached"));
|
|
|
|
|
}
|
2019-11-13 19:35:39 +01:00
|
|
|
print ' / '.price($soc->outstanding_limit, '', $langs, 0, 0, -1, $conf->currency);
|
2018-09-12 17:45:38 +02:00
|
|
|
}
|
|
|
|
|
print ')';
|
|
|
|
|
print '</td>';
|
2020-05-21 15:05:19 +02:00
|
|
|
} else {
|
2021-03-01 11:18:14 +01:00
|
|
|
print '<td class="fieldrequired">'.$langs->trans('ThirdParty').'</td>';
|
|
|
|
|
print '<td>';
|
2018-09-12 17:45:38 +02:00
|
|
|
print $form->select_company($soc->id, 'socid', '(s.client = 1 OR s.client = 3) AND status=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300');
|
|
|
|
|
// Option to reload page to retrieve customer informations. Note, this clear other input
|
2021-02-25 22:18:34 +01:00
|
|
|
if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED)) {
|
2018-09-12 17:45:38 +02:00
|
|
|
print '<script type="text/javascript">
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
|
$("#socid").change(function() {
|
2020-11-03 02:17:51 +01:00
|
|
|
console.log("We have changed the company - Reload page");
|
2018-09-12 17:45:38 +02:00
|
|
|
var socid = $(this).val();
|
|
|
|
|
var fac_rec = $(\'#fac_rec\').val();
|
|
|
|
|
// reload page
|
2021-03-02 15:59:48 +01:00
|
|
|
$("input[name=action]").val("create");
|
|
|
|
|
$("form[name=add]").submit();
|
2018-09-12 17:45:38 +02:00
|
|
|
});
|
2018-09-12 17:24:11 +02:00
|
|
|
});
|
2018-09-12 17:45:38 +02:00
|
|
|
</script>';
|
|
|
|
|
}
|
2021-03-01 11:18:14 +01:00
|
|
|
print ' <a href="'.DOL_URL_ROOT.'/societe/card.php?action=create&client=3&fournisseur=0&backtopage='.urlencode($_SERVER["PHP_SELF"].'?action=create').'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("AddThirdParty").'"></span></a>';
|
2018-09-12 17:45:38 +02:00
|
|
|
print '</td>';
|
2018-09-12 17:24:11 +02:00
|
|
|
}
|
2019-11-13 19:35:39 +01:00
|
|
|
print '</tr>'."\n";
|
2018-09-12 17:45:38 +02:00
|
|
|
}
|
2018-09-12 18:04:33 +02:00
|
|
|
|
|
|
|
|
// Date
|
2016-04-04 15:20:21 +02:00
|
|
|
print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("Date").'</td><td>';
|
2019-11-13 19:35:39 +01:00
|
|
|
print $form->selectDate($donation_date ? $donation_date : -1, '', '', '', '', "add", 1, 1);
|
2008-11-15 19:20:40 +01:00
|
|
|
print '</td>';
|
|
|
|
|
|
2018-09-12 18:04:33 +02:00
|
|
|
// Amount
|
|
|
|
|
print "<tr>".'<td class="fieldrequired">'.$langs->trans("Amount").'</td><td><input type="text" name="amount" value="'.dol_escape_htmltag(GETPOST("amount")).'" size="10"> '.$langs->trans("Currency".$conf->currency).'</td></tr>';
|
2008-11-15 19:20:40 +01:00
|
|
|
|
2018-09-12 18:04:33 +02:00
|
|
|
// Public donation
|
2010-02-08 15:57:39 +01:00
|
|
|
print '<tr><td class="fieldrequired">'.$langs->trans("PublicDonation")."</td><td>";
|
2020-11-22 20:59:34 +01:00
|
|
|
print $form->selectyesno("public", $public_donation, 1);
|
2008-11-15 19:20:40 +01:00
|
|
|
print "</td></tr>\n";
|
|
|
|
|
|
2021-02-25 22:18:34 +01:00
|
|
|
if (empty($conf->societe->enabled) || empty($conf->global->DONATION_USE_THIRDPARTIES)) {
|
2018-09-12 17:45:38 +02:00
|
|
|
print "<tr>".'<td>'.$langs->trans("Company").'</td><td><input type="text" name="societe" value="'.dol_escape_htmltag(GETPOST("societe")).'" class="maxwidth200"></td></tr>';
|
|
|
|
|
print "<tr>".'<td>'.$langs->trans("Lastname").'</td><td><input type="text" name="lastname" value="'.dol_escape_htmltag(GETPOST("lastname")).'" class="maxwidth200"></td></tr>';
|
|
|
|
|
print "<tr>".'<td>'.$langs->trans("Firstname").'</td><td><input type="text" name="firstname" value="'.dol_escape_htmltag(GETPOST("firstname")).'" class="maxwidth200"></td></tr>';
|
|
|
|
|
print "<tr>".'<td>'.$langs->trans("Address").'</td><td>';
|
2020-09-18 01:29:17 +02:00
|
|
|
print '<textarea name="address" wrap="soft" class="quatrevingtpercent" rows="3">'.dol_escape_htmltag(GETPOST("address", "alphanohtml"), 0, 1).'</textarea></td></tr>';
|
2018-09-12 17:45:38 +02:00
|
|
|
|
|
|
|
|
// Zip / Town
|
|
|
|
|
print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>';
|
2020-11-30 14:47:07 +01:00
|
|
|
print $formcompany->select_ziptown((GETPOSTISSET("zipcode") ? GETPOST("zipcode") : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6);
|
2018-09-12 17:45:38 +02:00
|
|
|
print ' ';
|
2020-11-30 14:47:07 +01:00
|
|
|
print $formcompany->select_ziptown((GETPOSTISSET("town") ? GETPOST("town") : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id'));
|
2018-09-12 17:45:38 +02:00
|
|
|
print '</tr>';
|
|
|
|
|
|
|
|
|
|
// Country
|
|
|
|
|
print '<tr><td><label for="selectcountry_id">'.$langs->trans('Country').'</label></td><td class="maxwidthonsmartphone">';
|
2020-06-18 03:32:13 +02:00
|
|
|
print img_picto('', 'globe-americas', 'class="paddingrightonly"').$form->select_country(GETPOST('country_id') != '' ?GETPOST('country_id') : $object->country_id);
|
2021-02-25 22:18:34 +01:00
|
|
|
if ($user->admin) {
|
|
|
|
|
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
|
|
|
|
}
|
2018-09-12 17:45:38 +02:00
|
|
|
print '</td></tr>';
|
2015-05-18 22:25:51 +02:00
|
|
|
|
2020-06-18 03:32:13 +02:00
|
|
|
print "<tr>".'<td>'.$langs->trans("EMail").'</td><td>'.img_picto('', 'object_email', 'class="paddingrightonly"').'<input type="text" name="email" value="'.dol_escape_htmltag(GETPOST("email")).'" class="maxwidth200"></td></tr>';
|
2018-09-12 17:45:38 +02:00
|
|
|
}
|
2015-03-16 06:29:15 +01:00
|
|
|
|
2018-03-02 12:32:49 +01:00
|
|
|
// Payment mode
|
|
|
|
|
print "<tr><td>".$langs->trans("PaymentMode")."</td><td>\n";
|
2019-01-27 11:55:16 +01:00
|
|
|
$selected = GETPOST('modepayment', 'int');
|
2018-03-02 12:32:49 +01:00
|
|
|
$form->select_types_paiements($selected, 'modepayment', 'CRDT', 0, 1);
|
|
|
|
|
print "</td></tr>\n";
|
|
|
|
|
|
2015-03-16 06:29:15 +01:00
|
|
|
// Public note
|
|
|
|
|
print '<tr>';
|
2019-11-13 19:35:39 +01:00
|
|
|
print '<td class="tdtop">'.$langs->trans('NotePublic').'</td>';
|
2017-06-07 16:44:04 +02:00
|
|
|
print '<td>';
|
2015-05-18 22:25:51 +02:00
|
|
|
|
2020-11-30 14:54:44 +01:00
|
|
|
$doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PUBLIC) ? 0 : 1, ROWS_3, '90%');
|
2015-03-16 06:29:15 +01:00
|
|
|
print $doleditor->Create(1);
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
|
|
|
|
|
// Private note
|
2019-10-31 20:46:31 +01:00
|
|
|
if (empty($user->socid)) {
|
2015-03-16 06:29:15 +01:00
|
|
|
print '<tr>';
|
2019-11-13 19:35:39 +01:00
|
|
|
print '<td class="tdtop">'.$langs->trans('NotePrivate').'</td>';
|
2017-06-07 16:44:04 +02:00
|
|
|
print '<td>';
|
2015-03-16 06:29:15 +01:00
|
|
|
|
2020-11-30 14:54:44 +01:00
|
|
|
$doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, empty($conf->global->FCKEDITOR_ENABLE_NOTE_PRIVATE) ? 0 : 1, ROWS_3, '90%');
|
2015-03-16 06:29:15 +01:00
|
|
|
print $doleditor->Create(1);
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
}
|
2011-06-12 17:47:10 +02:00
|
|
|
|
2022-06-14 17:53:17 +02:00
|
|
|
if (!empty($conf->project->enabled)) {
|
2020-10-31 14:32:18 +01:00
|
|
|
print "<tr><td>".$langs->trans("Project")."</td><td>";
|
|
|
|
|
$formproject->select_projects(-1, $projectid, 'fk_project', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth500');
|
2015-03-18 06:29:10 +01:00
|
|
|
print "</td></tr>\n";
|
2020-10-31 14:32:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Other attributes
|
|
|
|
|
$parameters = array();
|
|
|
|
|
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
|
|
|
|
print $hookmanager->resPrint;
|
2021-02-25 22:18:34 +01:00
|
|
|
if (empty($reshook)) {
|
2021-10-08 15:58:08 +02:00
|
|
|
print $object->showOptionals($extrafields, 'create', $parameters);
|
2020-10-31 14:32:18 +01:00
|
|
|
}
|
2015-05-18 22:25:51 +02:00
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
print '</tbody>';
|
2008-11-15 19:20:40 +01:00
|
|
|
print "</table>\n";
|
2015-05-18 22:25:51 +02:00
|
|
|
|
2020-10-27 18:19:31 +01:00
|
|
|
print dol_get_fiche_end();
|
2015-05-18 22:25:51 +02:00
|
|
|
|
2021-08-20 14:41:30 +02:00
|
|
|
print $form->buttonsSaveCancel();
|
2015-05-13 17:53:25 +02:00
|
|
|
|
2008-11-15 19:20:40 +01:00
|
|
|
print "</form>\n";
|
|
|
|
|
}
|
2004-09-04 17:56:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ************************************************************ */
|
|
|
|
|
/* */
|
2015-03-18 05:07:32 +01:00
|
|
|
/* Donation card in edit mode */
|
2004-09-04 17:56:12 +02:00
|
|
|
/* */
|
|
|
|
|
/* ************************************************************ */
|
|
|
|
|
|
2021-02-25 22:18:34 +01:00
|
|
|
if (!empty($id) && $action == 'edit') {
|
2019-11-13 19:35:39 +01:00
|
|
|
$result = $object->fetch($id);
|
2015-03-21 07:12:32 +01:00
|
|
|
if ($result < 0) {
|
2019-01-27 11:55:16 +01:00
|
|
|
dol_print_error($db, $object->error); exit;
|
2015-03-21 07:12:32 +01:00
|
|
|
}
|
2019-11-13 19:35:39 +01:00
|
|
|
$result = $object->fetch_optionals();
|
2015-03-21 07:12:32 +01:00
|
|
|
if ($result < 0) {
|
|
|
|
|
dol_print_error($db); exit;
|
|
|
|
|
}
|
2008-11-15 19:20:40 +01:00
|
|
|
|
2019-11-13 19:35:39 +01:00
|
|
|
$hselected = 'card';
|
2015-03-16 06:29:15 +01:00
|
|
|
$head = donation_prepare_head($object);
|
2008-11-15 19:20:40 +01:00
|
|
|
|
2019-11-13 19:35:39 +01:00
|
|
|
print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
2019-12-18 23:12:31 +01:00
|
|
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
2008-11-15 19:20:40 +01:00
|
|
|
print '<input type="hidden" name="action" value="update">';
|
2015-03-16 06:29:15 +01:00
|
|
|
print '<input type="hidden" name="rowid" value="'.$object->id.'">';
|
2015-03-29 09:20:32 +02:00
|
|
|
print '<input type="hidden" name="amount" value="'.$object->amount.'">';
|
2008-11-15 19:20:40 +01:00
|
|
|
|
2015-06-03 18:08:30 +02:00
|
|
|
|
2020-10-22 22:50:03 +02:00
|
|
|
print dol_get_fiche_head($head, $hselected, $langs->trans("Donation"), 0, 'donation');
|
2015-06-03 18:08:30 +02:00
|
|
|
|
2019-11-05 21:24:41 +01:00
|
|
|
print '<table class="border centpercent">';
|
2015-06-03 18:08:30 +02:00
|
|
|
|
2008-11-15 19:20:40 +01:00
|
|
|
// Ref
|
2016-08-01 07:34:55 +02:00
|
|
|
print '<tr><td>'.$langs->trans("Ref").'</td><td colspan="2">';
|
2015-03-16 06:29:15 +01:00
|
|
|
print $object->getNomUrl();
|
2008-11-15 19:20:40 +01:00
|
|
|
print '</td>';
|
|
|
|
|
print '</tr>';
|
2008-11-15 19:13:25 +01:00
|
|
|
|
2015-03-29 09:20:32 +02:00
|
|
|
// Date
|
2016-11-28 20:48:43 +01:00
|
|
|
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("Date").'</td><td>';
|
2019-01-27 11:55:16 +01:00
|
|
|
print $form->selectDate($object->date, '', '', '', '', "update");
|
2008-11-15 19:20:40 +01:00
|
|
|
print '</td>';
|
2008-11-15 19:13:25 +01:00
|
|
|
|
2011-06-12 17:47:10 +02:00
|
|
|
// Amount
|
2020-11-19 21:09:29 +01:00
|
|
|
if ($object->statut == 0) {
|
2019-01-18 11:20:36 +01:00
|
|
|
print "<tr>".'<td class="fieldrequired">'.$langs->trans("Amount").'</td><td><input type="text" name="amount" size="10" value="'.price($object->amount).'"> '.$langs->trans("Currency".$conf->currency).'</td></tr>';
|
2020-05-21 15:05:19 +02:00
|
|
|
} else {
|
2017-06-07 16:44:04 +02:00
|
|
|
print '<tr><td>'.$langs->trans("Amount").'</td><td>';
|
2019-01-27 11:55:16 +01:00
|
|
|
print price($object->amount, 0, $langs, 0, 0, -1, $conf->currency);
|
2015-03-29 09:20:32 +02:00
|
|
|
print '</td></tr>';
|
|
|
|
|
}
|
2008-11-15 19:20:40 +01:00
|
|
|
|
2010-02-08 15:57:39 +01:00
|
|
|
print '<tr><td class="fieldrequired">'.$langs->trans("PublicDonation")."</td><td>";
|
2020-11-22 20:59:34 +01:00
|
|
|
print $form->selectyesno("public", $object->public, 1);
|
2008-11-15 19:20:40 +01:00
|
|
|
print "</td>";
|
|
|
|
|
print "</tr>\n";
|
|
|
|
|
|
2021-03-01 11:18:14 +01:00
|
|
|
if (!empty($conf->societe->enabled) && !empty($conf->global->DONATION_USE_THIRDPARTIES)) {
|
2020-10-31 14:32:18 +01:00
|
|
|
$company = new Societe($db);
|
|
|
|
|
|
2021-03-01 11:18:14 +01:00
|
|
|
print '<tr><td>'.$langs->trans("ThirdParty").'</td><td colspan="2">';
|
|
|
|
|
if ($object->socid > 0) {
|
|
|
|
|
$result = $company->fetch($object->socid);
|
|
|
|
|
print $company->getNomUrl(1);
|
|
|
|
|
}
|
|
|
|
|
print '</td></tr>';
|
2020-10-31 14:32:18 +01:00
|
|
|
} else {
|
|
|
|
|
$langs->load("companies");
|
|
|
|
|
print '<tr><td>'.$langs->trans("Company").'</td><td><input type="text" name="societe" class="maxwidth200" value="'.dol_escape_htmltag($object->societe).'"></td></tr>';
|
|
|
|
|
print '<tr><td>'.$langs->trans("Lastname").'</td><td><input type="text" name="lastname" class="maxwidth200" value="'.dol_escape_htmltag($object->lastname).'"></td></tr>';
|
|
|
|
|
print '<tr><td>'.$langs->trans("Firstname").'</td><td><input type="text" name="firstname" class="maxwidth200" value="'.dol_escape_htmltag($object->firstname).'"></td></tr>';
|
|
|
|
|
print '<tr><td>'.$langs->trans("Address").'</td><td>';
|
|
|
|
|
print '<textarea name="address" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.'">'.dol_escape_htmltag($object->address, 0, 1).'</textarea></td></tr>';
|
|
|
|
|
|
|
|
|
|
// Zip / Town
|
|
|
|
|
print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>';
|
2020-11-30 14:47:07 +01:00
|
|
|
print $formcompany->select_ziptown((GETPOSTISSET("zipcode") ? GETPOSTISSET("zipcode") : $object->zip), 'zipcode', array('town', 'selectcountry_id', 'state_id'), 6);
|
2020-10-31 14:32:18 +01:00
|
|
|
print ' ';
|
2020-11-30 14:47:07 +01:00
|
|
|
print $formcompany->select_ziptown((GETPOSTISSET("town") ? GETPOST("town") : $object->town), 'town', array('zipcode', 'selectcountry_id', 'state_id'));
|
2020-10-31 14:32:18 +01:00
|
|
|
print '</tr>';
|
|
|
|
|
|
|
|
|
|
// Country
|
|
|
|
|
print '<tr><td class="titlefieldcreate">'.$langs->trans('Country').'</td><td>';
|
|
|
|
|
print $form->select_country((!empty($object->country_id) ? $object->country_id : $mysoc->country_code), 'country_id');
|
|
|
|
|
if ($user->admin) {
|
|
|
|
|
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
|
|
|
|
}
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
|
|
|
|
|
print "<tr>".'<td>'.$langs->trans("EMail").'</td><td><input type="text" name="email" class="maxwidth200" value="'.dol_escape_htmltag($object->email).'"></td></tr>';
|
|
|
|
|
}
|
|
|
|
|
// Payment mode
|
|
|
|
|
print "<tr><td>".$langs->trans("PaymentMode")."</td><td>\n";
|
2021-02-25 22:18:34 +01:00
|
|
|
if ($object->mode_reglement_id) {
|
|
|
|
|
$selected = $object->mode_reglement_id;
|
|
|
|
|
} else {
|
|
|
|
|
$selected = '';
|
|
|
|
|
}
|
2020-10-31 14:32:18 +01:00
|
|
|
$form->select_types_paiements($selected, 'modepayment', 'CRDT', 0, 1);
|
|
|
|
|
print "</td></tr>\n";
|
|
|
|
|
|
|
|
|
|
// Status
|
2015-03-16 06:29:15 +01:00
|
|
|
print "<tr>".'<td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
|
2008-11-15 19:20:40 +01:00
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
// Project
|
2022-06-14 17:53:17 +02:00
|
|
|
if (!empty($conf->project->enabled)) {
|
2020-10-31 14:32:18 +01:00
|
|
|
$formproject = new FormProjets($db);
|
2015-05-18 22:25:51 +02:00
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
$langs->load('projects');
|
|
|
|
|
print '<tr><td>'.$langs->trans('Project').'</td><td>';
|
2020-03-27 19:08:39 +01:00
|
|
|
$formproject->select_projects(-1, $object->fk_project, 'fk_project', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth500');
|
2020-10-31 14:32:18 +01:00
|
|
|
print '</td></tr>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Other attributes
|
|
|
|
|
$parameters = array();
|
|
|
|
|
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
|
|
|
|
print $hookmanager->resPrint;
|
2021-02-25 22:18:34 +01:00
|
|
|
if (empty($reshook)) {
|
|
|
|
|
print $object->showOptionals($extrafields, 'edit', $parameters);
|
2020-10-31 14:32:18 +01:00
|
|
|
}
|
2015-03-25 22:37:14 +01:00
|
|
|
|
2008-11-15 19:20:40 +01:00
|
|
|
print "</table>\n";
|
2010-04-05 03:25:44 +02:00
|
|
|
|
2020-10-27 18:19:31 +01:00
|
|
|
print dol_get_fiche_end();
|
2010-04-05 03:25:44 +02:00
|
|
|
|
2021-08-20 14:41:30 +02:00
|
|
|
print $form->buttonsSaveCancel();
|
2008-11-15 19:20:40 +01:00
|
|
|
|
2015-06-03 18:08:30 +02:00
|
|
|
print "</form>\n";
|
2004-09-04 17:56:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ************************************************************ */
|
|
|
|
|
/* */
|
2015-03-18 05:07:32 +01:00
|
|
|
/* Donation card in view mode */
|
2004-09-04 17:56:12 +02:00
|
|
|
/* */
|
|
|
|
|
/* ************************************************************ */
|
2021-02-25 22:18:34 +01:00
|
|
|
if (!empty($id) && $action != 'edit') {
|
2015-03-26 20:43:34 +01:00
|
|
|
// Confirmation delete
|
2021-02-25 22:18:34 +01:00
|
|
|
if ($action == 'delete') {
|
2020-10-31 14:32:18 +01:00
|
|
|
$text = $langs->trans("ConfirmDeleteADonation");
|
|
|
|
|
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("DeleteADonation"), $text, "confirm_delete", '', '', 1);
|
|
|
|
|
}
|
2015-05-18 22:25:51 +02:00
|
|
|
|
2019-11-13 19:35:39 +01:00
|
|
|
$result = $object->fetch($id);
|
2015-03-21 07:12:32 +01:00
|
|
|
if ($result < 0) {
|
2019-01-27 11:55:16 +01:00
|
|
|
dol_print_error($db, $object->error); exit;
|
2015-03-21 07:12:32 +01:00
|
|
|
}
|
2019-11-13 19:35:39 +01:00
|
|
|
$result = $object->fetch_optionals();
|
2015-03-21 07:12:32 +01:00
|
|
|
if ($result < 0) {
|
|
|
|
|
dol_print_error($db); exit;
|
|
|
|
|
}
|
2015-05-18 22:25:51 +02:00
|
|
|
|
2019-11-13 19:35:39 +01:00
|
|
|
$hselected = 'card';
|
2015-05-18 23:04:49 +02:00
|
|
|
|
2015-03-16 06:29:15 +01:00
|
|
|
$head = donation_prepare_head($object);
|
2020-10-22 22:50:03 +02:00
|
|
|
print dol_get_fiche_head($head, $hselected, $langs->trans("Donation"), -1, 'donation');
|
2008-11-15 19:20:40 +01:00
|
|
|
|
2016-10-16 17:25:33 +02:00
|
|
|
// Print form confirm
|
|
|
|
|
print $formconfirm;
|
2017-06-07 16:44:04 +02:00
|
|
|
|
2020-04-10 10:59:32 +02:00
|
|
|
$linkback = '<a href="'.DOL_URL_ROOT.'/don/list.php'.(!empty($socid) ? '?socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
|
2017-06-07 16:44:04 +02:00
|
|
|
|
2020-04-10 10:59:32 +02:00
|
|
|
$morehtmlref = '<div class="refidno">';
|
2016-10-16 17:25:33 +02:00
|
|
|
// Project
|
2022-06-14 17:53:17 +02:00
|
|
|
if (!empty($conf->project->enabled)) {
|
2020-10-31 14:32:18 +01:00
|
|
|
$langs->load("projects");
|
|
|
|
|
$morehtmlref .= $langs->trans('Project').' ';
|
2021-02-25 22:18:34 +01:00
|
|
|
if ($user->rights->don->creer) {
|
2020-10-31 14:32:18 +01:00
|
|
|
if ($action != 'classify') {
|
2021-09-18 22:09:55 +02:00
|
|
|
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
|
2020-10-31 14:32:18 +01:00
|
|
|
}
|
|
|
|
|
if ($action == 'classify') {
|
|
|
|
|
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
|
|
|
|
|
$morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
|
|
|
|
|
$morehtmlref .= '<input type="hidden" name="action" value="classin">';
|
|
|
|
|
$morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
|
|
|
|
|
$morehtmlref .= $formproject->select_projects($object->socid, $object->fk_project, 'projectid', 0, 0, 1, 0, 1, 0, 0, '', 1, 0, 'maxwidth500');
|
|
|
|
|
$morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
|
|
|
|
|
$morehtmlref .= '</form>';
|
|
|
|
|
} else {
|
|
|
|
|
$morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (!empty($object->fk_project)) {
|
|
|
|
|
$proj = new Project($db);
|
|
|
|
|
$proj->fetch($object->fk_project);
|
2021-10-29 09:40:38 +02:00
|
|
|
$morehtmlref .= ' : '.$proj->getNomUrl(1);
|
|
|
|
|
if ($proj->title) {
|
|
|
|
|
$morehtmlref .= ' - '.$proj->title;
|
|
|
|
|
}
|
2020-10-31 14:32:18 +01:00
|
|
|
} else {
|
|
|
|
|
$morehtmlref .= '';
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-10-16 17:25:33 +02:00
|
|
|
}
|
2020-04-10 10:59:32 +02:00
|
|
|
$morehtmlref .= '</div>';
|
2017-06-07 16:44:04 +02:00
|
|
|
|
|
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref);
|
2016-10-16 17:25:33 +02:00
|
|
|
|
|
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
print '<div class="fichecenter">';
|
|
|
|
|
print '<div class="fichehalfleft">';
|
|
|
|
|
print '<div class="underbanner clearboth"></div>';
|
2016-10-16 17:25:33 +02:00
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
print '<table class="border tableforfield" width="100%">';
|
2012-07-28 21:22:59 +02:00
|
|
|
|
2008-11-15 19:13:25 +01:00
|
|
|
// Date
|
2016-11-28 20:48:43 +01:00
|
|
|
print '<tr><td class="titlefield">'.$langs->trans("Date").'</td><td colspan="2">';
|
2019-01-27 11:55:16 +01:00
|
|
|
print dol_print_date($object->date, "day");
|
2008-11-15 19:20:40 +01:00
|
|
|
print "</td>";
|
|
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
print '<tr><td>'.$langs->trans("Amount").'</td><td colspan="2">';
|
2019-01-27 11:55:16 +01:00
|
|
|
print price($object->amount, 0, $langs, 0, 0, -1, $conf->currency);
|
2015-03-18 21:56:00 +01:00
|
|
|
print '</td></tr>';
|
2008-11-15 19:20:40 +01:00
|
|
|
|
2015-03-18 21:56:00 +01:00
|
|
|
print '<tr><td>'.$langs->trans("PublicDonation").'</td><td colspan="2">';
|
2015-03-16 06:29:15 +01:00
|
|
|
print yn($object->public);
|
2015-03-18 21:56:00 +01:00
|
|
|
print '</td></tr>';
|
|
|
|
|
|
2021-03-01 11:18:14 +01:00
|
|
|
if (!empty($conf->societe->enabled) && !empty($conf->global->DONATION_USE_THIRDPARTIES)) {
|
2020-10-31 14:32:18 +01:00
|
|
|
$company = new Societe($db);
|
2019-01-18 11:20:36 +01:00
|
|
|
|
2021-03-01 11:18:14 +01:00
|
|
|
print '<tr><td>'.$langs->trans("ThirdParty").'</td><td colspan="2">';
|
|
|
|
|
if ($object->socid > 0) {
|
|
|
|
|
$result = $company->fetch($object->socid);
|
|
|
|
|
print $company->getNomUrl(1);
|
|
|
|
|
}
|
|
|
|
|
print '</td></tr>';
|
2020-10-31 14:32:18 +01:00
|
|
|
} else {
|
|
|
|
|
print '<tr><td>'.$langs->trans("Company").'</td><td colspan="2">'.$object->societe.'</td></tr>';
|
|
|
|
|
print '<tr><td>'.$langs->trans("Lastname").'</td><td colspan="2">'.$object->lastname.'</td></tr>';
|
|
|
|
|
print '<tr><td>'.$langs->trans("Firstname").'</td><td colspan="2">'.$object->firstname.'</td></tr>';
|
|
|
|
|
}
|
2017-06-07 16:44:04 +02:00
|
|
|
|
2016-10-16 17:25:33 +02:00
|
|
|
// Payment mode
|
|
|
|
|
print "<tr><td>".$langs->trans("PaymentMode")."</td><td>";
|
2019-10-30 15:23:24 +01:00
|
|
|
$form->form_modes_reglement(null, $object->mode_reglement_id, 'none');
|
2016-10-16 17:25:33 +02:00
|
|
|
print "</td></tr>\n";
|
2017-06-07 16:44:04 +02:00
|
|
|
|
2016-10-16 17:25:33 +02:00
|
|
|
// Other attributes
|
|
|
|
|
$cols = 2;
|
2019-11-13 19:35:39 +01:00
|
|
|
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
|
2016-11-28 20:48:43 +01:00
|
|
|
|
2016-10-16 17:25:33 +02:00
|
|
|
print '</table>';
|
2016-11-28 20:48:43 +01:00
|
|
|
|
2016-10-16 17:25:33 +02:00
|
|
|
print '</div>';
|
|
|
|
|
print '<div class="fichehalfright">';
|
2016-11-28 20:48:43 +01:00
|
|
|
|
2015-03-18 21:56:00 +01:00
|
|
|
/*
|
|
|
|
|
* Payments
|
|
|
|
|
*/
|
2015-03-29 09:20:32 +02:00
|
|
|
$sql = "SELECT p.rowid, p.num_payment, p.datep as dp, p.amount,";
|
2019-11-13 19:35:39 +01:00
|
|
|
$sql .= "c.code as type_code,c.libelle as paiement_type";
|
|
|
|
|
$sql .= " FROM ".MAIN_DB_PREFIX."payment_donation as p";
|
|
|
|
|
$sql .= ", ".MAIN_DB_PREFIX."c_paiement as c ";
|
|
|
|
|
$sql .= ", ".MAIN_DB_PREFIX."don as d";
|
2021-10-25 18:48:44 +02:00
|
|
|
$sql .= " WHERE d.rowid = ".((int) $id);
|
2019-11-13 19:35:39 +01:00
|
|
|
$sql .= " AND p.fk_donation = d.rowid";
|
|
|
|
|
$sql .= " AND d.entity IN (".getEntity('donation').")";
|
|
|
|
|
$sql .= " AND p.fk_typepayment = c.id";
|
|
|
|
|
$sql .= " ORDER BY dp";
|
2015-03-18 21:56:00 +01:00
|
|
|
|
|
|
|
|
//print $sql;
|
|
|
|
|
$resql = $db->query($sql);
|
2021-02-25 22:18:34 +01:00
|
|
|
if ($resql) {
|
2015-03-18 21:56:00 +01:00
|
|
|
$num = $db->num_rows($resql);
|
|
|
|
|
$i = 0; $total = 0;
|
2019-10-31 23:17:08 +01:00
|
|
|
print '<table class="noborder paymenttable centpercent">';
|
2015-03-18 21:56:00 +01:00
|
|
|
print '<tr class="liste_titre">';
|
|
|
|
|
print '<td>'.$langs->trans("RefPayment").'</td>';
|
|
|
|
|
print '<td>'.$langs->trans("Date").'</td>';
|
|
|
|
|
print '<td>'.$langs->trans("Type").'</td>';
|
2021-02-25 22:18:34 +01:00
|
|
|
print '<td class="right">'.$langs->trans("Amount").'</td>';
|
|
|
|
|
print '</tr>';
|
2015-03-18 21:56:00 +01:00
|
|
|
|
2021-02-25 22:18:34 +01:00
|
|
|
while ($i < $num) {
|
2015-03-18 21:56:00 +01:00
|
|
|
$objp = $db->fetch_object($resql);
|
2017-06-07 16:44:04 +02:00
|
|
|
|
2017-05-13 17:25:35 +02:00
|
|
|
print '<tr class="oddeven"><td>';
|
2019-01-27 11:55:16 +01:00
|
|
|
print '<a href="'.DOL_URL_ROOT.'/don/payment/card.php?id='.$objp->rowid.'">'.img_object($langs->trans("Payment"), "payment").' '.$objp->rowid.'</a></td>';
|
|
|
|
|
print '<td>'.dol_print_date($db->jdate($objp->dp), 'day')."</td>\n";
|
2020-10-31 14:32:18 +01:00
|
|
|
$labeltype = $langs->trans("PaymentType".$objp->type_code) != ("PaymentType".$objp->type_code) ? $langs->trans("PaymentType".$objp->type_code) : $objp->paiement_type;
|
|
|
|
|
print "<td>".$labeltype.' '.$objp->num_payment."</td>\n";
|
2019-03-10 09:00:59 +01:00
|
|
|
print '<td class="right">'.price($objp->amount)."</td>\n";
|
2015-03-18 21:56:00 +01:00
|
|
|
print "</tr>";
|
2015-03-21 18:00:16 +01:00
|
|
|
$totalpaid += $objp->amount;
|
2015-03-18 21:56:00 +01:00
|
|
|
$i++;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-25 22:18:34 +01:00
|
|
|
if ($object->paid == 0) {
|
2019-03-10 09:00:59 +01:00
|
|
|
print "<tr><td colspan=\"3\" class=\"right\">".$langs->trans("AlreadyPaid")." :</td><td class=\"right\">".price($totalpaid)."</td></tr>\n";
|
|
|
|
|
print "<tr><td colspan=\"3\" class=\"right\">".$langs->trans("AmountExpected")." :</td><td class=\"right\">".price($object->amount)."</td></tr>\n";
|
2008-11-15 19:20:40 +01:00
|
|
|
|
2015-03-18 21:56:00 +01:00
|
|
|
$remaintopay = $object->amount - $totalpaid;
|
|
|
|
|
|
2019-03-10 09:00:59 +01:00
|
|
|
print "<tr><td colspan=\"3\" class=\"right\">".$langs->trans("RemainderToPay")." :</td>";
|
2019-11-13 19:35:39 +01:00
|
|
|
print '<td class="right'.($resteapayeraffiche ? ' amountremaintopay' : '').'">'.price($remaintopay)."</td></tr>\n";
|
2015-03-18 21:56:00 +01:00
|
|
|
}
|
|
|
|
|
print "</table>";
|
|
|
|
|
$db->free($resql);
|
2020-05-21 15:05:19 +02:00
|
|
|
} else {
|
2015-03-18 21:56:00 +01:00
|
|
|
dol_print_error($db);
|
|
|
|
|
}
|
2011-06-12 17:47:10 +02:00
|
|
|
|
2016-10-16 17:25:33 +02:00
|
|
|
print '</div>';
|
|
|
|
|
print '</div>';
|
2016-11-28 20:48:43 +01:00
|
|
|
|
2016-10-16 17:25:33 +02:00
|
|
|
print '<div class="clearboth"></div>';
|
2016-11-28 20:48:43 +01:00
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
print dol_get_fiche_end();
|
2008-11-15 19:20:40 +01:00
|
|
|
|
2015-03-18 05:07:32 +01:00
|
|
|
$remaintopay = $object->amount - $totalpaid;
|
2009-01-15 02:14:03 +01:00
|
|
|
|
2016-10-16 17:25:33 +02:00
|
|
|
// Actions buttons
|
|
|
|
|
|
2008-11-15 19:20:40 +01:00
|
|
|
print '<div class="tabsAction">';
|
2004-09-04 17:56:12 +02:00
|
|
|
|
2020-11-03 14:19:54 +01:00
|
|
|
// Re-open
|
2021-02-25 22:18:34 +01:00
|
|
|
if ($permissiontoadd && $object->statut == $object::STATUS_CANCELED) {
|
2020-11-03 14:19:54 +01:00
|
|
|
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_reopen&confirm=yes&token='.newToken().'">'.$langs->trans("ReOpen").'</a>';
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-27 12:24:01 +02:00
|
|
|
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'&rowid='.$object->id.'">'.$langs->trans('Modify').'</a></div>';
|
2004-11-16 21:11:30 +01:00
|
|
|
|
2021-02-25 22:18:34 +01:00
|
|
|
if ($object->statut == $object::STATUS_DRAFT) {
|
2020-09-30 15:13:28 +02:00
|
|
|
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=valid_promesse&token='.newToken().'">'.$langs->trans("ValidPromess").'</a></div>';
|
2008-11-15 19:20:40 +01:00
|
|
|
}
|
2002-12-21 18:34:05 +01:00
|
|
|
|
2021-02-25 22:18:34 +01:00
|
|
|
if (($object->statut == $object::STATUS_DRAFT || $object->statut == $object::STATUS_VALIDATED) && $totalpaid == 0 && $object->paid == 0) {
|
2020-10-31 14:32:18 +01:00
|
|
|
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=set_cancel&token='.newToken().'">'.$langs->trans("ClassifyCanceled")."</a></div>";
|
|
|
|
|
}
|
2011-06-12 17:47:10 +02:00
|
|
|
|
2015-03-18 05:07:32 +01:00
|
|
|
// Create payment
|
2021-02-25 22:18:34 +01:00
|
|
|
if ($object->statut == $object::STATUS_VALIDATED && $object->paid == 0 && $user->rights->don->creer) {
|
|
|
|
|
if ($remaintopay == 0) {
|
2019-11-13 19:35:39 +01:00
|
|
|
print '<div class="inline-block divButAction"><span class="butActionRefused classfortooltip" title="'.$langs->trans("DisabledBecauseRemainderToPayIsZero").'">'.$langs->trans('DoPayment').'</span></div>';
|
2020-05-21 15:05:19 +02:00
|
|
|
} else {
|
2021-09-27 12:24:01 +02:00
|
|
|
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/don/payment/payment.php?rowid='.$object->id.'&action=create&token='.newToken().'">'.$langs->trans('DoPayment').'</a></div>';
|
2015-03-18 05:07:32 +01:00
|
|
|
}
|
2008-11-15 19:20:40 +01:00
|
|
|
}
|
|
|
|
|
|
2015-03-18 05:07:32 +01:00
|
|
|
// Classify 'paid'
|
2021-02-25 22:18:34 +01:00
|
|
|
if ($object->statut == $object::STATUS_VALIDATED && round($remaintopay) == 0 && $object->paid == 0 && $user->rights->don->creer) {
|
2021-09-18 22:09:55 +02:00
|
|
|
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>";
|
2015-03-18 05:07:32 +01:00
|
|
|
}
|
2015-05-18 22:25:51 +02:00
|
|
|
|
2015-03-26 20:43:34 +01:00
|
|
|
// Delete
|
2021-02-25 22:18:34 +01:00
|
|
|
if ($user->rights->don->supprimer) {
|
|
|
|
|
if ($object->statut == $object::STATUS_CANCELED || $object->statut == $object::STATUS_DRAFT) {
|
2020-10-01 10:50:54 +02:00
|
|
|
print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?rowid='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans("Delete")."</a></div>";
|
2020-05-21 15:05:19 +02:00
|
|
|
} else {
|
2018-11-13 21:40:17 +01:00
|
|
|
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans("Delete")."</a></div>";
|
2015-05-31 03:30:38 +02:00
|
|
|
}
|
2020-05-21 15:05:19 +02:00
|
|
|
} else {
|
2018-11-13 21:40:17 +01:00
|
|
|
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans("Delete")."</a></div>";
|
2008-11-15 19:20:40 +01:00
|
|
|
}
|
2002-12-19 19:55:38 +01:00
|
|
|
|
2008-11-15 19:20:40 +01:00
|
|
|
print "</div>";
|
2005-11-11 23:36:56 +01:00
|
|
|
|
|
|
|
|
|
2020-10-31 14:32:18 +01:00
|
|
|
print '<div class="fichecenter"><div class="fichehalfleft">';
|
2005-11-11 23:36:56 +01:00
|
|
|
|
|
|
|
|
/*
|
2021-03-16 04:04:18 +01:00
|
|
|
* Generated documents
|
2005-11-11 23:36:56 +01:00
|
|
|
*/
|
2019-11-13 19:35:39 +01:00
|
|
|
$filename = dol_sanitizeFileName($object->id);
|
|
|
|
|
$filedir = $conf->don->dir_output."/".dol_sanitizeFileName($object->id);
|
|
|
|
|
$urlsource = $_SERVER['PHP_SELF'].'?rowid='.$object->id;
|
|
|
|
|
$genallowed = (($object->paid == 0 || $user->admin) && $user->rights->don->lire);
|
|
|
|
|
$delallowed = $user->rights->don->creer;
|
2005-11-11 23:36:56 +01:00
|
|
|
|
2020-09-10 01:49:09 +02:00
|
|
|
print $formfile->showdocuments('donation', $filename, $filedir, $urlsource, $genallowed, $delallowed, $object->model_pdf);
|
2002-12-26 11:22:14 +01:00
|
|
|
|
2017-09-17 20:45:00 +02:00
|
|
|
// Show links to link elements
|
|
|
|
|
$linktoelem = $form->showLinkToObjectBlock($object, null, array('don'));
|
|
|
|
|
$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
|
|
|
|
|
|
2019-10-27 08:50:32 +01:00
|
|
|
// Show online payment link
|
2020-04-10 10:59:32 +02:00
|
|
|
$useonlinepayment = (!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled));
|
2018-09-05 17:36:28 +02:00
|
|
|
|
2021-02-25 22:18:34 +01:00
|
|
|
if ($useonlinepayment) { //$object->statut != Facture::STATUS_DRAFT &&
|
2019-10-27 08:50:32 +01:00
|
|
|
print '<br><!-- Link to pay -->'."\n";
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
|
|
|
|
|
print showOnlinePaymentUrl('donation', $object->ref).'<br>';
|
|
|
|
|
}
|
2017-09-17 20:45:00 +02:00
|
|
|
|
2021-10-23 17:18:35 +02:00
|
|
|
print '</div><div class="fichehalfright">';
|
2016-11-28 20:48:43 +01:00
|
|
|
|
2021-10-23 17:18:35 +02:00
|
|
|
print '</div></div>';
|
2002-12-19 19:55:38 +01:00
|
|
|
}
|
|
|
|
|
|
2011-08-27 16:24:16 +02:00
|
|
|
llxFooter();
|
2016-07-01 03:51:23 +02:00
|
|
|
$db->close();
|