Skip to content

Commit

Permalink
#230 [Certificate] add: clean lib and admin
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-eoxia committed Jul 6, 2023
1 parent b2957d1 commit 9ebc0da
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 70 deletions.
15 changes: 12 additions & 3 deletions admin/dolisirhdocuments.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,18 @@
require_once $dir.'/'.$file;
$module = new $classname($db);

$modulequalified = 1;
if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
// Active
print '<td class="center">';

if (in_array($name, $def)) {
print '<a href="' . $_SERVER['PHP_SELF'] . '?action=del&value=' . $name . '&const=' . $module->scandir . '&label=' . urlencode($module->name) . '&type=' . explode('_', $name)[0] . '&token=' . newToken() . '">';
print img_picto($langs->trans('Enabled'), 'switch_on');
} else {
print '<a href="' . $_SERVER['PHP_SELF'] . '?action=set&value=' . $name . '&const=' . $module->scandir . '&label=' . urlencode($module->name) . '&type=' . explode('_', $name)[0] . '&token=' . newToken() . '">';
print img_picto($langs->trans('Disabled'), 'switch_off');
}
print '</a>';
print '</td>';

if ($modulequalified) {
print '<tr class="oddeven"><td>';
Expand Down
2 changes: 1 addition & 1 deletion class/dolisirhdocuments.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hided

$modelpath = "custom/dolisirh/core/modules/dolisirh/dolisirhdocuments/".$this->element."/";

$result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams['object']);
$result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams);

$this->call_trigger(strtoupper($this->type).'_GENERATE', $moreparams['user']);

Expand Down
2 changes: 1 addition & 1 deletion langs/fr_FR/dolisirh.lang
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,10 @@ DoliSIRHCertificateStandardModel = Renvoie le numéro sous la forme CERTyymm-nnn

# Data - Donnée
Certificate = Certificat
TheCertificate = le certificat
NewCertificate = Nouveau certificat
ModifyCertificate = Modifer le certificat
CertificateList = Liste des certificats
CertificateManagement = Gestion des certificats

#
# CertificateDocument - Document certificat
Expand Down
12 changes: 6 additions & 6 deletions lib/dolisirh.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ function dolisirhAdminPrepareHead(): array
$head[$h][2] = 'projecttasks';
$h++;

$head[$h][0] = dol_buildpath("/dolisirh/admin/timesheet.php", 1);
$head[$h][1] = '<i class="fas fa-calendar-check pictofixedwidth"></i>' . $langs->trans("TimeSheet");
$head[$h][0] = dol_buildpath('/saturne/admin/object.php', 1) . '?module_name=DoliSIRH&object_type=timesheet';
$head[$h][1] = '<i class="fas fa-calendar-check pictofixedwidth"></i>' . $langs->trans('TimeSheet');
$head[$h][2] = 'timesheet';
$h++;

// $head[$h][0] = dol_buildpath("/dolisirh/admin/certificate.php", 1);
// $head[$h][1] = '<i class="fas fa-user-graduate pictofixedwidth"></i>' . $langs->trans("Certificate");
// $head[$h][2] = 'certificate';
// $h++;
$head[$h][0] = dol_buildpath('/saturne/admin/object.php', 1) . '?module_name=DoliSIRH&object_type=certificate';
$head[$h][1] = '<i class="fas fa-user-graduate pictofixedwidth"></i>' . $langs->trans("Certificate");
$head[$h][2] = 'certificate';
$h++;

$head[$h][0] = dol_buildpath("/dolisirh/admin/dolisirhdocuments.php", 1);
$head[$h][1] = '<i class="fas fa-file-alt pictofixedwidth"></i>' . $langs->trans("YourDocuments");
Expand Down
67 changes: 8 additions & 59 deletions lib/dolisirh_certificate.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,71 +17,20 @@

/**
* \file lib/dolisirh_certificate.lib.php
* \ingroup dolisirh
* \brief Library files with common functions for Certificate
* \ingroup dolimeet
* \brief Library files with common functions for Certificate.
*/

// Load Saturne Libraries.
require_once __DIR__ . '/../../saturne/lib/object.lib.php';

/**
* Prepare array of tabs for Certificate
* Prepare certificate pages header
*
* @param Certificate $object Certificate
* @return array Array of tabs
*/
function certificatePrepareHead($object)
{
global $db, $langs, $conf;

$langs->load("dolisirh@dolisirh");

$h = 0;
$head = array();

$head[$h][0] = dol_buildpath("/dolisirh/view/certificate/certificate_card.php", 1).'?id='.$object->id;
$head[$h][1] = '<i class="fas fa-info-circle pictofixedwidth"></i>' . $langs->trans("Card");
$head[$h][2] = 'card';
$h++;

if (isset($object->fields['note_public']) || isset($object->fields['note_private'])) {
$nbNote = 0;
if (!empty($object->note_private)) {
$nbNote++;
}
if (!empty($object->note_public)) {
$nbNote++;
}
$head[$h][0] = dol_buildpath('/dolisirh/view/certificate/certificate_note.php', 1).'?id='.$object->id;
$head[$h][1] = '<i class="fas fa-comment pictofixedwidth"></i>' . $langs->trans('Notes');
if ($nbNote > 0) {
$head[$h][1] .= (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '<span class="badge marginleftonlyshort">'.$nbNote.'</span>' : '');
}
$head[$h][2] = 'note';
$h++;
}

// require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
// require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
// $upload_dir = $conf->dolisirh->dir_output."/certificate/".dol_sanitizeFileName($object->ref);
// $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
// $nbLinks = Link::count($db, $object->element, $object->id);
// $head[$h][0] = dol_buildpath("/dolisirh/view/certificate/certificate_document.php", 1).'?id='.$object->id;
// $head[$h][1] = $langs->trans('Documents');
// if (($nbFiles + $nbLinks) > 0) {
// $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
// }
// $head[$h][2] = 'document';
// $h++;

$head[$h][0] = dol_buildpath("/dolisirh/view/certificate/certificate_agenda.php", 1).'?id='.$object->id;
$head[$h][1] = '<i class="fas fa-calendar-alt pictofixedwidth"></i>' . $langs->trans("Events");
$head[$h][2] = 'agenda';
$h++;

$head[$h][0] = dol_buildpath("/dolisirh/view/certificate/certificate_attendants.php", 1) . '?id=' . $object->id;
$head[$h][1] = '<i class="fas fa-file-signature pictofixedwidth"></i>' . $langs->trans("Attendants");
$head[$h][2] = 'attendants';
$h++;

complete_head_from_modules($conf, $langs, $object, $head, $h, 'certificate@dolisirh');

return $head;
}
return saturne_object_prepare_head($object, true);
}

0 comments on commit 9ebc0da

Please sign in to comment.