Skip to content

Commit

Permalink
#29 [AdminConf] add: missing numering module ref
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-eoxia committed Nov 2, 2022
1 parent b96b101 commit a92cc65
Show file tree
Hide file tree
Showing 9 changed files with 238 additions and 212 deletions.
28 changes: 12 additions & 16 deletions admin/certificate.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@

// Initialize objects
// Technical objets
$certificate = new Certificate($db);

// View objects
$form = new Form($db);
$object = new Certificate($db);

// Access control
if (!$user->admin) accessforbidden();
Expand All @@ -66,6 +63,9 @@
* View
*/

// Initialize view objects
$form = new Form($db);

$help_url = 'FR:Module_DoliSIRH';
$title = $langs->trans("Certificate");
$morejs = array("/dolisirh/js/dolisirh.js.php");
Expand All @@ -76,17 +76,17 @@
// Subheader
$linkback = '<a href="'.($backtopage ?: DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>';

print load_fiche_titre($title, $linkback, 'object_'.$certificate->picto);
print load_fiche_titre($title, $linkback, 'object_'.$object->picto);

// Configuration header
$head = dolisirhAdminPrepareHead();
print dol_get_fiche_head($head, 'certificate', $title, -1, 'dolisirh_red@dolisirh');

print load_fiche_titre($pictos[$type] . $langs->trans($type), '', '', 0, $langs->trans($type));
print load_fiche_titre($langs->trans("CertificateManagement"), '', 'object_'.$object->picto);
print '<hr>';

/*
* Numbering module
* Numbering module Certificate
*/

print load_fiche_titre($langs->trans("DoliSIRHCertificateNumberingModule"), '', '');
Expand All @@ -102,7 +102,7 @@

clearstatcache();

$dir = dol_buildpath("/custom/dolisirh/core/modules/dolisirh/dolisirh/certificat/");
$dir = dol_buildpath("/custom/dolisirh/core/modules/dolisirh/certificate/");
if (is_dir($dir)) {
$handle = opendir($dir);
if (is_resource($handle)) {
Expand Down Expand Up @@ -140,18 +140,13 @@
print img_picto($langs->trans("Activated"), 'switch_on');
}
else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&value='.preg_replace('/\.php$/', '', $file).'&const='.$module->scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&value='.preg_replace('/\.php$/', '', $file).'&const='.$module->scandir.'&label='.urlencode($module->name).'&token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
}
print '</td>';

// Example for listing risks action
// Example for certificate
$htmltooltip = '' . $langs->trans("Version") . ': <b>' . $module->getVersion() . '</b><br>';

require_once __DIR__ . '/../class/dolisirh/'.$type.'document.class.php';
$classdocumentname = $type.'Document';
$object_document = new $classdocumentname($db);

$nextval = $module->getNextValue($object_document);
$nextval = $module->getNextValue($object);
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= $langs->trans("NextValue").': ';
if ($nextval) {
Expand All @@ -177,6 +172,7 @@
closedir($handle);
}
}
print '</table>';

// Page end
print dol_get_fiche_end();
Expand Down
10 changes: 5 additions & 5 deletions admin/dolisirhdocuments.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@
print dol_get_fiche_head($head, 'dolisirhdocuments', $title, -1, 'dolisirh_red@dolisirh');

foreach ($types as $type => $documentType) {
print load_fiche_titre($pictos[$type] . $langs->trans($type), '', '', 0, $langs->trans($type));
print load_fiche_titre($langs->trans($type), '', 'object_'.strtolower($type).'@dolisirh', 0, $langs->trans($type));
print '<hr>';

$trad = 'DoliSIRH' . $type . 'DocumentNumberingModule';
Expand Down Expand Up @@ -272,7 +272,7 @@
print img_picto($langs->trans("Activated"), 'switch_on');
}
else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&value='.preg_replace('/\.php$/', '', $file).'&const='.$module->scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&value='.preg_replace('/\.php$/', '', $file).'&const='.$module->scandir.'&label='.urlencode($module->name).'&token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
}
print '</td>';

Expand Down Expand Up @@ -380,12 +380,12 @@
// Active
print '<td class="center">';
if (in_array($name, $def)) {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;const='.$module->scandir.'&amp;label='.urlencode($module->name).'&type='.preg_split('/_/',$name)[0].'">';
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;const='.$module->scandir.'&amp;label='.urlencode($module->name).'&type='.preg_split('/_/',$name)[0].'&token='.newToken().'">';
print img_picto($langs->trans("Enabled"), 'switch_on');
print '</a>';
}
else {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;value='.$name.'&amp;const='.$module->scandir.'&amp;label='.urlencode($module->name).'&type='.preg_split('/_/',$name)[0].'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;value='.$name.'&amp;const='.$module->scandir.'&amp;label='.urlencode($module->name).'&type='.preg_split('/_/',$name)[0].'&token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
}
print "</td>";

Expand All @@ -396,7 +396,7 @@
print img_picto($langs->trans("Default"), 'on');
}
else {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;value='.$name.'&amp;const='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;value='.$name.'&amp;const='.$module->scandir.'&amp;label='.urlencode($module->name).'&token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
}
print '</td>';

Expand Down
104 changes: 98 additions & 6 deletions admin/timesheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@

// Initialize objects
// Technical objets
$timesheet = new TimeSheet($db);

// View objects
$form = new Form($db);
$object = new TimeSheet($db);

// Access control
if (!$user->admin) accessforbidden();
Expand All @@ -66,6 +63,9 @@
* View
*/

// Initialize view objects
$form = new Form($db);

$help_url = 'FR:Module_DoliSIRH';
$title = $langs->trans("TimeSheet");
$morejs = array("/dolisirh/js/dolisirh.js.php");
Expand All @@ -76,14 +76,106 @@
// Subheader
$linkback = '<a href="'.($backtopage ?: DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1').'">'.$langs->trans("BackToModuleList").'</a>';

print load_fiche_titre($title, $linkback, 'object_'.$timesheet->picto);
print load_fiche_titre($title, $linkback, 'object_'.$object->picto);

// Configuration header
$head = dolisirhAdminPrepareHead();
print dol_get_fiche_head($head, 'timesheet', $title, -1, 'dolisirh_red@dolisirh');

print load_fiche_titre($langs->trans("TimeSheetManagement"), '', 'object_'.$object->picto);
print '<hr>';

/*
* Numbering module TimeSheet
*/

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

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

clearstatcache();

$dir = dol_buildpath("/custom/dolisirh/core/modules/dolisirh/timesheet/");
if (is_dir($dir)) {
$handle = opendir($dir);
if (is_resource($handle)) {
while (($file = readdir($handle)) !== false ) {
if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) {
$filebis = $file;

$classname = preg_replace('/\.php$/', '', $file);
$classname = preg_replace('/-.*$/', '', $classname);

if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') {
// Charging the numbering class
require_once $dir.$filebis;

$module = new $classname($db);

if ($module->isEnabled()) {
print '<tr class="oddeven"><td>';
print $langs->trans($module->name);
print "</td><td>";
print $module->info();
print '</td>';

// Show example of numbering module
print '<td class="nowrap">';
$tmp = $module->getExample();
if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
else print $tmp;
print '</td>';

print '<td class="center">';
$confType = 'DOLISIRH_TIMESHEET_ADDON';
if ($conf->global->$confType == $file || $conf->global->$confType.'.php' == $file) {
print img_picto($langs->trans("Activated"), 'switch_on');
}
else {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&value='.preg_replace('/\.php$/', '', $file).'&const='.$module->scandir.'&label='.urlencode($module->name).'&token='.newToken().'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
}
print '</td>';

// Example for timesheet
$htmltooltip = '' . $langs->trans("Version") . ': <b>' . $module->getVersion() . '</b><br>';
$nextval = $module->getNextValue($object);
if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval
$htmltooltip .= $langs->trans("NextValue").': ';
if ($nextval) {
if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
$nextval = $langs->trans($nextval);
$htmltooltip .= $nextval.'<br>';
} else {
$htmltooltip .= $langs->trans($module->error).'<br>';
}
}

print '<td class="center">';
print $form->textwithpicto('', $htmltooltip, 1, 0);
if ($conf->global->$confType.'.php' == $file) { // If module is the one used, we show existing errors
if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1);
}
print '</td>';
print "</tr>";
}
}
}
}
closedir($handle);
}
}
print '</table>';

//Time spent
print load_fiche_titre($langs->transnoentities("TimeSheetData"), '', 'object_timesheet@dolisirh');
print load_fiche_titre($langs->transnoentities("TimeSheetData"), '', '');

print '<table class="noborder centpercent">';

Expand Down
139 changes: 0 additions & 139 deletions core/modules/dolisirh/certificate/mod_certificate_advanced.php

This file was deleted.

Loading

0 comments on commit a92cc65

Please sign in to comment.