code syntax don directory
This commit is contained in:
parent
f7c119e48c
commit
8670cc2d6f
@ -30,12 +30,16 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||||
if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
|
if (!empty($conf->accounting->enabled)) {
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
|
||||||
|
}
|
||||||
|
|
||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array('admin', 'donations', 'accountancy', 'other'));
|
$langs->loadLangs(array('admin', 'donations', 'accountancy', 'other'));
|
||||||
|
|
||||||
if (!$user->admin) accessforbidden();
|
if (!$user->admin) {
|
||||||
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
$action = GETPOST('action', 'aZ09');
|
$action = GETPOST('action', 'aZ09');
|
||||||
$value = GETPOST('value');
|
$value = GETPOST('value');
|
||||||
@ -49,8 +53,7 @@ $type = 'donation';
|
|||||||
* Action
|
* Action
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($action == 'specimen')
|
if ($action == 'specimen') {
|
||||||
{
|
|
||||||
$modele = GETPOST('module', 'alpha');
|
$modele = GETPOST('module', 'alpha');
|
||||||
|
|
||||||
$don = new Don($db);
|
$don = new Don($db);
|
||||||
@ -59,15 +62,13 @@ if ($action == 'specimen')
|
|||||||
// Search template files
|
// Search template files
|
||||||
$dir = DOL_DOCUMENT_ROOT."/core/modules/dons/";
|
$dir = DOL_DOCUMENT_ROOT."/core/modules/dons/";
|
||||||
$file = $modele.".modules.php";
|
$file = $modele.".modules.php";
|
||||||
if (file_exists($dir.$file))
|
if (file_exists($dir.$file)) {
|
||||||
{
|
|
||||||
$classname = $modele;
|
$classname = $modele;
|
||||||
require_once $dir.$file;
|
require_once $dir.$file;
|
||||||
|
|
||||||
$obj = new $classname($db);
|
$obj = new $classname($db);
|
||||||
|
|
||||||
if ($obj->write_file($don, $langs) > 0)
|
if ($obj->write_file($don, $langs) > 0) {
|
||||||
{
|
|
||||||
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=donation&file=SPECIMEN.html");
|
header("Location: ".DOL_URL_ROOT."/document.php?modulepart=donation&file=SPECIMEN.html");
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
@ -78,13 +79,9 @@ if ($action == 'specimen')
|
|||||||
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
|
setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
|
||||||
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
|
||||||
}
|
}
|
||||||
}
|
} elseif ($action == 'setdoc') {
|
||||||
|
|
||||||
// Set default model
|
// Set default model
|
||||||
elseif ($action == 'setdoc')
|
if (dolibarr_set_const($db, "DON_ADDON_MODEL", $value, 'chaine', 0, '', $conf->entity)) {
|
||||||
{
|
|
||||||
if (dolibarr_set_const($db, "DON_ADDON_MODEL", $value, 'chaine', 0, '', $conf->entity))
|
|
||||||
{
|
|
||||||
// The constant that was read before the new set
|
// The constant that was read before the new set
|
||||||
// So we go through a variable for a coherent display
|
// So we go through a variable for a coherent display
|
||||||
$conf->global->DON_ADDON_MODEL = $value;
|
$conf->global->DON_ADDON_MODEL = $value;
|
||||||
@ -92,52 +89,48 @@ elseif ($action == 'setdoc')
|
|||||||
|
|
||||||
// It enables the model
|
// It enables the model
|
||||||
$ret = delDocumentModel($value, $type);
|
$ret = delDocumentModel($value, $type);
|
||||||
if ($ret > 0)
|
if ($ret > 0) {
|
||||||
{
|
|
||||||
$ret = addDocumentModel($value, $type, $label, $scandir);
|
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||||
}
|
}
|
||||||
}
|
} elseif ($action == 'set') {
|
||||||
|
|
||||||
// Activate a model
|
// Activate a model
|
||||||
elseif ($action == 'set')
|
|
||||||
{
|
|
||||||
$ret = addDocumentModel($value, $type, $label, $scandir);
|
$ret = addDocumentModel($value, $type, $label, $scandir);
|
||||||
} elseif ($action == 'del')
|
} elseif ($action == 'del') {
|
||||||
{
|
|
||||||
$ret = delDocumentModel($value, $type);
|
$ret = delDocumentModel($value, $type);
|
||||||
if ($ret > 0)
|
if ($ret > 0) {
|
||||||
{
|
if ($conf->global->DON_ADDON_MODEL == "$value") {
|
||||||
if ($conf->global->DON_ADDON_MODEL == "$value") dolibarr_del_const($db, 'DON_ADDON_MODEL', $conf->entity);
|
dolibarr_del_const($db, 'DON_ADDON_MODEL', $conf->entity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Options
|
// Options
|
||||||
if ($action == 'set_DONATION_ACCOUNTINGACCOUNT')
|
if ($action == 'set_DONATION_ACCOUNTINGACCOUNT') {
|
||||||
{
|
|
||||||
$account = GETPOST('DONATION_ACCOUNTINGACCOUNT', 'alpha');
|
$account = GETPOST('DONATION_ACCOUNTINGACCOUNT', 'alpha');
|
||||||
|
|
||||||
$res = dolibarr_set_const($db, "DONATION_ACCOUNTINGACCOUNT", $account, 'chaine', 0, '', $conf->entity);
|
$res = dolibarr_set_const($db, "DONATION_ACCOUNTINGACCOUNT", $account, 'chaine', 0, '', $conf->entity);
|
||||||
|
|
||||||
if (!($res > 0)) $error++;
|
if (!($res > 0)) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'set_DONATION_MESSAGE')
|
if ($action == 'set_DONATION_MESSAGE') {
|
||||||
{
|
|
||||||
$freemessage = GETPOST('DONATION_MESSAGE', 'restricthtml'); // No alpha here, we want exact string
|
$freemessage = GETPOST('DONATION_MESSAGE', 'restricthtml'); // No alpha here, we want exact string
|
||||||
|
|
||||||
$res = dolibarr_set_const($db, "DONATION_MESSAGE", $freemessage, 'chaine', 0, '', $conf->entity);
|
$res = dolibarr_set_const($db, "DONATION_MESSAGE", $freemessage, 'chaine', 0, '', $conf->entity);
|
||||||
|
|
||||||
if (!($res > 0)) $error++;
|
if (!($res > 0)) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||||
} else {
|
} else {
|
||||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||||
@ -147,11 +140,9 @@ if ($action == 'set_DONATION_MESSAGE')
|
|||||||
/*
|
/*
|
||||||
* Action
|
* Action
|
||||||
*/
|
*/
|
||||||
if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
|
if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) {
|
||||||
{
|
|
||||||
$code = $reg[1];
|
$code = $reg[1];
|
||||||
if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0)
|
if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) {
|
||||||
{
|
|
||||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
@ -159,11 +150,9 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg))
|
if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) {
|
||||||
{
|
|
||||||
$code = $reg[1];
|
$code = $reg[1];
|
||||||
if (dolibarr_del_const($db, $code, $conf->entity) > 0)
|
if (dolibarr_del_const($db, $code, $conf->entity) > 0) {
|
||||||
{
|
|
||||||
header("Location: ".$_SERVER["PHP_SELF"]);
|
header("Location: ".$_SERVER["PHP_SELF"]);
|
||||||
exit;
|
exit;
|
||||||
} else {
|
} else {
|
||||||
@ -177,7 +166,9 @@ if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg))
|
|||||||
|
|
||||||
$dir = "../../core/modules/dons/";
|
$dir = "../../core/modules/dons/";
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
|
if (!empty($conf->accounting->enabled)) {
|
||||||
|
$formaccounting = new FormAccounting($db);
|
||||||
|
}
|
||||||
|
|
||||||
llxHeader('', $langs->trans("DonationsSetup"), 'DonConfiguration');
|
llxHeader('', $langs->trans("DonationsSetup"), 'DonConfiguration');
|
||||||
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
||||||
@ -198,12 +189,10 @@ $sql = "SELECT nom";
|
|||||||
$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
|
$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
|
||||||
$sql .= " WHERE type = '".$db->escape($type)."'";
|
$sql .= " WHERE type = '".$db->escape($type)."'";
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$num_rows = $db->num_rows($resql);
|
$num_rows = $db->num_rows($resql);
|
||||||
while ($i < $num_rows)
|
while ($i < $num_rows) {
|
||||||
{
|
|
||||||
$array = $db->fetch_array($resql);
|
$array = $db->fetch_array($resql);
|
||||||
array_push($def, $array[0]);
|
array_push($def, $array[0]);
|
||||||
$i++;
|
$i++;
|
||||||
@ -226,12 +215,9 @@ clearstatcache();
|
|||||||
|
|
||||||
$handle = opendir($dir);
|
$handle = opendir($dir);
|
||||||
|
|
||||||
if (is_resource($handle))
|
if (is_resource($handle)) {
|
||||||
{
|
while (($file = readdir($handle)) !== false) {
|
||||||
while (($file = readdir($handle)) !== false)
|
if (preg_match('/\.modules\.php$/i', $file)) {
|
||||||
{
|
|
||||||
if (preg_match('/\.modules\.php$/i', $file))
|
|
||||||
{
|
|
||||||
$name = substr($file, 0, dol_strlen($file) - 12);
|
$name = substr($file, 0, dol_strlen($file) - 12);
|
||||||
$classname = substr($file, 0, dol_strlen($file) - 12);
|
$classname = substr($file, 0, dol_strlen($file) - 12);
|
||||||
|
|
||||||
@ -239,11 +225,14 @@ if (is_resource($handle))
|
|||||||
$module = new $classname($db);
|
$module = new $classname($db);
|
||||||
|
|
||||||
// Show modules according to features level
|
// Show modules according to features level
|
||||||
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
|
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
|
||||||
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
|
continue;
|
||||||
|
}
|
||||||
|
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ($module->isEnabled())
|
if ($module->isEnabled()) {
|
||||||
{
|
|
||||||
print '<tr class="oddeven"><td width=\"100\">';
|
print '<tr class="oddeven"><td width=\"100\">';
|
||||||
echo $module->name;
|
echo $module->name;
|
||||||
print '</td>';
|
print '</td>';
|
||||||
@ -252,10 +241,8 @@ if (is_resource($handle))
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
|
|
||||||
// Active
|
// Active
|
||||||
if (in_array($name, $def))
|
if (in_array($name, $def)) {
|
||||||
{
|
if ($conf->global->DON_ADDON_MODEL == $name) {
|
||||||
if ($conf->global->DON_ADDON_MODEL == $name)
|
|
||||||
{
|
|
||||||
print "<td class=\"center\">\n";
|
print "<td class=\"center\">\n";
|
||||||
print img_picto($langs->trans("Enabled"), 'switch_on');
|
print img_picto($langs->trans("Enabled"), 'switch_on');
|
||||||
print '</td>';
|
print '</td>';
|
||||||
@ -271,8 +258,7 @@ if (is_resource($handle))
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Default
|
// Default
|
||||||
if ($conf->global->DON_ADDON_MODEL == "$name")
|
if ($conf->global->DON_ADDON_MODEL == "$name") {
|
||||||
{
|
|
||||||
print "<td class=\"center\">";
|
print "<td class=\"center\">";
|
||||||
print img_picto($langs->trans("Default"), 'on');
|
print img_picto($langs->trans("Default"), 'on');
|
||||||
print '</td>';
|
print '</td>';
|
||||||
@ -285,8 +271,7 @@ if (is_resource($handle))
|
|||||||
// Info
|
// Info
|
||||||
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
|
$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
|
||||||
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
|
$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
|
||||||
if ($module->type == 'pdf')
|
if ($module->type == 'pdf') {
|
||||||
{
|
|
||||||
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
|
$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
|
||||||
}
|
}
|
||||||
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
|
$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
|
||||||
@ -345,8 +330,7 @@ print '<td>';
|
|||||||
$label = $langs->trans("AccountAccounting");
|
$label = $langs->trans("AccountAccounting");
|
||||||
print '<label for="DONATION_ACCOUNTINGACCOUNT">'.$label.'</label></td>';
|
print '<label for="DONATION_ACCOUNTINGACCOUNT">'.$label.'</label></td>';
|
||||||
print '<td class="center">';
|
print '<td class="center">';
|
||||||
if (!empty($conf->accounting->enabled))
|
if (!empty($conf->accounting->enabled)) {
|
||||||
{
|
|
||||||
print $formaccounting->select_account($conf->global->DONATION_ACCOUNTINGACCOUNT, 'DONATION_ACCOUNTINGACCOUNT', 1, '', 1, 1);
|
print $formaccounting->select_account($conf->global->DONATION_ACCOUNTINGACCOUNT, 'DONATION_ACCOUNTINGACCOUNT', 1, '', 1, 1);
|
||||||
} else {
|
} else {
|
||||||
print '<input type="text" size="10" id="DONATION_ACCOUNTINGACCOUNT" name="DONATION_ACCOUNTINGACCOUNT" value="'.$conf->global->DONATION_ACCOUNTINGACCOUNT.'">';
|
print '<input type="text" size="10" id="DONATION_ACCOUNTINGACCOUNT" name="DONATION_ACCOUNTINGACCOUNT" value="'.$conf->global->DONATION_ACCOUNTINGACCOUNT.'">';
|
||||||
@ -373,8 +357,7 @@ print '</form>';
|
|||||||
/*
|
/*
|
||||||
* French params
|
* French params
|
||||||
*/
|
*/
|
||||||
if (preg_match('/fr/i', $conf->global->MAIN_INFO_SOCIETE_COUNTRY))
|
if (preg_match('/fr/i', $conf->global->MAIN_INFO_SOCIETE_COUNTRY)) {
|
||||||
{
|
|
||||||
print '<br>';
|
print '<br>';
|
||||||
print load_fiche_titre($langs->trans("FrenchOptions"), '', '');
|
print load_fiche_titre($langs->trans("FrenchOptions"), '', '');
|
||||||
|
|
||||||
|
|||||||
@ -35,13 +35,17 @@ $form = new Form($db);
|
|||||||
// List of supported format
|
// List of supported format
|
||||||
$tmptype2label = ExtraFields::$type2label;
|
$tmptype2label = ExtraFields::$type2label;
|
||||||
$type2label = array('');
|
$type2label = array('');
|
||||||
foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val);
|
foreach ($tmptype2label as $key => $val) {
|
||||||
|
$type2label[$key] = $langs->transnoentitiesnoconv($val);
|
||||||
|
}
|
||||||
|
|
||||||
$action = GETPOST('action', 'aZ09');
|
$action = GETPOST('action', 'aZ09');
|
||||||
$attrname = GETPOST('attrname', 'alpha');
|
$attrname = GETPOST('attrname', 'alpha');
|
||||||
$elementtype = 'don'; //Must be the $table_element of the class that manage extrafield
|
$elementtype = 'don'; //Must be the $table_element of the class that manage extrafield
|
||||||
|
|
||||||
if (!$user->admin) accessforbidden();
|
if (!$user->admin) {
|
||||||
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -74,8 +78,7 @@ print dol_get_fiche_end();
|
|||||||
|
|
||||||
|
|
||||||
// Buttons
|
// Buttons
|
||||||
if ($action != 'create' && $action != 'edit')
|
if ($action != 'create' && $action != 'edit') {
|
||||||
{
|
|
||||||
print '<div class="tabsAction">';
|
print '<div class="tabsAction">';
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=create">'.$langs->trans("NewAttribute").'</a></div>';
|
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=create">'.$langs->trans("NewAttribute").'</a></div>';
|
||||||
print "</div>";
|
print "</div>";
|
||||||
@ -88,8 +91,7 @@ if ($action != 'create' && $action != 'edit')
|
|||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
if ($action == 'create')
|
if ($action == 'create') {
|
||||||
{
|
|
||||||
print "<br>";
|
print "<br>";
|
||||||
print load_fiche_titre($langs->trans('NewAttribute'));
|
print load_fiche_titre($langs->trans('NewAttribute'));
|
||||||
|
|
||||||
@ -101,8 +103,7 @@ if ($action == 'create')
|
|||||||
/* Edit optional field */
|
/* Edit optional field */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
if ($action == 'edit' && !empty($attrname))
|
if ($action == 'edit' && !empty($attrname)) {
|
||||||
{
|
|
||||||
print "<br>";
|
print "<br>";
|
||||||
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
|
print load_fiche_titre($langs->trans("FieldEdition", $attrname));
|
||||||
|
|
||||||
|
|||||||
@ -79,23 +79,27 @@ $permissiontoadd = $user->rights->don->creer;
|
|||||||
$parameters = array();
|
$parameters = array();
|
||||||
|
|
||||||
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some
|
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some
|
||||||
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
if ($reshook < 0) {
|
||||||
|
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
|
||||||
|
}
|
||||||
|
|
||||||
// Action reopen object
|
// Action reopen object
|
||||||
if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd)
|
if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd) {
|
||||||
{
|
|
||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
|
|
||||||
$result = $object->reopen($user);
|
$result = $object->reopen($user);
|
||||||
if ($result >= 0)
|
if ($result >= 0) {
|
||||||
{
|
|
||||||
// Define output language
|
// Define output language
|
||||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
||||||
if (method_exists($object, 'generateDocument')) {
|
if (method_exists($object, 'generateDocument')) {
|
||||||
$outputlangs = $langs;
|
$outputlangs = $langs;
|
||||||
$newlang = '';
|
$newlang = '';
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
|
||||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
|
$newlang = GETPOST('lang_id', 'aZ09');
|
||||||
|
}
|
||||||
|
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
|
||||||
|
$newlang = $object->thirdparty->default_lang;
|
||||||
|
}
|
||||||
if (!empty($newlang)) {
|
if (!empty($newlang)) {
|
||||||
$outputlangs = new Translate("", $conf);
|
$outputlangs = new Translate("", $conf);
|
||||||
$outputlangs->setDefaultLang($newlang);
|
$outputlangs->setDefaultLang($newlang);
|
||||||
@ -114,32 +118,27 @@ if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'update')
|
if ($action == 'update') {
|
||||||
{
|
if (!empty($cancel)) {
|
||||||
if (!empty($cancel))
|
|
||||||
{
|
|
||||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
|
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
if (empty($donation_date))
|
if (empty($donation_date)) {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
|
||||||
$action = "create";
|
$action = "create";
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($amount))
|
if (empty($amount)) {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors');
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors');
|
||||||
$action = "create";
|
$action = "create";
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
|
|
||||||
$object->firstname = (string) GETPOST("firstname", 'alpha');
|
$object->firstname = (string) GETPOST("firstname", 'alpha');
|
||||||
@ -160,7 +159,9 @@ if ($action == 'update')
|
|||||||
|
|
||||||
// Fill array 'array_options' with data from add form
|
// Fill array 'array_options' with data from add form
|
||||||
$ret = $extrafields->setOptionalsFromPost(null, $object);
|
$ret = $extrafields->setOptionalsFromPost(null, $object);
|
||||||
if ($ret < 0) $error++;
|
if ($ret < 0) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
if ($object->update($user) > 0) {
|
if ($object->update($user) > 0) {
|
||||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||||
@ -169,32 +170,27 @@ if ($action == 'update')
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action == 'add')
|
if ($action == 'add') {
|
||||||
{
|
if (!empty($cancel)) {
|
||||||
if (!empty($cancel))
|
|
||||||
{
|
|
||||||
header("Location: index.php");
|
header("Location: index.php");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
if (empty($donation_date))
|
if (empty($donation_date)) {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
|
||||||
$action = "create";
|
$action = "create";
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($amount))
|
if (empty($amount)) {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors');
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors');
|
||||||
$action = "create";
|
$action = "create";
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
$object->socid = (int) GETPOST("socid", 'int');
|
$object->socid = (int) GETPOST("socid", 'int');
|
||||||
$object->firstname = (string) GETPOST("firstname", 'alpha');
|
$object->firstname = (string) GETPOST("firstname", 'alpha');
|
||||||
$object->lastname = (string) GETPOST("lastname", 'alpha');
|
$object->lastname = (string) GETPOST("lastname", 'alpha');
|
||||||
@ -214,7 +210,9 @@ if ($action == 'add')
|
|||||||
|
|
||||||
// Fill array 'array_options' with data from add form
|
// Fill array 'array_options' with data from add form
|
||||||
$ret = $extrafields->setOptionalsFromPost(null, $object);
|
$ret = $extrafields->setOptionalsFromPost(null, $object);
|
||||||
if ($ret < 0) $error++;
|
if ($ret < 0) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
$res = $object->create($user);
|
$res = $object->create($user);
|
||||||
if ($res > 0) {
|
if ($res > 0) {
|
||||||
@ -331,10 +329,11 @@ llxHeader('', $langs->trans("Donation"), 'EN:Module_Donations|FR:Module_Dons|ES:
|
|||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
$formfile = new FormFile($db);
|
$formfile = new FormFile($db);
|
||||||
$formcompany = new FormCompany($db);
|
$formcompany = new FormCompany($db);
|
||||||
if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
|
if (!empty($conf->projet->enabled)) {
|
||||||
|
$formproject = new FormProjets($db);
|
||||||
|
}
|
||||||
|
|
||||||
if ($action == 'create')
|
if ($action == 'create') {
|
||||||
{
|
|
||||||
print load_fiche_titre($langs->trans("AddDonation"), '', 'object_donation');
|
print load_fiche_titre($langs->trans("AddDonation"), '', 'object_donation');
|
||||||
|
|
||||||
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||||
@ -350,12 +349,10 @@ if ($action == 'create')
|
|||||||
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans('Ref').'</td><td colspan="2">'.$langs->trans('Draft').'</td></tr>';
|
print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans('Ref').'</td><td colspan="2">'.$langs->trans('Draft').'</td></tr>';
|
||||||
|
|
||||||
// Company
|
// Company
|
||||||
if (!empty($conf->societe->enabled) && !empty($conf->global->DONATION_USE_THIRDPARTIES))
|
if (!empty($conf->societe->enabled) && !empty($conf->global->DONATION_USE_THIRDPARTIES)) {
|
||||||
{
|
|
||||||
// Thirdparty
|
// Thirdparty
|
||||||
print '<td>'.$langs->trans('Customer').'</td>';
|
print '<td>'.$langs->trans('Customer').'</td>';
|
||||||
if ($soc->id > 0 && !GETPOST('fac_rec', 'alpha'))
|
if ($soc->id > 0 && !GETPOST('fac_rec', 'alpha')) {
|
||||||
{
|
|
||||||
print '<td colspan="2">';
|
print '<td colspan="2">';
|
||||||
print $soc->getNomUrl(1);
|
print $soc->getNomUrl(1);
|
||||||
print '<input type="hidden" name="socid" value="'.$soc->id.'">';
|
print '<input type="hidden" name="socid" value="'.$soc->id.'">';
|
||||||
@ -364,9 +361,10 @@ if ($action == 'create')
|
|||||||
$outstandingBills = $arrayoutstandingbills['opened'];
|
$outstandingBills = $arrayoutstandingbills['opened'];
|
||||||
print ' ('.$langs->trans('CurrentOutstandingBill').': ';
|
print ' ('.$langs->trans('CurrentOutstandingBill').': ';
|
||||||
print price($outstandingBills, '', $langs, 0, 0, -1, $conf->currency);
|
print price($outstandingBills, '', $langs, 0, 0, -1, $conf->currency);
|
||||||
if ($soc->outstanding_limit != '')
|
if ($soc->outstanding_limit != '') {
|
||||||
{
|
if ($outstandingBills > $soc->outstanding_limit) {
|
||||||
if ($outstandingBills > $soc->outstanding_limit) print img_warning($langs->trans("OutstandingBillReached"));
|
print img_warning($langs->trans("OutstandingBillReached"));
|
||||||
|
}
|
||||||
print ' / '.price($soc->outstanding_limit, '', $langs, 0, 0, -1, $conf->currency);
|
print ' / '.price($soc->outstanding_limit, '', $langs, 0, 0, -1, $conf->currency);
|
||||||
}
|
}
|
||||||
print ')';
|
print ')';
|
||||||
@ -375,8 +373,7 @@ if ($action == 'create')
|
|||||||
print '<td colspan="2">';
|
print '<td colspan="2">';
|
||||||
print $form->select_company($soc->id, 'socid', '(s.client = 1 OR s.client = 3) AND status=1', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300');
|
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
|
// Option to reload page to retrieve customer informations. Note, this clear other input
|
||||||
if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED))
|
if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED)) {
|
||||||
{
|
|
||||||
print '<script type="text/javascript">
|
print '<script type="text/javascript">
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$("#socid").change(function() {
|
$("#socid").change(function() {
|
||||||
@ -408,8 +405,7 @@ if ($action == 'create')
|
|||||||
print $form->selectyesno("public", $public_donation, 1);
|
print $form->selectyesno("public", $public_donation, 1);
|
||||||
print "</td></tr>\n";
|
print "</td></tr>\n";
|
||||||
|
|
||||||
if (empty($conf->societe->enabled) || empty($conf->global->DONATION_USE_THIRDPARTIES))
|
if (empty($conf->societe->enabled) || empty($conf->global->DONATION_USE_THIRDPARTIES)) {
|
||||||
{
|
|
||||||
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("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("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("Firstname").'</td><td><input type="text" name="firstname" value="'.dol_escape_htmltag(GETPOST("firstname")).'" class="maxwidth200"></td></tr>';
|
||||||
@ -426,7 +422,9 @@ if ($action == 'create')
|
|||||||
// Country
|
// Country
|
||||||
print '<tr><td><label for="selectcountry_id">'.$langs->trans('Country').'</label></td><td class="maxwidthonsmartphone">';
|
print '<tr><td><label for="selectcountry_id">'.$langs->trans('Country').'</label></td><td class="maxwidthonsmartphone">';
|
||||||
print img_picto('', 'globe-americas', 'class="paddingrightonly"').$form->select_country(GETPOST('country_id') != '' ?GETPOST('country_id') : $object->country_id);
|
print img_picto('', 'globe-americas', 'class="paddingrightonly"').$form->select_country(GETPOST('country_id') != '' ?GETPOST('country_id') : $object->country_id);
|
||||||
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
if ($user->admin) {
|
||||||
|
print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
|
||||||
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
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>';
|
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>';
|
||||||
@ -458,8 +456,7 @@ if ($action == 'create')
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($conf->projet->enabled))
|
if (!empty($conf->projet->enabled)) {
|
||||||
{
|
|
||||||
print "<tr><td>".$langs->trans("Project")."</td><td>";
|
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');
|
$formproject->select_projects(-1, $projectid, 'fk_project', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth500');
|
||||||
print "</td></tr>\n";
|
print "</td></tr>\n";
|
||||||
@ -469,8 +466,7 @@ if ($action == 'create')
|
|||||||
$parameters = array();
|
$parameters = array();
|
||||||
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||||
print $hookmanager->resPrint;
|
print $hookmanager->resPrint;
|
||||||
if (empty($reshook))
|
if (empty($reshook)) {
|
||||||
{
|
|
||||||
print $object->showOptionals($extrafields, 'edit', $parameters);
|
print $object->showOptionals($extrafields, 'edit', $parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -495,8 +491,7 @@ if ($action == 'create')
|
|||||||
/* */
|
/* */
|
||||||
/* ************************************************************ */
|
/* ************************************************************ */
|
||||||
|
|
||||||
if (!empty($id) && $action == 'edit')
|
if (!empty($id) && $action == 'edit') {
|
||||||
{
|
|
||||||
$result = $object->fetch($id);
|
$result = $object->fetch($id);
|
||||||
if ($result < 0) {
|
if ($result < 0) {
|
||||||
dol_print_error($db, $object->error); exit;
|
dol_print_error($db, $object->error); exit;
|
||||||
@ -577,8 +572,11 @@ if (!empty($id) && $action == 'edit')
|
|||||||
}
|
}
|
||||||
// Payment mode
|
// Payment mode
|
||||||
print "<tr><td>".$langs->trans("PaymentMode")."</td><td>\n";
|
print "<tr><td>".$langs->trans("PaymentMode")."</td><td>\n";
|
||||||
if ($object->mode_reglement_id) $selected = $object->mode_reglement_id;
|
if ($object->mode_reglement_id) {
|
||||||
else $selected = '';
|
$selected = $object->mode_reglement_id;
|
||||||
|
} else {
|
||||||
|
$selected = '';
|
||||||
|
}
|
||||||
$form->select_types_paiements($selected, 'modepayment', 'CRDT', 0, 1);
|
$form->select_types_paiements($selected, 'modepayment', 'CRDT', 0, 1);
|
||||||
print "</td></tr>\n";
|
print "</td></tr>\n";
|
||||||
|
|
||||||
@ -599,8 +597,7 @@ if (!empty($id) && $action == 'edit')
|
|||||||
$parameters = array();
|
$parameters = array();
|
||||||
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||||
print $hookmanager->resPrint;
|
print $hookmanager->resPrint;
|
||||||
if (empty($reshook))
|
if (empty($reshook)) {
|
||||||
{
|
|
||||||
print $object->showOptionals($extrafields, 'edit', $parameters);
|
print $object->showOptionals($extrafields, 'edit', $parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -620,11 +617,9 @@ if (!empty($id) && $action == 'edit')
|
|||||||
/* Donation card in view mode */
|
/* Donation card in view mode */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************ */
|
/* ************************************************************ */
|
||||||
if (!empty($id) && $action != 'edit')
|
if (!empty($id) && $action != 'edit') {
|
||||||
{
|
|
||||||
// Confirmation delete
|
// Confirmation delete
|
||||||
if ($action == 'delete')
|
if ($action == 'delete') {
|
||||||
{
|
|
||||||
$text = $langs->trans("ConfirmDeleteADonation");
|
$text = $langs->trans("ConfirmDeleteADonation");
|
||||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("DeleteADonation"), $text, "confirm_delete", '', '', 1);
|
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("DeleteADonation"), $text, "confirm_delete", '', '', 1);
|
||||||
}
|
}
|
||||||
@ -650,12 +645,10 @@ if (!empty($id) && $action != 'edit')
|
|||||||
|
|
||||||
$morehtmlref = '<div class="refidno">';
|
$morehtmlref = '<div class="refidno">';
|
||||||
// Project
|
// Project
|
||||||
if (!empty($conf->projet->enabled))
|
if (!empty($conf->projet->enabled)) {
|
||||||
{
|
|
||||||
$langs->load("projects");
|
$langs->load("projects");
|
||||||
$morehtmlref .= $langs->trans('Project').' ';
|
$morehtmlref .= $langs->trans('Project').' ';
|
||||||
if ($user->rights->don->creer)
|
if ($user->rights->don->creer) {
|
||||||
{
|
|
||||||
if ($action != 'classify') {
|
if ($action != 'classify') {
|
||||||
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
|
$morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> : ';
|
||||||
}
|
}
|
||||||
@ -749,8 +742,7 @@ if (!empty($id) && $action != 'edit')
|
|||||||
|
|
||||||
//print $sql;
|
//print $sql;
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
|
||||||
$num = $db->num_rows($resql);
|
$num = $db->num_rows($resql);
|
||||||
$i = 0; $total = 0;
|
$i = 0; $total = 0;
|
||||||
print '<table class="noborder paymenttable centpercent">';
|
print '<table class="noborder paymenttable centpercent">';
|
||||||
@ -761,8 +753,7 @@ if (!empty($id) && $action != 'edit')
|
|||||||
print '<td class="right">'.$langs->trans("Amount").'</td>';
|
print '<td class="right">'.$langs->trans("Amount").'</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
while ($i < $num)
|
while ($i < $num) {
|
||||||
{
|
|
||||||
$objp = $db->fetch_object($resql);
|
$objp = $db->fetch_object($resql);
|
||||||
|
|
||||||
print '<tr class="oddeven"><td>';
|
print '<tr class="oddeven"><td>';
|
||||||
@ -776,8 +767,7 @@ if (!empty($id) && $action != 'edit')
|
|||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($object->paid == 0)
|
if ($object->paid == 0) {
|
||||||
{
|
|
||||||
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("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";
|
print "<tr><td colspan=\"3\" class=\"right\">".$langs->trans("AmountExpected")." :</td><td class=\"right\">".price($object->amount)."</td></tr>\n";
|
||||||
|
|
||||||
@ -807,28 +797,23 @@ if (!empty($id) && $action != 'edit')
|
|||||||
print '<div class="tabsAction">';
|
print '<div class="tabsAction">';
|
||||||
|
|
||||||
// Re-open
|
// Re-open
|
||||||
if ($permissiontoadd && $object->statut == $object::STATUS_CANCELED)
|
if ($permissiontoadd && $object->statut == $object::STATUS_CANCELED) {
|
||||||
{
|
|
||||||
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_reopen&confirm=yes&token='.newToken().'">'.$langs->trans("ReOpen").'</a>';
|
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=confirm_reopen&confirm=yes&token='.newToken().'">'.$langs->trans("ReOpen").'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&rowid='.$object->id.'">'.$langs->trans('Modify').'</a></div>';
|
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&rowid='.$object->id.'">'.$langs->trans('Modify').'</a></div>';
|
||||||
|
|
||||||
if ($object->statut == $object::STATUS_DRAFT)
|
if ($object->statut == $object::STATUS_DRAFT) {
|
||||||
{
|
|
||||||
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>';
|
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>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($object->statut == $object::STATUS_DRAFT || $object->statut == $object::STATUS_VALIDATED) && $totalpaid == 0 && $object->paid == 0)
|
if (($object->statut == $object::STATUS_DRAFT || $object->statut == $object::STATUS_VALIDATED) && $totalpaid == 0 && $object->paid == 0) {
|
||||||
{
|
|
||||||
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>";
|
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>";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create payment
|
// Create payment
|
||||||
if ($object->statut == $object::STATUS_VALIDATED && $object->paid == 0 && $user->rights->don->creer)
|
if ($object->statut == $object::STATUS_VALIDATED && $object->paid == 0 && $user->rights->don->creer) {
|
||||||
{
|
if ($remaintopay == 0) {
|
||||||
if ($remaintopay == 0)
|
|
||||||
{
|
|
||||||
print '<div class="inline-block divButAction"><span class="butActionRefused classfortooltip" title="'.$langs->trans("DisabledBecauseRemainderToPayIsZero").'">'.$langs->trans('DoPayment').'</span></div>';
|
print '<div class="inline-block divButAction"><span class="butActionRefused classfortooltip" title="'.$langs->trans("DisabledBecauseRemainderToPayIsZero").'">'.$langs->trans('DoPayment').'</span></div>';
|
||||||
} else {
|
} else {
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/don/payment/payment.php?rowid='.$object->id.'&action=create">'.$langs->trans('DoPayment').'</a></div>';
|
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/don/payment/payment.php?rowid='.$object->id.'&action=create">'.$langs->trans('DoPayment').'</a></div>';
|
||||||
@ -836,16 +821,13 @@ if (!empty($id) && $action != 'edit')
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Classify 'paid'
|
// Classify 'paid'
|
||||||
if ($object->statut == $object::STATUS_VALIDATED && round($remaintopay) == 0 && $object->paid == 0 && $user->rights->don->creer)
|
if ($object->statut == $object::STATUS_VALIDATED && round($remaintopay) == 0 && $object->paid == 0 && $user->rights->don->creer) {
|
||||||
{
|
|
||||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=set_paid">'.$langs->trans("ClassifyPaid")."</a></div>";
|
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$object->id.'&action=set_paid">'.$langs->trans("ClassifyPaid")."</a></div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete
|
// Delete
|
||||||
if ($user->rights->don->supprimer)
|
if ($user->rights->don->supprimer) {
|
||||||
{
|
if ($object->statut == $object::STATUS_CANCELED || $object->statut == $object::STATUS_DRAFT) {
|
||||||
if ($object->statut == $object::STATUS_CANCELED || $object->statut == $object::STATUS_DRAFT)
|
|
||||||
{
|
|
||||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?rowid='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans("Delete")."</a></div>";
|
print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?rowid='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans("Delete")."</a></div>";
|
||||||
} else {
|
} else {
|
||||||
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans("Delete")."</a></div>";
|
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#">'.$langs->trans("Delete")."</a></div>";
|
||||||
@ -877,8 +859,7 @@ if (!empty($id) && $action != 'edit')
|
|||||||
// Show online payment link
|
// Show online payment link
|
||||||
$useonlinepayment = (!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled));
|
$useonlinepayment = (!empty($conf->paypal->enabled) || !empty($conf->stripe->enabled) || !empty($conf->paybox->enabled));
|
||||||
|
|
||||||
if ($useonlinepayment) //$object->statut != Facture::STATUS_DRAFT &&
|
if ($useonlinepayment) { //$object->statut != Facture::STATUS_DRAFT &&
|
||||||
{
|
|
||||||
print '<br><!-- Link to pay -->'."\n";
|
print '<br><!-- Link to pay -->'."\n";
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php';
|
||||||
print showOnlinePaymentUrl('donation', $object->ref).'<br>';
|
print showOnlinePaymentUrl('donation', $object->ref).'<br>';
|
||||||
|
|||||||
@ -32,7 +32,7 @@ class Donations extends DolibarrApi
|
|||||||
/**
|
/**
|
||||||
* @var array $FIELDS Mandatory fields, checked when create and update object
|
* @var array $FIELDS Mandatory fields, checked when create and update object
|
||||||
*/
|
*/
|
||||||
static $FIELDS = array(
|
public static $FIELDS = array(
|
||||||
'socid'
|
'socid'
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -109,18 +109,22 @@ class Donations extends DolibarrApi
|
|||||||
$socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids;
|
$socids = DolibarrApiAccess::$user->socid ? DolibarrApiAccess::$user->socid : $thirdparty_ids;
|
||||||
|
|
||||||
$sql = "SELECT t.rowid";
|
$sql = "SELECT t.rowid";
|
||||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids)) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
|
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids)) {
|
||||||
|
$sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
|
||||||
|
}
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."don as t";
|
$sql .= " FROM ".MAIN_DB_PREFIX."don as t";
|
||||||
|
|
||||||
$sql .= ' WHERE t.entity IN ('.getEntity('don').')';
|
$sql .= ' WHERE t.entity IN ('.getEntity('don').')';
|
||||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids)) $sql .= " AND t.fk_soc = sc.fk_soc";
|
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids)) {
|
||||||
if ($thirdparty_ids) $sql .= " AND t.fk_soc = ".$thirdparty_ids." ";
|
$sql .= " AND t.fk_soc = sc.fk_soc";
|
||||||
|
}
|
||||||
|
if ($thirdparty_ids) {
|
||||||
|
$sql .= " AND t.fk_soc = ".$thirdparty_ids." ";
|
||||||
|
}
|
||||||
|
|
||||||
// Add sql filters
|
// Add sql filters
|
||||||
if ($sqlfilters)
|
if ($sqlfilters) {
|
||||||
{
|
if (!DolibarrApi::_checkFilters($sqlfilters)) {
|
||||||
if (!DolibarrApi::_checkFilters($sqlfilters))
|
|
||||||
{
|
|
||||||
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
throw new RestException(503, 'Error when validating parameter sqlfilters '.$sqlfilters);
|
||||||
}
|
}
|
||||||
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
$regexstring = '\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||||
@ -129,8 +133,7 @@ class Donations extends DolibarrApi
|
|||||||
|
|
||||||
$sql .= $this->db->order($sortfield, $sortorder);
|
$sql .= $this->db->order($sortfield, $sortorder);
|
||||||
if ($limit) {
|
if ($limit) {
|
||||||
if ($page < 0)
|
if ($page < 0) {
|
||||||
{
|
|
||||||
$page = 0;
|
$page = 0;
|
||||||
}
|
}
|
||||||
$offset = $limit * $page;
|
$offset = $limit * $page;
|
||||||
@ -141,13 +144,11 @@ class Donations extends DolibarrApi
|
|||||||
dol_syslog("API Rest request");
|
dol_syslog("API Rest request");
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
|
|
||||||
if ($result)
|
if ($result) {
|
||||||
{
|
|
||||||
$num = $this->db->num_rows($result);
|
$num = $this->db->num_rows($result);
|
||||||
$min = min($num, ($limit <= 0 ? $num : $limit));
|
$min = min($num, ($limit <= 0 ? $num : $limit));
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $min)
|
while ($i < $min) {
|
||||||
{
|
|
||||||
$obj = $this->db->fetch_object($result);
|
$obj = $this->db->fetch_object($result);
|
||||||
$don_static = new Don($this->db);
|
$don_static = new Don($this->db);
|
||||||
if ($don_static->fetch($obj->rowid)) {
|
if ($don_static->fetch($obj->rowid)) {
|
||||||
@ -222,12 +223,13 @@ class Donations extends DolibarrApi
|
|||||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||||
}
|
}
|
||||||
foreach ($request_data as $field => $value) {
|
foreach ($request_data as $field => $value) {
|
||||||
if ($field == 'id') continue;
|
if ($field == 'id') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$this->don->$field = $value;
|
$this->don->$field = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->don->update(DolibarrApiAccess::$user) > 0)
|
if ($this->don->update(DolibarrApiAccess::$user) > 0) {
|
||||||
{
|
|
||||||
return $this->get($id);
|
return $this->get($id);
|
||||||
} else {
|
} else {
|
||||||
throw new RestException(500, $this->don->error);
|
throw new RestException(500, $this->don->error);
|
||||||
@ -356,8 +358,9 @@ class Donations extends DolibarrApi
|
|||||||
{
|
{
|
||||||
$don = array();
|
$don = array();
|
||||||
foreach (Orders::$FIELDS as $field) {
|
foreach (Orders::$FIELDS as $field) {
|
||||||
if (!isset($data[$field]))
|
if (!isset($data[$field])) {
|
||||||
throw new RestException(400, $field." field missing");
|
throw new RestException(400, $field." field missing");
|
||||||
|
}
|
||||||
$don[$field] = $data[$field];
|
$don[$field] = $data[$field];
|
||||||
}
|
}
|
||||||
return $don;
|
return $don;
|
||||||
|
|||||||
@ -171,8 +171,7 @@ class Don extends CommonObject
|
|||||||
public function LibStatut($status, $mode = 0)
|
public function LibStatut($status, $mode = 0)
|
||||||
{
|
{
|
||||||
// phpcs:enable
|
// phpcs:enable
|
||||||
if (empty($this->labelStatus) || empty($this->labelStatusShort))
|
if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
|
||||||
{
|
|
||||||
global $langs;
|
global $langs;
|
||||||
$langs->load("donations");
|
$langs->load("donations");
|
||||||
$this->labelStatus[-1] = $langs->transnoentitiesnoconv("Canceled");
|
$this->labelStatus[-1] = $langs->transnoentitiesnoconv("Canceled");
|
||||||
@ -186,8 +185,12 @@ class Don extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
$statusType = 'status'.$status;
|
$statusType = 'status'.$status;
|
||||||
if ($status == self::STATUS_CANCELED) $statusType = 'status9';
|
if ($status == self::STATUS_CANCELED) {
|
||||||
if ($status == self::STATUS_PAID) $statusType = 'status6';
|
$statusType = 'status9';
|
||||||
|
}
|
||||||
|
if ($status == self::STATUS_PAID) {
|
||||||
|
$statusType = 'status6';
|
||||||
|
}
|
||||||
|
|
||||||
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
|
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
|
||||||
}
|
}
|
||||||
@ -216,12 +219,10 @@ class Don extends CommonObject
|
|||||||
$sql .= " LIMIT 10";
|
$sql .= " LIMIT 10";
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
|
||||||
$num_socs = $this->db->num_rows($resql);
|
$num_socs = $this->db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num_socs)
|
while ($i < $num_socs) {
|
||||||
{
|
|
||||||
$i++;
|
$i++;
|
||||||
|
|
||||||
$row = $this->db->fetch_row($resql);
|
$row = $this->db->fetch_row($resql);
|
||||||
@ -269,35 +270,29 @@ class Don extends CommonObject
|
|||||||
$error_string = array();
|
$error_string = array();
|
||||||
$err = 0;
|
$err = 0;
|
||||||
|
|
||||||
if (dol_strlen(trim($this->societe)) == 0)
|
if (dol_strlen(trim($this->societe)) == 0) {
|
||||||
{
|
if ((dol_strlen(trim($this->lastname)) + dol_strlen(trim($this->firstname))) == 0) {
|
||||||
if ((dol_strlen(trim($this->lastname)) + dol_strlen(trim($this->firstname))) == 0)
|
|
||||||
{
|
|
||||||
$error_string[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Company').'/'.$langs->transnoentitiesnoconv('Firstname').'-'.$langs->transnoentitiesnoconv('Lastname'));
|
$error_string[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Company').'/'.$langs->transnoentitiesnoconv('Firstname').'-'.$langs->transnoentitiesnoconv('Lastname'));
|
||||||
$err++;
|
$err++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dol_strlen(trim($this->address)) == 0)
|
if (dol_strlen(trim($this->address)) == 0) {
|
||||||
{
|
|
||||||
$error_string[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Address'));
|
$error_string[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Address'));
|
||||||
$err++;
|
$err++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dol_strlen(trim($this->zip)) == 0)
|
if (dol_strlen(trim($this->zip)) == 0) {
|
||||||
{
|
|
||||||
$error_string[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Zip'));
|
$error_string[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Zip'));
|
||||||
$err++;
|
$err++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dol_strlen(trim($this->town)) == 0)
|
if (dol_strlen(trim($this->town)) == 0) {
|
||||||
{
|
|
||||||
$error_string[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Town'));
|
$error_string[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Town'));
|
||||||
$err++;
|
$err++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dol_strlen(trim($this->email)) == 0)
|
if (dol_strlen(trim($this->email)) == 0) {
|
||||||
{
|
|
||||||
$error_string[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('EMail'));
|
$error_string[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('EMail'));
|
||||||
$err++;
|
$err++;
|
||||||
}
|
}
|
||||||
@ -306,10 +301,8 @@ class Don extends CommonObject
|
|||||||
|
|
||||||
$map = range(0, 9);
|
$map = range(0, 9);
|
||||||
$len = dol_strlen($this->amount);
|
$len = dol_strlen($this->amount);
|
||||||
for ($i = 0; $i < $len; $i++)
|
for ($i = 0; $i < $len; $i++) {
|
||||||
{
|
if (!isset($map[substr($this->amount, $i, 1)])) {
|
||||||
if (!isset($map[substr($this->amount, $i, 1)]))
|
|
||||||
{
|
|
||||||
$error_string[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Amount'));
|
$error_string[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Amount'));
|
||||||
$err++;
|
$err++;
|
||||||
$amount_invalid = 1;
|
$amount_invalid = 1;
|
||||||
@ -317,23 +310,19 @@ class Don extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$amount_invalid)
|
if (!$amount_invalid) {
|
||||||
{
|
if ($this->amount == 0) {
|
||||||
if ($this->amount == 0)
|
|
||||||
{
|
|
||||||
$error_string[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Amount'));
|
$error_string[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Amount'));
|
||||||
$err++;
|
$err++;
|
||||||
} else {
|
} else {
|
||||||
if ($this->amount < $minimum && $minimum > 0)
|
if ($this->amount < $minimum && $minimum > 0) {
|
||||||
{
|
|
||||||
$error_string[] = $langs->trans('MinimumAmount', $langs->transnoentitiesnoconv('$minimum'));
|
$error_string[] = $langs->trans('MinimumAmount', $langs->transnoentitiesnoconv('$minimum'));
|
||||||
$err++;
|
$err++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($err)
|
if ($err) {
|
||||||
{
|
|
||||||
$this->errors = $error_string;
|
$this->errors = $error_string;
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
@ -415,16 +404,16 @@ class Don extends CommonObject
|
|||||||
$sql .= ")";
|
$sql .= ")";
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
|
||||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."don");
|
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."don");
|
||||||
$ret = $this->id;
|
$ret = $this->id;
|
||||||
|
|
||||||
if (!$notrigger)
|
if (!$notrigger) {
|
||||||
{
|
|
||||||
// Call trigger
|
// Call trigger
|
||||||
$result = $this->call_trigger('DON_CREATE', $user);
|
$result = $this->call_trigger('DON_CREATE', $user);
|
||||||
if ($result < 0) { $error++; }
|
if ($result < 0) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
// End call triggers
|
// End call triggers
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -441,14 +430,12 @@ class Don extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error && !empty($conf->global->MAIN_DISABLEDRAFTSTATUS))
|
if (!$error && !empty($conf->global->MAIN_DISABLEDRAFTSTATUS)) {
|
||||||
{
|
|
||||||
//$res = $this->setValid($user);
|
//$res = $this->setValid($user);
|
||||||
//if ($res < 0) $error++;
|
//if ($res < 0) $error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return $ret;
|
return $ret;
|
||||||
} else {
|
} else {
|
||||||
@ -503,28 +490,25 @@ class Don extends CommonObject
|
|||||||
|
|
||||||
dol_syslog(get_class($this)."::Update", LOG_DEBUG);
|
dol_syslog(get_class($this)."::Update", LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
if (!$notrigger) {
|
||||||
if (!$notrigger)
|
|
||||||
{
|
|
||||||
// Call trigger
|
// Call trigger
|
||||||
$result = $this->call_trigger('DON_MODIFY', $user);
|
$result = $this->call_trigger('DON_MODIFY', $user);
|
||||||
if ($result < 0) { $error++; }
|
if ($result < 0) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
// End call triggers
|
// End call triggers
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update extrafield
|
// Update extrafield
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
$result = $this->insertExtraFields();
|
$result = $this->insertExtraFields();
|
||||||
if ($result < 0)
|
if ($result < 0) {
|
||||||
{
|
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
$result = 1;
|
$result = 1;
|
||||||
} else {
|
} else {
|
||||||
@ -568,39 +552,33 @@ class Don extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Delete donation
|
// Delete donation
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."don_extrafields";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."don_extrafields";
|
||||||
$sql .= " WHERE fk_object=".$this->id;
|
$sql .= " WHERE fk_object=".$this->id;
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if (!$resql)
|
if (!$resql) {
|
||||||
{
|
|
||||||
$this->errors[] = $this->db->lasterror();
|
$this->errors[] = $this->db->lasterror();
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."don";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."don";
|
||||||
$sql .= " WHERE rowid=".$this->id;
|
$sql .= " WHERE rowid=".$this->id;
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if (!$resql)
|
if (!$resql) {
|
||||||
{
|
|
||||||
$this->errors[] = $this->db->lasterror();
|
$this->errors[] = $this->db->lasterror();
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
foreach ($this->errors as $errmsg)
|
foreach ($this->errors as $errmsg) {
|
||||||
{
|
|
||||||
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
|
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
|
||||||
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
|
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
|
||||||
}
|
}
|
||||||
@ -633,20 +611,16 @@ class Don extends CommonObject
|
|||||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON cp.id = d.fk_payment";
|
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON cp.id = d.fk_payment";
|
||||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.fk_country = c.rowid";
|
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.fk_country = c.rowid";
|
||||||
$sql .= " WHERE d.entity IN (".getEntity('donation').")";
|
$sql .= " WHERE d.entity IN (".getEntity('donation').")";
|
||||||
if (!empty($id))
|
if (!empty($id)) {
|
||||||
{
|
|
||||||
$sql .= " AND d.rowid=".$id;
|
$sql .= " AND d.rowid=".$id;
|
||||||
} elseif (!empty($ref))
|
} elseif (!empty($ref)) {
|
||||||
{
|
|
||||||
$sql .= " AND d.ref='".$this->db->escape($ref)."'";
|
$sql .= " AND d.ref='".$this->db->escape($ref)."'";
|
||||||
}
|
}
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
if ($this->db->num_rows($resql)) {
|
||||||
if ($this->db->num_rows($resql))
|
|
||||||
{
|
|
||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
$this->id = $obj->rowid;
|
$this->id = $obj->rowid;
|
||||||
@ -731,14 +705,14 @@ class Don extends CommonObject
|
|||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 1, fk_user_valid = ".$userid." WHERE rowid = ".$id." AND fk_statut = 0";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 1, fk_user_valid = ".$userid." WHERE rowid = ".$id." AND fk_statut = 0";
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
if ($this->db->affected_rows($resql)) {
|
||||||
if ($this->db->affected_rows($resql))
|
|
||||||
{
|
|
||||||
if (!$notrigger) {
|
if (!$notrigger) {
|
||||||
// Call trigger
|
// Call trigger
|
||||||
$result = $this->call_trigger('DON_VALIDATE', $user);
|
$result = $this->call_trigger('DON_VALIDATE', $user);
|
||||||
if ($result < 0) { $error++; }
|
if ($result < 0) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
// End call triggers
|
// End call triggers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -784,8 +758,7 @@ class Don extends CommonObject
|
|||||||
public function setPaid($id, $modepayment = 0)
|
public function setPaid($id, $modepayment = 0)
|
||||||
{
|
{
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 2";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 2";
|
||||||
if ($modepayment)
|
if ($modepayment) {
|
||||||
{
|
|
||||||
$sql .= ", fk_payment=".$modepayment;
|
$sql .= ", fk_payment=".$modepayment;
|
||||||
}
|
}
|
||||||
$sql .= " WHERE rowid = ".$id." AND fk_statut = 1";
|
$sql .= " WHERE rowid = ".$id." AND fk_statut = 1";
|
||||||
@ -874,8 +847,7 @@ class Don extends CommonObject
|
|||||||
$sql .= " AND entity = ".$conf->entity;
|
$sql .= " AND entity = ".$conf->entity;
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
|
||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
$result = $obj->total;
|
$result = $obj->total;
|
||||||
}
|
}
|
||||||
@ -902,10 +874,8 @@ class Don extends CommonObject
|
|||||||
$sql .= " AND d.entity IN (".getEntity('donation').")";
|
$sql .= " AND d.entity IN (".getEntity('donation').")";
|
||||||
|
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
while ($obj = $this->db->fetch_object($resql)) {
|
||||||
while ($obj = $this->db->fetch_object($resql))
|
|
||||||
{
|
|
||||||
$this->nb["donations"] = $obj->nb;
|
$this->nb["donations"] = $obj->nb;
|
||||||
}
|
}
|
||||||
$this->db->free($resql);
|
$this->db->free($resql);
|
||||||
@ -930,7 +900,9 @@ class Don extends CommonObject
|
|||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
|
if (!empty($conf->dol_no_mouse_hover)) {
|
||||||
|
$notooltip = 1; // Force disable tooltips
|
||||||
|
}
|
||||||
|
|
||||||
$result = '';
|
$result = '';
|
||||||
$label = img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("Donation").'</u>';
|
$label = img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("Donation").'</u>';
|
||||||
@ -941,20 +913,30 @@ class Don extends CommonObject
|
|||||||
$label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->id;
|
$label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->id;
|
||||||
$label .= '<br><b>'.$langs->trans('Date').':</b> '.dol_print_date($this->date, 'day');
|
$label .= '<br><b>'.$langs->trans('Date').':</b> '.dol_print_date($this->date, 'day');
|
||||||
}
|
}
|
||||||
if ($moretitle) $label .= ' - '.$moretitle;
|
if ($moretitle) {
|
||||||
|
$label .= ' - '.$moretitle;
|
||||||
|
}
|
||||||
|
|
||||||
$url = DOL_URL_ROOT.'/don/card.php?id='.$this->id;
|
$url = DOL_URL_ROOT.'/don/card.php?id='.$this->id;
|
||||||
|
|
||||||
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
|
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
|
||||||
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
|
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
|
||||||
if ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
|
$add_save_lastsearch_values = 1;
|
||||||
|
}
|
||||||
|
if ($add_save_lastsearch_values) {
|
||||||
|
$url .= '&save_lastsearch_values=1';
|
||||||
|
}
|
||||||
|
|
||||||
$linkstart = '<a href="'.$url.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
|
$linkstart = '<a href="'.$url.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
|
||||||
$linkend = '</a>';
|
$linkend = '</a>';
|
||||||
|
|
||||||
$result .= $linkstart;
|
$result .= $linkstart;
|
||||||
if ($withpicto) $result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
if ($withpicto) {
|
||||||
if ($withpicto != 2) $result .= $this->ref;
|
$result .= img_object(($notooltip ? '' : $label), $this->picto, ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
|
||||||
|
}
|
||||||
|
if ($withpicto != 2) {
|
||||||
|
$result .= $this->ref;
|
||||||
|
}
|
||||||
$result .= $linkend;
|
$result .= $linkend;
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
@ -976,20 +958,16 @@ class Don extends CommonObject
|
|||||||
dol_syslog(get_class($this).'::info', LOG_DEBUG);
|
dol_syslog(get_class($this).'::info', LOG_DEBUG);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
|
|
||||||
if ($result)
|
if ($result) {
|
||||||
{
|
if ($this->db->num_rows($result)) {
|
||||||
if ($this->db->num_rows($result))
|
|
||||||
{
|
|
||||||
$obj = $this->db->fetch_object($result);
|
$obj = $this->db->fetch_object($result);
|
||||||
$this->id = $obj->rowid;
|
$this->id = $obj->rowid;
|
||||||
if ($obj->fk_user_author)
|
if ($obj->fk_user_author) {
|
||||||
{
|
|
||||||
$cuser = new User($this->db);
|
$cuser = new User($this->db);
|
||||||
$cuser->fetch($obj->fk_user_author);
|
$cuser->fetch($obj->fk_user_author);
|
||||||
$this->user_creation = $cuser;
|
$this->user_creation = $cuser;
|
||||||
}
|
}
|
||||||
if ($obj->fk_user_valid)
|
if ($obj->fk_user_valid) {
|
||||||
{
|
|
||||||
$vuser = new User($this->db);
|
$vuser = new User($this->db);
|
||||||
$vuser->fetch($obj->fk_user_valid);
|
$vuser->fetch($obj->fk_user_valid);
|
||||||
$this->user_modification = $vuser;
|
$this->user_modification = $vuser;
|
||||||
@ -1045,8 +1023,7 @@ class Don extends CommonObject
|
|||||||
|
|
||||||
// If selected modele is a filename template (then $modele="modelname:filename")
|
// If selected modele is a filename template (then $modele="modelname:filename")
|
||||||
$tmp = explode(':', $modele, 2);
|
$tmp = explode(':', $modele, 2);
|
||||||
if (!empty($tmp[1]))
|
if (!empty($tmp[1])) {
|
||||||
{
|
|
||||||
$modele = $tmp[0];
|
$modele = $tmp[0];
|
||||||
$srctemplatepath = $tmp[1];
|
$srctemplatepath = $tmp[1];
|
||||||
}
|
}
|
||||||
@ -1054,28 +1031,28 @@ class Don extends CommonObject
|
|||||||
// Search template files
|
// Search template files
|
||||||
$file = ''; $classname = ''; $filefound = 0;
|
$file = ''; $classname = ''; $filefound = 0;
|
||||||
$dirmodels = array('/');
|
$dirmodels = array('/');
|
||||||
if (is_array($conf->modules_parts['models'])) $dirmodels = array_merge($dirmodels, $conf->modules_parts['models']);
|
if (is_array($conf->modules_parts['models'])) {
|
||||||
foreach ($dirmodels as $reldir)
|
$dirmodels = array_merge($dirmodels, $conf->modules_parts['models']);
|
||||||
{
|
}
|
||||||
foreach (array('html', 'doc', 'pdf') as $prefix)
|
foreach ($dirmodels as $reldir) {
|
||||||
{
|
foreach (array('html', 'doc', 'pdf') as $prefix) {
|
||||||
$file = $prefix."_".preg_replace('/^html_/', '', $modele).".modules.php";
|
$file = $prefix."_".preg_replace('/^html_/', '', $modele).".modules.php";
|
||||||
|
|
||||||
// On verifie l'emplacement du modele
|
// On verifie l'emplacement du modele
|
||||||
$file = dol_buildpath($reldir."core/modules/dons/".$file, 0);
|
$file = dol_buildpath($reldir."core/modules/dons/".$file, 0);
|
||||||
if (file_exists($file))
|
if (file_exists($file)) {
|
||||||
{
|
|
||||||
$filefound = 1;
|
$filefound = 1;
|
||||||
$classname = $prefix.'_'.$modele;
|
$classname = $prefix.'_'.$modele;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($filefound) break;
|
if ($filefound) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Charge le modele
|
// Charge le modele
|
||||||
if ($filefound)
|
if ($filefound) {
|
||||||
{
|
|
||||||
require_once $file;
|
require_once $file;
|
||||||
|
|
||||||
$object = $this;
|
$object = $this;
|
||||||
@ -1086,8 +1063,7 @@ class Don extends CommonObject
|
|||||||
// We save charset_output to restore it because write_file can change it if needed for
|
// We save charset_output to restore it because write_file can change it if needed for
|
||||||
// output format that does not support UTF8.
|
// output format that does not support UTF8.
|
||||||
$sav_charset_output = $outputlangs->charset_output;
|
$sav_charset_output = $outputlangs->charset_output;
|
||||||
if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0)
|
if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref) > 0) {
|
||||||
{
|
|
||||||
$outputlangs->charset_output = $sav_charset_output;
|
$outputlangs->charset_output = $sav_charset_output;
|
||||||
|
|
||||||
// we delete preview files
|
// we delete preview files
|
||||||
|
|||||||
@ -84,7 +84,9 @@ class DonationStats extends Stats
|
|||||||
|
|
||||||
//$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity;
|
//$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity;
|
||||||
$this->where .= " AND d.entity = ".$conf->entity;
|
$this->where .= " AND d.entity = ".$conf->entity;
|
||||||
if ($this->userid > 0) $this->where .= ' WHERE c.fk_user_author = '.$this->userid;
|
if ($this->userid > 0) {
|
||||||
|
$this->where .= ' WHERE c.fk_user_author = '.$this->userid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -120,25 +120,39 @@ class PaymentDonation extends CommonObject
|
|||||||
$now = dol_now();
|
$now = dol_now();
|
||||||
|
|
||||||
// Validate parameters
|
// Validate parameters
|
||||||
if (!$this->datepaid)
|
if (!$this->datepaid) {
|
||||||
{
|
|
||||||
$this->error = 'ErrorBadValueForParameterCreatePaymentDonation';
|
$this->error = 'ErrorBadValueForParameterCreatePaymentDonation';
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
if (isset($this->fk_donation)) $this->fk_donation = (int) $this->fk_donation;
|
if (isset($this->fk_donation)) {
|
||||||
if (isset($this->amount)) $this->amount = trim($this->amount);
|
$this->fk_donation = (int) $this->fk_donation;
|
||||||
if (isset($this->fk_typepayment)) $this->fk_typepayment = trim($this->fk_typepayment);
|
}
|
||||||
if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment);
|
if (isset($this->amount)) {
|
||||||
if (isset($this->note_public)) $this->note_public = trim($this->note_public);
|
$this->amount = trim($this->amount);
|
||||||
if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank;
|
}
|
||||||
if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat;
|
if (isset($this->fk_typepayment)) {
|
||||||
if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif;
|
$this->fk_typepayment = trim($this->fk_typepayment);
|
||||||
|
}
|
||||||
|
if (isset($this->num_payment)) {
|
||||||
|
$this->num_payment = trim($this->num_payment);
|
||||||
|
}
|
||||||
|
if (isset($this->note_public)) {
|
||||||
|
$this->note_public = trim($this->note_public);
|
||||||
|
}
|
||||||
|
if (isset($this->fk_bank)) {
|
||||||
|
$this->fk_bank = (int) $this->fk_bank;
|
||||||
|
}
|
||||||
|
if (isset($this->fk_user_creat)) {
|
||||||
|
$this->fk_user_creat = (int) $this->fk_user_creat;
|
||||||
|
}
|
||||||
|
if (isset($this->fk_user_modif)) {
|
||||||
|
$this->fk_user_modif = (int) $this->fk_user_modif;
|
||||||
|
}
|
||||||
|
|
||||||
$totalamount = 0;
|
$totalamount = 0;
|
||||||
foreach ($this->amounts as $key => $value) // How payment is dispatch
|
foreach ($this->amounts as $key => $value) { // How payment is dispatch
|
||||||
{
|
|
||||||
$newvalue = price2num($value, 'MT');
|
$newvalue = price2num($value, 'MT');
|
||||||
$this->amounts[$key] = $newvalue;
|
$this->amounts[$key] = $newvalue;
|
||||||
$totalamount += $newvalue;
|
$totalamount += $newvalue;
|
||||||
@ -146,13 +160,14 @@ class PaymentDonation extends CommonObject
|
|||||||
$totalamount = price2num($totalamount);
|
$totalamount = price2num($totalamount);
|
||||||
|
|
||||||
// Check parameters
|
// Check parameters
|
||||||
if ($totalamount == 0) return -1; // On accepte les montants negatifs pour les rejets de prelevement mais pas null
|
if ($totalamount == 0) {
|
||||||
|
return -1; // On accepte les montants negatifs pour les rejets de prelevement mais pas null
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
if ($totalamount != 0)
|
if ($totalamount != 0) {
|
||||||
{
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_donation (fk_donation, datec, datep, amount,";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_donation (fk_donation, datec, datep, amount,";
|
||||||
$sql .= " fk_typepayment, num_payment, note, fk_user_creat, fk_bank)";
|
$sql .= " fk_typepayment, num_payment, note, fk_user_creat, fk_bank)";
|
||||||
$sql .= " VALUES ($this->chid, '".$this->db->idate($now)."',";
|
$sql .= " VALUES ($this->chid, '".$this->db->idate($now)."',";
|
||||||
@ -163,8 +178,7 @@ class PaymentDonation extends CommonObject
|
|||||||
|
|
||||||
dol_syslog(get_class($this)."::create", LOG_DEBUG);
|
dol_syslog(get_class($this)."::create", LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
|
||||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_donation");
|
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_donation");
|
||||||
$this->ref = $this->id;
|
$this->ref = $this->id;
|
||||||
} else {
|
} else {
|
||||||
@ -172,16 +186,16 @@ class PaymentDonation extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error && !$notrigger)
|
if (!$error && !$notrigger) {
|
||||||
{
|
|
||||||
// Call triggers
|
// Call triggers
|
||||||
$result = $this->call_trigger('DONATION_PAYMENT_CREATE', $user);
|
$result = $this->call_trigger('DONATION_PAYMENT_CREATE', $user);
|
||||||
if ($result < 0) { $error++; }
|
if ($result < 0) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
// End call triggers
|
// End call triggers
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($totalamount != 0 && !$error)
|
if ($totalamount != 0 && !$error) {
|
||||||
{
|
|
||||||
$this->amount = $totalamount;
|
$this->amount = $totalamount;
|
||||||
$this->total = $totalamount; // deprecated
|
$this->total = $totalamount; // deprecated
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
@ -224,10 +238,8 @@ class PaymentDonation extends CommonObject
|
|||||||
|
|
||||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
if ($this->db->num_rows($resql)) {
|
||||||
if ($this->db->num_rows($resql))
|
|
||||||
{
|
|
||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
$this->id = $obj->rowid;
|
$this->id = $obj->rowid;
|
||||||
@ -275,14 +287,30 @@ class PaymentDonation extends CommonObject
|
|||||||
|
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
|
|
||||||
if (isset($this->fk_donation)) $this->fk_donation = (int) $this->fk_donation;
|
if (isset($this->fk_donation)) {
|
||||||
if (isset($this->amount)) $this->amount = trim($this->amount);
|
$this->fk_donation = (int) $this->fk_donation;
|
||||||
if (isset($this->fk_typepayment)) $this->fk_typepayment = trim($this->fk_typepayment);
|
}
|
||||||
if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment);
|
if (isset($this->amount)) {
|
||||||
if (isset($this->note_public)) $this->note_public = trim($this->note_public);
|
$this->amount = trim($this->amount);
|
||||||
if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank;
|
}
|
||||||
if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat;
|
if (isset($this->fk_typepayment)) {
|
||||||
if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif;
|
$this->fk_typepayment = trim($this->fk_typepayment);
|
||||||
|
}
|
||||||
|
if (isset($this->num_payment)) {
|
||||||
|
$this->num_payment = trim($this->num_payment);
|
||||||
|
}
|
||||||
|
if (isset($this->note_public)) {
|
||||||
|
$this->note_public = trim($this->note_public);
|
||||||
|
}
|
||||||
|
if (isset($this->fk_bank)) {
|
||||||
|
$this->fk_bank = (int) $this->fk_bank;
|
||||||
|
}
|
||||||
|
if (isset($this->fk_user_creat)) {
|
||||||
|
$this->fk_user_creat = (int) $this->fk_user_creat;
|
||||||
|
}
|
||||||
|
if (isset($this->fk_user_modif)) {
|
||||||
|
$this->fk_user_modif = (int) $this->fk_user_modif;
|
||||||
|
}
|
||||||
|
|
||||||
// Check parameters
|
// Check parameters
|
||||||
// Put here code to add control on parameters values
|
// Put here code to add control on parameters values
|
||||||
@ -311,25 +339,22 @@ class PaymentDonation extends CommonObject
|
|||||||
$this->errors[] = "Error ".$this->db->lasterror();
|
$this->errors[] = "Error ".$this->db->lasterror();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
if (!$notrigger) {
|
||||||
if (!$notrigger)
|
if (!$error && !$notrigger) {
|
||||||
{
|
|
||||||
if (!$error && !$notrigger)
|
|
||||||
{
|
|
||||||
// Call triggers
|
// Call triggers
|
||||||
$result = $this->call_trigger('DONATION_PAYMENT_MODIFY', $user);
|
$result = $this->call_trigger('DONATION_PAYMENT_MODIFY', $user);
|
||||||
if ($result < 0) { $error++; }
|
if ($result < 0) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
// End call triggers
|
// End call triggers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Commit or rollback
|
// Commit or rollback
|
||||||
if ($error)
|
if ($error) {
|
||||||
{
|
foreach ($this->errors as $errmsg) {
|
||||||
foreach ($this->errors as $errmsg)
|
|
||||||
{
|
|
||||||
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
|
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
|
||||||
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
|
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
|
||||||
}
|
}
|
||||||
@ -356,18 +381,18 @@ class PaymentDonation extends CommonObject
|
|||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url";
|
||||||
$sql .= " WHERE type='payment_donation' AND url_id=".(int) $this->id;
|
$sql .= " WHERE type='payment_donation' AND url_id=".(int) $this->id;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); }
|
if (!$resql) {
|
||||||
|
$error++; $this->errors[] = "Error ".$this->db->lasterror();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_donation";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_donation";
|
||||||
$sql .= " WHERE rowid=".$this->id;
|
$sql .= " WHERE rowid=".$this->id;
|
||||||
|
|
||||||
@ -379,25 +404,22 @@ class PaymentDonation extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
if (!$notrigger) {
|
||||||
if (!$notrigger)
|
if (!$error && !$notrigger) {
|
||||||
{
|
|
||||||
if (!$error && !$notrigger)
|
|
||||||
{
|
|
||||||
// Call triggers
|
// Call triggers
|
||||||
$result = $this->call_trigger('DONATION_PAYMENT_DELETE', $user);
|
$result = $this->call_trigger('DONATION_PAYMENT_DELETE', $user);
|
||||||
if ($result < 0) { $error++; }
|
if ($result < 0) {
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
// End call triggers
|
// End call triggers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Commit or rollback
|
// Commit or rollback
|
||||||
if ($error)
|
if ($error) {
|
||||||
{
|
foreach ($this->errors as $errmsg) {
|
||||||
foreach ($this->errors as $errmsg)
|
|
||||||
{
|
|
||||||
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
|
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
|
||||||
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
|
$this->error .= ($this->error ? ', '.$errmsg : $errmsg);
|
||||||
}
|
}
|
||||||
@ -439,21 +461,18 @@ class PaymentDonation extends CommonObject
|
|||||||
$result = $object->create($user);
|
$result = $object->create($user);
|
||||||
|
|
||||||
// Other options
|
// Other options
|
||||||
if ($result < 0)
|
if ($result < 0) {
|
||||||
{
|
|
||||||
$this->error = $object->error;
|
$this->error = $object->error;
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($object->context['createfromclone']);
|
unset($object->context['createfromclone']);
|
||||||
|
|
||||||
// End
|
// End
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return $object->id;
|
return $object->id;
|
||||||
} else {
|
} else {
|
||||||
@ -534,15 +553,16 @@ class PaymentDonation extends CommonObject
|
|||||||
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
if (!empty($conf->banque->enabled))
|
if (!empty($conf->banque->enabled)) {
|
||||||
{
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||||
|
|
||||||
$acc = new Account($this->db);
|
$acc = new Account($this->db);
|
||||||
$acc->fetch($accountid);
|
$acc->fetch($accountid);
|
||||||
|
|
||||||
$total = $this->total;
|
$total = $this->total;
|
||||||
if ($mode == 'payment_donation') $amount = $total;
|
if ($mode == 'payment_donation') {
|
||||||
|
$amount = $total;
|
||||||
|
}
|
||||||
|
|
||||||
// Insert payment into llx_bank
|
// Insert payment into llx_bank
|
||||||
$bank_line_id = $acc->addline(
|
$bank_line_id = $acc->addline(
|
||||||
@ -559,23 +579,21 @@ class PaymentDonation extends CommonObject
|
|||||||
|
|
||||||
// Update fk_bank in llx_paiement.
|
// Update fk_bank in llx_paiement.
|
||||||
// On connait ainsi le paiement qui a genere l'ecriture bancaire
|
// On connait ainsi le paiement qui a genere l'ecriture bancaire
|
||||||
if ($bank_line_id > 0)
|
if ($bank_line_id > 0) {
|
||||||
{
|
|
||||||
$result = $this->update_fk_bank($bank_line_id);
|
$result = $this->update_fk_bank($bank_line_id);
|
||||||
if ($result <= 0)
|
if ($result <= 0) {
|
||||||
{
|
|
||||||
$error++;
|
$error++;
|
||||||
dol_print_error($this->db);
|
dol_print_error($this->db);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add link 'payment', 'payment_supplier', 'payment_donation' in bank_url between payment and bank transaction
|
// Add link 'payment', 'payment_supplier', 'payment_donation' in bank_url between payment and bank transaction
|
||||||
$url = '';
|
$url = '';
|
||||||
if ($mode == 'payment_donation') $url = DOL_URL_ROOT.'/don/payment/card.php?rowid=';
|
if ($mode == 'payment_donation') {
|
||||||
if ($url)
|
$url = DOL_URL_ROOT.'/don/payment/card.php?rowid=';
|
||||||
{
|
}
|
||||||
|
if ($url) {
|
||||||
$result = $acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode);
|
$result = $acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode);
|
||||||
if ($result <= 0)
|
if ($result <= 0) {
|
||||||
{
|
|
||||||
$error++;
|
$error++;
|
||||||
dol_print_error($this->db);
|
dol_print_error($this->db);
|
||||||
}
|
}
|
||||||
@ -586,8 +604,7 @@ class PaymentDonation extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return -1;
|
return -1;
|
||||||
@ -609,8 +626,7 @@ class PaymentDonation extends CommonObject
|
|||||||
|
|
||||||
dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG);
|
dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG);
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
if ($result)
|
if ($result) {
|
||||||
{
|
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
$this->error = $this->db->error();
|
$this->error = $this->db->error();
|
||||||
@ -635,14 +651,19 @@ class PaymentDonation extends CommonObject
|
|||||||
$label .= '<br>';
|
$label .= '<br>';
|
||||||
$label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
|
$label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
|
||||||
|
|
||||||
if (!empty($this->id))
|
if (!empty($this->id)) {
|
||||||
{
|
|
||||||
$link = '<a href="'.DOL_URL_ROOT.'/don/payment/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
|
$link = '<a href="'.DOL_URL_ROOT.'/don/payment/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
|
||||||
$linkend = '</a>';
|
$linkend = '</a>';
|
||||||
|
|
||||||
if ($withpicto) $result .= ($link.img_object($label, 'payment', 'class="classfortooltip"').$linkend.' ');
|
if ($withpicto) {
|
||||||
if ($withpicto && $withpicto != 2) $result .= ' ';
|
$result .= ($link.img_object($label, 'payment', 'class="classfortooltip"').$linkend.' ');
|
||||||
if ($withpicto != 2) $result .= $link.($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref).$linkend;
|
}
|
||||||
|
if ($withpicto && $withpicto != 2) {
|
||||||
|
$result .= ' ';
|
||||||
|
}
|
||||||
|
if ($withpicto != 2) {
|
||||||
|
$result .= $link.($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref).$linkend;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
|||||||
@ -34,8 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
|
||||||
if (!empty($conf->projet->enabled))
|
if (!empty($conf->projet->enabled)) {
|
||||||
{
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||||
}
|
}
|
||||||
@ -50,7 +49,9 @@ $confirm = GETPOST('confirm', 'alpha');
|
|||||||
$projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0);
|
$projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0);
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
if ($user->socid) $socid = $user->socid;
|
if ($user->socid) {
|
||||||
|
$socid = $user->socid;
|
||||||
|
}
|
||||||
$result = restrictedArea($user, 'don', $id, '');
|
$result = restrictedArea($user, 'don', $id, '');
|
||||||
|
|
||||||
|
|
||||||
@ -59,12 +60,18 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
|
|||||||
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
||||||
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
||||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
if (empty($page) || $page == -1) {
|
||||||
|
$page = 0;
|
||||||
|
} // If $page is not defined, or '' or -1
|
||||||
$offset = $limit * $page;
|
$offset = $limit * $page;
|
||||||
$pageprev = $page - 1;
|
$pageprev = $page - 1;
|
||||||
$pagenext = $page + 1;
|
$pagenext = $page + 1;
|
||||||
if (!$sortorder) $sortorder = "ASC";
|
if (!$sortorder) {
|
||||||
if (!$sortfield) $sortfield = "name";
|
$sortorder = "ASC";
|
||||||
|
}
|
||||||
|
if (!$sortfield) {
|
||||||
|
$sortfield = "name";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$object = new Don($db);
|
$object = new Don($db);
|
||||||
@ -80,8 +87,7 @@ $modulepart = 'don';
|
|||||||
|
|
||||||
include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
|
include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
|
||||||
|
|
||||||
if ($action == 'classin' && $user->rights->don->creer)
|
if ($action == 'classin' && $user->rights->don->creer) {
|
||||||
{
|
|
||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
$object->setProject($projectid);
|
$object->setProject($projectid);
|
||||||
}
|
}
|
||||||
@ -91,15 +97,16 @@ if ($action == 'classin' && $user->rights->don->creer)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
|
if (!empty($conf->projet->enabled)) {
|
||||||
|
$formproject = new FormProjets($db);
|
||||||
|
}
|
||||||
|
|
||||||
$title = $langs->trans('Donation')." - ".$langs->trans('Documents');
|
$title = $langs->trans('Donation')." - ".$langs->trans('Documents');
|
||||||
$helpurl = "";
|
$helpurl = "";
|
||||||
llxHeader('', $title, $helpurl);
|
llxHeader('', $title, $helpurl);
|
||||||
|
|
||||||
|
|
||||||
if ($object->id)
|
if ($object->id) {
|
||||||
{
|
|
||||||
$object->fetch_thirdparty();
|
$object->fetch_thirdparty();
|
||||||
|
|
||||||
$head = donation_prepare_head($object);
|
$head = donation_prepare_head($object);
|
||||||
@ -110,8 +117,7 @@ if ($object->id)
|
|||||||
// Build file list
|
// Build file list
|
||||||
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
|
$filearray = dol_dir_list($upload_dir, "files", 0, '', '(\.meta|_preview.*\.png)$', $sortfield, (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC), 1);
|
||||||
$totalsize = 0;
|
$totalsize = 0;
|
||||||
foreach ($filearray as $key => $file)
|
foreach ($filearray as $key => $file) {
|
||||||
{
|
|
||||||
$totalsize += $file['size'];
|
$totalsize += $file['size'];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,12 +125,10 @@ if ($object->id)
|
|||||||
|
|
||||||
$morehtmlref = '<div class="refidno">';
|
$morehtmlref = '<div class="refidno">';
|
||||||
// Project
|
// Project
|
||||||
if (!empty($conf->projet->enabled))
|
if (!empty($conf->projet->enabled)) {
|
||||||
{
|
|
||||||
$langs->load("projects");
|
$langs->load("projects");
|
||||||
$morehtmlref .= $langs->trans('Project').' ';
|
$morehtmlref .= $langs->trans('Project').' ';
|
||||||
if ($user->rights->don->creer)
|
if ($user->rights->don->creer) {
|
||||||
{
|
|
||||||
if ($action != 'classify') {
|
if ($action != 'classify') {
|
||||||
// $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
|
// $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -66,12 +66,10 @@ $sql .= " GROUP BY d.fk_statut";
|
|||||||
$sql .= " ORDER BY d.fk_statut";
|
$sql .= " ORDER BY d.fk_statut";
|
||||||
|
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
if ($result)
|
if ($result) {
|
||||||
{
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$num = $db->num_rows($result);
|
$num = $db->num_rows($result);
|
||||||
while ($i < $num)
|
while ($i < $num) {
|
||||||
{
|
|
||||||
$objp = $db->fetch_object($result);
|
$objp = $db->fetch_object($result);
|
||||||
|
|
||||||
$somme[$objp->fk_statut] = $objp->somme;
|
$somme[$objp->fk_statut] = $objp->somme;
|
||||||
@ -90,25 +88,25 @@ print load_fiche_titre($langs->trans("DonationsArea"), '', 'object_donation');
|
|||||||
|
|
||||||
print '<div class="fichecenter"><div class="fichethirdleft">';
|
print '<div class="fichecenter"><div class="fichethirdleft">';
|
||||||
|
|
||||||
if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
|
if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) { // This is useless due to the global search combo
|
||||||
{
|
if (!empty($conf->don->enabled) && $user->rights->don->lire) {
|
||||||
if (!empty($conf->don->enabled) && $user->rights->don->lire)
|
|
||||||
{
|
|
||||||
$listofsearchfields['search_donation'] = array('text'=>'Donation');
|
$listofsearchfields['search_donation'] = array('text'=>'Donation');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($listofsearchfields))
|
if (count($listofsearchfields)) {
|
||||||
{
|
|
||||||
print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
|
print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
|
||||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
print '<table class="noborder nohover centpercent">';
|
print '<table class="noborder nohover centpercent">';
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($listofsearchfields as $key => $value)
|
foreach ($listofsearchfields as $key => $value) {
|
||||||
{
|
if ($i == 0) {
|
||||||
if ($i == 0) print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
|
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
|
||||||
|
}
|
||||||
print '<tr '.$bc[false].'>';
|
print '<tr '.$bc[false].'>';
|
||||||
print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label></td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'"></td>';
|
print '<td class="nowrap"><label for="'.$key.'">'.$langs->trans($value["text"]).'</label></td><td><input type="text" class="flat inputsearch" name="'.$key.'" id="'.$key.'"></td>';
|
||||||
if ($i == 0) print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
|
if ($i == 0) {
|
||||||
|
print '<td rowspan="'.count($listofsearchfields).'"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td>';
|
||||||
|
}
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
@ -129,17 +127,23 @@ print '<th colspan="4">'.$langs->trans("Statistics").'</th>';
|
|||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
$listofstatus = array(0, 1, -1, 2);
|
$listofstatus = array(0, 1, -1, 2);
|
||||||
foreach ($listofstatus as $status)
|
foreach ($listofstatus as $status) {
|
||||||
{
|
|
||||||
$dataseries[] = array($donstatic->LibStatut($status, 1), (isset($nb[$status]) ? (int) $nb[$status] : 0));
|
$dataseries[] = array($donstatic->LibStatut($status, 1), (isset($nb[$status]) ? (int) $nb[$status] : 0));
|
||||||
if ($status == Don::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0;
|
if ($status == Don::STATUS_DRAFT) {
|
||||||
if ($status == Don::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus1;
|
$colorseries[$status] = '-'.$badgeStatus0;
|
||||||
if ($status == Don::STATUS_CANCELED) $colorseries[$status] = $badgeStatus9;
|
}
|
||||||
if ($status == Don::STATUS_PAID) $colorseries[$status] = $badgeStatus6;
|
if ($status == Don::STATUS_VALIDATED) {
|
||||||
|
$colorseries[$status] = $badgeStatus1;
|
||||||
|
}
|
||||||
|
if ($status == Don::STATUS_CANCELED) {
|
||||||
|
$colorseries[$status] = $badgeStatus9;
|
||||||
|
}
|
||||||
|
if ($status == Don::STATUS_PAID) {
|
||||||
|
$colorseries[$status] = $badgeStatus6;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($conf->use_javascript_ajax)
|
if ($conf->use_javascript_ajax) {
|
||||||
{
|
|
||||||
print '<tr><td class="center" colspan="4">';
|
print '<tr><td class="center" colspan="4">';
|
||||||
|
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
|
||||||
@ -165,8 +169,7 @@ print '</tr>';
|
|||||||
|
|
||||||
$total = 0;
|
$total = 0;
|
||||||
$totalnb = 0;
|
$totalnb = 0;
|
||||||
foreach ($listofstatus as $status)
|
foreach ($listofstatus as $status) {
|
||||||
{
|
|
||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
print '<td><a href="list.php?search_status='.$status.'">'.$donstatic->LibStatut($status, 4).'</a></td>';
|
print '<td><a href="list.php?search_status='.$status.'">'.$donstatic->LibStatut($status, 4).'</a></td>';
|
||||||
print '<td class="right">'.(!empty($nb[$status]) ? $nb[$status] : ' ').'</td>';
|
print '<td class="right">'.(!empty($nb[$status]) ? $nb[$status] : ' ').'</td>';
|
||||||
@ -203,18 +206,15 @@ $sql .= " ORDER BY c.tms DESC";
|
|||||||
$sql .= $db->plimit($max, 0);
|
$sql .= $db->plimit($max, 0);
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
|
||||||
print '<table class="noborder centpercent">';
|
print '<table class="noborder centpercent">';
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
print '<th colspan="5">'.$langs->trans("LastModifiedDonations", $max).'</th></tr>';
|
print '<th colspan="5">'.$langs->trans("LastModifiedDonations", $max).'</th></tr>';
|
||||||
|
|
||||||
$num = $db->num_rows($resql);
|
$num = $db->num_rows($resql);
|
||||||
if ($num)
|
if ($num) {
|
||||||
{
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($i < $num)
|
while ($i < $num) {
|
||||||
{
|
|
||||||
$obj = $db->fetch_object($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
|
|
||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
@ -246,7 +246,9 @@ if ($resql)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
print "</table><br>";
|
print "</table><br>";
|
||||||
} else dol_print_error($db);
|
} else {
|
||||||
|
dol_print_error($db);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
print '</div></div></div>';
|
print '</div></div></div>';
|
||||||
|
|||||||
@ -25,8 +25,7 @@ require '../main.inc.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
|
||||||
if (!empty($conf->projet->enabled))
|
if (!empty($conf->projet->enabled)) {
|
||||||
{
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||||
}
|
}
|
||||||
@ -39,7 +38,9 @@ $action = GETPOST('action', 'aZ09');
|
|||||||
$projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0);
|
$projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0);
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
if ($user->socid) $socid = $user->socid;
|
if ($user->socid) {
|
||||||
|
$socid = $user->socid;
|
||||||
|
}
|
||||||
$result = restrictedArea($user, 'don', $id, '');
|
$result = restrictedArea($user, 'don', $id, '');
|
||||||
|
|
||||||
$object = new Don($db);
|
$object = new Don($db);
|
||||||
@ -47,8 +48,7 @@ $object->fetch($id);
|
|||||||
/*
|
/*
|
||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
if ($action == 'classin' && $user->rights->don->creer)
|
if ($action == 'classin' && $user->rights->don->creer) {
|
||||||
{
|
|
||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
$object->setProject($projectid);
|
$object->setProject($projectid);
|
||||||
}
|
}
|
||||||
@ -61,7 +61,9 @@ $helpurl = "";
|
|||||||
llxHeader('', $title, $helpurl);
|
llxHeader('', $title, $helpurl);
|
||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
|
if (!empty($conf->projet->enabled)) {
|
||||||
|
$formproject = new FormProjets($db);
|
||||||
|
}
|
||||||
|
|
||||||
$object->info($id);
|
$object->info($id);
|
||||||
|
|
||||||
@ -73,12 +75,10 @@ $linkback = '<a href="'.DOL_URL_ROOT.'/don/list.php'.(!empty($socid) ? '?socid='
|
|||||||
|
|
||||||
$morehtmlref = '<div class="refidno">';
|
$morehtmlref = '<div class="refidno">';
|
||||||
// Project
|
// Project
|
||||||
if (!empty($conf->projet->enabled))
|
if (!empty($conf->projet->enabled)) {
|
||||||
{
|
|
||||||
$langs->load("projects");
|
$langs->load("projects");
|
||||||
$morehtmlref .= $langs->trans('Project').' ';
|
$morehtmlref .= $langs->trans('Project').' ';
|
||||||
if ($user->rights->don->creer)
|
if ($user->rights->don->creer) {
|
||||||
{
|
|
||||||
if ($action != 'classify') {
|
if ($action != 'classify') {
|
||||||
// $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
|
// $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,7 +27,9 @@
|
|||||||
|
|
||||||
require '../main.inc.php';
|
require '../main.inc.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
|
||||||
if (!empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
if (!empty($conf->projet->enabled)) {
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||||
|
}
|
||||||
|
|
||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array("companies", "donations"));
|
$langs->loadLangs(array("companies", "donations"));
|
||||||
@ -38,12 +40,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
|
|||||||
$sortfield = GETPOST("sortfield", 'alpha');
|
$sortfield = GETPOST("sortfield", 'alpha');
|
||||||
$sortorder = GETPOST("sortorder", 'alpha');
|
$sortorder = GETPOST("sortorder", 'alpha');
|
||||||
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
|
||||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
if (empty($page) || $page == -1) {
|
||||||
|
$page = 0;
|
||||||
|
} // If $page is not defined, or '' or -1
|
||||||
$offset = $limit * $page;
|
$offset = $limit * $page;
|
||||||
$pageprev = $page - 1;
|
$pageprev = $page - 1;
|
||||||
$pagenext = $page + 1;
|
$pagenext = $page + 1;
|
||||||
if (!$sortorder) $sortorder = "DESC";
|
if (!$sortorder) {
|
||||||
if (!$sortfield) $sortfield = "d.datedon";
|
$sortorder = "DESC";
|
||||||
|
}
|
||||||
|
if (!$sortfield) {
|
||||||
|
$sortfield = "d.datedon";
|
||||||
|
}
|
||||||
|
|
||||||
$search_status = (GETPOST("search_status", 'intcomma') != '') ? GETPOST("search_status", 'intcomma') : "-4";
|
$search_status = (GETPOST("search_status", 'intcomma') != '') ? GETPOST("search_status", 'intcomma') : "-4";
|
||||||
$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
|
$search_all = trim((GETPOST('search_all', 'alphanohtml') != '') ?GETPOST('search_all', 'alphanohtml') : GETPOST('sall', 'alphanohtml'));
|
||||||
@ -53,10 +61,11 @@ $search_name = GETPOST('search_name', 'alpha');
|
|||||||
$search_amount = GETPOST('search_amount', 'alpha');
|
$search_amount = GETPOST('search_amount', 'alpha');
|
||||||
$optioncss = GETPOST('optioncss', 'alpha');
|
$optioncss = GETPOST('optioncss', 'alpha');
|
||||||
|
|
||||||
if (!$user->rights->don->lire) accessforbidden();
|
if (!$user->rights->don->lire) {
|
||||||
|
accessforbidden();
|
||||||
|
}
|
||||||
|
|
||||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers
|
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers
|
||||||
{
|
|
||||||
$search_all = "";
|
$search_all = "";
|
||||||
$search_ref = "";
|
$search_ref = "";
|
||||||
$search_company = "";
|
$search_company = "";
|
||||||
@ -84,7 +93,9 @@ $fieldstosearchall = array(
|
|||||||
|
|
||||||
$donationstatic = new Don($db);
|
$donationstatic = new Don($db);
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
if (!empty($conf->projet->enabled)) $projectstatic = new Project($db);
|
if (!empty($conf->projet->enabled)) {
|
||||||
|
$projectstatic = new Project($db);
|
||||||
|
}
|
||||||
|
|
||||||
llxHeader('', $langs->trans("Donations"), 'EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones');
|
llxHeader('', $langs->trans("Donations"), 'EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones');
|
||||||
|
|
||||||
@ -94,37 +105,32 @@ $sql .= " d.amount, d.fk_statut as status,";
|
|||||||
$sql .= " p.rowid as pid, p.ref, p.title, p.public";
|
$sql .= " p.rowid as pid, p.ref, p.title, p.public";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."don as d LEFT JOIN ".MAIN_DB_PREFIX."projet AS p";
|
$sql .= " FROM ".MAIN_DB_PREFIX."don as d LEFT JOIN ".MAIN_DB_PREFIX."projet AS p";
|
||||||
$sql .= " ON p.rowid = d.fk_projet WHERE d.entity IN (".getEntity('donation').")";
|
$sql .= " ON p.rowid = d.fk_projet WHERE d.entity IN (".getEntity('donation').")";
|
||||||
if ($search_status != '' && $search_status != '-4')
|
if ($search_status != '' && $search_status != '-4') {
|
||||||
{
|
|
||||||
$sql .= " AND d.fk_statut IN (".$db->sanitize($db->escape($search_status)).")";
|
$sql .= " AND d.fk_statut IN (".$db->sanitize($db->escape($search_status)).")";
|
||||||
}
|
}
|
||||||
if (trim($search_ref) != '')
|
if (trim($search_ref) != '') {
|
||||||
{
|
|
||||||
$sql .= natural_search('d.ref', $search_ref);
|
$sql .= natural_search('d.ref', $search_ref);
|
||||||
}
|
}
|
||||||
if (trim($search_all) != '')
|
if (trim($search_all) != '') {
|
||||||
{
|
|
||||||
$sql .= natural_search(array_keys($fieldstosearchall), $search_all);
|
$sql .= natural_search(array_keys($fieldstosearchall), $search_all);
|
||||||
}
|
}
|
||||||
if (trim($search_company) != '')
|
if (trim($search_company) != '') {
|
||||||
{
|
|
||||||
$sql .= natural_search('d.societe', $search_company);
|
$sql .= natural_search('d.societe', $search_company);
|
||||||
}
|
}
|
||||||
if (trim($search_name) != '')
|
if (trim($search_name) != '') {
|
||||||
{
|
|
||||||
$sql .= natural_search(array('d.lastname', 'd.firstname'), $search_name);
|
$sql .= natural_search(array('d.lastname', 'd.firstname'), $search_name);
|
||||||
}
|
}
|
||||||
if ($search_amount) $sql .= natural_search('d.amount', $search_amount, 1);
|
if ($search_amount) {
|
||||||
|
$sql .= natural_search('d.amount', $search_amount, 1);
|
||||||
|
}
|
||||||
|
|
||||||
$sql .= $db->order($sortfield, $sortorder);
|
$sql .= $db->order($sortfield, $sortorder);
|
||||||
|
|
||||||
$nbtotalofrecords = '';
|
$nbtotalofrecords = '';
|
||||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
|
||||||
{
|
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
$nbtotalofrecords = $db->num_rows($result);
|
$nbtotalofrecords = $db->num_rows($result);
|
||||||
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
|
if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
|
||||||
{
|
|
||||||
$page = 0;
|
$page = 0;
|
||||||
$offset = 0;
|
$offset = 0;
|
||||||
}
|
}
|
||||||
@ -133,29 +139,45 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
|||||||
$sql .= $db->plimit($limit + 1, $offset);
|
$sql .= $db->plimit($limit + 1, $offset);
|
||||||
|
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
|
||||||
$num = $db->num_rows($resql);
|
$num = $db->num_rows($resql);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
$param = '';
|
$param = '';
|
||||||
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
|
if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
|
||||||
if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
|
$param .= '&contextpage='.urlencode($contextpage);
|
||||||
if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
|
}
|
||||||
if ($search_status && $search_status != -1) $param .= '&search_status='.urlencode($search_status);
|
if ($limit > 0 && $limit != $conf->liste_limit) {
|
||||||
if ($search_ref) $param .= '&search_ref='.urlencode($search_ref);
|
$param .= '&limit='.urlencode($limit);
|
||||||
if ($search_company) $param .= '&search_company='.urlencode($search_company);
|
}
|
||||||
if ($search_name) $param .= '&search_name='.urlencode($search_name);
|
if ($optioncss != '') {
|
||||||
if ($search_amount) $param .= '&search_amount='.urlencode($search_amount);
|
$param .= '&optioncss='.urlencode($optioncss);
|
||||||
|
}
|
||||||
|
if ($search_status && $search_status != -1) {
|
||||||
|
$param .= '&search_status='.urlencode($search_status);
|
||||||
|
}
|
||||||
|
if ($search_ref) {
|
||||||
|
$param .= '&search_ref='.urlencode($search_ref);
|
||||||
|
}
|
||||||
|
if ($search_company) {
|
||||||
|
$param .= '&search_company='.urlencode($search_company);
|
||||||
|
}
|
||||||
|
if ($search_name) {
|
||||||
|
$param .= '&search_name='.urlencode($search_name);
|
||||||
|
}
|
||||||
|
if ($search_amount) {
|
||||||
|
$param .= '&search_amount='.urlencode($search_amount);
|
||||||
|
}
|
||||||
|
|
||||||
$newcardbutton = '';
|
$newcardbutton = '';
|
||||||
if ($user->rights->don->creer)
|
if ($user->rights->don->creer) {
|
||||||
{
|
|
||||||
$newcardbutton .= dolGetButtonTitle($langs->trans('NewDonation'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/don/card.php?action=create');
|
$newcardbutton .= dolGetButtonTitle($langs->trans('NewDonation'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/don/card.php?action=create');
|
||||||
}
|
}
|
||||||
|
|
||||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n";
|
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">'."\n";
|
||||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
if ($optioncss != '') {
|
||||||
|
print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||||
|
}
|
||||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||||
print '<input type="hidden" name="action" value="list">';
|
print '<input type="hidden" name="action" value="list">';
|
||||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||||
@ -165,9 +187,10 @@ if ($resql)
|
|||||||
|
|
||||||
print_barre_liste($langs->trans("Donations"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'object_donation', 0, $newcardbutton, '', $limit, 0, 0, 1);
|
print_barre_liste($langs->trans("Donations"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'object_donation', 0, $newcardbutton, '', $limit, 0, 0, 1);
|
||||||
|
|
||||||
if ($search_all)
|
if ($search_all) {
|
||||||
{
|
foreach ($fieldstosearchall as $key => $val) {
|
||||||
foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val);
|
$fieldstosearchall[$key] = $langs->trans($val);
|
||||||
|
}
|
||||||
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
|
print '<div class="divsearchfieldfilter">'.$langs->trans("FilterOnInto", $search_all).join(', ', $fieldstosearchall).'</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,8 +217,7 @@ if ($resql)
|
|||||||
print '<td class="liste_titre left">';
|
print '<td class="liste_titre left">';
|
||||||
print ' ';
|
print ' ';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
if (!empty($conf->projet->enabled))
|
if (!empty($conf->projet->enabled)) {
|
||||||
{
|
|
||||||
print '<td class="liste_titre right">';
|
print '<td class="liste_titre right">';
|
||||||
print ' ';
|
print ' ';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
@ -225,8 +247,7 @@ if ($resql)
|
|||||||
}
|
}
|
||||||
print_liste_field_titre("Name", $_SERVER["PHP_SELF"], "d.lastname", "", $param, "", $sortfield, $sortorder);
|
print_liste_field_titre("Name", $_SERVER["PHP_SELF"], "d.lastname", "", $param, "", $sortfield, $sortorder);
|
||||||
print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "d.datedon", "", $param, '', $sortfield, $sortorder, 'center ');
|
print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "d.datedon", "", $param, '', $sortfield, $sortorder, 'center ');
|
||||||
if (!empty($conf->projet->enabled))
|
if (!empty($conf->projet->enabled)) {
|
||||||
{
|
|
||||||
$langs->load("projects");
|
$langs->load("projects");
|
||||||
print_liste_field_titre("Project", $_SERVER["PHP_SELF"], "d.fk_projet", "", $param, "", $sortfield, $sortorder);
|
print_liste_field_titre("Project", $_SERVER["PHP_SELF"], "d.fk_projet", "", $param, "", $sortfield, $sortorder);
|
||||||
}
|
}
|
||||||
@ -235,8 +256,7 @@ if ($resql)
|
|||||||
print_liste_field_titre('');
|
print_liste_field_titre('');
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
while ($i < min($num, $limit))
|
while ($i < min($num, $limit)) {
|
||||||
{
|
|
||||||
$objp = $db->fetch_object($resql);
|
$objp = $db->fetch_object($resql);
|
||||||
|
|
||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
@ -258,18 +278,18 @@ if ($resql)
|
|||||||
}
|
}
|
||||||
print "<td>".$donationstatic->getFullName($langs)."</td>";
|
print "<td>".$donationstatic->getFullName($langs)."</td>";
|
||||||
print '<td class="center">'.dol_print_date($db->jdate($objp->datedon), 'day').'</td>';
|
print '<td class="center">'.dol_print_date($db->jdate($objp->datedon), 'day').'</td>';
|
||||||
if (!empty($conf->projet->enabled))
|
if (!empty($conf->projet->enabled)) {
|
||||||
{
|
|
||||||
print "<td>";
|
print "<td>";
|
||||||
if ($objp->pid)
|
if ($objp->pid) {
|
||||||
{
|
|
||||||
$projectstatic->id = $objp->pid;
|
$projectstatic->id = $objp->pid;
|
||||||
$projectstatic->ref = $objp->ref;
|
$projectstatic->ref = $objp->ref;
|
||||||
$projectstatic->id = $objp->pid;
|
$projectstatic->id = $objp->pid;
|
||||||
$projectstatic->public = $objp->public;
|
$projectstatic->public = $objp->public;
|
||||||
$projectstatic->title = $objp->title;
|
$projectstatic->title = $objp->title;
|
||||||
print $projectstatic->getNomUrl(1);
|
print $projectstatic->getNomUrl(1);
|
||||||
} else print ' ';
|
} else {
|
||||||
|
print ' ';
|
||||||
|
}
|
||||||
print "</td>\n";
|
print "</td>\n";
|
||||||
}
|
}
|
||||||
print '<td class="right">'.price($objp->amount).'</td>';
|
print '<td class="right">'.price($objp->amount).'</td>';
|
||||||
|
|||||||
@ -29,8 +29,7 @@ require '../main.inc.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||||
if (!empty($conf->projet->enabled))
|
if (!empty($conf->projet->enabled)) {
|
||||||
{
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||||
}
|
}
|
||||||
@ -45,7 +44,9 @@ $projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0);
|
|||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
$socid = 0;
|
$socid = 0;
|
||||||
if ($user->socid) $socid = $user->socid;
|
if ($user->socid) {
|
||||||
|
$socid = $user->socid;
|
||||||
|
}
|
||||||
$result = restrictedArea($user, 'don', $id, '');
|
$result = restrictedArea($user, 'don', $id, '');
|
||||||
|
|
||||||
$object = new Don($db);
|
$object = new Don($db);
|
||||||
@ -59,8 +60,7 @@ $permissionnote = $user->rights->don->creer; // Used by the include of actions_s
|
|||||||
*/
|
*/
|
||||||
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
|
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
|
||||||
|
|
||||||
if ($action == 'classin' && $user->rights->don->creer)
|
if ($action == 'classin' && $user->rights->don->creer) {
|
||||||
{
|
|
||||||
$object->fetch($id);
|
$object->fetch($id);
|
||||||
$object->setProject($projectid);
|
$object->setProject($projectid);
|
||||||
}
|
}
|
||||||
@ -74,10 +74,11 @@ $helpurl = "";
|
|||||||
llxHeader('', $title, $helpurl);
|
llxHeader('', $title, $helpurl);
|
||||||
|
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
if (!empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
|
if (!empty($conf->projet->enabled)) {
|
||||||
|
$formproject = new FormProjets($db);
|
||||||
|
}
|
||||||
|
|
||||||
if ($id > 0 || !empty($ref))
|
if ($id > 0 || !empty($ref)) {
|
||||||
{
|
|
||||||
$object = new Don($db);
|
$object = new Don($db);
|
||||||
$object->fetch($id, $ref);
|
$object->fetch($id, $ref);
|
||||||
|
|
||||||
@ -89,12 +90,10 @@ if ($id > 0 || !empty($ref))
|
|||||||
|
|
||||||
$morehtmlref = '<div class="refidno">';
|
$morehtmlref = '<div class="refidno">';
|
||||||
// Project
|
// Project
|
||||||
if (!empty($conf->projet->enabled))
|
if (!empty($conf->projet->enabled)) {
|
||||||
{
|
|
||||||
$langs->load("projects");
|
$langs->load("projects");
|
||||||
$morehtmlref .= $langs->trans('Project').' ';
|
$morehtmlref .= $langs->trans('Project').' ';
|
||||||
if ($user->rights->don->creer)
|
if ($user->rights->don->creer) {
|
||||||
{
|
|
||||||
if ($action != 'classify') {
|
if ($action != 'classify') {
|
||||||
// $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
|
// $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,7 +27,9 @@ require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php';
|
||||||
if (!empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
if (!empty($conf->banque->enabled)) {
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||||
|
}
|
||||||
|
|
||||||
// Load translation files required by the page
|
// Load translation files required by the page
|
||||||
$langs->loadLangs(array("bills", "banks", "companies", "donations"));
|
$langs->loadLangs(array("bills", "banks", "companies", "donations"));
|
||||||
@ -36,15 +38,18 @@ $langs->loadLangs(array("bills", "banks", "companies", "donations"));
|
|||||||
$id = GETPOST('rowid') ? GETPOST('rowid', 'int') : GETPOST('id', 'int');
|
$id = GETPOST('rowid') ? GETPOST('rowid', 'int') : GETPOST('id', 'int');
|
||||||
$action = GETPOST('action', 'aZ09');
|
$action = GETPOST('action', 'aZ09');
|
||||||
$confirm = GETPOST('confirm', 'alpha');
|
$confirm = GETPOST('confirm', 'alpha');
|
||||||
if ($user->socid) $socid = $user->socid;
|
if ($user->socid) {
|
||||||
|
$socid = $user->socid;
|
||||||
|
}
|
||||||
// TODO Add rule to restrict access payment
|
// TODO Add rule to restrict access payment
|
||||||
//$result = restrictedArea($user, 'facture', $id,'');
|
//$result = restrictedArea($user, 'facture', $id,'');
|
||||||
|
|
||||||
$object = new PaymentDonation($db);
|
$object = new PaymentDonation($db);
|
||||||
if ($id > 0)
|
if ($id > 0) {
|
||||||
{
|
|
||||||
$result = $object->fetch($id);
|
$result = $object->fetch($id);
|
||||||
if (!$result) dol_print_error($db, 'Failed to get payment id '.$id);
|
if (!$result) {
|
||||||
|
dol_print_error($db, 'Failed to get payment id '.$id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -53,13 +58,11 @@ if ($id > 0)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Delete payment
|
// Delete payment
|
||||||
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->don->supprimer)
|
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->don->supprimer) {
|
||||||
{
|
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
$result = $object->delete($user);
|
$result = $object->delete($user);
|
||||||
if ($result > 0)
|
if ($result > 0) {
|
||||||
{
|
|
||||||
$db->commit();
|
$db->commit();
|
||||||
header("Location: ".DOL_URL_ROOT."/don/index.php");
|
header("Location: ".DOL_URL_ROOT."/don/index.php");
|
||||||
exit;
|
exit;
|
||||||
@ -93,8 +96,7 @@ print dol_get_fiche_head($head, $hselected, $langs->trans("DonationPayment"), -1
|
|||||||
/*
|
/*
|
||||||
* Confirm deleting of the payment
|
* Confirm deleting of the payment
|
||||||
*/
|
*/
|
||||||
if ($action == 'delete')
|
if ($action == 'delete') {
|
||||||
{
|
|
||||||
print $form->formconfirm('card.php?id='.$object->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete', '', 0, 2);
|
print $form->formconfirm('card.php?id='.$object->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete', '', 0, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,10 +124,8 @@ print '<tr><td>'.$langs->trans('Amount').'</td><td>'.price($object->amount, 0, $
|
|||||||
print '<tr><td>'.$langs->trans('Note').'</td><td>'.nl2br($object->note_public).'</td></tr>';
|
print '<tr><td>'.$langs->trans('Note').'</td><td>'.nl2br($object->note_public).'</td></tr>';
|
||||||
|
|
||||||
// Bank account
|
// Bank account
|
||||||
if (!empty($conf->banque->enabled))
|
if (!empty($conf->banque->enabled)) {
|
||||||
{
|
if ($object->bank_account) {
|
||||||
if ($object->bank_account)
|
|
||||||
{
|
|
||||||
$bankline = new AccountLine($db);
|
$bankline = new AccountLine($db);
|
||||||
$bankline->fetch($object->bank_line);
|
$bankline->fetch($object->bank_line);
|
||||||
|
|
||||||
@ -154,8 +154,7 @@ $sql .= ' AND pd.rowid = '.$id;
|
|||||||
|
|
||||||
dol_syslog("don/payment/card.php", LOG_DEBUG);
|
dol_syslog("don/payment/card.php", LOG_DEBUG);
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
|
||||||
$num = $db->num_rows($resql);
|
$num = $db->num_rows($resql);
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
@ -168,10 +167,8 @@ if ($resql)
|
|||||||
print '<td class="right">'.$langs->trans('PayedByThisPayment').'</td>';
|
print '<td class="right">'.$langs->trans('PayedByThisPayment').'</td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
if ($num > 0)
|
if ($num > 0) {
|
||||||
{
|
while ($i < $num) {
|
||||||
while ($i < $num)
|
|
||||||
{
|
|
||||||
$objp = $db->fetch_object($resql);
|
$objp = $db->fetch_object($resql);
|
||||||
|
|
||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
@ -213,12 +210,9 @@ print dol_get_fiche_end();
|
|||||||
*/
|
*/
|
||||||
print '<div class="tabsAction">';
|
print '<div class="tabsAction">';
|
||||||
|
|
||||||
if (empty($action))
|
if (empty($action)) {
|
||||||
{
|
if ($user->rights->don->supprimer) {
|
||||||
if ($user->rights->don->supprimer)
|
if (!$disable_delete) {
|
||||||
{
|
|
||||||
if (!$disable_delete)
|
|
||||||
{
|
|
||||||
print '<a class="butActionDelete" href="card.php?id='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans('Delete').'</a>';
|
print '<a class="butActionDelete" href="card.php?id='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans('Delete').'</a>';
|
||||||
} else {
|
} else {
|
||||||
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("CantRemovePaymentWithOneInvoicePaid")).'">'.$langs->trans('Delete').'</a>';
|
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("CantRemovePaymentWithOneInvoicePaid")).'">'.$langs->trans('Delete').'</a>';
|
||||||
|
|||||||
@ -46,12 +46,10 @@ $object = new Don($db);
|
|||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ($action == 'add_payment')
|
if ($action == 'add_payment') {
|
||||||
{
|
|
||||||
$error = 0;
|
$error = 0;
|
||||||
|
|
||||||
if ($_POST["cancel"])
|
if ($_POST["cancel"]) {
|
||||||
{
|
|
||||||
$loc = DOL_URL_ROOT.'/don/card.php?rowid='.$chid;
|
$loc = DOL_URL_ROOT.'/don/card.php?rowid='.$chid;
|
||||||
header("Location: ".$loc);
|
header("Location: ".$loc);
|
||||||
exit;
|
exit;
|
||||||
@ -59,45 +57,37 @@ if ($action == 'add_payment')
|
|||||||
|
|
||||||
$datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
|
$datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
|
||||||
|
|
||||||
if (!$_POST["paymenttype"] > 0)
|
if (!$_POST["paymenttype"] > 0) {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")), null, 'errors');
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")), null, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
if ($datepaid == '')
|
if ($datepaid == '') {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors');
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
if (!empty($conf->banque->enabled) && !$_POST["accountid"] > 0)
|
if (!empty($conf->banque->enabled) && !$_POST["accountid"] > 0) {
|
||||||
{
|
|
||||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToCredit")), null, 'errors');
|
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToCredit")), null, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
$paymentid = 0;
|
$paymentid = 0;
|
||||||
|
|
||||||
// Read possible payments
|
// Read possible payments
|
||||||
foreach ($_POST as $key => $value)
|
foreach ($_POST as $key => $value) {
|
||||||
{
|
if (substr($key, 0, 7) == 'amount_') {
|
||||||
if (substr($key, 0, 7) == 'amount_')
|
|
||||||
{
|
|
||||||
$other_chid = substr($key, 7);
|
$other_chid = substr($key, 7);
|
||||||
$amounts[$other_chid] = price2num($_POST[$key]);
|
$amounts[$other_chid] = price2num($_POST[$key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($amounts) <= 0)
|
if (count($amounts) <= 0) {
|
||||||
{
|
|
||||||
$error++;
|
$error++;
|
||||||
$errmsg = 'ErrorNoPaymentDefined';
|
$errmsg = 'ErrorNoPaymentDefined';
|
||||||
setEventMessages($errmsg, null, 'errors');
|
setEventMessages($errmsg, null, 'errors');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
// Create a line of payments
|
// Create a line of payments
|
||||||
@ -109,30 +99,25 @@ if ($action == 'add_payment')
|
|||||||
$payment->num_payment = GETPOST("num_payment", 'alphanohtml');
|
$payment->num_payment = GETPOST("num_payment", 'alphanohtml');
|
||||||
$payment->note_public = GETPOST("note_public", 'restricthtml');
|
$payment->note_public = GETPOST("note_public", 'restricthtml');
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
$paymentid = $payment->create($user);
|
$paymentid = $payment->create($user);
|
||||||
if ($paymentid < 0)
|
if ($paymentid < 0) {
|
||||||
{
|
|
||||||
$errmsg = $payment->error;
|
$errmsg = $payment->error;
|
||||||
setEventMessages($errmsg, null, 'errors');
|
setEventMessages($errmsg, null, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
$result = $payment->addPaymentToBank($user, 'payment_donation', '(DonationPayment)', $_POST['accountid'], '', '');
|
$result = $payment->addPaymentToBank($user, 'payment_donation', '(DonationPayment)', $_POST['accountid'], '', '');
|
||||||
if (!$result > 0)
|
if (!$result > 0) {
|
||||||
{
|
|
||||||
$errmsg = $payment->error;
|
$errmsg = $payment->error;
|
||||||
setEventMessages($errmsg, null, 'errors');
|
setEventMessages($errmsg, null, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error)
|
if (!$error) {
|
||||||
{
|
|
||||||
$db->commit();
|
$db->commit();
|
||||||
$loc = DOL_URL_ROOT.'/don/card.php?rowid='.$chid;
|
$loc = DOL_URL_ROOT.'/don/card.php?rowid='.$chid;
|
||||||
header('Location: '.$loc);
|
header('Location: '.$loc);
|
||||||
@ -160,8 +145,7 @@ $sql = "SELECT sum(p.amount) as total";
|
|||||||
$sql .= " FROM ".MAIN_DB_PREFIX."payment_donation as p";
|
$sql .= " FROM ".MAIN_DB_PREFIX."payment_donation as p";
|
||||||
$sql .= " WHERE p.fk_donation = ".$chid;
|
$sql .= " WHERE p.fk_donation = ".$chid;
|
||||||
$resql = $db->query($sql);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql) {
|
||||||
{
|
|
||||||
$obj = $db->fetch_object($resql);
|
$obj = $db->fetch_object($resql);
|
||||||
$sumpaid = $obj->total;
|
$sumpaid = $obj->total;
|
||||||
$db->free();
|
$db->free();
|
||||||
@ -169,16 +153,14 @@ if ($resql)
|
|||||||
|
|
||||||
|
|
||||||
// Form to create donation payment
|
// Form to create donation payment
|
||||||
if ($action == 'create')
|
if ($action == 'create') {
|
||||||
{
|
|
||||||
$object->fetch($chid);
|
$object->fetch($chid);
|
||||||
|
|
||||||
$total = $object->amount;
|
$total = $object->amount;
|
||||||
|
|
||||||
print load_fiche_titre($langs->trans("DoPayment"));
|
print load_fiche_titre($langs->trans("DoPayment"));
|
||||||
|
|
||||||
if (!empty($conf->use_javascript_ajax))
|
if (!empty($conf->use_javascript_ajax)) {
|
||||||
{
|
|
||||||
print "\n".'<script type="text/javascript" language="javascript">';
|
print "\n".'<script type="text/javascript" language="javascript">';
|
||||||
//Add js for AutoFill
|
//Add js for AutoFill
|
||||||
print ' $(document).ready(function () {';
|
print ' $(document).ready(function () {';
|
||||||
@ -252,8 +234,7 @@ if ($action == 'create')
|
|||||||
$total = 0;
|
$total = 0;
|
||||||
$totalrecu = 0;
|
$totalrecu = 0;
|
||||||
|
|
||||||
while ($i < $num)
|
while ($i < $num) {
|
||||||
{
|
|
||||||
$objp = $object;
|
$objp = $object;
|
||||||
|
|
||||||
print '<tr class="oddeven">';
|
print '<tr class="oddeven">';
|
||||||
@ -267,11 +248,11 @@ if ($action == 'create')
|
|||||||
print '<td class="right">'.price($objp->amount - $sumpaid)."</td>";
|
print '<td class="right">'.price($objp->amount - $sumpaid)."</td>";
|
||||||
|
|
||||||
print '<td class="center">';
|
print '<td class="center">';
|
||||||
if ($sumpaid < $objp->amount)
|
if ($sumpaid < $objp->amount) {
|
||||||
{
|
|
||||||
$namef = "amount_".$objp->id;
|
$namef = "amount_".$objp->id;
|
||||||
if (!empty($conf->use_javascript_ajax))
|
if (!empty($conf->use_javascript_ajax)) {
|
||||||
print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".price($objp->amount - $sumpaid)."'");
|
print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmout' data-rowname='".$namef."' data-value='".price($objp->amount - $sumpaid)."'");
|
||||||
|
}
|
||||||
print '<input type="text" size="8" name="'.$namef.'">';
|
print '<input type="text" size="8" name="'.$namef.'">';
|
||||||
} else {
|
} else {
|
||||||
print '-';
|
print '-';
|
||||||
|
|||||||
@ -35,8 +35,7 @@ $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height');
|
|||||||
$userid = GETPOST('userid', 'int');
|
$userid = GETPOST('userid', 'int');
|
||||||
$socid = GETPOST('socid', 'int');
|
$socid = GETPOST('socid', 'int');
|
||||||
// Security check
|
// Security check
|
||||||
if ($user->socid > 0)
|
if ($user->socid > 0) {
|
||||||
{
|
|
||||||
$action = '';
|
$action = '';
|
||||||
$socid = $user->socid;
|
$socid = $user->socid;
|
||||||
}
|
}
|
||||||
@ -72,8 +71,7 @@ $data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
|
|||||||
// $data = array(array('Lib',val1,val2,val3),...)
|
// $data = array(array('Lib',val1,val2,val3),...)
|
||||||
|
|
||||||
|
|
||||||
if (!$user->rights->societe->client->voir || $user->socid)
|
if (!$user->rights->societe->client->voir || $user->socid) {
|
||||||
{
|
|
||||||
$filenamenb = $dir.'/shipmentsnbinyear-'.$user->id.'-'.$year.'.png';
|
$filenamenb = $dir.'/shipmentsnbinyear-'.$user->id.'-'.$year.'.png';
|
||||||
} else {
|
} else {
|
||||||
$filenamenb = $dir.'/shipmentsnbinyear-'.$year.'.png';
|
$filenamenb = $dir.'/shipmentsnbinyear-'.$year.'.png';
|
||||||
@ -81,12 +79,10 @@ if (!$user->rights->societe->client->voir || $user->socid)
|
|||||||
|
|
||||||
$px1 = new DolGraph();
|
$px1 = new DolGraph();
|
||||||
$mesg = $px1->isGraphKo();
|
$mesg = $px1->isGraphKo();
|
||||||
if (!$mesg)
|
if (!$mesg) {
|
||||||
{
|
|
||||||
$px1->SetData($data);
|
$px1->SetData($data);
|
||||||
$i = $startyear; $legend = array();
|
$i = $startyear; $legend = array();
|
||||||
while ($i <= $endyear)
|
while ($i <= $endyear) {
|
||||||
{
|
|
||||||
$legend[] = $i;
|
$legend[] = $i;
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
@ -192,7 +188,9 @@ foreach ($data as $val) {
|
|||||||
$arrayyears[$val['year']] = $val['year'];
|
$arrayyears[$val['year']] = $val['year'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!count($arrayyears)) $arrayyears[$nowyear] = $nowyear;
|
if (!count($arrayyears)) {
|
||||||
|
$arrayyears[$nowyear] = $nowyear;
|
||||||
|
}
|
||||||
|
|
||||||
$h = 0;
|
$h = 0;
|
||||||
$head = array();
|
$head = array();
|
||||||
@ -229,8 +227,12 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
|
|||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
// Year
|
// Year
|
||||||
print '<tr><td class="left">'.$langs->trans("Year").'</td><td class="left">';
|
print '<tr><td class="left">'.$langs->trans("Year").'</td><td class="left">';
|
||||||
if (!in_array($year, $arrayyears)) $arrayyears[$year] = $year;
|
if (!in_array($year, $arrayyears)) {
|
||||||
if (!in_array($nowyear, $arrayyears)) $arrayyears[$nowyear] = $nowyear;
|
$arrayyears[$year] = $year;
|
||||||
|
}
|
||||||
|
if (!in_array($nowyear, $arrayyears)) {
|
||||||
|
$arrayyears[$nowyear] = $nowyear;
|
||||||
|
}
|
||||||
arsort($arrayyears);
|
arsort($arrayyears);
|
||||||
print $form->selectarray('year', $arrayyears, $year, 0);
|
print $form->selectarray('year', $arrayyears, $year, 0);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
@ -250,11 +252,9 @@ print '<td class="center">'.$langs->trans("AmountAverage").'</td>';*/
|
|||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
$oldyear = 0;
|
$oldyear = 0;
|
||||||
foreach ($data as $val)
|
foreach ($data as $val) {
|
||||||
{
|
|
||||||
$year = $val['year'];
|
$year = $val['year'];
|
||||||
while (!empty($year) && $oldyear > $year + 1)
|
while (!empty($year) && $oldyear > $year + 1) { // If we have empty year
|
||||||
{ // If we have empty year
|
|
||||||
$oldyear--;
|
$oldyear--;
|
||||||
print '<tr height="24">';
|
print '<tr height="24">';
|
||||||
print '<td class="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$oldyear.'">'.$oldyear.'</a></td>';
|
print '<td class="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$oldyear.'">'.$oldyear.'</a></td>';
|
||||||
@ -283,7 +283,9 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
|
|||||||
|
|
||||||
// Show graphs
|
// Show graphs
|
||||||
print '<table class="border centpercent"><tr class="pair nohover"><td class="center">';
|
print '<table class="border centpercent"><tr class="pair nohover"><td class="center">';
|
||||||
if ($mesg) { print $mesg; } else {
|
if ($mesg) {
|
||||||
|
print $mesg;
|
||||||
|
} else {
|
||||||
print $px1->show();
|
print $px1->show();
|
||||||
print "<br>\n";
|
print "<br>\n";
|
||||||
/*print $px2->show();
|
/*print $px2->show();
|
||||||
|
|||||||
@ -35,7 +35,9 @@ foreach ($linkedObjectBlock as $key => $objectlink) {
|
|||||||
$ilink++;
|
$ilink++;
|
||||||
|
|
||||||
$trclass = 'oddeven';
|
$trclass = 'oddeven';
|
||||||
if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) $trclass .= ' liste_sub_total';
|
if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) {
|
||||||
|
$trclass .= ' liste_sub_total';
|
||||||
|
}
|
||||||
print '<tr class="'.$trclass.'">';
|
print '<tr class="'.$trclass.'">';
|
||||||
print '<td>'.$langs->trans("Donation").'</td>';
|
print '<td>'.$langs->trans("Donation").'</td>';
|
||||||
print '<td>'.$objectlink->getNomUrl(1).'</td>';
|
print '<td>'.$objectlink->getNomUrl(1).'</td>';
|
||||||
@ -49,8 +51,7 @@ print '</td>';
|
|||||||
print '<td class="right">'.$objectlink->getLibStatut(3).'</td>';
|
print '<td class="right">'.$objectlink->getLibStatut(3).'</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
if (count($linkedObjectBlock) > 1)
|
if (count($linkedObjectBlock) > 1) {
|
||||||
{
|
|
||||||
?>
|
?>
|
||||||
<tr class="liste_total <?php echo (empty($noMoreLinkedObjectBlockAfter) ? 'liste_sub_total' : ''); ?>">
|
<tr class="liste_total <?php echo (empty($noMoreLinkedObjectBlockAfter) ? 'liste_sub_total' : ''); ?>">
|
||||||
<td><?php echo $langs->trans("Total"); ?></td>
|
<td><?php echo $langs->trans("Total"); ?></td>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user