From 1cd81f0e81c2dc779b30c58baed8d824386d93a7 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Mon, 16 Mar 2015 06:29:15 +0100 Subject: [PATCH 01/27] Work on module donations --- htdocs/compta/dons/card.php | 282 +++++++++--------- htdocs/compta/dons/class/don.class.php | 85 +++++- htdocs/compta/dons/document.php | 125 ++++++++ htdocs/compta/dons/info.php | 62 ++++ htdocs/core/lib/donation.lib.php | 61 ++++ .../install/mysql/migration/3.7.0-3.8.0.sql | 3 + htdocs/install/mysql/tables/llx_don.sql | 3 +- 7 files changed, 469 insertions(+), 152 deletions(-) create mode 100644 htdocs/compta/dons/document.php create mode 100644 htdocs/compta/dons/info.php create mode 100644 htdocs/core/lib/donation.lib.php diff --git a/htdocs/compta/dons/card.php b/htdocs/compta/dons/card.php index 71e96f60f49..a4e68fbc4de 100644 --- a/htdocs/compta/dons/card.php +++ b/htdocs/compta/dons/card.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2013 Florian Henry + * Copyright (C) 2015 Alexandre Spangaro * * 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 @@ -26,6 +27,7 @@ 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.'/compta/dons/class/don.class.php'; @@ -33,6 +35,7 @@ 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'; } +require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $langs->load("companies"); $langs->load("donations"); @@ -43,7 +46,7 @@ $action=GETPOST('action','alpha'); $cancel=GETPOST('cancel'); $amount=GETPOST('amount'); -$don = new Don($db); +$object = new Don($db); $donation_date=dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); // Security check @@ -83,28 +86,26 @@ if ($action == 'update') if (! $error) { - $don->fetch($id); + $object->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"]; + $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("projectid"); + $object->note_private= GETPOST("note_private"); + $object->note_public = GETPOST("note_public"); - if ($don->update($user) > 0) + if ($object->update($user) > 0) { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$don->id); + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } } @@ -136,24 +137,23 @@ if ($action == 'add') 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"]; + $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->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("projectid"); - if ($don->create($user) > 0) + if ($object->create($user) > 0) { header("Location: index.php"); exit; @@ -163,57 +163,57 @@ if ($action == 'add') if ($action == 'delete') { - $don->delete($id); + $object->delete($id); header("Location: list.php"); exit; } if ($action == 'commentaire') { - $don->fetch($id); - $don->update_note($_POST["commentaire"]); + $object->fetch($id); + $object->update_note(GETPOST("commentaire")); } if ($action == 'valid_promesse') { - if ($don->valid_promesse($id, $user->id) >= 0) + if ($object->valid_promesse($id, $user->id) >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit; } else { - setEventMessage($don->error, 'errors'); + setEventMessage($object->error, 'errors'); } } if ($action == 'set_cancel') { - if ($don->set_cancel($id) >= 0) + if ($object->set_cancel($id) >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit; } else { - setEventMessage($don->error, 'errors'); + setEventMessage($object->error, 'errors'); } } if ($action == 'set_paid') { - if ($don->set_paye($id, $modepaiement) >= 0) + if ($object->set_paye($id, $modepaiement) >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit; } else { - setEventMessage($don->error, 'errors'); + setEventMessage($object->error, 'errors'); } } if ($action == 'set_encaisse') { - if ($don->set_encaisse($id) >= 0) + if ($object->set_encaisse($id) >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit; } else { - setEventMessage($don->error, 'errors'); + setEventMessage($object->error, 'errors'); } } @@ -268,7 +268,7 @@ if ($action == 'create') { print_fiche_titre($langs->trans("AddDonation")); - print '
'; + print ''; print ''; print ''; @@ -278,40 +278,57 @@ if ($action == 'create') if (! empty($conf->projet->enabled)) $nbrows++; // Date - print ''; - print '"; - print ""; - // Amount - print "".''; + print "".''; print '\n"; - print "".''; - print "".''; - print "".''; + print "".''; + print "".''; + print "".''; print "".''; + print ''; // Zip / Town print ''; - print "".''; - print "".''; + // Country + print ''; + + print "".''; - print "\n"; + // Public note + print ''; + print ''; + print ''; + + // Private note + if (empty($user->societe_id)) { + print ''; + print ''; + print ''; + } if (! empty($conf->projet->enabled)) { @@ -320,13 +337,13 @@ if ($action == 'create') // Si module projet actif print "\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 + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print "
'.$langs->trans("Date").''; + print '
'.$langs->trans("Date").''; $form->select_date($donation_date?$donation_date:-1,'','','','',"add",1,1); print ''.$langs->trans("Comments").' :
'; - print "
'.$langs->trans("Amount").' '.$langs->trans("Currency".$conf->currency).'
'.$langs->trans("Amount").' '.$langs->trans("Currency".$conf->currency).'
'.$langs->trans("PublicDonation").""; print $form->selectyesno("public",isset($_POST["public"])?$_POST["public"]:1,1); print "
'.$langs->trans("Company").'
'.$langs->trans("Firstname").'
'.$langs->trans("Lastname").'
'.$langs->trans("Company").'
'.$langs->trans("Lastname").'
'.$langs->trans("Firstname").'
'.$langs->trans("Address").''; - print '
'.$langs->trans("Zip").' / '.$langs->trans("Town").''; - print $formcompany->select_ziptown((isset($_POST["zipcode"])?$_POST["zipcode"]:$don->zip),'zipcode',array('town','selectcountry_id','state_id'),6); + 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"]:$don->town),'town',array('zipcode','selectcountry_id','state_id')); + print $formcompany->select_ziptown((isset($_POST["town"])?$_POST["town"]:$object->town),'town',array('zipcode','selectcountry_id','state_id')); print '
'.$langs->trans("Country").'
'.$langs->trans("EMail").'
'; + print $form->select_country(GETPOST('country_id')!=''?GETPOST('country_id'):$object->country_id); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); + print '
'.$langs->trans("EMail").'
".$langs->trans("PaymentMode")."\n"; - $form->select_types_paiements('', 'modepaiement', 'CRDT', 0, 1); - print "
' . $langs->trans('NotePublic') . ''; + + $doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); + print $doleditor->Create(1); + print '
' . $langs->trans('NotePrivate') . ''; + + $doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, 70); + print $doleditor->Create(1); + print '
".$langs->trans("Project").""; - $formproject->select_projects('',$_POST["projectid"],"projectid"); + $formproject->select_projects('',GETPOST("projectid"),"projectid"); print "
\n"; print '
   
'; @@ -342,26 +359,21 @@ if ($action == 'create') 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++; + $object->fetch($id); + $head = donation_prepare_head($object); dol_fiche_head($head, $hselected, $langs->trans("Donation"), 0, 'generic'); - print ''; + print ''; print ''; print ''; print ''; - print ''; + print ''; // Ref print "".''; print ''; @@ -370,15 +382,11 @@ if (! empty($id) && $action == 'edit') // Date print "".''; - print '"; - print ""; - // Amount - print "".''; + print "".''; print '\n"; $langs->load("companies"); - print "".''; - print "".''; - print "".''; + print "".''; + print "".''; + print "".''; print "".''; + print ''; // Zip / Town print ''; - print "".''; - print "".''; + // Country + print ''; + + print "".''; print "\n"; - print "".''; + print "".''; // Project if (! empty($conf->projet->enabled)) @@ -419,13 +432,13 @@ if (! empty($id) && $action == 'edit') $langs->load('projects'); print ''; } // 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 + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print "
'.$langs->trans("Ref").''; - print $don->getNomUrl(); + print $object->getNomUrl(); print '
'.$langs->trans("Date").''; - $form->select_date($don->date,'','','','',"update"); + $form->select_date($object->date,'','','','',"update"); print ''.$langs->trans("Comments").' :
'; - print "
'.$langs->trans("Amount").' '.$langs->trans("Currency".$conf->currency).'
'.$langs->trans("Amount").' '.$langs->trans("Currency".$conf->currency).'
'.$langs->trans("PublicDonation").""; print $form->selectyesno("public",1,1); @@ -386,31 +394,36 @@ if (! empty($id) && $action == 'edit') print "
'.$langs->trans("Company").'
'.$langs->trans("Firstname").'
'.$langs->trans("Lastname").'
'.$langs->trans("Company").'
'.$langs->trans("Lastname").'
'.$langs->trans("Firstname").'
'.$langs->trans("Address").''; - print '
'.$langs->trans("Zip").' / '.$langs->trans("Town").''; - print $formcompany->select_ziptown((isset($_POST["zipcode"])?$_POST["zipcode"]:$don->zip),'zipcode',array('town','selectcountry_id','state_id'),6); + 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"]:$don->town),'town',array('zipcode','selectcountry_id','state_id')); + print $formcompany->select_ziptown((isset($_POST["town"])?$_POST["town"]:$object->town),'town',array('zipcode','selectcountry_id','state_id')); print '
'.$langs->trans("Country").'
'.$langs->trans("EMail").'
'.$langs->trans('Country').''; + 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 '
'.$langs->trans("EMail").'
".$langs->trans("PaymentMode")."\n"; - if ($don->modepaiementid) $selected = $don->modepaiementid; + if ($object->modepaiementid) $selected = $object->modepaiementid; else $selected = ''; $form->select_types_paiements($selected, 'modepaiement', 'CRDT', 0, 1); print "
'.$langs->trans("Status").''.$don->getLibStatut(4).'
'.$langs->trans("Status").''.$object->getLibStatut(4).'
'.$langs->trans('Project').''; - $formproject->select_projects(-1, (isset($_POST["projectid"])?$_POST["projectid"]:$don->fk_project), 'projectid'); + $formproject->select_projects(-1, (isset($_POST["projectid"])?$_POST["projectid"]:$don->fk_project), 'projectid'); print '
\n"; @@ -445,17 +458,12 @@ if (! empty($id) && $action == 'edit') /* ************************************************************ */ 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++; - + $result=$object->fetch($id); + + $head = donation_prepare_head($object); dol_fiche_head($head, $hselected, $langs->trans("Donation"), 0, 'generic'); - print ""; + print ''; print ''; print ''; @@ -466,54 +474,58 @@ if (! empty($id) && $action != 'edit') // Ref print "".''; print ''; // Date print '"; - print ''; - - print "".''; + print "".''; print "\n"; - print "".''; - print "".''; - print "".''; - print "".''; + print "".''; + print "".''; + print "".''; + print "".''; // Zip / Town - print "".''; + print "".''; // Country - print "".''; + print ''; // EMail - print "".''; + print "".''; // Payment mode print "\n"; - print "".''; + print "".''; // Project if (! empty($conf->projet->enabled)) { - print "".''; + print "".''; } // 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 + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook print "
'.$langs->trans("Ref").''; - print $form->showrefnav($don, 'rowid', $linkback, 1, 'rowid', 'ref', ''); + print $form->showrefnav($object, 'rowid', $linkback, 1, 'rowid', 'ref', ''); print '
'.$langs->trans("Date").''; - print dol_print_date($don->date,"day"); + print dol_print_date($object->date,"day"); print "'.$langs->trans("Comments").' :
'; - print nl2br($don->note_private).'
'.$langs->trans("Amount").''.price($don->amount,0,$langs,0,0,-1,$conf->currency).'
'.$langs->trans("Amount").''.price($object->amount,0,$langs,0,0,-1,$conf->currency).'
".$langs->trans("PublicDonation").""; - print yn($don->public); + print yn($object->public); print "
'.$langs->trans("Company").''.$don->societe.'
'.$langs->trans("Firstname").''.$don->firstname.'
'.$langs->trans("Lastname").''.$don->lastname.'
'.$langs->trans("Address").''.dol_nl2br($don->address).'
'.$langs->trans("Company").''.$object->societe.'
'.$langs->trans("Lastname").''.$object->lastname.'
'.$langs->trans("Firstname").''.$object->firstname.'
'.$langs->trans("Address").''.dol_nl2br($object->address).'
'.$langs->trans("Zip").' / '.$langs->trans("Town").''.$don->zip.($don->zip && $don->town?' / ':'').$don->town.'
'.$langs->trans("Zip").' / '.$langs->trans("Town").''.$object->zip.($object->zip && $object->town?' / ':'').$object->town.'
'.$langs->trans("Country").''.$don->country.'
'.$langs->trans('Country').''; + if (! empty($object->country_code)) + { + $img=picto_from_langcode($object->country_code); + print ($img?$img.' ':''); + } + print $object->country; + print '
'.$langs->trans("EMail").''.dol_print_email($don->email).'
'.$langs->trans("EMail").''.dol_print_email($object->email).'
".$langs->trans("PaymentMode").""; - $form->form_modes_reglement(null, $don->modepaiementid,'none'); + $form->form_modes_reglement(null, $object->modepaiementid,'none'); print "
'.$langs->trans("Status").''.$don->getLibStatut(4).'
'.$langs->trans("Status").''.$object->getLibStatut(4).'
'.$langs->trans("Project").''.$don->projet.'
'.$langs->trans("Project").''.$object->projet.'
\n"; print "
\n"; @@ -529,32 +541,32 @@ if (! empty($id) && $action != 'edit') */ print '
'; - print ''; + print ''; - if ($don->statut == 0) + if ($object->statut == 0) { - print ''; + print ''; } - if (($don->statut == 0 || $don->statut == 1) && $resteapayer == 0 && $don->paye == 0) + if (($object->statut == 0 || $object->statut == 1) && $resteapayer == 0 && $object->paye == 0) { - print '"; + print '"; } // TODO Gerer action emettre paiement - if ($don->statut == 1 && $resteapayer > 0) + if ($object->statut == 1 && $resteapayer > 0) { - print '"; + print '"; } - if ($don->statut == 1 && $resteapayer == 0 && $don->paye == 0) + if ($object->statut == 1 && $resteapayer == 0 && $object->paye == 0) { - print '"; + print '"; } if ($user->rights->don->supprimer) { - print '"; + print '"; } else { @@ -569,9 +581,9 @@ if (! empty($id) && $action != 'edit') /* * Documents generes */ - $filename=dol_sanitizeFileName($don->id); + $filename=dol_sanitizeFileName($object->id); $filedir=$conf->don->dir_output . '/' . get_exdir($filename,2); - $urlsource=$_SERVER['PHP_SELF'].'?rowid='.$don->id; + $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; diff --git a/htdocs/compta/dons/class/don.class.php b/htdocs/compta/dons/class/don.class.php index e5d64eb0d9d..6435e82ed8c 100644 --- a/htdocs/compta/dons/class/don.class.php +++ b/htdocs/compta/dons/class/don.class.php @@ -2,7 +2,8 @@ /* Copyright (C) 2002 Rodolphe Quiedeville * Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2009 Regis Houssin - * Copyright (C) 2014 Florian Henry + * Copyright (C) 2014 Florian Henry + * Copyright (C) 2015 Alexandre Spangaro * * 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 @@ -20,8 +21,8 @@ /** * \file htdocs/compta/dons/class/don.class.php - * \ingroup don - * \brief Fichier de la classe des dons + * \ingroup Donation + * \brief File of class to manage donations */ require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php'; @@ -46,6 +47,8 @@ class Don extends CommonObject var $address; var $zip; var $town; + var $country_id; + var $country_code; var $country; var $email; var $public; @@ -326,7 +329,8 @@ class Don extends CommonObject $sql.= ", address"; $sql.= ", zip"; $sql.= ", town"; - $sql.= ", country"; + // $sql.= ", country"; -- Deprecated + $sql.= ", fk_pays"; $sql.= ", public"; $sql.= ", fk_don_projet"; $sql.= ", note_private"; @@ -348,7 +352,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"); @@ -409,7 +413,7 @@ class Don extends CommonObject $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_pays = ".$this->country_id; $sql .= ",public=".$this->public; $sql .= ",fk_don_projet=".($this->fk_project>0?$this->fk_project:'null'); $sql .= ",note_private=".(!empty($this->note_private)?("'".$this->db->escape($this->note_private)."'"):"NULL"); @@ -493,12 +497,14 @@ class Don extends CommonObject $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_pays, 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.= " 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.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.fk_pays = c.rowid"; $sql.= " WHERE d.rowid = ".$rowid." AND d.entity = ".$conf->entity; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); @@ -522,7 +528,9 @@ class Don extends CommonObject $this->town = $obj->town; $this->zip = $obj->zip; $this->town = $obj->town; - $this->country = $obj->country; + $this->country_id = $obj->country_id; + $this->country_code = $obj->country_code; + $this->country = $obj->country; $this->email = $obj->email; $this->phone = $obj->phone; $this->phone_mobile = $obj->phone_mobile; @@ -547,10 +555,10 @@ 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) @@ -644,9 +652,9 @@ class Don extends CommonObject } /** - * Set donation sto status canceled + * 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_cancel($rowid) @@ -673,7 +681,7 @@ class Don extends CommonObject } /** - * Somme des dons + * Sum of donations * * @param string $param 1=promesses de dons validees , 2=xxx, 3=encaisses * @return int Summ of donations @@ -724,5 +732,50 @@ class Don extends CommonObject if ($withpicto != 2) $result.=$lien.$this->id.$lienfin; 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); + } + } } diff --git a/htdocs/compta/dons/document.php b/htdocs/compta/dons/document.php new file mode 100644 index 00000000000..d4671097fad --- /dev/null +++ b/htdocs/compta/dons/document.php @@ -0,0 +1,125 @@ + + * + * 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 . + */ + +/** + * \file htdocs/compta/dons/document.php + * \ingroup Donation + * \brief Page of linked files into donations + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/dons/class/don.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; + +$langs->load("other"); +$langs->load("donations"); +$langs->load("companies"); +$langs->load("interventions"); + +$id = GETPOST('id','int'); +$ref = GETPOST('ref', 'alpha'); +$action = GETPOST('action','alpha'); +$confirm = GETPOST('confirm','alpha'); + +// Security check +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'don', $id, ''); + +// Get parameters +$sortfield = GETPOST('sortfield','alpha'); +$sortorder = GETPOST('sortorder','alpha'); +$page = GETPOST('page','int'); +if ($page == -1) { $page = 0; } +$offset = $conf->liste_limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (! $sortorder) $sortorder="ASC"; +if (! $sortfield) $sortfield="name"; + +$object = new Don($db); +$object->fetch($id, $ref); + +$upload_dir = $conf->dons->dir_output.'/'.dol_sanitizeFileName($object->ref); +$modulepart='don'; + + +/* + * Actions + */ + +include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php'; + + +/* + * View + */ + +$form = new Form($db); + +llxHeader("","",$langs->trans("Don")); + + +if ($object->id) +{ + $object->fetch_thirdparty(); + + $head=donation_prepare_head($object); + + dol_fiche_head($head, 'documents', $langs->trans("Don"), 0, 'bill'); + + + // Built files list + $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); + $totalsize=0; + foreach($filearray as $key => $file) + { + $totalsize+=$file['size']; + } + + + print ''; + + $linkback = ''.$langs->trans("BackToList").''; + + // Ref + print ''; + + print ''; + print ''; + print '
'.$langs->trans("Ref").''; + print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref', ''); + print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; + + print '
'; + + $modulepart = 'don'; + $permission = $user->rights->don->creer; + $param = '&id=' . $object->id; + include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; + +} +else +{ + print $langs->trans("ErrorUnknown"); +} + +llxFooter(); + +$db->close(); diff --git a/htdocs/compta/dons/info.php b/htdocs/compta/dons/info.php new file mode 100644 index 00000000000..ca2c03878d6 --- /dev/null +++ b/htdocs/compta/dons/info.php @@ -0,0 +1,62 @@ + + * + * 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 . + */ + +/** + * \file htdocs/compta/dons/info.php + * \ingroup Donation + * \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.'/compta/dons/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 '
'; + dol_print_object_info($object); + print '
'; + + print ''; +} + +$db->close(); + +llxFooter(); diff --git a/htdocs/core/lib/donation.lib.php b/htdocs/core/lib/donation.lib.php new file mode 100644 index 00000000000..dcbe2d30e84 --- /dev/null +++ b/htdocs/core/lib/donation.lib.php @@ -0,0 +1,61 @@ + + * + * 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 . + */ + +/** + * \file htdocs/core/lib/donation.lib.php + * \ingroup Donation + * \brief Library of donation functions + */ + +/** + * 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 . '/compta/dons/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 . '/compta/dons/document.php?id='.$object->id; + $head[$h][1] = $langs->trans("Documents"); + $head[$h][2] = 'documents'; + $h++; + + $head[$h][0] = DOL_URL_ROOT . '/compta/dons/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; +} diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index b7475d88f91..d2520973275 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -370,3 +370,6 @@ INSERT INTO llx_c_incoterms (code, libelle, active) VALUES ('DDP', 'Delivered Du -- Extrafields fk_object must be unique (1-1 relation) 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_pays integer NOT NULL after country; diff --git a/htdocs/install/mysql/tables/llx_don.sql b/htdocs/install/mysql/tables/llx_don.sql index 259cac22966..bf434e11518 100644 --- a/htdocs/install/mysql/tables/llx_don.sql +++ b/htdocs/install/mysql/tables/llx_don.sql @@ -36,7 +36,8 @@ create table llx_don address text, zip varchar(30), town varchar(50), - country varchar(50), + country varchar(50), -- Deprecated - Replace with fk_pays + fk_pays integer NOT NULL, email varchar(255), phone varchar(24), phone_mobile varchar(24), From 4e839524855c3d8806d41b81b0f8f74410901126 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Wed, 18 Mar 2015 05:07:32 +0100 Subject: [PATCH 02/27] Add payment on donation --- htdocs/compta/dons/card.php | 71 +- htdocs/compta/dons/class/don.class.php | 30 +- .../dons/class/paymentdonation.class.php | 607 ++++++++++++++++++ htdocs/compta/dons/payment.php | 313 +++++++++ .../install/mysql/migration/3.7.0-3.8.0.sql | 20 +- htdocs/install/mysql/tables/llx_don.sql | 8 +- .../mysql/tables/llx_payment_donation.sql | 33 + 7 files changed, 1041 insertions(+), 41 deletions(-) create mode 100644 htdocs/compta/dons/class/paymentdonation.class.php create mode 100644 htdocs/compta/dons/payment.php create mode 100644 htdocs/install/mysql/tables/llx_payment_donation.sql diff --git a/htdocs/compta/dons/card.php b/htdocs/compta/dons/card.php index a4e68fbc4de..0c4c92cecd7 100644 --- a/htdocs/compta/dons/card.php +++ b/htdocs/compta/dons/card.php @@ -142,7 +142,6 @@ if ($action == 'add') $object->societe = GETPOST("societe"); $object->address = GETPOST("address"); $object->amount = price2num(GETPOST("amount")); - $object->town = GETPOST("town"); $object->zip = GETPOST("zipcode"); $object->town = GETPOST("town"); $object->country_id = GETPOST('country_id', 'int'); @@ -196,7 +195,7 @@ if ($action == 'set_cancel') } if ($action == 'set_paid') { - if ($object->set_paye($id, $modepaiement) >= 0) + if ($object->set_paye($id, $modepayment) >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit; @@ -260,7 +259,7 @@ $formcompany = new FormCompany($db); /* ************************************************************************** */ /* */ -/* Creation */ +/* Donation card in create mode */ /* */ /* ************************************************************************** */ @@ -353,7 +352,7 @@ if ($action == 'create') /* ************************************************************ */ /* */ -/* Fiche don en mode edition */ +/* Donation card in edit mode */ /* */ /* ************************************************************ */ @@ -417,10 +416,10 @@ if (! empty($id) && $action == 'edit') print "".$langs->trans("PaymentMode")."\n"; - if ($object->modepaiementid) $selected = $object->modepaiementid; + if ($object->modepaymentid) $selected = $object->modepaymentid; else $selected = ''; - $form->select_types_paiements($selected, 'modepaiement', 'CRDT', 0, 1); + $form->select_types_paiements($selected, 'modepayment', 'CRDT', 0, 1); print "\n"; print "".''.$langs->trans("Status").''.$object->getLibStatut(4).''; @@ -453,7 +452,7 @@ if (! empty($id) && $action == 'edit') /* ************************************************************ */ /* */ -/* Fiche don en mode visu */ +/* Donation card in view mode */ /* */ /* ************************************************************ */ if (! empty($id) && $action != 'edit') @@ -503,8 +502,12 @@ if (! empty($id) && $action != 'edit') { $img=picto_from_langcode($object->country_code); print ($img?$img.' ':''); + print $object->country; } - print $object->country; + else + { + print $object->country_olddata; + } print ''; // EMail @@ -512,7 +515,7 @@ if (! empty($id) && $action != 'edit') // Payment mode print "".$langs->trans("PaymentMode").""; - $form->form_modes_reglement(null, $object->modepaiementid,'none'); + $form->form_modes_reglement(null, $object->modepaymentid,'none'); print "\n"; print "".''.$langs->trans("Status").''.$object->getLibStatut(4).''; @@ -532,41 +535,63 @@ if (! empty($id) && $action != 'edit') print ""; - // TODO Gerer action emettre paiement - $resteapayer = 0; - + $remaintopay = $object->amount - $totalpaid; /** - * Barre d'actions + * Actions buttons */ print '
'; - print ''; + print ''; if ($object->statut == 0) { - print ''; + print ''; } - if (($object->statut == 0 || $object->statut == 1) && $resteapayer == 0 && $object->paye == 0) + if (($object->statut == 0 || $object->statut == 1) && $remaintopay == 0 && $object->paye == 0) { - print '"; + print '"; } - // TODO Gerer action emettre paiement - if ($object->statut == 1 && $resteapayer > 0) + // Create payment + if ($object->statut == 1 && $object->paid == 0 && $user->rights->don->creer) { - print '"; + if ($remaintopay == 0) + { + print '
' . $langs->trans('DoPayment') . '
'; + } + else + { + print ''; + } } - if ($object->statut == 1 && $resteapayer == 0 && $object->paye == 0) + /* + // Classify paid + if ($object->statut == 1 && $object->paye == 0 && $user->rights->facture->paiement && (($object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT && $resteapayer <= 0) || ($object->type == Facture::TYPE_CREDIT_NOTE && $resteapayer >= 0)) + || ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 0 && $resteapayer == 0 && $user->rights->facture->paiement && empty($discount->id)) + ) + { + print ''; + } + + // Emit payment + if ($object->statut == 1 && $object->paid == 0 && ((price2num($object->amount) > 0 && round($remaintopay) > 0)) && $user->rights->don->creer) { - print '"; + print ''; } + */ + // Classify 'paid' + if ($object->statut == 1 && round($remaintopay) == 0 && $object->paid == 0 && $user->rights->don->creer) + { + print '"; + } + if ($user->rights->don->supprimer) { - print '"; + print '"; } else { diff --git a/htdocs/compta/dons/class/don.class.php b/htdocs/compta/dons/class/don.class.php index 88682b9d738..b677a3afad2 100644 --- a/htdocs/compta/dons/class/don.class.php +++ b/htdocs/compta/dons/class/don.class.php @@ -322,7 +322,7 @@ class Don extends CommonObject $sql.= "datec"; $sql.= ", entity"; $sql.= ", amount"; - $sql.= ", fk_paiement"; + $sql.= ", fk_payment"; $sql.= ", firstname"; $sql.= ", lastname"; $sql.= ", societe"; @@ -330,7 +330,7 @@ class Don extends CommonObject $sql.= ", zip"; $sql.= ", town"; // $sql.= ", country"; -- Deprecated - $sql.= ", fk_pays"; + $sql.= ", fk_country"; $sql.= ", public"; $sql.= ", fk_don_projet"; $sql.= ", note_private"; @@ -406,14 +406,14 @@ 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 .= ",fk_pays = ".$this->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 .= ",note_private=".(!empty($this->note_private)?("'".$this->db->escape($this->note_private)."'"):"NULL"); @@ -497,14 +497,14 @@ class Don extends CommonObject $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.fk_pays, d.public, d.amount, d.fk_paiement, d.note_private, d.note_public, cp.libelle, d.email, d.phone, "; + $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_don_projet,"; $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.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.fk_pays = c.rowid"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as cp ON cp.id = d.fk_payment"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON d.fk_country = c.rowid"; $sql.= " WHERE d.rowid = ".$rowid." AND d.entity = ".$conf->entity; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); @@ -528,17 +528,19 @@ 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_id = $obj->country_id; + $this->country_code = $obj->country_code; + $this->country = $obj->country; + $this->country_olddata= $obj->country_olddata; + $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->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; @@ -597,7 +599,7 @@ class Don extends CommonObject $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"; diff --git a/htdocs/compta/dons/class/paymentdonation.class.php b/htdocs/compta/dons/class/paymentdonation.class.php new file mode 100644 index 00000000000..65d72fbfb52 --- /dev/null +++ b/htdocs/compta/dons/class/paymentdonation.class.php @@ -0,0 +1,607 @@ + + * + * 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 . + */ + +/** + * \file htdocs/compta/dons/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 $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->datepaye) + { + $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->datepaye)."',"; + $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_sc' 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 PaymentSocialContribution($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_sc' + * @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_sc') $total=-$total; + + // Insert payment into llx_bank + $bank_line_id = $acc->addline( + $this->datepaye, + $this->paymenttype, // Payment mode id or code ("CHQ or VIR for example") + $label, + $total, + $this->num_payment, + '', + $user, + $emetteur_nom, + $emetteur_banque + ); + + // Mise a jour fk_bank dans 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_sc' in bank_url between payment and bank transaction + $url=''; + if ($mode == 'payment_sc') $url=DOL_URL_ROOT.'/compta/payment_sc/card.php?id='; + if ($url) + { + $result=$acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode); + if ($result <= 0) + { + $error++; + dol_print_error($this->db); + } + } + + // Add link 'company' in bank_url between invoice and bank transaction (for each invoice concerned by payment) + $linkaddedforthirdparty=array(); + foreach ($this->amounts as $key => $value) + { + if ($mode == 'payment_sc') + { + $socialcontrib = new ChargeSociales($this->db); + $socialcontrib->fetch($key); + $result=$acc->add_url_line($bank_line_id, $socialcontrib->id, DOL_URL_ROOT.'/compta/charges.php?id=', $socialcontrib->type_libelle.(($socialcontrib->lib && $socialcontrib->lib!=$socialcontrib->type_libelle)?' ('.$socialcontrib->lib.')':''),'sc'); + if ($result <= 0) dol_print_error($this->db); + } + } + } + else + { + $this->error=$acc->error; + $error++; + } + } + + if (! $error) + { + return 1; + } + else + { + return -1; + } + } + + + /** + * Mise a jour du lien entre le paiement de charge et la ligne dans llx_bank generee + * + * @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 = ''; + $linkend=''; + + 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; + } +} + + diff --git a/htdocs/compta/dons/payment.php b/htdocs/compta/dons/payment.php new file mode 100644 index 00000000000..12b0296ca5a --- /dev/null +++ b/htdocs/compta/dons/payment.php @@ -0,0 +1,313 @@ + + * + * 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 . + */ + +/** + * \file htdocs/compta/dons/payment.php + * \ingroup Donation + * \brief Page to add payment of a donation + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/dons/class/don.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/dons/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.'/compta/dons/card.php?rowid='.$chid; + header("Location: ".$loc); + exit; + } + + $datepaye = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + + if (! $_POST["paymenttype"] > 0) + { + $mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode")); + $error++; + } + if ($datepaye == '') + { + $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->datepaye = $datepaye; + $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.'/compta/dons/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 "
\n"; + + if ($mesg) + { + print "
$mesg
"; + } + + print '
'; + print ''; + print ''; + print ''; + print ''; + + print ''; + + print ''; + + print ''; + print '\n"; + print ''; + + $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 ''; + print ''; + + print ''; + print "'; + print ''; + + print '"; + print ''; + + print '\n"; + print ''; + + print ''; + print ''; + print ''; + + // Number + print ''; + print ''."\n"; + + print ''; + print ''; + print ''; + print ''; + + print '
'.$langs->trans("Donation").'
'.$langs->trans("Ref").''.$chid.'
'.$langs->trans("Date")."".dol_print_date($don->date,'day')."
'.$langs->trans("Amount")."".price($don->amount,0,$outputlangs,1,-1,-1,$conf->currency).'
'.$langs->trans("AlreadyPaid").''.price($sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'
'.$langs->trans("RemainderToPay").''.price($total-$sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'
".$langs->trans("Payment").'
'.$langs->trans("Date").''; + $datepaye = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + $datepayment=empty($conf->global->MAIN_AUTOFILL_DATE)?(empty($_POST["remonth"])?-1:$datepaye):0; + $form->select_date($datepayment,'','','','',"add_payment",1,1); + print "
'.$langs->trans("PaymentMode").''; + $form->select_types_paiements(isset($_POST["paymenttype"])?$_POST["paymenttype"]:$don->paymenttype, "paymenttype"); + print "
'.$langs->trans('AccountToDebit').''; + $form->select_comptes(isset($_POST["accountid"])?$_POST["accountid"]:$don->accountid, "accountid", 0, '',1); // Show opend bank account list + print '
'.$langs->trans('Numero'); + print ' ('.$langs->trans("ChequeOrTransferNumber").')'; + print '
'.$langs->trans("Comments").'
'; + + print '
'; + + /* + * Autres charges impayees + */ + $num = 1; + $i = 0; + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + $var=true; + $total=0; + $totalrecu=0; + + while ($i < $num) + { + $objp = $don; + + $var=!$var; + + print ""; + + print '"; + + print '"; + + print '"; + + print '"; + + print "\n"; + $total+=$objp->total; + $total_ttc+=$objp->total_ttc; + $totalrecu+=$objp->am; + $i++; + } + if ($i > 1) + { + // Print total + print ""; + print ''; + print ""; + print ""; + print ""; + print ''; + print "\n"; + } + + print "
'.$langs->trans("Amount").''.$langs->trans("AlreadyPaid").''.$langs->trans("RemainderToPay").''.$langs->trans("Amount").'
'.price($objp->amount)."'.price($sumpaid)."'.price($objp->amount - $sumpaid)."'; + if ($sumpaid < $objp->amount) + { + $namef = "amount_".$objp->id; + print ''; + } + else + { + print '-'; + } + print "
'.$langs->trans("Total").':".price($total_ttc)."".price($totalrecu)."".price($total_ttc - $totalrecu)." 
"; + + print '
'; + print ''; + print '     '; + print ''; + print '
'; + + print "
\n"; +} + + +$db->close(); + +llxFooter(); diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index d2520973275..c92c78014cb 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -372,4 +372,22 @@ 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_pays integer NOT NULL after country; +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; + +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; diff --git a/htdocs/install/mysql/tables/llx_don.sql b/htdocs/install/mysql/tables/llx_don.sql index bf434e11518..d4e03c55d0c 100644 --- a/htdocs/install/mysql/tables/llx_don.sql +++ b/htdocs/install/mysql/tables/llx_don.sql @@ -2,6 +2,7 @@ -- Copyright (C) 2001-2002 Rodolphe Quiedeville -- Copyright (C) 2009 Regis Houssin -- Copyright (C) 2011 Laurent Destailleur +-- Copyright (C) 2015 Alexandre Spangaro -- -- 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 @@ -29,15 +30,16 @@ create table llx_don 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), -- Deprecated - Replace with fk_pays - fk_pays integer NOT NULL, + country varchar(50), -- Deprecated - Replace with fk_country + fk_country integer NOT NULL, email varchar(255), phone varchar(24), phone_mobile varchar(24), diff --git a/htdocs/install/mysql/tables/llx_payment_donation.sql b/htdocs/install/mysql/tables/llx_payment_donation.sql new file mode 100644 index 00000000000..0389a59e06e --- /dev/null +++ b/htdocs/install/mysql/tables/llx_payment_donation.sql @@ -0,0 +1,33 @@ +-- =================================================================== +-- Copyright (C) 2015 Alexandre Spangaro +-- +-- 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 . +-- +-- =================================================================== + +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; From e6d9d18f252613b5fc92bf9e72a6a0347c7644de Mon Sep 17 00:00:00 2001 From: aspangaro Date: Wed, 18 Mar 2015 06:29:10 +0100 Subject: [PATCH 03/27] Update work on donation --- htdocs/compta/dons/card.php | 36 ++++++------------- htdocs/compta/dons/class/don.class.php | 12 +++---- .../dons/class/paymentdonation.class.php | 21 +++++------ htdocs/compta/dons/payment.php | 14 ++++---- .../install/mysql/migration/3.7.0-3.8.0.sql | 1 + htdocs/install/mysql/tables/llx_don.sql | 2 +- 6 files changed, 37 insertions(+), 49 deletions(-) diff --git a/htdocs/compta/dons/card.php b/htdocs/compta/dons/card.php index 0c4c92cecd7..d20af7f8ba6 100644 --- a/htdocs/compta/dons/card.php +++ b/htdocs/compta/dons/card.php @@ -32,7 +32,8 @@ 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)) { +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'; @@ -99,7 +100,7 @@ if ($action == 'update') $object->email = GETPOST("email"); $object->date = $donation_date; $object->public = GETPOST("public"); - $object->fk_project = GETPOST("projectid"); + $object->fk_project = GETPOST("fk_project"); $object->note_private= GETPOST("note_private"); $object->note_public = GETPOST("note_public"); @@ -334,10 +335,9 @@ if ($action == 'create') $formproject=new FormProjets($db); - // Si module projet actif print "".$langs->trans("Project").""; - $formproject->select_projects('',GETPOST("projectid"),"projectid"); - print "\n"; + $formproject->select_projects(-1, GETPOST("fk_project"),'fk_project', 0, 1, 0, 1); + print "\n"; } // Other attributes @@ -431,7 +431,7 @@ if (! empty($id) && $action == 'edit') $langs->load('projects'); print ''.$langs->trans('Project').''; - $formproject->select_projects(-1, (isset($_POST["projectid"])?$_POST["projectid"]:$don->fk_project), 'projectid'); + $formproject->select_projects(-1, $object->fk_project,'fk_project', 0, 1, 0, 1); print ''; } @@ -523,7 +523,10 @@ if (! empty($id) && $action != 'edit') // Project if (! empty($conf->projet->enabled)) { - print "".''.$langs->trans("Project").''.$object->projet.''; + print ''; + print ''.$langs->trans("Project").''; + print ''.$object->projet.''; + print ''; } // Other attributes @@ -567,22 +570,6 @@ if (! empty($id) && $action != 'edit') } } - /* - // Classify paid - if ($object->statut == 1 && $object->paye == 0 && $user->rights->facture->paiement && (($object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT && $resteapayer <= 0) || ($object->type == Facture::TYPE_CREDIT_NOTE && $resteapayer >= 0)) - || ($object->type == Facture::TYPE_DEPOSIT && $object->paye == 0 && $resteapayer == 0 && $user->rights->facture->paiement && empty($discount->id)) - ) - { - print ''; - } - - // Emit payment - if ($object->statut == 1 && $object->paid == 0 && ((price2num($object->amount) > 0 && round($remaintopay) > 0)) && $user->rights->don->creer) - { - print ''; - } - */ - // Classify 'paid' if ($object->statut == 1 && round($remaintopay) == 0 && $object->paid == 0 && $user->rights->don->creer) { @@ -625,6 +612,5 @@ if (! empty($id) && $action != 'edit') } - llxFooter(); -$db->close(); +$db->close(); \ No newline at end of file diff --git a/htdocs/compta/dons/class/don.class.php b/htdocs/compta/dons/class/don.class.php index b677a3afad2..273d54a6eef 100644 --- a/htdocs/compta/dons/class/don.class.php +++ b/htdocs/compta/dons/class/don.class.php @@ -332,7 +332,7 @@ class Don extends CommonObject // $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"; @@ -415,7 +415,7 @@ class Don extends CommonObject $sql .= ",town='".$this->db->escape($this->town)."'"; $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)."'"; @@ -498,11 +498,11 @@ class Don extends CommonObject $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.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_don_projet,"; + $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."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"; $sql.= " WHERE d.rowid = ".$rowid." AND d.entity = ".$conf->entity; @@ -535,8 +535,8 @@ class Don extends CommonObject $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->modepaymentid = $obj->fk_payment; $this->modepayment = $obj->libelle; diff --git a/htdocs/compta/dons/class/paymentdonation.class.php b/htdocs/compta/dons/class/paymentdonation.class.php index 65d72fbfb52..907ea46bf72 100644 --- a/htdocs/compta/dons/class/paymentdonation.class.php +++ b/htdocs/compta/dons/class/paymentdonation.class.php @@ -33,6 +33,7 @@ class PaymentDonation extends CommonObject public $table_element='payment_donation'; //!< Name of table without prefix where object is stored var $id; + var $rowid; var $ref; var $fk_donation; @@ -74,7 +75,7 @@ class PaymentDonation extends CommonObject $now=dol_now(); // Validate parameters - if (! $this->datepaye) + if (! $this->datepaid) { $this->error='ErrorBadValueForParameterCreatePaymentDonation'; return -1; @@ -110,7 +111,7 @@ class PaymentDonation extends CommonObject $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->datepaye)."',"; + $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)"; @@ -485,7 +486,7 @@ class PaymentDonation extends CommonObject // Insert payment into llx_bank $bank_line_id = $acc->addline( - $this->datepaye, + $this->datepaid, $this->paymenttype, // Payment mode id or code ("CHQ or VIR for example") $label, $total, @@ -496,7 +497,7 @@ class PaymentDonation extends CommonObject $emetteur_banque ); - // Mise a jour fk_bank dans llx_paiement. + // Update fk_bank in llx_paiement. // On connait ainsi le paiement qui a genere l'ecriture bancaire if ($bank_line_id > 0) { @@ -509,7 +510,7 @@ class PaymentDonation extends CommonObject // Add link 'payment', 'payment_supplier', 'payment_sc' in bank_url between payment and bank transaction $url=''; - if ($mode == 'payment_sc') $url=DOL_URL_ROOT.'/compta/payment_sc/card.php?id='; + if ($mode == 'payment_donation') $url=DOL_URL_ROOT.'/compta/dons/card.php?rowid='; if ($url) { $result=$acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode); @@ -520,15 +521,15 @@ class PaymentDonation extends CommonObject } } - // Add link 'company' in bank_url between invoice and bank transaction (for each invoice concerned by payment) + // Add link 'thirdparty' in bank_url between donation and bank transaction (for each donation concerned by payment) $linkaddedforthirdparty=array(); foreach ($this->amounts as $key => $value) { - if ($mode == 'payment_sc') + if ($mode == 'payment_donation') { - $socialcontrib = new ChargeSociales($this->db); - $socialcontrib->fetch($key); - $result=$acc->add_url_line($bank_line_id, $socialcontrib->id, DOL_URL_ROOT.'/compta/charges.php?id=', $socialcontrib->type_libelle.(($socialcontrib->lib && $socialcontrib->lib!=$socialcontrib->type_libelle)?' ('.$socialcontrib->lib.')':''),'sc'); + $don = new Don($this->db); + $don->fetch($key); + $result=$acc->add_url_line($bank_line_id, $don->rowid, DOL_URL_ROOT.'/compta/card.php?rowid=', $don->type_libelle.(($don->lib && $don->lib!=$don->type_libelle)?' ('.$don->lib.')':''),'sc'); if ($result <= 0) dol_print_error($this->db); } } diff --git a/htdocs/compta/dons/payment.php b/htdocs/compta/dons/payment.php index 12b0296ca5a..948cd221b0c 100644 --- a/htdocs/compta/dons/payment.php +++ b/htdocs/compta/dons/payment.php @@ -55,14 +55,14 @@ if ($action == 'add_payment') exit; } - $datepaye = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + $datepaid = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); if (! $_POST["paymenttype"] > 0) { $mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("PaymentMode")); $error++; } - if ($datepaye == '') + if ($datepaid == '') { $mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("Date")); $error++; @@ -100,7 +100,7 @@ if ($action == 'add_payment') // Create a line of payments $payment = new PaymentDonation($db); $payment->chid = $chid; - $payment->datepaye = $datepaye; + $payment->datepaid = $datepaid; $payment->amounts = $amounts; // Tableau de montant $payment->paymenttype = $_POST["paymenttype"]; $payment->num_payment = $_POST["num_payment"]; @@ -202,8 +202,8 @@ if (GETPOST("action") == 'create') print ''; print ''.$langs->trans("Date").''; - $datepaye = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); - $datepayment=empty($conf->global->MAIN_AUTOFILL_DATE)?(empty($_POST["remonth"])?-1:$datepaye):0; + $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 ""; print ''; @@ -214,9 +214,9 @@ if (GETPOST("action") == 'create') print ''; print ''; - print ''.$langs->trans('AccountToDebit').''; + print ''.$langs->trans('AccountToCredit').''; print ''; - $form->select_comptes(isset($_POST["accountid"])?$_POST["accountid"]:$don->accountid, "accountid", 0, '',1); // Show opend bank account list + $form->select_comptes(isset($_POST["accountid"])?$_POST["accountid"]:$don->accountid, "accountid", 0, '',1); // Show open bank account list print ''; // Number diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index c92c78014cb..b07974b8889 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -375,6 +375,7 @@ ALTER TABLE llx_societe_extrafields ADD UNIQUE INDEX uk_societe_extrafields (fk_ 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_payment_donation ( diff --git a/htdocs/install/mysql/tables/llx_don.sql b/htdocs/install/mysql/tables/llx_don.sql index d4e03c55d0c..a3882fc6f99 100644 --- a/htdocs/install/mysql/tables/llx_don.sql +++ b/htdocs/install/mysql/tables/llx_don.sql @@ -44,7 +44,7 @@ create table llx_don 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 + fk_project integer NULL, -- projet auquel est fait le don fk_user_author integer NOT NULL, fk_user_valid integer NULL, note_private text, From dbeccf765307252dfec7a8576e80ff158db9a9f8 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Wed, 18 Mar 2015 21:56:00 +0100 Subject: [PATCH 04/27] Update work --- htdocs/compta/dons/card.php | 97 ++++++++++++++++++++++++++++++++----- htdocs/projet/element.php | 23 ++++++--- 2 files changed, 103 insertions(+), 17 deletions(-) diff --git a/htdocs/compta/dons/card.php b/htdocs/compta/dons/card.php index d20af7f8ba6..88331bb5498 100644 --- a/htdocs/compta/dons/card.php +++ b/htdocs/compta/dons/card.php @@ -404,7 +404,7 @@ if (! empty($id) && $action == 'edit') 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 ''; + print ''; // Country print ''.$langs->trans('Country').''; @@ -478,26 +478,101 @@ if (! empty($id) && $action != 'edit') print ''; // Date - print ''.$langs->trans("Date").''; + print ''.$langs->trans("Date").''; print dol_print_date($object->date,"day"); print ""; - print "".''.$langs->trans("Amount").''.price($object->amount,0,$langs,0,0,-1,$conf->currency).''; + print ''.$langs->trans("Amount").''; + print price($object->amount,0,$langs,0,0,-1,$conf->currency); + print ''; - print "".$langs->trans("PublicDonation").""; + print ''.$langs->trans("PublicDonation").''; print yn($object->public); - print "\n"; + print ''; - print "".''.$langs->trans("Company").''.$object->societe.''; - print "".''.$langs->trans("Lastname").''.$object->lastname.''; - print "".''.$langs->trans("Firstname").''.$object->firstname.''; - print "".''.$langs->trans("Address").''.dol_nl2br($object->address).''; + print "".''.$langs->trans("Company").''.$object->societe.''; + print "".''.$langs->trans("Lastname").''.$object->lastname.''; + print "".''.$langs->trans("Firstname").''.$object->firstname.''; + print "".''.$langs->trans("Address").''.dol_nl2br($object->address).''; + + $rowspan=6; + if (! empty($conf->projet->enabled)) $rowspan++; + print ''; + + /* + * Payments + */ + $sql = "SELECT p.rowid, p.num_payment, 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 = '".$rowid."'"; + $sql.= " AND p.fk_donation = d.rowid"; + $sql.= " AND d.entity = ".$conf->entity; + $sql.= " AND p.fk_typepayment = c.id"; + $sql.= " ORDER BY dp DESC"; + + //print $sql; + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; $total = 0; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + $var=True; + while ($i < $num) + { + $objp = $db->fetch_object($resql); + $var=!$var; + print "'; + print '\n"; + $labeltype=$langs->trans("PaymentType".$object->type_code)!=("PaymentType".$object->type_code)?$langs->trans("PaymentType".$object->type_code):$object->paiement_type; + print "\n"; + print '\n"; + print ""; + $totalpaid += $object->amount; + $i++; + } + + if ($object->paid == 0) + { + print "\n"; + print "\n"; + + $remaintopay = $object->amount - $totalpaid; + + print ""; + print "\n"; + } + print "
'.$langs->trans("RefPayment").''.$langs->trans("Date").''.$langs->trans("Type").''.$langs->trans("Amount").' 
"; + print ''.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.''.dol_print_date($db->jdate($objp->dp),'day')."".$labeltype.' '.$object->num_paiement."'.price($object->amount)." ".$langs->trans("Currency".$conf->currency)."
".$langs->trans("AlreadyPaid")." :".price($totalpaye)." ".$langs->trans("Currency".$conf->currency)."
".$langs->trans("AmountExpected")." :".price($object->amount)." ".$langs->trans("Currency".$conf->currency)."
".$langs->trans("RemainderToPay")." :".price($resteapayer)." ".$langs->trans("Currency".$conf->currency)."
"; + $db->free($resql); + } + else + { + dol_print_error($db); + } + print ""; + + print ""; // Zip / Town - print "".''.$langs->trans("Zip").' / '.$langs->trans("Town").''.$object->zip.($object->zip && $object->town?' / ':'').$object->town.''; + print ''.$langs->trans("Zip").' / '.$langs->trans("Town").''; + print $object->zip.($object->zip && $object->town?' / ':'').$object->town.''; + + // Country - print ''.$langs->trans('Country').''; + print ''.$langs->trans('Country').''; if (! empty($object->country_code)) { $img=picto_from_langcode($object->country_code); diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 3075d128066..a49914b538a 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2015 Alexandre Spangaro * * 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.'/compta/dons/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->expensereport->enabled)) $langs->load("donations"); $id=GETPOST('id','int'); $ref=GETPOST('ref','alpha'); @@ -244,7 +247,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") From 4e68586389eb7cb28745c2b07052678b14fd7f55 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 19 Mar 2015 05:08:23 +0100 Subject: [PATCH 05/27] Move module Dons in htdocs>donations --- htdocs/{ => donations}/admin/dons.php | 0 .../dons/class => donations/admin}/index.html | 0 htdocs/donations/admin/index.php | 117 ++++++++++++++++++ htdocs/{compta/dons => donations}/card.php | 0 .../dons => donations}/class/don.class.php | 0 htdocs/donations/class/index.html | 0 .../class/paymentdonation.class.php | 0 .../{compta/dons => donations}/document.php | 0 htdocs/donations/index.html | 0 htdocs/{compta/dons => donations}/index.php | 0 htdocs/{compta/dons => donations}/info.php | 0 htdocs/{compta/dons => donations}/list.php | 0 htdocs/{compta/dons => donations}/payment.php | 0 htdocs/{compta/dons => donations}/stats.php | 0 14 files changed, 117 insertions(+) rename htdocs/{ => donations}/admin/dons.php (100%) rename htdocs/{compta/dons/class => donations/admin}/index.html (100%) create mode 100644 htdocs/donations/admin/index.php rename htdocs/{compta/dons => donations}/card.php (100%) rename htdocs/{compta/dons => donations}/class/don.class.php (100%) create mode 100644 htdocs/donations/class/index.html rename htdocs/{compta/dons => donations}/class/paymentdonation.class.php (100%) rename htdocs/{compta/dons => donations}/document.php (100%) create mode 100644 htdocs/donations/index.html rename htdocs/{compta/dons => donations}/index.php (100%) rename htdocs/{compta/dons => donations}/info.php (100%) rename htdocs/{compta/dons => donations}/list.php (100%) rename htdocs/{compta/dons => donations}/payment.php (100%) rename htdocs/{compta/dons => donations}/stats.php (100%) diff --git a/htdocs/admin/dons.php b/htdocs/donations/admin/dons.php similarity index 100% rename from htdocs/admin/dons.php rename to htdocs/donations/admin/dons.php diff --git a/htdocs/compta/dons/class/index.html b/htdocs/donations/admin/index.html similarity index 100% rename from htdocs/compta/dons/class/index.html rename to htdocs/donations/admin/index.html diff --git a/htdocs/donations/admin/index.php b/htdocs/donations/admin/index.php new file mode 100644 index 00000000000..78ff3b48f9a --- /dev/null +++ b/htdocs/donations/admin/index.php @@ -0,0 +1,117 @@ + + * + * 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 . + * + */ + +/** + * \file htdocs/admin/index.php + * \ingroup Donations + * \brief Setup page to configure donations module + */ + +require '../main.inc.php'; + +// Class +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; + +$langs->load("admin"); +$langs->load("donations"); + +// Security check +if (!$user->admin) + accessforbidden(); + +$action = GETPOST('action', 'alpha'); + +// Other parameters DONATIONS_* +$list = array ( + 'DONATIONS_ACCOUNTING_ACCOUNT_PRODUCT' +); + +/* + * Actions + */ + +if ($action == 'update') +{ + $error = 0; + + foreach ($list as $constname) { + $constvalue = GETPOST($constname, 'alpha'); + + if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { + $error++; + } + } + + if (! $error) + { + setEventMessage($langs->trans("SetupSaved")); + } + else + { + setEventMessage($langs->trans("Error"),'errors'); + } +} + +/* + * View + */ + +llxHeader('',$langs->trans('DonationsSetup')); + +$form = new Form($db); + +$linkback=''.$langs->trans("BackToModuleList").''; +print_fiche_titre($langs->trans('DonationsSetup'),$linkback,'setup'); + +print '
'; +print ''; +print ''; + +/* + * Params + */ +print ''; +print ''; +print ''; +print "\n"; + +foreach ($list as $key) +{ + $var=!$var; + + print ''; + + // Param + $label = $langs->trans($key); + print ''; + + // Value + print ''; +} + +print ''; + +print ''; +print "
' . $langs->trans('Options') . '
'; + print ''; + print '
\n"; + +print '
'; + +llxFooter(); +$db->close(); \ No newline at end of file diff --git a/htdocs/compta/dons/card.php b/htdocs/donations/card.php similarity index 100% rename from htdocs/compta/dons/card.php rename to htdocs/donations/card.php diff --git a/htdocs/compta/dons/class/don.class.php b/htdocs/donations/class/don.class.php similarity index 100% rename from htdocs/compta/dons/class/don.class.php rename to htdocs/donations/class/don.class.php diff --git a/htdocs/donations/class/index.html b/htdocs/donations/class/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/compta/dons/class/paymentdonation.class.php b/htdocs/donations/class/paymentdonation.class.php similarity index 100% rename from htdocs/compta/dons/class/paymentdonation.class.php rename to htdocs/donations/class/paymentdonation.class.php diff --git a/htdocs/compta/dons/document.php b/htdocs/donations/document.php similarity index 100% rename from htdocs/compta/dons/document.php rename to htdocs/donations/document.php diff --git a/htdocs/donations/index.html b/htdocs/donations/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/compta/dons/index.php b/htdocs/donations/index.php similarity index 100% rename from htdocs/compta/dons/index.php rename to htdocs/donations/index.php diff --git a/htdocs/compta/dons/info.php b/htdocs/donations/info.php similarity index 100% rename from htdocs/compta/dons/info.php rename to htdocs/donations/info.php diff --git a/htdocs/compta/dons/list.php b/htdocs/donations/list.php similarity index 100% rename from htdocs/compta/dons/list.php rename to htdocs/donations/list.php diff --git a/htdocs/compta/dons/payment.php b/htdocs/donations/payment.php similarity index 100% rename from htdocs/compta/dons/payment.php rename to htdocs/donations/payment.php diff --git a/htdocs/compta/dons/stats.php b/htdocs/donations/stats.php similarity index 100% rename from htdocs/compta/dons/stats.php rename to htdocs/donations/stats.php From 7b6cb59f4bc1994c54680e086563055dd630ecc9 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 19 Mar 2015 05:17:10 +0100 Subject: [PATCH 06/27] Move module Don in htdocs->donations --- htdocs/{ => donations}/core/lib/donation.lib.php | 0 .../core/modules/dons/html_cerfafr.html | 0 .../core/modules/dons/html_cerfafr.modules.php | 0 htdocs/{ => donations}/core/modules/dons/index.html | 0 .../{ => donations}/core/modules/dons/modules_don.php | 0 htdocs/{ => donations}/core/modules/modDon.class.php | 10 +++++----- 6 files changed, 5 insertions(+), 5 deletions(-) rename htdocs/{ => donations}/core/lib/donation.lib.php (100%) rename htdocs/{ => donations}/core/modules/dons/html_cerfafr.html (100%) rename htdocs/{ => donations}/core/modules/dons/html_cerfafr.modules.php (100%) rename htdocs/{ => donations}/core/modules/dons/index.html (100%) rename htdocs/{ => donations}/core/modules/dons/modules_don.php (100%) rename htdocs/{ => donations}/core/modules/modDon.class.php (95%) diff --git a/htdocs/core/lib/donation.lib.php b/htdocs/donations/core/lib/donation.lib.php similarity index 100% rename from htdocs/core/lib/donation.lib.php rename to htdocs/donations/core/lib/donation.lib.php diff --git a/htdocs/core/modules/dons/html_cerfafr.html b/htdocs/donations/core/modules/dons/html_cerfafr.html similarity index 100% rename from htdocs/core/modules/dons/html_cerfafr.html rename to htdocs/donations/core/modules/dons/html_cerfafr.html diff --git a/htdocs/core/modules/dons/html_cerfafr.modules.php b/htdocs/donations/core/modules/dons/html_cerfafr.modules.php similarity index 100% rename from htdocs/core/modules/dons/html_cerfafr.modules.php rename to htdocs/donations/core/modules/dons/html_cerfafr.modules.php diff --git a/htdocs/core/modules/dons/index.html b/htdocs/donations/core/modules/dons/index.html similarity index 100% rename from htdocs/core/modules/dons/index.html rename to htdocs/donations/core/modules/dons/index.html diff --git a/htdocs/core/modules/dons/modules_don.php b/htdocs/donations/core/modules/dons/modules_don.php similarity index 100% rename from htdocs/core/modules/dons/modules_don.php rename to htdocs/donations/core/modules/dons/modules_don.php diff --git a/htdocs/core/modules/modDon.class.php b/htdocs/donations/core/modules/modDon.class.php similarity index 95% rename from htdocs/core/modules/modDon.class.php rename to htdocs/donations/core/modules/modDon.class.php index b1b265146a4..bf5db49ec82 100644 --- a/htdocs/core/modules/modDon.class.php +++ b/htdocs/donations/core/modules/modDon.class.php @@ -2,7 +2,7 @@ /* Copyright (C) 2003-2005 Rodolphe Quiedeville * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2011 Regis Houssin - * Copyright (C) 2014 Alexandre Spangaro + * Copyright (C) 2015 Alexandre Spangaro * * 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 @@ -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("dons.php@donations"); // 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); } -} +} \ No newline at end of file From fa411323722b34adba3072f86f2e40abb75031b5 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 19 Mar 2015 05:22:42 +0100 Subject: [PATCH 07/27] Move module Don in htdocs->donations --- htdocs/compta/index.php | 4 ++-- htdocs/compta/resultat/clientfourn.php | 2 +- htdocs/core/menus/init_menu_auguria.sql | 8 ++++---- htdocs/core/menus/standard/eldy.lib.php | 8 ++++---- htdocs/donations/admin/dons.php | 2 +- htdocs/donations/card.php | 10 +++++----- htdocs/donations/class/don.class.php | 4 ++-- htdocs/donations/class/paymentdonation.class.php | 4 ++-- htdocs/donations/core/lib/donation.lib.php | 6 +++--- .../core/modules/dons/html_cerfafr.modules.php | 2 +- htdocs/donations/core/modules/dons/modules_don.php | 2 +- htdocs/donations/document.php | 6 +++--- htdocs/donations/index.php | 4 ++-- htdocs/donations/info.php | 4 ++-- htdocs/donations/list.php | 4 ++-- htdocs/donations/payment.php | 12 ++++++------ htdocs/donations/stats.php | 2 +- 17 files changed, 42 insertions(+), 42 deletions(-) diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index b1d32083a8a..9af8296f84d 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -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 '
'; + print ''; print ''; print ''; print ''; @@ -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.'/donations/class/don.class.php'; $langs->load("boxes"); $donationstatic=new Don($db); diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 09469329069..4f1ff225417 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -651,7 +651,7 @@ if ($conf->donation->enabled) $var = !$var; print ""; - print "\n"; + print "\n"; if ($modecompta == 'CREANCES-DETTES') print ''; print ''; diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index b2f81ed1769..87e8f6a9ec2 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -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__, '/donations/index.php?leftmenu=donations&mainmenu=accountancy', 'Donations', 0, 'donations', '$user->rights->don->lire', '', 2, 4, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->don->enabled && $leftmenu=="donations"', __HANDLER__, 'left', 2001__+MAX_llx_menu__, 'accountancy', '', 2000__+MAX_llx_menu__, '/donations/card.php?leftmenu=donations&mainmenu=accountancy&action=create', 'NewDonation', 1, 'donations', '$user->rights->don->creer', '', 2, 0, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->don->enabled && $leftmenu=="donations"', __HANDLER__, 'left', 2002__+MAX_llx_menu__, 'accountancy', '', 2000__+MAX_llx_menu__, '/donations/list.php?leftmenu=donations&mainmenu=accountancy', 'List', 1, 'donations', '$user->rights->don->lire', '', 2, 1, __ENTITY__); +--insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->don->enabled && $leftmenu=="donations"', __HANDLER__, 'left', 2003__+MAX_llx_menu__, 'accountancy', '', 2000__+MAX_llx_menu__, '/donations/stats.php?leftmenu=donations&mainmenu=accountancy', 'Statistics', 1, 'donations', '$user->rights->don->lire', '', 2, 2, __ENTITY__); -- 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__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 24af20ea4af..95cbad199a7 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -788,10 +788,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("/donations/index.php?leftmenu=donations&mainmenu=accountancy",$langs->trans("Donations"), 0, $user->rights->don->lire, '', $mainmenu, 'donations'); + if (empty($leftmenu) || $leftmenu=="donations") $newmenu->add("/donations/card.php?action=create",$langs->trans("NewDonation"), 1, $user->rights->don->creer); + if (empty($leftmenu) || $leftmenu=="donations") $newmenu->add("/donations/list.php",$langs->trans("List"), 1, $user->rights->don->lire); + //if ($leftmenu=="donations") $newmenu->add("/donations/stats.php",$langs->trans("Statistics"), 1, $user->rights->don->lire); } // Taxes and social contributions diff --git a/htdocs/donations/admin/dons.php b/htdocs/donations/admin/dons.php index dcac1079422..f4afddc65d0 100644 --- a/htdocs/donations/admin/dons.php +++ b/htdocs/donations/admin/dons.php @@ -25,7 +25,7 @@ */ 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.'/donations/class/don.class.php'; $langs->load("admin"); $langs->load("donations"); diff --git a/htdocs/donations/card.php b/htdocs/donations/card.php index 88331bb5498..79b97c2fde3 100644 --- a/htdocs/donations/card.php +++ b/htdocs/donations/card.php @@ -20,7 +20,7 @@ */ /** - * \file htdocs/compta/dons/card.php + * \file htdocs/donations/card.php * \ingroup don * \brief Page of donation card */ @@ -30,7 +30,7 @@ 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.'/compta/dons/class/don.class.php'; +require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; if (! empty($conf->projet->enabled)) { @@ -466,7 +466,7 @@ if (! empty($id) && $action != 'edit') print ''; print '
'.$langs->trans("SearchADonation").'
 ".$langs->trans("Donation")." name."&search_name=".$obj->firstname." ".$obj->lastname."\">".$obj->name. " ".$obj->firstname." ".$obj->lastname."".$langs->trans("Donation")." name."&search_name=".$obj->firstname." ".$obj->lastname."\">".$obj->name. " ".$obj->firstname." ".$obj->lastname."'.price($obj->amount).''.price($obj->amount).'
'; - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; $nbrows=12; if (! empty($conf->projet->enabled)) $nbrows++; @@ -534,7 +534,7 @@ if (! empty($id) && $action != 'edit') $objp = $db->fetch_object($resql); $var=!$var; print "'; + print ''.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.''; print '\n"; $labeltype=$langs->trans("PaymentType".$object->type_code)!=("PaymentType".$object->type_code)?$langs->trans("PaymentType".$object->type_code):$object->paiement_type; print "\n"; @@ -641,7 +641,7 @@ if (! empty($id) && $action != 'edit') } else { - print ''; + print ''; } } diff --git a/htdocs/donations/class/don.class.php b/htdocs/donations/class/don.class.php index 273d54a6eef..51c3958f2e6 100644 --- a/htdocs/donations/class/don.class.php +++ b/htdocs/donations/class/don.class.php @@ -20,7 +20,7 @@ */ /** - * \file htdocs/compta/dons/class/don.class.php + * \file htdocs/donations/class/don.class.php * \ingroup Donation * \brief File of class to manage donations */ @@ -723,7 +723,7 @@ class Don extends CommonObject $result=''; $label=$langs->trans("ShowDonation").': '.$this->id; - $link = ''; + $link = ''; $linkend=''; $picto='generic'; diff --git a/htdocs/donations/class/paymentdonation.class.php b/htdocs/donations/class/paymentdonation.class.php index 907ea46bf72..72d1709b252 100644 --- a/htdocs/donations/class/paymentdonation.class.php +++ b/htdocs/donations/class/paymentdonation.class.php @@ -16,7 +16,7 @@ */ /** - * \file htdocs/compta/dons/class/paymentdonation.class.php + * \file htdocs/donations/class/paymentdonation.class.php * \ingroup Donation * \brief File of class to manage payment of donations */ @@ -510,7 +510,7 @@ class PaymentDonation extends CommonObject // Add link 'payment', 'payment_supplier', 'payment_sc' in bank_url between payment and bank transaction $url=''; - if ($mode == 'payment_donation') $url=DOL_URL_ROOT.'/compta/dons/card.php?rowid='; + if ($mode == 'payment_donation') $url=DOL_URL_ROOT.'/donations/card.php?rowid='; if ($url) { $result=$acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode); diff --git a/htdocs/donations/core/lib/donation.lib.php b/htdocs/donations/core/lib/donation.lib.php index dcbe2d30e84..c274811bca1 100644 --- a/htdocs/donations/core/lib/donation.lib.php +++ b/htdocs/donations/core/lib/donation.lib.php @@ -34,7 +34,7 @@ function donation_prepare_head($object) $h = 0; $head = array (); - $head[$h][0] = DOL_URL_ROOT . '/compta/dons/card.php?id=' . $object->id; + $head[$h][0] = DOL_URL_ROOT . '/donations/card.php?id=' . $object->id; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; $h ++; @@ -45,12 +45,12 @@ function donation_prepare_head($object) // $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 . '/compta/dons/document.php?id='.$object->id; + $head[$h][0] = DOL_URL_ROOT . '/donations/document.php?id='.$object->id; $head[$h][1] = $langs->trans("Documents"); $head[$h][2] = 'documents'; $h++; - $head[$h][0] = DOL_URL_ROOT . '/compta/dons/info.php?id=' . $object->id; + $head[$h][0] = DOL_URL_ROOT . '/donations/info.php?id=' . $object->id; $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++; diff --git a/htdocs/donations/core/modules/dons/html_cerfafr.modules.php b/htdocs/donations/core/modules/dons/html_cerfafr.modules.php index b4cc2795c1a..0efaf8c4524 100644 --- a/htdocs/donations/core/modules/dons/html_cerfafr.modules.php +++ b/htdocs/donations/core/modules/dons/html_cerfafr.modules.php @@ -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.'/donations/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; diff --git a/htdocs/donations/core/modules/dons/modules_don.php b/htdocs/donations/core/modules/dons/modules_don.php index 8c894e7fa1f..69db5bec011 100644 --- a/htdocs/donations/core/modules/dons/modules_don.php +++ b/htdocs/donations/core/modules/dons/modules_don.php @@ -25,7 +25,7 @@ * \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.'/donations/class/don.class.php'; diff --git a/htdocs/donations/document.php b/htdocs/donations/document.php index d4671097fad..16729a9bd81 100644 --- a/htdocs/donations/document.php +++ b/htdocs/donations/document.php @@ -16,13 +16,13 @@ */ /** - * \file htdocs/compta/dons/document.php + * \file htdocs/donations/document.php * \ingroup Donation * \brief Page of linked files into donations */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/dons/class/don.class.php'; +require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php'; @@ -96,7 +96,7 @@ if ($object->id) print '
"; - print ''.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.''.dol_print_date($db->jdate($objp->dp),'day')."".$labeltype.' '.$object->num_paiement."
'; - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; // Ref print ''; - print ''; + print ''; print '\n"; print ''; diff --git a/htdocs/donations/stats.php b/htdocs/donations/stats.php index 1fbde7c0ce7..7552c29ebc0 100644 --- a/htdocs/donations/stats.php +++ b/htdocs/donations/stats.php @@ -17,7 +17,7 @@ */ /** - * \file htdocs/compta/dons/stats.php + * \file htdocs/donations/stats.php * \ingroup don * \brief Page des statistiques de dons */ From c9d31dab3a5fc4c3e3cfbfbb6c99497da1be80e5 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 19 Mar 2015 05:41:13 +0100 Subject: [PATCH 08/27] Move module Dons in htdocs->donations --- htdocs/projet/element.php | 2 +- htdocs/public/donations/donateurs_code.php | 2 +- htdocs/public/donations/therm.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index a49914b538a..69dc6a539c1 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -42,7 +42,7 @@ 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.'/compta/dons/class/don.class.php'; +if (! empty($conf->don->enabled)) require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php'; $langs->load("projects"); $langs->load("companies"); diff --git a/htdocs/public/donations/donateurs_code.php b/htdocs/public/donations/donateurs_code.php index d2435f9f20f..ad42b7e0e7f 100644 --- a/htdocs/public/donations/donateurs_code.php +++ b/htdocs/public/donations/donateurs_code.php @@ -39,7 +39,7 @@ function llxHeaderVierge() { print 'Export agenda cal function llxFooterVierge() { print ''; } require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT .'/compta/dons/class/class/don.class.php'; +require_once DOL_DOCUMENT_ROOT .'/donations/class/class/don.class.php'; // Security check if (empty($conf->don->enabled)) accessforbidden('',1,1,1); diff --git a/htdocs/public/donations/therm.php b/htdocs/public/donations/therm.php index 1e111567c17..36bdec4637f 100644 --- a/htdocs/public/donations/therm.php +++ b/htdocs/public/donations/therm.php @@ -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.'/donations/class/don.class.php'; // Security check if (empty($conf->don->enabled)) accessforbidden('',1,1,1); From 0e01dbd44e845216a06b587f9124a211591106f5 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Fri, 20 Mar 2015 06:36:48 +0100 Subject: [PATCH 09/27] Update work --- htdocs/donations/admin/dons.php | 19 ++++++++++--------- htdocs/donations/card.php | 6 +++--- .../modules/dons/html_cerfafr.modules.php | 6 +++--- .../core/modules/dons/modules_don.php | 6 +++--- .../donations/core/modules/modDon.class.php | 6 +++--- htdocs/donations/document.php | 4 ++-- htdocs/donations/index.php | 2 +- htdocs/donations/info.php | 6 +++--- htdocs/donations/list.php | 6 +++--- htdocs/donations/payment.php | 4 ++-- htdocs/donations/stats.php | 2 +- htdocs/langs/en_US/donations.lang | 2 ++ 12 files changed, 36 insertions(+), 33 deletions(-) diff --git a/htdocs/donations/admin/dons.php b/htdocs/donations/admin/dons.php index f4afddc65d0..daf7b2f0e6d 100644 --- a/htdocs/donations/admin/dons.php +++ b/htdocs/donations/admin/dons.php @@ -2,7 +2,7 @@ /* Copyright (C) 2005-2010 Laurent Destailleur * Copyright (C) 2012-2013 Juanjo Menent * Copyright (C) 2013 Philippe Grand - * Copyright (C) 2014 Alexandre Spangaro + * Copyright (C) 2015 Alexandre Spangaro * * 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,14 @@ */ /** - * \file htdocs/admin/dons.php - * \ingroup dons - * \brief Page d'administration/configuration du module Dons + * \file htdocs/donations/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.'/donations/class/don.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $langs->load("admin"); $langs->load("donations"); @@ -52,7 +53,7 @@ if ($action == 'specimen') $don->initAsSpecimen(); // Search template files - $dir = DOL_DOCUMENT_ROOT . "/core/modules/dons/"; + $dir = DOL_DOCUMENT_ROOT . "/donations/core/modules/dons/"; $file = $modele.".modules.php"; if (file_exists($dir.$file)) { @@ -173,7 +174,7 @@ else if ($action == 'setart885') { * View */ -$dir = "../core/modules/dons/"; +$dir = DOL_DOCUMENT_ROOT.'/donations/core/modules/dons/'; $form=new Form($db); llxHeader('',$langs->trans("DonationsSetup"),'DonConfiguration'); @@ -191,7 +192,7 @@ print ''; print ''; print '
'.$langs->trans("Ref").''; diff --git a/htdocs/donations/index.php b/htdocs/donations/index.php index 100380bc128..9a4f13e7e4a 100644 --- a/htdocs/donations/index.php +++ b/htdocs/donations/index.php @@ -18,13 +18,13 @@ */ /** - * \file htdocs/compta/dons/index.php + * \file htdocs/donations/index.php * \ingroup don * \brief Home page of donation module */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/dons/class/don.class.php'; +require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php'; $langs->load("donations"); diff --git a/htdocs/donations/info.php b/htdocs/donations/info.php index ca2c03878d6..2121e379a65 100644 --- a/htdocs/donations/info.php +++ b/htdocs/donations/info.php @@ -16,7 +16,7 @@ */ /** - * \file htdocs/compta/dons/info.php + * \file htdocs/donations/info.php * \ingroup Donation * \brief Page to show a donation information */ @@ -24,7 +24,7 @@ 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.'/compta/dons/class/don.class.php'; +require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php'; $langs->load("donations"); diff --git a/htdocs/donations/list.php b/htdocs/donations/list.php index 95011ca0b74..5e0c1690413 100644 --- a/htdocs/donations/list.php +++ b/htdocs/donations/list.php @@ -19,13 +19,13 @@ */ /** - * \file htdocs/compta/dons/list.php + * \file htdocs/donations/list.php * \ingroup don * \brief Page de liste des dons */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/dons/class/don.class.php'; +require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php'; if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $langs->load("companies"); diff --git a/htdocs/donations/payment.php b/htdocs/donations/payment.php index 948cd221b0c..4df5b1c0e22 100644 --- a/htdocs/donations/payment.php +++ b/htdocs/donations/payment.php @@ -16,14 +16,14 @@ */ /** - * \file htdocs/compta/dons/payment.php + * \file htdocs/donations/payment.php * \ingroup Donation * \brief Page to add payment of a donation */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/dons/class/don.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/dons/class/paymentdonation.class.php'; +require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php'; +require_once DOL_DOCUMENT_ROOT.'/donations/class/paymentdonation.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; $langs->load("bills"); @@ -50,7 +50,7 @@ if ($action == 'add_payment') if ($_POST["cancel"]) { - $loc = DOL_URL_ROOT.'/compta/dons/card.php?rowid='.$chid; + $loc = DOL_URL_ROOT.'/donations/card.php?rowid='.$chid; header("Location: ".$loc); exit; } @@ -129,7 +129,7 @@ if ($action == 'add_payment') if (! $error) { $db->commit(); - $loc = DOL_URL_ROOT.'/compta/dons/card.php?rowid='.$chid; + $loc = DOL_URL_ROOT.'/donations/card.php?rowid='.$chid; header('Location: '.$loc); exit; } @@ -180,7 +180,7 @@ if (GETPOST("action") == 'create') print '
'.$langs->trans("Donation").'
'.$langs->trans("Ref").''.$chid.'
'.$langs->trans("Ref").''.$chid.'
'.$langs->trans("Date")."".dol_print_date($don->date,'day')."
'.$langs->trans("Amount")."".price($don->amount,0,$outputlangs,1,-1,-1,$conf->currency).'
'; print ''; -print ''; +print ''; print ''; print "\n"; $var=true; @@ -210,7 +211,7 @@ print ''; /* * French params */ -if ($conf->global->MAIN_LANG_DEFAULT == "fr_FR") +if (preg_match('/fr/i',$outputlangs->defaultlang)) { print '
'; print_titre($langs->trans("FrenchOptions")); diff --git a/htdocs/donations/card.php b/htdocs/donations/card.php index 79b97c2fde3..0d1cea0d4f1 100644 --- a/htdocs/donations/card.php +++ b/htdocs/donations/card.php @@ -25,9 +25,9 @@ * \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 '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/donations/core/modules/dons/modules_don.php'; +require_once DOL_DOCUMENT_ROOT.'/donations/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.'/donations/class/don.class.php'; diff --git a/htdocs/donations/core/modules/dons/html_cerfafr.modules.php b/htdocs/donations/core/modules/dons/html_cerfafr.modules.php index 0efaf8c4524..4f4c4b7be1a 100644 --- a/htdocs/donations/core/modules/dons/html_cerfafr.modules.php +++ b/htdocs/donations/core/modules/dons/html_cerfafr.modules.php @@ -20,11 +20,11 @@ */ /** - * \file htdocs/core/modules/dons/html_cerfafr.modules.php + * \file htdocs/donations/core/modules/dons/html_cerfafr.modules.php * \ingroup don * \brief Form of donation */ -require_once DOL_DOCUMENT_ROOT.'/core/modules/dons/modules_don.php'; +require_once DOL_DOCUMENT_ROOT.'/donations/core/modules/dons/modules_don.php'; require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; @@ -132,7 +132,7 @@ class html_cerfafr extends ModeleDon else $paymentmode = ''; // Define contents - $donmodel=DOL_DOCUMENT_ROOT ."/core/modules/dons/html_cerfafr.html"; + $donmodel=DOL_DOCUMENT_ROOT ."/donations/core/modules/dons/html_cerfafr.html"; $form = implode('', file($donmodel)); $form = str_replace('__REF__',$don->id,$form); $form = str_replace('__DATE__',dol_print_date($don->date,'day',false,$outputlangs),$form); diff --git a/htdocs/donations/core/modules/dons/modules_don.php b/htdocs/donations/core/modules/dons/modules_don.php index 69db5bec011..f3a38bbfc0b 100644 --- a/htdocs/donations/core/modules/dons/modules_don.php +++ b/htdocs/donations/core/modules/dons/modules_don.php @@ -20,8 +20,8 @@ */ /** - * \file htdocs/core/modules/dons/modules_don.php - * \ingroup don + * \file htdocs/donations/core/modules/dons/modules_don.php + * \ingroup donations * \brief File of class to manage donation document generation */ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; @@ -201,7 +201,7 @@ function don_create($db, $id, $message, $modele, $outputlangs, $hidedetails=0, $ $file = $prefix."_".preg_replace('/^html_/','',$modele).".modules.php"; // On verifie l'emplacement du modele - $file=dol_buildpath($reldir."core/modules/dons/".$file,0); + $file=dol_buildpath($reldir."donations/core/modules/dons/".$file,0); if (file_exists($file)) { $filefound=1; diff --git a/htdocs/donations/core/modules/modDon.class.php b/htdocs/donations/core/modules/modDon.class.php index bf5db49ec82..d602d867e1c 100644 --- a/htdocs/donations/core/modules/modDon.class.php +++ b/htdocs/donations/core/modules/modDon.class.php @@ -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 + * \file htdocs/donations/core/modules/modDon.class.php + * \ingroup donations * \brief Description and activation file for module Donation */ diff --git a/htdocs/donations/document.php b/htdocs/donations/document.php index 16729a9bd81..19088425c8b 100644 --- a/htdocs/donations/document.php +++ b/htdocs/donations/document.php @@ -21,11 +21,11 @@ * \brief Page of linked files into donations */ -require '../../main.inc.php'; +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/donations/core/lib/donation.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $langs->load("other"); diff --git a/htdocs/donations/index.php b/htdocs/donations/index.php index 9a4f13e7e4a..7ed677f6f58 100644 --- a/htdocs/donations/index.php +++ b/htdocs/donations/index.php @@ -23,7 +23,7 @@ * \brief Home page of donation module */ -require '../../main.inc.php'; +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php'; $langs->load("donations"); diff --git a/htdocs/donations/info.php b/htdocs/donations/info.php index 2121e379a65..b3c60cf004e 100644 --- a/htdocs/donations/info.php +++ b/htdocs/donations/info.php @@ -17,12 +17,12 @@ /** * \file htdocs/donations/info.php - * \ingroup Donation + * \ingroup donations * \brief Page to show a donation information */ -require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php'; +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/donations/core/lib/donation.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php'; diff --git a/htdocs/donations/list.php b/htdocs/donations/list.php index 5e0c1690413..4f49c28fb59 100644 --- a/htdocs/donations/list.php +++ b/htdocs/donations/list.php @@ -20,11 +20,11 @@ /** * \file htdocs/donations/list.php - * \ingroup don - * \brief Page de liste des dons + * \ingroup donations + * \brief List of donations */ -require '../../main.inc.php'; +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php'; if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; diff --git a/htdocs/donations/payment.php b/htdocs/donations/payment.php index 4df5b1c0e22..b86678dcd39 100644 --- a/htdocs/donations/payment.php +++ b/htdocs/donations/payment.php @@ -17,11 +17,11 @@ /** * \file htdocs/donations/payment.php - * \ingroup Donation + * \ingroup donations * \brief Page to add payment of a donation */ -require '../../main.inc.php'; +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/donations/class/paymentdonation.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; diff --git a/htdocs/donations/stats.php b/htdocs/donations/stats.php index 7552c29ebc0..2dacd9e093f 100644 --- a/htdocs/donations/stats.php +++ b/htdocs/donations/stats.php @@ -22,7 +22,7 @@ * \brief Page des statistiques de dons */ -require '../../main.inc.php'; +require '../main.inc.php'; $langs->load("donations"); diff --git a/htdocs/langs/en_US/donations.lang b/htdocs/langs/en_US/donations.lang index 77d91ad801d..13634f98380 100644 --- a/htdocs/langs/en_US/donations.lang +++ b/htdocs/langs/en_US/donations.lang @@ -21,6 +21,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 From 15e50ed24f474e019a1eec8c7284d84ff393d677 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sat, 21 Mar 2015 06:21:34 +0100 Subject: [PATCH 10/27] Update works --- htdocs/core/menus/init_menu_auguria.sql | 2 +- htdocs/core/menus/standard/eldy.lib.php | 2 +- .../admin/{dons.php => donation.php} | 6 +- .../donations/admin/donation_extrafields.php | 114 ++++++++++++++ htdocs/donations/card.php | 26 +++- .../donations/class/donationstats.class.php | 141 ++++++++++++++++++ htdocs/donations/core/lib/donation.lib.php | 34 +++++ .../donations/core/modules/modDon.class.php | 2 +- htdocs/donations/list.php | 4 +- htdocs/donations/stats.php | 84 ----------- .../install/mysql/migration/3.7.0-3.8.0.sql | 10 ++ .../mysql/tables/llx_don_extrafields.key.sql | 20 +++ .../mysql/tables/llx_don_extrafields.sql | 26 ++++ 13 files changed, 377 insertions(+), 94 deletions(-) rename htdocs/donations/admin/{dons.php => donation.php} (98%) create mode 100644 htdocs/donations/admin/donation_extrafields.php create mode 100644 htdocs/donations/class/donationstats.class.php delete mode 100644 htdocs/donations/stats.php create mode 100644 htdocs/install/mysql/tables/llx_don_extrafields.key.sql create mode 100644 htdocs/install/mysql/tables/llx_don_extrafields.sql diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index ca31e816086..b407c4fcdb4 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -175,7 +175,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->don->enabled', __HANDLER__, 'left', 2000__+MAX_llx_menu__, 'accountancy', 'donations', 6__+MAX_llx_menu__, '/donations/index.php?leftmenu=donations&mainmenu=accountancy', 'Donations', 0, 'donations', '$user->rights->don->lire', '', 2, 4, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->don->enabled && $leftmenu=="donations"', __HANDLER__, 'left', 2001__+MAX_llx_menu__, 'accountancy', '', 2000__+MAX_llx_menu__, '/donations/card.php?leftmenu=donations&mainmenu=accountancy&action=create', 'NewDonation', 1, 'donations', '$user->rights->don->creer', '', 2, 0, __ENTITY__); insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->don->enabled && $leftmenu=="donations"', __HANDLER__, 'left', 2002__+MAX_llx_menu__, 'accountancy', '', 2000__+MAX_llx_menu__, '/donations/list.php?leftmenu=donations&mainmenu=accountancy', 'List', 1, 'donations', '$user->rights->don->lire', '', 2, 1, __ENTITY__); ---insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->don->enabled && $leftmenu=="donations"', __HANDLER__, 'left', 2003__+MAX_llx_menu__, 'accountancy', '', 2000__+MAX_llx_menu__, '/donations/stats.php?leftmenu=donations&mainmenu=accountancy', 'Statistics', 1, 'donations', '$user->rights->don->lire', '', 2, 2, __ENTITY__); +insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->don->enabled && $leftmenu=="donations"', __HANDLER__, 'left', 2003__+MAX_llx_menu__, 'accountancy', '', 2000__+MAX_llx_menu__, '/donations/stats/index.php?leftmenu=donations&mainmenu=accountancy', 'Statistics', 1, 'donations', '$user->rights->don->lire', '', 2, 2, __ENTITY__); -- Special expenses 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__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index ca6bde79080..ed8eb59841f 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -791,7 +791,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $newmenu->add("/donations/index.php?leftmenu=donations&mainmenu=accountancy",$langs->trans("Donations"), 0, $user->rights->don->lire, '', $mainmenu, 'donations'); if (empty($leftmenu) || $leftmenu=="donations") $newmenu->add("/donations/card.php?action=create",$langs->trans("NewDonation"), 1, $user->rights->don->creer); if (empty($leftmenu) || $leftmenu=="donations") $newmenu->add("/donations/list.php",$langs->trans("List"), 1, $user->rights->don->lire); - //if ($leftmenu=="donations") $newmenu->add("/donations/stats.php",$langs->trans("Statistics"), 1, $user->rights->don->lire); + if ($leftmenu=="donations") $newmenu->add("/donations/stats/index.php",$langs->trans("Statistics"), 1, $user->rights->don->lire); } // Taxes and social contributions diff --git a/htdocs/donations/admin/dons.php b/htdocs/donations/admin/donation.php similarity index 98% rename from htdocs/donations/admin/dons.php rename to htdocs/donations/admin/donation.php index daf7b2f0e6d..ba0a72843fc 100644 --- a/htdocs/donations/admin/dons.php +++ b/htdocs/donations/admin/donation.php @@ -25,6 +25,7 @@ */ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/donations/core/lib/donation.lib.php'; require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -178,10 +179,13 @@ $dir = DOL_DOCUMENT_ROOT.'/donations/core/modules/dons/'; $form=new Form($db); llxHeader('',$langs->trans("DonationsSetup"),'DonConfiguration'); - $linkback=''.$langs->trans("BackToModuleList").''; print_fiche_titre($langs->trans("DonationsSetup"),$linkback,'setup'); +$head = donation_admin_prepare_head(); + +dol_fiche_head($head, 'general', $langs->trans("Donations"), 0, 'donation'); + /* * Params */ diff --git a/htdocs/donations/admin/donation_extrafields.php b/htdocs/donations/admin/donation_extrafields.php new file mode 100644 index 00000000000..3caa65bce98 --- /dev/null +++ b/htdocs/donations/admin/donation_extrafields.php @@ -0,0 +1,114 @@ + + * + * 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 . + */ + +/** + * \file htdocs/donations/admin/donation_extrafields.php + * \ingroup donations + * \brief Page to setup extra fields of donations + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/donations/core/lib/donation.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; + +$langs->load("companies"); +$langs->load("admin"); +$langs->load('donations'); + +$extrafields = new ExtraFields($db); +$form = new Form($db); + +// List of supported format +$tmptype2label=ExtraFields::$type2label; +$type2label=array(''); +foreach ($tmptype2label as $key => $val) $type2label[$key]=$langs->trans($val); + +$action=GETPOST('action', 'alpha'); +$attrname=GETPOST('attrname', 'alpha'); +$elementtype='don'; //Must be the $table_element of the class that manage extrafield + +if (!$user->admin) accessforbidden(); + + +/* + * Actions + */ + +require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; + + + +/* + * View + */ + +$textobject=$langs->transnoentitiesnoconv("Donations"); + +llxHeader('',$langs->trans("DonationsSetup")); + +$linkback=''.$langs->trans("BackToModuleList").''; +print_fiche_titre($langs->trans("DonationsSetup"),$linkback,'setup'); + + +$head = donation_admin_prepare_head(); + +dol_fiche_head($head, 'attributes', $langs->trans("Donations"), 0, 'donation'); + +require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; + +dol_fiche_end(); + + +// Buttons +if ($action != 'create' && $action != 'edit') +{ + print '
'; + print ''; + print "
"; +} + + +/* ************************************************************************** */ +/* */ +/* Create optional field */ +/* */ +/* ************************************************************************** */ + +if ($action == 'create') +{ + print "
"; + 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 "
"; + print_titre($langs->trans("FieldEdition", $attrname)); + + require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_edit.tpl.php'; +} + +llxFooter(); + +$db->close(); diff --git a/htdocs/donations/card.php b/htdocs/donations/card.php index 0d1cea0d4f1..d5aeaedb56d 100644 --- a/htdocs/donations/card.php +++ b/htdocs/donations/card.php @@ -32,6 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/donations/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'; @@ -48,6 +49,11 @@ $cancel=GETPOST('cancel'); $amount=GETPOST('amount'); $object = new Don($db); +$extrafields = new ExtraFields($db); + +// fetch optionals attributes and labels +$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); + $donation_date=dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); // Security check @@ -103,6 +109,10 @@ if ($action == 'update') $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) { @@ -151,7 +161,11 @@ if ($action == 'add') $object->note_private= GETPOST("note_private"); $object->note_public = GETPOST("note_public"); $object->public = GETPOST("public"); - $object->fk_project = GETPOST("projectid"); + $object->fk_project = GETPOST("fk_project"); + + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost($extralabels,$object); + if ($ret < 0) $error++; if ($object->create($user) > 0) { @@ -341,9 +355,13 @@ if ($action == 'create') } // Other attributes - $parameters=array('colspan' => ' colspan="1"'); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - + $parameters=array(); + $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 "
'.$langs->trans("Parameter").''.$langs->trans("Parameters").' 
\n"; print '
   
'; print "\n"; diff --git a/htdocs/donations/class/donationstats.class.php b/htdocs/donations/class/donationstats.class.php new file mode 100644 index 00000000000..74fd4d3d6f1 --- /dev/null +++ b/htdocs/donations/class/donationstats.class.php @@ -0,0 +1,141 @@ + + * Copyright (c) 2005-2013 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2011 Juanjo Menent + * + * 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 . + */ + +/** + * \file htdocs/donations/class/donationstats.class.php + * \ingroup donations + * \brief File of class to manage donations statistics + */ + +include_once DOL_DOCUMENT_ROOT . '/core/class/stats.class.php'; +include_once DOL_DOCUMENT_ROOT . '/donations/class/don.class.php'; +include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; + + +/** + * Class to manage donations statistics + */ +class DonationStats extends Stats +{ + public $table_element; + + var $socid; + var $userid; + + var $from; + var $field; + var $where; + + + /** + * Constructor + * + * @param DoliDB $db Database handler + * @param int $socid Id third party for filter + * @param string $mode Option (not used) + * @param int $userid Id user for filter (creation user) + */ + function __construct($db, $socid, $mode, $userid=0) + { + global $user, $conf; + + $this->db = $db; + + $this->socid = ($socid > 0 ? $socid : 0); + $this->userid = $userid; + $this->cachefilesuffix = $mode; + + $object=new Don($this->db); + $this->from = MAIN_DB_PREFIX.$object->table_element." as c"; + //$this->from.= ", ".MAIN_DB_PREFIX."societe as s"; + //$this->field='weight'; // Warning, unit of weight is NOT USED AND MUST BE + $this->where.= " c.fk_statut > 0"; // Not draft and not cancelled + + //$this->where.= " AND c.fk_soc = s.rowid AND c.entity = ".$conf->entity; + $this->where.= " AND c.entity = ".$conf->entity; + if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; + if ($this->socid) + { + $this->where.=" AND c.fk_soc = ".$this->socid; + } + if ($this->userid > 0) $this->where.=' AND c.fk_user_author = '.$this->userid; + } + + /** + * Return shipment number by month for a year + * + * @param int $year Year to scan + * @return array Array with number by month + */ + function getNbByMonth($year) + { + global $user; + + $sql = "SELECT date_format(c.date_valid,'%m') as dm, COUNT(*) as nb"; + $sql.= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql.= " AND ".$this->where; + $sql.= " GROUP BY dm"; + $sql.= $this->db->order('dm','DESC'); + + $res=$this->_getNbByMonth($year, $sql); + return $res; + } + + /** + * Return shipments number per year + * + * @return array Array with number by year + * + */ + function getNbByYear() + { + global $user; + + $sql = "SELECT date_format(c.date_valid,'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.")"; + $sql.= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE ".$this->where; + $sql.= " GROUP BY dm"; + $sql.= $this->db->order('dm','DESC'); + + return $this->_getNbByYear($sql); + } + + /** + * Return nb, total and average + * + * @return array Array of values + */ + function getAllByYear() + { + global $user; + + $sql = "SELECT date_format(c.date_valid,'%Y') as year, COUNT(*) as nb, SUM(c.".$this->field.") as total, AVG(".$this->field.") as avg"; + $sql.= " FROM ".$this->from; + if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + $sql.= " WHERE ".$this->where; + $sql.= " GROUP BY year"; + $sql.= $this->db->order('year','DESC'); + + return $this->_getAllByYear($sql); + } +} \ No newline at end of file diff --git a/htdocs/donations/core/lib/donation.lib.php b/htdocs/donations/core/lib/donation.lib.php index c274811bca1..93cbe889e4d 100644 --- a/htdocs/donations/core/lib/donation.lib.php +++ b/htdocs/donations/core/lib/donation.lib.php @@ -21,6 +21,40 @@ * \brief Library of donation functions */ +/** + * Prepare array with list of admin tabs + * + * @param Donation $object Donation + * @return array Array of tabs to show + */ +function donation_admin_prepare_head() +{ + global $langs, $conf; + + $h = 0; + $head = array (); + + $head[$h][0] = DOL_URL_ROOT . '/donations/admin/donation.php'; + $head[$h][1] = $langs->trans("Miscellaneous"); + $head[$h][2] = 'general'; + $h ++; + + // Show more tabs from modules + // Entries must be declared in modules descriptor with line + // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab + // $this->tabs = array('entity:-tabname); to remove a tab + complete_head_from_modules($conf, $langs, $object, $head, $h, 'donation_admin'); + + $head[$h][0] = DOL_URL_ROOT . '/donations/admin/donation_extrafields.php'; + $head[$h][1] = $langs->trans("ExtraFields"); + $head[$h][2] = 'attributes'; + $h++; + + complete_head_from_modules($conf, $langs, $object, $head, $h, 'donation_admin', 'remove'); + + return $head; +} + /** * Prepare array with list of tabs * diff --git a/htdocs/donations/core/modules/modDon.class.php b/htdocs/donations/core/modules/modDon.class.php index d602d867e1c..a4a825d8343 100644 --- a/htdocs/donations/core/modules/modDon.class.php +++ b/htdocs/donations/core/modules/modDon.class.php @@ -64,7 +64,7 @@ class modDon extends DolibarrModules $this->requiredby = array(); // Config pages - $this->config_page_url = array("dons.php@donations"); + $this->config_page_url = array("donation.php@donations"); // Constants $this->const = array (); diff --git a/htdocs/donations/list.php b/htdocs/donations/list.php index 4f49c28fb59..f277dc0b671 100644 --- a/htdocs/donations/list.php +++ b/htdocs/donations/list.php @@ -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); diff --git a/htdocs/donations/stats.php b/htdocs/donations/stats.php deleted file mode 100644 index 2dacd9e093f..00000000000 --- a/htdocs/donations/stats.php +++ /dev/null @@ -1,84 +0,0 @@ - - * Copyright (C) 2004-2009 Laurent Destailleur - * - * 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 . - */ - -/** - * \file htdocs/donations/stats.php - * \ingroup don - * \brief Page des statistiques de dons - */ - -require '../main.inc.php'; - -$langs->load("donations"); - -if (!$user->rights->don->lire) accessforbidden(); - - -/* - * View - */ - -llxHeader('',$langs->trans("Donations"),'EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones'); - - -print_fiche_titre($langs->trans("Statistics")); - - -$sql = "SELECT d.amount"; -$sql .= " FROM ".MAIN_DB_PREFIX."don as d LEFT JOIN ".MAIN_DB_PREFIX."projet as p"; -$sql .= " ON p.rowid = d.fk_don_projet"; - -$result = $db->query($sql); -if ($result) -{ - $num = $db->num_rows($result); - - $var=true; - $i=0; - $total=0; - while ($i < $num) - { - $objp = $db->fetch_object($result); - $total += $objp->amount; - $i++; - } - - print ''; - - print ''; - - $var=!$var; - print ""; - print ''; - $var=!$var; - print "".''; - $var=!$var; - print "".''; - print ""; - - print "
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("DonationsNumber").''.$num.'
'.$langs->trans("AmountTotal").''.price($total).'
'.$langs->trans("Average").''.price($total / ($num?$num:1)).'
"; -} -else -{ - dol_print_error($db); -} - - -llxFooter(); - -$db->close(); diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index caf7a474543..c1b999fa052 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -380,6 +380,16 @@ ALTER TABLE llx_don CHANGE COLUMN fk_paiement fk_payment integer; ALTER TABLE llx_don ADD COLUMN paid smallint default 0 NOT NULL after fk_payment; ALTER TABLE llx_don 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, diff --git a/htdocs/install/mysql/tables/llx_don_extrafields.key.sql b/htdocs/install/mysql/tables/llx_don_extrafields.key.sql new file mode 100644 index 00000000000..592df29f8f9 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_don_extrafields.key.sql @@ -0,0 +1,20 @@ +-- =================================================================== +-- Copyright (C) 2015 Alexandre Spangaro +-- +-- 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 . +-- +-- =================================================================== + + +ALTER TABLE llx_don_extrafields ADD INDEX idx_don_extrafields (fk_object); diff --git a/htdocs/install/mysql/tables/llx_don_extrafields.sql b/htdocs/install/mysql/tables/llx_don_extrafields.sql new file mode 100644 index 00000000000..b81f31f0c65 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_don_extrafields.sql @@ -0,0 +1,26 @@ +-- ======================================================================== +-- Copyright (C) 2015 Alexandre Spangaro +-- +-- 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 . +-- +-- ======================================================================== + +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; + From 4e6c40c78113993c1a4e37842d70531cf1205bba Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sat, 21 Mar 2015 07:12:32 +0100 Subject: [PATCH 11/27] Update works --- htdocs/donations/card.php | 36 ++- htdocs/donations/class/don.class.php | 59 ++++- htdocs/donations/stats/index.php | 357 +++++++++++++++++++++++++++ 3 files changed, 442 insertions(+), 10 deletions(-) create mode 100644 htdocs/donations/stats/index.php diff --git a/htdocs/donations/card.php b/htdocs/donations/card.php index d5aeaedb56d..300e18f1ad0 100644 --- a/htdocs/donations/card.php +++ b/htdocs/donations/card.php @@ -376,7 +376,14 @@ if ($action == 'create') if (! empty($id) && $action == 'edit') { - $object->fetch($id); + $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'); @@ -454,9 +461,13 @@ if (! empty($id) && $action == 'edit') } // Other attributes - $parameters=array('colspan' => ' colspan="1"'); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - + $parameters=array(); + $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 "\n"; print '
   
'; @@ -476,6 +487,13 @@ if (! empty($id) && $action == 'edit') 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'); @@ -587,8 +605,6 @@ if (! empty($id) && $action != 'edit') print ''.$langs->trans("Zip").' / '.$langs->trans("Town").''; print $object->zip.($object->zip && $object->town?' / ':'').$object->town.''; - - // Country print ''.$langs->trans('Country').''; if (! empty($object->country_code)) @@ -623,8 +639,12 @@ if (! empty($id) && $action != 'edit') } // Other attributes - $parameters=array('colspan' => ' colspan="1"'); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + $parameters=array(); + $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 "\n"; print "\n"; diff --git a/htdocs/donations/class/don.class.php b/htdocs/donations/class/don.class.php index 51c3958f2e6..478f4cce7c0 100644 --- a/htdocs/donations/class/don.class.php +++ b/htdocs/donations/class/don.class.php @@ -369,6 +369,24 @@ class Don extends CommonObject $result = $this->db->query($sql); if ($result) { + // Actions on extra fields (by external module) + $hookmanager->initHooks(array('dondao')); + $parameters=array('id'=>$this->id); + $action=''; + $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if (empty($reshook)) + { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + } + else if ($reshook < 0) $error++; + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."don"); // Call trigger @@ -429,7 +447,25 @@ class Don extends CommonObject $result = $this->db->query($sql); if ($result) { - // Call trigger + // Actions on extra fields (by external module) + $hookmanager->initHooks(array('dondao')); + $parameters=array('id'=>$this->id); + $action=''; + $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if (empty($reshook)) + { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + } + else if ($reshook < 0) $error++; + + // Call trigger $result=$this->call_trigger('DON_UPDATE',$user); if ($result < 0) { $error++; $this->db->rollback(); return -1; } // End call triggers @@ -463,6 +499,18 @@ class Don extends CommonObject { if ( $this->db->affected_rows($resql) ) { + // Removed extrafields + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->deleteExtraFields(); + if ($result < 0) + { + $error++; + $errorflag=-4; + dol_syslog(get_class($this)."::delete error ".$errorflag." ".$this->error, LOG_ERR); + } + } + // Call trigger $result=$this->call_trigger('DON_DELETE',$user); if ($result < 0) { $error++; $this->db->rollback(); return -1; } @@ -531,7 +579,7 @@ class Don extends CommonObject $this->country_id = $obj->country_id; $this->country_code = $obj->country_code; $this->country = $obj->country; - $this->country_olddata= $obj->country_olddata; + $this->country_olddata= $obj->country_olddata; // deprecated $this->email = $obj->email; $this->phone = $obj->phone; $this->phone_mobile = $obj->phone_mobile; @@ -545,6 +593,13 @@ class Don extends CommonObject $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; } diff --git a/htdocs/donations/stats/index.php b/htdocs/donations/stats/index.php new file mode 100644 index 00000000000..f6fc43ce90a --- /dev/null +++ b/htdocs/donations/stats/index.php @@ -0,0 +1,357 @@ + + * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * + * 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 . + */ + +/** + * \file htdocs/donations/stats/index.php + * \ingroup donations + * \brief Page with donations statistics + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php'; +require_once DOL_DOCUMENT_ROOT.'/donations/class/donationstats.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 . '/commande/stats/index.php?mode='.$mode; +$head[$h][1] = $langs->trans("ByMonthYear"); +$head[$h][2] = 'byyear'; +$h++; + +$type='shipment_stats'; + +complete_head_from_modules($conf,$langs,null,$head,$h,$type); + +dol_fiche_head($head,'byyear',$langs->trans("Statistics")); + + +print '
'; + + +//if (empty($socid)) +//{ + // Show filter box + print '
'; + print ''; + print ''; + print ''; + // Company + print ''; + // User + print ''; + // Year + print ''; + print ''; + print '
'.$langs->trans("Filter").'
'.$langs->trans("ThirdParty").''; + 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 '
'.$langs->trans("CreatedBy").''; + print $form->select_users($userid,'userid',1); + print '
'.$langs->trans("Year").''; + 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 '
'; + print '
'; + print '

'; +//} + +print ''; +print ''; +print ''; +print ''; +/*print ''; +print '';*/ +print ''; + +$oldyear=0; +foreach ($data as $val) +{ + $year = $val['year']; + while (! empty($year) && $oldyear > $year+1) + { // If we have empty year + $oldyear--; + print ''; + print ''; + + print ''; + /*print ''; + print '';*/ + print ''; + } + + print ''; + print ''; + print ''; + /*print ''; + print '';*/ + print ''; + $oldyear=$year; +} + +print '
'.$langs->trans("Year").''.$langs->trans("NbOfSendings").''.$langs->trans("AmountTotal").''.$langs->trans("AmountAverage").'
'.$oldyear.'000
'.$year.''.$val['nb'].''.price(price2num($val['total'],'MT'),1).''.price(price2num($val['avg'],'MT'),1).'
'; + + +print '
'; + + +// Show graphs +print '
'; +if ($mesg) { print $mesg; } +else { + print $px1->show(); + print "
\n"; + /*print $px2->show(); + print "
\n"; + print $px3->show();*/ +} +print '
'; + + +print '
'; +print '
'; + +dol_fiche_end(); + + + +// TODO USe code similar to commande/stats/index.php instead of this one. +/* +print ''; +print ''; +print ''; + +$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 ""; + print ''; + $i++; + } +} +$db->free($resql); + +print '
'.$langs->trans("Year").''.$langs->trans("NbOfSendings").'
'.$year.''.$nbproduct.'
'; +*/ + +print '
'; +print ''.$langs->trans("StatsOnShipmentsOnlyValidated").''; + +llxFooter(); + +$db->close(); From b4b3c45dbcb976816348d674f768a03637722bf0 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sat, 21 Mar 2015 18:00:16 +0100 Subject: [PATCH 12/27] Update works --- htdocs/compta/bank/account.php | 19 +- htdocs/donations/card.php | 22 +- htdocs/donations/class/don.class.php | 3 +- .../donations/class/paymentdonation.class.php | 20 +- htdocs/donations/payment/card.php | 312 ++++++++++++++++++ htdocs/donations/payment/index.html | 0 htdocs/donations/{ => payment}/payment.php | 2 +- 7 files changed, 353 insertions(+), 25 deletions(-) create mode 100644 htdocs/donations/payment/card.php create mode 100644 htdocs/donations/payment/index.html rename htdocs/donations/{ => payment}/payment.php (99%) diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php index 024e21510e1..080fd46495c 100644 --- a/htdocs/compta/bank/account.php +++ b/htdocs/compta/bank/account.php @@ -6,7 +6,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010-2011 Juanjo Menent * Copyright (C) 2012-2014 Marcos García - * Copyright (C) 2011-2014 Alexandre Spangaro + * Copyright (C) 2011-2015 Alexandre Spangaro * * 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.'/donations/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; @@ -153,6 +154,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); @@ -705,6 +707,21 @@ if ($id > 0 || ! empty($ref)) $chargestatic->ref=$chargestatic->lib; print $chargestatic->getNomUrl(1,16); } + else if ($links[$key]['type']=='donation') + { + $donstatic->id=$links[$key]['url_id']; + if (preg_match('/^\((.*)\)$/i',$links[$key]['label'],$reg)) + { + if ($reg[1]=='donation') $reg[1]='Donation'; + $donstatic->lib=$langs->trans($reg[1]); + } + else + { + $donstatic->lib=$links[$key]['label']; + } + $donstatic->ref=$donstatic->lib; + print $donstatic->getNomUrl(1,16); + } else if ($links[$key]['type']=='member') { $memberstatic->id=$links[$key]['url_id']; diff --git a/htdocs/donations/card.php b/htdocs/donations/card.php index 300e18f1ad0..a8424da558e 100644 --- a/htdocs/donations/card.php +++ b/htdocs/donations/card.php @@ -526,10 +526,10 @@ if (! empty($id) && $action != 'edit') print yn($object->public); print ''; - print "".''.$langs->trans("Company").''.$object->societe.''; - print "".''.$langs->trans("Lastname").''.$object->lastname.''; - print "".''.$langs->trans("Firstname").''.$object->firstname.''; - print "".''.$langs->trans("Address").''.dol_nl2br($object->address).''; + print ''.$langs->trans("Company").''.$object->societe.''; + print ''.$langs->trans("Lastname").''.$object->lastname.''; + print ''.$langs->trans("Firstname").''.$object->firstname.''; + print ''.$langs->trans("Address").''.dol_nl2br($object->address).''; $rowspan=6; if (! empty($conf->projet->enabled)) $rowspan++; @@ -543,7 +543,7 @@ if (! empty($id) && $action != 'edit') $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 = '".$rowid."'"; + $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"; @@ -570,25 +570,25 @@ if (! empty($id) && $action != 'edit') $objp = $db->fetch_object($resql); $var=!$var; print ""; - print ''.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.''; + print ''.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.''; print ''.dol_print_date($db->jdate($objp->dp),'day')."\n"; $labeltype=$langs->trans("PaymentType".$object->type_code)!=("PaymentType".$object->type_code)?$langs->trans("PaymentType".$object->type_code):$object->paiement_type; print "".$labeltype.' '.$object->num_paiement."\n"; - print ''.price($object->amount)." ".$langs->trans("Currency".$conf->currency)."\n"; + print ''.price($objp->amount)." ".$langs->trans("Currency".$conf->currency)."\n"; print ""; - $totalpaid += $object->amount; + $totalpaid += $objp->amount; $i++; } if ($object->paid == 0) { - print "".$langs->trans("AlreadyPaid")." :".price($totalpaye)." ".$langs->trans("Currency".$conf->currency)."\n"; + print "".$langs->trans("AlreadyPaid")." :".price($totalpaid)." ".$langs->trans("Currency".$conf->currency)."\n"; print "".$langs->trans("AmountExpected")." :".price($object->amount)." ".$langs->trans("Currency".$conf->currency)."\n"; $remaintopay = $object->amount - $totalpaid; print "".$langs->trans("RemainderToPay")." :"; - print "".price($resteapayer)." ".$langs->trans("Currency".$conf->currency)."\n"; + print "".price($remaintopay)." ".$langs->trans("Currency".$conf->currency)."\n"; } print ""; $db->free($resql); @@ -679,7 +679,7 @@ if (! empty($id) && $action != 'edit') } else { - print ''; + print ''; } } diff --git a/htdocs/donations/class/don.class.php b/htdocs/donations/class/don.class.php index 478f4cce7c0..e02ecefccbc 100644 --- a/htdocs/donations/class/don.class.php +++ b/htdocs/donations/class/don.class.php @@ -370,7 +370,7 @@ class Don extends CommonObject if ($result) { // Actions on extra fields (by external module) - $hookmanager->initHooks(array('dondao')); + /*$hookmanager->initHooks(array('dondao')); $parameters=array('id'=>$this->id); $action=''; $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks @@ -386,6 +386,7 @@ class Don extends CommonObject } } else if ($reshook < 0) $error++; + */ $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."don"); diff --git a/htdocs/donations/class/paymentdonation.class.php b/htdocs/donations/class/paymentdonation.class.php index 72d1709b252..9125ea68d57 100644 --- a/htdocs/donations/class/paymentdonation.class.php +++ b/htdocs/donations/class/paymentdonation.class.php @@ -317,7 +317,7 @@ class PaymentDonation extends CommonObject if (! $error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."bank_url"; - $sql.= " WHERE type='payment_sc' AND url_id=".$this->id; + $sql.= " WHERE type='payment_donation' AND url_id=".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); $resql = $this->db->query($sql); @@ -382,7 +382,7 @@ class PaymentDonation extends CommonObject $error=0; - $object=new PaymentSocialContribution($this->db); + $object=new PaymentDonation($this->db); $object->context['createfromclone'] = 'createfromclone'; @@ -461,7 +461,7 @@ class PaymentDonation extends CommonObject * 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_sc' + * @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 @@ -482,7 +482,7 @@ class PaymentDonation extends CommonObject $acc->fetch($accountid); $total=$this->total; - if ($mode == 'payment_sc') $total=-$total; + if ($mode == 'payment_donation') $total=-$total; // Insert payment into llx_bank $bank_line_id = $acc->addline( @@ -508,9 +508,9 @@ class PaymentDonation extends CommonObject dol_print_error($this->db); } - // Add link 'payment', 'payment_supplier', 'payment_sc' in bank_url between payment and bank transaction + // Add link 'payment', 'payment_supplier', 'payment_donation' in bank_url between payment and bank transaction $url=''; - if ($mode == 'payment_donation') $url=DOL_URL_ROOT.'/donations/card.php?rowid='; + if ($mode == 'payment_donation') $url=DOL_URL_ROOT.'/donations/payment/card.php?rowid='; if ($url) { $result=$acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode); @@ -529,7 +529,7 @@ class PaymentDonation extends CommonObject { $don = new Don($this->db); $don->fetch($key); - $result=$acc->add_url_line($bank_line_id, $don->rowid, DOL_URL_ROOT.'/compta/card.php?rowid=', $don->type_libelle.(($don->lib && $don->lib!=$don->type_libelle)?' ('.$don->lib.')':''),'sc'); + $result=$acc->add_url_line($bank_line_id, $don->rowid, DOL_URL_ROOT.'/donations/card.php?rowid=', $don->type_libelle.(($don->lib && $don->lib!=$don->type_libelle)?' ('.$don->lib.')':''),'donation'); if ($result <= 0) dol_print_error($this->db); } } @@ -593,7 +593,7 @@ class PaymentDonation extends CommonObject if (!empty($this->id)) { - $link = ''; + $link = ''; $linkend=''; if ($withpicto) $result.=($link.img_object($label, 'payment', 'class="classfortooltip"').$linkend.' '); @@ -603,6 +603,4 @@ class PaymentDonation extends CommonObject return $result; } -} - - +} \ No newline at end of file diff --git a/htdocs/donations/payment/card.php b/htdocs/donations/payment/card.php new file mode 100644 index 00000000000..3e4d03d15d2 --- /dev/null +++ b/htdocs/donations/payment/card.php @@ -0,0 +1,312 @@ + + * + * 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 . + */ + +/** + * \file htdocs/donations/payment/card.php + * \ingroup donations + * \brief Tab payment of a donation + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php'; +require_once DOL_DOCUMENT_ROOT.'/donations/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."/donations/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.'/donations/payment/card.php?id='.$_GET["id"]; +$head[$h][1] = $langs->trans("Card"); +$hselected = $h; +$h++; + +dol_fiche_head($head, $hselected, $langs->trans("PaymentDonation"), 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 ''; + +// Ref +print ''; +print ''; + +// Date +print ''; + +// Mode +print ''; + +// Number +print ''; + +// Amount +print ''; + +// Note +print ''; + +// Bank account +if (! empty($conf->banque->enabled)) +{ + if ($payment->bank_account) + { + $bankline=new AccountLine($db); + $bankline->fetch($payment->bank_line); + + print ''; + print ''; + print ''; + print ''; + } +} + +print '
'.$langs->trans('Ref').''; +print $form->showrefnav($payment,'id','',1,'rowid','id'); +print '
'.$langs->trans('Date').''.dol_print_date($payment->datep,'day').'
'.$langs->trans('Mode').''.$langs->trans("PaymentType".$payment->type_code).'
'.$langs->trans('Number').''.$payment->num_paiement.'
'.$langs->trans('Amount').''.price($payment->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'
'.$langs->trans('Note').''.nl2br($payment->note).'
'.$langs->trans('BankTransactionLine').''; + print $bankline->getNomUrl(1,0,'showall'); + print '
'; + + +/* + * List of donations payed + */ + +$disable_delete = 0; +$sql = 'SELECT d.rowid as did, d.libelle, d.paid, d.amount as d_amount, pd.amount, pd.libelle as d_type'; +$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 '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + if ($num > 0) + { + $var=True; + + while ($i < $num) + { + $objp = $db->fetch_object($resql); + + $var=!$var; + print ''; + // Ref + print '\n"; + // Type + print '\n"; + // Label + print ''; + // Expected to pay + print ''; + // Status + print ''; + // Amount payed + print ''; + print "\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 "
'.$langs->trans('Donation').''.$langs->trans('Type').''.$langs->trans('Label').''.$langs->trans('ExpectedToPay').''.$langs->trans('Status').''.$langs->trans('PayedByThisPayment').'
'; + $don->fetch($objp->did); + print $don->getNomUrl(1); + print "'; + print $don->type_libelle; + /*print $don->type;*/ + print "'.$objp->libelle.''.price($objp->d_amount).''.$don->getLibStatut(4,$objp->amount).''.price($objp->amount).'
\n"; + $db->free($resql); +} +else +{ + dol_print_error($db); +} + +print '
'; + + +/* + * Boutons Actions + */ +print '
'; + +/* +if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) +{ + if ($user->societe_id == 0 && $payment->statut == 0 && $_GET['action'] == '') + { + if ($user->rights->facture->paiement) + { + print ''.$langs->trans('Valid').''; + } + } +} +*/ + +if ($_GET['action'] == '') +{ + if ($user->rights->don->supprimer) + { + if (! $disable_delete) + { + print ''.$langs->trans('Delete').''; + } + else + { + print ''.$langs->trans('Delete').''; + } + } +} + +print '
'; + + + +llxFooter(); + +$db->close(); diff --git a/htdocs/donations/payment/index.html b/htdocs/donations/payment/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/donations/payment.php b/htdocs/donations/payment/payment.php similarity index 99% rename from htdocs/donations/payment.php rename to htdocs/donations/payment/payment.php index b86678dcd39..871bbaa1056 100644 --- a/htdocs/donations/payment.php +++ b/htdocs/donations/payment/payment.php @@ -21,7 +21,7 @@ * \brief Page to add payment of a donation */ -require '../main.inc.php'; +require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/donations/class/paymentdonation.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; From 9264482e25eb0bbfd323f14d1d2ffae8846ca6f6 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 22 Mar 2015 08:20:19 +0100 Subject: [PATCH 13/27] Update works --- htdocs/{donations => }/core/lib/donation.lib.php | 0 .../core/modules/dons/html_cerfafr.html | 0 .../core/modules/dons/html_cerfafr.modules.php | 2 +- htdocs/{donations => }/core/modules/dons/index.html | 0 .../{donations => }/core/modules/dons/modules_don.php | 4 ++-- htdocs/{donations => }/core/modules/modDon.class.php | 0 htdocs/donations/admin/donation.php | 5 +++-- htdocs/donations/card.php | 10 +++++----- htdocs/donations/document.php | 4 ++-- htdocs/donations/index.php | 6 +++--- htdocs/donations/info.php | 2 +- htdocs/donations/payment/card.php | 2 +- 12 files changed, 18 insertions(+), 17 deletions(-) rename htdocs/{donations => }/core/lib/donation.lib.php (100%) rename htdocs/{donations => }/core/modules/dons/html_cerfafr.html (100%) rename htdocs/{donations => }/core/modules/dons/html_cerfafr.modules.php (99%) rename htdocs/{donations => }/core/modules/dons/index.html (100%) rename htdocs/{donations => }/core/modules/dons/modules_don.php (97%) rename htdocs/{donations => }/core/modules/modDon.class.php (100%) diff --git a/htdocs/donations/core/lib/donation.lib.php b/htdocs/core/lib/donation.lib.php similarity index 100% rename from htdocs/donations/core/lib/donation.lib.php rename to htdocs/core/lib/donation.lib.php diff --git a/htdocs/donations/core/modules/dons/html_cerfafr.html b/htdocs/core/modules/dons/html_cerfafr.html similarity index 100% rename from htdocs/donations/core/modules/dons/html_cerfafr.html rename to htdocs/core/modules/dons/html_cerfafr.html diff --git a/htdocs/donations/core/modules/dons/html_cerfafr.modules.php b/htdocs/core/modules/dons/html_cerfafr.modules.php similarity index 99% rename from htdocs/donations/core/modules/dons/html_cerfafr.modules.php rename to htdocs/core/modules/dons/html_cerfafr.modules.php index 4f4c4b7be1a..69484033374 100644 --- a/htdocs/donations/core/modules/dons/html_cerfafr.modules.php +++ b/htdocs/core/modules/dons/html_cerfafr.modules.php @@ -24,7 +24,7 @@ * \ingroup don * \brief Form of donation */ -require_once DOL_DOCUMENT_ROOT.'/donations/core/modules/dons/modules_don.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/dons/modules_don.php'; require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; diff --git a/htdocs/donations/core/modules/dons/index.html b/htdocs/core/modules/dons/index.html similarity index 100% rename from htdocs/donations/core/modules/dons/index.html rename to htdocs/core/modules/dons/index.html diff --git a/htdocs/donations/core/modules/dons/modules_don.php b/htdocs/core/modules/dons/modules_don.php similarity index 97% rename from htdocs/donations/core/modules/dons/modules_don.php rename to htdocs/core/modules/dons/modules_don.php index f3a38bbfc0b..abb7dd105ae 100644 --- a/htdocs/donations/core/modules/dons/modules_don.php +++ b/htdocs/core/modules/dons/modules_don.php @@ -20,7 +20,7 @@ */ /** - * \file htdocs/donations/core/modules/dons/modules_don.php + * \file htdocs/core/modules/dons/modules_don.php * \ingroup donations * \brief File of class to manage donation document generation */ @@ -201,7 +201,7 @@ function don_create($db, $id, $message, $modele, $outputlangs, $hidedetails=0, $ $file = $prefix."_".preg_replace('/^html_/','',$modele).".modules.php"; // On verifie l'emplacement du modele - $file=dol_buildpath($reldir."donations/core/modules/dons/".$file,0); + $file=dol_buildpath($reldir."core/modules/dons/".$file,0); if (file_exists($file)) { $filefound=1; diff --git a/htdocs/donations/core/modules/modDon.class.php b/htdocs/core/modules/modDon.class.php similarity index 100% rename from htdocs/donations/core/modules/modDon.class.php rename to htdocs/core/modules/modDon.class.php diff --git a/htdocs/donations/admin/donation.php b/htdocs/donations/admin/donation.php index ba0a72843fc..6c363c4bdc1 100644 --- a/htdocs/donations/admin/donation.php +++ b/htdocs/donations/admin/donation.php @@ -25,7 +25,7 @@ */ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/donations/core/lib/donation.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php'; require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -54,7 +54,8 @@ if ($action == 'specimen') $don->initAsSpecimen(); // Search template files - $dir = DOL_DOCUMENT_ROOT . "/donations/core/modules/dons/"; + $dir = DOL_DOCUMENT_ROOT . "/core/modules/dons/"; + $dir = DOL_DOCUMENT_ROOT . "/core/modules/dons/"; $file = $modele.".modules.php"; if (file_exists($dir.$file)) { diff --git a/htdocs/donations/card.php b/htdocs/donations/card.php index a8424da558e..6c2bd28a2d0 100644 --- a/htdocs/donations/card.php +++ b/htdocs/donations/card.php @@ -20,14 +20,14 @@ */ /** - * \file htdocs/donations/card.php - * \ingroup don - * \brief Page of donation card + * \file htdocs/donations/card.php + * \ingroup donations + * \brief Page of donation card */ require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/donations/core/modules/dons/modules_don.php'; -require_once DOL_DOCUMENT_ROOT.'/donations/core/lib/donation.lib.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.'/donations/class/don.class.php'; diff --git a/htdocs/donations/document.php b/htdocs/donations/document.php index 19088425c8b..0cfb0447630 100644 --- a/htdocs/donations/document.php +++ b/htdocs/donations/document.php @@ -17,7 +17,7 @@ /** * \file htdocs/donations/document.php - * \ingroup Donation + * \ingroup donations * \brief Page of linked files into donations */ @@ -25,7 +25,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/donations/core/lib/donation.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $langs->load("other"); diff --git a/htdocs/donations/index.php b/htdocs/donations/index.php index 7ed677f6f58..ac64d6b2dde 100644 --- a/htdocs/donations/index.php +++ b/htdocs/donations/index.php @@ -18,9 +18,9 @@ */ /** - * \file htdocs/donations/index.php - * \ingroup don - * \brief Home page of donation module + * \file htdocs/donations/index.php + * \ingroup donations + * \brief Home page of donation module */ require '../main.inc.php'; diff --git a/htdocs/donations/info.php b/htdocs/donations/info.php index b3c60cf004e..a85b734fcf6 100644 --- a/htdocs/donations/info.php +++ b/htdocs/donations/info.php @@ -22,7 +22,7 @@ */ require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/donations/core/lib/donation.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php'; diff --git a/htdocs/donations/payment/card.php b/htdocs/donations/payment/card.php index 3e4d03d15d2..6b30fdcc89b 100644 --- a/htdocs/donations/payment/card.php +++ b/htdocs/donations/payment/card.php @@ -121,7 +121,7 @@ $form = new Form($db); $h=0; -$head[$h][0] = DOL_URL_ROOT.'/donations/payment/card.php?id='.$_GET["id"]; +$head[$h][0] = DOL_URL_ROOT.'/donations/payment/card.php?id='.$id; $head[$h][1] = $langs->trans("Card"); $hselected = $h; $h++; From dafc955848d95a6b74e7bea8182e2855002bfaf0 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 22 Mar 2015 08:25:45 +0100 Subject: [PATCH 14/27] Correct path --- htdocs/donations/admin/donation.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/donations/admin/donation.php b/htdocs/donations/admin/donation.php index 6c363c4bdc1..fa785763cc0 100644 --- a/htdocs/donations/admin/donation.php +++ b/htdocs/donations/admin/donation.php @@ -55,7 +55,6 @@ if ($action == 'specimen') // Search template files $dir = DOL_DOCUMENT_ROOT . "/core/modules/dons/"; - $dir = DOL_DOCUMENT_ROOT . "/core/modules/dons/"; $file = $modele.".modules.php"; if (file_exists($dir.$file)) { @@ -176,7 +175,7 @@ else if ($action == 'setart885') { * View */ -$dir = DOL_DOCUMENT_ROOT.'/donations/core/modules/dons/'; +$dir = "../../core/modules/dons/"; $form=new Form($db); llxHeader('',$langs->trans("DonationsSetup"),'DonConfiguration'); From feef043513d82f9df1c50c9e36983c37c7fb7249 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 22 Mar 2015 15:27:05 +0100 Subject: [PATCH 15/27] Correct --- htdocs/core/modules/dons/html_cerfafr.modules.php | 4 ++-- htdocs/core/modules/modDon.class.php | 2 +- htdocs/donations/admin/donation_extrafields.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/modules/dons/html_cerfafr.modules.php b/htdocs/core/modules/dons/html_cerfafr.modules.php index 69484033374..0efaf8c4524 100644 --- a/htdocs/core/modules/dons/html_cerfafr.modules.php +++ b/htdocs/core/modules/dons/html_cerfafr.modules.php @@ -20,7 +20,7 @@ */ /** - * \file htdocs/donations/core/modules/dons/html_cerfafr.modules.php + * \file htdocs/core/modules/dons/html_cerfafr.modules.php * \ingroup don * \brief Form of donation */ @@ -132,7 +132,7 @@ class html_cerfafr extends ModeleDon else $paymentmode = ''; // Define contents - $donmodel=DOL_DOCUMENT_ROOT ."/donations/core/modules/dons/html_cerfafr.html"; + $donmodel=DOL_DOCUMENT_ROOT ."/core/modules/dons/html_cerfafr.html"; $form = implode('', file($donmodel)); $form = str_replace('__REF__',$don->id,$form); $form = str_replace('__DATE__',dol_print_date($don->date,'day',false,$outputlangs),$form); diff --git a/htdocs/core/modules/modDon.class.php b/htdocs/core/modules/modDon.class.php index a4a825d8343..6d67b625f91 100644 --- a/htdocs/core/modules/modDon.class.php +++ b/htdocs/core/modules/modDon.class.php @@ -21,7 +21,7 @@ /** * \defgroup don Module donations * \brief Module to manage the follow-up of the donations - * \file htdocs/donations/core/modules/modDon.class.php + * \file htdocs/core/modules/modDon.class.php * \ingroup donations * \brief Description and activation file for module Donation */ diff --git a/htdocs/donations/admin/donation_extrafields.php b/htdocs/donations/admin/donation_extrafields.php index 3caa65bce98..f93b48bafca 100644 --- a/htdocs/donations/admin/donation_extrafields.php +++ b/htdocs/donations/admin/donation_extrafields.php @@ -22,7 +22,7 @@ */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/donations/core/lib/donation.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; $langs->load("companies"); From f6d8d2eb23de0d54bf9199a80aa68e45864a9a32 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Mon, 23 Mar 2015 06:56:12 +0100 Subject: [PATCH 16/27] Correct stats --- .../donations/class/donationstats.class.php | 24 +++++++------------ htdocs/donations/stats/index.php | 4 ++-- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/htdocs/donations/class/donationstats.class.php b/htdocs/donations/class/donationstats.class.php index 74fd4d3d6f1..b26617d651b 100644 --- a/htdocs/donations/class/donationstats.class.php +++ b/htdocs/donations/class/donationstats.class.php @@ -63,19 +63,14 @@ class DonationStats extends Stats $this->cachefilesuffix = $mode; $object=new Don($this->db); - $this->from = MAIN_DB_PREFIX.$object->table_element." as c"; + $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.= " c.fk_statut > 0"; // Not draft and not cancelled + $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 c.entity = ".$conf->entity; - if (!$user->rights->societe->client->voir && !$this->socid) $this->where .= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($this->socid) - { - $this->where.=" AND c.fk_soc = ".$this->socid; - } - if ($this->userid > 0) $this->where.=' AND c.fk_user_author = '.$this->userid; + $this->where.= " AND d.entity = ".$conf->entity; + if ($this->userid > 0) $this->where.=' WHERE c.fk_user_author = '.$this->userid; } /** @@ -88,10 +83,9 @@ class DonationStats extends Stats { global $user; - $sql = "SELECT date_format(c.date_valid,'%m') as dm, COUNT(*) as nb"; + $sql = "SELECT date_format(d.datedon,'%m') as dm, COUNT(*) as nb"; $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; - $sql.= " WHERE c.date_valid BETWEEN '".$this->db->idate(dol_get_first_day($year))."' AND '".$this->db->idate(dol_get_last_day($year))."'"; + $sql.= " 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'); @@ -110,9 +104,8 @@ class DonationStats extends Stats { global $user; - $sql = "SELECT date_format(c.date_valid,'%Y') as dm, COUNT(*) as nb, SUM(c.".$this->field.")"; + $sql = "SELECT date_format(d.datedon,'%Y') as dm, COUNT(*) as nb, SUM(d.".$this->field.")"; $sql.= " FROM ".$this->from; - if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE ".$this->where; $sql.= " GROUP BY dm"; $sql.= $this->db->order('dm','DESC'); @@ -129,9 +122,8 @@ class DonationStats extends Stats { global $user; - $sql = "SELECT date_format(c.date_valid,'%Y') as year, COUNT(*) as nb, SUM(c.".$this->field.") as total, AVG(".$this->field.") as avg"; + $sql = "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; - if (!$user->rights->societe->client->voir && !$this->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE ".$this->where; $sql.= " GROUP BY year"; $sql.= $this->db->order('year','DESC'); diff --git a/htdocs/donations/stats/index.php b/htdocs/donations/stats/index.php index f6fc43ce90a..0a58751b8ed 100644 --- a/htdocs/donations/stats/index.php +++ b/htdocs/donations/stats/index.php @@ -213,12 +213,12 @@ if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear; $h=0; $head = array(); -$head[$h][0] = DOL_URL_ROOT . '/commande/stats/index.php?mode='.$mode; +$head[$h][0] = DOL_URL_ROOT . '/donations/stats/index.php?mode='.$mode; $head[$h][1] = $langs->trans("ByMonthYear"); $head[$h][2] = 'byyear'; $h++; -$type='shipment_stats'; +$type='donation_stats'; complete_head_from_modules($conf,$langs,null,$head,$h,$type); From f778f470492aa5ec84270c8e891b2dd5a9370cee Mon Sep 17 00:00:00 2001 From: aspangaro Date: Wed, 25 Mar 2015 21:46:08 +0100 Subject: [PATCH 17/27] Add dirs --- build/rpm/dolibarr_fedora.spec | 1 + build/rpm/dolibarr_generic.spec | 1 + build/rpm/dolibarr_mandriva.spec | 1 + build/rpm/dolibarr_opensuse.spec | 1 + 4 files changed, 4 insertions(+) diff --git a/build/rpm/dolibarr_fedora.spec b/build/rpm/dolibarr_fedora.spec index 1a6371b1bf8..463f3e94e86 100755 --- a/build/rpm/dolibarr_fedora.spec +++ b/build/rpm/dolibarr_fedora.spec @@ -172,6 +172,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/contrat %_datadir/dolibarr/htdocs/core %_datadir/dolibarr/htdocs/cron +%_datadir/dolibarr/htdocs/donations %_datadir/dolibarr/htdocs/ecm %_datadir/dolibarr/htdocs/expedition %_datadir/dolibarr/htdocs/expensereport diff --git a/build/rpm/dolibarr_generic.spec b/build/rpm/dolibarr_generic.spec index 59569c2c9fd..adc5abbfd58 100755 --- a/build/rpm/dolibarr_generic.spec +++ b/build/rpm/dolibarr_generic.spec @@ -252,6 +252,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/contrat %_datadir/dolibarr/htdocs/core %_datadir/dolibarr/htdocs/cron +%_datadir/dolibarr/htdocs/donations %_datadir/dolibarr/htdocs/ecm %_datadir/dolibarr/htdocs/expedition %_datadir/dolibarr/htdocs/expensereport diff --git a/build/rpm/dolibarr_mandriva.spec b/build/rpm/dolibarr_mandriva.spec index 0c7050ef049..ecc5fb76b0c 100755 --- a/build/rpm/dolibarr_mandriva.spec +++ b/build/rpm/dolibarr_mandriva.spec @@ -169,6 +169,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/contrat %_datadir/dolibarr/htdocs/core %_datadir/dolibarr/htdocs/cron +%_datadir/dolibarr/htdocs/donations %_datadir/dolibarr/htdocs/ecm %_datadir/dolibarr/htdocs/expedition %_datadir/dolibarr/htdocs/expensereport diff --git a/build/rpm/dolibarr_opensuse.spec b/build/rpm/dolibarr_opensuse.spec index 34833025e81..129f6dc8f0a 100755 --- a/build/rpm/dolibarr_opensuse.spec +++ b/build/rpm/dolibarr_opensuse.spec @@ -180,6 +180,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/contrat %_datadir/dolibarr/htdocs/core %_datadir/dolibarr/htdocs/cron +%_datadir/dolibarr/htdocs/donations %_datadir/dolibarr/htdocs/ecm %_datadir/dolibarr/htdocs/expedition %_datadir/dolibarr/htdocs/expensereport From 2b2b43afb6b670944cfa21fbc663957b814ea94a Mon Sep 17 00:00:00 2001 From: aspangaro Date: Wed, 25 Mar 2015 22:37:14 +0100 Subject: [PATCH 18/27] Dir "Don" --- build/rpm/dolibarr_fedora.spec | 2 +- build/rpm/dolibarr_generic.spec | 2 +- build/rpm/dolibarr_mandriva.spec | 2 +- build/rpm/dolibarr_opensuse.spec | 2 +- htdocs/compta/bank/account.php | 2 +- htdocs/compta/index.php | 4 +- htdocs/compta/resultat/clientfourn.php | 2 +- htdocs/core/lib/donation.lib.php | 10 +- htdocs/core/menus/init_menu_auguria.sql | 8 +- htdocs/core/menus/standard/eldy.lib.php | 8 +- .../modules/dons/html_cerfafr.modules.php | 2 +- htdocs/core/modules/dons/modules_don.php | 2 +- htdocs/{donations => don}/admin/donation.php | 4 +- .../admin/donation_extrafields.php | 2 +- htdocs/{donations => don/admin}/index.html | 0 htdocs/don/admin/index.php | 117 ++++++++++++++++++ htdocs/{donations => don}/card.php | 54 ++++---- htdocs/{donations => don}/class/don.class.php | 78 ++++++------ .../class/donationstats.class.php | 4 +- htdocs/don/class/index.html | 0 .../class/paymentdonation.class.php | 8 +- htdocs/{donations => don}/document.php | 6 +- htdocs/don/index.html | 0 htdocs/{donations => don}/index.php | 4 +- htdocs/{donations => don}/info.php | 4 +- htdocs/{donations => don}/list.php | 4 +- htdocs/{donations => don}/payment/card.php | 10 +- htdocs/don/payment/index.html | 0 htdocs/{donations => don}/payment/payment.php | 12 +- htdocs/{donations => don}/stats/index.php | 8 +- htdocs/install/filelist.xml | 2 +- htdocs/product/class/product.class.php | 2 +- 32 files changed, 239 insertions(+), 126 deletions(-) rename htdocs/{donations => don}/admin/donation.php (99%) rename htdocs/{donations => don}/admin/donation_extrafields.php (98%) rename htdocs/{donations => don/admin}/index.html (100%) create mode 100644 htdocs/don/admin/index.php rename htdocs/{donations => don}/card.php (93%) rename htdocs/{donations => don}/class/don.class.php (93%) rename htdocs/{donations => don}/class/donationstats.class.php (96%) create mode 100644 htdocs/don/class/index.html rename htdocs/{donations => don}/class/paymentdonation.class.php (97%) rename htdocs/{donations => don}/document.php (92%) create mode 100644 htdocs/don/index.html rename htdocs/{donations => don}/index.php (98%) rename htdocs/{donations => don}/info.php (93%) rename htdocs/{donations => don}/list.php (98%) rename htdocs/{donations => don}/payment/card.php (95%) create mode 100644 htdocs/don/payment/index.html rename htdocs/{donations => don}/payment/payment.php (95%) rename htdocs/{donations => don}/stats/index.php (97%) diff --git a/build/rpm/dolibarr_fedora.spec b/build/rpm/dolibarr_fedora.spec index 463f3e94e86..c34cd4e9d61 100755 --- a/build/rpm/dolibarr_fedora.spec +++ b/build/rpm/dolibarr_fedora.spec @@ -172,7 +172,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/contrat %_datadir/dolibarr/htdocs/core %_datadir/dolibarr/htdocs/cron -%_datadir/dolibarr/htdocs/donations +%_datadir/dolibarr/htdocs/don %_datadir/dolibarr/htdocs/ecm %_datadir/dolibarr/htdocs/expedition %_datadir/dolibarr/htdocs/expensereport diff --git a/build/rpm/dolibarr_generic.spec b/build/rpm/dolibarr_generic.spec index adc5abbfd58..c3c3b2a7939 100755 --- a/build/rpm/dolibarr_generic.spec +++ b/build/rpm/dolibarr_generic.spec @@ -252,7 +252,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/contrat %_datadir/dolibarr/htdocs/core %_datadir/dolibarr/htdocs/cron -%_datadir/dolibarr/htdocs/donations +%_datadir/dolibarr/htdocs/don %_datadir/dolibarr/htdocs/ecm %_datadir/dolibarr/htdocs/expedition %_datadir/dolibarr/htdocs/expensereport diff --git a/build/rpm/dolibarr_mandriva.spec b/build/rpm/dolibarr_mandriva.spec index ecc5fb76b0c..efe55e2aa7a 100755 --- a/build/rpm/dolibarr_mandriva.spec +++ b/build/rpm/dolibarr_mandriva.spec @@ -169,7 +169,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/contrat %_datadir/dolibarr/htdocs/core %_datadir/dolibarr/htdocs/cron -%_datadir/dolibarr/htdocs/donations +%_datadir/dolibarr/htdocs/don %_datadir/dolibarr/htdocs/ecm %_datadir/dolibarr/htdocs/expedition %_datadir/dolibarr/htdocs/expensereport diff --git a/build/rpm/dolibarr_opensuse.spec b/build/rpm/dolibarr_opensuse.spec index 129f6dc8f0a..6a86f9e3ffa 100755 --- a/build/rpm/dolibarr_opensuse.spec +++ b/build/rpm/dolibarr_opensuse.spec @@ -180,7 +180,7 @@ done >>%{name}.lang %_datadir/dolibarr/htdocs/contrat %_datadir/dolibarr/htdocs/core %_datadir/dolibarr/htdocs/cron -%_datadir/dolibarr/htdocs/donations +%_datadir/dolibarr/htdocs/don %_datadir/dolibarr/htdocs/ecm %_datadir/dolibarr/htdocs/expedition %_datadir/dolibarr/htdocs/expensereport diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php index a4bfe4c0c37..3213709a54e 100644 --- a/htdocs/compta/bank/account.php +++ b/htdocs/compta/bank/account.php @@ -37,7 +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.'/donations/class/don.class.php'; +require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/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'; diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 9af8296f84d..698676829d1 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -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 '
'; + print ''; print ''; print ''; print ''; @@ -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.'/donations/class/don.class.php'; + include_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; $langs->load("boxes"); $donationstatic=new Don($db); diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 4f1ff225417..a9e14030388 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -651,7 +651,7 @@ if ($conf->donation->enabled) $var = !$var; print ""; - print "\n"; + print "\n"; if ($modecompta == 'CREANCES-DETTES') print ''; print ''; diff --git a/htdocs/core/lib/donation.lib.php b/htdocs/core/lib/donation.lib.php index 93cbe889e4d..4155d5ce60e 100644 --- a/htdocs/core/lib/donation.lib.php +++ b/htdocs/core/lib/donation.lib.php @@ -34,7 +34,7 @@ function donation_admin_prepare_head() $h = 0; $head = array (); - $head[$h][0] = DOL_URL_ROOT . '/donations/admin/donation.php'; + $head[$h][0] = DOL_URL_ROOT . '/don/admin/donation.php'; $head[$h][1] = $langs->trans("Miscellaneous"); $head[$h][2] = 'general'; $h ++; @@ -45,7 +45,7 @@ function donation_admin_prepare_head() // $this->tabs = array('entity:-tabname); to remove a tab complete_head_from_modules($conf, $langs, $object, $head, $h, 'donation_admin'); - $head[$h][0] = DOL_URL_ROOT . '/donations/admin/donation_extrafields.php'; + $head[$h][0] = DOL_URL_ROOT . '/don/admin/donation_extrafields.php'; $head[$h][1] = $langs->trans("ExtraFields"); $head[$h][2] = 'attributes'; $h++; @@ -68,7 +68,7 @@ function donation_prepare_head($object) $h = 0; $head = array (); - $head[$h][0] = DOL_URL_ROOT . '/donations/card.php?id=' . $object->id; + $head[$h][0] = DOL_URL_ROOT . '/don/card.php?id=' . $object->id; $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'card'; $h ++; @@ -79,12 +79,12 @@ function donation_prepare_head($object) // $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 . '/donations/document.php?id='.$object->id; + $head[$h][0] = DOL_URL_ROOT . '/don/document.php?id='.$object->id; $head[$h][1] = $langs->trans("Documents"); $head[$h][2] = 'documents'; $h++; - $head[$h][0] = DOL_URL_ROOT . '/donations/info.php?id=' . $object->id; + $head[$h][0] = DOL_URL_ROOT . '/don/info.php?id=' . $object->id; $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; $h++; diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 00579ab5f6d..3eab01619f1 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -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__, '/donations/index.php?leftmenu=donations&mainmenu=accountancy', 'Donations', 0, 'donations', '$user->rights->don->lire', '', 2, 4, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->don->enabled && $leftmenu=="donations"', __HANDLER__, 'left', 2001__+MAX_llx_menu__, 'accountancy', '', 2000__+MAX_llx_menu__, '/donations/card.php?leftmenu=donations&mainmenu=accountancy&action=create', 'NewDonation', 1, 'donations', '$user->rights->don->creer', '', 2, 0, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->don->enabled && $leftmenu=="donations"', __HANDLER__, 'left', 2002__+MAX_llx_menu__, 'accountancy', '', 2000__+MAX_llx_menu__, '/donations/list.php?leftmenu=donations&mainmenu=accountancy', 'List', 1, 'donations', '$user->rights->don->lire', '', 2, 1, __ENTITY__); -insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->don->enabled && $leftmenu=="donations"', __HANDLER__, 'left', 2003__+MAX_llx_menu__, 'accountancy', '', 2000__+MAX_llx_menu__, '/donations/stats/index.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__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index b6122c095a2..1d35db720b7 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -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("/donations/index.php?leftmenu=donations&mainmenu=accountancy",$langs->trans("Donations"), 0, $user->rights->don->lire, '', $mainmenu, 'donations'); - if (empty($leftmenu) || $leftmenu=="donations") $newmenu->add("/donations/card.php?action=create",$langs->trans("NewDonation"), 1, $user->rights->don->creer); - if (empty($leftmenu) || $leftmenu=="donations") $newmenu->add("/donations/list.php",$langs->trans("List"), 1, $user->rights->don->lire); - if ($leftmenu=="donations") $newmenu->add("/donations/stats/index.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 diff --git a/htdocs/core/modules/dons/html_cerfafr.modules.php b/htdocs/core/modules/dons/html_cerfafr.modules.php index 0efaf8c4524..8730b1041de 100644 --- a/htdocs/core/modules/dons/html_cerfafr.modules.php +++ b/htdocs/core/modules/dons/html_cerfafr.modules.php @@ -25,7 +25,7 @@ * \brief Form of donation */ require_once DOL_DOCUMENT_ROOT.'/core/modules/dons/modules_don.php'; -require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php'; +require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; diff --git a/htdocs/core/modules/dons/modules_don.php b/htdocs/core/modules/dons/modules_don.php index abb7dd105ae..14045f20d11 100644 --- a/htdocs/core/modules/dons/modules_don.php +++ b/htdocs/core/modules/dons/modules_don.php @@ -25,7 +25,7 @@ * \brief File of class to manage donation document generation */ require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; -require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php'; +require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; diff --git a/htdocs/donations/admin/donation.php b/htdocs/don/admin/donation.php similarity index 99% rename from htdocs/donations/admin/donation.php rename to htdocs/don/admin/donation.php index fa785763cc0..41ea0a3d542 100644 --- a/htdocs/donations/admin/donation.php +++ b/htdocs/don/admin/donation.php @@ -19,14 +19,14 @@ */ /** - * \file htdocs/donations/admin/dons.php + * \file htdocs/don/admin/dons.php * \ingroup donations * \brief Page to setup the donation module */ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php'; +require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $langs->load("admin"); diff --git a/htdocs/donations/admin/donation_extrafields.php b/htdocs/don/admin/donation_extrafields.php similarity index 98% rename from htdocs/donations/admin/donation_extrafields.php rename to htdocs/don/admin/donation_extrafields.php index f93b48bafca..6c964b46321 100644 --- a/htdocs/donations/admin/donation_extrafields.php +++ b/htdocs/don/admin/donation_extrafields.php @@ -16,7 +16,7 @@ */ /** - * \file htdocs/donations/admin/donation_extrafields.php + * \file htdocs/don/admin/donation_extrafields.php * \ingroup donations * \brief Page to setup extra fields of donations */ diff --git a/htdocs/donations/index.html b/htdocs/don/admin/index.html similarity index 100% rename from htdocs/donations/index.html rename to htdocs/don/admin/index.html diff --git a/htdocs/don/admin/index.php b/htdocs/don/admin/index.php new file mode 100644 index 00000000000..78ff3b48f9a --- /dev/null +++ b/htdocs/don/admin/index.php @@ -0,0 +1,117 @@ + + * + * 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 . + * + */ + +/** + * \file htdocs/admin/index.php + * \ingroup Donations + * \brief Setup page to configure donations module + */ + +require '../main.inc.php'; + +// Class +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; + +$langs->load("admin"); +$langs->load("donations"); + +// Security check +if (!$user->admin) + accessforbidden(); + +$action = GETPOST('action', 'alpha'); + +// Other parameters DONATIONS_* +$list = array ( + 'DONATIONS_ACCOUNTING_ACCOUNT_PRODUCT' +); + +/* + * Actions + */ + +if ($action == 'update') +{ + $error = 0; + + foreach ($list as $constname) { + $constvalue = GETPOST($constname, 'alpha'); + + if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { + $error++; + } + } + + if (! $error) + { + setEventMessage($langs->trans("SetupSaved")); + } + else + { + setEventMessage($langs->trans("Error"),'errors'); + } +} + +/* + * View + */ + +llxHeader('',$langs->trans('DonationsSetup')); + +$form = new Form($db); + +$linkback=''.$langs->trans("BackToModuleList").''; +print_fiche_titre($langs->trans('DonationsSetup'),$linkback,'setup'); + +print ''; +print ''; +print ''; + +/* + * Params + */ +print '
'.$langs->trans("SearchADonation").'
 ".$langs->trans("Donation")." name."&search_name=".$obj->firstname." ".$obj->lastname."\">".$obj->name. " ".$obj->firstname." ".$obj->lastname."".$langs->trans("Donation")." name."&search_name=".$obj->firstname." ".$obj->lastname."\">".$obj->name. " ".$obj->firstname." ".$obj->lastname."'.price($obj->amount).''.price($obj->amount).'
'; +print ''; +print ''; +print "\n"; + +foreach ($list as $key) +{ + $var=!$var; + + print ''; + + // Param + $label = $langs->trans($key); + print ''; + + // Value + print ''; +} + +print ''; + +print ''; +print "
' . $langs->trans('Options') . '
'; + print ''; + print '
\n"; + +print '
'; + +llxFooter(); +$db->close(); \ No newline at end of file diff --git a/htdocs/donations/card.php b/htdocs/don/card.php similarity index 93% rename from htdocs/donations/card.php rename to htdocs/don/card.php index 6c2bd28a2d0..7e4039f760f 100644 --- a/htdocs/donations/card.php +++ b/htdocs/don/card.php @@ -20,7 +20,7 @@ */ /** - * \file htdocs/donations/card.php + * \file htdocs/don/card.php * \ingroup donations * \brief Page of donation card */ @@ -30,7 +30,7 @@ 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.'/donations/class/don.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)) @@ -111,7 +111,7 @@ if ($action == 'update') $object->note_public = GETPOST("note_public"); // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels,$object); + $ret = $extrafields->setOptionalsFromPost($extralabels,$object); if ($ret < 0) $error++; if ($object->update($user) > 0) @@ -164,7 +164,7 @@ if ($action == 'add') $object->fk_project = GETPOST("fk_project"); // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels,$object); + $ret = $extrafields->setOptionalsFromPost($extralabels,$object); if ($ret < 0) $error++; if ($object->create($user) > 0) @@ -355,13 +355,13 @@ if ($action == 'create') } // Other attributes - $parameters=array(); - $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=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 "\n"; print '
   
'; print "\n"; @@ -461,13 +461,13 @@ if (! empty($id) && $action == 'edit') } // Other attributes - $parameters=array(); - $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=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 "\n"; print '
   
'; @@ -502,7 +502,7 @@ if (! empty($id) && $action != 'edit') print ''; print ''; - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; $nbrows=12; if (! empty($conf->projet->enabled)) $nbrows++; @@ -570,7 +570,7 @@ if (! empty($id) && $action != 'edit') $objp = $db->fetch_object($resql); $var=!$var; print "'; + print ''.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.''; print '\n"; $labeltype=$langs->trans("PaymentType".$object->type_code)!=("PaymentType".$object->type_code)?$langs->trans("PaymentType".$object->type_code):$object->paiement_type; print "\n"; @@ -639,12 +639,12 @@ if (! empty($id) && $action != 'edit') } // Other attributes - $parameters=array(); - $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); - } + $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 "
"; - print ''.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.''.dol_print_date($db->jdate($objp->dp),'day')."".$labeltype.' '.$object->num_paiement."
\n"; print "\n"; @@ -679,7 +679,7 @@ if (! empty($id) && $action != 'edit') } else { - print ''; + print ''; } } diff --git a/htdocs/donations/class/don.class.php b/htdocs/don/class/don.class.php similarity index 93% rename from htdocs/donations/class/don.class.php rename to htdocs/don/class/don.class.php index e02ecefccbc..c9f776e5ce6 100644 --- a/htdocs/donations/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -20,7 +20,7 @@ */ /** - * \file htdocs/donations/class/don.class.php + * \file htdocs/don/class/don.class.php * \ingroup Donation * \brief File of class to manage donations */ @@ -369,24 +369,22 @@ class Don extends CommonObject $result = $this->db->query($sql); if ($result) { - // Actions on extra fields (by external module) - /*$hookmanager->initHooks(array('dondao')); - $parameters=array('id'=>$this->id); - $action=''; - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) - { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } - } - else if ($reshook < 0) $error++; - */ + // Actions on extra fields (by external module or standard code) + $hookmanager->initHooks(array('donationdao')); + $parameters=array('id'=>$this->id); + $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if (empty($reshook)) + { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + } + else if ($reshook < 0) $error++; $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."don"); @@ -448,23 +446,22 @@ class Don extends CommonObject $result = $this->db->query($sql); if ($result) { - // Actions on extra fields (by external module) - $hookmanager->initHooks(array('dondao')); - $parameters=array('id'=>$this->id); - $action=''; - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) - { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } - } - else if ($reshook < 0) $error++; + // Actions on extra fields (by external module or standard code) + $hookmanager->initHooks(array('donationdao')); + $parameters=array('id'=>$this->id); + $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks + if (empty($reshook)) + { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$this->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + } + else if ($reshook < 0) $error++; // Call trigger $result=$this->call_trigger('DON_UPDATE',$user); @@ -500,15 +497,14 @@ class Don extends CommonObject { if ( $this->db->affected_rows($resql) ) { - // Removed extrafields - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + // Remove extrafields + if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used { $result=$this->deleteExtraFields(); if ($result < 0) { $error++; - $errorflag=-4; - dol_syslog(get_class($this)."::delete error ".$errorflag." ".$this->error, LOG_ERR); + dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); } } @@ -779,7 +775,7 @@ class Don extends CommonObject $result=''; $label=$langs->trans("ShowDonation").': '.$this->id; - $link = ''; + $link = ''; $linkend=''; $picto='generic'; diff --git a/htdocs/donations/class/donationstats.class.php b/htdocs/don/class/donationstats.class.php similarity index 96% rename from htdocs/donations/class/donationstats.class.php rename to htdocs/don/class/donationstats.class.php index b26617d651b..63105da07d2 100644 --- a/htdocs/donations/class/donationstats.class.php +++ b/htdocs/don/class/donationstats.class.php @@ -19,13 +19,13 @@ */ /** - * \file htdocs/donations/class/donationstats.class.php + * \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 . '/donations/class/don.class.php'; +include_once DOL_DOCUMENT_ROOT . '/don/class/don.class.php'; include_once DOL_DOCUMENT_ROOT . '/core/lib/date.lib.php'; diff --git a/htdocs/don/class/index.html b/htdocs/don/class/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/donations/class/paymentdonation.class.php b/htdocs/don/class/paymentdonation.class.php similarity index 97% rename from htdocs/donations/class/paymentdonation.class.php rename to htdocs/don/class/paymentdonation.class.php index 9125ea68d57..4a42c677ec9 100644 --- a/htdocs/donations/class/paymentdonation.class.php +++ b/htdocs/don/class/paymentdonation.class.php @@ -16,7 +16,7 @@ */ /** - * \file htdocs/donations/class/paymentdonation.class.php + * \file htdocs/don/class/paymentdonation.class.php * \ingroup Donation * \brief File of class to manage payment of donations */ @@ -510,7 +510,7 @@ class PaymentDonation extends CommonObject // Add link 'payment', 'payment_supplier', 'payment_donation' in bank_url between payment and bank transaction $url=''; - if ($mode == 'payment_donation') $url=DOL_URL_ROOT.'/donations/payment/card.php?rowid='; + 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); @@ -529,7 +529,7 @@ class PaymentDonation extends CommonObject { $don = new Don($this->db); $don->fetch($key); - $result=$acc->add_url_line($bank_line_id, $don->rowid, DOL_URL_ROOT.'/donations/card.php?rowid=', $don->type_libelle.(($don->lib && $don->lib!=$don->type_libelle)?' ('.$don->lib.')':''),'donation'); + $result=$acc->add_url_line($bank_line_id, $don->rowid, DOL_URL_ROOT.'/don/card.php?rowid=', $don->type_libelle.(($don->lib && $don->lib!=$don->type_libelle)?' ('.$don->lib.')':''),'donation'); if ($result <= 0) dol_print_error($this->db); } } @@ -593,7 +593,7 @@ class PaymentDonation extends CommonObject if (!empty($this->id)) { - $link = ''; + $link = ''; $linkend=''; if ($withpicto) $result.=($link.img_object($label, 'payment', 'class="classfortooltip"').$linkend.' '); diff --git a/htdocs/donations/document.php b/htdocs/don/document.php similarity index 92% rename from htdocs/donations/document.php rename to htdocs/don/document.php index 0cfb0447630..200e4180252 100644 --- a/htdocs/donations/document.php +++ b/htdocs/don/document.php @@ -16,13 +16,13 @@ */ /** - * \file htdocs/donations/document.php + * \file htdocs/don/document.php * \ingroup donations * \brief Page of linked files into donations */ require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php'; +require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php'; @@ -96,7 +96,7 @@ if ($object->id) print ''; - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; // Ref print ''; - print ''; + print ''; print '\n"; print ''; diff --git a/htdocs/donations/stats/index.php b/htdocs/don/stats/index.php similarity index 97% rename from htdocs/donations/stats/index.php rename to htdocs/don/stats/index.php index 0a58751b8ed..798b1b5a392 100644 --- a/htdocs/donations/stats/index.php +++ b/htdocs/don/stats/index.php @@ -18,14 +18,14 @@ */ /** - * \file htdocs/donations/stats/index.php + * \file htdocs/don/stats/index.php * \ingroup donations * \brief Page with donations statistics */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php'; -require_once DOL_DOCUMENT_ROOT.'/donations/class/donationstats.class.php'; +require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; +require_once DOL_DOCUMENT_ROOT.'/don/class/dontats.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php'; $WIDTH=DolGraph::getDefaultGraphSizeForStats('width'); @@ -213,7 +213,7 @@ if (! count($arrayyears)) $arrayyears[$nowyear]=$nowyear; $h=0; $head = array(); -$head[$h][0] = DOL_URL_ROOT . '/donations/stats/index.php?mode='.$mode; +$head[$h][0] = DOL_URL_ROOT . '/don/stats/index.php?mode='.$mode; $head[$h][1] = $langs->trans("ByMonthYear"); $head[$h][2] = 'byyear'; $h++; diff --git a/htdocs/install/filelist.xml b/htdocs/install/filelist.xml index e9ae4ec5dd1..7b7ed9c36ef 100644 --- a/htdocs/install/filelist.xml +++ b/htdocs/install/filelist.xml @@ -5893,7 +5893,7 @@ d41d8cd98f00b204e9800998ecf8427e8ea20800d43bbdfdb20363355521c20c - + 9029f09e1592da49626e9fb5b6399e1e d71afb404b4f1946d241bc44ab27df8b 823e0c612e7de62db2d41adf37214bea diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index f66a007e93a..d08ed699b7f 100755 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -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); From 8d4ceadd7e19861b8998d7c865206a2c56cb8f0a Mon Sep 17 00:00:00 2001 From: aspangaro Date: Wed, 25 Mar 2015 22:38:44 +0100 Subject: [PATCH 19/27] Dir "Don" --- htdocs/donations/admin/index.html | 0 htdocs/donations/admin/index.php | 117 ---------------------------- htdocs/donations/class/index.html | 0 htdocs/donations/payment/index.html | 0 4 files changed, 117 deletions(-) delete mode 100644 htdocs/donations/admin/index.html delete mode 100644 htdocs/donations/admin/index.php delete mode 100644 htdocs/donations/class/index.html delete mode 100644 htdocs/donations/payment/index.html diff --git a/htdocs/donations/admin/index.html b/htdocs/donations/admin/index.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/donations/admin/index.php b/htdocs/donations/admin/index.php deleted file mode 100644 index 78ff3b48f9a..00000000000 --- a/htdocs/donations/admin/index.php +++ /dev/null @@ -1,117 +0,0 @@ - - * - * 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 . - * - */ - -/** - * \file htdocs/admin/index.php - * \ingroup Donations - * \brief Setup page to configure donations module - */ - -require '../main.inc.php'; - -// Class -require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; - -$langs->load("admin"); -$langs->load("donations"); - -// Security check -if (!$user->admin) - accessforbidden(); - -$action = GETPOST('action', 'alpha'); - -// Other parameters DONATIONS_* -$list = array ( - 'DONATIONS_ACCOUNTING_ACCOUNT_PRODUCT' -); - -/* - * Actions - */ - -if ($action == 'update') -{ - $error = 0; - - foreach ($list as $constname) { - $constvalue = GETPOST($constname, 'alpha'); - - if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { - $error++; - } - } - - if (! $error) - { - setEventMessage($langs->trans("SetupSaved")); - } - else - { - setEventMessage($langs->trans("Error"),'errors'); - } -} - -/* - * View - */ - -llxHeader('',$langs->trans('DonationsSetup')); - -$form = new Form($db); - -$linkback=''.$langs->trans("BackToModuleList").''; -print_fiche_titre($langs->trans('DonationsSetup'),$linkback,'setup'); - -print '
'; -print ''; -print ''; - -/* - * Params - */ -print '
'.$langs->trans("Ref").''; diff --git a/htdocs/don/index.html b/htdocs/don/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/donations/index.php b/htdocs/don/index.php similarity index 98% rename from htdocs/donations/index.php rename to htdocs/don/index.php index ac64d6b2dde..b276e21dc50 100644 --- a/htdocs/donations/index.php +++ b/htdocs/don/index.php @@ -18,13 +18,13 @@ */ /** - * \file htdocs/donations/index.php + * \file htdocs/don/index.php * \ingroup donations * \brief Home page of donation module */ require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php'; +require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; $langs->load("donations"); diff --git a/htdocs/donations/info.php b/htdocs/don/info.php similarity index 93% rename from htdocs/donations/info.php rename to htdocs/don/info.php index a85b734fcf6..04cbae7a587 100644 --- a/htdocs/donations/info.php +++ b/htdocs/don/info.php @@ -16,7 +16,7 @@ */ /** - * \file htdocs/donations/info.php + * \file htdocs/don/info.php * \ingroup donations * \brief Page to show a donation information */ @@ -24,7 +24,7 @@ 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.'/donations/class/don.class.php'; +require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; $langs->load("donations"); diff --git a/htdocs/donations/list.php b/htdocs/don/list.php similarity index 98% rename from htdocs/donations/list.php rename to htdocs/don/list.php index f277dc0b671..ee7a6f5e6f9 100644 --- a/htdocs/donations/list.php +++ b/htdocs/don/list.php @@ -19,13 +19,13 @@ */ /** - * \file htdocs/donations/list.php + * \file htdocs/don/list.php * \ingroup donations * \brief List of donations */ require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php'; +require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; if (! empty($conf->projet->enabled)) require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; $langs->load("companies"); diff --git a/htdocs/donations/payment/card.php b/htdocs/don/payment/card.php similarity index 95% rename from htdocs/donations/payment/card.php rename to htdocs/don/payment/card.php index 6b30fdcc89b..5cdb7f20446 100644 --- a/htdocs/donations/payment/card.php +++ b/htdocs/don/payment/card.php @@ -16,14 +16,14 @@ */ /** - * \file htdocs/donations/payment/card.php + * \file htdocs/don/payment/card.php * \ingroup donations * \brief Tab payment of a donation */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php'; -require_once DOL_DOCUMENT_ROOT.'/donations/class/paymentdonation.class.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'; @@ -61,7 +61,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->don->supp if ($result > 0) { $db->commit(); - header("Location: ".DOL_URL_ROOT."/donations/index.php"); + header("Location: ".DOL_URL_ROOT."/don/index.php"); exit; } else @@ -121,7 +121,7 @@ $form = new Form($db); $h=0; -$head[$h][0] = DOL_URL_ROOT.'/donations/payment/card.php?id='.$id; +$head[$h][0] = DOL_URL_ROOT.'/don/payment/card.php?id='.$id; $head[$h][1] = $langs->trans("Card"); $hselected = $h; $h++; diff --git a/htdocs/don/payment/index.html b/htdocs/don/payment/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/donations/payment/payment.php b/htdocs/don/payment/payment.php similarity index 95% rename from htdocs/donations/payment/payment.php rename to htdocs/don/payment/payment.php index 871bbaa1056..52cf8f38a12 100644 --- a/htdocs/donations/payment/payment.php +++ b/htdocs/don/payment/payment.php @@ -16,14 +16,14 @@ */ /** - * \file htdocs/donations/payment.php + * \file htdocs/don/payment.php * \ingroup donations * \brief Page to add payment of a donation */ require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/donations/class/don.class.php'; -require_once DOL_DOCUMENT_ROOT.'/donations/class/paymentdonation.class.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"); @@ -50,7 +50,7 @@ if ($action == 'add_payment') if ($_POST["cancel"]) { - $loc = DOL_URL_ROOT.'/donations/card.php?rowid='.$chid; + $loc = DOL_URL_ROOT.'/don/card.php?rowid='.$chid; header("Location: ".$loc); exit; } @@ -129,7 +129,7 @@ if ($action == 'add_payment') if (! $error) { $db->commit(); - $loc = DOL_URL_ROOT.'/donations/card.php?rowid='.$chid; + $loc = DOL_URL_ROOT.'/don/card.php?rowid='.$chid; header('Location: '.$loc); exit; } @@ -180,7 +180,7 @@ if (GETPOST("action") == 'create') print '
'.$langs->trans("Donation").'
'.$langs->trans("Ref").''.$chid.'
'.$langs->trans("Ref").''.$chid.'
'.$langs->trans("Date")."".dol_print_date($don->date,'day')."
'.$langs->trans("Amount")."".price($don->amount,0,$outputlangs,1,-1,-1,$conf->currency).'
'; -print ''; -print ''; -print "\n"; - -foreach ($list as $key) -{ - $var=!$var; - - print ''; - - // Param - $label = $langs->trans($key); - print ''; - - // Value - print ''; -} - -print ''; - -print ''; -print "
' . $langs->trans('Options') . '
'; - print ''; - print '
\n"; - -print '
'; - -llxFooter(); -$db->close(); \ No newline at end of file diff --git a/htdocs/donations/class/index.html b/htdocs/donations/class/index.html deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/htdocs/donations/payment/index.html b/htdocs/donations/payment/index.html deleted file mode 100644 index e69de29bb2d..00000000000 From b60f1e33d6767e5bb94568cc7453b72d0f0d7c5a Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 26 Mar 2015 06:29:16 +0100 Subject: [PATCH 20/27] Debug --- htdocs/compta/bank/account.php | 1 + htdocs/core/modules/modDon.class.php | 2 +- htdocs/projet/element.php | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php index 3213709a54e..cd7478bf36c 100644 --- a/htdocs/compta/bank/account.php +++ b/htdocs/compta/bank/account.php @@ -730,6 +730,7 @@ if ($id > 0 || ! empty($ref)) } $donstatic->ref=$donstatic->lib; print $donstatic->getNomUrl(1,16); + } else if ($links[$key]['type']=='loan') { $loanstatic->id=$links[$key]['url_id']; diff --git a/htdocs/core/modules/modDon.class.php b/htdocs/core/modules/modDon.class.php index 6d67b625f91..8c7425ceed2 100644 --- a/htdocs/core/modules/modDon.class.php +++ b/htdocs/core/modules/modDon.class.php @@ -64,7 +64,7 @@ class modDon extends DolibarrModules $this->requiredby = array(); // Config pages - $this->config_page_url = array("donation.php@donations"); + $this->config_page_url = array("donation.php@don"); // Constants $this->const = array (); diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 000b759e091..23c3cc6f8b1 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -53,7 +53,7 @@ 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->expensereport->enabled)) $langs->load("donations"); +if (! empty($conf->don->enabled)) $langs->load("donations"); $id=GETPOST('id','int'); $ref=GETPOST('ref','alpha'); From 059bb403450eb0ce48d70ac7e4e3e37bf0b37c83 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 26 Mar 2015 20:43:34 +0100 Subject: [PATCH 21/27] Debug --- htdocs/don/card.php | 44 ++-- htdocs/don/class/don.class.php | 320 +++++++++++++----------- htdocs/install/mysql/tables/llx_don.sql | 6 +- htdocs/langs/en_US/donations.lang | 2 + htdocs/projet/class/project.class.php | 2 +- 5 files changed, 211 insertions(+), 163 deletions(-) diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 7e4039f760f..8f33ee7fb1b 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -47,25 +47,25 @@ $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); -// fetch optionals attributes and labels -$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); - -$donation_date=dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); - // 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') { @@ -174,17 +174,21 @@ if ($action == 'add') } } } - -if ($action == 'delete') +if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights->don->supprimer) { - $object->delete($id); - header("Location: list.php"); - exit; -} -if ($action == 'commentaire') -{ - $object->fetch($id); - $object->update_note(GETPOST("commentaire")); + $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') { @@ -486,6 +490,13 @@ if (! empty($id) && $action == 'edit') /* ************************************************************ */ 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; @@ -689,6 +700,7 @@ if (! empty($id) && $action != 'edit') print '"; } + // Delete if ($user->rights->don->supprimer) { print '"; diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index c9f776e5ce6..bddd5c9e533 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -34,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_don'; + protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe var $id; var $ref; @@ -299,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); @@ -314,8 +321,6 @@ 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 ("; @@ -365,41 +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) { - // Actions on extra fields (by external module or standard code) - $hookmanager->initHooks(array('donationdao')); - $parameters=array('id'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) - { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } - } - else if ($reshook < 0) $error++; - - $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; } } @@ -410,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); @@ -440,91 +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) - { - // Actions on extra fields (by external module or standard code) - $hookmanager->initHooks(array('donationdao')); - $parameters=array('id'=>$this->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) - { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - { - $result=$this->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } - } - else if ($reshook < 0) $error++; - - // 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) { - // Remove extrafields - if ((! $error) && (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED))) // For avoid conflicts if trigger used - { - $result=$this->deleteExtraFields(); - if ($result < 0) - { - $error++; - dol_syslog(get_class($this)."::delete error -4 ".$this->error, LOG_ERR); - } - } - - // 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; } } @@ -536,7 +593,7 @@ 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; @@ -550,7 +607,15 @@ class Don extends CommonObject $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"; - $sql.= " WHERE d.rowid = ".$rowid." AND d.entity = ".$conf->entity; + 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); @@ -615,10 +680,10 @@ class Don extends CommonObject * @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) @@ -646,7 +711,7 @@ 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) @@ -674,46 +739,15 @@ class Don extends CommonObject } } - - /** - * Classe le don comme encaisse - * - * @param int $rowid id du don a modifier - * @return int <0 if KO, >0 if OK - */ - function set_encaisse($rowid) - { - - $sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = 3 WHERE rowid = $rowid AND fk_statut = 2"; - - $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; - } - } - /** * Set donation to status canceled * * @param int $rowid id of donation * @return int <0 if KO, >0 if OK */ - function set_cancel($rowid) + function set_cancel($id) { - $sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = -1 WHERE rowid = ".$rowid; + $sql = "UPDATE ".MAIN_DB_PREFIX."don SET fk_statut = -1 WHERE rowid = ".$id; $resql=$this->db->query($sql); if ($resql) diff --git a/htdocs/install/mysql/tables/llx_don.sql b/htdocs/install/mysql/tables/llx_don.sql index a3882fc6f99..d33467f9a7b 100644 --- a/htdocs/install/mysql/tables/llx_don.sql +++ b/htdocs/install/mysql/tables/llx_don.sql @@ -26,7 +26,7 @@ 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, @@ -43,8 +43,8 @@ create table llx_don email varchar(255), phone varchar(24), phone_mobile varchar(24), - public smallint DEFAULT 1 NOT NULL, -- le don est-il public (0,1) - fk_project 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, diff --git a/htdocs/langs/en_US/donations.lang b/htdocs/langs/en_US/donations.lang index 13634f98380..627cc9a076c 100644 --- a/htdocs/langs/en_US/donations.lang +++ b/htdocs/langs/en_US/donations.lang @@ -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 diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 681abb411ce..e78e9de0c63 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -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) { From 6a0916b3faaf46f3ba48ff50d0c88df13a0f0a48 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 26 Mar 2015 21:03:56 +0100 Subject: [PATCH 22/27] Correct path --- htdocs/don/class/don.class.php | 2 +- htdocs/public/donations/donateurs_code.php | 2 +- htdocs/public/donations/therm.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index bddd5c9e533..c4f9d66a3ec 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -36,7 +36,7 @@ class Don extends CommonObject { 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_don'; + 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; diff --git a/htdocs/public/donations/donateurs_code.php b/htdocs/public/donations/donateurs_code.php index ad42b7e0e7f..0fef24df949 100644 --- a/htdocs/public/donations/donateurs_code.php +++ b/htdocs/public/donations/donateurs_code.php @@ -39,7 +39,7 @@ function llxHeaderVierge() { print 'Export agenda cal function llxFooterVierge() { print ''; } require '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT .'/donations/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); diff --git a/htdocs/public/donations/therm.php b/htdocs/public/donations/therm.php index 36bdec4637f..7c24253dd71 100644 --- a/htdocs/public/donations/therm.php +++ b/htdocs/public/donations/therm.php @@ -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.'/donations/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); From f0823a215b98f95ce934d2e3aa9e36159a3fbd31 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 26 Mar 2015 21:16:52 +0100 Subject: [PATCH 23/27] Add language key --- htdocs/langs/en_US/projects.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index ef270909120..40b1c2e308d 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -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 From ce6df7c022446ec68a803f7616faaa35bfc15aa6 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 29 Mar 2015 09:20:32 +0200 Subject: [PATCH 24/27] Debug --- htdocs/compta/bank/account.php | 22 +-- htdocs/core/lib/donation.lib.php | 5 - htdocs/core/menus/init_menu_auguria.sql | 2 +- htdocs/core/menus/standard/eldy.lib.php | 2 +- htdocs/don/card.php | 33 +++-- htdocs/don/class/don.class.php | 4 +- ...tionstats.class.php => donstats.class.php} | 0 htdocs/don/class/paymentdonation.class.php | 83 +++++------- htdocs/don/document.php | 125 ------------------ htdocs/don/payment/card.php | 21 +-- htdocs/don/stats/index.php | 3 +- htdocs/langs/en_US/donations.lang | 1 + 12 files changed, 71 insertions(+), 230 deletions(-) rename htdocs/don/class/{donationstats.class.php => donstats.class.php} (100%) delete mode 100644 htdocs/don/document.php diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php index 329ba2149cf..20ef8bcc3cc 100644 --- a/htdocs/compta/bank/account.php +++ b/htdocs/compta/bank/account.php @@ -47,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'); @@ -617,6 +618,12 @@ if ($id > 0 || ! empty($ref)) print ' '.img_object($langs->trans('ShowPayment'),'payment').' '; print ''; } + elseif ($links[$key]['type']=='payment_donation') + { + print ''; + print ' '.img_object($langs->trans('ShowPayment'),'payment').' '; + print ''; + } 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. @@ -716,21 +723,6 @@ if ($id > 0 || ! empty($ref)) $chargestatic->ref=$chargestatic->lib; print $chargestatic->getNomUrl(1,16); } - else if ($links[$key]['type']=='donation') - { - $donstatic->id=$links[$key]['url_id']; - if (preg_match('/^\((.*)\)$/i',$links[$key]['label'],$reg)) - { - if ($reg[1]=='donation') $reg[1]='Donation'; - $donstatic->lib=$langs->trans($reg[1]); - } - else - { - $donstatic->lib=$links[$key]['label']; - } - $donstatic->ref=$donstatic->lib; - print $donstatic->getNomUrl(1,16); - } else if ($links[$key]['type']=='loan') { $loanstatic->id=$links[$key]['url_id']; diff --git a/htdocs/core/lib/donation.lib.php b/htdocs/core/lib/donation.lib.php index 4155d5ce60e..ed6407b1e84 100644 --- a/htdocs/core/lib/donation.lib.php +++ b/htdocs/core/lib/donation.lib.php @@ -78,11 +78,6 @@ function donation_prepare_head($object) // $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/document.php?id='.$object->id; - $head[$h][1] = $langs->trans("Documents"); - $head[$h][2] = 'documents'; - $h++; $head[$h][0] = DOL_URL_ROOT . '/don/info.php?id=' . $object->id; $head[$h][1] = $langs->trans("Info"); diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index 3eab01619f1..ffb33138bcc 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -175,7 +175,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$conf->don->enabled', __HANDLER__, 'left', 2000__+MAX_llx_menu__, 'accountancy', 'donations', 6__+MAX_llx_menu__, '/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__); +-- 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__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 1d35db720b7..9eba6b79dd6 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -810,7 +810,7 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu $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); + // if ($leftmenu=="donations") $newmenu->add("/don/stats/index.php",$langs->trans("Statistics"), 1, $user->rights->don->lire); } // Taxes and social contributions diff --git a/htdocs/don/card.php b/htdocs/don/card.php index 8f33ee7fb1b..d3ce60a5381 100644 --- a/htdocs/don/card.php +++ b/htdocs/don/card.php @@ -214,7 +214,7 @@ if ($action == 'set_cancel') } if ($action == 'set_paid') { - if ($object->set_paye($id, $modepayment) >= 0) + if ($object->set_paid($id, $modepayment) >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); exit; @@ -223,17 +223,6 @@ if ($action == 'set_paid') setEventMessage($object->error, 'errors'); } } -if ($action == 'set_encaisse') -{ - if ($object->set_encaisse($id) >= 0) - { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$id); - exit; - } - else { - setEventMessage($object->error, 'errors'); - } -} /* * Build doc @@ -398,6 +387,7 @@ if (! empty($id) && $action == 'edit') print ''; print ''; + print ''; // Ref print "".''.$langs->trans("Ref").''; @@ -408,13 +398,22 @@ if (! empty($id) && $action == 'edit') $nbrows=12; if (! empty($conf->projet->enabled)) $nbrows++; - // Date + // Date print "".''.$langs->trans("Date").''; $form->select_date($object->date,'','','','',"update"); print ''; // Amount - print "".''.$langs->trans("Amount").' '.$langs->trans("Currency".$conf->currency).''; + if ($object->statut == 0) + { + print "".''.$langs->trans("Amount").' '.$langs->trans("Currency".$conf->currency).''; + } + else + { + print ''.$langs->trans("Amount").''; + print price($object->amount,0,$langs,0,0,-1,$conf->currency); + print ''; + } print ''.$langs->trans("PublicDonation").""; print $form->selectyesno("public",1,1); @@ -549,7 +548,7 @@ if (! empty($id) && $action != 'edit') /* * Payments */ - $sql = "SELECT p.rowid, p.num_payment, datep as dp, p.amount,"; + $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 "; @@ -558,7 +557,7 @@ if (! empty($id) && $action != 'edit') $sql.= " AND p.fk_donation = d.rowid"; $sql.= " AND d.entity = ".$conf->entity; $sql.= " AND p.fk_typepayment = c.id"; - $sql.= " ORDER BY dp DESC"; + $sql.= " ORDER BY dp"; //print $sql; $resql = $db->query($sql); @@ -581,7 +580,7 @@ if (! empty($id) && $action != 'edit') $objp = $db->fetch_object($resql); $var=!$var; print ""; - print ''.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.''; + print ''.img_object($langs->trans("Payment"),"payment").' '.$objp->rowid.''; print ''.dol_print_date($db->jdate($objp->dp),'day')."\n"; $labeltype=$langs->trans("PaymentType".$object->type_code)!=("PaymentType".$object->type_code)?$langs->trans("PaymentType".$object->type_code):$object->paiement_type; print "".$labeltype.' '.$object->num_paiement."\n"; diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index c4f9d66a3ec..ce041351eed 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -718,7 +718,7 @@ class Don extends CommonObject { $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) @@ -809,7 +809,7 @@ class Don extends CommonObject $result=''; $label=$langs->trans("ShowDonation").': '.$this->id; - $link = ''; + $link = ''; $linkend=''; $picto='generic'; diff --git a/htdocs/don/class/donationstats.class.php b/htdocs/don/class/donstats.class.php similarity index 100% rename from htdocs/don/class/donationstats.class.php rename to htdocs/don/class/donstats.class.php diff --git a/htdocs/don/class/paymentdonation.class.php b/htdocs/don/class/paymentdonation.class.php index 4a42c677ec9..a6c56f9f235 100644 --- a/htdocs/don/class/paymentdonation.class.php +++ b/htdocs/don/class/paymentdonation.class.php @@ -82,14 +82,14 @@ class PaymentDonation extends CommonObject } // 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); + 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 @@ -183,23 +183,23 @@ class PaymentDonation extends CommonObject $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->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->type_code = $obj->type_code; + $this->type_libelle = $obj->type_libelle; - $this->bank_account = $obj->fk_account; - $this->bank_line = $obj->fk_bank; + $this->bank_account = $obj->fk_account; + $this->bank_line = $obj->fk_bank; } $this->db->free($resql); @@ -227,14 +227,14 @@ class PaymentDonation extends CommonObject // 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); + 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); @@ -482,14 +482,14 @@ class PaymentDonation extends CommonObject $acc->fetch($accountid); $total=$this->total; - if ($mode == 'payment_donation') $total=-$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, - $total, + $amount, $this->num_payment, '', $user, @@ -520,19 +520,6 @@ class PaymentDonation extends CommonObject dol_print_error($this->db); } } - - // Add link 'thirdparty' in bank_url between donation and bank transaction (for each donation concerned by payment) - $linkaddedforthirdparty=array(); - foreach ($this->amounts as $key => $value) - { - if ($mode == 'payment_donation') - { - $don = new Don($this->db); - $don->fetch($key); - $result=$acc->add_url_line($bank_line_id, $don->rowid, DOL_URL_ROOT.'/don/card.php?rowid=', $don->type_libelle.(($don->lib && $don->lib!=$don->type_libelle)?' ('.$don->lib.')':''),'donation'); - if ($result <= 0) dol_print_error($this->db); - } - } } else { @@ -553,7 +540,7 @@ class PaymentDonation extends CommonObject /** - * Mise a jour du lien entre le paiement de charge et la ligne dans llx_bank generee + * 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 @@ -593,7 +580,7 @@ class PaymentDonation extends CommonObject if (!empty($this->id)) { - $link = ''; + $link = ''; $linkend=''; if ($withpicto) $result.=($link.img_object($label, 'payment', 'class="classfortooltip"').$linkend.' '); diff --git a/htdocs/don/document.php b/htdocs/don/document.php deleted file mode 100644 index 200e4180252..00000000000 --- a/htdocs/don/document.php +++ /dev/null @@ -1,125 +0,0 @@ - - * - * 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 . - */ - -/** - * \file htdocs/don/document.php - * \ingroup donations - * \brief Page of linked files into donations - */ - -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; - -$langs->load("other"); -$langs->load("donations"); -$langs->load("companies"); -$langs->load("interventions"); - -$id = GETPOST('id','int'); -$ref = GETPOST('ref', 'alpha'); -$action = GETPOST('action','alpha'); -$confirm = GETPOST('confirm','alpha'); - -// Security check -if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'don', $id, ''); - -// Get parameters -$sortfield = GETPOST('sortfield','alpha'); -$sortorder = GETPOST('sortorder','alpha'); -$page = GETPOST('page','int'); -if ($page == -1) { $page = 0; } -$offset = $conf->liste_limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="name"; - -$object = new Don($db); -$object->fetch($id, $ref); - -$upload_dir = $conf->dons->dir_output.'/'.dol_sanitizeFileName($object->ref); -$modulepart='don'; - - -/* - * Actions - */ - -include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php'; - - -/* - * View - */ - -$form = new Form($db); - -llxHeader("","",$langs->trans("Don")); - - -if ($object->id) -{ - $object->fetch_thirdparty(); - - $head=donation_prepare_head($object); - - dol_fiche_head($head, 'documents', $langs->trans("Don"), 0, 'bill'); - - - // Built files list - $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); - $totalsize=0; - foreach($filearray as $key => $file) - { - $totalsize+=$file['size']; - } - - - print ''; - - $linkback = ''.$langs->trans("BackToList").''; - - // Ref - print ''; - - print ''; - print ''; - print '
'.$langs->trans("Ref").''; - print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref', ''); - print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; - - print ''; - - $modulepart = 'don'; - $permission = $user->rights->don->creer; - $param = '&id=' . $object->id; - include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; - -} -else -{ - print $langs->trans("ErrorUnknown"); -} - -llxFooter(); - -$db->close(); diff --git a/htdocs/don/payment/card.php b/htdocs/don/payment/card.php index 5cdb7f20446..4c59f566ba5 100644 --- a/htdocs/don/payment/card.php +++ b/htdocs/don/payment/card.php @@ -126,7 +126,7 @@ $head[$h][1] = $langs->trans("Card"); $hselected = $h; $h++; -dol_fiche_head($head, $hselected, $langs->trans("PaymentDonation"), 0, 'payment'); +dol_fiche_head($head, $hselected, $langs->trans("DonationPayment"), 0, 'payment'); /* * Confirmation de la suppression du paiement @@ -151,19 +151,19 @@ if ($action == 'valide') print ''; // Ref -print ''; +print ''; print ''; // Date -print ''; +print ''; // Mode print ''; // Number -print ''; +print ''; // Amount print ''; @@ -196,7 +196,7 @@ print '
'.$langs->trans('Ref').'
'.$langs->trans('Ref').''; print $form->showrefnav($payment,'id','',1,'rowid','id'); print '
'.$langs->trans('Date').''.dol_print_date($payment->datep,'day').'
'.$langs->trans('Date').''.dol_print_date($payment->datep,'day').'
'.$langs->trans('Mode').''.$langs->trans("PaymentType".$payment->type_code).'
'.$langs->trans('Number').''.$payment->num_paiement.'
'.$langs->trans('Number').''.$payment->num_payment.'
'.$langs->trans('Amount').''.price($payment->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'
'; */ $disable_delete = 0; -$sql = 'SELECT d.rowid as did, d.libelle, d.paid, d.amount as d_amount, pd.amount, pd.libelle as d_type'; +$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; @@ -213,9 +213,7 @@ if ($resql) print '
'; print ''; print ''; - print ''; - print ''; - print ''; + print ''; print ''; print ''; print "\n"; @@ -235,13 +233,6 @@ if ($resql) $don->fetch($objp->did); print $don->getNomUrl(1); print "\n"; - // Type - print '\n"; - // Label - print ''; // Expected to pay print ''; // Status diff --git a/htdocs/don/stats/index.php b/htdocs/don/stats/index.php index 798b1b5a392..91f4465f376 100644 --- a/htdocs/don/stats/index.php +++ b/htdocs/don/stats/index.php @@ -2,6 +2,7 @@ /* Copyright (C) 2001-2003 Rodolphe Quiedeville * Copyright (C) 2004-2013 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2015 Alexandre Spangaro * * 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,7 +26,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; -require_once DOL_DOCUMENT_ROOT.'/don/class/dontats.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'); diff --git a/htdocs/langs/en_US/donations.lang b/htdocs/langs/en_US/donations.lang index 627cc9a076c..8b4c2ca8756 100644 --- a/htdocs/langs/en_US/donations.lang +++ b/htdocs/langs/en_US/donations.lang @@ -40,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 From c733249c7583dfd3bbe0cfa241d9d86d181276a6 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 29 Mar 2015 09:23:39 +0200 Subject: [PATCH 25/27] Don Remove old file --- htdocs/don/admin/index.php | 117 ------------------------------------- 1 file changed, 117 deletions(-) delete mode 100644 htdocs/don/admin/index.php diff --git a/htdocs/don/admin/index.php b/htdocs/don/admin/index.php deleted file mode 100644 index 78ff3b48f9a..00000000000 --- a/htdocs/don/admin/index.php +++ /dev/null @@ -1,117 +0,0 @@ - - * - * 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 . - * - */ - -/** - * \file htdocs/admin/index.php - * \ingroup Donations - * \brief Setup page to configure donations module - */ - -require '../main.inc.php'; - -// Class -require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; - -$langs->load("admin"); -$langs->load("donations"); - -// Security check -if (!$user->admin) - accessforbidden(); - -$action = GETPOST('action', 'alpha'); - -// Other parameters DONATIONS_* -$list = array ( - 'DONATIONS_ACCOUNTING_ACCOUNT_PRODUCT' -); - -/* - * Actions - */ - -if ($action == 'update') -{ - $error = 0; - - foreach ($list as $constname) { - $constvalue = GETPOST($constname, 'alpha'); - - if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) { - $error++; - } - } - - if (! $error) - { - setEventMessage($langs->trans("SetupSaved")); - } - else - { - setEventMessage($langs->trans("Error"),'errors'); - } -} - -/* - * View - */ - -llxHeader('',$langs->trans('DonationsSetup')); - -$form = new Form($db); - -$linkback=''.$langs->trans("BackToModuleList").''; -print_fiche_titre($langs->trans('DonationsSetup'),$linkback,'setup'); - -print '
'; -print ''; -print ''; - -/* - * Params - */ -print '
'.$langs->trans('Donation').''.$langs->trans('Type').''.$langs->trans('Label').''.$langs->trans('ExpectedToPay').''.$langs->trans('ExpectedToPay').''.$langs->trans('Status').''.$langs->trans('PayedByThisPayment').'
'; - print $don->type_libelle; - /*print $don->type;*/ - print "'.$objp->libelle.''.price($objp->d_amount).'
'; -print ''; -print ''; -print "\n"; - -foreach ($list as $key) -{ - $var=!$var; - - print ''; - - // Param - $label = $langs->trans($key); - print ''; - - // Value - print ''; -} - -print ''; - -print ''; -print "
' . $langs->trans('Options') . '
'; - print ''; - print '
\n"; - -print '
'; - -llxFooter(); -$db->close(); \ No newline at end of file From ed493b651b8b6719064d1b6d929476dd75dde2a4 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 29 Mar 2015 14:29:53 +0200 Subject: [PATCH 26/27] Icons & fr_FR options not show --- htdocs/don/admin/donation.php | 5 +++-- htdocs/don/admin/donation_extrafields.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/don/admin/donation.php b/htdocs/don/admin/donation.php index 41ea0a3d542..b7fb9c2b74a 100644 --- a/htdocs/don/admin/donation.php +++ b/htdocs/don/admin/donation.php @@ -184,7 +184,7 @@ print_fiche_titre($langs->trans("DonationsSetup"),$linkback,'setup'); $head = donation_admin_prepare_head(); -dol_fiche_head($head, 'general', $langs->trans("Donations"), 0, 'donation'); +dol_fiche_head($head, 'general', $langs->trans("Donations"), 0, 'payment'); /* * Params @@ -215,7 +215,8 @@ print ''; /* * French params */ -if (preg_match('/fr/i',$outputlangs->defaultlang)) +print $outputlangs->defaultlang; +if (preg_match('/fr/i',$conf->global->MAIN_INFO_SOCIETE_COUNTRY)) { print '
'; print_titre($langs->trans("FrenchOptions")); diff --git a/htdocs/don/admin/donation_extrafields.php b/htdocs/don/admin/donation_extrafields.php index 6c964b46321..2d08c36873f 100644 --- a/htdocs/don/admin/donation_extrafields.php +++ b/htdocs/don/admin/donation_extrafields.php @@ -66,7 +66,7 @@ print_fiche_titre($langs->trans("DonationsSetup"),$linkback,'setup'); $head = donation_admin_prepare_head(); -dol_fiche_head($head, 'attributes', $langs->trans("Donations"), 0, 'donation'); +dol_fiche_head($head, 'attributes', $langs->trans("Donations"), 0, 'payment'); require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php'; From 96b7cac93fac2c2dc43862ecc8804cb220ad8bf8 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 29 Mar 2015 14:30:43 +0200 Subject: [PATCH 27/27] Delete useless line --- htdocs/don/admin/donation.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/don/admin/donation.php b/htdocs/don/admin/donation.php index b7fb9c2b74a..af00f2dbbcc 100644 --- a/htdocs/don/admin/donation.php +++ b/htdocs/don/admin/donation.php @@ -215,7 +215,6 @@ print ''; /* * French params */ -print $outputlangs->defaultlang; if (preg_match('/fr/i',$conf->global->MAIN_INFO_SOCIETE_COUNTRY)) { print '
';