Clean code - removed old deprecated module Deplacement
This commit is contained in:
parent
98befc283c
commit
580a5adde8
21 changed files with 3 additions and 2545 deletions
|
|
@ -202,7 +202,8 @@ The following changes may create regressions for some external modules, but were
|
|||
* The substitution variable __MYCOUNTRY_ID__ has been removed (duplicate of standard __MYCOMPANY_COUNTRY_ID__).
|
||||
* Renamed hook "info_admin" into "messageOfTheDay".
|
||||
* Library jeditable was not used by the core (used by a hidden option with no security rules), so it has been removed.
|
||||
* Module Paybox has been removed.
|
||||
* Old deprecated module Paybox has been removed.
|
||||
* Old deprecated module Deplacement has been removed.
|
||||
|
||||
|
||||
***** ChangeLog for 23.0.3 compared to 23.0.2 *****
|
||||
|
|
|
|||
|
|
@ -1777,12 +1777,6 @@ if ($object->id > 0) {
|
|||
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/fichinter/card.php?socid='.$object->id.'&action=create">'.$langs->trans("AddIntervention").'</a></div>';
|
||||
}
|
||||
|
||||
// Add invoice
|
||||
if (isModEnabled('deplacement') && $object->status == 1) {
|
||||
$langs->load("trips");
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/compta/deplacement/card.php?socid='.$object->id.'&action=create">'.$langs->trans("AddTrip").'</a></div>';
|
||||
}
|
||||
|
||||
if (isModEnabled('invoice') && $object->status == 1) {
|
||||
if (!$user->hasRight('facture', 'creer')) {
|
||||
$langs->load("bills");
|
||||
|
|
|
|||
|
|
@ -1,517 +0,0 @@
|
|||
<?php
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/compta/deplacement/card.php
|
||||
* \brief Page to show a trip card
|
||||
*/
|
||||
|
||||
// Load Dolibarr environment
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/trip.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
if (isModEnabled('project')) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* @var Conf $conf
|
||||
* @var DoliDB $db
|
||||
* @var HookManager $hookmanager
|
||||
* @var Translate $langs
|
||||
* @var User $user
|
||||
*/
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->load("trips");
|
||||
|
||||
|
||||
// Security check
|
||||
$id = GETPOSTINT('id');
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
|
||||
// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
|
||||
$hookmanager->initHooks(array('tripsandexpensescard', 'globalcard'));
|
||||
|
||||
$result = restrictedArea($user, 'deplacement', $id, '');
|
||||
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$confirm = GETPOST('confirm', 'alpha');
|
||||
|
||||
$object = new Deplacement($db);
|
||||
|
||||
$permissionnote = $user->hasRight('deplacement', 'creer'); // Used by the include of actions_setnotes.inc.php
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
|
||||
|
||||
if ($action == 'validate' && $user->hasRight('deplacement', 'creer')) {
|
||||
$object->fetch($id);
|
||||
if ($object->statut == Deplacement::STATUS_DRAFT) {
|
||||
$result = $object->setStatut(Deplacement::STATUS_REFUNDED, null, '', 'DELIVERY_MODIFY');
|
||||
if ($result > 0) {
|
||||
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
|
||||
exit;
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
} elseif ($action == 'classifyrefunded' && $user->hasRight('deplacement', 'creer')) {
|
||||
$object->fetch($id);
|
||||
if ($object->statut == Deplacement::STATUS_VALIDATED) {
|
||||
$result = $object->setStatut(Deplacement::STATUS_REFUNDED, null, '', 'DELIVERY_MODIFY');
|
||||
if ($result > 0) {
|
||||
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
|
||||
exit;
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
} elseif ($action == 'confirm_delete' && $confirm == "yes" && $user->hasRight('deplacement', 'supprimer')) {
|
||||
$result = $object->delete($user);
|
||||
if ($result >= 0) {
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
} elseif ($action == 'add' && $user->hasRight('deplacement', 'creer')) {
|
||||
if (!GETPOST('cancel', 'alpha')) {
|
||||
$error = 0;
|
||||
|
||||
$object->date = dol_mktime(12, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear'));
|
||||
$object->km = (float) price2num(GETPOST('km', 'alpha'), 'MU'); // Not 'int', it may be a formatted amount
|
||||
$object->type = GETPOST('type', 'alpha');
|
||||
$object->socid = GETPOSTINT('socid');
|
||||
$object->fk_user = GETPOSTINT('fk_user');
|
||||
$object->note_private = GETPOST('note_private', 'alpha');
|
||||
$object->note_public = GETPOST('note_public', 'alpha');
|
||||
$object->statut = Deplacement::STATUS_DRAFT;
|
||||
|
||||
if (!$object->date) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
if ($object->type == '-1') {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
if (!($object->fk_user > 0)) {
|
||||
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Person")), null, 'errors');
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
$id = $object->create($user);
|
||||
|
||||
if ($id > 0) {
|
||||
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
|
||||
exit;
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action = 'create';
|
||||
}
|
||||
} else {
|
||||
$action = 'create';
|
||||
}
|
||||
} else {
|
||||
header("Location: index.php");
|
||||
exit;
|
||||
}
|
||||
} elseif ($action == 'update' && $user->hasRight('deplacement', 'creer')) {
|
||||
// Update record
|
||||
if (!GETPOST('cancel', 'alpha')) {
|
||||
$result = $object->fetch($id);
|
||||
|
||||
$object->date = dol_mktime(12, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear'));
|
||||
$object->km = (float) price2num(GETPOST('km', 'alpha'), 'MU'); // Not 'int', it may be a formatted amount
|
||||
$object->type = GETPOST('type', 'alpha');
|
||||
$object->socid = GETPOSTINT('socid');
|
||||
$object->fk_user = GETPOSTINT('fk_user');
|
||||
$object->note_private = GETPOST('note_private', 'alpha');
|
||||
$object->note_public = GETPOST('note_public', 'alpha');
|
||||
|
||||
$result = $object->update($user);
|
||||
|
||||
if ($result > 0) {
|
||||
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
|
||||
exit;
|
||||
} else {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
} else {
|
||||
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
|
||||
exit;
|
||||
}
|
||||
} elseif ($action == 'classin' && $user->hasRight('deplacement', 'creer')) {
|
||||
// Set into a project
|
||||
$object->fetch($id);
|
||||
$result = $object->setProject(GETPOSTINT('projectid'));
|
||||
if ($result < 0) {
|
||||
dol_print_error($db, $object->error);
|
||||
}
|
||||
} elseif ($action == 'setdated' && $user->hasRight('deplacement', 'creer')) {
|
||||
// Set fields
|
||||
$dated = dol_mktime(GETPOSTINT('datedhour'), GETPOSTINT('datedmin'), GETPOSTINT('datedsec'), GETPOSTINT('datedmonth'), GETPOSTINT('datedday'), GETPOSTINT('datedyear'));
|
||||
$object->fetch($id);
|
||||
$result = $object->setValueFrom('dated', $dated, '', null, 'date', '', $user, 'DEPLACEMENT_MODIFY');
|
||||
if ($result < 0) {
|
||||
dol_print_error($db, $object->error);
|
||||
}
|
||||
} elseif ($action == 'setkm' && $user->hasRight('deplacement', 'creer')) {
|
||||
$object->fetch($id);
|
||||
$result = $object->setValueFrom('km', GETPOSTINT('km'), '', null, 'text', '', $user, 'DEPLACEMENT_MODIFY');
|
||||
if ($result < 0) {
|
||||
dol_print_error($db, $object->error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader();
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
/*
|
||||
* Action create
|
||||
*/
|
||||
if ($action == 'create') {
|
||||
//WYSIWYG Editor
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
|
||||
print load_fiche_titre($langs->trans("NewTrip"));
|
||||
|
||||
$datec = dol_mktime(12, 0, 0, GETPOSTINT('remonth'), GETPOSTINT('reday'), GETPOSTINT('reyear'));
|
||||
|
||||
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
print "<tr>";
|
||||
print '<td class="fieldrequired">'.$langs->trans("Type").'</td><td>';
|
||||
$form->select_type_fees((string) GETPOSTINT('type'), 'type', 1);
|
||||
print '</td></tr>';
|
||||
|
||||
print "<tr>";
|
||||
print '<td class="fieldrequired">'.$langs->trans("Person").'</td><td>';
|
||||
print $form->select_dolusers(GETPOSTINT('fk_user'), 'fk_user', 1, null, 0, '', '', '0', 0, 0, '', 0, '', 'maxwidth300');
|
||||
print '</td></tr>';
|
||||
|
||||
print "<tr>";
|
||||
print '<td class="fieldrequired">'.$langs->trans("Date").'</td><td>';
|
||||
print $form->selectDate($datec ? $datec : -1, '', 0, 0, 0, 'add', 1, 1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Km
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("FeesKilometersOrAmout").'</td><td><input name="km" size="10" value="'.GETPOST("km").'"></td></tr>';
|
||||
|
||||
// Company
|
||||
print "<tr>";
|
||||
print '<td>'.$langs->trans("CompanyVisited").'</td><td>';
|
||||
print $form->select_company(GETPOSTINT('socid'), 'socid', '', 1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Public note
|
||||
print '<tr>';
|
||||
print '<td class="tdtop">'.$langs->trans('NotePublic').'</td>';
|
||||
print '<td>';
|
||||
|
||||
$doleditor = new DolEditor('note_public', GETPOST('note_public', 'restricthtml'), '', 200, 'dolibarr_notes', 'In', false, true, !getDolGlobalString('FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_8, '90%');
|
||||
print $doleditor->Create(1);
|
||||
|
||||
print '</td></tr>';
|
||||
|
||||
// Private note
|
||||
if (empty($user->socid)) {
|
||||
print '<tr>';
|
||||
print '<td class="tdtop">'.$langs->trans('NotePrivate').'</td>';
|
||||
print '<td>';
|
||||
|
||||
$doleditor = new DolEditor('note_private', GETPOST('note_private', 'restricthtml'), '', 200, 'dolibarr_notes', 'In', false, true, !getDolGlobalString('FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_8, '90%');
|
||||
print $doleditor->Create(1);
|
||||
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '<br><div class="center">';
|
||||
print '<input class="button button-save" type="submit" value="'.$langs->trans("Save").'">';
|
||||
print ' ';
|
||||
print '<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
} elseif ($id) {
|
||||
$result = $object->fetch($id);
|
||||
if ($result > 0) {
|
||||
$head = trip_prepare_head($object);
|
||||
|
||||
print dol_get_fiche_head($head, 'card', $langs->trans("TripCard"), 0, 'trip');
|
||||
|
||||
if ($action == 'edit' && $user->hasRight('deplacement', 'creer')) {
|
||||
//WYSIWYG Editor
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
|
||||
$soc = new Societe($db);
|
||||
if ($object->socid) {
|
||||
$soc->fetch($object->socid);
|
||||
}
|
||||
|
||||
print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="action" value="update">';
|
||||
print '<input type="hidden" name="id" value="'.$id.'">';
|
||||
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
// Ref
|
||||
print "<tr>";
|
||||
print '<td class="titlefield">'.$langs->trans("Ref").'</td><td>';
|
||||
print $object->ref;
|
||||
print '</td></tr>';
|
||||
|
||||
// Type
|
||||
print "<tr>";
|
||||
print '<td class="fieldrequired">'.$langs->trans("Type").'</td><td>';
|
||||
$form->select_type_fees(GETPOSTINT('type') ? GETPOSTINT('type') : $object->type, 'type', 0);
|
||||
print '</td></tr>';
|
||||
|
||||
// Who
|
||||
print "<tr>";
|
||||
print '<td class="fieldrequired">'.$langs->trans("Person").'</td><td>';
|
||||
print $form->select_dolusers(GETPOSTINT('fk_user') ? GETPOSTINT('fk_user') : $object->fk_user, 'fk_user', 0, null, 0, '', '', '0', 0, 0, '', 0, '', 'maxwidth300');
|
||||
print '</td></tr>';
|
||||
|
||||
// Date
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Date").'</td><td>';
|
||||
print $form->selectDate($object->date, '', 0, 0, 0, 'update', 1, 0);
|
||||
print '</td></tr>';
|
||||
|
||||
// Km
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("FeesKilometersOrAmout").'</td><td>';
|
||||
print '<input name="km" class="flat" size="10" value="'.$object->km.'">';
|
||||
print '</td></tr>';
|
||||
|
||||
// Where
|
||||
print "<tr>";
|
||||
print '<td>'.$langs->trans("CompanyVisited").'</td><td>';
|
||||
print $form->select_company($soc->id, 'socid', '', 1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Public note
|
||||
print '<tr><td class="tdtop">'.$langs->trans("NotePublic").'</td>';
|
||||
print '<td>';
|
||||
|
||||
$doleditor = new DolEditor('note_public', $object->note_public, '', 200, 'dolibarr_notes', 'In', false, true, !getDolGlobalString('FCKEDITOR_ENABLE_NOTE_PUBLIC') ? 0 : 1, ROWS_8, '90%');
|
||||
print $doleditor->Create(1);
|
||||
|
||||
print "</td></tr>";
|
||||
|
||||
// Private note
|
||||
if (empty($user->socid)) {
|
||||
print '<tr><td class="tdtop">'.$langs->trans("NotePrivate").'</td>';
|
||||
print '<td>';
|
||||
|
||||
$doleditor = new DolEditor('note_private', $object->note_private, '', 200, 'dolibarr_notes', 'In', false, true, !getDolGlobalString('FCKEDITOR_ENABLE_NOTE_PRIVATE') ? 0 : 1, ROWS_8, '90%');
|
||||
print $doleditor->Create(1);
|
||||
|
||||
print "</td></tr>";
|
||||
}
|
||||
|
||||
// Other attributes
|
||||
$parameters = array();
|
||||
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
|
||||
print $hookmanager->resPrint;
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '<br><div class="center">';
|
||||
print '<input type="submit" class="button button-save" value="'.$langs->trans("Save").'">';
|
||||
print ' ';
|
||||
print '<input type="submit" name="cancel" class="button button-cancel" value="'.$langs->trans("Cancel").'">';
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
|
||||
print '</div>';
|
||||
} else {
|
||||
/*
|
||||
* Confirm delete trip
|
||||
*/
|
||||
if ($action == 'delete') {
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".urlencode((string) ($id)), $langs->trans("DeleteTrip"), $langs->trans("ConfirmDeleteTrip"), "confirm_delete");
|
||||
}
|
||||
|
||||
$soc = new Societe($db);
|
||||
if ($object->socid) {
|
||||
$soc->fetch($object->socid);
|
||||
}
|
||||
|
||||
print '<table class="border centpercent">';
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/deplacement/list.php'.(!empty($socid) ? '?socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td>';
|
||||
print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref', '');
|
||||
print '</td></tr>';
|
||||
|
||||
$form->load_cache_types_fees();
|
||||
|
||||
// Type
|
||||
print '<tr><td>';
|
||||
print $form->editfieldkey("Type", 'type', $langs->trans($object->type), $object, $user->hasRight('deplacement', 'creer'), 'select:types_fees');
|
||||
print '</td><td>';
|
||||
print $form->editfieldval("Type", 'type', $form->cache_types_fees[$object->type], $object, $user->hasRight('deplacement', 'creer'), 'select:types_fees');
|
||||
print '</td></tr>';
|
||||
|
||||
// Who
|
||||
print '<tr><td>'.$langs->trans("Person").'</td><td>';
|
||||
$userfee = new User($db);
|
||||
$userfee->fetch($object->fk_user);
|
||||
print $userfee->getNomUrl(1);
|
||||
print '</td></tr>';
|
||||
|
||||
// Date
|
||||
print '<tr><td>';
|
||||
print $form->editfieldkey("Date", 'dated', $object->date, $object, $user->hasRight('deplacement', 'creer'), 'datepicker');
|
||||
print '</td><td>';
|
||||
print $form->editfieldval("Date", 'dated', $object->date, $object, $user->hasRight('deplacement', 'creer'), 'datepicker');
|
||||
print '</td></tr>';
|
||||
|
||||
// Km/Price
|
||||
print '<tr><td class="tdtop">';
|
||||
print $form->editfieldkey("FeesKilometersOrAmout", 'km', (string) $object->km, $object, $user->hasRight('deplacement', 'creer'), 'numeric:6');
|
||||
print '</td><td>';
|
||||
print $form->editfieldval("FeesKilometersOrAmout", 'km', $object->km, $object, $user->hasRight('deplacement', 'creer'), 'numeric:6');
|
||||
print "</td></tr>";
|
||||
|
||||
// Where
|
||||
print '<tr><td>'.$langs->trans("CompanyVisited").'</td>';
|
||||
print '<td>';
|
||||
if ($soc->id) {
|
||||
print $soc->getNomUrl(1);
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// Project
|
||||
if (isModEnabled('project')) {
|
||||
$langs->load('projects');
|
||||
print '<tr>';
|
||||
print '<td>';
|
||||
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('Project');
|
||||
print '</td>';
|
||||
if ($action != 'classify' && $user->hasRight('deplacement', 'creer')) {
|
||||
print '<td class="right"><a href="'.$_SERVER["PHP_SELF"].'?action=classify&token='.newToken().'&id='.$object->id.'">';
|
||||
print img_edit($langs->trans('SetProject'), 1);
|
||||
print '</a></td>';
|
||||
}
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="3">';
|
||||
if ($action == 'classify') {
|
||||
$form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, (string) $object->fk_project, 'projectid', 0, 0, 1);
|
||||
} else {
|
||||
$form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, (string) $object->fk_project, 'none', 0, 0);
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Statut
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td>'.$object->getLibStatut(4).'</td></tr>';
|
||||
|
||||
// Other attributes
|
||||
$parameters = array('socid' => $object->id);
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
|
||||
|
||||
print "</table><br>";
|
||||
|
||||
// Notes
|
||||
$blocname = 'notes';
|
||||
$title = $langs->trans('Notes');
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php';
|
||||
|
||||
print '</div>';
|
||||
|
||||
/*
|
||||
* Action bar
|
||||
*/
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
if ($object->statut < Deplacement::STATUS_REFUNDED) { // if not refunded
|
||||
if ($user->hasRight('deplacement', 'creer')) {
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&token='.newToken().'&id='.$id.'">'.$langs->trans('Modify').'</a>';
|
||||
} else {
|
||||
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans('Modify').'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($object->statut == Deplacement::STATUS_DRAFT) { // if draft
|
||||
if ($user->hasRight('deplacement', 'creer')) {
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=validate&id='.$id.'">'.$langs->trans('Validate').'</a>';
|
||||
} else {
|
||||
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans('Validate').'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($object->statut == Deplacement::STATUS_VALIDATED) { // if validated
|
||||
if ($user->hasRight('deplacement', 'creer')) {
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=classifyrefunded&token='.newToken().'&id='.$id.'">'.$langs->trans('ClassifyRefunded').'</a>';
|
||||
} else {
|
||||
print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotAllowed")).'">'.$langs->trans('ClassifyRefunded').'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
$permissiontodelete = $user->hasRight('deplacement', 'supprimer');
|
||||
print dolGetButtonAction($langs->trans("Delete"), '', 'delete', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete&token='.newToken(), 'delete', $permissiontodelete);
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
}
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
|
|
@ -1,481 +0,0 @@
|
|||
<?php
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2009-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2019-2025 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/compta/deplacement/class/deplacement.class.php
|
||||
* \ingroup deplacement
|
||||
* \brief File of class to manage trips
|
||||
*/
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
|
||||
|
||||
/**
|
||||
* Class to manage trips and working credit notes
|
||||
*/
|
||||
class Deplacement extends CommonObject
|
||||
{
|
||||
/**
|
||||
* @var string ID to identify managed object
|
||||
*/
|
||||
public $element = 'deplacement';
|
||||
|
||||
/**
|
||||
* @var string Name of table without prefix where object is stored
|
||||
*/
|
||||
public $table_element = 'deplacement';
|
||||
|
||||
/**
|
||||
* @var string Name of subtable line
|
||||
*/
|
||||
public $table_element_line = '';
|
||||
|
||||
/**
|
||||
* @var string Fieldname with ID of parent key if this field has a parent
|
||||
*/
|
||||
public $fk_element = '';
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $fk_soc;
|
||||
/**
|
||||
* @var int|string
|
||||
*/
|
||||
public $date;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $type;
|
||||
|
||||
/**
|
||||
* Date creation record (datec)
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $datec;
|
||||
|
||||
/**
|
||||
* Date (dated)
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $dated;
|
||||
|
||||
/**
|
||||
* @var int ID
|
||||
*/
|
||||
public $fk_user_author;
|
||||
|
||||
/**
|
||||
* @var int User ID
|
||||
*/
|
||||
public $fk_user;
|
||||
|
||||
/**
|
||||
* @var float km value formatted
|
||||
*/
|
||||
public $km;
|
||||
|
||||
/**
|
||||
* @var int Thirdparty id
|
||||
*/
|
||||
public $socid;
|
||||
|
||||
/**
|
||||
* @var int Status 0=draft, 1=validated, 2=Refunded
|
||||
*/
|
||||
public $statut;
|
||||
/**
|
||||
* @var array<string,string> (Encoded as JSON in database)
|
||||
*/
|
||||
public $extraparams = array();
|
||||
|
||||
|
||||
/**
|
||||
* Draft status
|
||||
*/
|
||||
const STATUS_DRAFT = 0;
|
||||
|
||||
/**
|
||||
* Validated status
|
||||
*/
|
||||
const STATUS_VALIDATED = 1;
|
||||
|
||||
/**
|
||||
* Refunded status
|
||||
*/
|
||||
const STATUS_REFUNDED = 2;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
public function __construct(DoliDB $db)
|
||||
{
|
||||
$this->db = $db;
|
||||
|
||||
$this->ismultientitymanaged = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create object in database
|
||||
* TODO Add ref number
|
||||
*
|
||||
* @param User $user User that creates
|
||||
* @return int Return integer <0 if KO, >0 if OK
|
||||
*/
|
||||
public function create($user)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
// Check parameters
|
||||
if (empty($this->type) || $this->type < 0) {
|
||||
$this->error = 'ErrorBadParameter';
|
||||
return -1;
|
||||
}
|
||||
if (empty($this->fk_user) || $this->fk_user < 0) {
|
||||
$this->error = 'ErrorBadParameter';
|
||||
return -1;
|
||||
}
|
||||
|
||||
$now = dol_now();
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."deplacement (";
|
||||
$sql .= "datec";
|
||||
//$sql.= ", dated";
|
||||
$sql .= ", entity";
|
||||
$sql .= ", fk_user_author";
|
||||
$sql .= ", fk_user";
|
||||
$sql .= ", type";
|
||||
$sql .= ", note_private";
|
||||
$sql .= ", note_public";
|
||||
$sql .= ", fk_projet";
|
||||
$sql .= ", fk_soc";
|
||||
$sql .= ") VALUES (";
|
||||
$sql .= " '".$this->db->idate($now)."'";
|
||||
$sql .= ", ".((int) $conf->entity);
|
||||
$sql .= ", ".((int) $user->id);
|
||||
$sql .= ", ".((int) $this->fk_user);
|
||||
$sql .= ", '".$this->db->escape($this->type)."'";
|
||||
$sql .= ", ".($this->note_private ? "'".$this->db->escape($this->note_private)."'" : "null");
|
||||
$sql .= ", ".($this->note_public ? "'".$this->db->escape($this->note_public)."'" : "null");
|
||||
$sql .= ", ".($this->fk_project > 0 ? ((int) $this->fk_project) : 0);
|
||||
$sql .= ", ".($this->fk_soc > 0 ? ((int) $this->fk_soc) : "null");
|
||||
$sql .= ")";
|
||||
|
||||
dol_syslog(get_class($this)."::create", LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."deplacement");
|
||||
|
||||
// Call trigger
|
||||
$result = $this->call_trigger('DEPLACEMENT_CREATE', $user);
|
||||
if ($result < 0) {
|
||||
$this->db->rollback();
|
||||
return -2;
|
||||
}
|
||||
// End call triggers
|
||||
|
||||
$result = $this->update($user);
|
||||
if ($result > 0) {
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
} else {
|
||||
$this->error = $this->db->error();
|
||||
$this->db->rollback();
|
||||
return $result;
|
||||
}
|
||||
} else {
|
||||
$this->error = $this->db->error()." sql=".$sql;
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update record
|
||||
*
|
||||
* @param User $user User making update
|
||||
* @return int Return integer <0 if KO, >0 if OK
|
||||
*/
|
||||
public function update($user)
|
||||
{
|
||||
// Clean parameters
|
||||
$this->km = (float) price2num($this->km);
|
||||
|
||||
// Check parameters
|
||||
if (!is_numeric($this->km)) {
|
||||
$this->km = 0;
|
||||
}
|
||||
if (empty($this->date)) {
|
||||
$this->error = 'ErrorBadParameter';
|
||||
return -1;
|
||||
}
|
||||
if (empty($this->type) || $this->type < 0) {
|
||||
$this->error = 'ErrorBadParameter';
|
||||
return -1;
|
||||
}
|
||||
if (empty($this->fk_user) || $this->fk_user < 0) {
|
||||
$this->error = 'ErrorBadParameter';
|
||||
return -1;
|
||||
}
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."deplacement ";
|
||||
$sql .= " SET km = ".((float) $this->km); // This is a distance or amount
|
||||
$sql .= " , dated = '".$this->db->idate($this->date)."'";
|
||||
$sql .= " , type = '".$this->db->escape($this->type)."'";
|
||||
$sql .= " , fk_statut = '".$this->db->escape((string) $this->statut)."'";
|
||||
$sql .= " , fk_user = ".((int) $this->fk_user);
|
||||
$sql .= " , fk_user_modif = ".((int) $user->id);
|
||||
$sql .= " , fk_soc = ".($this->socid > 0 ? $this->socid : 'null');
|
||||
$sql .= " , note_private = ".($this->note_private ? "'".$this->db->escape($this->note_private)."'" : "null");
|
||||
$sql .= " , note_public = ".($this->note_public ? "'".$this->db->escape($this->note_public)."'" : "null");
|
||||
$sql .= " , fk_projet = ".($this->fk_project > 0 ? $this->fk_project : 0);
|
||||
$sql .= " WHERE rowid = ".((int) $this->id);
|
||||
|
||||
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
} else {
|
||||
$this->error = $this->db->lasterror();
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load an object from database
|
||||
*
|
||||
* @param int $id Id of record to load
|
||||
* @param string $ref Ref of record
|
||||
* @return int Return integer <0 if KO, >0 if OK
|
||||
*/
|
||||
public function fetch($id, $ref = '')
|
||||
{
|
||||
$sql = "SELECT rowid, fk_user, type, fk_statut, km, fk_soc, dated, note_private, note_public, fk_projet as fk_project, extraparams";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."deplacement";
|
||||
$sql .= " WHERE entity IN (".getEntity('deplacement').")";
|
||||
if ($ref) {
|
||||
$sql .= " AND ref ='".$this->db->escape($ref)."'";
|
||||
} else {
|
||||
$sql .= " AND rowid = ".((int) $id);
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
$this->ref = $obj->rowid;
|
||||
$this->date = $this->db->jdate($obj->dated);
|
||||
$this->fk_user = $obj->fk_user;
|
||||
$this->socid = $obj->fk_soc;
|
||||
$this->km = $obj->km;
|
||||
$this->type = $obj->type;
|
||||
$this->statut = $obj->fk_statut;
|
||||
$this->note_private = $obj->note_private;
|
||||
$this->note_public = $obj->note_public;
|
||||
$this->fk_project = $obj->fk_project;
|
||||
|
||||
$this->extraparams = !empty($obj->extraparams) ? (array) json_decode($obj->extraparams, true) : array();
|
||||
|
||||
return 1;
|
||||
} else {
|
||||
$this->error = $this->db->error();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete record
|
||||
*
|
||||
* @param User $user USer that Delete
|
||||
* @return int Return integer <0 if KO, >0 if OK
|
||||
*/
|
||||
public function delete($user)
|
||||
{
|
||||
$this->db->begin();
|
||||
|
||||
$id = $this->id;
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."deplacement WHERE rowid = ".((int) $id);
|
||||
|
||||
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
} else {
|
||||
$this->error = $this->db->error();
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the label of the status
|
||||
*
|
||||
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
|
||||
* @return string Label of status
|
||||
*/
|
||||
public function getLibStatut($mode = 0)
|
||||
{
|
||||
return $this->LibStatut($this->statut, $mode);
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Return the label of a given status
|
||||
*
|
||||
* @param int $status Id status
|
||||
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
|
||||
* @return string Label of status
|
||||
*/
|
||||
public function LibStatut($status, $mode = 0)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $langs;
|
||||
|
||||
if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
|
||||
global $langs;
|
||||
//$langs->load("mymodule@mymodule");
|
||||
$this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
|
||||
$this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated');
|
||||
$this->labelStatus[self::STATUS_REFUNDED] = $langs->transnoentitiesnoconv('Refunded');
|
||||
$this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft');
|
||||
$this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated');
|
||||
$this->labelStatusShort[self::STATUS_REFUNDED] = $langs->transnoentitiesnoconv('Refunded');
|
||||
}
|
||||
|
||||
$status_logo = array(0 => 'status0', 1 => 'status4', 2 => 'status1', 4 => 'status6', 5 => 'status4', 6 => 'status6', 99 => 'status5');
|
||||
$statusType = $status_logo[$status];
|
||||
|
||||
return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return clickable name (with picto eventually)
|
||||
*
|
||||
* @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
|
||||
* @return string String with URL
|
||||
*/
|
||||
public function getNomUrl($withpicto = 0)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$result = '';
|
||||
$label = $langs->trans("Show").': '.$this->ref;
|
||||
|
||||
$link = '<a href="'.DOL_URL_ROOT.'/compta/deplacement/card.php?id='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
|
||||
$linkend = '</a>';
|
||||
|
||||
$picto = 'trip';
|
||||
|
||||
|
||||
if ($withpicto) {
|
||||
$result .= ($link.img_object($label, $picto, 'class="classfortooltip"').$linkend);
|
||||
}
|
||||
if ($withpicto && $withpicto != 2) {
|
||||
$result .= ' ';
|
||||
}
|
||||
if ($withpicto != 2) {
|
||||
$result .= $link.$this->ref.$linkend;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* List of types
|
||||
*
|
||||
* @param int $active Active or not
|
||||
* @return array<string,string>
|
||||
*/
|
||||
public function listOfTypes($active = 1)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$ret = array();
|
||||
|
||||
$sql = "SELECT id, code, label";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_type_fees";
|
||||
$sql .= " WHERE active = ".((int) $active);
|
||||
|
||||
dol_syslog(get_class($this)."::listOfTypes", LOG_DEBUG);
|
||||
$result = $this->db->query($sql);
|
||||
if ($result) {
|
||||
$num = $this->db->num_rows($result);
|
||||
$i = 0;
|
||||
while ($i < $num) {
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$ret[$obj->code] = (($langs->trans($obj->code) != $obj->code) ? $langs->trans($obj->code) : $obj->label);
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Information on record
|
||||
*
|
||||
* @param int $id Id of record
|
||||
* @return void
|
||||
*/
|
||||
public function info($id)
|
||||
{
|
||||
$sql = 'SELECT c.rowid, c.datec, c.fk_user_author, c.fk_user_modif,';
|
||||
$sql .= ' c.tms as datem';
|
||||
$sql .= ' FROM '.MAIN_DB_PREFIX.'deplacement as c';
|
||||
$sql .= ' WHERE c.rowid = '.((int) $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;
|
||||
|
||||
$this->user_creation_id = $obj->fk_user_author;
|
||||
$this->user_modification_id = $obj->fk_user_modif;
|
||||
$this->date_creation = $this->db->jdate($obj->datec);
|
||||
$this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem);
|
||||
}
|
||||
$this->db->free($result);
|
||||
} else {
|
||||
dol_print_error($this->db);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,186 +0,0 @@
|
|||
<?php
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (c) 2005-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2024-2026 MDW <mdeweerd@users.noreply.github.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/compta/deplacement/class/deplacementstats.class.php
|
||||
* \ingroup invoices
|
||||
* \brief File for class managaging the statistics of travel and expense notes
|
||||
*/
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/stats.class.php';
|
||||
include_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
|
||||
|
||||
/**
|
||||
* Class to manage the statistics of travel and expense notes
|
||||
*/
|
||||
class DeplacementStats extends Stats
|
||||
{
|
||||
/**
|
||||
* @var string Name of table without prefix where object is stored
|
||||
*/
|
||||
public $table_element;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $socid;
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
public $userid;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $from;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $field;
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public $where;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
* @param int $socid Id third party
|
||||
* @param int|int[] $userid Id user for filter or array of user ids
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($db, $socid = 0, $userid = 0)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$this->db = $db;
|
||||
$this->socid = $socid;
|
||||
$this->userid = $userid;
|
||||
|
||||
$object = new Deplacement($this->db);
|
||||
$this->from = MAIN_DB_PREFIX.$object->table_element;
|
||||
$this->field = 'km';
|
||||
|
||||
$this->where = " fk_statut > 0";
|
||||
$this->where .= " AND entity = ".$conf->entity;
|
||||
if ($this->socid > 0) {
|
||||
$this->where .= " AND fk_soc = ".((int) $this->socid);
|
||||
}
|
||||
if (is_array($this->userid) && count($this->userid) > 0) {
|
||||
$this->where .= ' AND fk_user IN ('.$this->db->sanitize(implode(',', $this->userid)).')';
|
||||
} elseif ($this->userid > 0) {
|
||||
$this->where .= ' AND fk_user = '.((int) $this->userid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the number of invoices per year
|
||||
*
|
||||
* @return array<array{0:int,1:int}> Array of nb each year
|
||||
*/
|
||||
public function getNbByYear()
|
||||
{
|
||||
$sql = "SELECT YEAR(dated) as dm, count(*)";
|
||||
$sql .= " FROM ".$this->db->sanitize($this->from, 0, 1, 1);
|
||||
$sql .= " GROUP BY dm DESC";
|
||||
$sql .= " WHERE ".$this->where;
|
||||
|
||||
return $this->_getNbByYear($sql);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the number of invoices for the given year
|
||||
*
|
||||
* @param int $year Year to scan
|
||||
* @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month
|
||||
* @return array<int<0,11>,array{0:int<1,12>,1:int}> Array with number by month
|
||||
*/
|
||||
public function getNbByMonth($year, $format = 0)
|
||||
{
|
||||
$sql = "SELECT MONTH(dated) as dm, count(*)";
|
||||
$sql .= " FROM ".$this->db->sanitize($this->from, 0, 1, 1);
|
||||
$sql .= " WHERE YEAR(dated) = ".((int) $year);
|
||||
$sql .= " AND ".$this->where;
|
||||
$sql .= " GROUP BY dm";
|
||||
$sql .= $this->db->order('dm', 'DESC');
|
||||
|
||||
$res = $this->_getNbByMonth($year, $sql, $format);
|
||||
//var_dump($res);print '<br>';
|
||||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Renvoie le montant de facture par mois pour une annee donnee
|
||||
*
|
||||
* @param int $year Year to scan
|
||||
* @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month
|
||||
* @return array<int<0,11>,array{0:int<1,12>,1:int|float}> Array of values
|
||||
*/
|
||||
public function getAmountByMonth($year, $format = 0)
|
||||
{
|
||||
$sql = "SELECT date_format(dated,'%m') as dm, sum(".$this->db->sanitize($this->field).")";
|
||||
$sql .= " FROM ".$this->db->sanitize($this->from, 0, 1, 1);
|
||||
$sql .= " WHERE date_format(dated,'%Y') = '".$this->db->escape((string) $year)."'";
|
||||
$sql .= " AND ".$this->where;
|
||||
$sql .= " GROUP BY dm";
|
||||
$sql .= $this->db->order('dm', 'DESC');
|
||||
|
||||
$res = $this->_getAmountByMonth($year, $sql, $format);
|
||||
//var_dump($res);print '<br>';
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return average amount
|
||||
*
|
||||
* @param int $year Year to scan
|
||||
* @return array<int<0,11>,array{0:int<1,12>,1:int|float}> Array with number by month
|
||||
*/
|
||||
public function getAverageByMonth($year)
|
||||
{
|
||||
$sql = "SELECT date_format(dated,'%m') as dm, avg(".$this->db->sanitize($this->field).")";
|
||||
$sql .= " FROM ".$this->db->sanitize($this->from, 0, 1, 1);
|
||||
$sql .= " WHERE date_format(dated,'%Y') = '".$this->db->escape((string) $year)."'";
|
||||
$sql .= " AND ".$this->where;
|
||||
$sql .= " GROUP BY dm";
|
||||
$sql .= $this->db->order('dm', 'DESC');
|
||||
|
||||
return $this->_getAverageByMonth($year, $sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return nb, total and average
|
||||
*
|
||||
* @return array<array{year:string,nb:int,nb_diff?:float,total?:float,avg?:float,weighted?:float,total_diff?:float,avg_diff?:float,avg_weighted?:float}> Array of values
|
||||
*/
|
||||
public function getAllByYear()
|
||||
{
|
||||
$sql = "SELECT date_format(dated,'%Y') as year, count(*) as nb, sum(".$this->db->sanitize($this->field).") as total, avg(".$this->db->sanitize($this->field).") as avg";
|
||||
$sql .= " FROM ".$this->db->sanitize($this->from, 0, 1, 1);
|
||||
$sql .= " WHERE ".$this->where;
|
||||
$sql .= " GROUP BY year";
|
||||
$sql .= $this->db->order('year', 'DESC');
|
||||
|
||||
return $this->_getAllByYear($sql);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,150 +0,0 @@
|
|||
<?php
|
||||
/* Copyright (C) 2003-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
|
||||
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2005 Simon TOSSER <simon@kornog-computing.com>
|
||||
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
|
||||
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/compta/deplacement/document.php
|
||||
* \ingroup deplacement
|
||||
* \brief Page of linked files onto trip and expenses
|
||||
*/
|
||||
|
||||
// Load Dolibarr environment
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.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/trip.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
|
||||
/**
|
||||
* @var Conf $conf
|
||||
* @var DoliDB $db
|
||||
* @var HookManager $hookmanager
|
||||
* @var Translate $langs
|
||||
* @var User $user
|
||||
*/
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('other', 'trips', 'companies', 'interventions'));
|
||||
|
||||
$id = GETPOSTINT('id');
|
||||
$ref = GETPOST('ref', 'alpha');
|
||||
$action = GETPOST('action', 'aZ09');
|
||||
$confirm = GETPOST('confirm', 'alpha');
|
||||
|
||||
|
||||
// Get parameters
|
||||
$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
|
||||
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
||||
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
|
||||
if (empty($page) || $page == -1) {
|
||||
$page = 0;
|
||||
} // If $page is not defined, or '' or -1
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (!$sortorder) {
|
||||
$sortorder = "ASC";
|
||||
}
|
||||
if (!$sortfield) {
|
||||
$sortfield = "name";
|
||||
}
|
||||
|
||||
|
||||
$object = new Deplacement($db);
|
||||
$object->fetch($id, $ref);
|
||||
|
||||
$upload_dir = $conf->deplacement->dir_output.'/'.dol_sanitizeFileName($object->ref);
|
||||
$modulepart = 'trip';
|
||||
|
||||
// Security check
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'deplacement', $id, '');
|
||||
|
||||
$permissiontoadd = $user->hasRight('deplacement', 'creer'); // Used by the include of actions_dellink.inc.php
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
llxHeader("", "", $langs->trans("TripCard"));
|
||||
|
||||
|
||||
if ($object->id) {
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$head = trip_prepare_head($object);
|
||||
|
||||
print dol_get_fiche_head($head, 'documents', $langs->trans("TripCard"), 0, 'trip');
|
||||
|
||||
|
||||
// Build file 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 '<table class="border tableforfield centpercent">';
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/compta/deplacement/list.php'.(!empty($socid) ? '?socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
// Ref
|
||||
print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>';
|
||||
print $form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'ref', '');
|
||||
print '</td></tr>';
|
||||
|
||||
// Societe
|
||||
//print "<tr><td>".$langs->trans("Company")."</td><td>".$object->client->getNomUrl(1)."</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">'.dol_print_size($totalsize, 1, 1).'</td></tr>';
|
||||
print '</table>';
|
||||
|
||||
print '</div>';
|
||||
|
||||
$modulepart = 'deplacement';
|
||||
$permissiontoadd = $user->hasRight('deplacement', 'creer');
|
||||
$param = '&id='.$object->id;
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
|
||||
} else {
|
||||
print $langs->trans("ErrorUnknown");
|
||||
}
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
|
|
@ -1,240 +0,0 @@
|
|||
<?php
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2005-2011 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/compta/deplacement/index.php
|
||||
* \brief Page list of expenses
|
||||
*/
|
||||
|
||||
// Load Dolibarr environment
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
|
||||
|
||||
/**
|
||||
* @var Conf $conf
|
||||
* @var DoliDB $db
|
||||
* @var HookManager $hookmanager
|
||||
* @var Translate $langs
|
||||
* @var User $user
|
||||
*/
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('companies', 'users', 'trips'));
|
||||
|
||||
// Security check
|
||||
$socid = GETPOSTINT('socid');
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'deplacement', '', '');
|
||||
|
||||
$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
|
||||
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
||||
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
|
||||
if (empty($page) || $page == -1) {
|
||||
$page = 0;
|
||||
} // If $page is not defined, or '' or -1
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (!$sortorder) {
|
||||
$sortorder = "DESC";
|
||||
}
|
||||
if (!$sortfield) {
|
||||
$sortfield = "d.dated";
|
||||
}
|
||||
$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$tripandexpense_static = new Deplacement($db);
|
||||
|
||||
$childids = $user->getAllChildIds();
|
||||
$childids[] = $user->id;
|
||||
|
||||
//$help_url='EN:Module_Donations|FR:Module_Dons|ES:Módulo_Donaciones';
|
||||
$help_url = '';
|
||||
llxHeader('', $langs->trans("TripsAndExpenses"), $help_url);
|
||||
|
||||
|
||||
|
||||
$totalnb = 0;
|
||||
$sql = "SELECT count(d.rowid) as nb, sum(d.km) as km, d.type";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."deplacement as d";
|
||||
$sql .= " WHERE d.entity = ".$conf->entity;
|
||||
if (!$user->hasRight('deplacement', 'readall') && !$user->hasRight('deplacement', 'lire_tous')) {
|
||||
$sql .= ' AND d.fk_user IN ('.$db->sanitize(implode(',', $childids)).')';
|
||||
}
|
||||
$sql .= " GROUP BY d.type";
|
||||
$sql .= " ORDER BY d.type";
|
||||
|
||||
$result = $db->query($sql);
|
||||
$somme = array();
|
||||
$nb = array();
|
||||
if ($result) {
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
while ($i < $num) {
|
||||
$objp = $db->fetch_object($result);
|
||||
|
||||
$somme[$objp->type] = $objp->km;
|
||||
$nb[$objp->type] = $objp->nb;
|
||||
$totalnb += $objp->nb;
|
||||
$i++;
|
||||
}
|
||||
$db->free($result);
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
|
||||
print load_fiche_titre($langs->trans("ExpensesArea"));
|
||||
|
||||
|
||||
print '<div class="fichecenter"><div class="fichethirdleft">';
|
||||
|
||||
|
||||
// Statistics
|
||||
print '<table class="noborder nohover centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="4">'.$langs->trans("Statistics").'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$listoftype = $tripandexpense_static->listOfTypes();
|
||||
$dataseries = array();
|
||||
foreach ($listoftype as $code => $label) {
|
||||
$dataseries[] = array($label, (isset($nb[$code]) ? (int) $nb[$code] : 0));
|
||||
}
|
||||
|
||||
if ($conf->use_javascript_ajax) {
|
||||
print '<tr><td align="center" colspan="4">';
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
|
||||
$dolgraph = new DolGraph();
|
||||
$dolgraph->SetData($dataseries);
|
||||
$dolgraph->setShowLegend(2);
|
||||
$dolgraph->setShowPercent(1);
|
||||
$dolgraph->SetType(array('pie'));
|
||||
$dolgraph->setHeight('200');
|
||||
$dolgraph->draw('idgraphstatus');
|
||||
print $dolgraph->show($totalnb ? 0 : 1);
|
||||
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
print '<tr class="liste_total">';
|
||||
print '<td>'.$langs->trans("Total").'</td>';
|
||||
print '<td class="right">'.$totalnb.'</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
|
||||
|
||||
print '</div><div class="fichetwothirdright">';
|
||||
|
||||
|
||||
$max = 10;
|
||||
|
||||
$langs->load("boxes");
|
||||
|
||||
$sql = "SELECT u.rowid as uid, u.lastname, u.firstname, d.rowid, d.dated as date, d.tms as dm, d.km, d.fk_statut";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."deplacement as d, ".MAIN_DB_PREFIX."user as u";
|
||||
$sql .= " WHERE u.rowid = d.fk_user";
|
||||
$sql .= " AND d.entity = ".$conf->entity;
|
||||
if (!$user->hasRight('deplacement', 'readall') && !$user->hasRight('deplacement', 'lire_tous')) {
|
||||
$sql .= ' AND d.fk_user IN ('.$db->sanitize(implode(',', $childids)).')';
|
||||
}
|
||||
// If the internal user must only see his customers, force searching by him
|
||||
$search_sale = 0;
|
||||
if (!$user->hasRight('societe', 'client', 'voir')) {
|
||||
$search_sale = $user->id;
|
||||
}
|
||||
// Search on sale representative
|
||||
if ($search_sale && $search_sale != '-1') {
|
||||
if ($search_sale == -2) {
|
||||
$sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = d.fk_soc)";
|
||||
} elseif ($search_sale > 0) {
|
||||
$sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = d.fk_soc AND sc.fk_user = ".((int) $search_sale).")";
|
||||
}
|
||||
}
|
||||
// Search on socid
|
||||
if ($socid) {
|
||||
$sql .= " AND d.fk_soc = ".((int) $socid);
|
||||
}
|
||||
$sql .= $db->order("d.tms", "DESC");
|
||||
$sql .= $db->plimit($max, 0);
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result) {
|
||||
$var = false;
|
||||
$num = $db->num_rows($result);
|
||||
|
||||
$i = 0;
|
||||
|
||||
print '<table class="noborder centpercent">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td colspan="2">'.$langs->trans("BoxTitleLastModifiedExpenses", min($max, $num)).'</td>';
|
||||
print '<td class="right">'.$langs->trans("FeesKilometersOrAmout").'</td>';
|
||||
print '<td class="right">'.$langs->trans("DateModificationShort").'</td>';
|
||||
print '<td width="16"> </td>';
|
||||
print '</tr>';
|
||||
if ($num) {
|
||||
$total_ttc = $totalam = $total = 0;
|
||||
|
||||
$deplacementstatic = new Deplacement($db);
|
||||
$userstatic = new User($db);
|
||||
while ($i < $num && $i < $max) {
|
||||
$obj = $db->fetch_object($result);
|
||||
$deplacementstatic->ref = $obj->rowid;
|
||||
$deplacementstatic->id = $obj->rowid;
|
||||
$userstatic->id = $obj->uid;
|
||||
$userstatic->lastname = $obj->lastname;
|
||||
$userstatic->firstname = $obj->firstname;
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$deplacementstatic->getNomUrl(1).'</td>';
|
||||
print '<td>'.$userstatic->getNomUrl(1).'</td>';
|
||||
print '<td class="right">'.$obj->km.'</td>';
|
||||
print '<td class="right">'.dol_print_date($db->jdate($obj->dm), 'day').'</td>';
|
||||
print '<td>'.$deplacementstatic->LibStatut($obj->fk_statut, 3).'</td>';
|
||||
print '</tr>';
|
||||
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
print '<tr class="oddeven"><td colspan="2" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
|
||||
}
|
||||
print '</table><br>';
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
|
||||
print '</div></div>';
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
<?php
|
||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/compta/deplacement/info.php
|
||||
* \ingroup trip
|
||||
* \brief Page to show a trip information
|
||||
*/
|
||||
|
||||
// Load Dolibarr environment
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/trip.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
|
||||
|
||||
/**
|
||||
* @var Conf $conf
|
||||
* @var DoliDB $db
|
||||
* @var HookManager $hookmanager
|
||||
* @var Translate $langs
|
||||
* @var User $user
|
||||
*/
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->load("trips");
|
||||
|
||||
// Security check
|
||||
$id = GETPOSTINT('id');
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'deplacement', $id, '');
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
llxHeader();
|
||||
|
||||
if ($id) {
|
||||
$object = new Deplacement($db);
|
||||
$object->fetch($id);
|
||||
$object->info($id);
|
||||
|
||||
$head = trip_prepare_head($object);
|
||||
|
||||
print dol_get_fiche_head($head, 'info', $langs->trans("TripCard"), 0, 'trip');
|
||||
|
||||
print '<table width="100%"><tr><td>';
|
||||
dol_print_object_info($object);
|
||||
print '</td></tr></table>';
|
||||
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
|
|
@ -1,244 +0,0 @@
|
|||
<?php
|
||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
|
||||
* Copyright (C) 2005-2011 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2012 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2018 charlene Benke <charlie@patas-monkey.com>
|
||||
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/compta/deplacement/list.php
|
||||
* \brief Page to list trips and expenses
|
||||
*/
|
||||
|
||||
// Load Dolibarr environment
|
||||
require '../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
|
||||
/**
|
||||
* @var Conf $conf
|
||||
* @var DoliDB $db
|
||||
* @var Form $form
|
||||
* @var HookManager $hookmanager
|
||||
* @var Translate $langs
|
||||
* @var User $user
|
||||
*/
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('companies', 'users', 'trips'));
|
||||
|
||||
// Security check
|
||||
$socid = GETPOSTINT('socid');
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'deplacement', '', '');
|
||||
|
||||
$search_ref = GETPOST('search_ref', 'alpha');
|
||||
$search_name = GETPOST('search_name', 'alpha');
|
||||
$search_company = GETPOST('search_company', 'alpha');
|
||||
// $search_amount=GETPOST('search_amount','alpha');
|
||||
$sortfield = GETPOST('sortfield', 'aZ09comma');
|
||||
$sortorder = GETPOST('sortorder', 'aZ09comma');
|
||||
$page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page");
|
||||
$limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit;
|
||||
if (empty($page) || $page == -1) {
|
||||
$page = 0;
|
||||
} // If $page is not defined, or '' or -1
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (!$sortorder) {
|
||||
$sortorder = "DESC";
|
||||
}
|
||||
if (!$sortfield) {
|
||||
$sortfield = "d.dated";
|
||||
}
|
||||
|
||||
$year = GETPOST("year");
|
||||
$month = GETPOST("month");
|
||||
$day = GETPOST("day");
|
||||
|
||||
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // Both test are required to be compatible with all browsers
|
||||
$search_ref = "";
|
||||
$search_name = "";
|
||||
$search_company = "";
|
||||
// $search_amount="";
|
||||
$year = "";
|
||||
$month = "";
|
||||
$day = "";
|
||||
}
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$formother = new FormOther($db);
|
||||
$tripandexpense_static = new Deplacement($db);
|
||||
$userstatic = new User($db);
|
||||
|
||||
$childids = $user->getAllChildIds();
|
||||
$childids[] = $user->id;
|
||||
|
||||
llxHeader();
|
||||
|
||||
$sql = "SELECT s.nom, d.fk_user, s.rowid as socid,"; // Ou
|
||||
$sql .= " d.rowid, d.type, d.dated as dd, d.km,"; // Comment
|
||||
$sql .= " d.fk_statut,";
|
||||
$sql .= " u.lastname, u.firstname"; // Qui
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
|
||||
$sql .= ", ".MAIN_DB_PREFIX."deplacement as d";
|
||||
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON d.fk_soc = s.rowid";
|
||||
$sql .= " WHERE d.fk_user = u.rowid";
|
||||
$sql .= " AND d.entity = ".$conf->entity;
|
||||
if (!$user->hasRight('deplacement', 'readall') && !$user->hasRight('deplacement', 'lire_tous')) {
|
||||
$sql .= ' AND d.fk_user IN ('.$db->sanitize(implode(',', $childids)).')';
|
||||
}
|
||||
// If the internal user must only see his customers, force searching by him
|
||||
$search_sale = 0;
|
||||
if (!$user->hasRight('societe', 'client', 'voir')) {
|
||||
$search_sale = $user->id;
|
||||
}
|
||||
// Search on sale representative
|
||||
if ($search_sale && $search_sale != '-1') {
|
||||
if ($search_sale == -2) {
|
||||
$sql .= " AND NOT EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = d.fk_soc)";
|
||||
} elseif ($search_sale > 0) {
|
||||
$sql .= " AND EXISTS (SELECT sc.fk_soc FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc WHERE sc.fk_soc = d.fk_soc AND sc.fk_user = ".((int) $search_sale).")";
|
||||
}
|
||||
}
|
||||
// Search on socid
|
||||
if ($socid) {
|
||||
$sql .= " AND d.fk_soc = ".((int) $socid);
|
||||
}
|
||||
|
||||
if ($search_ref) {
|
||||
$sql .= " AND d.rowid = ".((int) $search_ref);
|
||||
}
|
||||
if ($search_name) {
|
||||
$sql .= natural_search('u.lastname', $search_name);
|
||||
}
|
||||
if ($search_company) {
|
||||
$sql .= natural_search('s.nom', $search_company);
|
||||
}
|
||||
$sql .= dolSqlDateFilter("d.dated", $day, $month, $year);
|
||||
|
||||
$sql .= $db->order($sortfield, $sortorder);
|
||||
$sql .= $db->plimit($limit + 1, $offset);
|
||||
|
||||
//print $sql;
|
||||
$resql = $db->query($sql);
|
||||
if ($resql) {
|
||||
$num = $db->num_rows($resql);
|
||||
|
||||
print_barre_liste($langs->trans("TripsAndExpenses"), $page, $_SERVER["PHP_SELF"], "&socid=$socid", $sortfield, $sortorder, '', $num);
|
||||
|
||||
$i = 0;
|
||||
print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">'."\n";
|
||||
print '<table class="noborder centpercent">';
|
||||
print "<tr class=\"liste_titre\">";
|
||||
print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "d.rowid", "", "&socid=$socid", '', $sortfield, $sortorder);
|
||||
print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "d.type", "", "&socid=$socid", '', $sortfield, $sortorder);
|
||||
print_liste_field_titre("Date", $_SERVER["PHP_SELF"], "d.dated", "", "&socid=$socid", 'align="center"', $sortfield, $sortorder);
|
||||
print_liste_field_titre("Person", $_SERVER["PHP_SELF"], "u.lastname", "", "&socid=$socid", '', $sortfield, $sortorder);
|
||||
print_liste_field_titre("Company", $_SERVER["PHP_SELF"], "s.nom", "", "&socid=$socid", '', $sortfield, $sortorder);
|
||||
print_liste_field_titre("FeesKilometersOrAmout", $_SERVER["PHP_SELF"], "d.km", "", "&socid=$socid", 'class="right"', $sortfield, $sortorder);
|
||||
print_liste_field_titre('');
|
||||
print "</tr>\n";
|
||||
|
||||
// Filters lines
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td class="liste_titre">';
|
||||
print '<input class="flat" size="4" type="text" name="search_ref" value="'.$search_ref.'">';
|
||||
print '</td>';
|
||||
print '<td class="liste_titre">';
|
||||
print ' ';
|
||||
print '</td>';
|
||||
print '<td class="liste_titre" align="center">';
|
||||
if (getDolGlobalString('MAIN_LIST_FILTER_ON_DAY')) {
|
||||
print '<input class="flat" type="text" size="1" maxlength="2" name="day" value="'.$day.'">';
|
||||
}
|
||||
print '<input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.'">';
|
||||
print $formother->selectyear($year ? $year : -1, 'year', 1, 20, 5);
|
||||
print '</td>';
|
||||
print '<td class="liste_titre">';
|
||||
print '<input class="flat" size="10" type="text" name="search_name" value="'.$search_name.'">';
|
||||
print '</td>';
|
||||
print '<td class="liste_titre">';
|
||||
print '<input class="flat" size="10" type="text" name="search_company" value="'.$search_company.'">';
|
||||
print '</td>';
|
||||
print '<td class="liste_titre right">';
|
||||
// print '<input class="flat" size="10" type="text" name="search_amount" value="'.$search_amount.'">';
|
||||
print '</td>';
|
||||
print '<td class="liste_titre maxwidthsearch">';
|
||||
$searchpicto = $form->showFilterAndCheckAddButtons(0);
|
||||
print $searchpicto;
|
||||
print '</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
while ($i < min($num, $limit)) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
$soc = new Societe($db);
|
||||
if ($obj->socid) {
|
||||
$soc->fetch($obj->socid);
|
||||
}
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
// Id
|
||||
print '<td><a href="card.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowTrip"), "trip").' '.$obj->rowid.'</a></td>';
|
||||
// Type
|
||||
print '<td>'.$langs->trans($obj->type).'</td>';
|
||||
// Date
|
||||
print '<td class="center">'.dol_print_date($db->jdate($obj->dd), 'day').'</td>';
|
||||
// User
|
||||
print '<td>';
|
||||
$userstatic->id = $obj->fk_user;
|
||||
$userstatic->lastname = $obj->lastname;
|
||||
$userstatic->firstname = $obj->firstname;
|
||||
print $userstatic->getNomUrl(1);
|
||||
print '</td>';
|
||||
|
||||
if ($obj->socid) {
|
||||
print '<td>'.$soc->getNomUrl(1).'</td>';
|
||||
} else {
|
||||
print '<td> </td>';
|
||||
}
|
||||
|
||||
print '<td class="right">'.$obj->km.'</td>';
|
||||
|
||||
$tripandexpense_static->statut = $obj->fk_statut;
|
||||
print '<td class="right">'.$tripandexpense_static->getLibStatut(5).'</td>';
|
||||
print "</tr>\n";
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
print "</table>";
|
||||
print "</form>\n";
|
||||
$db->free($resql);
|
||||
} else {
|
||||
dol_print_error($db);
|
||||
}
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
|
|
@ -1,343 +0,0 @@
|
|||
<?php
|
||||
/* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (c) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2012 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/compta/deplacement/stats/index.php
|
||||
* \ingroup deplacement
|
||||
* \brief Page for statistics of module trips and expenses
|
||||
*/
|
||||
|
||||
// Load Dolibarr environment
|
||||
require '../../../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacementstats.class.php';
|
||||
|
||||
/**
|
||||
* @var Conf $conf
|
||||
* @var DoliDB $db
|
||||
* @var HookManager $hookmanager
|
||||
* @var Translate $langs
|
||||
* @var User $user
|
||||
*/
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array('trips', 'companies'));
|
||||
|
||||
$WIDTH = DolGraph::getDefaultGraphSizeForStats('width');
|
||||
$HEIGHT = DolGraph::getDefaultGraphSizeForStats('height');
|
||||
|
||||
$userid = GETPOSTINT('userid');
|
||||
if ($userid < 0) {
|
||||
$userid = 0;
|
||||
}
|
||||
$socid = GETPOSTINT('socid');
|
||||
if ($socid < 0) {
|
||||
$socid = 0;
|
||||
}
|
||||
$id = GETPOSTINT('id');
|
||||
|
||||
// Security check
|
||||
if ($user->socid > 0) {
|
||||
$action = '';
|
||||
$socid = $user->socid;
|
||||
}
|
||||
if ($user->socid) {
|
||||
$socid = $user->socid;
|
||||
}
|
||||
$result = restrictedArea($user, 'deplacement', $id, '');
|
||||
|
||||
// Other security check
|
||||
$childids = $user->getAllChildIds(1);
|
||||
if ($userid > 0) {
|
||||
if (!$user->hasRight('deplacement', 'readall') && !$user->hasRight('deplacement', 'lire_tous') && !in_array($userid, $childids)) {
|
||||
accessforbidden();
|
||||
}
|
||||
}
|
||||
|
||||
$nowyear = (int) dol_print_date(dol_now('gmt'), "%Y", 'gmt');
|
||||
$year = GETPOSTINT('year') > 0 ? GETPOSTINT('year') : $nowyear;
|
||||
$startyear = $year - (!getDolGlobalInt('MAIN_STATS_GRAPHS_SHOW_N_YEARS') ? 2 : max(1, min(10, getDolGlobalInt('MAIN_STATS_GRAPHS_SHOW_N_YEARS'))));
|
||||
$endyear = $year;
|
||||
|
||||
$mode = GETPOST("mode") ? GETPOST("mode") : 'customer';
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
|
||||
|
||||
llxHeader();
|
||||
|
||||
$title = $langs->trans("TripsAndExpensesStatistics");
|
||||
$dir = $conf->deplacement->dir_temp;
|
||||
|
||||
print load_fiche_titre($title);
|
||||
|
||||
dol_mkdir($dir);
|
||||
|
||||
$useridtofilter = $userid; // Filter from parameters
|
||||
if (empty($useridtofilter)) {
|
||||
$useridtofilter = $childids;
|
||||
if ($user->hasRight('deplacement', 'readall') || $user->hasRight('deplacement', 'lire_tous')) {
|
||||
$useridtofilter = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$stats = new DeplacementStats($db, $socid, $useridtofilter);
|
||||
|
||||
|
||||
// Build graphic number of object
|
||||
// $data = array(array('Lib',val1,val2,val3),...)
|
||||
//print "$endyear, $startyear";
|
||||
$data = $stats->getNbByMonthWithPrevYear($endyear, $startyear);
|
||||
//var_dump($data);
|
||||
|
||||
$filenamenb = $dir."/tripsexpensesnbinyear-".$year.".png";
|
||||
$fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=tripsexpensesstats&file=tripsexpensesnbinyear-'.$year.'.png';
|
||||
|
||||
$px1 = new DolGraph();
|
||||
$mesg = $px1->isGraphKo();
|
||||
if (!$mesg) {
|
||||
$px1->SetData($data);
|
||||
$i = $startyear;
|
||||
$legend = array();
|
||||
while ($i <= $endyear) {
|
||||
$legend[] = $i;
|
||||
$i++;
|
||||
}
|
||||
$px1->SetLegend($legend);
|
||||
$px1->SetMaxValue($px1->GetCeilMaxValue());
|
||||
$px1->SetWidth($WIDTH);
|
||||
$px1->SetHeight($HEIGHT);
|
||||
$px1->SetYLabel($langs->trans("Number"));
|
||||
$px1->SetShading(3);
|
||||
$px1->SetHorizTickIncrement(1);
|
||||
$px1->mode = 'depth';
|
||||
$px1->SetTitle($langs->trans("NumberByMonth"));
|
||||
|
||||
$px1->draw($filenamenb, $fileurlnb);
|
||||
}
|
||||
|
||||
// Build graphic amount of object
|
||||
$data = $stats->getAmountByMonthWithPrevYear($endyear, $startyear);
|
||||
//var_dump($data);
|
||||
// $data = array(array('Lib',val1,val2,val3),...)
|
||||
|
||||
$filenameamount = $dir."/tripsexpensesamountinyear-".$year.".png";
|
||||
$fileurlamount = DOL_URL_ROOT.'/viewimage.php?modulepart=tripsexpensesstats&file=tripsexpensesamountinyear-'.$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("Amount"));
|
||||
$px2->SetShading(3);
|
||||
$px2->SetHorizTickIncrement(1);
|
||||
$px2->mode = 'depth';
|
||||
$px2->SetTitle($langs->trans("AmountTotal"));
|
||||
|
||||
$px2->draw($filenameamount, $fileurlamount);
|
||||
}
|
||||
|
||||
|
||||
$data = $stats->getAverageByMonthWithPrevYear($endyear, $startyear);
|
||||
|
||||
$filename_avg = '';
|
||||
$fileurl_avg = '';
|
||||
if (!$user->hasRight('societe', 'client', 'voir')) {
|
||||
$filename_avg = $dir.'/ordersaverage-'.$user->id.'-'.$year.'.png';
|
||||
if ($mode == 'customer') {
|
||||
$fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$user->id.'-'.$year.'.png';
|
||||
}
|
||||
if ($mode == 'supplier') {
|
||||
$fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$user->id.'-'.$year.'.png';
|
||||
}
|
||||
} else {
|
||||
$filename_avg = $dir.'/ordersaverage-'.$year.'.png';
|
||||
if ($mode == 'customer') {
|
||||
$fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstats&file=ordersaverage-'.$year.'.png';
|
||||
}
|
||||
if ($mode == 'supplier') {
|
||||
$fileurl_avg = DOL_URL_ROOT.'/viewimage.php?modulepart=orderstatssupplier&file=ordersaverage-'.$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((int) $px3->GetFloorMinValue());
|
||||
$px3->SetWidth($WIDTH);
|
||||
$px3->SetHeight($HEIGHT);
|
||||
$px3->SetShading(3);
|
||||
$px3->SetHorizTickIncrement(1);
|
||||
$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) {
|
||||
$arrayyears[$val['year']] = $val['year'];
|
||||
}
|
||||
if (!count($arrayyears)) {
|
||||
$arrayyears[$nowyear] = $nowyear;
|
||||
}
|
||||
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
$head[$h][0] = DOL_URL_ROOT.'/compta/deplacement/stats/index.php';
|
||||
$head[$h][1] = $langs->trans("ByMonthYear");
|
||||
$head[$h][2] = 'byyear';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf, $langs, null, $head, $h, 'trip_stats');
|
||||
|
||||
print dol_get_fiche_head($head, 'byyear', '', -1);
|
||||
|
||||
|
||||
print '<div class="fichecenter"><div class="fichethirdleft">';
|
||||
|
||||
|
||||
// Show filter box
|
||||
print '<form name="stats" method="POST" action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="mode" value="'.$mode.'">';
|
||||
|
||||
print '<table class="border centpercent">';
|
||||
print '<tr class="liste_titre"><td class="liste_titre" colspan="2">'.$langs->trans("Filter").'</td></tr>';
|
||||
// Company
|
||||
print '<tr><td>'.$langs->trans("ThirdParty").'</td><td>';
|
||||
print img_picto('', 'company', 'class="pictofixedwidth"');
|
||||
print $form->select_company($socid, 'socid', '', 1, 1, 0, array(), 0, 'widthcentpercentminusx maxwidth300', '');
|
||||
print '</td></tr>';
|
||||
// User
|
||||
print '<tr><td>'.$langs->trans("User").'</td><td>';
|
||||
$include = '';
|
||||
if (!$user->hasRight('deplacement', 'readall') && !$user->hasRight('deplacement', 'lire_tous')) {
|
||||
$include = 'hierarchy';
|
||||
}
|
||||
print img_picto('', 'user', 'class="pictofixedwidth"');
|
||||
print $form->select_dolusers($userid, 'userid', 1, null, 0, $include, '', '0', 0, 0, '', 0, '', 'widthcentpercentminusx maxwidth300');
|
||||
print '</td></tr>';
|
||||
// Year
|
||||
print '<tr><td>'.$langs->trans("Year").'</td><td>';
|
||||
if (!in_array($year, $arrayyears)) {
|
||||
$arrayyears[$year] = $year;
|
||||
}
|
||||
arsort($arrayyears);
|
||||
print img_picto('', 'calendar', 'class="pictofixedwidth"');
|
||||
print $form->selectarray('year', $arrayyears, $year, 0, 0, 0, '', 0, 0, 0, '', 'width75');
|
||||
print '</td></tr>';
|
||||
print '<tr><td align="center" colspan="2"><input type="submit" name="submit" class="button small" value="'.$langs->trans("Refresh").'"></td></tr>';
|
||||
print '</table>';
|
||||
print '</form>';
|
||||
print '<br><br>';
|
||||
|
||||
print '<div class="div-table-responsive-no-min">';
|
||||
print '<table class="border centpercent">';
|
||||
print '<tr>';
|
||||
print '<td class="center">'.$langs->trans("Year").'</td>';
|
||||
print '<td class="center">'.$langs->trans("Number").'</td>';
|
||||
print '<td class="center">'.$langs->trans("AmountTotal").'</td>';
|
||||
print '<td class="center">'.$langs->trans("AmountAverage").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
$oldyear = 0;
|
||||
foreach ($data as $val) {
|
||||
$year = $val['year'];
|
||||
while ($year && $oldyear > (int) $year + 1) { // If we have empty year
|
||||
$oldyear--;
|
||||
print '<tr>';
|
||||
print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$oldyear.'&mode='.$mode.'">'.$oldyear.'</a></td>';
|
||||
print '<td class="right">0</td>';
|
||||
print '<td class="right">0</td>';
|
||||
print '<td class="right">0</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Total
|
||||
print '<tr>';
|
||||
print '<td align="center"><a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'&mode='.$mode.'">'.$year.'</a></td>';
|
||||
print '<td class="right">'.$val['nb'].'</td>';
|
||||
print '<td class="right">'.price(price2num($val['total'], 'MT'), 1).'</td>';
|
||||
print '<td class="right">'.price(price2num($val['avg'], 'MT'), 1).'</td>';
|
||||
print '</tr>';
|
||||
$oldyear = $year;
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
print '</div>';
|
||||
|
||||
print '</div><div class="fichetwothirdright">';
|
||||
|
||||
|
||||
// Show graphs
|
||||
print '<table class="border centpercent"><tr class="pair nohover"><td align="center">';
|
||||
if ($mesg) {
|
||||
print $mesg;
|
||||
} else {
|
||||
print $px1->show();
|
||||
print "<br>\n";
|
||||
print $px2->show();
|
||||
print "<br>\n";
|
||||
print $px3->show();
|
||||
}
|
||||
print '</td></tr></table>';
|
||||
|
||||
|
||||
print '</div></div>';
|
||||
print '<div class="clearboth"></div>';
|
||||
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
<?php
|
||||
/* Copyright (C) 2011 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
|
||||
* Copyright (C) 2025 Frédéric France <frederic.france@free.fr>
|
||||
*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
* or see https://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/lib/trip.lib.php
|
||||
* \brief Ensemble de functions de base pour les deplacements
|
||||
*/
|
||||
|
||||
/**
|
||||
* Prepare array with list of tabs
|
||||
*
|
||||
* @param Deplacement $object Object related to tabs
|
||||
* @return array<array{0:string,1:string,2:string}> Array of tabs to show
|
||||
*/
|
||||
function trip_prepare_head(Deplacement $object)
|
||||
{
|
||||
global $langs, $conf;
|
||||
|
||||
$h = 0;
|
||||
$head = array();
|
||||
|
||||
$query = ['id' => $object->id];
|
||||
$head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/compta/deplacement/card.php', $query);
|
||||
$head[$h][1] = $langs->trans("Trip");
|
||||
$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, 'trip');
|
||||
|
||||
$head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/compta/deplacement/document.php', $query);
|
||||
$head[$h][1] = $langs->trans("Documents");
|
||||
$head[$h][2] = 'documents';
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/compta/deplacement/info.php', $query);
|
||||
$head[$h][1] = $langs->trans("Info");
|
||||
$head[$h][2] = 'info';
|
||||
$h++;
|
||||
|
||||
complete_head_from_modules($conf, $langs, $object, $head, $h, 'trip', 'remove');
|
||||
|
||||
return $head;
|
||||
}
|
||||
|
|
@ -474,12 +474,6 @@ 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 ('', 'isModEnabled("holiday")', __HANDLER__, 'left', 5005__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/define_holiday.php?mainmenu=hrm', 'MenuConfCP', 1, 'holiday', '$user->hasRight("holiday", "define_holiday")', '', 0, 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 ('', 'isModEnabled("holiday")', __HANDLER__, 'left', 5006__+MAX_llx_menu__, 'hrm', '', 5000__+MAX_llx_menu__, '/holiday/view_log.php?mainmenu=hrm', 'MenuLogCP', 1, 'holiday', '$user->hasRight("holiday", "define_holiday")', '', 0, 3, __ENTITY__);
|
||||
|
||||
-- HRM - Trips and expenses (old module)
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("deplacement")', __HANDLER__, 'left', 2100__+MAX_llx_menu__, 'accountancy', 'tripsandexpenses', 15__+MAX_llx_menu__, '/compta/deplacement/index.php?mainmenu=accountancy&leftmenu=tripsandexpenses', 'TripsAndExpenses', 0, 'trips', '$user->hasRight("deplacement","lire")', '', 0, 5, __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 ('', 'isModEnabled("deplacement")', __HANDLER__, 'left', 2101__+MAX_llx_menu__, 'accountancy', '', 2100__+MAX_llx_menu__, '/compta/deplacement/card.php?mainmenu=accountancy&action=create&leftmenu=tripsandexpenses', 'New', 1, 'trips', '$user->hasRight("deplacement","creer")', '', 0, 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 ('', 'isModEnabled("deplacement")', __HANDLER__, 'left', 2102__+MAX_llx_menu__, 'accountancy', '', 2100__+MAX_llx_menu__, '/compta/deplacement/list.php?mainmenu=accountancy&leftmenu=tripsandexpenses', 'List', 1, 'trips', '$user->hasRight("deplacement","lire")', '', 0, 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 ('', 'isModEnabled("deplacement")', __HANDLER__, 'left', 2103__+MAX_llx_menu__, 'accountancy', '', 2100__+MAX_llx_menu__, '/compta/deplacement/stats/index.php?mainmenu=accountancy&leftmenu=tripsandexpenses', 'Statistics', 1, 'trips', '$user->hasRight("deplacement","lire")', '', 0, 2, __ENTITY__);
|
||||
|
||||
-- HRM - Expense reports
|
||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', 'isModEnabled("expensereport")', __HANDLER__, 'left', 5300__+MAX_llx_menu__, 'hrm', 'expensereport', 15__+MAX_llx_menu__, '/expensereport/index.php?mainmenu=hrm&leftmenu=expensereport', 'TripsAndExpenses', 0, 'trips', '$user->hasRight("expensereport","lire")', '', 0, 5, __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 ('', 'isModEnabled("expensereport")', __HANDLER__, 'left', 5301__+MAX_llx_menu__, 'hrm', '', 5300__+MAX_llx_menu__, '/expensereport/card.php?mainmenu=hrm&action=create&leftmenu=expensereport', 'New', 1, 'trips', '$user->hasRight("expensereport","creer")', '', 0, 1, __ENTITY__);
|
||||
|
|
|
|||
|
|
@ -2525,15 +2525,6 @@ function get_left_menu_hrm($mainmenu, &$newmenu, $usemenuhider = 1, $leftmenu =
|
|||
$newmenu->add(dolBuildUrl('/holiday/view_log.php', ['mainmenu' => 'hrm', 'leftmenu' => 'holiday']), $langs->trans("MenuLogCP"), 1, $user->hasRight('holiday', 'define_holiday'), '', $mainmenu, 'holiday_sm');
|
||||
}
|
||||
|
||||
// Trips and expenses (old module)
|
||||
if (isModEnabled('deplacement')) {
|
||||
$langs->load("trips");
|
||||
$newmenu->add(dolBuildUrl('/compta/deplacement/index.php', ['leftmenu' => 'tripsandexpenses', 'mainmenu' => 'hrm']), $langs->trans("TripsAndExpenses"), 0, $user->hasRight('deplacement', 'lire'), '', $mainmenu, 'tripsandexpenses', 0, '', '', '', img_picto('', 'trip', 'class="paddingright pictofixedwidth"'));
|
||||
$newmenu->add(dolBuildUrl('/compta/deplacement/card.php', ['action' => 'create', 'leftmenu' => 'tripsandexpenses', 'mainmenu' => 'hrm']), $langs->trans("New"), 1, $user->hasRight('deplacement', 'creer'));
|
||||
$newmenu->add(dolBuildUrl('/compta/deplacement/list.php', ['leftmenu' => 'tripsandexpenses', 'mainmenu' => 'hrm']), $langs->trans("List"), 1, $user->hasRight('deplacement', 'lire'));
|
||||
$newmenu->add(dolBuildUrl('/compta/deplacement/stats/index.php', ['leftmenu' => 'tripsandexpenses', 'mainmenu' => 'hrm']), $langs->trans("Statistics"), 1, $user->hasRight('deplacement', 'lire'));
|
||||
}
|
||||
|
||||
// Expense report
|
||||
if (isModEnabled('expensereport')) {
|
||||
$langs->loadLangs(array("trips", "bills"));
|
||||
|
|
|
|||
|
|
@ -1,173 +0,0 @@
|
|||
<?php
|
||||
/* Copyright (C) 2005-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \defgroup deplacement Module traves
|
||||
* \brief Module pour gerer les deplacements et notes de frais
|
||||
* \file htdocs/core/modules/modDeplacement.class.php
|
||||
* \ingroup deplacement
|
||||
* \brief Description and activation file for the module trips (deprecated)
|
||||
*/
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
|
||||
|
||||
|
||||
/**
|
||||
* Class to describe and enable module Deplacement
|
||||
*/
|
||||
class modDeplacement extends DolibarrModules
|
||||
{
|
||||
/**
|
||||
* Constructor. Define names, constants, directories, boxes, permissions
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
public function __construct($db)
|
||||
{
|
||||
global $conf, $user;
|
||||
|
||||
$this->db = $db;
|
||||
$this->numero = 75;
|
||||
|
||||
$this->family = "hr";
|
||||
$this->module_position = '43';
|
||||
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
|
||||
$this->name = preg_replace('/^mod/i', '', get_class($this));
|
||||
$this->description = "Gestion des notes de frais et deplacements"; // Si traduction Module75Desc non trouvee
|
||||
|
||||
// Possible values for version are: 'development', 'experimental', 'dolibarr' or 'dolibarr_deprecated' or version
|
||||
$this->version = 'dolibarr_deprecated';
|
||||
|
||||
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
|
||||
$this->picto = "trip";
|
||||
|
||||
// Data directories to create when module is enabled
|
||||
$this->dirs = array();
|
||||
|
||||
// Config pages
|
||||
$this->config_page_url = array();
|
||||
$this->langfiles = array("companies", "trips");
|
||||
|
||||
// Dependencies
|
||||
$this->depends = array();
|
||||
$this->requiredby = array();
|
||||
|
||||
// Constants
|
||||
$this->const = array();
|
||||
|
||||
// Boxes
|
||||
$this->boxes = array();
|
||||
|
||||
// Permissions
|
||||
$this->rights = array();
|
||||
$this->rights_class = 'deplacement';
|
||||
|
||||
$this->rights[1][0] = 171;
|
||||
$this->rights[1][1] = 'View own expense and travel reports, and its hierarchy';
|
||||
$this->rights[1][2] = 'r';
|
||||
$this->rights[1][3] = 0;
|
||||
$this->rights[1][4] = 'lire';
|
||||
|
||||
$this->rights[2][0] = 172;
|
||||
$this->rights[2][1] = 'Creer/modifier une note de frais et deplacements';
|
||||
$this->rights[2][2] = 'w';
|
||||
$this->rights[2][3] = 0;
|
||||
$this->rights[2][4] = 'creer';
|
||||
|
||||
$this->rights[3][0] = 173;
|
||||
$this->rights[3][1] = 'Supprimer les notes de frais et deplacements';
|
||||
$this->rights[3][2] = 'd';
|
||||
$this->rights[3][3] = 0;
|
||||
$this->rights[3][4] = 'supprimer';
|
||||
|
||||
$this->rights[4][0] = 174;
|
||||
$this->rights[4][1] = 'Lire toutes les notes de frais';
|
||||
$this->rights[4][2] = 'd';
|
||||
$this->rights[4][3] = 0;
|
||||
$this->rights[4][4] = 'readall';
|
||||
|
||||
$this->rights[5][0] = 178;
|
||||
$this->rights[5][1] = 'Exporter les notes de frais et deplacements';
|
||||
$this->rights[5][2] = 'd';
|
||||
$this->rights[5][3] = 0;
|
||||
$this->rights[5][4] = 'export';
|
||||
|
||||
|
||||
// Menus
|
||||
//-------
|
||||
$this->menu = 1; // This module add menu entries. They are coded into menu manager.
|
||||
|
||||
|
||||
// Exports
|
||||
$r = 0;
|
||||
|
||||
$r++;
|
||||
$this->export_code[$r] = 'trips_'.$r;
|
||||
$this->export_label[$r] = 'ListTripsAndExpenses';
|
||||
$this->export_permission[$r] = array(array("deplacement", "export"));
|
||||
$this->export_fields_array[$r] = array('u.login'=>'Login', 'u.lastname'=>'Lastname', 'u.firstname'=>'Firstname', 'd.rowid'=>"TripId", 'd.type'=>"Type", 'd.km'=>"FeesKilometersOrAmout", 'd.dated'=>"Date", 'd.note_private'=>'NotePrivate', 'd.note_public'=>'NotePublic', 's.nom'=>'ThirdParty');
|
||||
$this->export_TypeFields_array[$r] = array('u.rowid'=>'List:user:name', 'u.login'=>'Text', 'u.lastname'=>'Text', 'u.firstname'=>'Text', 'd.type'=>"Text", 'd.km'=>"Numeric", 'd.dated'=>"Date", 'd.note_private'=>'Text', 'd.note_public'=>'Text', 's.rowid'=>"Numeric", 's.nom'=>'Text');
|
||||
$this->export_entities_array[$r] = array('u.login'=>'user', 'u.lastname'=>'user', 'u.firstname'=>'user', 'd.rowid'=>"trip", 'd.type'=>"trip", 'd.km'=>"trip", 'd.dated'=>"trip", 'd.note_private'=>'trip', 'd.note_public'=>'trip', 's.nom'=>'company');
|
||||
$this->export_dependencies_array[$r] = array('trip'=>'d.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them
|
||||
|
||||
$this->export_sql_start[$r] = 'SELECT DISTINCT ';
|
||||
$this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'user as u';
|
||||
$this->export_sql_end[$r] .= ', '.MAIN_DB_PREFIX.'deplacement as d';
|
||||
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON d.fk_soc = s.rowid';
|
||||
if (!empty($user) && !$user->hasRight('societe', 'client', 'voir')) {
|
||||
$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe_commerciaux as sc ON sc.fk_soc = s.rowid';
|
||||
}
|
||||
$this->export_sql_end[$r] .= ' WHERE d.fk_user = u.rowid';
|
||||
$this->export_sql_end[$r] .= ' AND d.entity IN ('.getEntity('deplacement').')';
|
||||
if (!empty($user) && !$user->hasRight('societe', 'client', 'voir')) {
|
||||
$this->export_sql_end[$r] .= ' AND (sc.fk_user = '.(empty($user) ? 0 : $user->id).' OR d.fk_soc IS NULL)';
|
||||
}
|
||||
|
||||
if (!empty($user)) { // Not defined during migration process
|
||||
$childids = $user->getAllChildIds();
|
||||
$childids[] = $user->id;
|
||||
|
||||
if (!$user->hasRight('deplacement', 'readall') && !$user->hasRight('deplacement', 'lire_tous')) {
|
||||
$this->export_sql_end[$r] .= ' AND d.fk_user IN ('.$this->db->sanitize(implode(',', $childids)).')';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function called when module is enabled.
|
||||
* The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
|
||||
* It also creates data directories
|
||||
*
|
||||
* @param string $options Options when enabling module ('', 'noboxes')
|
||||
* @return int 1 if OK, 0 if KO
|
||||
*/
|
||||
public function init($options = '')
|
||||
{
|
||||
$result = $this->_load_tables('/install/mysql/', 'deplacement');
|
||||
if ($result < 0) {
|
||||
return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
|
||||
}
|
||||
|
||||
// Permissions
|
||||
$this->remove($options);
|
||||
|
||||
$sql = array();
|
||||
|
||||
return $this->_init($sql, $options);
|
||||
}
|
||||
}
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
/**
|
||||
* \defgroup expensereport Module expensereport
|
||||
* \brief Module to manage expense report. Replace old module Deplacement.
|
||||
* \brief Module to manage expense report.
|
||||
* \file htdocs/core/modules/modExpenseReport.class.php
|
||||
* \ingroup expensereport
|
||||
* \brief Description and activation file for the module ExpenseReport
|
||||
|
|
@ -65,7 +65,6 @@ class modExpenseReport extends DolibarrModules
|
|||
// Dependencies
|
||||
$this->hidden = false; // A condition to hide module
|
||||
$this->depends = []; // List of module class names as string that must be enabled if this module is enabled
|
||||
// $this->conflictwith = ["modDeplacement"]; // Deactivate for access on old information
|
||||
$this->requiredby = []; // List of modules id to disable if this one is disabled
|
||||
$this->langfiles = ["companies", "trips"];
|
||||
|
||||
|
|
|
|||
|
|
@ -63,9 +63,6 @@ if (isModEnabled('contract')) {
|
|||
if (isModEnabled('intervention')) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
|
||||
}
|
||||
if (isModEnabled('deplacement')) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
|
||||
}
|
||||
if (isModEnabled('agenda')) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
|
||||
}
|
||||
|
|
@ -1005,13 +1002,6 @@ class doc_generic_project_odt extends ModelePDFProjects
|
|||
'disableamount' => 1,
|
||||
'test' => isModEnabled('shipping') && $user->hasRight('expedition', 'lire')
|
||||
),
|
||||
'trip' => array(
|
||||
'title' => "ListTripAssociatedProject",
|
||||
'class' => 'Deplacement',
|
||||
'table' => 'deplacement',
|
||||
'disableamount' => 1,
|
||||
'test' => isModEnabled('deplacement') && $user->hasRight('deplacement', 'lire')
|
||||
),
|
||||
'expensereport' => array(
|
||||
'title' => "ListExpenseReportsAssociatedProject",
|
||||
'class' => 'ExpenseReportLine',
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
|
|||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
|
||||
|
||||
|
|
@ -414,16 +413,6 @@ class pdf_beluga extends ModelePDFProjects
|
|||
'disableamount' => 1,
|
||||
'test' => isModEnabled('intervention') && $user->hasRight('ficheinter', 'lire'),
|
||||
'lang' => 'interventions'),
|
||||
'trip' => array(
|
||||
'name' => "TripsAndExpenses",
|
||||
'title' => "ListExpenseReportsAssociatedProject",
|
||||
'class' => 'Deplacement',
|
||||
'table' => 'deplacement',
|
||||
'datefieldname' => 'dated',
|
||||
'margin' => 'minus',
|
||||
'disableamount' => 1,
|
||||
'test' => isModEnabled('deplacement') && $user->hasRight('deplacement', 'lire'),
|
||||
'lang' => 'trip'),
|
||||
'expensereport' => array(
|
||||
'name' => "ExpensesReports",
|
||||
'title' => "ListExpenseReportsAssociatedProject",
|
||||
|
|
|
|||
|
|
@ -65,9 +65,6 @@ if (isModEnabled('contract')) {
|
|||
if (isModEnabled('intervention')) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
|
||||
}
|
||||
if (isModEnabled('deplacement')) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
|
||||
}
|
||||
if (isModEnabled('agenda')) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,10 +103,6 @@ if (GETPOST('search_contact') != '') {
|
|||
header("Location: ".DOL_URL_ROOT.'/contact/list.php?mode=search&sall='.urlencode(GETPOST('search_contact')));
|
||||
exit;
|
||||
}
|
||||
if (GETPOST('search_deplacement') != '') {
|
||||
header("Location: ".DOL_URL_ROOT.'/compta/deplacement/list.php?mode=search&sall='.urlencode(GETPOST('search_deplacement')));
|
||||
exit;
|
||||
}
|
||||
if (GETPOST('search_expensereport') != '') {
|
||||
header("Location: ".DOL_URL_ROOT.'/expensereport/list.php?mode=search&sall='.urlencode(GETPOST('search_expensereport')));
|
||||
exit;
|
||||
|
|
|
|||
|
|
@ -45,9 +45,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/usergroups.lib.php';
|
|||
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/user/class/usergroup.class.php';
|
||||
|
||||
if (isModEnabled('deplacement')) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
|
||||
}
|
||||
if (isModEnabled('expensereport')) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,9 +68,6 @@ if (isModEnabled('order')) {
|
|||
if (isModEnabled('contract')) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
|
||||
}
|
||||
if (isModEnabled('deplacement')) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/deplacement/class/deplacement.class.php';
|
||||
}
|
||||
if (isModEnabled('don')) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
|
||||
}
|
||||
|
|
@ -659,20 +656,6 @@ $listofreferent = array(
|
|||
'nototal' => 1,
|
||||
'test' => isModEnabled('mrp') && $user->hasRight('mrp', 'read')
|
||||
),
|
||||
'trip' => array(
|
||||
'name' => "TripsAndExpenses",
|
||||
'title' => "ListExpenseReportsAssociatedProject",
|
||||
'class' => 'Deplacement',
|
||||
'table' => 'deplacement',
|
||||
'datefieldname' => 'dated',
|
||||
'margin' => 'minus',
|
||||
'disableamount' => 1,
|
||||
'urlnew' => DOL_URL_ROOT.'/deplacement/card.php?action=create&projectid='.$id.'&socid='.$socid.'&backtopage='.urlencode($_SERVER['PHP_SELF'].'?id='.$id),
|
||||
'lang' => 'trips',
|
||||
'buttonnew' => 'AddTrip',
|
||||
'testnew' => $user->hasRight('deplacement', 'creer'),
|
||||
'test' => isModEnabled('deplacement') && $user->hasRight('deplacement', 'lire')
|
||||
),
|
||||
'expensereport' => array(
|
||||
'name' => "ExpenseReports",
|
||||
'title' => "ListExpenseReportsAssociatedProject",
|
||||
|
|
|
|||
Loading…
Reference in a new issue