Skip to content

Commit

Permalink
Evarisk#268 [Admin] clean: admin files
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-eoxia committed Sep 13, 2024
1 parent 9e107aa commit 878bb47
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 117 deletions.
17 changes: 5 additions & 12 deletions admin/publicinterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
die('Include of dolicar main fails');
}

// Load Dolibarr libraries
require_once DOL_DOCUMENT_ROOT . '/core/lib/admin.lib.php';

// Load DoliCar libraries
require_once __DIR__ . '/../lib/dolicar.lib.php';

Expand All @@ -40,8 +43,7 @@
saturne_load_langs();

// Get parameters
$action = GETPOST('action', 'alpha');
$backtopage = GETPOST('backtopage', 'alpha');
$action = GETPOST('action', 'alpha');

// Initialize view objects
$form = new Form($db);
Expand Down Expand Up @@ -74,7 +76,7 @@
saturne_header(0,'', $title, $helpUrl);

// Subheader
$linkBack = '<a href="' . ($backtopage ?: DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1') . '">' . $langs->trans('BackToModuleList') . '</a>';
$linkBack = '<a href="' . DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1' . '">' . $langs->trans('BackToModuleList') . '</a>';
print load_fiche_titre($title, $linkBack, 'title_setup');

// Configuration header
Expand Down Expand Up @@ -108,15 +110,6 @@
print ajax_constantonoff('DOLICAR_PUBLIC_INTERFACE_USE_SIGNATORY');
print '</td></tr>';

print '<tr class="oddeven"><td>';
print $langs->transnoentities('PublicInterfaceUser');
print '</td><td>';
print $langs->transnoentities('PublicInterfaceUserDescription');
print '</td>';
print '<td class="minwidth400">';
print img_picto($langs->trans('User'), 'user', 'class="pictofixedwidth"') . $form->select_dolusers(getDolGlobalInt('DOLICAR_PUBLIC_INTERFACE_USER'), 'public_interface_user_id', 1, null, 0, '', '', '0', 0, 0, '', 0, '','minwidth100 maxwidth300');
print '</td></tr>';

print '<tr class="oddeven"><td>';
print $langs->transnoentities('MaxArrivalMileage');
print '</td><td>';
Expand Down
64 changes: 25 additions & 39 deletions admin/quickcreation.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
require_once __DIR__ . '/../lib/dolicar.lib.php';

// Global variables definitions
global $conf, $db, $langs, $user;
global $conf, $db, $langs, $moduleNameLowerCase, $user;

// Load translation files required by the page
saturne_load_langs();
Expand All @@ -54,50 +54,36 @@

// Subheader
$linkBack = '<a href="'. DOL_URL_ROOT . '/admin/modules.php?restore_lastsearch_values=1' . '">' . $langs->trans('BackToModuleList') . '</a>';

print load_fiche_titre($title, $linkBack, 'title_setup');

// Configuration header
$head = dolicar_admin_prepare_head();
print dol_get_fiche_head($head, 'quickcreation', $title, -1, 'dolicar_color@dolicar');

print load_fiche_titre($langs->transnoentities('Config'), '', '');

print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>' . $langs->transnoentities('Parameters') . '</td>';
print '<td class="center">' . $langs->transnoentities('Status') . '</td>';
print '</tr>';

print '<tr class="oddeven">';
print '<td>' . $langs->transnoentities('AutomaticContactCreation') . '</td>';
print '<td class="center">';
print ajax_constantonoff('DOLICAR_AUTOMATIC_CONTACT_CREATION');
print '</td>';
print '</tr>';

print '<tr class="oddeven">';
print '<td>' . $langs->transnoentities('ThirdpartyQuickCreation') . '</td>';
print '<td class="center">';
print ajax_constantonoff('DOLICAR_THIRDPARTY_QUICK_CREATION');
print '</td>';
print '</tr>';

print '<tr class="oddeven">';
print '<td>' . $langs->transnoentities('ContactQuickCreation') . '</td>';
print '<td class="center">';
print ajax_constantonoff('DOLICAR_CONTACT_QUICK_CREATION');
print '</td>';
print '</tr>';

print '<tr class="oddeven">';
print '<td>' . $langs->transnoentities('ProjectQuickCreation') . '</td>';
print '<td class="center">';
print ajax_constantonoff('DOLICAR_PROJECT_QUICK_CREATION');
print '</td>';
print '</tr>';

print '</table>';
$constArray[$moduleNameLowerCase] = [
'AutomaticContactCreation' => [
'name' => 'AutomaticContactCreation',
'description' => 'AutomaticContactCreationDescription',
'code' => 'DOLICAR_AUTOMATIC_CONTACT_CREATION'
],
'ThirdpartyQuickCreation' => [
'name' => 'ThirdPartyQuickCreation',
'description' => 'ThirdPartyQuickCreationDescription',
'code' => 'DOLICAR_THIRDPARTY_QUICK_CREATION'
],
'ContactQuickCreation' => [
'name' => 'ContactQuickCreation',
'description' => 'ContactQuickCreationDescription',
'code' => 'DOLICAR_CONTACT_QUICK_CREATION'
],
'ProjectQuickCreation' => [
'name' => 'ProjectQuickCreation',
'description' => 'ProjectQuickCreationDescription',
'code' => 'DOLICAR_PROJECT_QUICK_CREATION'
]
];

require_once __DIR__ . '/../../saturne/core/tpl/admin/object/object_const_view.tpl.php';

// Page end
print dol_get_fiche_end();
Expand Down
50 changes: 6 additions & 44 deletions admin/registrationcertificate.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

/**
* \file dolicar/admin/setup.php
* \file dolicar/admin/registrationcertificate.php
* \ingroup dolicar
* \brief DoliCar registration certificate config page
*/
Expand Down Expand Up @@ -69,23 +69,6 @@
$head = dolicar_admin_prepare_head();
print dol_get_fiche_head($head, 'registrationcertificate', $title, -1, 'dolicar_color@dolicar');

print load_fiche_titre($langs->transnoentities('ImmatriculationAPIConfig'), '', '');

print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>' . $langs->transnoentities('Parameters') . '</td>';
print '<td class="center">' . $langs->transnoentities('Value') . '</td>';
print '</tr>';

print '<tr class="oddeven">';
print '<td>' . $langs->transnoentities('RemainingRequests') . '</td>';
print '<td class="center">';
print '<b>' . (getDolGlobalInt('DOLICAR_API_REMAINING_REQUESTS_COUNTER') ?? 0) . '</b>';
print '</td>';
print '</tr>';

print '</table>';

print load_fiche_titre($langs->transnoentities('RegistrationCertificateFieldsConfig'), '', '');

print '<table class="noborder centpercent">';
Expand All @@ -97,39 +80,18 @@

foreach ($object->fields as $registrationCertificateCode => $registrationCertificateField) {
if ($registrationCertificateField['config'] == 1) {
print '<tr class="oddeven"><td>' . $langs->transnoentities('Display') . ' ' . $langs->transnoentities($registrationCertificateField['label']) . '</td>';
print '<td class="center">';
print '<tr class="oddeven"><td>';
print $langs->transnoentities('Display') . ' ' . $langs->transnoentities($registrationCertificateField['label']);
print '</td><td class="center">';
print ajax_constantonoff('DOLICAR_' . dol_strtoupper($registrationCertificateCode) . '_VISIBLE');
print '</td>';
print '<td class="center">';
print '</td><td class="center">';
print $form->textwithpicto('', $langs->transnoentities('ShowRegistrationCertificateFieldHelp'));
print '</td>';
print '</tr>';
print '</td></tr>';
}
}

print '</table>';

print load_fiche_titre($langs->trans('Config'), '', '');

print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>' . $langs->trans('Parameters') . '</td>';
print '<td>' . $langs->trans('Description') . '</td>';
print '<td class="center">' . $langs->trans('Status') . '</td>';
print '</tr>';

print '<tr class="oddeven"><td>' . $langs->trans('HideObjectDetsDolicarDetails') . '</td>';
print '<td>';
print $langs->trans('HideObjectDetsDolicarDetailsDescription');
print '</td>';
print '<td class="center">';
print ajax_constantonoff('DOLICAR_HIDE_OBJECT_DET_DOLICAR_DETAILS');
print '</td>';
print '</tr>';

print '</table>';

// Page end
print dol_get_fiche_end();
llxFooter();
Expand Down
20 changes: 15 additions & 5 deletions admin/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,21 @@
$head = dolicar_admin_prepare_head();
print dol_get_fiche_head($head, 'settings', $title, -1, 'dolicar_color@dolicar');

// Configuration header
print '<div style="text-indent: 1em"><i class="fas fa-2x fa-calendar-alt" style="padding: 10px"></i>' . $langs->trans('AgendaModuleRequired') . '</div>';
print '<div style="text-indent: 1em"><i class="fas fa-2x fa-tools" style="padding: 10px"></i>' . $langs->trans('HowToSetupOtherModules') . '<a href=' . '"../../../admin/modules.php">' . $langs->trans('ConfigMyModules') . '</a></div>';
print '<div style="text-indent: 1em"><i class="fas fa-2x fa-globe" style="padding: 10px"></i>' . $langs->trans('AvoidLogoProblems') . '<a href="' . $langs->trans('LogoHelpLink') . '">' . $langs->trans('LogoHelpLink') . '</a></div>';
print '<div style="text-indent: 1em"><i class="fab fa-2x fa-css3-alt" style="padding: 10px"></i>' . $langs->trans('HowToSetupIHM') . '<a href=' . '"../../../admin/ihm.php">' . $langs->trans('ConfigIHM') . '</a></div>';
print load_fiche_titre($langs->transnoentities('ImmatriculationAPIConfig'), '', '');

print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<td>' . $langs->transnoentities('Parameters') . '</td>';
print '<td class="center">' . $langs->transnoentities('Value') . '</td>';
print '</tr>';

print '<tr class="oddeven"><td>';
print $langs->transnoentities('RemainingRequests');
print '</td><td class="center">';
print '<b>' . (getDolGlobalInt('DOLICAR_API_REMAINING_REQUESTS_COUNTER') ?? 0) . '</b>';
print '</td></tr>';

print '</table>';

// Page end
print dol_get_fiche_end();
Expand Down
2 changes: 1 addition & 1 deletion class/registrationcertificatefr.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -425,14 +425,14 @@ public function getLinkedObject(string $objectType)
*
* @return array array of linked objects
*/
public function getLinkedObjects(): array
{
$linkedObjects = [];
$objectTypes = ['propal', 'commande', 'facture'];
foreach ($objectTypes as $objectType) {
$linkedObject = $this->getLinkedObject($objectType);
if (is_array($linkedObject) && !empty($linkedObject)) {
$linkedObjects[] = $linkedObject;
public function getLinkedObjects(): array
}
}

Expand Down
3 changes: 2 additions & 1 deletion core/modules/modDoliCar.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ public function __construct($db)
$i++ => ['DOLICAR_API_REQUESTS_COUNTER', 'integer', 0, '', 0, 'current'],

// CONST PUBLIC INTERFACE
$i++ => array('DOLICAR_PUBLIC_MAX_ARRIVAL_MILEAGE', 'integer', 1000, '', 0, 'current'),
$i++ => ['DOLICAR_PUBLIC_INTERFACE_USE_SIGNATORY', 'integer', 0, '', 0, 'current'],
$i++ => ['DOLICAR_PUBLIC_MAX_ARRIVAL_MILEAGE', 'integer', 1000, '', 0, 'current'],

// CONST MODULE
$i++ => ['DOLICAR_VERSION','chaine', $this->version, '', 0, 'current'],
Expand Down
32 changes: 19 additions & 13 deletions langs/fr_FR/dolicar.lang
Original file line number Diff line number Diff line change
Expand Up @@ -42,26 +42,32 @@ Bicycle = Vélo
# Config page - Page d'administration
#

# Public interface - Interface publique
OfPublicVehicleLogBook = du carnet de bord publique du véhicule
MaxArrivalMileage = Nombre maximal de kilomètre d'arrivé
MaxArrivalMileageDescription = Cette option permet de configurer le nombre maximal de kilomètre d'arrivé qu'un conducteur peut saisir lors de l'enregistrement d'une donné dans le carnet de bord d'un véhicule <br> (par défaut 1000 km)

# RegistrationCertificateFr - Carte grise
ImmatriculationAPIConfig = Configuration de l'API immatriculationapi.com
RemainingRequests = Jetons de recherche de plaque d'immatriculation restants : %s
RegistrationCertificateFieldsConfig = Configuration des champs de la carte grise
Display = Afficher
ShowRegistrationCertificateFieldHelp = Afficher/Cacher ce champ sur la carte grise
ShowRegistrationCertificateFieldHelp = Afficher/cacher ce champ sur la carte grise
HideObjectDetsDolicarDetails = Cacher le détail de Dolicar des lignes d'objets
HideObjectDetsDolicarDetailsDescription = Cette option permet de cacher/afficher le kilométrage, la plaque d'immatriculation et le modèle de véhicule sur les lignes des factures/propales/commandes

# QuickCreation - Ajout rapide
QuickCreation = Ajout rapide
AutomaticContactCreation = Création automatique de contact à la création du tiers
ThirdpartyQuickCreation = Création rapide de tiers
ContactQuickCreation = Création rapide de contact
ProjectQuickCreation = Création rapide de projet
QuickCreation = Ajout rapide
AutomaticContactCreation = Création automatique de contact à la création du tiers
AutomaticContactCreationDescription = Cette option permet de créer automatiquement un contact lors de la création d'un tiers
ThirdPartyQuickCreation = Création rapide de tiers
ThirdPartyQuickCreationDescription = Cette option permet de créer rapidement un tiers
ContactQuickCreation = Création rapide de contact
ContactQuickCreationDescription = Cette option permet de créer rapidement un contact
ProjectQuickCreation = Création rapide de projet
ProjectQuickCreationDescription = Cette option permet de créer rapidement un projet

# Public interface - Interface publique
OfPublicVehicleLogBook = du carnet de bord publique du véhicule
MaxArrivalMileage = Nombre maximal de kilomètre d'arrivé
MaxArrivalMileageDescription = Cette option permet de configurer le nombre maximal de kilomètre d'arrivé qu'un conducteur peut saisir lors de l'enregistrement d'une donné dans le carnet de bord d'un véhicule <br> (par défaut 1000 km)

# Setup - Réglages
ImmatriculationAPIConfig = Configuration de l'API immatriculationapi.com
RemainingRequests = Jetons de recherche de plaque d'immatriculation restants : %s



Expand Down
3 changes: 1 addition & 2 deletions public/agenda/public_vehicle_logbook.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@
}
}

$user->fetch(getDolGlobalInt('DOLICAR_PUBLIC_INTERFACE_USER'));
if ($isModEnabledDigiquali) {
$controls = saturne_fetch_all_object_type('Control', 'DESC', 't.control_date', 1, 0, ['customsql' => 't.rowid = ee.fk_target AND t.status = ' . Control::STATUS_LOCKED], 'AND', false, true, false, ' LEFT JOIN ' . MAIN_DB_PREFIX . 'element_element as ee on ee.sourcetype = "productbatch" AND ee.fk_source = ' . $id . ' AND ee.targettype = "digiquali_control" AND ee.fk_target = t.rowid');
if (is_array($controls) && !empty($controls)) {
Expand Down Expand Up @@ -182,7 +181,7 @@
$actionComm->datep = dol_stringtotime(GETPOST('start_date_and_hour'));
$actionComm->datef = dol_stringtotime(GETPOST('end_date_and_hour'));
$actionComm->fk_element = $productLot->id;
$actionComm->userownerid = $user->id;
$actionComm->userownerid = 0;
$actionComm->percentage = -1;

// The client can set HTTP header information (like $_SERVER['HTTP_CLIENT_IP'] ...) to any arbitrary value it wants. As such it's far more reliable to use $_SERVER['REMOTE_ADDR'], as this cannot be set by the user
Expand Down

0 comments on commit 878bb47

Please sign in to comment.