dolibarr/htdocs/loan/note.php

147 lines
5.3 KiB
PHP
Raw Normal View History

2016-06-06 20:36:04 +02:00
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
2018-10-27 14:43:12 +02:00
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
2016-06-06 20:36:04 +02:00
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2015 Frederic France <frederic.france@free.fr>
2023-10-09 06:40:30 +02:00
* Copyright (C) 2016-2023 Alexandre Spangaro <aspangaro@easya.solutions>
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
2016-06-06 20:36:04 +02:00
*
* 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
2019-09-23 21:55:30 +02:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2016-06-06 20:36:04 +02:00
*/
/**
* \file htdocs/loan/note.php
* \ingroup loan
2016-12-20 07:29:49 +01:00
* \brief Tab for notes on loan
2016-06-06 20:36:04 +02:00
*/
2022-09-07 20:08:59 +02:00
// Load Dolibarr environment
2016-06-06 20:36:04 +02:00
require '../main.inc.php';
2018-05-27 00:06:49 +02:00
require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
2016-06-06 20:36:04 +02:00
require_once DOL_DOCUMENT_ROOT.'/core/lib/loan.lib.php';
2023-06-09 13:47:07 +02:00
if (isModEnabled('project')) {
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
2017-12-26 12:13:35 +01:00
}
2016-06-06 20:36:04 +02:00
$action = GETPOST('action', 'aZ09');
2016-06-06 20:36:04 +02:00
2018-05-26 21:11:25 +02:00
// Load translation files required by the page
2018-05-19 08:06:52 +02:00
$langs->loadLangs(array("loan"));
2016-06-06 20:36:04 +02:00
// Security check
$id = GETPOST('id', 'int');
2021-07-09 18:36:21 +02:00
2021-07-09 18:41:41 +02:00
$hookmanager->initHooks(array('loannote'));
2016-06-06 20:36:04 +02:00
$result = restrictedArea($user, 'loan', $id, '&loan');
$object = new Loan($db);
if ($id > 0) {
$object->fetch($id);
}
2016-06-06 20:36:04 +02:00
$permissionnote = $user->rights->loan->write; // Used by the include of actions_setnotes.inc.php
2016-06-06 20:36:04 +02:00
/*
* Actions
*/
2021-07-09 18:36:21 +02:00
$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
2021-07-11 09:49:24 +02:00
if ($reshook < 0) {
2021-07-09 18:36:21 +02:00
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2021-07-11 09:49:24 +02:00
}
2021-07-11 09:49:39 +02:00
if (empty($reshook)) {
2021-07-09 18:36:21 +02:00
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
2021-07-11 09:49:24 +02:00
}
2016-06-06 20:36:04 +02:00
/*
* View
*/
$form = new Form($db);
$title = $langs->trans("Loan").' - '.$langs->trans("Notes");
2016-12-20 07:29:49 +01:00
$help_url = 'EN:Module_Loan|FR:Module_Emprunt';
llxHeader("", $title, $help_url);
2016-06-06 20:36:04 +02:00
if ($id > 0) {
/*
* Affichage onglets
*/
$totalpaid = $object->getSumPayment();
2016-06-06 20:36:04 +02:00
$head = loan_prepare_head($object);
2016-06-06 20:36:04 +02:00
2023-10-09 06:40:30 +02:00
print dol_get_fiche_head($head, 'note', $langs->trans("Loan"), -1, 'money-bill-alt');
2016-06-06 20:36:04 +02:00
$morehtmlref = '<div class="refidno">';
2016-12-20 07:29:49 +01:00
// Ref loan
$morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, 0, 'string', '', 0, 1);
$morehtmlref .= $form->editfieldval("Label", 'label', $object->label, $object, 0, 'string', '', null, null, '', 1);
// Project
2023-06-09 13:47:07 +02:00
if (isModEnabled('project')) {
2018-05-19 08:06:52 +02:00
$langs->loadLangs(array("projects"));
$morehtmlref .= '<br>'.$langs->trans('Project').' : ';
if ($user->rights->loan->write) {
//if ($action != 'classify')
2021-09-18 22:09:55 +02:00
// $morehtmlref .= '<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token='.newToken().'&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="'.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, '', 'maxwidth300');
}
} else {
if (!empty($object->fk_project)) {
$proj = new Project($db);
$proj->fetch($object->fk_project);
2021-10-29 09:40:38 +02:00
$morehtmlref .= ' : '.$proj->getNomUrl(1);
if ($proj->title) {
$morehtmlref .= ' - '.$proj->title;
}
} else {
$morehtmlref .= '';
}
}
}
$morehtmlref .= '</div>';
2016-06-06 20:36:04 +02:00
$linkback = '<a href="'.DOL_URL_ROOT.'/loan/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
2016-06-06 20:36:04 +02:00
$object->totalpaid = $totalpaid; // To give a chance to dol_banner_tab to use already paid amount to show correct status
2016-06-06 20:36:04 +02:00
2016-12-20 07:29:49 +01:00
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright);
2016-06-06 20:36:04 +02:00
2016-12-20 07:29:49 +01:00
print '<div class="fichecenter">';
print '<div class="underbanner clearboth"></div>';
2016-06-06 20:36:04 +02:00
$cssclass = 'titlefield';
$permission = $user->rights->loan->write; // Used by the include of notes.tpl.php
include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
2016-06-06 20:36:04 +02:00
print dol_get_fiche_end();
2016-06-06 20:36:04 +02:00
}
2018-08-13 11:25:48 +02:00
// End of page
2016-06-06 20:36:04 +02:00
llxFooter();
$db->close();