Merge pull request #6199 from aspangaro/5.0-p14

Loan | Donation | Social contribution : Complete work on dol_banner
This commit is contained in:
Laurent Destailleur 2016-12-23 00:45:08 +01:00 committed by GitHub
commit 6d14710e18
14 changed files with 409 additions and 260 deletions

View File

@ -269,8 +269,9 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->char
$form = new Form($db); $form = new Form($db);
$formsocialcontrib = new FormSocialContrib($db); $formsocialcontrib = new FormSocialContrib($db);
$title = $langs->trans("SocialContribution") . ' - ' . $langs->trans("Card");
$help_url='EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:Módulo Impuestos y cargas sociales (IVA, impuestos)'; $help_url='EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:Módulo Impuestos y cargas sociales (IVA, impuestos)';
llxHeader("",$langs->trans("SocialContribution"),$help_url); llxHeader("",$title,$help_url);
// Mode creation // Mode creation

View File

@ -75,6 +75,13 @@ $modulepart='tax';
include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php'; include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
if ($action == 'setlib' && $user->rights->tax->charges->creer)
{
$object->fetch($id);
$result = $object->setValueFrom('libelle', GETPOST('lib'), '', '', 'text', '', $user, 'TAX_MODIFY');
if ($result < 0)
setEventMessages($object->error, $object->errors, 'errors');
}
/* /*
* View * View
@ -82,8 +89,9 @@ include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
$form = new Form($db); $form = new Form($db);
$title = $langs->trans("SocialContribution") . ' - ' . $langs->trans("Documents");
$help_url='EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:M&oacute;dulo Impuestos y cargas sociales (IVA, impuestos)'; $help_url='EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:M&oacute;dulo Impuestos y cargas sociales (IVA, impuestos)';
llxHeader("",$langs->trans("SocialContribution"),$help_url); llxHeader("",$title,$help_url);
if ($object->id) if ($object->id)
{ {
@ -93,6 +101,20 @@ if ($object->id)
dol_fiche_head($head, 'documents', $langs->trans("SocialContribution"), 0, 'bill'); dol_fiche_head($head, 'documents', $langs->trans("SocialContribution"), 0, 'bill');
$morehtmlref='<div class="refidno">';
// Label of social contribution
$morehtmlref.=$form->editfieldkey("Label", 'lib', $object->lib, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("Label", 'lib', $object->lib, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1);
$morehtmlref.='</div>';
$linkback = '<a href="' . DOL_URL_ROOT . '/compta/sociales/index.php">' . $langs->trans("BackToList") . '</a>';
$object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
// Construit liste des fichiers // Construit liste des fichiers
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
@ -105,62 +127,15 @@ if ($object->id)
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Ref print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td>';
print $form->showrefnav($object,'id');
print "</td></tr>";
// Label
if ($action == 'edit')
{
print '<tr><td>'.$langs->trans("Label").'</td><td>';
print '<input type="text" name="label" size="40" value="'.$object->lib.'">';
print '</td></tr>';
}
else
{
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$object->lib.'</td></tr>';
}
// Type
print "<tr><td>".$langs->trans("Type")."</td><td>".$object->type_libelle."</td></tr>";
// Period end date
print "<tr><td>".$langs->trans("PeriodEndDate")."</td>";
print "<td>";
if ($action == 'edit')
{
print $form->select_date($object->periode, 'period', 0, 0, 0, 'charge', 1);
}
else
{
print dol_print_date($object->periode,"day");
}
print "</td>";
print "</tr>";
// Due date
if ($action == 'edit')
{
print '<tr><td>'.$langs->trans("DateDue")."</td><td>";
print $form->select_date($object->date_ech, 'ech', 0, 0, 0, 'charge', 1);
print "</td></tr>";
}
else {
print "<tr><td>".$langs->trans("DateDue")."</td><td>".dol_print_date($object->date_ech,'day')."</td></tr>";
}
// Amount
print '<tr><td>'.$langs->trans("AmountTTC").'</td><td>'.price($object->amount,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
// Status
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4,$alreadypayed).'</td></tr>';
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>'; print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
print '</table>'; print '</table>';
print '</div>'; print '</div>';
print '<div class="clearboth"></div>';
dol_fiche_end();
$modulepart = 'tax'; $modulepart = 'tax';
$permission = $user->rights->tax->charges->creer; $permission = $user->rights->tax->charges->creer;

View File

@ -37,25 +37,52 @@ $socid = GETPOST('socid','int');
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'tax', $id, 'chargesociales','charges'); $result = restrictedArea($user, 'tax', $id, 'chargesociales','charges');
/*
* Actions
*/
if ($action == 'setlib' && $user->rights->tax->charges->creer)
{
$object->fetch($id);
$result = $object->setValueFrom('libelle', GETPOST('lib'), '', '', 'text', '', $user, 'TAX_MODIFY');
if ($result < 0)
setEventMessages($object->error, $object->errors, 'errors');
}
/* /*
* View * View
*/ */
$title = $langs->trans("SocialContribution") . ' - ' . $langs->trans("Info");
$help_url = 'EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:M&oacute;dulo Impuestos y cargas sociales (IVA, impuestos)';
llxHeader("",$title,$help_url);
$help_url='EN:Module_Taxes_and_social_contributions|FR:Module Taxes et dividendes|ES:M&oacute;dulo Impuestos y cargas sociales (IVA, impuestos)'; $object = new ChargeSociales($db);
llxHeader("",$langs->trans("SocialContribution"),$help_url); $object->fetch($id);
$object->info($id);
$chargesociales = new ChargeSociales($db); $head = tax_prepare_head($object);
$chargesociales->fetch($id);
$chargesociales->info($id);
$head = tax_prepare_head($chargesociales);
dol_fiche_head($head, 'info', $langs->trans("SocialContribution"), 0, 'bill'); dol_fiche_head($head, 'info', $langs->trans("SocialContribution"), 0, 'bill');
$morehtmlref='<div class="refidno">';
// Label of social contribution
$morehtmlref.=$form->editfieldkey("Label", 'lib', $object->lib, $object, $user->rights->tax->charges->creer, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("Label", 'lib', $object->lib, $object, $user->rights->tax->charges->creer, 'string', '', null, null, '', 1);
$morehtmlref.='</div>';
$linkback = '<a href="' . DOL_URL_ROOT . '/compta/sociales/index.php">' . $langs->trans("BackToList") . '</a>';
$object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<br>';
print '<table width="100%"><tr><td>'; print '<table width="100%"><tr><td>';
dol_print_object_info($chargesociales); dol_print_object_info($object);
print '</td></tr></table>'; print '</td></tr></table>';
print '</div>'; print '</div>';

View File

@ -1071,6 +1071,12 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5, $object->totalpaye); if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5, $object->totalpaye);
$morehtmlstatus.=$tmptxt; $morehtmlstatus.=$tmptxt;
} }
elseif ($object->element == 'loan')
{
$tmptxt=$object->getLibStatut(6, $object->totalpaye);
if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5, $object->totalpaye);
$morehtmlstatus.=$tmptxt;
}
elseif ($object->element == 'contrat') elseif ($object->element == 'contrat')
{ {
if ($object->statut==0) $morehtmlstatus.=$object->getLibStatut(2); if ($object->statut==0) $morehtmlstatus.=$object->getLibStatut(2);
@ -1082,7 +1088,8 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
$morehtmlstatus.=$tmptxt; $morehtmlstatus.=$tmptxt;
} }
if (! empty($object->name_alias)) $morehtmlref.='<div class="refidno">'.$object->name_alias.'</div>'; // For thirdparty if (! empty($object->name_alias)) $morehtmlref.='<div class="refidno">'.$object->name_alias.'</div>'; // For thirdparty
if (! empty($object->label)) $morehtmlref.='<div class="refidno">'.$object->label.'</div>'; // For product if ($object->element == 'product' && ! empty($object->label)) $morehtmlref.='<div class="refidno">'.$object->label.'</div>';
if ($object->element != 'product') if ($object->element != 'product')
{ {
$morehtmlref.='<div class="refidno">'; $morehtmlref.='<div class="refidno">';

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
<?php <?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 * 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 * 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/donation.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
if (! empty($conf->projet->enabled))
{
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
}
$langs->load("donations"); $langs->load("donations");
// Security check
$id = GETPOST('id','int'); $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; if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'don', $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 * 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); $langs->load("projects");
$object->fetch($id); $morehtmlref.=$langs->trans('Project') . ' ';
$object->info($id); if ($user->rights->don->creer)
{
$head = donation_prepare_head($object); if ($action != 'classify')
$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
dol_fiche_head($head, 'info', $langs->trans("Donation"), 0, 'generic'); if ($action == 'classify') {
//$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
print '<table width="100%"><tr><td>'; $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
dol_print_object_info($object); $morehtmlref.='<input type="hidden" name="action" value="classin">';
print '</td></tr></table>'; $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);
print '</div>'; $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(); llxFooter();
$db->close(); $db->close();

View File

@ -2,7 +2,8 @@
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * 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 * 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 * it under the terms of the GNU General Public License as published by
@ -19,15 +20,20 @@
*/ */
/** /**
* \file htdocs/compta/facture/note.php * \file htdocs/don/note.php
* \ingroup facture * \ingroup donations
* \brief Fiche de notes sur une facture * \brief Page to show a donation notes
*/ */
require '../main.inc.php'; require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php'; require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/donation.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
if (! empty($conf->projet->enabled))
{
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("companies");
$langs->load("bills"); $langs->load("bills");
@ -36,6 +42,7 @@ $langs->load("donations");
$id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility $id=(GETPOST('id','int')?GETPOST('id','int'):GETPOST('facid','int')); // For backward compatibility
$ref=GETPOST('ref','alpha'); $ref=GETPOST('ref','alpha');
$action=GETPOST('action','alpha'); $action=GETPOST('action','alpha');
$projectid = (GETPOST('projectid') ? GETPOST('projectid', 'int') : 0);
// Security check // Security check
$socid=0; $socid=0;
@ -51,10 +58,13 @@ $permissionnote=$user->rights->don->creer; // Used by the include of actions_set
/* /*
* Actions * 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 * View
@ -65,35 +75,65 @@ $helpurl = "";
llxHeader('', $title, $helpurl); llxHeader('', $title, $helpurl);
$form = new Form($db); $form = new Form($db);
if (! empty($conf->projet->enabled)) { $formproject = new FormProjets($db); }
if ($id > 0 || ! empty($ref)) if ($id > 0 || ! empty($ref))
{ {
$object = new Don($db); $object = new Don($db);
$object->fetch($id,$ref); $object->fetch($id,$ref);
$head = donation_prepare_head($object); $head = donation_prepare_head($object);
dol_fiche_head($head, 'note', $langs->trans("Donation"), 0, 'generic'); 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%">';
// Ref $linkback = '<a href="'.DOL_URL_ROOT.'/don/list.php'.(! empty($socid)?'?socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>';
print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref', '');
print '</td></tr>';
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'; include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
dol_fiche_end(); dol_fiche_end();
} }
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2014-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> /* Copyright (C) 2014-2016 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2015 Frederic France <frederic.france@free.fr> * Copyright (C) 2015 Frederic France <frederic.france@free.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -86,8 +86,9 @@ if ($action == 'add' && $user->rights->loan->write)
{ {
if (! $cancel) if (! $cancel)
{ {
$datestart=@dol_mktime(12,0,0, $_POST["startmonth"], $_POST["startday"], $_POST["startyear"]); $datestart = dol_mktime(12, 0, 0, GETPOST('startmonth','int'), GETPOST('startday','int'), GETPOST('startyear','int'));
$dateend=@dol_mktime(12,0,0, $_POST["endmonth"], $_POST["endday"], $_POST["endyear"]); $dateend = dol_mktime(12, 0, 0, GETPOST('endmonth','int'), GETPOST('endday','int'), GETPOST('endyear','int'));
$capital = price2num(GETPOST('capital'));
if (! $datestart) if (! $datestart)
{ {
@ -99,20 +100,20 @@ if ($action == 'add' && $user->rights->loan->write)
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateEnd")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("DateEnd")), null, 'errors');
$action = 'create'; $action = 'create';
} }
elseif (! $_POST["capital"]) elseif (! $capital)
{ {
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("LoanCapital")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("LoanCapital")), null, 'errors');
$action = 'create'; $action = 'create';
} }
else else
{ {
$object->label = $_POST["label"]; $object->label = GETPOST('label');
$object->fk_bank = $_POST["accountid"]; $object->fk_bank = GETPOST('accountid');
$object->capital = $_POST["capital"]; $object->capital = $capital;
$object->datestart = $datestart; $object->datestart = $datestart;
$object->dateend = $dateend; $object->dateend = $dateend;
$object->nbterm = $_POST["nbterm"]; $object->nbterm = GETPOST('nbterm');
$object->rate = $_POST["rate"]; $object->rate = GETPOST('rate');
$object->note_private = GETPOST('note_private'); $object->note_private = GETPOST('note_private');
$object->note_public = GETPOST('note_public'); $object->note_public = GETPOST('note_public');
@ -147,9 +148,9 @@ else if ($action == 'update' && $user->rights->loan->write)
if ($object->fetch($id)) if ($object->fetch($id))
{ {
$object->label = GETPOST("label");
$object->datestart = dol_mktime(12, 0, 0, GETPOST('startmonth','int'), GETPOST('startday','int'), GETPOST('startyear','int')); $object->datestart = dol_mktime(12, 0, 0, GETPOST('startmonth','int'), GETPOST('startday','int'), GETPOST('startyear','int'));
$object->dateend = dol_mktime(12, 0, 0, GETPOST('endmonth','int'), GETPOST('endday','int'), GETPOST('endyear','int')); $object->dateend = dol_mktime(12, 0, 0, GETPOST('endmonth','int'), GETPOST('endday','int'), GETPOST('endyear','int'));
$object->capital = price2num(GETPOST("capital"));
$object->nbterm = GETPOST("nbterm"); $object->nbterm = GETPOST("nbterm");
$object->rate = GETPOST("rate"); $object->rate = GETPOST("rate");
} }
@ -173,6 +174,14 @@ else if ($action == 'update' && $user->rights->loan->write)
} }
} }
if ($action == 'setlabel' && $user->rights->loan->write)
{
$object->fetch($id);
$result = $object->setValueFrom('label', GETPOST('label'), '', '', 'text', '', $user, 'LOAN_MODIFY');
if ($result < 0)
setEventMessages($object->error, $object->errors, 'errors');
}
/* /*
* View * View
*/ */
@ -180,8 +189,9 @@ else if ($action == 'update' && $user->rights->loan->write)
$form = new Form($db); $form = new Form($db);
if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db); if (! empty($conf->accounting->enabled)) $formaccountancy = New FormVentilation($db);
$help_url='EN:Module_Loan|FR:Module_Emprunt'; $title = $langs->trans("Loan") . ' - ' . $langs->trans("Card");
llxHeader("",$langs->trans("Loan"),$help_url); $help_url = 'EN:Module_Loan|FR:Module_Emprunt';
llxHeader("",$title,$help_url);
// Create mode // Create mode
@ -203,7 +213,7 @@ if ($action == 'create')
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
// Label // Label
print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("Label").'</td><td colspan="3"><input name="label" size="40" maxlength="255" value="'.dol_escape_htmltag(GETPOST('label')).'"></td></tr>'; print '<tr><td class="fieldrequired titlefieldcreate">'.$langs->trans("Label").'</td><td><input name="label" size="40" maxlength="255" value="'.dol_escape_htmltag(GETPOST('label')).'"></td></tr>';
// Bank account // Bank account
if (! empty($conf->banque->enabled)) if (! empty($conf->banque->enabled))
@ -243,7 +253,7 @@ if ($action == 'create')
// Note Private // Note Private
print '<tr>'; print '<tr>';
print '<td class="border" valign="top">'.$langs->trans('NotePrivate').'</td>'; print '<td class="border" valign="top">'.$langs->trans('NotePrivate').'</td>';
print '<td valign="top" colspan="2">'; print '<td valign="top">';
$doleditor = new DolEditor('note_private', GETPOST('note_private', 'alpha'), '', 160, 'dolibarr_notes', 'In', false, true, true, ROWS_6, '90%'); $doleditor = new DolEditor('note_private', GETPOST('note_private', 'alpha'), '', 160, 'dolibarr_notes', 'In', false, true, true, ROWS_6, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
@ -253,16 +263,11 @@ if ($action == 'create')
// Note Public // Note Public
print '<tr>'; print '<tr>';
print '<td class="border" valign="top">'.$langs->trans('NotePublic').'</td>'; print '<td class="border" valign="top">'.$langs->trans('NotePublic').'</td>';
print '<td valign="top" colspan="2">'; print '<td valign="top">';
$doleditor = new DolEditor('note_public', GETPOST('note_public', 'alpha'), '', 160, 'dolibarr_notes', 'In', false, true, true, ROWS_6, '90%'); $doleditor = new DolEditor('note_public', GETPOST('note_public', 'alpha'), '', 160, 'dolibarr_notes', 'In', false, true, true, ROWS_6, '90%');
print $doleditor->Create(1); print $doleditor->Create(1);
print '</td></tr>'; print '</td></tr>';
print '</table>';
print '<br>';
print '<table class="border" width="100%">';
// Accountancy // Accountancy
if (! empty($conf->accounting->enabled)) if (! empty($conf->accounting->enabled))
{ {
@ -283,7 +288,7 @@ if ($action == 'create')
print '<td>'; print '<td>';
print $formaccountancy->select_account($object->accountancy_account_interest, 'accountancy_account_interest', 1, '', 0, 1); print $formaccountancy->select_account($object->accountancy_account_interest, 'accountancy_account_interest', 1, '', 0, 1);
print '</td></tr>'; print '</td></tr>';
} }
else // For external software else // For external software
{ {
// Accountancy_account_capital // Accountancy_account_capital
@ -300,15 +305,16 @@ if ($action == 'create')
print '<tr><td class="fieldrequired">'.$langs->trans("LoanAccountancyInterestCode").'</td>'; print '<tr><td class="fieldrequired">'.$langs->trans("LoanAccountancyInterestCode").'</td>';
print '<td><input name="accountancy_account_interest" size="16" value="'.$object->accountancy_account_interest.'">'; print '<td><input name="accountancy_account_interest" size="16" value="'.$object->accountancy_account_interest.'">';
print '</td></tr>'; print '</td></tr>';
print '</table>';
} }
print '</table>'; print '</table>';
dol_fiche_end(); dol_fiche_end();
print '<div align="center"><input class="button" type="submit" value="'.$langs->trans("Save").'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; print '<div class="center">';
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'"></div>'; print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
print '</div>';
print '</form>'; print '</form>';
} }
@ -316,12 +322,15 @@ if ($action == 'create')
// View // View
if ($id > 0) if ($id > 0)
{ {
$object = new Loan($db);
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result > 0) if ($result > 0)
{ {
$head=loan_prepare_head($object); $head=loan_prepare_head($object);
$totalpaid = $object->getSumPayment();
// Confirm for loan // Confirm for loan
if ($action == 'paid') if ($action == 'paid')
{ {
@ -345,27 +354,54 @@ if ($id > 0)
dol_fiche_head($head, 'card', $langs->trans("Loan"), 0, 'bill'); dol_fiche_head($head, 'card', $langs->trans("Loan"), 0, 'bill');
$morehtmlref='<div class="refidno">';
// Ref loan
$morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', null, null, '', 1);
$morehtmlref.='</div>';
$linkback = '<a href="' . DOL_URL_ROOT . '/loan/index.php">' . $langs->trans("BackToList") . '</a>';
$object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright);
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
/*
// Ref // Ref
print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td colspan="3">'; print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>';
print $form->showrefnav($object,'id'); print $form->showrefnav($object,'id');
print "</td></tr>"; print "</td></tr>";
// Label // Label
if ($action == 'edit') if ($action == 'edit')
{ {
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'; print '<tr><td>'.$langs->trans("Label").'</td><td>';
print '<input type="text" name="label" size="40" value="'.$object->label.'">'; print '<input type="text" name="label" size="40" value="'.$object->label.'">';
print '</td></tr>'; print '</td></tr>';
} }
else else
{ {
print '<tr><td>'.$langs->trans("Label").'</td><td colspan="2">'.$object->label.'</td></tr>'; print '<tr><td>'.$langs->trans("Label").'</td><td>'.$object->label.'</td></tr>';
} }
*/
// Capital // Capital
print '<tr><td>'.$langs->trans("LoanCapital").'</td><td>'.price($object->capital,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>'; if ($action == 'edit')
{
print '<tr><td class="titlefield">'.$langs->trans("LoanCapital").'</td><td>';
print '<input name="capital" size="10" value="' . $object->capital . '"></td></tr>';
print '</td></tr>';
}
else
{
print '<tr><td class="titlefield">'.$langs->trans("LoanCapital").'</td><td>'.price($object->capital,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
}
// Date start // Date start
print "<tr><td>".$langs->trans("DateStart")."</td>"; print "<tr><td>".$langs->trans("DateStart")."</td>";
@ -433,25 +469,13 @@ if ($id > 0)
print '</td></tr>'; print '</td></tr>';
// Status // Status
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4, $totalpaye).'</td></tr>'; // print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4, $totalpaye).'</td></tr>';
print '</table>'; print '</table>';
dol_fiche_end(); print '</div>';
print '<div class="fichehalfright">';
print '<div class="ficheaddleft">';
if ($action == 'edit')
{
print '<div align="center">';
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
print ' &nbsp; ';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>';
print '</form><br><br>';
}
print '<table class="border" width="100%">';
print '<tr><td>';
/* /*
* Payments * Payments
@ -477,14 +501,14 @@ if ($id > 0)
$total_insurance = 0; $total_insurance = 0;
$total_interest = 0; $total_interest = 0;
$total_capital = 0; $total_capital = 0;
echo '<table class="nobordernopadding" width="100%">'; print '<table class="noborder paymenttable">';
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("RefPayment").'</td>'; print '<td>'.$langs->trans("RefPayment").'</td>';
print '<td>'.$langs->trans("Date").'</td>'; print '<td>'.$langs->trans("Date").'</td>';
print '<td>'.$langs->trans("Type").'</td>'; print '<td>'.$langs->trans("Type").'</td>';
print '<td align="center">'.$langs->trans("Insurance").'</td>'; print '<td align="right">'.$langs->trans("Insurance").'</td>';
print '<td align="center">'.$langs->trans("Interest").'</td>'; print '<td align="right">'.$langs->trans("Interest").'</td>';
print '<td align="center">'.$langs->trans("LoanCapital").'</td>'; print '<td align="right">'.$langs->trans("LoanCapital").'</td>';
print '</tr>'; print '</tr>';
$var=True; $var=True;
@ -508,13 +532,13 @@ if ($id > 0)
if ($object->paid == 0) if ($object->paid == 0)
{ {
print '<tr><td colspan="5" align="right">'.$langs->trans("AlreadyPaid").' :</td><td align="right"><b>'.price($totalpaid, 0, $langs, 0, 0, -1, $conf->currency).'</b></td></tr>'; print '<tr><td colspan="5" align="right">'.$langs->trans("AlreadyPaid").' :</td><td align="right">'.price($totalpaid, 0, $langs, 0, 0, -1, $conf->currency).'</td></tr>';
print '<tr><td colspan="5" align="right">'.$langs->trans("AmountExpected").' :</td><td align="right" bgcolor="#d0d0d0">'.price($object->capital, 0, $langs, 0, 0, -1, $conf->currency).'</td></tr>'; print '<tr><td colspan="5" align="right">'.$langs->trans("AmountExpected").' :</td><td align="right">'.price($object->capital,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
$staytopay = $object->capital - $totalpaid; $staytopay = $object->capital - $totalpaid;
print '<tr><td colspan="5" align="right">'.$langs->trans("RemainderToPay").' :</td>'; print '<tr><td colspan="5" align="right">'.$langs->trans("RemainderToPay").' :</td>';
print '<td align="right" bgcolor="#f0f0f0"><b>'.price($staytopay, 0, $langs, 0, 0, -1, $conf->currency).'</b></td></tr>'; print '<td align="right"><b>'.price($staytopay, 0, $langs, 0, 0, -1, $conf->currency).'</b></td></tr>';
} }
print "</table>"; print "</table>";
$db->free($resql); $db->free($resql);
@ -523,8 +547,25 @@ if ($id > 0)
{ {
dol_print_error($db); dol_print_error($db);
} }
print "</td></tr>";
print "</table>"; print '</div>';
print '</div>';
print '</div>';
print '<div class="clearboth"></div>';
dol_fiche_end();
if ($action == 'edit')
{
print '<div class="center">';
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>';
}
if ($action == 'edit') print "</form>\n";
/* /*
* Buttons actions * Buttons actions
@ -562,7 +603,7 @@ if ($id > 0)
} }
else else
{ {
// Loan not find // Loan not found
dol_print_error('',$object->error); dol_print_error('',$object->error);
} }
} }

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2014 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> /* Copyright (C) 2014-2016 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2015 Frederic France <frederic.france@free.fr> * Copyright (C) 2015 Frederic France <frederic.france@free.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -32,6 +32,7 @@ class Loan extends CommonObject
public $element='loan'; public $element='loan';
public $table='loan'; public $table='loan';
public $table_element='loan'; public $table_element='loan';
public $picto = 'bill';
public $rowid; public $rowid;
public $datestart; public $datestart;
@ -278,6 +279,7 @@ class Loan extends CommonObject
$sql = "UPDATE ".MAIN_DB_PREFIX."loan"; $sql = "UPDATE ".MAIN_DB_PREFIX."loan";
$sql.= " SET label='".$this->db->escape($this->label)."',"; $sql.= " SET label='".$this->db->escape($this->label)."',";
$sql.= " capital='".price2num($this->db->escape($this->capital))."',";
$sql.= " datestart='".$this->db->idate($this->datestart)."',"; $sql.= " datestart='".$this->db->idate($this->datestart)."',";
$sql.= " dateend='".$this->db->idate($this->dateend)."',"; $sql.= " dateend='".$this->db->idate($this->dateend)."',";
$sql.= " fk_user_modif = ".$user->id; $sql.= " fk_user_modif = ".$user->id;
@ -378,6 +380,12 @@ class Loan extends CommonObject
if ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3'); if ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3');
if ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6'); if ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6');
} }
if ($mode == 6)
{
if ($statut == 0 && $alreadypaid <= 0) return $langs->trans("Unpaid").' '.img_picto($langs->trans("Unpaid"), 'statut1');
if ($statut == 0 && $alreadypaid > 0) return $langs->trans("BillStatusStarted").' '.img_picto($langs->trans("BillStatusStarted"), 'statut3');
if ($statut == 1) return $langs->trans("Paid").' '.img_picto($langs->trans("Paid"), 'statut6');
}
return "Error, mode/status not found"; return "Error, mode/status not found";
} }

View File

@ -1,5 +1,5 @@
<?php <?php
/* Copyright (C) 2014 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> /* Copyright (C) 2014-2016 Alexandre Spangaro <aspangaro@zendsi.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -75,17 +75,33 @@ include_once DOL_DOCUMENT_ROOT . '/core/actions_linkedfiles.inc.php';
$form = new Form($db); $form = new Form($db);
$help_url='EN:Module_Loan|FR:Module_Emprunt'; $title = $langs->trans("Loan") . ' - ' . $langs->trans("Documents");
llxHeader("",$langs->trans("Loan"),$help_url); $help_url = 'EN:Module_Loan|FR:Module_Emprunt';
llxHeader("",$title,$help_url);
if ($object->id) if ($object->id)
{ {
$alreadypayed=$object->getSumPayment(); $totalpaid=$object->getSumPayment();
$head = loan_prepare_head($object); $head = loan_prepare_head($object);
dol_fiche_head($head, 'documents', $langs->trans("Loan"), 0, 'bill'); dol_fiche_head($head, 'documents', $langs->trans("Loan"), 0, 'bill');
$morehtmlref='<div class="refidno">';
// Ref loan
$morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', null, null, '', 1);
$morehtmlref.='</div>';
$linkback = '<a href="' . DOL_URL_ROOT . '/loan/index.php">' . $langs->trans("BackToList") . '</a>';
$object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright);
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
// Construit liste des fichiers // Construit liste des fichiers
$filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); $filearray=dol_dir_list($upload_dir,"files",0,'','(\.meta|_preview\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
@ -97,63 +113,13 @@ if ($object->id)
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';
print '<tr><td class="titlefield">'.$langs->trans("NbOfAttachedFiles").'</td><td>'.count($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td>'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
print "</table>\n";
// Ref print "</div>\n";
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td>';
print $form->showrefnav($object,'id');
print "</td></tr>";
// Label dol_fiche_end();
if ($action == 'edit')
{
print '<tr><td>'.$langs->trans("Label").'</td><td>';
print '<input type="text" name="label" size="40" value="'.$object->label.'">';
print '</td></tr>';
}
else
{
print '<tr><td>'.$langs->trans("Label").'</td><td>'.$object->label.'</td></tr>';
}
// Amount
print '<tr><td>'.$langs->trans("LoanCapital").'</td><td>'.price($object->capital,0,$outputlangs,1,-1,-1,$conf->currency).'</td></tr>';
// Date start
print "<tr><td>".$langs->trans("DateStart")."</td>";
print "<td>";
if ($action == 'edit')
{
print $form->select_date($object->datestart, 'start', 0, 0, 0, 'loan', 1, 0, 1);
}
else
{
print dol_print_date($object->datestart,"day");
}
print "</td>";
print "</tr>";
// Date end
print "<tr><td>".$langs->trans("DateEnd")."</td>";
print "<td>";
if ($action == 'edit')
{
print $form->select_date($object->dateend, 'end', 0, 0, 0, 'loan', 1, 0, 1);
}
else
{
print dol_print_date($object->dateend,"day");
}
print "</td>";
print "</tr>";
// Status
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4,$alreadypayed).'</td></tr>';
print '<tr><td>'.$langs->trans("NbOfAttachedFiles").'</td><td colspan="3">'.count($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans("TotalSizeOfAttachedFiles").'</td><td colspan="3">'.$totalsize.' '.$langs->trans("bytes").'</td></tr>';
print '</table>';
print '</div>';
$modulepart = 'loan'; $modulepart = 'loan';
$permission = $user->rights->loan->write; $permission = $user->rights->loan->write;

View File

@ -43,29 +43,38 @@ $result = restrictedArea($user, 'loan', $id, '','');
* View * View
*/ */
$help_url='EN:Module_Loan|FR:Module_Emprunt'; $title = $langs->trans("Loan") . ' - ' . $langs->trans("Info");
llxHeader("",$langs->trans("Loan"),$help_url); $help_url = 'EN:Module_Loan|FR:Module_Emprunt';
llxHeader("",$title,$help_url);
if ($id > 0) { $object = new Loan($db);
$loan = new Loan($db); $object->fetch($id);
$loan->fetch($id); $object->info($id);
$loan->info($id);
$head = loan_prepare_head($loan); $head = loan_prepare_head($object);
dol_fiche_head($head, 'info', $langs->trans("Loan"), 0, 'bill'); dol_fiche_head($head, 'info', $langs->trans("Loan"), 0, 'bill');
print '<table width="100%"><tr><td>'; $morehtmlref='<div class="refidno">';
dol_print_object_info($loan); // Ref loan
print '</td></tr></table>'; $morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', null, null, '', 1);
$morehtmlref.='</div>';
print '</div>'; $linkback = '<a href="' . DOL_URL_ROOT . '/loan/index.php">' . $langs->trans("BackToList") . '</a>';
}
else $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status
{
// $id ? dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright);
}
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<table width="100%"><tr><td>';
dol_print_object_info($object);
print '</td></tr></table>';
print '</div>';
llxFooter(); llxFooter();
$db->close(); $db->close();

View File

@ -4,6 +4,7 @@
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com> * 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) 2015 Frederic France <frederic.france@free.fr> * Copyright (C) 2015 Frederic France <frederic.france@free.fr>
* Copyright (C) 2016 Alexandre Spangaro <aspangaro@zendsi.com>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -21,8 +22,8 @@
/** /**
* \file htdocs/loan/note.php * \file htdocs/loan/note.php
* \brief Tab for notes on loan
* \ingroup loan * \ingroup loan
* \brief Tab for notes on loan
*/ */
require '../main.inc.php'; require '../main.inc.php';
@ -56,43 +57,40 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include,
$form = new Form($db); $form = new Form($db);
llxHeader('',$langs->trans("Loan"),''); $title = $langs->trans("Loan") . ' - ' . $langs->trans("Notes");
$help_url = 'EN:Module_Loan|FR:Module_Emprunt';
llxHeader("",$title,$help_url);
if ($id > 0) if ($id > 0)
{ {
/* /*
* Affichage onglets * Affichage onglets
*/ */
$totalpaid=$object->getSumPayment();
$head = loan_prepare_head($object); $head = loan_prepare_head($object);
dol_fiche_head($head, 'note', $langs->trans("Loan"), 0, 'bill'); dol_fiche_head($head, 'note', $langs->trans("Loan"), 0, 'bill');
$morehtmlref='<div class="refidno">';
// Ref loan
$morehtmlref.=$form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', 0, 1);
$morehtmlref.=$form->editfieldval("Label", 'label', $object->label, $object, $user->rights->loan->write, 'string', '', null, null, '', 1);
$morehtmlref.='</div>';
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">'; $linkback = '<a href="' . DOL_URL_ROOT . '/loan/index.php">' . $langs->trans("BackToList") . '</a>';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<table class="border" width="100%">'; $object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status
// Ref dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright);
print '<tr><td class="titlefield">'.$langs->trans('Ref').'</td>';
print '<td colspan="3">';
print $form->showrefnav($object,'id','',1,'rowid','ref');
print '</td></tr>';
// Name
print '<tr><td>'.$langs->trans("Name").'</td>';
print '<td colspan="3">'.$object->label.'</td></tr>';
print "</table>"; print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
print '<br>';
//$colwidth='25';
$cssclass='titlefield'; $cssclass='titlefield';
$permission = $user->rights->loan->write; // Used by the include of notes.tpl.php $permission = $user->rights->loan->write; // Used by the include of notes.tpl.php
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php'; include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
dol_fiche_end(); dol_fiche_end();
} }