Skip to content

Commit

Permalink
1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-eoxia committed Jul 22, 2024
2 parents 38f6e62 + 8e84eae commit c0e859b
Show file tree
Hide file tree
Showing 10 changed files with 144 additions and 17 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
## Informations

- Numéro du module : 436312
- Dernière mise à jour : 19/02/2024
- Dernière mise à jour : 22/07/2024
- Éditeur : [Evarisk](https://evarisk.com)
- Thème : Eldy Menu
- Licence : GPLv3
- Disponible sur : Windows - MacOS - Linux

### Version

- Version : 1.0.0
- Version : 1.1.0
- PHP : 7.4.33
- Compatibilité : Dolibarr 16.0.0 - 18.0.4
- Saturne Framework : 1.3.0
- Compatibilité : Dolibarr 16.0.0 - 20.0.0
- Saturne Framework : 1.3.0 - 1.5.1

## Liens

Expand Down
104 changes: 101 additions & 3 deletions class/actions_gmao.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,13 @@ public function doActions(array $parameters, $object, string $action): int
}

if ($action == 'builddoc' && preg_match('/\bgmaoticketdocument_odt\b/', GETPOST('model'))) {
$thirdParty = new Societe($this->db);

$thirdParty->fetch($object->fk_soc);

$moreParams = [
'gmaoclientticketdocument' => [
'url' => 'public/ticket/view.php?track_id=' . $object->track_id . '&entity=' . $conf->entity
'url' => 'public/ticket/view.php?track_id=' . $object->track_id . (dol_strlen($thirdParty->email) > 0 ? '&email=' . $thirdParty->email : '') . '&entity=' . $conf->entity
],
'gmaotechticketdocument' => [
'url' => 'ticket/card.php?id=' . $object->id
Expand All @@ -162,8 +166,11 @@ public function doActions(array $parameters, $object, string $action): int
$document->createQRCode($moreParams, $object);
$moduleNameLowerCase = 'gmao';
$permissiontoadd = $user->rights->ticket->write;
}

require __DIR__ . '/../../saturne/core/tpl/documents/documents_action.tpl.php';
if ($action == 'remove_file' && preg_match('/\bgmaoticketdocument\b/', GETPOST('file'))) {
$upload_dir = $conf->gmao->multidir_output[$conf->entity ?? 1];
$permissiontodelete = $user->rights->ticket->delete;
}

if ($action == 'pdfGeneration') {
Expand All @@ -183,17 +190,97 @@ public function doActions(array $parameters, $object, string $action): int
}

if ($action == 'generate_qrcode') {
$thirdParty = new Societe($this->db);

$thirdParty->fetch($object->fk_soc);

$moreParams = [
'gmaoclientticketdocument' => [
'url' => 'public/ticket/view.php?track_id=' . $object->track_id . '&entity=' . $conf->entity
'url' => 'public/ticket/view.php?track_id=' . $object->track_id . (dol_strlen($thirdParty->email) > 0 ? '&email=' . $thirdParty->email : '') . '&entity=' . $conf->entity
],
];

$document->createQRCode($moreParams, $object);
header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id);
exit;
}

require __DIR__ . '/../../saturne/core/tpl/documents/documents_action.tpl.php';
}

if (strpos($parameters['context'], 'inventorycard') !== false) {
if (GETPOST('importMassBatch', 'alpha') && ! empty($conf->global->MAIN_UPLOAD_DOC)) {
// Submit file
if (!empty($_FILES)) {
$error = 0;
if (pathinfo($_FILES['importMassBatch']['name'][0], PATHINFO_EXTENSION) != 'csv') {
setEventMessages($langs->trans('ErrorWrongFileNameExtension', $_FILES['importMassBatch']['name'][0]), [], 'errors');
} else {
if (is_array($_FILES['importMassBatch']['tmp_name'])) {
$files = $_FILES['importMassBatch']['tmp_name'];
} else {
$files = [$_FILES['importMassBatch']['tmp_name']];
}

foreach ($files as $key => $file) {
if (empty($_FILES['importMassBatch']['tmp_name'][$key])) {
$error++;
if ($_FILES['importMassBatch']['error'][$key] == 1 || $_FILES['importMassBatch']['error'][$key] == 2) {
setEventMessages($langs->trans('ErrorFileSizeTooLarge'), [], 'errors');
} else {
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('File')), [], 'errors');
}
}
}

if (!$error) {
$fileDir = $conf->gmao->multidir_output[$conf->entity ?? 1] . '/temp/';
if (!empty($fileDir)) {
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
dol_add_file_process($fileDir, 0, 1, 'importMassBatch', '', null, '', 0);
}

$filePath = $fileDir . '/' . $_FILES['importMassBatch']['name'][0];
$fileCSV = fopen($filePath, 'r');
if ($fileCSV !== false) {
$headers = fgetcsv($fileCSV);
$expectedHeaders = ['FK_STOCK', 'FK_PRODUCT', 'BATCH', 'QTY'];
if ($headers === $expectedHeaders) {
$dataCSV = [];
while (($row = fgetcsv($fileCSV)) !== false) {
$dataCSV[] = $row;
}
fclose($fileCSV);
unset($dataCSV[0]);

foreach ($dataCSV as $cell) {
$inventoryLine = new InventoryLine($this->db);
$inventoryLine->fk_inventory = $object->id;
$inventoryLine->datec = dol_now();
$inventoryLine->fk_warehouse = $cell[0];
$inventoryLine->fk_product = $cell[1];
$inventoryLine->batch = $cell[2];
$inventoryLine->qty_view = $cell[3];

$inventoryLine->create($user);
}

unlink($filePath);
header('Location: ' . $_SERVER['PHP_SELF'] . '?id=' . $object->id);
exit;
} else {
fclose($fileCSV);
setEventMessages($langs->trans('ErrorInvalidHeaders', 'FK_STOCK, FK_PRODUCT, BATCH, QTY'), [], 'errors');
}
} else {
setEventMessages($langs->trans('ErrorFileNotFound'), [], 'errors');
}
}
}
}
}
}

return 0; // or return 1 to replace standard code
}

Expand Down Expand Up @@ -285,6 +372,17 @@ public function printCommonFooter(array $parameters): int
}
}

if (strpos($parameters['context'], 'inventorycard') !== false) {
$out = '<input type="file" name="importMassBatch[]" id="import-mass-batch" />';
$out .= '<input type="submit" class="button reposition" name="importMassBatch" value="' . $langs->trans('ImportMassBatch') . '">'; ?>

<script>
jQuery('#formrecord').attr('enctype', 'multipart/form-data');
jQuery('center').first().append(<?php echo json_encode($out); ?>);
</script>
<?php
}

return 0; // or return 1 to replace standard code
}

Expand Down
18 changes: 15 additions & 3 deletions core/modules/modGMAO.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.0.0';
$this->version = '1.1.0';

// 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 @@ -119,7 +119,8 @@ public function __construct($db)
// Set here all hooks context managed by module. To find available hook context, make a "grep -r '>initHooks(' *" on source code. You can also set hook context to 'all'
'hooks' => [
'ticketcard',
'gmaoadmindocuments'
'gmaoadmindocuments',
'inventorycard'
],
// Set this to 1 if features of module are opened to external users
'moduleforexternal' => 0
Expand Down Expand Up @@ -267,7 +268,7 @@ public function __construct($db)
*/
public function init($options = ''): int
{
global $conf;
global $conf, $db, $langs;

// Permissions
$this->remove($options);
Expand All @@ -283,6 +284,17 @@ public function init($options = ''): int

addDocumentModel('gmaoticketdocument_odt', 'gmaoticketdocument', 'ODT templates', 'GMAO_GMAOTICKETDOCUMENT_ADDON_ODT_PATH');

if (getDolGlobalInt('GMAO_TICKET_MAIN_CATEGORIES_SET') == 0) {
$tagParentID = saturne_create_category($langs->transnoentities('GMAO'), 'ticket', 0, 'pictogram_GMAO_64px.png');

saturne_create_category($langs->transnoentities('Preventive'), 'ticket', $tagParentID, 'pictogram_Preventive_64px.png');
saturne_create_category($langs->transnoentities('Curative'), 'ticket', $tagParentID, 'pictogram_Curative_64px.png');
saturne_create_category($langs->transnoentities('Improvement'), 'ticket', $tagParentID, 'pictogram_Improvement_64px.png');

dolibarr_set_const($db, 'GMAO_TICKET_MAIN_CATEGORY', $tagParentID, 'integer', 0, '', $conf->entity);
dolibarr_set_const($db, 'GMAO_TICKET_MAIN_CATEGORIES_SET', 1, 'integer', 0, '', $conf->entity);
}

return $this->_init($sql, $options);
}

Expand Down
10 changes: 6 additions & 4 deletions core/triggers/interface_99_modGmao_GmaoTriggers.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct(DoliDB $db)
$this->name = preg_replace('/^Interface/i', '', get_class($this));
$this->family = 'demo';
$this->description = 'GMAO triggers';
$this->version = '1.0.0';
$this->version = '1.1.0';
$this->picto = 'gmao@gmao';
}

Expand Down Expand Up @@ -114,14 +114,16 @@ public function runTrigger($action, $object, User $user, Translate $langs, Conf
case 'TICKET_CREATE' :
require_once __DIR__ . '/../../class/gmaodocuments/gmaoticketdocument.class.php';

$document = new GMAOTicketDocument($this->db);
$document = new GMAOTicketDocument($this->db);
$thirdParty = new Societe($this->db);

$thirdParty->fetch($object->fk_soc);

$moreParams = [
'gmaoclientticketdocument' => [
'url' => 'public/ticket/view.php?track_id=' . $object->track_id . '&entity=' . $conf->entity
'url' => 'public/ticket/view.php?track_id=' . $object->track_id . (dol_strlen($thirdParty->email) > 0 ? '&email=' . $thirdParty->email : '') . '&entity=' . $conf->entity
],
];

$document->createQRCode($moreParams, $object);
break;
}
Expand Down
Binary file not shown.
Binary file added img/pictos_ticket/pictogram_Curative_64px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/pictos_ticket/pictogram_GMAO_64px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/pictos_ticket/pictogram_Improvement_64px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/pictos_ticket/pictogram_Preventive_64px.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 18 additions & 3 deletions langs/fr_FR/gmao.lang
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ ModuleGMAODesc = Gestion de maintenance au travers des tickets
GMAODescription = Gestion de maintenance au travers des tickets
GMAODescriptionLong = Gestion de maintenance au travers des tickets

# Tags - Catégories
Preventive = Préventive
Curative = Curative
Improvement = Amélioration



#
Expand Down Expand Up @@ -55,8 +60,18 @@ ErrorConfigProposalService = Impossible de créer une proposition de maintenance
# Data - Donnée
GMAOTicketDocument = Tickets GMAO
gmaoclientticketdocument.odt = Ticket client
gmaoclientticketdocument = Ticket client
gmaoclientticketdocument = ticket client
gmaotechticketdocument.odt = Ticket interne
gmaotechticketdocument = Ticket interne
gmaotechticketdocument = ticket interne
gmaospecialticketdocument.odt = Ticket client et ticket interne
gmaospecialticketdocument = Ticket client et ticket interne
gmaospecialticketdocument = ticket client et ticket interne



#
# Other - Autres
#

# Data - Donnée
ImportMassBatch = Import en masse de lot/série
ErrorInvalidHeaders = Erreur : mauvaise en-tête de fichier %s

0 comments on commit c0e859b

Please sign in to comment.