Donation : Complete work on dol_banner & Fix project selector

This commit is contained in:
aspangaro 2016-12-20 21:39:42 +01:00
parent e9765c5190
commit eb2d85ab78
5 changed files with 162 additions and 45 deletions

View File

@ -49,7 +49,7 @@ $action=GETPOST('action','alpha');
$cancel=GETPOST('cancel');
$amount=GETPOST('amount');
$donation_date=dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear'));
$projectid=GETPOST('projectid')?GETPOST('projectid','int'):GETPOST("fk_projet",'int');
$projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0);
$object = new Don($db);
$extrafields = new ExtraFields($db);
@ -109,7 +109,7 @@ if ($action == 'update')
$object->email = GETPOST("email");
$object->date = $donation_date;
$object->public = GETPOST("public");
$object->fk_projet = GETPOST("fk_projet");
$object->fk_project = GETPOST("fk_project");
$object->note_private= GETPOST("note_private");
$object->note_public = GETPOST("note_public");
@ -164,7 +164,7 @@ if ($action == 'add')
$object->note_private= GETPOST("note_private");
$object->note_public = GETPOST("note_public");
$object->public = GETPOST("public");
$object->fk_projet = GETPOST("fk_projet");
$object->fk_project = GETPOST("fk_project");
// Fill array 'array_options' with data from add form
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
@ -230,6 +230,11 @@ if ($action == 'set_paid')
setEventMessages($object->error, $object->errors, 'errors');
}
}
else if ($action == 'classin' && $user->rights->don->creer)
{
$object->fetch($id);
$object->setProject($projectid);
}
// Remove file in doc form
if ($action == 'remove_file')
{
@ -361,7 +366,7 @@ if ($action == 'create')
if (! empty($conf->projet->enabled))
{
print "<tr><td>".$langs->trans("Project")."</td><td>";
$formproject->select_projects(-1, $projectid,'fk_projet', 0, 0, 1, 1);
$formproject->select_projects(-1, $projectid,'fk_project', 0, 0, 1, 1);
print "</td></tr>\n";
}
@ -486,7 +491,7 @@ if (! empty($id) && $action == 'edit')
$langs->load('projects');
print '<tr><td>'.$langs->trans('Project').'</td><td>';
$formproject->select_projects(-1, $object->fk_projet,'fk_projet', 0, 0, 1, 1);
$formproject->select_projects(-1, $object->fk_project,'fk_project', 0, 0, 1, 1);
print '</td></tr>';
}

View File

@ -363,7 +363,7 @@ class Don extends CommonObject
$sql.= ", '".$this->db->escape($this->town)."'";
$sql.= ", ".$this->country_id;
$sql.= ", ".$this->public;
$sql.= ", ".($this->fk_projet > 0?$this->fk_projet:"null");
$sql.= ", ".($this->fk_project > 0?$this->fk_project:"null");
$sql.= ", ".(!empty($this->note_private)?("'".$this->db->escape($this->note_private)."'"):"NULL");
$sql.= ", ".(!empty($this->note_public)?("'".$this->db->escape($this->note_public)."'"):"NULL");
$sql.= ", ".$user->id;
@ -459,7 +459,7 @@ class Don extends CommonObject
$sql .= ",town='".$this->db->escape($this->town)."'";
$sql .= ",fk_country = ".$this->country_id;
$sql .= ",public=".$this->public;
$sql .= ",fk_projet=".($this->fk_projet>0?$this->fk_projet:'null');
$sql .= ",fk_projet=".($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)."'";

View File

@ -48,6 +48,7 @@ $id = GETPOST('id','int');
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action','alpha');
$confirm = GETPOST('confirm','alpha');
$projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0);
// Security check
if ($user->societe_id) $socid=$user->societe_id;
@ -79,6 +80,11 @@ $modulepart='don';
include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
if ($action == 'classin' && $user->rights->don->creer)
{
$object->fetch($id);
$object->setProject($projectid);
}
/*
* View
@ -87,7 +93,9 @@ include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
$form = new Form($db);
if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
llxHeader("",$langs->trans("Donation"));
$title = $langs->trans('Donation') . " - " . $langs->trans('Documents');
$helpurl = "";
llxHeader('', $title, $helpurl);
if ($object->id)

View File

@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
/* Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro@zendsi.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -25,37 +25,101 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
if (! empty($conf->projet->enabled))
{
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
}
$langs->load("donations");
// Security check
$id = GETPOST('id','int');
$ref=GETPOST('ref','alpha');
$action=GETPOST('action','alpha');
$projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0);
// Security check
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'don', $id, '');
$object = new Don($db);
$object->fetch($id);
/*
* Actions
*/
if ($action == 'classin' && $user->rights->don->creer)
{
$object->fetch($id);
$object->setProject($projectid);
}
/*
* View
*/
$title = $langs->trans('Donation') . " - " . $langs->trans('Info');
$helpurl = "";
llxHeader('', $title, $helpurl);
llxHeader("",$langs->trans("Donation"));
$form = new Form($db);
if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
if ($id)
$object->info($id);
$head = donation_prepare_head($object);
dol_fiche_head($head, 'info', $langs->trans("Donation"), 0, 'generic');
$linkback = '<a href="'.DOL_URL_ROOT.'/don/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
$morehtmlref='<div class="refidno">';
// Project
if (! empty($conf->projet->enabled))
{
$object = new Don($db);
$object->fetch($id);
$object->info($id);
$head = donation_prepare_head($object);
dol_fiche_head($head, 'info', $langs->trans("Donation"), 0, 'generic');
print '<table width="100%"><tr><td>';
dol_print_object_info($object);
print '</td></tr></table>';
print '</div>';
$langs->load("projects");
$morehtmlref.=$langs->trans('Project') . ' ';
if ($user->rights->don->creer)
{
if ($action != 'classify')
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<br>';
print '<table width="100%"><tr><td>';
dol_print_object_info($object);
print '</td></tr></table>';
print '</div>';
dol_fiche_end();
llxFooter();
$db->close();

View File

@ -2,7 +2,8 @@
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2016 Alexandre Spangaro <aspangaro@zendsi.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -19,15 +20,20 @@
*/
/**
* \file htdocs/compta/facture/note.php
* \ingroup facture
* \brief Fiche de notes sur une facture
* \file htdocs/don/note.php
* \ingroup donations
* \brief Page to show a donation notes
*/
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
if (! empty($conf->projet->enabled))
{
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
}
$langs->load("companies");
$langs->load("bills");
@ -36,6 +42,7 @@ $langs->load("donations");
$id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility
$ref=GETPOST('ref','alpha');
$action=GETPOST('action','alpha');
$projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0);
// Security check
$socid=0;
@ -51,10 +58,13 @@ $permissionnote=$user->rights->don->creer; // Used by the include of actions_set
/*
* Actions
*/
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
if ($action == 'classin' && $user->rights->don->creer)
{
$object->fetch($id);
$object->setProject($projectid);
}
/*
* View
@ -65,35 +75,65 @@ $helpurl = "";
llxHeader('', $title, $helpurl);
$form = new Form($db);
if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
if ($id > 0 || ! empty($ref))
{
$object = new Don($db);
$object->fetch($id,$ref);
$head = donation_prepare_head($object);
$head = donation_prepare_head($object);
dol_fiche_head($head, 'note', $langs->trans("Donation"), 0, 'generic');
$linkback = '<a href="'.DOL_URL_ROOT.'/don/list.php">'.$langs->trans("BackToList").'</a>';
print '<table class="border" width="100%">';
dol_fiche_head($head, 'note', $langs->trans("Donation"), 0, 'generic');
// Ref
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>';
print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref', '');
print '</td></tr>';
$linkback = '<a href="'.DOL_URL_ROOT.'/don/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
print "</table>";
$morehtmlref='<div class="refidno">';
// Project
if (! empty($conf->projet->enabled))
{
$langs->load("projects");
$morehtmlref.=$langs->trans('Project') . ' ';
if ($user->rights->don->creer)
{
if ($action != 'classify')
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
$morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
$morehtmlref.='<input type="hidden" name="action" value="classin">';
$morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
$morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
$morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
$morehtmlref.='</form>';
} else {
$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
}
} else {
if (! empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
$morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
$morehtmlref.=$proj->ref;
$morehtmlref.='</a>';
} else {
$morehtmlref.='';
}
}
}
$morehtmlref.='</div>';
print '<br>';
dol_banner_tab($object, 'rowid', $linkback, 1, 'rowid', 'ref', $morehtmlref);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
$cssclass="titlefield";
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
dol_fiche_end();
}
llxFooter();
$db->close();