Merge pull request #2494 from aspangaro/develop-ReviewAssoc
New: Review module donation
This commit is contained in:
commit
32bda97712
@ -172,6 +172,7 @@ done >>%{name}.lang
|
||||
%_datadir/dolibarr/htdocs/contrat
|
||||
%_datadir/dolibarr/htdocs/core
|
||||
%_datadir/dolibarr/htdocs/cron
|
||||
%_datadir/dolibarr/htdocs/don
|
||||
%_datadir/dolibarr/htdocs/ecm
|
||||
%_datadir/dolibarr/htdocs/expedition
|
||||
%_datadir/dolibarr/htdocs/expensereport
|
||||
|
||||
@ -252,6 +252,7 @@ done >>%{name}.lang
|
||||
%_datadir/dolibarr/htdocs/contrat
|
||||
%_datadir/dolibarr/htdocs/core
|
||||
%_datadir/dolibarr/htdocs/cron
|
||||
%_datadir/dolibarr/htdocs/don
|
||||
%_datadir/dolibarr/htdocs/ecm
|
||||
%_datadir/dolibarr/htdocs/expedition
|
||||
%_datadir/dolibarr/htdocs/expensereport
|
||||
|
||||
@ -169,6 +169,7 @@ done >>%{name}.lang
|
||||
%_datadir/dolibarr/htdocs/contrat
|
||||
%_datadir/dolibarr/htdocs/core
|
||||
%_datadir/dolibarr/htdocs/cron
|
||||
%_datadir/dolibarr/htdocs/don
|
||||
%_datadir/dolibarr/htdocs/ecm
|
||||
%_datadir/dolibarr/htdocs/expedition
|
||||
%_datadir/dolibarr/htdocs/expensereport
|
||||
|
||||
@ -180,6 +180,7 @@ done >>%{name}.lang
|
||||
%_datadir/dolibarr/htdocs/contrat
|
||||
%_datadir/dolibarr/htdocs/core
|
||||
%_datadir/dolibarr/htdocs/cron
|
||||
%_datadir/dolibarr/htdocs/don
|
||||
%_datadir/dolibarr/htdocs/ecm
|
||||
%_datadir/dolibarr/htdocs/expedition
|
||||
%_datadir/dolibarr/htdocs/expensereport
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2010-2011 Juanjo Menent <jmenent@@2byte.es>
|
||||
* Copyright (C) 2012-2014 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2011-2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* Copyright (C) 2011-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
|
||||
@ -37,6 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/salaries/class/paymentsalary.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
@ -46,6 +47,7 @@ $langs->load("categories");
|
||||
$langs->load("bills");
|
||||
$langs->load("companies");
|
||||
$langs->load("loan");
|
||||
$langs->load("donations");
|
||||
|
||||
$id = (GETPOST('id','int') ? GETPOST('id','int') : GETPOST('account','int'));
|
||||
$ref = GETPOST('ref','alpha');
|
||||
@ -156,6 +158,7 @@ $paymentstatic=new Paiement($db);
|
||||
$paymentsupplierstatic=new PaiementFourn($db);
|
||||
$paymentvatstatic=new TVA($db);
|
||||
$paymentsalstatic=new PaymentSalary($db);
|
||||
$donstatic=new Don($db);
|
||||
$bankstatic=new Account($db);
|
||||
$banklinestatic=new AccountLine($db);
|
||||
|
||||
@ -615,6 +618,12 @@ if ($id > 0 || ! empty($ref))
|
||||
print ' '.img_object($langs->trans('ShowPayment'),'payment').' ';
|
||||
print '</a>';
|
||||
}
|
||||
elseif ($links[$key]['type']=='payment_donation')
|
||||
{
|
||||
print '<a href="'.DOL_URL_ROOT.'/don/payment/card.php?id='.$links[$key]['url_id'].'">';
|
||||
print ' '.img_object($langs->trans('ShowPayment'),'payment').' ';
|
||||
print '</a>';
|
||||
}
|
||||
elseif ($links[$key]['type']=='banktransfert')
|
||||
{
|
||||
// Do not show link to transfer since there is no transfer card (avoid confusion). Can already be accessed from transaction detail.
|
||||
|
||||
@ -1,593 +0,0 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
*
|
||||
* 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/compta/dons/card.php
|
||||
* \ingroup don
|
||||
* \brief Page of donation card
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/dons/modules_don.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/dons/class/don.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
|
||||
if (! empty($conf->projet->enabled)) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
||||
}
|
||||
|
||||
$langs->load("companies");
|
||||
$langs->load("donations");
|
||||
$langs->load("bills");
|
||||
|
||||
$id=GETPOST('rowid')?GETPOST('rowid','int'):GETPOST('id','int');
|
||||
$action=GETPOST('action','alpha');
|
||||
$cancel=GETPOST('cancel');
|
||||
$amount=GETPOST('amount');
|
||||
|
||||
$don = new Don($db);
|
||||
$donation_date=dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
|
||||
|
||||
// Security check
|
||||
$result = restrictedArea($user, 'don', $id);
|
||||
|
||||
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
||||
$hookmanager->initHooks(array('doncard','globalcard'));
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($action == 'update')
|
||||
{
|
||||
if (! empty($cancel))
|
||||
{
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
|
||||
exit;
|
||||
}
|
||||
|
||||
$error=0;
|
||||
|
||||
if (empty($donation_date))
|
||||
{
|
||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->trans("Date")), 'errors');
|
||||
$action = "create";
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (empty($amount))
|
||||
{
|
||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->trans("Amount")), 'errors');
|
||||
$action = "create";
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$don->fetch($id);
|
||||
|
||||
$don->firstname = $_POST["firstname"];
|
||||
$don->lastname = $_POST["lastname"];
|
||||
$don->societe = $_POST["societe"];
|
||||
$don->address = $_POST["address"];
|
||||
$don->amount = price2num($_POST["amount"]);
|
||||
$don->town = $_POST["town"];
|
||||
$don->zip = $_POST["zipcode"];
|
||||
$don->country = $_POST["country"];
|
||||
$don->email = $_POST["email"];
|
||||
$don->date = $donation_date;
|
||||
$don->note = $_POST["note"];
|
||||
$don->public = $_POST["public"];
|
||||
$don->fk_project = $_POST["projectid"];
|
||||
$don->note_private= GETPOST("note_private");
|
||||
$don->note_public = GETPOST("note_public");
|
||||
$don->modepaiementid = $_POST["modepaiement"];
|
||||
|
||||
if ($don->update($user) > 0)
|
||||
{
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$don->id);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'add')
|
||||
{
|
||||
if (! empty($cancel))
|
||||
{
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$error=0;
|
||||
|
||||
if (empty($donation_date))
|
||||
{
|
||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->trans("Date")), 'errors');
|
||||
$action = "create";
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (empty($amount))
|
||||
{
|
||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->trans("Amount")), 'errors');
|
||||
$action = "create";
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$don->firstname = $_POST["firstname"];
|
||||
$don->lastname = $_POST["lastname"];
|
||||
$don->societe = $_POST["societe"];
|
||||
$don->address = $_POST["address"];
|
||||
$don->amount = price2num($_POST["amount"]);
|
||||
$don->town = $_POST["town"];
|
||||
$don->zip = $_POST["zipcode"];
|
||||
$don->town = $_POST["town"];
|
||||
$don->country = $_POST["country"];
|
||||
$don->email = $_POST["email"];
|
||||
$don->date = $donation_date;
|
||||
$don->note_private= GETPOST("note_private");
|
||||
$don->note_public = GETPOST("note_public");
|
||||
$don->public = $_POST["public"];
|
||||
$don->fk_project = $_POST["projectid"];
|
||||
$don->modepaiementid = $_POST["modepaiement"];
|
||||
|
||||
if ($don->create($user) > 0)
|
||||
{
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'delete')
|
||||
{
|
||||
$don->delete($id);
|
||||
header("Location: list.php");
|
||||
exit;
|
||||
}
|
||||
if ($action == 'commentaire')
|
||||
{
|
||||
$don->fetch($id);
|
||||
$don->update_note($_POST["commentaire"]);
|
||||
}
|
||||
if ($action == 'valid_promesse')
|
||||
{
|
||||
if ($don->valid_promesse($id, $user->id) >= 0)
|
||||
{
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
setEventMessage($don->error, 'errors');
|
||||
}
|
||||
}
|
||||
if ($action == 'set_cancel')
|
||||
{
|
||||
if ($don->set_cancel($id) >= 0)
|
||||
{
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
setEventMessage($don->error, 'errors');
|
||||
}
|
||||
}
|
||||
if ($action == 'set_paid')
|
||||
{
|
||||
if ($don->set_paye($id, $modepaiement) >= 0)
|
||||
{
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
setEventMessage($don->error, 'errors');
|
||||
}
|
||||
}
|
||||
if ($action == 'set_encaisse')
|
||||
{
|
||||
if ($don->set_encaisse($id) >= 0)
|
||||
{
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
setEventMessage($don->error, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Build doc
|
||||
*/
|
||||
if ($action == 'builddoc')
|
||||
{
|
||||
$object = new Don($db);
|
||||
$object->fetch($id);
|
||||
|
||||
// Save last template used to generate document
|
||||
if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha'));
|
||||
|
||||
// Define output language
|
||||
$outputlangs = $langs;
|
||||
$newlang='';
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
|
||||
if (! empty($newlang))
|
||||
{
|
||||
$outputlangs = new Translate("",$conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$result=don_create($db, $object->id, '', $object->modelpdf, $outputlangs);
|
||||
if ($result <= 0)
|
||||
{
|
||||
dol_print_error($db,$result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader('',$langs->trans("Donations"),'EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones');
|
||||
|
||||
$form=new Form($db);
|
||||
$formfile = new FormFile($db);
|
||||
$formcompany = new FormCompany($db);
|
||||
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* Creation */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
if ($action == 'create')
|
||||
{
|
||||
print_fiche_titre($langs->trans("AddDonation"));
|
||||
|
||||
print '<form name="add" action="card.php" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
|
||||
$nbrows=11;
|
||||
if (! empty($conf->projet->enabled)) $nbrows++;
|
||||
|
||||
// Date
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Date").'</td><td>';
|
||||
$form->select_date($donation_date?$donation_date:-1,'','','','',"add",1,1);
|
||||
print '</td>';
|
||||
|
||||
print '<td rowspan="'.$nbrows.'" valign="top">'.$langs->trans("Comments").' :<br>';
|
||||
print "<textarea name=\"note_private\" wrap=\"soft\" cols=\"40\" rows=\"15\">".GETPOST("note_private")."</textarea></td>";
|
||||
print "</tr>";
|
||||
|
||||
// Amount
|
||||
print "<tr>".'<td class="fieldrequired">'.$langs->trans("Amount").'</td><td><input type="text" name="amount" value="'.$_POST["amount"].'" size="10"> '.$langs->trans("Currency".$conf->currency).'</td></tr>';
|
||||
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("PublicDonation")."</td><td>";
|
||||
print $form->selectyesno("public",isset($_POST["public"])?$_POST["public"]:1,1);
|
||||
print "</td></tr>\n";
|
||||
|
||||
print "<tr>".'<td>'.$langs->trans("Company").'</td><td><input type="text" name="societe" value="'.$_POST["societe"].'" size="40"></td></tr>';
|
||||
print "<tr>".'<td>'.$langs->trans("Firstname").'</td><td><input type="text" name="firstname" value="'.$_POST["firstname"].'" size="40"></td></tr>';
|
||||
print "<tr>".'<td>'.$langs->trans("Lastname").'</td><td><input type="text" name="lastname" value="'.$_POST["lastname"].'" size="40"></td></tr>';
|
||||
print "<tr>".'<td>'.$langs->trans("Address").'</td><td>';
|
||||
print '<textarea name="address" wrap="soft" cols="40" rows="3">'.$_POST["address"].'</textarea></td></tr>';
|
||||
|
||||
// Zip / Town
|
||||
print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>';
|
||||
print $formcompany->select_ziptown((isset($_POST["zipcode"])?$_POST["zipcode"]:$don->zip),'zipcode',array('town','selectcountry_id','state_id'),6);
|
||||
print ' ';
|
||||
print $formcompany->select_ziptown((isset($_POST["town"])?$_POST["town"]:$don->town),'town',array('zipcode','selectcountry_id','state_id'));
|
||||
print '</tr>';
|
||||
|
||||
print "<tr>".'<td>'.$langs->trans("Country").'</td><td><input type="text" name="country" value="'.$_POST["country"].'" size="40"></td></tr>';
|
||||
print "<tr>".'<td>'.$langs->trans("EMail").'</td><td><input type="text" name="email" value="'.$_POST["email"].'" size="40"></td></tr>';
|
||||
|
||||
print "<tr><td>".$langs->trans("PaymentMode")."</td><td>\n";
|
||||
$form->select_types_paiements('', 'modepaiement', 'CRDT', 0, 1);
|
||||
print "</td></tr>\n";
|
||||
|
||||
if (! empty($conf->projet->enabled))
|
||||
{
|
||||
|
||||
$formproject=new FormProjets($db);
|
||||
|
||||
// Si module projet actif
|
||||
print "<tr><td>".$langs->trans("Project")."</td><td>";
|
||||
$formproject->select_projects('',$_POST["projectid"],"projectid");
|
||||
print "</td></tr>\n";
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
$parameters=array('colspan' => ' colspan="1"');
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$don,$action); // Note that $action and $object may have been modified by hook
|
||||
|
||||
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 "</form>\n";
|
||||
}
|
||||
|
||||
|
||||
/* ************************************************************ */
|
||||
/* */
|
||||
/* Fiche don en mode edition */
|
||||
/* */
|
||||
/* ************************************************************ */
|
||||
|
||||
if (! empty($id) && $action == 'edit')
|
||||
{
|
||||
$don->fetch($id);
|
||||
|
||||
$h=0;
|
||||
$head[$h][0] = $_SERVER['PHP_SELF']."?id=".$don->id;
|
||||
$head[$h][1] = $langs->trans("Card");
|
||||
$hselected=$h;
|
||||
$h++;
|
||||
|
||||
dol_fiche_head($head, $hselected, $langs->trans("Donation"), 0, 'generic');
|
||||
|
||||
print '<form name="update" action="card.php" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<input type="hidden" name="rowid" value="'.$don->id.'">';
|
||||
|
||||
// Ref
|
||||
print "<tr>".'<td>'.$langs->trans("Ref").'</td><td colspan="2">';
|
||||
print $don->getNomUrl();
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
$nbrows=12;
|
||||
if (! empty($conf->projet->enabled)) $nbrows++;
|
||||
|
||||
// Date
|
||||
print "<tr>".'<td width="25%" class="fieldrequired">'.$langs->trans("Date").'</td><td>';
|
||||
$form->select_date($don->date,'','','','',"update");
|
||||
print '</td>';
|
||||
|
||||
print '<td rowspan="'.$nbrows.'" valign="top">'.$langs->trans("Comments").' :<br>';
|
||||
print "<textarea name=\"note_private\" wrap=\"soft\" cols=\"40\" rows=\"15\">".$don->note_private."</textarea></td>";
|
||||
print "</tr>";
|
||||
|
||||
// Amount
|
||||
print "<tr>".'<td class="fieldrequired">'.$langs->trans("Amount").'</td><td><input type="text" name="amount" size="10" value="'.$don->amount.'"> '.$langs->trans("Currency".$conf->currency).'</td></tr>';
|
||||
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("PublicDonation")."</td><td>";
|
||||
print $form->selectyesno("public",1,1);
|
||||
print "</td>";
|
||||
print "</tr>\n";
|
||||
|
||||
$langs->load("companies");
|
||||
print "<tr>".'<td>'.$langs->trans("Company").'</td><td><input type="text" name="societe" size="40" value="'.$don->societe.'"></td></tr>';
|
||||
print "<tr>".'<td>'.$langs->trans("Firstname").'</td><td><input type="text" name="firstname" size="40" value="'.$don->firstname.'"></td></tr>';
|
||||
print "<tr>".'<td>'.$langs->trans("Lastname").'</td><td><input type="text" name="lastname" size="40" value="'.$don->lastname.'"></td></tr>';
|
||||
print "<tr>".'<td>'.$langs->trans("Address").'</td><td>';
|
||||
print '<textarea name="address" wrap="soft" cols="40" rows="'.ROWS_3.'">'.$don->address.'</textarea></td></tr>';
|
||||
|
||||
// Zip / Town
|
||||
print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>';
|
||||
print $formcompany->select_ziptown((isset($_POST["zipcode"])?$_POST["zipcode"]:$don->zip),'zipcode',array('town','selectcountry_id','state_id'),6);
|
||||
print ' ';
|
||||
print $formcompany->select_ziptown((isset($_POST["town"])?$_POST["town"]:$don->town),'town',array('zipcode','selectcountry_id','state_id'));
|
||||
print '</tr>';
|
||||
|
||||
print "<tr>".'<td>'.$langs->trans("Country").'</td><td><input type="text" name="country" size="40" value="'.$don->country.'"></td></tr>';
|
||||
print "<tr>".'<td>'.$langs->trans("EMail").'</td><td><input type="text" name="email" size="40" value="'.$don->email.'"></td></tr>';
|
||||
|
||||
print "<tr><td>".$langs->trans("PaymentMode")."</td><td>\n";
|
||||
|
||||
if ($don->modepaiementid) $selected = $don->modepaiementid;
|
||||
else $selected = '';
|
||||
|
||||
$form->select_types_paiements($selected, 'modepaiement', 'CRDT', 0, 1);
|
||||
print "</td></tr>\n";
|
||||
|
||||
print "<tr>".'<td>'.$langs->trans("Status").'</td><td>'.$don->getLibStatut(4).'</td></tr>';
|
||||
|
||||
// Project
|
||||
if (! empty($conf->projet->enabled))
|
||||
{
|
||||
$formproject=new FormProjets($db);
|
||||
|
||||
$langs->load('projects');
|
||||
print '<tr><td>'.$langs->trans('Project').'</td><td>';
|
||||
$formproject->select_projects(-1, (isset($_POST["projectid"])?$_POST["projectid"]:$don->fk_project), 'projectid');
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
$parameters=array('colspan' => ' colspan="1"');
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$don,$action); // Note that $action and $object may have been modified by hook
|
||||
|
||||
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 "</form>\n";
|
||||
|
||||
print "</div>\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ************************************************************ */
|
||||
/* */
|
||||
/* Fiche don en mode visu */
|
||||
/* */
|
||||
/* ************************************************************ */
|
||||
if (! empty($id) && $action != 'edit')
|
||||
{
|
||||
$result=$don->fetch($id);
|
||||
|
||||
$h=0;
|
||||
$head[$h][0] = $_SERVER['PHP_SELF']."?id=".$don->id;
|
||||
$head[$h][1] = $langs->trans("Card");
|
||||
$hselected=$h;
|
||||
$h++;
|
||||
|
||||
dol_fiche_head($head, $hselected, $langs->trans("Donation"), 0, 'generic');
|
||||
|
||||
print "<form action=\"card.php\" method=\"post\">";
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/dons/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
$nbrows=12;
|
||||
if (! empty($conf->projet->enabled)) $nbrows++;
|
||||
|
||||
// Ref
|
||||
print "<tr>".'<td>'.$langs->trans("Ref").'</td><td colspan="2">';
|
||||
print $form->showrefnav($don, 'rowid', $linkback, 1, 'rowid', 'ref', '');
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Date
|
||||
print '<tr><td width="25%">'.$langs->trans("Date").'</td><td>';
|
||||
print dol_print_date($don->date,"day");
|
||||
print "</td>";
|
||||
|
||||
print '<td rowspan="'.$nbrows.'" valign="top" width="50%">'.$langs->trans("Comments").' :<br>';
|
||||
print nl2br($don->note_private).'</td></tr>';
|
||||
|
||||
print "<tr>".'<td>'.$langs->trans("Amount").'</td><td>'.price($don->amount,0,$langs,0,0,-1,$conf->currency).'</td></tr>';
|
||||
|
||||
print "<tr><td>".$langs->trans("PublicDonation")."</td><td>";
|
||||
print yn($don->public);
|
||||
print "</td></tr>\n";
|
||||
|
||||
print "<tr>".'<td>'.$langs->trans("Company").'</td><td>'.$don->societe.'</td></tr>';
|
||||
print "<tr>".'<td>'.$langs->trans("Firstname").'</td><td>'.$don->firstname.'</td></tr>';
|
||||
print "<tr>".'<td>'.$langs->trans("Lastname").'</td><td>'.$don->lastname.'</td></tr>';
|
||||
print "<tr>".'<td>'.$langs->trans("Address").'</td><td>'.dol_nl2br($don->address).'</td></tr>';
|
||||
|
||||
// Zip / Town
|
||||
print "<tr>".'<td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>'.$don->zip.($don->zip && $don->town?' / ':'').$don->town.'</td></tr>';
|
||||
|
||||
// Country
|
||||
print "<tr>".'<td>'.$langs->trans("Country").'</td><td>'.$don->country.'</td></tr>';
|
||||
|
||||
// EMail
|
||||
print "<tr>".'<td>'.$langs->trans("EMail").'</td><td>'.dol_print_email($don->email).'</td></tr>';
|
||||
|
||||
// Payment mode
|
||||
print "<tr><td>".$langs->trans("PaymentMode")."</td><td>";
|
||||
$form->form_modes_reglement(null, $don->modepaiementid,'none');
|
||||
print "</td></tr>\n";
|
||||
|
||||
print "<tr>".'<td>'.$langs->trans("Status").'</td><td>'.$don->getLibStatut(4).'</td></tr>';
|
||||
|
||||
// Project
|
||||
if (! empty($conf->projet->enabled))
|
||||
{
|
||||
print "<tr>".'<td>'.$langs->trans("Project").'</td><td>'.$don->projet.'</td></tr>';
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
$parameters=array('colspan' => ' colspan="1"');
|
||||
$reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$don,$action); // Note that $action and $object may have been modified by hook
|
||||
|
||||
print "</table>\n";
|
||||
print "</form>\n";
|
||||
|
||||
print "</div>";
|
||||
|
||||
// TODO Gerer action emettre paiement
|
||||
$resteapayer = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Barre d'actions
|
||||
*/
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?action=edit&rowid='.$don->id.'">'.$langs->trans('Modify').'</a></div>';
|
||||
|
||||
if ($don->statut == 0)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$don->id.'&action=valid_promesse">'.$langs->trans("ValidPromess").'</a></div>';
|
||||
}
|
||||
|
||||
if (($don->statut == 0 || $don->statut == 1) && $resteapayer == 0 && $don->paye == 0)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$don->id.'&action=set_cancel">'.$langs->trans("ClassifyCanceled")."</a></div>";
|
||||
}
|
||||
|
||||
// TODO Gerer action emettre paiement
|
||||
if ($don->statut == 1 && $resteapayer > 0)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="paiement.php?rowid='.$don->id.'&action=create">'.$langs->trans("DoPayment")."</a></div>";
|
||||
}
|
||||
|
||||
if ($don->statut == 1 && $resteapayer == 0 && $don->paye == 0)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="card.php?rowid='.$don->id.'&action=set_paid">'.$langs->trans("ClassifyPaid")."</a></div>";
|
||||
}
|
||||
|
||||
if ($user->rights->don->supprimer)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?rowid='.$don->id.'&action=delete">'.$langs->trans("Delete")."</a></div>";
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#">'.$langs->trans("Delete")."</a></div>";
|
||||
}
|
||||
|
||||
print "</div>";
|
||||
|
||||
|
||||
print '<table width="100%"><tr><td width="50%" valign="top">';
|
||||
|
||||
/*
|
||||
* Documents generes
|
||||
*/
|
||||
$filename=dol_sanitizeFileName($don->id);
|
||||
$filedir=$conf->don->dir_output . '/' . get_exdir($filename,2);
|
||||
$urlsource=$_SERVER['PHP_SELF'].'?rowid='.$don->id;
|
||||
// $genallowed=($fac->statut == 1 && ($fac->paye == 0 || $user->admin) && $user->rights->facture->creer);
|
||||
// $delallowed=$user->rights->facture->supprimer;
|
||||
$genallowed=1;
|
||||
$delallowed=0;
|
||||
|
||||
$var=true;
|
||||
|
||||
print '<br>';
|
||||
$formfile->show_documents('donation',$filename,$filedir,$urlsource,$genallowed,$delallowed);
|
||||
|
||||
print '</td><td> </td>';
|
||||
|
||||
print '</tr></table>';
|
||||
|
||||
}
|
||||
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
@ -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/compta/dons/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();
|
||||
@ -127,7 +127,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->lire)
|
||||
if (! empty($conf->don->enabled) && $user->rights->don->lire)
|
||||
{
|
||||
$langs->load("donations");
|
||||
print '<form method="post" action="'.DOL_URL_ROOT.'/compta/dons/list.php">';
|
||||
print '<form method="post" action="'.DOL_URL_ROOT.'/don/list.php">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<table class="noborder nohover" width="100%">';
|
||||
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchADonation").'</td></tr>';
|
||||
@ -497,7 +497,7 @@ if (! empty($conf->fournisseur->enabled) && $user->rights->fournisseur->facture-
|
||||
// Last donations
|
||||
if (! empty($conf->don->enabled) && $user->rights->societe->lire)
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/compta/dons/class/don.class.php';
|
||||
include_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
|
||||
|
||||
$langs->load("boxes");
|
||||
$donationstatic=new Don($db);
|
||||
|
||||
@ -651,7 +651,7 @@ if ($conf->donation->enabled)
|
||||
$var = !$var;
|
||||
print "<tr ".$bc[$var]."><td> </td>";
|
||||
|
||||
print "<td>".$langs->trans("Donation")." <a href=\"".DOL_URL_ROOT."/compta/dons/list.php?search_company=".$obj->name."&search_name=".$obj->firstname." ".$obj->lastname."\">".$obj->name. " ".$obj->firstname." ".$obj->lastname."</a></td>\n";
|
||||
print "<td>".$langs->trans("Donation")." <a href=\"".DOL_URL_ROOT."/don/list.php?search_company=".$obj->name."&search_name=".$obj->firstname." ".$obj->lastname."\">".$obj->name. " ".$obj->firstname." ".$obj->lastname."</a></td>\n";
|
||||
|
||||
if ($modecompta == 'CREANCES-DETTES') print '<td align="right">'.price($obj->amount).'</td>';
|
||||
print '<td align="right">'.price($obj->amount).'</td>';
|
||||
|
||||
90
htdocs/core/lib/donation.lib.php
Normal file
90
htdocs/core/lib/donation.lib.php
Normal file
@ -0,0 +1,90 @@
|
||||
<?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/core/lib/donation.lib.php
|
||||
* \ingroup Donation
|
||||
* \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 . '/don/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 . '/don/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
|
||||
*
|
||||
* @param Donation $object Donation
|
||||
* @return array Array of tabs to show
|
||||
*/
|
||||
function donation_prepare_head($object)
|
||||
{
|
||||
global $langs, $conf;
|
||||
|
||||
$h = 0;
|
||||
$head = array ();
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT . '/don/card.php?id=' . $object->id;
|
||||
$head[$h][1] = $langs->trans("Card");
|
||||
$head[$h][2] = 'card';
|
||||
$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');
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT . '/don/info.php?id=' . $object->id;
|
||||
$head[$h][1] = $langs->trans("Info");
|
||||
$head[$h][2] = 'info';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'donation', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
@ -172,10 +172,10 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
|
||||
-- Accountancy - Orders to bill
|
||||
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->commande->enabled', __HANDLER__, 'left', 1900__+MAX_llx_menu__, 'accountancy', 'orders', 6__+MAX_llx_menu__, '/commande/list.php?leftmenu=orders&viewstatut=3', 'MenuOrdersToBill', 0, 'orders', '$user->rights->commande->lire', '', 0, 3, __ENTITY__);
|
||||
-- Donations
|
||||
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__, '/compta/dons/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__, '/compta/dons/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__, '/compta/dons/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__, '/compta/dons/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', __HANDLER__, 'left', 2000__+MAX_llx_menu__, 'accountancy', 'donations', 6__+MAX_llx_menu__, '/don/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__, '/don/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__, '/don/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__, '/don/stats/index.php?leftmenu=donations&mainmenu=accountancy', 'Statistics', 1, 'donations', '$user->rights->don->lire', '', 2, 2, __ENTITY__);
|
||||
-- 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->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__);
|
||||
|
||||
@ -807,10 +807,10 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu
|
||||
if (! empty($conf->don->enabled))
|
||||
{
|
||||
$langs->load("donations");
|
||||
$newmenu->add("/compta/dons/index.php?leftmenu=donations&mainmenu=accountancy",$langs->trans("Donations"), 0, $user->rights->don->lire, '', $mainmenu, 'donations');
|
||||
if (empty($leftmenu) || $leftmenu=="donations") $newmenu->add("/compta/dons/card.php?action=create",$langs->trans("NewDonation"), 1, $user->rights->don->creer);
|
||||
if (empty($leftmenu) || $leftmenu=="donations") $newmenu->add("/compta/dons/list.php",$langs->trans("List"), 1, $user->rights->don->lire);
|
||||
//if ($leftmenu=="donations") $newmenu->add("/compta/dons/stats.php",$langs->trans("Statistics"), 1, $user->rights->don->lire);
|
||||
$newmenu->add("/don/index.php?leftmenu=donations&mainmenu=accountancy",$langs->trans("Donations"), 0, $user->rights->don->lire, '', $mainmenu, 'donations');
|
||||
if (empty($leftmenu) || $leftmenu=="donations") $newmenu->add("/don/card.php?action=create",$langs->trans("NewDonation"), 1, $user->rights->don->creer);
|
||||
if (empty($leftmenu) || $leftmenu=="donations") $newmenu->add("/don/list.php",$langs->trans("List"), 1, $user->rights->don->lire);
|
||||
// if ($leftmenu=="donations") $newmenu->add("/don/stats/index.php",$langs->trans("Statistics"), 1, $user->rights->don->lire);
|
||||
}
|
||||
|
||||
// Taxes and social contributions
|
||||
|
||||
@ -25,7 +25,7 @@
|
||||
* \brief Form of donation
|
||||
*/
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/dons/modules_don.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/dons/class/don.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
|
||||
|
||||
|
||||
@ -21,11 +21,11 @@
|
||||
|
||||
/**
|
||||
* \file htdocs/core/modules/dons/modules_don.php
|
||||
* \ingroup don
|
||||
* \ingroup donations
|
||||
* \brief File of class to manage donation document generation
|
||||
*/
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/dons/class/don.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
|
||||
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2011 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* 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
|
||||
@ -19,10 +19,10 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \defgroup don Module donation
|
||||
* \defgroup don Module donations
|
||||
* \brief Module to manage the follow-up of the donations
|
||||
* \file htdocs/core/modules/modDon.class.php
|
||||
* \ingroup don
|
||||
* \ingroup donations
|
||||
* \brief Description and activation file for module Donation
|
||||
*/
|
||||
|
||||
@ -64,7 +64,7 @@ class modDon extends DolibarrModules
|
||||
$this->requiredby = array();
|
||||
|
||||
// Config pages
|
||||
$this->config_page_url = array("dons.php");
|
||||
$this->config_page_url = array("donation.php@don");
|
||||
|
||||
// Constants
|
||||
$this->const = array ();
|
||||
@ -146,8 +146,8 @@ class modDon extends DolibarrModules
|
||||
global $conf;
|
||||
|
||||
$sql = array(
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[0][2]."' AND entity = ".$conf->entity,
|
||||
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->const[0][2]."','donation',".$conf->entity.")",
|
||||
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[0][4]."' AND entity = ".$conf->entity,
|
||||
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->const[0][4]."','donation',".$conf->entity.")",
|
||||
);
|
||||
|
||||
return $this->_init($sql,$options);
|
||||
@ -168,4 +168,4 @@ class modDon extends DolibarrModules
|
||||
return $this->_remove($sql,$options);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
/* Copyright (C) 2005-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2012-2013 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2013 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2014 Alexandre Spangaro <alexandre.spangaro@gmail.com>
|
||||
* 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
|
||||
@ -19,13 +19,15 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/admin/dons.php
|
||||
* \ingroup dons
|
||||
* \brief Page d'administration/configuration du module Dons
|
||||
* \file htdocs/don/admin/dons.php
|
||||
* \ingroup donations
|
||||
* \brief Page to setup the donation module
|
||||
*/
|
||||
require '../main.inc.php';
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/dons/class/don.class.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.'/core/class/doleditor.class.php';
|
||||
|
||||
$langs->load("admin");
|
||||
$langs->load("donations");
|
||||
@ -173,14 +175,17 @@ else if ($action == 'setart885') {
|
||||
* View
|
||||
*/
|
||||
|
||||
$dir = "../core/modules/dons/";
|
||||
$dir = "../../core/modules/dons/";
|
||||
$form=new Form($db);
|
||||
|
||||
llxHeader('',$langs->trans("DonationsSetup"),'DonConfiguration');
|
||||
|
||||
$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, 'general', $langs->trans("Donations"), 0, 'payment');
|
||||
|
||||
/*
|
||||
* Params
|
||||
*/
|
||||
@ -191,7 +196,7 @@ print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
|
||||
print '<input type="hidden" name="action" value="set_DONATION_MESSAGE" />';
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("Parameter").'</td>';
|
||||
print '<td>'.$langs->trans("Parameters").'</td>';
|
||||
print '<td width="80"> </td>';
|
||||
print "</tr>\n";
|
||||
$var=true;
|
||||
@ -210,7 +215,7 @@ print '</form>';
|
||||
/*
|
||||
* French params
|
||||
*/
|
||||
if ($conf->global->MAIN_LANG_DEFAULT == "fr_FR")
|
||||
if (preg_match('/fr/i',$conf->global->MAIN_INFO_SOCIETE_COUNTRY))
|
||||
{
|
||||
print '<br>';
|
||||
print_titre($langs->trans("FrenchOptions"));
|
||||
114
htdocs/don/admin/donation_extrafields.php
Normal file
114
htdocs/don/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/don/admin/donation_extrafields.php
|
||||
* \ingroup donations
|
||||
* \brief Page to setup extra fields of donations
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/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, 'payment');
|
||||
|
||||
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();
|
||||
740
htdocs/don/card.php
Normal file
740
htdocs/don/card.php
Normal file
@ -0,0 +1,740 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
* 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/don/card.php
|
||||
* \ingroup donations
|
||||
* \brief Page of donation card
|
||||
*/
|
||||
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/dons/modules_don.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
if (! empty($conf->projet->enabled))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
||||
}
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
|
||||
$langs->load("companies");
|
||||
$langs->load("donations");
|
||||
$langs->load("bills");
|
||||
|
||||
$id=GETPOST('rowid')?GETPOST('rowid','int'):GETPOST('id','int');
|
||||
$action=GETPOST('action','alpha');
|
||||
$cancel=GETPOST('cancel');
|
||||
$amount=GETPOST('amount');
|
||||
$donation_date=dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
|
||||
|
||||
$object = new Don($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
|
||||
// Security check
|
||||
$result = restrictedArea($user, 'don', $id);
|
||||
|
||||
// fetch optionals attributes and labels
|
||||
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
|
||||
// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array
|
||||
$hookmanager->initHooks(array('doncard','globalcard'));
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
$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 ($action == 'update')
|
||||
{
|
||||
if (! empty($cancel))
|
||||
{
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
|
||||
exit;
|
||||
}
|
||||
|
||||
$error=0;
|
||||
|
||||
if (empty($donation_date))
|
||||
{
|
||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->trans("Date")), 'errors');
|
||||
$action = "create";
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (empty($amount))
|
||||
{
|
||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->trans("Amount")), 'errors');
|
||||
$action = "create";
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$object->fetch($id);
|
||||
|
||||
$object->firstname = GETPOST("firstname");
|
||||
$object->lastname = GETPOST("lastname");
|
||||
$object->societe = GETPOST("societe");
|
||||
$object->address = GETPOST("address");
|
||||
$object->amount = price2num(GETPOST("amount"));
|
||||
$object->town = GETPOST("town");
|
||||
$object->zip = GETPOST("zipcode");
|
||||
$object->country_id = GETPOST('country_id', 'int');
|
||||
$object->email = GETPOST("email");
|
||||
$object->date = $donation_date;
|
||||
$object->public = GETPOST("public");
|
||||
$object->fk_project = GETPOST("fk_project");
|
||||
$object->note_private= GETPOST("note_private");
|
||||
$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)
|
||||
{
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'add')
|
||||
{
|
||||
if (! empty($cancel))
|
||||
{
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$error=0;
|
||||
|
||||
if (empty($donation_date))
|
||||
{
|
||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->trans("Date")), 'errors');
|
||||
$action = "create";
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (empty($amount))
|
||||
{
|
||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->trans("Amount")), 'errors');
|
||||
$action = "create";
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$object->firstname = GETPOST("firstname");
|
||||
$object->lastname = GETPOST("lastname");
|
||||
$object->societe = GETPOST("societe");
|
||||
$object->address = GETPOST("address");
|
||||
$object->amount = price2num(GETPOST("amount"));
|
||||
$object->zip = GETPOST("zipcode");
|
||||
$object->town = GETPOST("town");
|
||||
$object->country_id = GETPOST('country_id', 'int');
|
||||
$object->email = GETPOST("email");
|
||||
$object->date = $donation_date;
|
||||
$object->note_private= GETPOST("note_private");
|
||||
$object->note_public = GETPOST("note_public");
|
||||
$object->public = GETPOST("public");
|
||||
$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)
|
||||
{
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights->don->supprimer)
|
||||
{
|
||||
$object->fetch($id);
|
||||
$result=$object->delete($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog($object->error,LOG_DEBUG);
|
||||
setEventMessage($object->error,'errors');
|
||||
setEventMessage($object->errors,'errors');
|
||||
}
|
||||
}
|
||||
if ($action == 'valid_promesse')
|
||||
{
|
||||
if ($object->valid_promesse($id, $user->id) >= 0)
|
||||
{
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
setEventMessage($object->error, 'errors');
|
||||
}
|
||||
}
|
||||
if ($action == 'set_cancel')
|
||||
{
|
||||
if ($object->set_cancel($id) >= 0)
|
||||
{
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
setEventMessage($object->error, 'errors');
|
||||
}
|
||||
}
|
||||
if ($action == 'set_paid')
|
||||
{
|
||||
if ($object->set_paid($id, $modepayment) >= 0)
|
||||
{
|
||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$id);
|
||||
exit;
|
||||
}
|
||||
else {
|
||||
setEventMessage($object->error, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Build doc
|
||||
*/
|
||||
if ($action == 'builddoc')
|
||||
{
|
||||
$object = new Don($db);
|
||||
$object->fetch($id);
|
||||
|
||||
// Save last template used to generate document
|
||||
if (GETPOST('model')) $object->setDocModel($user, GETPOST('model','alpha'));
|
||||
|
||||
// Define output language
|
||||
$outputlangs = $langs;
|
||||
$newlang='';
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id'];
|
||||
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang;
|
||||
if (! empty($newlang))
|
||||
{
|
||||
$outputlangs = new Translate("",$conf);
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
$result=don_create($db, $object->id, '', $object->modelpdf, $outputlangs);
|
||||
if ($result <= 0)
|
||||
{
|
||||
dol_print_error($db,$result);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader('',$langs->trans("Donations"),'EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones');
|
||||
|
||||
$form=new Form($db);
|
||||
$formfile = new FormFile($db);
|
||||
$formcompany = new FormCompany($db);
|
||||
|
||||
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* Donation card in create mode */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
if ($action == 'create')
|
||||
{
|
||||
print_fiche_titre($langs->trans("AddDonation"));
|
||||
|
||||
print '<form name="add" action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
|
||||
$nbrows=11;
|
||||
if (! empty($conf->projet->enabled)) $nbrows++;
|
||||
|
||||
// Date
|
||||
print '<tr><td class="fieldrequired" width="25%">'.$langs->trans("Date").'</td><td>';
|
||||
$form->select_date($donation_date?$donation_date:-1,'','','','',"add",1,1);
|
||||
print '</td>';
|
||||
|
||||
// Amount
|
||||
print "<tr>".'<td class="fieldrequired">'.$langs->trans("Amount").'</td><td><input type="text" name="amount" value="'.GETPOST("amount").'" size="10"> '.$langs->trans("Currency".$conf->currency).'</td></tr>';
|
||||
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("PublicDonation")."</td><td>";
|
||||
print $form->selectyesno("public",isset($_POST["public"])?$_POST["public"]:1,1);
|
||||
print "</td></tr>\n";
|
||||
|
||||
print "<tr>".'<td>'.$langs->trans("Company").'</td><td><input type="text" name="societe" value="'.GETPOST("societe").'" size="40"></td></tr>';
|
||||
print "<tr>".'<td>'.$langs->trans("Lastname").'</td><td><input type="text" name="lastname" value="'.GETPOST("lastname").'" size="40"></td></tr>';
|
||||
print "<tr>".'<td>'.$langs->trans("Firstname").'</td><td><input type="text" name="firstname" value="'.GETPOST("firstname").'" size="40"></td></tr>';
|
||||
print "<tr>".'<td>'.$langs->trans("Address").'</td><td>';
|
||||
print '<textarea name="address" wrap="soft" cols="40" rows="3">'.GETPOST("address").'</textarea></td></tr>';
|
||||
|
||||
// Zip / Town
|
||||
print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>';
|
||||
print $formcompany->select_ziptown((isset($_POST["zipcode"])?$_POST["zipcode"]:$object->zip),'zipcode',array('town','selectcountry_id','state_id'),6);
|
||||
print ' ';
|
||||
print $formcompany->select_ziptown((isset($_POST["town"])?$_POST["town"]:$object->town),'town',array('zipcode','selectcountry_id','state_id'));
|
||||
print '</tr>';
|
||||
|
||||
// Country
|
||||
print '<tr><td width="25%"><label for="selectcountry_id">'.$langs->trans('Country').'</label></td><td colspan="3" class="maxwidthonsmartphone">';
|
||||
print $form->select_country(GETPOST('country_id')!=''?GETPOST('country_id'):$object->country_id);
|
||||
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
|
||||
print '</td></tr>';
|
||||
|
||||
print "<tr>".'<td>'.$langs->trans("EMail").'</td><td><input type="text" name="email" value="'.GETPOST("email").'" size="40"></td></tr>';
|
||||
|
||||
// Public note
|
||||
print '<tr>';
|
||||
print '<td class="border" valign="top">' . $langs->trans('NotePublic') . '</td>';
|
||||
print '<td valign="top" colspan="2">';
|
||||
|
||||
$doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70);
|
||||
print $doleditor->Create(1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Private note
|
||||
if (empty($user->societe_id)) {
|
||||
print '<tr>';
|
||||
print '<td class="border" valign="top">' . $langs->trans('NotePrivate') . '</td>';
|
||||
print '<td valign="top" colspan="2">';
|
||||
|
||||
$doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70);
|
||||
print $doleditor->Create(1);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
if (! empty($conf->projet->enabled))
|
||||
{
|
||||
|
||||
$formproject=new FormProjets($db);
|
||||
|
||||
print "<tr><td>".$langs->trans("Project")."</td><td>";
|
||||
$formproject->select_projects(-1, GETPOST("fk_project"),'fk_project', 0, 1, 0, 1);
|
||||
print "</td></tr>\n";
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
$parameters=array('colspan' => 3);
|
||||
$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',$parameters);
|
||||
}
|
||||
|
||||
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 "</form>\n";
|
||||
}
|
||||
|
||||
|
||||
/* ************************************************************ */
|
||||
/* */
|
||||
/* Donation card in edit mode */
|
||||
/* */
|
||||
/* ************************************************************ */
|
||||
|
||||
if (! empty($id) && $action == 'edit')
|
||||
{
|
||||
$result=$object->fetch($id);
|
||||
if ($result < 0) {
|
||||
dol_print_error($db,$object->error); exit;
|
||||
}
|
||||
$result=$object->fetch_optionals($object->id,$extralabels);
|
||||
if ($result < 0) {
|
||||
dol_print_error($db); exit;
|
||||
}
|
||||
|
||||
$head = donation_prepare_head($object);
|
||||
dol_fiche_head($head, $hselected, $langs->trans("Donation"), 0, 'generic');
|
||||
|
||||
print '<form name="update" action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<input type="hidden" name="rowid" value="'.$object->id.'">';
|
||||
print '<input type="hidden" name="amount" value="'.$object->amount.'">';
|
||||
|
||||
// Ref
|
||||
print "<tr>".'<td>'.$langs->trans("Ref").'</td><td colspan="2">';
|
||||
print $object->getNomUrl();
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
$nbrows=12;
|
||||
if (! empty($conf->projet->enabled)) $nbrows++;
|
||||
|
||||
// Date
|
||||
print "<tr>".'<td width="25%" class="fieldrequired">'.$langs->trans("Date").'</td><td>';
|
||||
$form->select_date($object->date,'','','','',"update");
|
||||
print '</td>';
|
||||
|
||||
// Amount
|
||||
if ($object->statut == 0)
|
||||
{
|
||||
print "<tr>".'<td class="fieldrequired">'.$langs->trans("Amount").'</td><td><input type="text" name="amount" size="10" value="'.$object->amount.'"> '.$langs->trans("Currency".$conf->currency).'</td></tr>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("Amount").'</td><td colspan="2">';
|
||||
print price($object->amount,0,$langs,0,0,-1,$conf->currency);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("PublicDonation")."</td><td>";
|
||||
print $form->selectyesno("public",1,1);
|
||||
print "</td>";
|
||||
print "</tr>\n";
|
||||
|
||||
$langs->load("companies");
|
||||
print "<tr>".'<td>'.$langs->trans("Company").'</td><td><input type="text" name="societe" size="40" value="'.$object->societe.'"></td></tr>';
|
||||
print "<tr>".'<td>'.$langs->trans("Lastname").'</td><td><input type="text" name="lastname" size="40" value="'.$object->lastname.'"></td></tr>';
|
||||
print "<tr>".'<td>'.$langs->trans("Firstname").'</td><td><input type="text" name="firstname" size="40" value="'.$object->firstname.'"></td></tr>';
|
||||
print "<tr>".'<td>'.$langs->trans("Address").'</td><td>';
|
||||
print '<textarea name="address" wrap="soft" cols="40" rows="'.ROWS_3.'">'.$object->address.'</textarea></td></tr>';
|
||||
|
||||
// Zip / Town
|
||||
print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>';
|
||||
print $formcompany->select_ziptown((isset($_POST["zipcode"])?$_POST["zipcode"]:$object->zip),'zipcode',array('town','selectcountry_id','state_id'),6);
|
||||
print ' ';
|
||||
print $formcompany->select_ziptown((isset($_POST["town"])?$_POST["town"]:$object->town),'town',array('zipcode','selectcountry_id','state_id'));
|
||||
print '</tr>';
|
||||
|
||||
// Country
|
||||
print '<tr><td width="25%">'.$langs->trans('Country').'</td><td colspan="3">';
|
||||
print $form->select_country((!empty($object->country_id)?$object->country_id:$mysoc->country_code),'country_id');
|
||||
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
|
||||
print '</td></tr>';
|
||||
|
||||
print "<tr>".'<td>'.$langs->trans("EMail").'</td><td><input type="text" name="email" size="40" value="'.$object->email.'"></td></tr>';
|
||||
|
||||
print "<tr><td>".$langs->trans("PaymentMode")."</td><td>\n";
|
||||
|
||||
if ($object->modepaymentid) $selected = $object->modepaymentid;
|
||||
else $selected = '';
|
||||
|
||||
$form->select_types_paiements($selected, 'modepayment', 'CRDT', 0, 1);
|
||||
print "</td></tr>\n";
|
||||
|
||||
print "<tr>".'<td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
|
||||
|
||||
// Project
|
||||
if (! empty($conf->projet->enabled))
|
||||
{
|
||||
$formproject=new FormProjets($db);
|
||||
|
||||
$langs->load('projects');
|
||||
print '<tr><td>'.$langs->trans('Project').'</td><td>';
|
||||
$formproject->select_projects(-1, $object->fk_project,'fk_project', 0, 1, 0, 1);
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
$parameters=array('colspan' => ' colspan="2"');
|
||||
$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 '<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 "</form>\n";
|
||||
|
||||
print "</div>\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ************************************************************ */
|
||||
/* */
|
||||
/* Donation card in view mode */
|
||||
/* */
|
||||
/* ************************************************************ */
|
||||
if (! empty($id) && $action != 'edit')
|
||||
{
|
||||
// Confirmation delete
|
||||
if ($action == 'delete')
|
||||
{
|
||||
$text=$langs->trans("ConfirmDeleteADonation");
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("DeleteADonation"),$text,"confirm_delete",'','',1);
|
||||
}
|
||||
|
||||
$result=$object->fetch($id);
|
||||
if ($result < 0) {
|
||||
dol_print_error($db,$object->error); exit;
|
||||
}
|
||||
$result=$object->fetch_optionals($object->id,$extralabels);
|
||||
if ($result < 0) {
|
||||
dol_print_error($db); exit;
|
||||
}
|
||||
|
||||
$head = donation_prepare_head($object);
|
||||
dol_fiche_head($head, $hselected, $langs->trans("Donation"), 0, 'generic');
|
||||
|
||||
print '<form action="' . $_SERVER["PHP_SELF"] . '" method="POST">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/don/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
$nbrows=12;
|
||||
if (! empty($conf->projet->enabled)) $nbrows++;
|
||||
|
||||
// Ref
|
||||
print "<tr>".'<td>'.$langs->trans("Ref").'</td><td colspan="2">';
|
||||
print $form->showrefnav($object, 'rowid', $linkback, 1, 'rowid', 'ref', '');
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Date
|
||||
print '<tr><td width="25%">'.$langs->trans("Date").'</td><td colspan="2">';
|
||||
print dol_print_date($object->date,"day");
|
||||
print "</td>";
|
||||
|
||||
print '<tr><td>'.$langs->trans("Amount").'</td><td colspan="2">';
|
||||
print price($object->amount,0,$langs,0,0,-1,$conf->currency);
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("PublicDonation").'</td><td colspan="2">';
|
||||
print yn($object->public);
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("Company").'</td><td colspan="2">'.$object->societe.'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Lastname").'</td><td colspan="2">'.$object->lastname.'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Firstname").'</td><td colspan="2">'.$object->firstname.'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Address").'</td><td>'.dol_nl2br($object->address).'</td>';
|
||||
|
||||
$rowspan=6;
|
||||
if (! empty($conf->projet->enabled)) $rowspan++;
|
||||
print '<td rowspan="'.$rowspan.'" valign="top">';
|
||||
|
||||
/*
|
||||
* Payments
|
||||
*/
|
||||
$sql = "SELECT p.rowid, p.num_payment, p.datep as dp, p.amount,";
|
||||
$sql.= "c.code as type_code,c.libelle as paiement_type";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."payment_donation as p";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."c_paiement as c ";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."don as d";
|
||||
$sql.= " WHERE d.rowid = '".$id."'";
|
||||
$sql.= " AND p.fk_donation = d.rowid";
|
||||
$sql.= " AND d.entity = ".$conf->entity;
|
||||
$sql.= " AND p.fk_typepayment = c.id";
|
||||
$sql.= " ORDER BY dp";
|
||||
|
||||
//print $sql;
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0; $total = 0;
|
||||
print '<table class="nobordernopadding" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans("RefPayment").'</td>';
|
||||
print '<td>'.$langs->trans("Date").'</td>';
|
||||
print '<td>'.$langs->trans("Type").'</td>';
|
||||
print '<td align="right">'.$langs->trans("Amount").'</td>';
|
||||
print '<td> </td>';
|
||||
print '</tr>';
|
||||
|
||||
$var=True;
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
$var=!$var;
|
||||
print "<tr ".$bc[$var]."><td>";
|
||||
print '<a href="'.DOL_URL_ROOT.'/don/payment/card.php?id='.$objp->rowid.'">'.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.'</a></td>';
|
||||
print '<td>'.dol_print_date($db->jdate($objp->dp),'day')."</td>\n";
|
||||
$labeltype=$langs->trans("PaymentType".$object->type_code)!=("PaymentType".$object->type_code)?$langs->trans("PaymentType".$object->type_code):$object->paiement_type;
|
||||
print "<td>".$labeltype.' '.$object->num_paiement."</td>\n";
|
||||
print '<td align="right">'.price($objp->amount)."</td><td> ".$langs->trans("Currency".$conf->currency)."</td>\n";
|
||||
print "</tr>";
|
||||
$totalpaid += $objp->amount;
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($object->paid == 0)
|
||||
{
|
||||
print "<tr><td colspan=\"2\" align=\"right\">".$langs->trans("AlreadyPaid")." :</td><td align=\"right\"><b>".price($totalpaid)."</b></td><td> ".$langs->trans("Currency".$conf->currency)."</td></tr>\n";
|
||||
print "<tr><td colspan=\"2\" align=\"right\">".$langs->trans("AmountExpected")." :</td><td align=\"right\" bgcolor=\"#d0d0d0\">".price($object->amount)."</td><td bgcolor=\"#d0d0d0\"> ".$langs->trans("Currency".$conf->currency)."</td></tr>\n";
|
||||
|
||||
$remaintopay = $object->amount - $totalpaid;
|
||||
|
||||
print "<tr><td colspan=\"2\" align=\"right\">".$langs->trans("RemainderToPay")." :</td>";
|
||||
print "<td align=\"right\" bgcolor=\"#f0f0f0\"><b>".price($remaintopay)."</b></td><td bgcolor=\"#f0f0f0\"> ".$langs->trans("Currency".$conf->currency)."</td></tr>\n";
|
||||
}
|
||||
print "</table>";
|
||||
$db->free($resql);
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
print "</td>";
|
||||
|
||||
print "</tr>";
|
||||
|
||||
// Zip / Town
|
||||
print '<tr><td>'.$langs->trans("Zip").' / '.$langs->trans("Town").'</td><td>';
|
||||
print $object->zip.($object->zip && $object->town?' / ':'').$object->town.'</td></tr>';
|
||||
|
||||
// Country
|
||||
print '<tr><td>'.$langs->trans('Country').'</td><td>';
|
||||
if (! empty($object->country_code))
|
||||
{
|
||||
$img=picto_from_langcode($object->country_code);
|
||||
print ($img?$img.' ':'');
|
||||
print $object->country;
|
||||
}
|
||||
else
|
||||
{
|
||||
print $object->country_olddata;
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// EMail
|
||||
print "<tr>".'<td>'.$langs->trans("EMail").'</td><td>'.dol_print_email($object->email).'</td></tr>';
|
||||
|
||||
// Payment mode
|
||||
print "<tr><td>".$langs->trans("PaymentMode")."</td><td>";
|
||||
$form->form_modes_reglement(null, $object->modepaymentid,'none');
|
||||
print "</td></tr>\n";
|
||||
|
||||
print "<tr>".'<td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
|
||||
|
||||
// Project
|
||||
if (! empty($conf->projet->enabled))
|
||||
{
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans("Project").'</td>';
|
||||
print '<td>'.$object->projet.'</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
$parameters=array('colspan' => ' colspan="2"');
|
||||
$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);
|
||||
}
|
||||
|
||||
print "</table>\n";
|
||||
print "</form>\n";
|
||||
|
||||
print "</div>";
|
||||
|
||||
$remaintopay = $object->amount - $totalpaid;
|
||||
|
||||
/**
|
||||
* Actions buttons
|
||||
*/
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
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 == 0)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?rowid='.$object->id.'&action=valid_promesse">'.$langs->trans("ValidPromess").'</a></div>';
|
||||
}
|
||||
|
||||
if (($object->statut == 0 || $object->statut == 1) && $remaintopay == 0 && $object->paye == 0)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?rowid='.$object->id.'&action=set_cancel">'.$langs->trans("ClassifyCanceled")."</a></div>";
|
||||
}
|
||||
|
||||
// Create payment
|
||||
if ($object->statut == 1 && $object->paid == 0 && $user->rights->don->creer)
|
||||
{
|
||||
if ($remaintopay == 0)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><span class="butActionRefused" title="' . $langs->trans("DisabledBecauseRemainderToPayIsZero") . '">' . $langs->trans('DoPayment') . '</span></div>';
|
||||
}
|
||||
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>';
|
||||
}
|
||||
}
|
||||
|
||||
// Classify 'paid'
|
||||
if ($object->statut == 1 && 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>";
|
||||
}
|
||||
|
||||
// Delete
|
||||
if ($user->rights->don->supprimer)
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?rowid='.$object->id.'&action=delete">'.$langs->trans("Delete")."</a></div>";
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butActionRefused" href="#">'.$langs->trans("Delete")."</a></div>";
|
||||
}
|
||||
|
||||
print "</div>";
|
||||
|
||||
|
||||
print '<table width="100%"><tr><td width="50%" valign="top">';
|
||||
|
||||
/*
|
||||
* Documents generes
|
||||
*/
|
||||
$filename=dol_sanitizeFileName($object->id);
|
||||
$filedir=$conf->don->dir_output . '/' . get_exdir($filename,2);
|
||||
$urlsource=$_SERVER['PHP_SELF'].'?rowid='.$object->id;
|
||||
// $genallowed=($fac->statut == 1 && ($fac->paye == 0 || $user->admin) && $user->rights->facture->creer);
|
||||
// $delallowed=$user->rights->facture->supprimer;
|
||||
$genallowed=1;
|
||||
$delallowed=0;
|
||||
|
||||
$var=true;
|
||||
|
||||
print '<br>';
|
||||
$formfile->show_documents('donation',$filename,$filedir,$urlsource,$genallowed,$delallowed);
|
||||
|
||||
print '</td><td> </td>';
|
||||
|
||||
print '</tr></table>';
|
||||
|
||||
}
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
@ -2,7 +2,8 @@
|
||||
/* Copyright (C) 2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2009 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* 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
|
||||
@ -19,9 +20,9 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/compta/dons/class/don.class.php
|
||||
* \ingroup don
|
||||
* \brief Fichier de la classe des dons
|
||||
* \file htdocs/don/class/don.class.php
|
||||
* \ingroup Donation
|
||||
* \brief File of class to manage donations
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
|
||||
@ -33,8 +34,10 @@ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
|
||||
*/
|
||||
class Don extends CommonObject
|
||||
{
|
||||
public $element='don';
|
||||
public $table_element='don';
|
||||
public $element='don'; // Id that identify managed objects
|
||||
public $table_element='don'; // Name of table without prefix where object is stored
|
||||
public $fk_element = 'fk_donation';
|
||||
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
||||
|
||||
var $id;
|
||||
var $ref;
|
||||
@ -46,6 +49,8 @@ class Don extends CommonObject
|
||||
var $address;
|
||||
var $zip;
|
||||
var $town;
|
||||
var $country_id;
|
||||
var $country_code;
|
||||
var $country;
|
||||
var $email;
|
||||
var $public;
|
||||
@ -296,14 +301,19 @@ class Don extends CommonObject
|
||||
/**
|
||||
* Create donation record into database
|
||||
*
|
||||
* @param User $user Objet utilisateur qui cree le don
|
||||
* @return int Id don cree si ok, <0 si ko
|
||||
* @param User $user User who created the donation
|
||||
* @param int $notrigger Disable triggers
|
||||
* @return int <0 if KO, id of created donation if OK
|
||||
* TODO add numbering module for Ref
|
||||
*/
|
||||
function create($user)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
global $conf, $langs;
|
||||
|
||||
$error = 0;
|
||||
$ret = 0;
|
||||
$now=dol_now();
|
||||
|
||||
// Clean parameters
|
||||
$this->address=($this->address>0?$this->address:$this->address);
|
||||
$this->zip=($this->zip>0?$this->zip:$this->zip);
|
||||
@ -311,24 +321,23 @@ class Don extends CommonObject
|
||||
$this->country_id=($this->country_id>0?$this->country_id:$this->country_id);
|
||||
$this->country=($this->country?$this->country:$this->country);
|
||||
|
||||
$now=dol_now();
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."don (";
|
||||
$sql.= "datec";
|
||||
$sql.= ", entity";
|
||||
$sql.= ", amount";
|
||||
$sql.= ", fk_paiement";
|
||||
$sql.= ", fk_payment";
|
||||
$sql.= ", firstname";
|
||||
$sql.= ", lastname";
|
||||
$sql.= ", societe";
|
||||
$sql.= ", address";
|
||||
$sql.= ", zip";
|
||||
$sql.= ", town";
|
||||
$sql.= ", country";
|
||||
// $sql.= ", country"; -- Deprecated
|
||||
$sql.= ", fk_country";
|
||||
$sql.= ", public";
|
||||
$sql.= ", fk_don_projet";
|
||||
$sql.= ", fk_project";
|
||||
$sql.= ", note_private";
|
||||
$sql.= ", note_public";
|
||||
$sql.= ", fk_user_author";
|
||||
@ -348,7 +357,7 @@ class Don extends CommonObject
|
||||
$sql.= ", '".$this->db->escape($this->address)."'";
|
||||
$sql.= ", '".$this->db->escape($this->zip)."'";
|
||||
$sql.= ", '".$this->db->escape($this->town)."'";
|
||||
$sql.= ", '".$this->db->escape($this->country)."'"; // TODO use country_id
|
||||
$sql.= ", ".$this->country_id;
|
||||
$sql.= ", ".$this->public;
|
||||
$sql.= ", ".($this->fk_project > 0?$this->fk_project:"null");
|
||||
$sql.= ", ".(!empty($this->note_private)?("'".$this->db->escape($this->note_private)."'"):"NULL");
|
||||
@ -361,24 +370,54 @@ class Don extends CommonObject
|
||||
$sql.= ", '".$this->db->escape($this->phone_mobile)."'";
|
||||
$sql.= ")";
|
||||
|
||||
dol_syslog("Don::create", LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
dol_syslog(get_class($this)."::create", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
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;
|
||||
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('DON_CREATE',$user);
|
||||
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
|
||||
// End call triggers
|
||||
if (!$notrigger)
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('DON_CREATE',$user);
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->errno = $this->db->lasterrno();
|
||||
$error++;
|
||||
}
|
||||
|
||||
// Update extrafield
|
||||
if (!$error) {
|
||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
|
||||
{
|
||||
$result=$this->insertExtraFields();
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error && !empty($conf->global->MAIN_DISABLEDRAFTSTATUS))
|
||||
{
|
||||
$res = $this->setValid($user);
|
||||
if ($res < 0) $error++;
|
||||
}
|
||||
|
||||
if (!$error)
|
||||
{
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
return $ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
dol_print_error($this->db);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -389,8 +428,12 @@ class Don extends CommonObject
|
||||
* @param User $user Objet utilisateur qui met a jour le don
|
||||
* @return int >0 if OK, <0 if KO
|
||||
*/
|
||||
function update($user)
|
||||
function update($user, $notrigger=0)
|
||||
{
|
||||
global $langs, $conf;
|
||||
|
||||
$error=0;
|
||||
|
||||
// Clean parameters
|
||||
$this->address=($this->address>0?$this->address:$this->address);
|
||||
$this->zip=($this->zip>0?$this->zip:$this->zip);
|
||||
@ -402,16 +445,16 @@ class Don extends CommonObject
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."don SET ";
|
||||
$sql .= "amount = " . price2num($this->amount);
|
||||
$sql .= ",fk_paiement = ".($this->modepaiementid?$this->modepaiementid:"null");
|
||||
$sql .= ",fk_payment = ".($this->modepaymentid?$this->modepaymentid:"null");
|
||||
$sql .= ",firstname = '".$this->db->escape($this->firstname)."'";
|
||||
$sql .= ",lastname='".$this->db->escape($this->lastname)."'";
|
||||
$sql .= ",societe='".$this->db->escape($this->societe)."'";
|
||||
$sql .= ",address='".$this->db->escape($this->address)."'";
|
||||
$sql .= ",zip='".$this->db->escape($this->zip)."'";
|
||||
$sql .= ",town='".$this->db->escape($this->town)."'";
|
||||
$sql .= ",country='".$this->db->escape($this->country)."'"; // TODO use country_id
|
||||
$sql .= ",fk_country = ".$this->country_id;
|
||||
$sql .= ",public=".$this->public;
|
||||
$sql .= ",fk_don_projet=".($this->fk_project>0?$this->fk_project:'null');
|
||||
$sql .= ",fk_project=".($this->fk_project>0?$this->fk_project:'null');
|
||||
$sql .= ",note_private=".(!empty($this->note_private)?("'".$this->db->escape($this->note_private)."'"):"NULL");
|
||||
$sql .= ",note_public=".(!empty($this->note_public)?("'".$this->db->escape($this->note_public)."'"):"NULL");
|
||||
$sql .= ",datedon='".$this->db->idate($this->date)."'";
|
||||
@ -419,63 +462,126 @@ class Don extends CommonObject
|
||||
$sql .= ",phone='".$this->phone."'";
|
||||
$sql .= ",phone_mobile='".$this->phone_mobile."'";
|
||||
$sql .= ",fk_statut=".$this->statut;
|
||||
$sql .= " WHERE rowid = $this->id";
|
||||
|
||||
dol_syslog("Don::update", LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('DON_UPDATE',$user);
|
||||
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
|
||||
// End call triggers
|
||||
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
dol_print_error($this->db);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a donation
|
||||
*
|
||||
* @param int $rowid Id of donation to delete
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function delete($rowid)
|
||||
{
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."don WHERE rowid = $rowid AND fk_statut = 0;";
|
||||
$sql .= " WHERE rowid = '".$this->id."'";
|
||||
|
||||
dol_syslog(get_class($this)."::Update", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ( $this->db->affected_rows($resql) )
|
||||
if (!$notrigger)
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('DON_DELETE',$user);
|
||||
if ($result < 0) { $error++; $this->db->rollback(); return -1; }
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('DON_MODIFY',$user);
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
|
||||
// Update extrafield
|
||||
if (!$error)
|
||||
{
|
||||
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
|
||||
{
|
||||
$result=$this->insertExtraFields();
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error )
|
||||
{
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
$result = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
$result = -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->errors[] = $this->error;
|
||||
$this->db->rollback();
|
||||
dol_syslog(get_class($this)."::Update error -2 " . $this->error, LOG_ERR);
|
||||
$result = -2;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a donation from database
|
||||
*
|
||||
* @param User $user User
|
||||
* @param int $notrigger Disable triggers
|
||||
* @return int <0 if KO, 0 if not possible, >0 if OK
|
||||
*/
|
||||
function delete($user, $notrigger=0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
|
||||
|
||||
$error = 0;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// Delete donation
|
||||
if (! $error)
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "don";
|
||||
$sql.= " WHERE rowid=" . $this->id;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (!$resql)
|
||||
{
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "don_extrafields";
|
||||
$sql.= " WHERE fk_object=" . $this->id;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql)
|
||||
{
|
||||
$this->errors[] = $this->db->lasterror();
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
if (!$notrigger)
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('DON_DELETE',$user);
|
||||
|
||||
if ($result < 0) {
|
||||
$error++;
|
||||
}
|
||||
// End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ( $this->errors as $errmsg )
|
||||
{
|
||||
dol_syslog(get_class($this) . "::delete " . $errmsg, LOG_ERR);
|
||||
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
|
||||
}
|
||||
dol_syslog(get_class($this) . "::delete " . $this->error, LOG_ERR);
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -487,19 +593,29 @@ class Don extends CommonObject
|
||||
* @param string $ref Ref of donation to load
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function fetch($rowid,$ref='')
|
||||
function fetch($id,$ref='')
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$sql = "SELECT d.rowid, d.datec, d.tms as datem, d.datedon,";
|
||||
$sql.= " d.firstname, d.lastname, d.societe, d.amount, d.fk_statut, d.address, d.zip, d.town, ";
|
||||
$sql.= " d.country, d.public, d.amount, d.fk_paiement, d.note_private, d.note_public, cp.libelle, d.email, d.phone, ";
|
||||
$sql.= " d.phone_mobile, d.fk_don_projet,";
|
||||
$sql.= " p.title as project_label";
|
||||
$sql.= " d.fk_country, d.country as country_olddata, d.public, d.amount, d.fk_payment, d.paid, d.note_private, d.note_public, cp.libelle, d.email, d.phone, ";
|
||||
$sql.= " d.phone_mobile, d.fk_project,";
|
||||
$sql.= " p.title as project_label,";
|
||||
$sql.= " c.code as country_code, c.label as country";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."don as d";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = d.fk_don_projet";
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON cp.id = d.fk_paiement";
|
||||
$sql.= " WHERE d.rowid = ".$rowid." AND d.entity = ".$conf->entity;
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet as p ON p.rowid = d.fk_project";
|
||||
$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";
|
||||
if (! empty($id))
|
||||
{
|
||||
$sql.= " WHERE d.rowid=".$id;
|
||||
}
|
||||
else if (! empty($ref))
|
||||
{
|
||||
$sql.= " WHERE ref='".$this->db->escape($ref)."'";
|
||||
}
|
||||
$sql.= " AND d.entity = ".$conf->entity;
|
||||
|
||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
@ -522,19 +638,30 @@ class Don extends CommonObject
|
||||
$this->town = $obj->town;
|
||||
$this->zip = $obj->zip;
|
||||
$this->town = $obj->town;
|
||||
$this->country_id = $obj->country_id;
|
||||
$this->country_code = $obj->country_code;
|
||||
$this->country = $obj->country;
|
||||
$this->email = $obj->email;
|
||||
$this->country_olddata= $obj->country_olddata; // deprecated
|
||||
$this->email = $obj->email;
|
||||
$this->phone = $obj->phone;
|
||||
$this->phone_mobile = $obj->phone_mobile;
|
||||
$this->projet = $obj->project_label;
|
||||
$this->fk_project = $obj->fk_don_projet;
|
||||
$this->project = $obj->project_label;
|
||||
$this->fk_project = $obj->fk_project;
|
||||
$this->public = $obj->public;
|
||||
$this->modepaiementid = $obj->fk_paiement;
|
||||
$this->modepaiement = $obj->libelle;
|
||||
$this->modepaymentid = $obj->fk_payment;
|
||||
$this->modepayment = $obj->libelle;
|
||||
$this->paid = $obj->paid;
|
||||
$this->amount = $obj->amount;
|
||||
$this->note_private = $obj->note_private;
|
||||
$this->note_public = $obj->note_public;
|
||||
$this->commentaire = $obj->note; // deprecated
|
||||
|
||||
// Retrieve all extrafield for thirdparty
|
||||
// fetch optionals attributes and labels
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
$extrafields=new ExtraFields($this->db);
|
||||
$extralabels=$extrafields->fetch_name_optionals_label($this->table_element,true);
|
||||
$this->fetch_optionals($this->id,$extralabels);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
@ -547,16 +674,16 @@ class Don extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Valide une promesse de don
|
||||
* Validate a promise of donation
|
||||
*
|
||||
* @param int $rowid id du don a modifier
|
||||
* @param int $userid utilisateur qui valide la promesse
|
||||
* @param int $rowid id of donation
|
||||
* @param int $userid User who validate the promise
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function valid_promesse($rowid, $userid)
|
||||
function valid_promesse($id, $userid)
|
||||
{
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 1, fk_user_valid = $userid WHERE rowid = $rowid 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);
|
||||
if ($resql)
|
||||
@ -584,14 +711,14 @@ class Don extends CommonObject
|
||||
* @param int $modepaiement mode de paiement
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function set_paye($rowid, $modepaiement='')
|
||||
function set_paid($id, $modepaiement='')
|
||||
{
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 2";
|
||||
if ($modepaiement)
|
||||
{
|
||||
$sql .= ", fk_paiement=$modepaiement";
|
||||
$sql .= ", fk_payment=$modepayment";
|
||||
}
|
||||
$sql .= " WHERE rowid = $rowid AND fk_statut = 1";
|
||||
$sql .= " WHERE rowid = $id AND fk_statut = 1";
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
@ -612,17 +739,15 @@ class Don extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Classe le don comme encaisse
|
||||
* Set donation to status canceled
|
||||
*
|
||||
* @param int $rowid id du don a modifier
|
||||
* @param int $rowid id of donation
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function set_encaisse($rowid)
|
||||
function set_cancel($id)
|
||||
{
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 3 WHERE rowid = $rowid AND fk_statut = 2";
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = -1 WHERE rowid = ".$id;
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
@ -644,36 +769,7 @@ class Don extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Set donation sto status canceled
|
||||
*
|
||||
* @param int $rowid id du don a modifier
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function set_cancel($rowid)
|
||||
{
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = -1 WHERE rowid = ".$rowid;
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ( $this->db->affected_rows($resql) )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Somme des dons
|
||||
* Sum of donations
|
||||
*
|
||||
* @param string $param 1=promesses de dons validees , 2=xxx, 3=encaisses
|
||||
* @return int Summ of donations
|
||||
@ -713,7 +809,7 @@ class Don extends CommonObject
|
||||
$result='';
|
||||
$label=$langs->trans("ShowDonation").': '.$this->id;
|
||||
|
||||
$link = '<a href="'.DOL_URL_ROOT.'/compta/dons/card.php?rowid='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
|
||||
$link = '<a href="'.DOL_URL_ROOT.'/don/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
|
||||
$linkend='</a>';
|
||||
|
||||
$picto='generic';
|
||||
@ -724,5 +820,50 @@ class Don extends CommonObject
|
||||
if ($withpicto != 2) $result.=$link.$this->id.$linkend;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Information on record
|
||||
*
|
||||
* @param int $id Id of record
|
||||
* @return void
|
||||
*/
|
||||
function info($id)
|
||||
{
|
||||
$sql = 'SELECT d.rowid, d.datec, d.fk_user_author, d.fk_user_valid,';
|
||||
$sql.= ' d.tms';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'don as d';
|
||||
$sql.= ' WHERE d.rowid = '.$id;
|
||||
|
||||
dol_syslog(get_class($this).'::info', LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
|
||||
if ($result)
|
||||
{
|
||||
if ($this->db->num_rows($result))
|
||||
{
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$this->id = $obj->rowid;
|
||||
if ($obj->fk_user_author)
|
||||
{
|
||||
$cuser = new User($this->db);
|
||||
$cuser->fetch($obj->fk_user_author);
|
||||
$this->user_creation = $cuser;
|
||||
}
|
||||
if ($obj->fk_user_valid)
|
||||
{
|
||||
$vuser = new User($this->db);
|
||||
$vuser->fetch($obj->fk_user_valid);
|
||||
$this->user_modification = $vuser;
|
||||
}
|
||||
$this->date_creation = $this->db->jdate($obj->datec);
|
||||
$this->date_modification = $this->db->jdate($obj->tms);
|
||||
}
|
||||
$this->db->free($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
133
htdocs/don/class/donstats.class.php
Normal file
133
htdocs/don/class/donstats.class.php
Normal file
@ -0,0 +1,133 @@
|
||||
<?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/don/class/dontats.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 . '/don/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 d";
|
||||
//$this->from.= ", ".MAIN_DB_PREFIX."societe as s";
|
||||
//$this->field='weight'; // Warning, unit of weight is NOT USED AND MUST BE
|
||||
$this->where.= " d.fk_statut > 0"; // Not draft and not cancelled
|
||||
|
||||
//$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity;
|
||||
$this->where.= " AND d.entity = ".$conf->entity;
|
||||
if ($this->userid > 0) $this->where.=' WHERE 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(d.datedon,'%m') as dm, COUNT(*) as nb";
|
||||
$sql.= " FROM ".$this->from;
|
||||
$sql.= " WHERE d.datedon 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(d.datedon,'%Y') as dm, COUNT(*) as nb, SUM(d.".$this->field.")";
|
||||
$sql.= " FROM ".$this->from;
|
||||
$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(d.datedon,'%Y') as year, COUNT(*) as nb, SUM(d.".$this->field.") as total, AVG(".$this->field.") as avg";
|
||||
$sql.= " FROM ".$this->from;
|
||||
$sql.= " WHERE ".$this->where;
|
||||
$sql.= " GROUP BY year";
|
||||
$sql.= $this->db->order('year','DESC');
|
||||
|
||||
return $this->_getAllByYear($sql);
|
||||
}
|
||||
}
|
||||
0
htdocs/don/class/index.html
Normal file
0
htdocs/don/class/index.html
Normal file
593
htdocs/don/class/paymentdonation.class.php
Normal file
593
htdocs/don/class/paymentdonation.class.php
Normal file
@ -0,0 +1,593 @@
|
||||
<?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/don/class/paymentdonation.class.php
|
||||
* \ingroup Donation
|
||||
* \brief File of class to manage payment of donations
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
|
||||
|
||||
|
||||
/** \class PaymentDonation
|
||||
* \brief Class to manage payments of donations
|
||||
*/
|
||||
class PaymentDonation extends CommonObject
|
||||
{
|
||||
public $element='payment_donation'; //!< Id that identify managed objects
|
||||
public $table_element='payment_donation'; //!< Name of table without prefix where object is stored
|
||||
|
||||
var $id;
|
||||
var $rowid;
|
||||
var $ref;
|
||||
|
||||
var $fk_donation;
|
||||
var $datec='';
|
||||
var $tms='';
|
||||
var $datep='';
|
||||
var $amount; // Total amount of payment
|
||||
var $amounts=array(); // Array of amounts
|
||||
var $fk_typepayment;
|
||||
var $num_payment;
|
||||
var $note;
|
||||
var $fk_bank;
|
||||
var $fk_user_creat;
|
||||
var $fk_user_modif;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
function __construct($db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create payment of donation into database.
|
||||
* Use this->amounts to have list of lines for the payment
|
||||
*
|
||||
* @param User $user User making payment
|
||||
* @return int <0 if KO, id of payment if OK
|
||||
*/
|
||||
function create($user)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
$error=0;
|
||||
|
||||
$now=dol_now();
|
||||
|
||||
// Validate parameters
|
||||
if (! $this->datepaid)
|
||||
{
|
||||
$this->error='ErrorBadValueForParameterCreatePaymentDonation';
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Clean parameters
|
||||
if (isset($this->fk_donation)) $this->fk_donation=trim($this->fk_donation);
|
||||
if (isset($this->amount)) $this->amount=trim($this->amount);
|
||||
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->note)) $this->note=trim($this->note);
|
||||
if (isset($this->fk_bank)) $this->fk_bank=trim($this->fk_bank);
|
||||
if (isset($this->fk_user_creat)) $this->fk_user_creat=trim($this->fk_user_creat);
|
||||
if (isset($this->fk_user_modif)) $this->fk_user_modif=trim($this->fk_user_modif);
|
||||
|
||||
$totalamount = 0;
|
||||
foreach ($this->amounts as $key => $value) // How payment is dispatch
|
||||
{
|
||||
$newvalue = price2num($value,'MT');
|
||||
$this->amounts[$key] = $newvalue;
|
||||
$totalamount += $newvalue;
|
||||
}
|
||||
$totalamount = price2num($totalamount);
|
||||
|
||||
// Check parameters
|
||||
if ($totalamount == 0) return -1; // On accepte les montants negatifs pour les rejets de prelevement mais pas null
|
||||
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
if ($totalamount != 0)
|
||||
{
|
||||
$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.= " VALUES ($this->chid, '".$this->db->idate($now)."',";
|
||||
$sql.= " '".$this->db->idate($this->datepaid)."',";
|
||||
$sql.= " ".$totalamount.",";
|
||||
$sql.= " ".$this->paymenttype.", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note)."', ".$user->id.",";
|
||||
$sql.= " 0)";
|
||||
|
||||
dol_syslog(get_class($this)."::create", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_donation");
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($totalamount != 0 && ! $error)
|
||||
{
|
||||
$this->amount=$totalamount;
|
||||
$this->total=$totalamount; // deprecated
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load object in memory from database
|
||||
*
|
||||
* @param int $id Id object
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function fetch($id)
|
||||
{
|
||||
global $langs;
|
||||
$sql = "SELECT";
|
||||
$sql.= " t.rowid,";
|
||||
$sql.= " t.fk_donation,";
|
||||
$sql.= " t.datec,";
|
||||
$sql.= " t.tms,";
|
||||
$sql.= " t.datep,";
|
||||
$sql.= " t.amount,";
|
||||
$sql.= " t.fk_typepayment,";
|
||||
$sql.= " t.num_payment,";
|
||||
$sql.= " t.note,";
|
||||
$sql.= " t.fk_bank,";
|
||||
$sql.= " t.fk_user_creat,";
|
||||
$sql.= " t.fk_user_modif,";
|
||||
$sql.= " pt.code as type_code, pt.libelle as type_libelle,";
|
||||
$sql.= ' b.fk_account';
|
||||
$sql.= " FROM (".MAIN_DB_PREFIX."c_paiement as pt, ".MAIN_DB_PREFIX."payment_donation as t)";
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid';
|
||||
$sql.= " WHERE t.rowid = ".$id." AND t.fk_typepayment = pt.id";
|
||||
|
||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
if ($this->db->num_rows($resql))
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
$this->ref = $obj->rowid;
|
||||
|
||||
$this->fk_donation = $obj->fk_donation;
|
||||
$this->datec = $this->db->jdate($obj->datec);
|
||||
$this->tms = $this->db->jdate($obj->tms);
|
||||
$this->datep = $this->db->jdate($obj->datep);
|
||||
$this->amount = $obj->amount;
|
||||
$this->fk_typepayment = $obj->fk_typepayment;
|
||||
$this->num_payment = $obj->num_payment;
|
||||
$this->note = $obj->note;
|
||||
$this->fk_bank = $obj->fk_bank;
|
||||
$this->fk_user_creat = $obj->fk_user_creat;
|
||||
$this->fk_user_modif = $obj->fk_user_modif;
|
||||
|
||||
$this->type_code = $obj->type_code;
|
||||
$this->type_libelle = $obj->type_libelle;
|
||||
|
||||
$this->bank_account = $obj->fk_account;
|
||||
$this->bank_line = $obj->fk_bank;
|
||||
}
|
||||
$this->db->free($resql);
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error="Error ".$this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update database
|
||||
*
|
||||
* @param User $user User that modify
|
||||
* @param int $notrigger 0=launch triggers after, 1=disable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function update($user=null, $notrigger=0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
$error=0;
|
||||
|
||||
// Clean parameters
|
||||
|
||||
if (isset($this->fk_donation)) $this->fk_donation=trim($this->fk_donation);
|
||||
if (isset($this->amount)) $this->amount=trim($this->amount);
|
||||
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->note)) $this->note=trim($this->note);
|
||||
if (isset($this->fk_bank)) $this->fk_bank=trim($this->fk_bank);
|
||||
if (isset($this->fk_user_creat)) $this->fk_user_creat=trim($this->fk_user_creat);
|
||||
if (isset($this->fk_user_modif)) $this->fk_user_modif=trim($this->fk_user_modif);
|
||||
|
||||
|
||||
|
||||
// Check parameters
|
||||
// Put here code to add control on parameters values
|
||||
|
||||
// Update request
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."payment_donation SET";
|
||||
|
||||
$sql.= " fk_donation=".(isset($this->fk_donation)?$this->fk_donation:"null").",";
|
||||
$sql.= " datec=".(dol_strlen($this->datec)!=0 ? "'".$this->db->idate($this->datec)."'" : 'null').",";
|
||||
$sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').",";
|
||||
$sql.= " datep=".(dol_strlen($this->datep)!=0 ? "'".$this->db->idate($this->datep)."'" : 'null').",";
|
||||
$sql.= " amount=".(isset($this->amount)?$this->amount:"null").",";
|
||||
$sql.= " fk_typepayment=".(isset($this->fk_typepayment)?$this->fk_typepayment:"null").",";
|
||||
$sql.= " num_payment=".(isset($this->num_payment)?"'".$this->db->escape($this->num_payment)."'":"null").",";
|
||||
$sql.= " note=".(isset($this->note)?"'".$this->db->escape($this->note)."'":"null").",";
|
||||
$sql.= " fk_bank=".(isset($this->fk_bank)?$this->fk_bank:"null").",";
|
||||
$sql.= " fk_user_creat=".(isset($this->fk_user_creat)?$this->fk_user_creat:"null").",";
|
||||
$sql.= " fk_user_modif=".(isset($this->fk_user_modif)?$this->fk_user_modif:"null")."";
|
||||
|
||||
|
||||
$sql.= " WHERE rowid=".$this->id;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
if (! $notrigger)
|
||||
{
|
||||
// Uncomment this and change MYOBJECT to your own tag if you
|
||||
// want this action call a trigger.
|
||||
|
||||
//// Call triggers
|
||||
//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||
//$interface=new Interfaces($this->db);
|
||||
//$result=$interface->run_triggers('MYOBJECT_MODIFY',$this,$user,$langs,$conf);
|
||||
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||
//// End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
foreach($this->errors as $errmsg)
|
||||
{
|
||||
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
|
||||
$this->error.=($this->error?', '.$errmsg:$errmsg);
|
||||
}
|
||||
$this->db->rollback();
|
||||
return -1*$error;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete object in database
|
||||
*
|
||||
* @param User $user User that delete
|
||||
* @param int $notrigger 0=launch triggers after, 1=disable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function delete($user, $notrigger=0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
$error=0;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url";
|
||||
$sql.= " WHERE type='payment_donation' AND url_id=".$this->id;
|
||||
|
||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_donation";
|
||||
$sql.= " WHERE rowid=".$this->id;
|
||||
|
||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
if (! $notrigger)
|
||||
{
|
||||
// Uncomment this and change MYOBJECT to your own tag if you
|
||||
// want this action call a trigger.
|
||||
|
||||
//// Call triggers
|
||||
//include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||
//$interface=new Interfaces($this->db);
|
||||
//$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
|
||||
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||
//// End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
foreach($this->errors as $errmsg)
|
||||
{
|
||||
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
|
||||
$this->error.=($this->error?', '.$errmsg:$errmsg);
|
||||
}
|
||||
$this->db->rollback();
|
||||
return -1*$error;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Load an object from its id and create a new one in database
|
||||
*
|
||||
* @param int $fromid Id of object to clone
|
||||
* @return int New id of clone
|
||||
*/
|
||||
function createFromClone($fromid)
|
||||
{
|
||||
global $user,$langs;
|
||||
|
||||
$error=0;
|
||||
|
||||
$object=new PaymentDonation($this->db);
|
||||
|
||||
$object->context['createfromclone'] = 'createfromclone';
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
// Load source object
|
||||
$object->fetch($fromid);
|
||||
$object->id=0;
|
||||
$object->statut=0;
|
||||
|
||||
// Clear fields
|
||||
// ...
|
||||
|
||||
// Create clone
|
||||
$result=$object->create($user);
|
||||
|
||||
// Other options
|
||||
if ($result < 0)
|
||||
{
|
||||
$this->error=$object->error;
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
unset($this->context['createfromclone']);
|
||||
|
||||
// End
|
||||
if (! $error)
|
||||
{
|
||||
$this->db->commit();
|
||||
return $object->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialise an instance with random values.
|
||||
* Used to build previews or test instances.
|
||||
* id must be 0 if object instance is a specimen.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function initAsSpecimen()
|
||||
{
|
||||
$this->id=0;
|
||||
|
||||
$this->fk_donation='';
|
||||
$this->datec='';
|
||||
$this->tms='';
|
||||
$this->datep='';
|
||||
$this->amount='';
|
||||
$this->fk_typepayment='';
|
||||
$this->num_payment='';
|
||||
$this->note='';
|
||||
$this->fk_bank='';
|
||||
$this->fk_user_creat='';
|
||||
$this->fk_user_modif='';
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add record into bank for payment with links between this bank record and invoices of payment.
|
||||
* All payment properties must have been set first like after a call to create().
|
||||
*
|
||||
* @param User $user Object of user making payment
|
||||
* @param string $mode 'payment_donation'
|
||||
* @param string $label Label to use in bank record
|
||||
* @param int $accountid Id of bank account to do link with
|
||||
* @param string $emetteur_nom Name of transmitter
|
||||
* @param string $emetteur_banque Name of bank
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function addPaymentToBank($user,$mode,$label,$accountid,$emetteur_nom,$emetteur_banque)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$error=0;
|
||||
|
||||
if (! empty($conf->banque->enabled))
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
|
||||
$acc = new Account($this->db);
|
||||
$acc->fetch($accountid);
|
||||
|
||||
$total=$this->total;
|
||||
if ($mode == 'payment_donation') $amount=$total;
|
||||
|
||||
// Insert payment into llx_bank
|
||||
$bank_line_id = $acc->addline(
|
||||
$this->datepaid,
|
||||
$this->paymenttype, // Payment mode id or code ("CHQ or VIR for example")
|
||||
$label,
|
||||
$amount,
|
||||
$this->num_payment,
|
||||
'',
|
||||
$user,
|
||||
$emetteur_nom,
|
||||
$emetteur_banque
|
||||
);
|
||||
|
||||
// Update fk_bank in llx_paiement.
|
||||
// On connait ainsi le paiement qui a genere l'ecriture bancaire
|
||||
if ($bank_line_id > 0)
|
||||
{
|
||||
$result=$this->update_fk_bank($bank_line_id);
|
||||
if ($result <= 0)
|
||||
{
|
||||
$error++;
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
|
||||
// Add link 'payment', 'payment_supplier', 'payment_donation' in bank_url between payment and bank transaction
|
||||
$url='';
|
||||
if ($mode == 'payment_donation') $url=DOL_URL_ROOT.'/don/payment/card.php?rowid=';
|
||||
if ($url)
|
||||
{
|
||||
$result=$acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode);
|
||||
if ($result <= 0)
|
||||
{
|
||||
$error++;
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$acc->error;
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update link between the donation payment and the generated line in llx_bank
|
||||
*
|
||||
* @param int $id_bank Id if bank
|
||||
* @return int >0 if OK, <=0 if KO
|
||||
*/
|
||||
function update_fk_bank($id_bank)
|
||||
{
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."payment_donation SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id;
|
||||
|
||||
dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return clicable name (with picto eventually)
|
||||
*
|
||||
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
|
||||
* @param int $maxlen Longueur max libelle
|
||||
* @return string Chaine avec URL
|
||||
*/
|
||||
function getNomUrl($withpicto=0,$maxlen=0)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$result='';
|
||||
|
||||
if (empty($this->ref)) $this->ref=$this->lib;
|
||||
$label = $langs->trans("ShowPayment").': '.$this->ref;
|
||||
|
||||
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">';
|
||||
$linkend='</a>';
|
||||
|
||||
if ($withpicto) $result.=($link.img_object($label, 'payment', 'class="classfortooltip"').$linkend.' ');
|
||||
if ($withpicto && $withpicto != 2) $result.=' ';
|
||||
if ($withpicto != 2) $result.=$link.($maxlen?dol_trunc($this->ref,$maxlen):$this->ref).$linkend;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
0
htdocs/don/index.html
Normal file
0
htdocs/don/index.html
Normal file
@ -18,13 +18,13 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/compta/dons/index.php
|
||||
* \ingroup don
|
||||
* \brief Home page of donation module
|
||||
* \file htdocs/don/index.php
|
||||
* \ingroup donations
|
||||
* \brief Home page of donation module
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/dons/class/don.class.php';
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
|
||||
|
||||
$langs->load("donations");
|
||||
|
||||
62
htdocs/don/info.php
Normal file
62
htdocs/don/info.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?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/don/info.php
|
||||
* \ingroup donations
|
||||
* \brief Page to show a donation information
|
||||
*/
|
||||
|
||||
require '../main.inc.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.'/don/class/don.class.php';
|
||||
|
||||
$langs->load("donations");
|
||||
|
||||
// Security check
|
||||
$id = GETPOST('id','int');
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
$result = restrictedArea($user, 'don', $id, '');
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader();
|
||||
|
||||
if ($id)
|
||||
{
|
||||
$object = new Don($db);
|
||||
$object->fetch($id);
|
||||
$object->info($id);
|
||||
|
||||
$head = donation_prepare_head($object);
|
||||
|
||||
dol_fiche_head($head, 'info', $langs->trans("Donation"), 0, 'bill');
|
||||
|
||||
print '<table width="100%"><tr><td>';
|
||||
dol_print_object_info($object);
|
||||
print '</td></tr></table>';
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter();
|
||||
@ -19,13 +19,13 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/compta/dons/list.php
|
||||
* \ingroup don
|
||||
* \brief Page de liste des dons
|
||||
* \file htdocs/don/list.php
|
||||
* \ingroup donations
|
||||
* \brief List of donations
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/dons/class/don.class.php';
|
||||
require '../main.inc.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';
|
||||
|
||||
$langs->load("companies");
|
||||
@ -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.= " 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.= " ON p.rowid = d.fk_don_projet WHERE 1 = 1";
|
||||
$sql.= " ON p.rowid = d.fk_project WHERE 1 = 1";
|
||||
if ($statut >= 0)
|
||||
{
|
||||
$sql .= " AND d.fk_statut = ".$statut;
|
||||
@ -125,7 +125,7 @@ if ($resql)
|
||||
if (! empty($conf->projet->enabled))
|
||||
{
|
||||
$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("Status"),$_SERVER["PHP_SELF"],"d.fk_statut","&page=$page&statut=$statut","",'align="right"',$sortfield,$sortorder);
|
||||
303
htdocs/don/payment/card.php
Normal file
303
htdocs/don/payment/card.php
Normal file
@ -0,0 +1,303 @@
|
||||
<?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/don/payment/card.php
|
||||
* \ingroup donations
|
||||
* \brief Tab payment of a donation
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
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.'/compta/facture/class/facture.class.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';
|
||||
|
||||
$langs->load('bills');
|
||||
$langs->load('banks');
|
||||
$langs->load('companies');
|
||||
|
||||
// Security check
|
||||
$id=GETPOST("id");
|
||||
$action=GETPOST("action");
|
||||
$confirm=GETPOST('confirm');
|
||||
if ($user->societe_id) $socid=$user->societe_id;
|
||||
// TODO Add rule to restrict access payment
|
||||
//$result = restrictedArea($user, 'facture', $id,'');
|
||||
|
||||
$payment = new PaymentDonation($db);
|
||||
if ($id > 0)
|
||||
{
|
||||
$result=$payment->fetch($id);
|
||||
if (! $result) dol_print_error($db,'Failed to get payment id '.$id);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
// Delete payment
|
||||
if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->don->supprimer)
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
$result = $payment->delete($user);
|
||||
if ($result > 0)
|
||||
{
|
||||
$db->commit();
|
||||
header("Location: ".DOL_URL_ROOT."/don/index.php");
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessage($payment->error, 'errors');
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
|
||||
// Create payment
|
||||
if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->don->creer)
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
$result=$payment->valide();
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
$db->commit();
|
||||
|
||||
$factures=array(); // TODO Get all id of invoices linked to this payment
|
||||
foreach($factures as $id)
|
||||
{
|
||||
$fac = new Facture($db);
|
||||
$fac->fetch($id);
|
||||
|
||||
$outputlangs = $langs;
|
||||
if (! empty($_REQUEST['lang_id']))
|
||||
{
|
||||
$outputlangs = new Translate("",$conf);
|
||||
$outputlangs->setDefaultLang($_REQUEST['lang_id']);
|
||||
}
|
||||
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
|
||||
$fac->generateDocument($fac->modelpdf, $outputlangs);
|
||||
}
|
||||
}
|
||||
|
||||
header('Location: card.php?id='.$payment->id);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessage($payment->error);
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader();
|
||||
|
||||
$don = new Don($db);
|
||||
$form = new Form($db);
|
||||
|
||||
$h=0;
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/don/payment/card.php?id='.$id;
|
||||
$head[$h][1] = $langs->trans("Card");
|
||||
$hselected = $h;
|
||||
$h++;
|
||||
|
||||
dol_fiche_head($head, $hselected, $langs->trans("DonationPayment"), 0, 'payment');
|
||||
|
||||
/*
|
||||
* Confirmation de la suppression du paiement
|
||||
*/
|
||||
if ($action == 'delete')
|
||||
{
|
||||
print $form->formconfirm('card.php?id='.$payment->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete','',0,2);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Confirmation de la validation du paiement
|
||||
*/
|
||||
if ($action == 'valide')
|
||||
{
|
||||
$facid = $_GET['facid'];
|
||||
print $form->formconfirm('card.php?id='.$payment->id.'&facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide','',0,2);
|
||||
|
||||
}
|
||||
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Ref
|
||||
print '<tr><td valign="top" width="20%">'.$langs->trans('Ref').'</td>';
|
||||
print '<td colspan="3">';
|
||||
print $form->showrefnav($payment,'id','',1,'rowid','id');
|
||||
print '</td></tr>';
|
||||
|
||||
// Date
|
||||
print '<tr><td valign="top">'.$langs->trans('Date').'</td><td colspan="3">'.dol_print_date($payment->datep,'day').'</td></tr>';
|
||||
|
||||
// Mode
|
||||
print '<tr><td valign="top">'.$langs->trans('Mode').'</td><td colspan="3">'.$langs->trans("PaymentType".$payment->type_code).'</td></tr>';
|
||||
|
||||
// Number
|
||||
print '<tr><td valign="top">'.$langs->trans('Number').'</td><td colspan="3">'.$payment->num_payment.'</td></tr>';
|
||||
|
||||
// Amount
|
||||
print '<tr><td valign="top">'.$langs->trans('Amount').'</td><td colspan="3">'.price($payment->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'</td></tr>';
|
||||
|
||||
// Note
|
||||
print '<tr><td valign="top">'.$langs->trans('Note').'</td><td colspan="3">'.nl2br($payment->note).'</td></tr>';
|
||||
|
||||
// Bank account
|
||||
if (! empty($conf->banque->enabled))
|
||||
{
|
||||
if ($payment->bank_account)
|
||||
{
|
||||
$bankline=new AccountLine($db);
|
||||
$bankline->fetch($payment->bank_line);
|
||||
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans('BankTransactionLine').'</td>';
|
||||
print '<td colspan="3">';
|
||||
print $bankline->getNomUrl(1,0,'showall');
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
|
||||
/*
|
||||
* List of donations payed
|
||||
*/
|
||||
|
||||
$disable_delete = 0;
|
||||
$sql = 'SELECT d.rowid as did, d.paid, d.amount as d_amount, pd.amount';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'payment_donation as pd,'.MAIN_DB_PREFIX.'don as d';
|
||||
$sql.= ' WHERE pd.fk_donation = d.rowid';
|
||||
$sql.= ' AND d.entity = '.$conf->entity;
|
||||
$sql.= ' AND pd.rowid = '.$id;
|
||||
|
||||
dol_syslog("donations/payment/card.php", LOG_DEBUG);
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
$i = 0;
|
||||
$total = 0;
|
||||
print '<br><table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td>'.$langs->trans('Donation').'</td>';
|
||||
print '<td align="right">'.$langs->trans('ExpectedToPay').'</td>';
|
||||
print '<td align="center">'.$langs->trans('Status').'</td>';
|
||||
print '<td align="right">'.$langs->trans('PayedByThisPayment').'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
if ($num > 0)
|
||||
{
|
||||
$var=True;
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $db->fetch_object($resql);
|
||||
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
// Ref
|
||||
print '<td>';
|
||||
$don->fetch($objp->did);
|
||||
print $don->getNomUrl(1);
|
||||
print "</td>\n";
|
||||
// Expected to pay
|
||||
print '<td align="right">'.price($objp->d_amount).'</td>';
|
||||
// Status
|
||||
print '<td align="center">'.$don->getLibStatut(4,$objp->amount).'</td>';
|
||||
// Amount payed
|
||||
print '<td align="right">'.price($objp->amount).'</td>';
|
||||
print "</tr>\n";
|
||||
if ($objp->paid == 1) // If at least one invoice is paid, disable delete
|
||||
{
|
||||
$disable_delete = 1;
|
||||
}
|
||||
$total = $total + $objp->amount;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$var=!$var;
|
||||
|
||||
print "</table>\n";
|
||||
$db->free($resql);
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
|
||||
|
||||
/*
|
||||
* Boutons Actions
|
||||
*/
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
/*
|
||||
if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))
|
||||
{
|
||||
if ($user->societe_id == 0 && $payment->statut == 0 && $_GET['action'] == '')
|
||||
{
|
||||
if ($user->rights->facture->paiement)
|
||||
{
|
||||
print '<a class="butAction" href="card.php?id='.$_GET['id'].'&facid='.$objp->facid.'&action=valide">'.$langs->trans('Valid').'</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
if ($_GET['action'] == '')
|
||||
{
|
||||
if ($user->rights->don->supprimer)
|
||||
{
|
||||
if (! $disable_delete)
|
||||
{
|
||||
print '<a class="butActionDelete" href="card.php?id='.$_GET['id'].'&action=delete">'.$langs->trans('Delete').'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->trans("CantRemovePaymentWithOneInvoicePaid")).'">'.$langs->trans('Delete').'</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
|
||||
|
||||
|
||||
llxFooter();
|
||||
|
||||
$db->close();
|
||||
0
htdocs/don/payment/index.html
Normal file
0
htdocs/don/payment/index.html
Normal file
313
htdocs/don/payment/payment.php
Normal file
313
htdocs/don/payment/payment.php
Normal file
@ -0,0 +1,313 @@
|
||||
<?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/don/payment.php
|
||||
* \ingroup donations
|
||||
* \brief Page to add payment of a donation
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
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.'/compta/bank/class/account.class.php';
|
||||
|
||||
$langs->load("bills");
|
||||
|
||||
$chid=GETPOST("rowid");
|
||||
$action=GETPOST('action');
|
||||
$amounts = array();
|
||||
|
||||
// Security check
|
||||
$socid=0;
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($action == 'add_payment')
|
||||
{
|
||||
$error=0;
|
||||
|
||||
if ($_POST["cancel"])
|
||||
{
|
||||
$loc = DOL_URL_ROOT.'/don/card.php?rowid='.$chid;
|
||||
header("Location: ".$loc);
|
||||
exit;
|
||||
}
|
||||
|
||||
$datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
|
||||
|
||||
if (! $_POST["paymenttype"] > 0)
|
||||
{
|
||||
$mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode"));
|
||||
$error++;
|
||||
}
|
||||
if ($datepaid == '')
|
||||
{
|
||||
$mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("Date"));
|
||||
$error++;
|
||||
}
|
||||
if (! empty($conf->banque->enabled) && ! $_POST["accountid"] > 0)
|
||||
{
|
||||
$mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("AccountToCredit"));
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$paymentid = 0;
|
||||
|
||||
// Read possible payments
|
||||
foreach ($_POST as $key => $value)
|
||||
{
|
||||
if (substr($key,0,7) == 'amount_')
|
||||
{
|
||||
$other_chid = substr($key,7);
|
||||
$amounts[$other_chid] = price2num($_POST[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
if (count($amounts) <= 0)
|
||||
{
|
||||
$error++;
|
||||
$errmsg='ErrorNoPaymentDefined';
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
// Create a line of payments
|
||||
$payment = new PaymentDonation($db);
|
||||
$payment->chid = $chid;
|
||||
$payment->datepaid = $datepaid;
|
||||
$payment->amounts = $amounts; // Tableau de montant
|
||||
$payment->paymenttype = $_POST["paymenttype"];
|
||||
$payment->num_payment = $_POST["num_payment"];
|
||||
$payment->note = $_POST["note"];
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$paymentid = $payment->create($user);
|
||||
if ($paymentid < 0)
|
||||
{
|
||||
$errmsg=$payment->error;
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$result=$payment->addPaymentToBank($user,'payment_donation','(DonationPayment)',$_POST['accountid'],'','');
|
||||
if (! $result > 0)
|
||||
{
|
||||
$errmsg=$payment->error;
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$db->commit();
|
||||
$loc = DOL_URL_ROOT.'/don/card.php?rowid='.$chid;
|
||||
header('Location: '.$loc);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$_GET["action"]='create';
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader();
|
||||
|
||||
$form=new Form($db);
|
||||
|
||||
|
||||
// Form to create donation payment
|
||||
if (GETPOST("action") == 'create')
|
||||
{
|
||||
|
||||
$don = new Don($db);
|
||||
$don->fetch($chid);
|
||||
|
||||
$total = $don->amount;
|
||||
|
||||
print_fiche_titre($langs->trans("DoPayment"));
|
||||
print "<br>\n";
|
||||
|
||||
if ($mesg)
|
||||
{
|
||||
print "<div class=\"error\">$mesg</div>";
|
||||
}
|
||||
|
||||
print '<form name="add_payment" action="'.$_SERVER['PHP_SELF'].'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="rowid" value="'.$chid.'">';
|
||||
print '<input type="hidden" name="chid" value="'.$chid.'">';
|
||||
print '<input type="hidden" name="action" value="add_payment">';
|
||||
|
||||
print '<table cellspacing="0" class="border" width="100%" cellpadding="2">';
|
||||
|
||||
print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Donation").'</td>';
|
||||
|
||||
print '<tr><td>'.$langs->trans("Ref").'</td><td colspan="2"><a href="'.DOL_URL_ROOT.'/don/card.php?rowid='.$chid.'">'.$chid.'</a></td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Date")."</td><td colspan=\"2\">".dol_print_date($don->date,'day')."</td></tr>\n";
|
||||
print '<tr><td>'.$langs->trans("Amount")."</td><td colspan=\"2\">".price($don->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
|
||||
|
||||
$sql = "SELECT sum(p.amount) as total";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."payment_donation as p";
|
||||
$sql.= " WHERE p.fk_donation = ".$chid;
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$obj=$db->fetch_object($resql);
|
||||
$sumpaid = $obj->total;
|
||||
$db->free();
|
||||
}
|
||||
print '<tr><td>'.$langs->trans("AlreadyPaid").'</td><td colspan="2">'.price($sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
|
||||
print '<tr><td valign="top">'.$langs->trans("RemainderToPay").'</td><td colspan="2">'.price($total-$sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print "<td colspan=\"3\">".$langs->trans("Payment").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Date").'</td><td colspan="2">';
|
||||
$datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
|
||||
$datepayment=empty($conf->global->MAIN_AUTOFILL_DATE)?(empty($_POST["remonth"])?-1:$datepaid):0;
|
||||
$form->select_date($datepayment,'','','','',"add_payment",1,1);
|
||||
print "</td>";
|
||||
print '</tr>';
|
||||
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("PaymentMode").'</td><td colspan="2">';
|
||||
$form->select_types_paiements(isset($_POST["paymenttype"])?$_POST["paymenttype"]:$don->paymenttype, "paymenttype");
|
||||
print "</td>\n";
|
||||
print '</tr>';
|
||||
|
||||
print '<tr>';
|
||||
print '<td class="fieldrequired">'.$langs->trans('AccountToCredit').'</td>';
|
||||
print '<td colspan="2">';
|
||||
$form->select_comptes(isset($_POST["accountid"])?$_POST["accountid"]:$don->accountid, "accountid", 0, '',1); // Show open bank account list
|
||||
print '</td></tr>';
|
||||
|
||||
// Number
|
||||
print '<tr><td>'.$langs->trans('Numero');
|
||||
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
|
||||
print '</td>';
|
||||
print '<td colspan="2"><input name="num_payment" type="text" value="'.GETPOST('num_payment').'"></td></tr>'."\n";
|
||||
|
||||
print '<tr>';
|
||||
print '<td valign="top">'.$langs->trans("Comments").'</td>';
|
||||
print '<td valign="top" colspan="2"><textarea name="note" wrap="soft" cols="60" rows="'.ROWS_3.'"></textarea></td>';
|
||||
print '</tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '<br>';
|
||||
|
||||
/*
|
||||
* Autres charges impayees
|
||||
*/
|
||||
$num = 1;
|
||||
$i = 0;
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td align="right">'.$langs->trans("Amount").'</td>';
|
||||
print '<td align="right">'.$langs->trans("AlreadyPaid").'</td>';
|
||||
print '<td align="right">'.$langs->trans("RemainderToPay").'</td>';
|
||||
print '<td align="center">'.$langs->trans("Amount").'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$var=true;
|
||||
$total=0;
|
||||
$totalrecu=0;
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$objp = $don;
|
||||
|
||||
$var=!$var;
|
||||
|
||||
print "<tr ".$bc[$var].">";
|
||||
|
||||
print '<td align="right">'.price($objp->amount)."</td>";
|
||||
|
||||
print '<td align="right">'.price($sumpaid)."</td>";
|
||||
|
||||
print '<td align="right">'.price($objp->amount - $sumpaid)."</td>";
|
||||
|
||||
print '<td align="center">';
|
||||
if ($sumpaid < $objp->amount)
|
||||
{
|
||||
$namef = "amount_".$objp->id;
|
||||
print '<input type="text" size="8" name="'.$namef.'">';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '-';
|
||||
}
|
||||
print "</td>";
|
||||
|
||||
print "</tr>\n";
|
||||
$total+=$objp->total;
|
||||
$total_ttc+=$objp->total_ttc;
|
||||
$totalrecu+=$objp->am;
|
||||
$i++;
|
||||
}
|
||||
if ($i > 1)
|
||||
{
|
||||
// Print total
|
||||
print "<tr ".$bc[!$var].">";
|
||||
print '<td colspan="2" align="left">'.$langs->trans("Total").':</td>';
|
||||
print "<td align=\"right\"><b>".price($total_ttc)."</b></td>";
|
||||
print "<td align=\"right\"><b>".price($totalrecu)."</b></td>";
|
||||
print "<td align=\"right\"><b>".price($total_ttc - $totalrecu)."</b></td>";
|
||||
print '<td align="center"> </td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
|
||||
print '<br><div class="center">';
|
||||
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
|
||||
print ' ';
|
||||
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||
print '</div>';
|
||||
|
||||
print "</form>\n";
|
||||
}
|
||||
|
||||
|
||||
$db->close();
|
||||
|
||||
llxFooter();
|
||||
358
htdocs/don/stats/index.php
Normal file
358
htdocs/don/stats/index.php
Normal file
@ -0,0 +1,358 @@
|
||||
<?php
|
||||
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* 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/don/stats/index.php
|
||||
* \ingroup donations
|
||||
* \brief Page with donations statistics
|
||||
*/
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/don/class/donstats.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
|
||||
|
||||
$WIDTH=DolGraph::getDefaultGraphSizeForStats('width');
|
||||
$HEIGHT=DolGraph::getDefaultGraphSizeForStats('height');
|
||||
|
||||
$userid=GETPOST('userid','int');
|
||||
$socid=GETPOST('socid','int');
|
||||
// Security check
|
||||
if ($user->societe_id > 0)
|
||||
{
|
||||
$action = '';
|
||||
$socid = $user->societe_id;
|
||||
}
|
||||
|
||||
$nowyear=strftime("%Y", dol_now());
|
||||
$year = GETPOST('year')>0?GETPOST('year'):$nowyear;
|
||||
//$startyear=$year-2;
|
||||
$startyear=$year-1;
|
||||
$endyear=$year;
|
||||
|
||||
$langs->load("sendings");
|
||||
$langs->load("other");
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$form=new Form($db);
|
||||
|
||||
llxHeader();
|
||||
|
||||
print_fiche_titre($langs->trans("StatisticsOfSendings"), $mesg);
|
||||
|
||||
|
||||
dol_mkdir($dir);
|
||||
|
||||
$stats = new DonationStats($db, $socid, $mode, ($userid>0?$userid:0));
|
||||
|
||||
// Build graphic number of object
|
||||
$data = $stats->getNbByMonthWithPrevYear($endyear,$startyear);
|
||||
//var_dump($data);exit;
|
||||
// $data = array(array('Lib',val1,val2,val3),...)
|
||||
|
||||
|
||||
if (!$user->rights->societe->client->voir || $user->societe_id)
|
||||
{
|
||||
$filenamenb = $dir.'/shipmentsnbinyear-'.$user->id.'-'.$year.'.png';
|
||||
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=shipmentstats&file=shipmentsnbinyear-'.$user->id.'-'.$year.'.png';
|
||||
if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=shipmentstatssupplier&file=shipmentsnbinyear-'.$user->id.'-'.$year.'.png';
|
||||
}
|
||||
else
|
||||
{
|
||||
$filenamenb = $dir.'/shipmentsnbinyear-'.$year.'.png';
|
||||
if ($mode == 'customer') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=shipmentstats&file=shipmentsnbinyear-'.$year.'.png';
|
||||
if ($mode == 'supplier') $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=shipmentstatssupplier&file=shipmentsnbinyear-'.$year.'.png';
|
||||
}
|
||||
|
||||
$px1 = new DolGraph();
|
||||
$mesg = $px1->isGraphKo();
|
||||
if (! $mesg)
|
||||
{
|
||||
$px1->SetData($data);
|
||||
$px1->SetPrecisionY(0);
|
||||
$i=$startyear;$legend=array();
|
||||
while ($i <= $endyear)
|
||||
{
|
||||
$legend[]=$i;
|
||||
$i++;
|
||||
}
|
||||
$px1->SetLegend($legend);
|
||||
$px1->SetMaxValue($px1->GetCeilMaxValue());
|
||||
$px1->SetMinValue(min(0,$px1->GetFloorMinValue()));
|
||||
$px1->SetWidth($WIDTH);
|
||||
$px1->SetHeight($HEIGHT);
|
||||
$px1->SetYLabel($langs->trans("NbOfSendings"));
|
||||
$px1->SetShading(3);
|
||||
$px1->SetHorizTickIncrement(1);
|
||||
$px1->SetPrecisionY(0);
|
||||
$px1->mode='depth';
|
||||
$px1->SetTitle($langs->trans("NumberOfShipmentsByMonth"));
|
||||
|
||||
$px1->draw($filenamenb,$fileurlnb);
|
||||
}
|
||||
|
||||
// Build graphic amount of object
|
||||
/*
|
||||
$data = $stats->getAmountByMonthWithPrevYear($endyear,$startyear);
|
||||
//var_dump($data);
|
||||
// $data = array(array('Lib',val1,val2,val3),...)
|
||||
|
||||
if (!$user->rights->societe->client->voir || $user->societe_id)
|
||||
{
|
||||
$filenameamount = $dir.'/shipmentsamountinyear-'.$user->id.'-'.$year.'.png';
|
||||
if ($mode == 'customer') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=shipmentstats&file=shipmentsamountinyear-'.$user->id.'-'.$year.'.png';
|
||||
if ($mode == 'supplier') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=shipmentstatssupplier&file=shipmentsamountinyear-'.$user->id.'-'.$year.'.png';
|
||||
}
|
||||
else
|
||||
{
|
||||
$filenameamount = $dir.'/shipmentsamountinyear-'.$year.'.png';
|
||||
if ($mode == 'customer') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=shipmentstats&file=shipmentsamountinyear-'.$year.'.png';
|
||||
if ($mode == 'supplier') $fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=shipmentstatssupplier&file=shipmentsamountinyear-'.$year.'.png';
|
||||
}
|
||||
|
||||
$px2 = new DolGraph();
|
||||
$mesg = $px2->isGraphKo();
|
||||
if (! $mesg)
|
||||
{
|
||||
$px2->SetData($data);
|
||||
$i=$startyear;$legend=array();
|
||||
while ($i <= $endyear)
|
||||
{
|
||||
$legend[]=$i;
|
||||
$i++;
|
||||
}
|
||||
$px2->SetLegend($legend);
|
||||
$px2->SetMaxValue($px2->GetCeilMaxValue());
|
||||
$px2->SetMinValue(min(0,$px2->GetFloorMinValue()));
|
||||
$px2->SetWidth($WIDTH);
|
||||
$px2->SetHeight($HEIGHT);
|
||||
$px2->SetYLabel($langs->trans("AmountOfShipments"));
|
||||
$px2->SetShading(3);
|
||||
$px2->SetHorizTickIncrement(1);
|
||||
$px2->SetPrecisionY(0);
|
||||
$px2->mode='depth';
|
||||
$px2->SetTitle($langs->trans("AmountOfShipmentsByMonthHT"));
|
||||
|
||||
$px2->draw($filenameamount,$fileurlamount);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
$data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear);
|
||||
|
||||
if (!$user->rights->societe->client->voir || $user->societe_id)
|
||||
{
|
||||
$filename_avg = $dir.'/shipmentsaverage-'.$user->id.'-'.$year.'.png';
|
||||
if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=shipmentstats&file=shipmentsaverage-'.$user->id.'-'.$year.'.png';
|
||||
if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=shipmentstatssupplier&file=shipmentsaverage-'.$user->id.'-'.$year.'.png';
|
||||
}
|
||||
else
|
||||
{
|
||||
$filename_avg = $dir.'/shipmentsaverage-'.$year.'.png';
|
||||
if ($mode == 'customer') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=shipmentstats&file=shipmentsaverage-'.$year.'.png';
|
||||
if ($mode == 'supplier') $fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=shipmentstatssupplier&file=shipmentsaverage-'.$year.'.png';
|
||||
}
|
||||
|
||||
$px3 = new DolGraph();
|
||||
$mesg = $px3->isGraphKo();
|
||||
if (! $mesg)
|
||||
{
|
||||
$px3->SetData($data);
|
||||
$i=$startyear;$legend=array();
|
||||
while ($i <= $endyear)
|
||||
{
|
||||
$legend[]=$i;
|
||||
$i++;
|
||||
}
|
||||
$px3->SetLegend($legend);
|
||||
$px3->SetYLabel($langs->trans("AmountAverage"));
|
||||
$px3->SetMaxValue($px3->GetCeilMaxValue());
|
||||
$px3->SetMinValue($px3->GetFloorMinValue());
|
||||
$px3->SetWidth($WIDTH);
|
||||
$px3->SetHeight($HEIGHT);
|
||||
$px3->SetShading(3);
|
||||
$px3->SetHorizTickIncrement(1);
|
||||
$px3->SetPrecisionY(0);
|
||||
$px3->mode='depth';
|
||||
$px3->SetTitle($langs->trans("AmountAverage"));
|
||||
|
||||
$px3->draw($filename_avg,$fileurl_avg);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
// Show array
|
||||
$data = $stats->getAllByYear();
|
||||
$arrayyears=array();
|
||||
foreach($data as $val) {
|
||||
if (! empty($val['year'])) {
|
||||
$arrayyears[$val['year']]=$val['year'];
|
||||
}
|
||||
}
|
||||
if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear;
|
||||
|
||||
$h=0;
|
||||
$head = array();
|
||||
$head[$h][0] = DOL_URL_ROOT . '/don/stats/index.php?mode='.$mode;
|
||||
$head[$h][1] = $langs->trans("ByMonthYear");
|
||||
$head[$h][2] = 'byyear';
|
||||
$h++;
|
||||
|
||||
$type='donation_stats';
|
||||
|
||||
complete_head_from_modules($conf,$langs,null,$head,$h,$type);
|
||||
|
||||
dol_fiche_head($head,'byyear',$langs->trans("Statistics"));
|
||||
|
||||
|
||||
print '<div class="fichecenter"><div class="fichethirdleft">';
|
||||
|
||||
|
||||
//if (empty($socid))
|
||||
//{
|
||||
// Show filter box
|
||||
print '<form name="stats" method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
print '<input type="hidden" name="mode" value="'.$mode.'">';
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans("Filter").'</td></tr>';
|
||||
// Company
|
||||
print '<tr><td align="left">'.$langs->trans("ThirdParty").'</td><td align="left">';
|
||||
if ($mode == 'customer') $filter='s.client in (1,2,3)';
|
||||
if ($mode == 'supplier') $filter='s.fournisseur = 1';
|
||||
print $form->select_company($socid,'socid',$filter,1);
|
||||
print '</td></tr>';
|
||||
// User
|
||||
print '<tr><td align="left">'.$langs->trans("CreatedBy").'</td><td align="left">';
|
||||
print $form->select_users($userid,'userid',1);
|
||||
print '</td></tr>';
|
||||
// Year
|
||||
print '<tr><td align="left">'.$langs->trans("Year").'</td><td align="left">';
|
||||
if (! in_array($year,$arrayyears)) $arrayyears[$year]=$year;
|
||||
if (! in_array($nowyear,$arrayyears)) $arrayyears[$nowyear]=$nowyear;
|
||||
arsort($arrayyears);
|
||||
print $form->selectarray('year',$arrayyears,$year,0);
|
||||
print '</td></tr>';
|
||||
print '<tr><td align="center" colspan="2"><input type="submit" name="submit" class="button" value="'.$langs->trans("Refresh").'"></td></tr>';
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
print '<br><br>';
|
||||
//}
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr height="24">';
|
||||
print '<td align="center">'.$langs->trans("Year").'</td>';
|
||||
print '<td align="center">'.$langs->trans("NbOfSendings").'</td>';
|
||||
/*print '<td align="center">'.$langs->trans("AmountTotal").'</td>';
|
||||
print '<td align="center">'.$langs->trans("AmountAverage").'</td>';*/
|
||||
print '</tr>';
|
||||
|
||||
$oldyear=0;
|
||||
foreach ($data as $val)
|
||||
{
|
||||
$year = $val['year'];
|
||||
while (! empty($year) && $oldyear > $year+1)
|
||||
{ // If we have empty year
|
||||
$oldyear--;
|
||||
print '<tr height="24">';
|
||||
print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$oldyear.'&mode='.$mode.'">'.$oldyear.'</a></td>';
|
||||
|
||||
print '<td align="right">0</td>';
|
||||
/*print '<td align="right">0</td>';
|
||||
print '<td align="right">0</td>';*/
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
print '<tr height="24">';
|
||||
print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'&mode='.$mode.'">'.$year.'</a></td>';
|
||||
print '<td align="right">'.$val['nb'].'</td>';
|
||||
/*print '<td align="right">'.price(price2num($val['total'],'MT'),1).'</td>';
|
||||
print '<td align="right">'.price(price2num($val['avg'],'MT'),1).'</td>';*/
|
||||
print '</tr>';
|
||||
$oldyear=$year;
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
|
||||
print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
|
||||
|
||||
|
||||
// Show graphs
|
||||
print '<table class="border" width="100%"><tr valign="top"><td align="center">';
|
||||
if ($mesg) { print $mesg; }
|
||||
else {
|
||||
print $px1->show();
|
||||
print "<br>\n";
|
||||
/*print $px2->show();
|
||||
print "<br>\n";
|
||||
print $px3->show();*/
|
||||
}
|
||||
print '</td></tr></table>';
|
||||
|
||||
|
||||
print '</div></div></div>';
|
||||
print '<div style="clear:both"></div>';
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
|
||||
|
||||
// TODO USe code similar to commande/stats/index.php instead of this one.
|
||||
/*
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td align="center">'.$langs->trans("Year").'</td>';
|
||||
print '<td width="40%" align="center">'.$langs->trans("NbOfSendings").'</td></tr>';
|
||||
|
||||
$sql = "SELECT count(*) as nb, date_format(date_expedition,'%Y') as dm";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."expedition";
|
||||
$sql.= " WHERE fk_statut > 0";
|
||||
$sql.= " AND entity = ".$conf->entity;
|
||||
$sql.= " GROUP BY dm DESC";
|
||||
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$row = $db->fetch_row($resql);
|
||||
$nbproduct = $row[0];
|
||||
$year = $row[1];
|
||||
print "<tr>";
|
||||
print '<td align="center"><a href="month.php?year='.$year.'">'.$year.'</a></td><td align="center">'.$nbproduct.'</td></tr>';
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$db->free($resql);
|
||||
|
||||
print '</table>';
|
||||
*/
|
||||
|
||||
print '<br>';
|
||||
print '<i>'.$langs->trans("StatsOnShipmentsOnlyValidated").'</i>';
|
||||
|
||||
llxFooter();
|
||||
|
||||
$db->close();
|
||||
@ -5893,7 +5893,7 @@
|
||||
<md5file name="index.html">d41d8cd98f00b204e9800998ecf8427e</md5file>
|
||||
<md5file name="cron_run_jobs.php">8ea20800d43bbdfdb20363355521c20c</md5file>
|
||||
</dir>
|
||||
<dir name="/public/donations" >
|
||||
<dir name="/public/don" >
|
||||
<md5file name="therm.php">9029f09e1592da49626e9fb5b6399e1e</md5file>
|
||||
<md5file name="donateurs_code.php">d71afb404b4f1946d241bc44ab27df8b</md5file>
|
||||
<md5file name="index.php">823e0c612e7de62db2d41adf37214bea</md5file>
|
||||
|
||||
@ -419,6 +419,37 @@ INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('DDP', 'Delivered Du
|
||||
ALTER TABLE llx_societe_extrafields DROP INDEX idx_societe_extrafields;
|
||||
ALTER TABLE llx_societe_extrafields ADD UNIQUE INDEX uk_societe_extrafields (fk_object);
|
||||
|
||||
-- Module Donation
|
||||
ALTER TABLE llx_don ADD COLUMN fk_country integer NOT NULL after country;
|
||||
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 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
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
fk_donation integer,
|
||||
datec datetime, -- date de creation
|
||||
tms timestamp,
|
||||
datep datetime, -- payment date
|
||||
amount real DEFAULT 0,
|
||||
fk_typepayment integer NOT NULL,
|
||||
num_payment varchar(50),
|
||||
note text,
|
||||
fk_bank integer NOT NULL,
|
||||
fk_user_creat integer, -- creation user
|
||||
fk_user_modif integer -- last modification user
|
||||
)ENGINE=innodb;
|
||||
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_VALIDATE','Customer invoice validated','Executed when a customer invoice is approved','facture',6);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('ORDER_SUPPLIER_APPROVE','Supplier order request approved','Executed when a supplier order is approved','order_supplier',12);
|
||||
@ -460,7 +491,6 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TASK_MODIFY','Task modified','Executed when a project task is modified','project',36);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TASK_DELETE','Task deleted','Executed when a project task is deleted','project',37);
|
||||
|
||||
|
||||
create table llx_c_price_global_variable
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
-- Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
-- Copyright (C) 2009 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
-- Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
-- 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
|
||||
@ -25,23 +26,25 @@ create table llx_don
|
||||
ref varchar(30) DEFAULT NULL, -- Ref donation (TODO change to NOT NULL)
|
||||
entity integer DEFAULT 1 NOT NULL, -- multi company id
|
||||
tms timestamp,
|
||||
fk_statut smallint NOT NULL DEFAULT 0, -- etat du don promesse/valid
|
||||
fk_statut smallint NOT NULL DEFAULT 0, -- Status of donation promise or validate
|
||||
datec datetime, -- date de creation de l'enregistrement
|
||||
datedon datetime, -- date du don/promesse
|
||||
amount real DEFAULT 0,
|
||||
fk_paiement integer,
|
||||
fk_payment integer,
|
||||
paid smallint default 0 NOT NULL,
|
||||
firstname varchar(50),
|
||||
lastname varchar(50),
|
||||
societe varchar(50),
|
||||
address text,
|
||||
zip varchar(30),
|
||||
town varchar(50),
|
||||
country varchar(50),
|
||||
country varchar(50), -- Deprecated - Replace with fk_country
|
||||
fk_country integer NOT NULL,
|
||||
email varchar(255),
|
||||
phone varchar(24),
|
||||
phone_mobile varchar(24),
|
||||
public smallint DEFAULT 1 NOT NULL, -- le don est-il public (0,1)
|
||||
fk_don_projet integer NULL, -- projet auquel est fait le don
|
||||
public smallint DEFAULT 1 NOT NULL, -- Donation is public ? (0,1)
|
||||
fk_project integer NULL, -- Donation is given for a project ?
|
||||
fk_user_author integer NOT NULL,
|
||||
fk_user_valid integer NULL,
|
||||
note_private text,
|
||||
|
||||
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;
|
||||
|
||||
33
htdocs/install/mysql/tables/llx_payment_donation.sql
Normal file
33
htdocs/install/mysql/tables/llx_payment_donation.sql
Normal file
@ -0,0 +1,33 @@
|
||||
-- ===================================================================
|
||||
-- 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_payment_donation
|
||||
(
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
fk_donation integer,
|
||||
datec datetime, -- date de creation
|
||||
tms timestamp,
|
||||
datep datetime, -- payment date
|
||||
amount real DEFAULT 0,
|
||||
fk_typepayment integer NOT NULL,
|
||||
num_payment varchar(50),
|
||||
note text,
|
||||
fk_bank integer NOT NULL,
|
||||
fk_user_creat integer, -- creation user
|
||||
fk_user_modif integer -- last modification user
|
||||
)ENGINE=innodb;
|
||||
@ -6,6 +6,8 @@ Donor=Donor
|
||||
Donors=Donors
|
||||
AddDonation=Create a donation
|
||||
NewDonation=New donation
|
||||
DeleteADonation=Delete a donation
|
||||
ConfirmDeleteADonation=Are you sure you want to delete this donation ?
|
||||
ShowDonation=Show donation
|
||||
DonationPromise=Gift promise
|
||||
PromisesNotValid=Not validated promises
|
||||
@ -21,6 +23,8 @@ DonationStatusPaid=Donation received
|
||||
DonationStatusPromiseNotValidatedShort=Draft
|
||||
DonationStatusPromiseValidatedShort=Validated
|
||||
DonationStatusPaidShort=Received
|
||||
DonationTitle=Donation receipt
|
||||
DonationDatePayment=Payment date
|
||||
ValidPromess=Validate promise
|
||||
DonationReceipt=Donation receipt
|
||||
BuildDonationReceipt=Build receipt
|
||||
@ -36,3 +40,4 @@ FrenchOptions=Options for France
|
||||
DONATION_ART200=Show article 200 from CGI if you are concerned
|
||||
DONATION_ART238=Show article 238 from CGI if you are concerned
|
||||
DONATION_ART885=Show article 885 from CGI if you are concerned
|
||||
DonationPayment=Donation payment
|
||||
|
||||
@ -72,6 +72,7 @@ ListSupplierInvoicesAssociatedProject=List of supplier's invoices associated wit
|
||||
ListContractAssociatedProject=List of contracts associated with the project
|
||||
ListFichinterAssociatedProject=List of interventions associated with the project
|
||||
ListExpenseReportsAssociatedProject=List of expense reports associated with the project
|
||||
ListDonationsAssociatedProject=List of donations associated with the project
|
||||
ListActionsAssociatedProject=List of events associated with the project
|
||||
ActivityOnProjectThisWeek=Activity on project this week
|
||||
ActivityOnProjectThisMonth=Activity on project this month
|
||||
|
||||
@ -1563,7 +1563,7 @@ class Product extends CommonObject
|
||||
$this->db->free($resql);
|
||||
|
||||
|
||||
// Retreive all extrafield for thirdparty
|
||||
// Retrieve all extrafield for thirdparty
|
||||
// fetch optionals attributes and labels
|
||||
require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
|
||||
$extrafields=new ExtraFields($this->db);
|
||||
|
||||
@ -506,7 +506,7 @@ class Project extends CommonObject
|
||||
// Set fk_projet into elements to null
|
||||
$listoftables=array(
|
||||
'facture'=>'fk_projet','propal'=>'fk_projet','commande'=>'fk_projet','facture_fourn'=>'fk_projet','commande_fournisseur'=>'fk_projet',
|
||||
'expensereport_det'=>'fk_projet','contrat'=>'fk_projet','fichinter'=>'fk_projet'
|
||||
'expensereport_det'=>'fk_projet','contrat'=>'fk_projet','fichinter'=>'fk_projet','don'=>'fk_project'
|
||||
);
|
||||
foreach($listoftables as $key => $value)
|
||||
{
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
|
||||
* 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
|
||||
@ -41,16 +42,18 @@ if (! empty($conf->ficheinter->enabled)) require_once DOL_DOCUMENT_ROOT.'/fichi
|
||||
if (! empty($conf->deplacement->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
|
||||
if (! empty($conf->expensereport->enabled)) require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
|
||||
if (! empty($conf->agenda->enabled)) require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
|
||||
if (! empty($conf->don->enabled)) require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php';
|
||||
|
||||
$langs->load("projects");
|
||||
$langs->load("companies");
|
||||
$langs->load("suppliers");
|
||||
if (! empty($conf->facture->enabled)) $langs->load("bills");
|
||||
if (! empty($conf->commande->enabled)) $langs->load("orders");
|
||||
if (! empty($conf->propal->enabled)) $langs->load("propal");
|
||||
if (! empty($conf->ficheinter->enabled)) $langs->load("interventions");
|
||||
if (! empty($conf->deplacement->enabled)) $langs->load("trips");
|
||||
if (! empty($conf->facture->enabled)) $langs->load("bills");
|
||||
if (! empty($conf->commande->enabled)) $langs->load("orders");
|
||||
if (! empty($conf->propal->enabled)) $langs->load("propal");
|
||||
if (! empty($conf->ficheinter->enabled)) $langs->load("interventions");
|
||||
if (! empty($conf->deplacement->enabled)) $langs->load("trips");
|
||||
if (! empty($conf->expensereport->enabled)) $langs->load("trips");
|
||||
if (! empty($conf->don->enabled)) $langs->load("donations");
|
||||
|
||||
$id=GETPOST('id','int');
|
||||
$ref=GETPOST('ref','alpha');
|
||||
@ -246,7 +249,15 @@ $listofreferent=array(
|
||||
'table'=>'actioncomm',
|
||||
'datefieldname'=>'datep',
|
||||
'disableamount'=>1,
|
||||
'test'=>$conf->agenda->enabled && $user->rights->agenda->allactions->lire)
|
||||
'test'=>$conf->agenda->enabled && $user->rights->agenda->allactions->lire),
|
||||
'donation'=>array(
|
||||
'name'=>"Donation",
|
||||
'title'=>"ListDonationsAssociatedProject",
|
||||
'class'=>'Don',
|
||||
'table'=>'don',
|
||||
'datefieldname'=>'date',
|
||||
'disableamount'=>1,
|
||||
'test'=>$conf->don->enabled && $user->rights->don->lire),
|
||||
);
|
||||
|
||||
if ($action=="addelement")
|
||||
|
||||
@ -39,7 +39,7 @@ function llxHeaderVierge() { print '<html><title>Export agenda cal</title><body>
|
||||
function llxFooterVierge() { print '</body></html>'; }
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT .'/compta/dons/class/class/don.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT .'/don/class/don.class.php';
|
||||
|
||||
// Security check
|
||||
if (empty($conf->don->enabled)) accessforbidden('',1,1,1);
|
||||
|
||||
@ -27,7 +27,7 @@ define("NOCSRFCHECK",1); // We accept to go on this page from external web site.
|
||||
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/dons/class/don.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
|
||||
|
||||
// Security check
|
||||
if (empty($conf->don->enabled)) accessforbidden('',1,1,1);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user