Skip to content

Commit

Permalink
Merge pull request #481 from Evarisk/develop
Browse files Browse the repository at this point in the history
1.2.1
  • Loading branch information
nicolas-eoxia authored Dec 27, 2023
2 parents 3304d76 + 8885d0d commit 67b4ffe
Show file tree
Hide file tree
Showing 9 changed files with 140 additions and 132 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@
## Informations

- Numéro du module : 436304
- Dernière mise à jour : 13/09/2023
- Dernière mise à jour : 22/12/2023
- Éditeur : [Evarisk](https://evarisk.com)
- Thème : Eldy Menu
- Licence : GPLv3
- Disponible sur : Windows - MacOS - Linux

## Version

- Version : 1.2.0
- Compatibilité : Dolibarr 16.0.0 - 18.0.0
- Saturne framework : 1.1.2
- Version : 1.2.1
- PHP : 7.4.33
- Compatibilité : Dolibarr 16.0.0 - 18.0.4
- Saturne framework : 1.2.1

## Liens

Expand Down
170 changes: 88 additions & 82 deletions class/actions_dolimeet.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,92 +205,94 @@ public function printCommonFooter(array $parameters): int
$id = GETPOST('id');
$type = GETPOST('type');

// Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
$offset = $limit * $page;

require_once __DIR__ . '/' . $type . '.class.php';

$classname = ucfirst($type);
$object = new $classname($this->db);

$sessions = $object->fetchAll('', '', 0, 0, ['customsql' => 't.type = ' . "'" . $type . "'"]);
$sessionArrays = [];
if (is_array($sessions) && !empty($sessions)) {
foreach ($sessions as $session) {
$sessionArrays[$session->id] = $session->ref;
if ($type == 'meeting' || $type == 'audit' || $type == 'trainingsession') {
// Load variable for pagination
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
$page = 0;
} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
$offset = $limit * $page;

require_once __DIR__ . '/' . $type . '.class.php';

$classname = ucfirst($type);
$object = new $classname($this->db);

$sessions = $object->fetchAll('', '', 0, 0, ['customsql' => 't.type = ' . "'" . $type . "'"]);
$sessionArrays = [];
if (is_array($sessions) && !empty($sessions)) {
foreach ($sessions as $session) {
$sessionArrays[$session->id] = $session->ref;
}
}
}

$category = new Categorie($this->db);
$category->fetch($id);

$sessionCategories = $category->getObjectsInCateg('session', 0, $limit, $offset);
$out = '<br>';

$out .= '<form method="post" action="' . $_SERVER['PHP_SELF'] . '?id=' . $id . '&type=' . $type . '">';
$out .= '<input type="hidden" name="token" value="' . newToken() . '">';
$out .= '<input type="hidden" name="action" value="addintocategory">';

$out .= '<table class="noborder centpercent">';
$out .= '<tr class="liste_titre"><td>';
$out .= $langs->trans('AddObjectIntoCategory') . ' ';
$out .= $form::selectarray('element_id', $sessionArrays, '', 1);
$out .= '<input type="submit" class="button buttongen" value="' . $langs->trans('ClassifyInCategory') . '"></td>';
$out .= '</tr>';
$out .= '</table>';
$out .= '</form>';

$out .= '<br>';

$out .= load_fiche_titre($langs->transnoentities($classname), '', 'object_' . $object->picto);
$out .= '<table class="noborder centpercent">';
$out .= '<tr class="liste_titre"><td colspan="3">' . $langs->trans('Ref') . '</td></tr>';

if (is_array($sessionCategories) && !empty($sessionCategories)) {
// Form to add record into a category
if (count($sessionCategories) > 0) {
$i = 0;
foreach ($sessionCategories as $session) {
$i++;
if ($i > $limit) break;

$out .= '<tr class="oddeven">';
$out .= '<td class="nowrap">';
$session->picto = $object->picto;
$session->element = $type;
$out .= $session->getNomUrl(1);
$out .= '</td>';
// Link to delete from category
$out .= '<td class="right">';
if ($user->rights->categorie->creer) {
$out .= '<a href="' . $_SERVER['PHP_SELF'] . '?action=delintocategory&id=' . $id . '&type=' . $type . '&element_id=' . $session->id . '&token=' . newToken() . '">';
$out .= $langs->trans('DeleteFromCat');
$out .= img_picto($langs->trans('DeleteFromCat'), 'unlink', '', false, 0, 0, '', 'paddingleft');
$out .= '</a>';
$category = new Categorie($this->db);
$category->fetch($id);

$sessionCategories = $category->getObjectsInCateg('session', 0, $limit, $offset);
$out = '<br>';

$out .= '<form method="post" action="' . $_SERVER['PHP_SELF'] . '?id=' . $id . '&type=' . $type . '">';
$out .= '<input type="hidden" name="token" value="' . newToken() . '">';
$out .= '<input type="hidden" name="action" value="addintocategory">';

$out .= '<table class="noborder centpercent">';
$out .= '<tr class="liste_titre"><td>';
$out .= $langs->trans('AddObjectIntoCategory') . ' ';
$out .= $form::selectarray('element_id', $sessionArrays, '', 1);
$out .= '<input type="submit" class="button buttongen" value="' . $langs->trans('ClassifyInCategory') . '"></td>';
$out .= '</tr>';
$out .= '</table>';
$out .= '</form>';

$out .= '<br>';

$out .= load_fiche_titre($langs->transnoentities($classname), '', 'object_' . $object->picto);
$out .= '<table class="noborder centpercent">';
$out .= '<tr class="liste_titre"><td colspan="3">' . $langs->trans('Ref') . '</td></tr>';

if (is_array($sessionCategories) && !empty($sessionCategories)) {
// Form to add record into a category
if (count($sessionCategories) > 0) {
$i = 0;
foreach ($sessionCategories as $session) {
$i++;
if ($i > $limit) break;

$out .= '<tr class="oddeven">';
$out .= '<td class="nowrap">';
$session->picto = $object->picto;
$session->element = $type;
$out .= $session->getNomUrl(1);
$out .= '</td>';
// Link to delete from category
$out .= '<td class="right">';
if ($user->rights->categorie->creer) {
$out .= '<a href="' . $_SERVER['PHP_SELF'] . '?action=delintocategory&id=' . $id . '&type=' . $type . '&element_id=' . $session->id . '&token=' . newToken() . '">';
$out .= $langs->trans('DeleteFromCat');
$out .= img_picto($langs->trans('DeleteFromCat'), 'unlink', '', false, 0, 0, '', 'paddingleft');
$out .= '</a>';
}
$out .= '</td>';
$out .= '</tr>';
}
$out .= '</td>';
$out .= '</tr>';
} else {
$out .= '<tr class="oddeven"><td colspan="2" class="opacitymedium">' . $langs->trans('ThisCategoryHasNoItems') . '</td></tr>';
}
} else {
$out .= '<tr class="oddeven"><td colspan="2" class="opacitymedium">' . $langs->trans('ThisCategoryHasNoItems') . '</td></tr>';
}
} else {
$out .= '<tr class="oddeven"><td colspan="2" class="opacitymedium">' . $langs->trans('ThisCategoryHasNoItems') . '</td></tr>';
}

$out .= '</table>'; ?>
$out .= '</table>'; ?>

<script>
jQuery('.fichecenter').last().after(<?php echo json_encode($out); ?>)
</script>
<?php
<script>
jQuery('.fichecenter').last().after(<?php echo json_encode($out); ?>)
</script>
<?php
}
}

return 0; // or return 1 to replace standard code.
Expand Down Expand Up @@ -478,12 +480,12 @@ public function saturneAttendantsBackToCard(array $parameters, CommonObject $obj
}

/**
* Overloading the SaturneAdminDocumentData function : replacing the parent's function with the one below.
* Overloading the saturneAdminDocumentData function : replacing the parent's function with the one below.
*
* @param array $parameters Hook metadatas (context, etc...).
* @return int 0 < on error, 0 on success, 1 to replace standard code.
*/
public function SaturneAdminDocumentData(array $parameters): int
public function saturneAdminDocumentData(array $parameters): int
{
// Do something only for the current context.
if ($parameters['currentcontext'] == 'dolimeetadmindocuments') {
Expand All @@ -504,12 +506,12 @@ public function SaturneAdminDocumentData(array $parameters): int
}

/**
* Overloading the SaturneAdminObjectConst function : replacing the parent's function with the one below.
* Overloading the saturneAdminObjectConst function : replacing the parent's function with the one below.
*
* @param array $parameters Hook metadatas (context, etc...).
* @return int 0 < on error, 0 on success, 1 to replace standard code.
*/
public function SaturneAdminObjectConst(array $parameters): int
public function saturneAdminObjectConst(array $parameters): int
{
// Do something only for the current context.
if ($parameters['currentcontext'] == 'dolimeetadmindocuments') {
Expand Down Expand Up @@ -558,7 +560,11 @@ public function saturneBuildDoc(array $parameters, CommonObject $object, string
}
}
}
setEventMessages($langs->trans('FileGenerated') . ' - ' . '<a href=' . DOL_URL_ROOT . '/document.php?modulepart=dolimeet&file=' . urlencode($object->element . 'document/' . $object->ref . '/' . $document->last_main_doc) . '&entity=' . $conf->entity . '"' . '>' . $document->last_main_doc, []);
$documentType = explode('_odt', (!empty($parameters['models']) ? $parameters['models'][1] : $parameters['model']));
if ($document->element != $documentType[0]) {
$document->element = $documentType[0];
}
setEventMessages($langs->trans('FileGenerated') . ' - ' . '<a href=' . DOL_URL_ROOT . '/document.php?modulepart=dolimeet&file=' . urlencode($document->element . '/' . $object->ref . '/' . $document->last_main_doc) . '&entity=' . $conf->entity . '"' . '>' . $document->last_main_doc, []);
$urlToRedirect = $_SERVER['REQUEST_URI'];
$urlToRedirect = preg_replace('/#builddoc$/', '', $urlToRedirect);
$urlToRedirect = preg_replace('/action=builddoc&?/', '', $urlToRedirect); // To avoid infinite loop
Expand Down
20 changes: 10 additions & 10 deletions class/session.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ public function getAttendantInfos(): array
$signatory = new SaturneSignature($this->db);

$array = [];
$signatories = $signatory->fetchAll('', '', 0, 0, ['customsql' => 't.module_name = "dolimeet"']);
$signatories = $signatory->fetchAll('', '', 0, 0, ['customsql' => 't.module_name = "dolimeet" AND status > 0']);
if (is_array($signatories) && !empty($signatories)) {
foreach ($signatories as $signatory) {
switch ($signatory->object_type) {
Expand Down Expand Up @@ -768,19 +768,19 @@ public function getAttendantInfos(): array
}
}
if ($array['meeting']['content'] > 0) {
$array['meeting']['attendanceRate']['present']['content'] = ($array['meeting']['attendance']['present']['content'] / $array['meeting']['content']) * 100 . ' %';
$array['meeting']['attendanceRate']['delay']['content'] = ($array['meeting']['attendance']['delay']['content'] / $array['meeting']['content']) * 100 . ' %';
$array['meeting']['attendanceRate']['absent']['content'] = ($array['meeting']['attendance']['absent']['content'] / $array['meeting']['content']) * 100 . ' %';
$array['meeting']['attendanceRate']['present']['content'] = price2num(($array['meeting']['attendance']['present']['content'] / $array['meeting']['content']) * 100, 'MT') . ' %';
$array['meeting']['attendanceRate']['delay']['content'] = price2num(($array['meeting']['attendance']['delay']['content'] / $array['meeting']['content']) * 100, 'MT') . ' %';
$array['meeting']['attendanceRate']['absent']['content'] = price2num(($array['meeting']['attendance']['absent']['content'] / $array['meeting']['content']) * 100, 'MT') . ' %';
}
if ($array['trainingsession']['content'] > 0) {
$array['trainingsession']['attendanceRate']['present']['content'] = ($array['trainingsession']['attendance']['present']['content'] / $array['trainingsession']['content']) * 100 . ' %';
$array['trainingsession']['attendanceRate']['delay']['content'] = ($array['trainingsession']['attendance']['delay']['content'] / $array['trainingsession']['content']) * 100 . ' %';
$array['trainingsession']['attendanceRate']['absent']['content'] = ($array['trainingsession']['attendance']['absent']['content'] / $array['trainingsession']['content']) * 100 . ' %';
$array['trainingsession']['attendanceRate']['present']['content'] = price2num(($array['trainingsession']['attendance']['present']['content'] / $array['trainingsession']['content']) * 100, 'MT') . ' %';
$array['trainingsession']['attendanceRate']['delay']['content'] = price2num(($array['trainingsession']['attendance']['delay']['content'] / $array['trainingsession']['content']) * 100, 'MT') . ' %';
$array['trainingsession']['attendanceRate']['absent']['content'] = price2num(($array['trainingsession']['attendance']['absent']['content'] / $array['trainingsession']['content']) * 100, 'MT') . ' %';
}
if ($array['audit']['content'] > 0) {
$array['audit']['attendanceRate']['present']['content'] = ($array['audit']['attendance']['present']['content'] / $array['audit']['content']) * 100 . ' %';
$array['audit']['attendanceRate']['delay']['content'] = ($array['audit']['attendance']['delay']['content'] / $array['audit']['content']) * 100 . ' %';
$array['audit']['attendanceRate']['absent']['content'] = ($array['audit']['attendance']['absent']['content'] / $array['audit']['content']) * 100 . ' %';
$array['audit']['attendanceRate']['present']['content'] = price2num(($array['audit']['attendance']['present']['content'] / $array['audit']['content']) * 100, 'MT') . ' %';
$array['audit']['attendanceRate']['delay']['content'] = price2num(($array['audit']['attendance']['delay']['content'] / $array['audit']['content']) * 100, 'MT') . ' %';
$array['audit']['attendanceRate']['absent']['content'] = price2num(($array['audit']['attendance']['absent']['content'] / $array['audit']['content']) * 100, 'MT') . ' %';
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public function info(Translate $langs): string
return parent::info($langs);
}


/**
* Function to build a document on disk.
*
Expand Down Expand Up @@ -134,31 +135,10 @@ public function write_file(SaturneDocuments $objectDocument, Translate $outputLa
$tmpArray['date_end'] = dol_print_date($object->date_end, 'dayhour', 'tzuser');
$tmpArray['duration'] = convertSecondToTime($object->duration);

$signatory = $signatory->fetchSignatory('SessionTrainer', $object->id, $object->element);
if (is_array($signatory) && !empty($signatory)) {
$signatory = array_shift($signatory);
$tmpArray['trainer_fullname'] = strtoupper($signatory->lastname) . ' ' . $signatory->firstname;
if (dol_strlen($signatory->signature) > 0 && $signatory->signature != $langs->transnoentities('FileGenerated')) {
if ($moreParam['specimen'] == 0 || ($moreParam['specimen'] == 1 && $conf->global->DOLIMEET_SHOW_SIGNATURE_SPECIMEN == 1)) {
$tempDir = $conf->dolimeet->multidir_output[$object->entity ?? 1] . '/temp/';
$encodedImage = explode(',', $signatory->signature)[1];
$decodedImage = base64_decode($encodedImage);
file_put_contents($tempDir . 'signature.png', $decodedImage);
$tmpArray['trainer_signature'] = $tempDir . 'signature.png';
} else {
$tmpArray['trainer_signature'] = '';
}
} else {
$tmpArray['trainer_signature'] = '';
}
} else {
$tmpArray['trainer_fullname'] = '';
$tmpArray['trainer_signature'] = '';
}

$tmpArray['date_creation'] = dol_print_date(dol_now(), 'dayhour', 'tzuser');

$moreParam['tmparray'] = $tmpArray;
$moreParam['tmparray'] = $tmpArray;
$moreParam['multipleAttendantsSegment'] = ['sessiontrainer', 'trainee'];

return parent::write_file($objectDocument, $outputLangs, $srcTemplatePath, $hideDetails, $hideDesc, $hideRef, $moreParam);
}
Expand Down
4 changes: 2 additions & 2 deletions core/modules/modDoliMeet.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function __construct($db)
$this->editor_url = 'https://evarisk.com';

// Possible values for version are: 'development', 'experimental', 'dolibarr', 'dolibarr_deprecated' or a version string like 'x.y.z'.
$this->version = '1.2.0';
$this->version = '1.2.1';

// Url to the file with your last numberversion of this module.
//$this->url_last_version = 'http://www.example.com/versionmodule.txt';
Expand Down Expand Up @@ -149,7 +149,7 @@ public function __construct($db)
$this->hidden = false;

// List of module class names as string that must be enabled if this module is enabled. Example: array('always1'=>'modModuleToEnable1','always2'=>'modModuleToEnable2', 'FR1'=>'modModuleToEnableFR'...).
$this->depends = ['modCategorie', 'modContrat', 'modProjet', 'modFckeditor', 'modSaturne'];
$this->depends = ['modCategorie', 'modContrat', 'modProjet', 'modFckeditor', 'modSaturne', 'modAgenda'];
$this->requiredby = []; // List of module class names as string to disable if this one is disabled. Example: array('modModuleToDisable1', ...).
$this->conflictwith = []; // List of module class names as string this module is in conflict with. Example: array('modModuleToDisable1', ...).

Expand Down
Loading

0 comments on commit 67b4ffe

Please sign in to comment.