Update works
This commit is contained in:
parent
0e01dbd44e
commit
15e50ed24f
@ -175,7 +175,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
|
|||||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->don->enabled', __HANDLER__, 'left', 2000__+MAX_llx_menu__, 'accountancy', 'donations', 6__+MAX_llx_menu__, '/donations/index.php?leftmenu=donations&mainmenu=accountancy', 'Donations', 0, 'donations', '$user->rights->don->lire', '', 2, 4, __ENTITY__);
|
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->don->enabled', __HANDLER__, 'left', 2000__+MAX_llx_menu__, 'accountancy', 'donations', 6__+MAX_llx_menu__, '/donations/index.php?leftmenu=donations&mainmenu=accountancy', 'Donations', 0, 'donations', '$user->rights->don->lire', '', 2, 4, __ENTITY__);
|
||||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->don->enabled && $leftmenu=="donations"', __HANDLER__, 'left', 2001__+MAX_llx_menu__, 'accountancy', '', 2000__+MAX_llx_menu__, '/donations/card.php?leftmenu=donations&mainmenu=accountancy&action=create', 'NewDonation', 1, 'donations', '$user->rights->don->creer', '', 2, 0, __ENTITY__);
|
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->don->enabled && $leftmenu=="donations"', __HANDLER__, 'left', 2001__+MAX_llx_menu__, 'accountancy', '', 2000__+MAX_llx_menu__, '/donations/card.php?leftmenu=donations&mainmenu=accountancy&action=create', 'NewDonation', 1, 'donations', '$user->rights->don->creer', '', 2, 0, __ENTITY__);
|
||||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->don->enabled && $leftmenu=="donations"', __HANDLER__, 'left', 2002__+MAX_llx_menu__, 'accountancy', '', 2000__+MAX_llx_menu__, '/donations/list.php?leftmenu=donations&mainmenu=accountancy', 'List', 1, 'donations', '$user->rights->don->lire', '', 2, 1, __ENTITY__);
|
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->don->enabled && $leftmenu=="donations"', __HANDLER__, 'left', 2002__+MAX_llx_menu__, 'accountancy', '', 2000__+MAX_llx_menu__, '/donations/list.php?leftmenu=donations&mainmenu=accountancy', 'List', 1, 'donations', '$user->rights->don->lire', '', 2, 1, __ENTITY__);
|
||||||
--insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->don->enabled && $leftmenu=="donations"', __HANDLER__, 'left', 2003__+MAX_llx_menu__, 'accountancy', '', 2000__+MAX_llx_menu__, '/donations/stats.php?leftmenu=donations&mainmenu=accountancy', 'Statistics', 1, 'donations', '$user->rights->don->lire', '', 2, 2, __ENTITY__);
|
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->don->enabled && $leftmenu=="donations"', __HANDLER__, 'left', 2003__+MAX_llx_menu__, 'accountancy', '', 2000__+MAX_llx_menu__, '/donations/stats/index.php?leftmenu=donations&mainmenu=accountancy', 'Statistics', 1, 'donations', '$user->rights->don->lire', '', 2, 2, __ENTITY__);
|
||||||
-- Special expenses
|
-- Special expenses
|
||||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled || $conf->salaries->enabled', __HANDLER__, 'left', 2200__+MAX_llx_menu__, 'accountancy', 'tax', 6__+MAX_llx_menu__, '/compta/charges/index.php?leftmenu=tax&mainmenu=accountancy', 'MenuSpecialExpenses', 0, 'compta', '(! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) || (! empty($conf->salaries->enabled) && $user->rights->salaries->read)', '', 0, 6, __ENTITY__);
|
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->tax->enabled || $conf->salaries->enabled', __HANDLER__, 'left', 2200__+MAX_llx_menu__, 'accountancy', 'tax', 6__+MAX_llx_menu__, '/compta/charges/index.php?leftmenu=tax&mainmenu=accountancy', 'MenuSpecialExpenses', 0, 'compta', '(! empty($conf->tax->enabled) && $user->rights->tax->charges->lire) || (! empty($conf->salaries->enabled) && $user->rights->salaries->read)', '', 0, 6, __ENTITY__);
|
||||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->salaries->enabled', __HANDLER__, 'left', 2210__+MAX_llx_menu__, 'accountancy', 'tax_sal', 2200__+MAX_llx_menu__, '/compta/salaries/index.php?leftmenu=tax_salary&mainmenu=accountancy', 'Salaries', 1, 'salaries', '$user->rights->salaries->read', '', 0, 1, __ENTITY__);
|
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->salaries->enabled', __HANDLER__, 'left', 2210__+MAX_llx_menu__, 'accountancy', 'tax_sal', 2200__+MAX_llx_menu__, '/compta/salaries/index.php?leftmenu=tax_salary&mainmenu=accountancy', 'Salaries', 1, 'salaries', '$user->rights->salaries->read', '', 0, 1, __ENTITY__);
|
||||||
|
|||||||
@ -791,7 +791,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
|
|||||||
$newmenu->add("/donations/index.php?leftmenu=donations&mainmenu=accountancy",$langs->trans("Donations"), 0, $user->rights->don->lire, '', $mainmenu, 'donations');
|
$newmenu->add("/donations/index.php?leftmenu=donations&mainmenu=accountancy",$langs->trans("Donations"), 0, $user->rights->don->lire, '', $mainmenu, 'donations');
|
||||||
if (empty($leftmenu) || $leftmenu=="donations") $newmenu->add("/donations/card.php?action=create",$langs->trans("NewDonation"), 1, $user->rights->don->creer);
|
if (empty($leftmenu) || $leftmenu=="donations") $newmenu->add("/donations/card.php?action=create",$langs->trans("NewDonation"), 1, $user->rights->don->creer);
|
||||||
if (empty($leftmenu) || $leftmenu=="donations") $newmenu->add("/donations/list.php",$langs->trans("List"), 1, $user->rights->don->lire);
|
if (empty($leftmenu) || $leftmenu=="donations") $newmenu->add("/donations/list.php",$langs->trans("List"), 1, $user->rights->don->lire);
|
||||||
//if ($leftmenu=="donations") $newmenu->add("/donations/stats.php",$langs->trans("Statistics"), 1, $user->rights->don->lire);
|
if ($leftmenu=="donations") $newmenu->add("/donations/stats/index.php",$langs->trans("Statistics"), 1, $user->rights->don->lire);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Taxes and social contributions
|
// Taxes and social contributions
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
require '../../main.inc.php';
|
require '../../main.inc.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/donations/core/lib/donation.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||||
|
|
||||||
@ -178,10 +179,13 @@ $dir = DOL_DOCUMENT_ROOT.'/donations/core/modules/dons/';
|
|||||||
$form=new Form($db);
|
$form=new Form($db);
|
||||||
|
|
||||||
llxHeader('',$langs->trans("DonationsSetup"),'DonConfiguration');
|
llxHeader('',$langs->trans("DonationsSetup"),'DonConfiguration');
|
||||||
|
|
||||||
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
||||||
print_fiche_titre($langs->trans("DonationsSetup"),$linkback,'setup');
|
print_fiche_titre($langs->trans("DonationsSetup"),$linkback,'setup');
|
||||||
|
|
||||||
|
$head = donation_admin_prepare_head();
|
||||||
|
|
||||||
|
dol_fiche_head($head, 'general', $langs->trans("Donations"), 0, 'donation');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Params
|
* Params
|
||||||
*/
|
*/
|
||||||
114
htdocs/donations/admin/donation_extrafields.php
Normal file
114
htdocs/donations/admin/donation_extrafields.php
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
<?php
|
||||||
|
/* Copyright (C) 2015 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file htdocs/donations/admin/donation_extrafields.php
|
||||||
|
* \ingroup donations
|
||||||
|
* \brief Page to setup extra fields of donations
|
||||||
|
*/
|
||||||
|
|
||||||
|
require '../../main.inc.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/donations/core/lib/donation.lib.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||||
|
|
||||||
|
$langs->load("companies");
|
||||||
|
$langs->load("admin");
|
||||||
|
$langs->load('donations');
|
||||||
|
|
||||||
|
$extrafields = new ExtraFields($db);
|
||||||
|
$form = new Form($db);
|
||||||
|
|
||||||
|
// List of supported format
|
||||||
|
$tmptype2label=ExtraFields::$type2label;
|
||||||
|
$type2label=array('');
|
||||||
|
foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val);
|
||||||
|
|
||||||
|
$action=GETPOST('action', 'alpha');
|
||||||
|
$attrname=GETPOST('attrname', 'alpha');
|
||||||
|
$elementtype='don'; //Must be the $table_element of the class that manage extrafield
|
||||||
|
|
||||||
|
if (!$user->admin) accessforbidden();
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Actions
|
||||||
|
*/
|
||||||
|
|
||||||
|
require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* View
|
||||||
|
*/
|
||||||
|
|
||||||
|
$textobject=$langs->transnoentitiesnoconv("Donations");
|
||||||
|
|
||||||
|
llxHeader('',$langs->trans("DonationsSetup"));
|
||||||
|
|
||||||
|
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
|
||||||
|
print_fiche_titre($langs->trans("DonationsSetup"),$linkback,'setup');
|
||||||
|
|
||||||
|
|
||||||
|
$head = donation_admin_prepare_head();
|
||||||
|
|
||||||
|
dol_fiche_head($head, 'attributes', $langs->trans("Donations"), 0, 'donation');
|
||||||
|
|
||||||
|
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
|
||||||
|
|
||||||
|
dol_fiche_end();
|
||||||
|
|
||||||
|
|
||||||
|
// Buttons
|
||||||
|
if ($action != 'create' && $action != 'edit')
|
||||||
|
{
|
||||||
|
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>";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* Create optional field */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
if ($action == 'create')
|
||||||
|
{
|
||||||
|
print "<br>";
|
||||||
|
print_titre($langs->trans('NewAttribute'));
|
||||||
|
|
||||||
|
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_add.tpl.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* Edit optional field */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
if ($action == 'edit' && ! empty($attrname))
|
||||||
|
{
|
||||||
|
print "<br>";
|
||||||
|
print_titre($langs->trans("FieldEdition", $attrname));
|
||||||
|
|
||||||
|
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
llxFooter();
|
||||||
|
|
||||||
|
$db->close();
|
||||||
@ -32,6 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.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';
|
||||||
@ -48,6 +49,11 @@ $cancel=GETPOST('cancel');
|
|||||||
$amount=GETPOST('amount');
|
$amount=GETPOST('amount');
|
||||||
|
|
||||||
$object = new Don($db);
|
$object = new Don($db);
|
||||||
|
$extrafields = new ExtraFields($db);
|
||||||
|
|
||||||
|
// fetch optionals attributes and labels
|
||||||
|
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
|
||||||
|
|
||||||
$donation_date=dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
|
$donation_date=dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
@ -104,6 +110,10 @@ if ($action == 'update')
|
|||||||
$object->note_private= GETPOST("note_private");
|
$object->note_private= GETPOST("note_private");
|
||||||
$object->note_public = GETPOST("note_public");
|
$object->note_public = GETPOST("note_public");
|
||||||
|
|
||||||
|
// Fill array 'array_options' with data from add form
|
||||||
|
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||||
|
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);
|
||||||
@ -151,7 +161,11 @@ if ($action == 'add')
|
|||||||
$object->note_private= GETPOST("note_private");
|
$object->note_private= GETPOST("note_private");
|
||||||
$object->note_public = GETPOST("note_public");
|
$object->note_public = GETPOST("note_public");
|
||||||
$object->public = GETPOST("public");
|
$object->public = GETPOST("public");
|
||||||
$object->fk_project = GETPOST("projectid");
|
$object->fk_project = GETPOST("fk_project");
|
||||||
|
|
||||||
|
// Fill array 'array_options' with data from add form
|
||||||
|
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||||
|
if ($ret < 0) $error++;
|
||||||
|
|
||||||
if ($object->create($user) > 0)
|
if ($object->create($user) > 0)
|
||||||
{
|
{
|
||||||
@ -341,8 +355,12 @@ if ($action == 'create')
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Other attributes
|
// Other attributes
|
||||||
$parameters=array('colspan' => ' colspan="1"');
|
$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
|
||||||
|
if (empty($reshook) && ! empty($extrafields->attribute_label))
|
||||||
|
{
|
||||||
|
print $object->showOptionals($extrafields,'edit');
|
||||||
|
}
|
||||||
|
|
||||||
print "</table>\n";
|
print "</table>\n";
|
||||||
print '<br><div class="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'"> <input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></div>';
|
print '<br><div class="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'"> <input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></div>';
|
||||||
|
|||||||
141
htdocs/donations/class/donationstats.class.php
Normal file
141
htdocs/donations/class/donationstats.class.php
Normal file
@ -0,0 +1,141 @@
|
|||||||
|
<?php
|
||||||
|
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
|
* Copyright (c) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
|
||||||
|
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file htdocs/donations/class/donationstats.class.php
|
||||||
|
* \ingroup donations
|
||||||
|
* \brief File of class to manage donations statistics
|
||||||
|
*/
|
||||||
|
|
||||||
|
include_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php';
|
||||||
|
include_once DOL_DOCUMENT_ROOT . '/donations/class/don.class.php';
|
||||||
|
include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class to manage donations statistics
|
||||||
|
*/
|
||||||
|
class DonationStats extends Stats
|
||||||
|
{
|
||||||
|
public $table_element;
|
||||||
|
|
||||||
|
var $socid;
|
||||||
|
var $userid;
|
||||||
|
|
||||||
|
var $from;
|
||||||
|
var $field;
|
||||||
|
var $where;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param DoliDB $db Database handler
|
||||||
|
* @param int $socid Id third party for filter
|
||||||
|
* @param string $mode Option (not used)
|
||||||
|
* @param int $userid Id user for filter (creation user)
|
||||||
|
*/
|
||||||
|
function __construct($db, $socid, $mode, $userid=0)
|
||||||
|
{
|
||||||
|
global $user, $conf;
|
||||||
|
|
||||||
|
$this->db = $db;
|
||||||
|
|
||||||
|
$this->socid = ($socid > 0 ? $socid : 0);
|
||||||
|
$this->userid = $userid;
|
||||||
|
$this->cachefilesuffix = $mode;
|
||||||
|
|
||||||
|
$object=new Don($this->db);
|
||||||
|
$this->from = MAIN_DB_PREFIX.$object->table_element." as c";
|
||||||
|
//$this->from.= ", ".MAIN_DB_PREFIX."societe as s";
|
||||||
|
//$this->field='weight'; // Warning, unit of weight is NOT USED AND MUST BE
|
||||||
|
$this->where.= " c.fk_statut > 0"; // Not draft and not cancelled
|
||||||
|
|
||||||
|
//$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity;
|
||||||
|
$this->where.= " AND c.entity = ".$conf->entity;
|
||||||
|
if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
|
||||||
|
if ($this->socid)
|
||||||
|
{
|
||||||
|
$this->where.=" AND c.fk_soc = ".$this->socid;
|
||||||
|
}
|
||||||
|
if ($this->userid > 0) $this->where.=' AND c.fk_user_author = '.$this->userid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return shipment number by month for a year
|
||||||
|
*
|
||||||
|
* @param int $year Year to scan
|
||||||
|
* @return array Array with number by month
|
||||||
|
*/
|
||||||
|
function getNbByMonth($year)
|
||||||
|
{
|
||||||
|
global $user;
|
||||||
|
|
||||||
|
$sql = "SELECT date_format(c.date_valid,'%m') as dm, COUNT(*) as nb";
|
||||||
|
$sql.= " FROM ".$this->from;
|
||||||
|
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
|
$sql.= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'";
|
||||||
|
$sql.= " AND ".$this->where;
|
||||||
|
$sql.= " GROUP BY dm";
|
||||||
|
$sql.= $this->db->order('dm','DESC');
|
||||||
|
|
||||||
|
$res=$this->_getNbByMonth($year, $sql);
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return shipments number per year
|
||||||
|
*
|
||||||
|
* @return array Array with number by year
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function getNbByYear()
|
||||||
|
{
|
||||||
|
global $user;
|
||||||
|
|
||||||
|
$sql = "SELECT date_format(c.date_valid,'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.")";
|
||||||
|
$sql.= " FROM ".$this->from;
|
||||||
|
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
|
$sql.= " WHERE ".$this->where;
|
||||||
|
$sql.= " GROUP BY dm";
|
||||||
|
$sql.= $this->db->order('dm','DESC');
|
||||||
|
|
||||||
|
return $this->_getNbByYear($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return nb, total and average
|
||||||
|
*
|
||||||
|
* @return array Array of values
|
||||||
|
*/
|
||||||
|
function getAllByYear()
|
||||||
|
{
|
||||||
|
global $user;
|
||||||
|
|
||||||
|
$sql = "SELECT date_format(c.date_valid,'%Y') as year, COUNT(*) as nb, SUM(c.".$this->field.") as total, AVG(".$this->field.") as avg";
|
||||||
|
$sql.= " FROM ".$this->from;
|
||||||
|
if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
||||||
|
$sql.= " WHERE ".$this->where;
|
||||||
|
$sql.= " GROUP BY year";
|
||||||
|
$sql.= $this->db->order('year','DESC');
|
||||||
|
|
||||||
|
return $this->_getAllByYear($sql);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -21,6 +21,40 @@
|
|||||||
* \brief Library of donation functions
|
* \brief Library of donation functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare array with list of admin tabs
|
||||||
|
*
|
||||||
|
* @param Donation $object Donation
|
||||||
|
* @return array Array of tabs to show
|
||||||
|
*/
|
||||||
|
function donation_admin_prepare_head()
|
||||||
|
{
|
||||||
|
global $langs, $conf;
|
||||||
|
|
||||||
|
$h = 0;
|
||||||
|
$head = array ();
|
||||||
|
|
||||||
|
$head[$h][0] = DOL_URL_ROOT . '/donations/admin/donation.php';
|
||||||
|
$head[$h][1] = $langs->trans("Miscellaneous");
|
||||||
|
$head[$h][2] = 'general';
|
||||||
|
$h ++;
|
||||||
|
|
||||||
|
// Show more tabs from modules
|
||||||
|
// Entries must be declared in modules descriptor with line
|
||||||
|
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
|
||||||
|
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||||
|
complete_head_from_modules($conf, $langs, $object, $head, $h, 'donation_admin');
|
||||||
|
|
||||||
|
$head[$h][0] = DOL_URL_ROOT . '/donations/admin/donation_extrafields.php';
|
||||||
|
$head[$h][1] = $langs->trans("ExtraFields");
|
||||||
|
$head[$h][2] = 'attributes';
|
||||||
|
$h++;
|
||||||
|
|
||||||
|
complete_head_from_modules($conf, $langs, $object, $head, $h, 'donation_admin', 'remove');
|
||||||
|
|
||||||
|
return $head;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare array with list of tabs
|
* Prepare array with list of tabs
|
||||||
*
|
*
|
||||||
|
|||||||
@ -64,7 +64,7 @@ class modDon extends DolibarrModules
|
|||||||
$this->requiredby = array();
|
$this->requiredby = array();
|
||||||
|
|
||||||
// Config pages
|
// Config pages
|
||||||
$this->config_page_url = array("dons.php@donations");
|
$this->config_page_url = array("donation.php@donations");
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
$this->const = array ();
|
$this->const = array ();
|
||||||
|
|||||||
@ -73,7 +73,7 @@ $sql = "SELECT d.rowid, d.datedon, d.firstname, d.lastname, d.societe,";
|
|||||||
$sql.= " d.amount, d.fk_statut as statut, ";
|
$sql.= " d.amount, d.fk_statut as statut, ";
|
||||||
$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_don_projet WHERE 1 = 1";
|
$sql.= " ON p.rowid = d.fk_project WHERE 1 = 1";
|
||||||
if ($statut >= 0)
|
if ($statut >= 0)
|
||||||
{
|
{
|
||||||
$sql .= " AND d.fk_statut = ".$statut;
|
$sql .= " AND d.fk_statut = ".$statut;
|
||||||
@ -125,7 +125,7 @@ if ($resql)
|
|||||||
if (! empty($conf->projet->enabled))
|
if (! empty($conf->projet->enabled))
|
||||||
{
|
{
|
||||||
$langs->load("projects");
|
$langs->load("projects");
|
||||||
print_liste_field_titre($langs->trans("Project"),$_SERVER["PHP_SELF"],"fk_don_projet","&page=$page&statut=$statut","","",$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Project"),$_SERVER["PHP_SELF"],"fk_project","&page=$page&statut=$statut","","",$sortfield,$sortorder);
|
||||||
}
|
}
|
||||||
print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"d.amount","&page=$page&statut=$statut","",'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Amount"),$_SERVER["PHP_SELF"],"d.amount","&page=$page&statut=$statut","",'align="right"',$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"d.fk_statut","&page=$page&statut=$statut","",'align="right"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"d.fk_statut","&page=$page&statut=$statut","",'align="right"',$sortfield,$sortorder);
|
||||||
|
|||||||
@ -1,84 +0,0 @@
|
|||||||
<?php
|
|
||||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
|
||||||
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \file htdocs/donations/stats.php
|
|
||||||
* \ingroup don
|
|
||||||
* \brief Page des statistiques de dons
|
|
||||||
*/
|
|
||||||
|
|
||||||
require '../main.inc.php';
|
|
||||||
|
|
||||||
$langs->load("donations");
|
|
||||||
|
|
||||||
if (!$user->rights->don->lire) accessforbidden();
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* View
|
|
||||||
*/
|
|
||||||
|
|
||||||
llxHeader('',$langs->trans("Donations"),'EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones');
|
|
||||||
|
|
||||||
|
|
||||||
print_fiche_titre($langs->trans("Statistics"));
|
|
||||||
|
|
||||||
|
|
||||||
$sql = "SELECT d.amount";
|
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."don as d LEFT JOIN ".MAIN_DB_PREFIX."projet as p";
|
|
||||||
$sql .= " ON p.rowid = d.fk_don_projet";
|
|
||||||
|
|
||||||
$result = $db->query($sql);
|
|
||||||
if ($result)
|
|
||||||
{
|
|
||||||
$num = $db->num_rows($result);
|
|
||||||
|
|
||||||
$var=true;
|
|
||||||
$i=0;
|
|
||||||
$total=0;
|
|
||||||
while ($i < $num)
|
|
||||||
{
|
|
||||||
$objp = $db->fetch_object($result);
|
|
||||||
$total += $objp->amount;
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
print '<table class="noborder" width="50%">';
|
|
||||||
|
|
||||||
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td align="right">'.$langs->trans("Value").'</td></tr>';
|
|
||||||
|
|
||||||
$var=!$var;
|
|
||||||
print "<tr ".$bc[$var].">";
|
|
||||||
print '<td>'.$langs->trans("DonationsNumber").'</td><td align="right">'.$num.'</td></tr>';
|
|
||||||
$var=!$var;
|
|
||||||
print "<tr ".$bc[$var].">".'<td>'.$langs->trans("AmountTotal").'</td><td align="right">'.price($total).'</td>';
|
|
||||||
$var=!$var;
|
|
||||||
print "<tr ".$bc[$var].">".'<td>'.$langs->trans("Average").'</td><td align="right">'.price($total / ($num?$num:1)).'</td>';
|
|
||||||
print "</tr>";
|
|
||||||
|
|
||||||
print "</table>";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dol_print_error($db);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
llxFooter();
|
|
||||||
|
|
||||||
$db->close();
|
|
||||||
@ -380,6 +380,16 @@ ALTER TABLE llx_don CHANGE COLUMN fk_paiement fk_payment integer;
|
|||||||
ALTER TABLE llx_don ADD COLUMN paid smallint default 0 NOT NULL after fk_payment;
|
ALTER TABLE llx_don ADD COLUMN paid smallint default 0 NOT NULL after fk_payment;
|
||||||
ALTER TABLE llx_don CHANGE COLUMN fk_don_projet fk_project integer NULL;
|
ALTER TABLE llx_don CHANGE COLUMN fk_don_projet fk_project integer NULL;
|
||||||
|
|
||||||
|
create table llx_don_extrafields
|
||||||
|
(
|
||||||
|
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
tms timestamp,
|
||||||
|
fk_object integer NOT NULL,
|
||||||
|
import_key varchar(14) -- import key
|
||||||
|
) ENGINE=innodb;
|
||||||
|
|
||||||
|
ALTER TABLE llx_don_extrafields ADD INDEX idx_don_extrafields (fk_object);
|
||||||
|
|
||||||
create table llx_payment_donation
|
create table llx_payment_donation
|
||||||
(
|
(
|
||||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
|||||||
20
htdocs/install/mysql/tables/llx_don_extrafields.key.sql
Normal file
20
htdocs/install/mysql/tables/llx_don_extrafields.key.sql
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
-- ===================================================================
|
||||||
|
-- Copyright (C) 2015 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||||
|
--
|
||||||
|
-- This program is free software; you can redistribute it and/or modify
|
||||||
|
-- it under the terms of the GNU General Public License as published by
|
||||||
|
-- the Free Software Foundation; either version 3 of the License, or
|
||||||
|
-- (at your option) any later version.
|
||||||
|
--
|
||||||
|
-- This program is distributed in the hope that it will be useful,
|
||||||
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
-- GNU General Public License for more details.
|
||||||
|
--
|
||||||
|
-- You should have received a copy of the GNU General Public License
|
||||||
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
--
|
||||||
|
-- ===================================================================
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE llx_don_extrafields ADD INDEX idx_don_extrafields (fk_object);
|
||||||
26
htdocs/install/mysql/tables/llx_don_extrafields.sql
Normal file
26
htdocs/install/mysql/tables/llx_don_extrafields.sql
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
-- ========================================================================
|
||||||
|
-- Copyright (C) 2015 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||||
|
--
|
||||||
|
-- This program is free software; you can redistribute it and/or modify
|
||||||
|
-- it under the terms of the GNU General Public License as published by
|
||||||
|
-- the Free Software Foundation; either version 3 of the License, or
|
||||||
|
-- (at your option) any later version.
|
||||||
|
--
|
||||||
|
-- This program is distributed in the hope that it will be useful,
|
||||||
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
-- GNU General Public License for more details.
|
||||||
|
--
|
||||||
|
-- You should have received a copy of the GNU General Public License
|
||||||
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
--
|
||||||
|
-- ========================================================================
|
||||||
|
|
||||||
|
create table llx_don_extrafields
|
||||||
|
(
|
||||||
|
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
tms timestamp,
|
||||||
|
fk_object integer NOT NULL,
|
||||||
|
import_key varchar(14) -- import key
|
||||||
|
) ENGINE=innodb;
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user