Skip to content

Commit

Permalink
Merge pull request #383 from nicolas-eoxia/clean_certificat
Browse files Browse the repository at this point in the history
#337 [Certificat] clean: view and lib
  • Loading branch information
nicolas-eoxia authored Jul 21, 2023
2 parents d1e19bb + 9d51543 commit a138c77
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 125 deletions.
14 changes: 10 additions & 4 deletions class/actions_dolisirh.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ function toggleTaskFavoriteWithId (taskId) {
*/
public function constructCategory(array $parameters)
{
if (in_array($parameters['currentcontext'], ['category', 'invoicecard', 'invoicereccard', 'timesheetcard', 'invoicelist', 'invoicereclist'])) {
if (in_array($parameters['currentcontext'], ['category', 'invoicecard', 'invoicereccard', 'timesheetcard', 'certificatecard', 'invoicelist', 'invoicereclist'])) {
$tags = [
'facture' => [
'id' => 436370001,
Expand All @@ -1018,12 +1018,18 @@ public function constructCategory(array $parameters)
'code' => 'timesheet',
'obj_class' => 'TimeSheet',
'obj_table' => 'dolisirh_timesheet',
],
'certificate' => [
'id' => 436370003,
'code' => 'certificate',
'obj_class' => 'Certificate',
'obj_table' => 'saturne_object_certificate',
]
];

$this->results = $tags;
}
}
$this->results = $tags;
}
}

/**
* Overloading the formObjectOptions function : replacing the parent's function with the one below
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
require_once __DIR__ . '/../../../../../../saturne/class/saturnesignature.class.php';
require_once __DIR__ . '/../../../../../../saturne/core/modules/saturne/modules_saturne.php';

// Load DoliSMQ libraries.
// Load DoliSIRH libraries.
require_once __DIR__ . '/mod_projectdocument_standard.php';

/**
Expand Down
45 changes: 38 additions & 7 deletions core/modules/modDoliSIRH.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ public function __construct($db)

// Gives the possibility for the module, to provide his own family info and position of this family (Overwrite $this->family and $this->module_position. Avoid this)
$this->familyinfo = ['Evarisk' => ['position' => '01', 'label' => $langs->trans('Evarisk')]];
// Module label (no space allowed), used if translation string 'ModuleDoliSMQName' not found (DoliSMQ is name of module).
// Module label (no space allowed), used if translation string 'ModuleDoliSIRHName' not found (DoliSIRH is name of module).
$this->name = preg_replace('/^mod/i', '', get_class($this));

// Module description, used if translation string 'ModuleDoliSMQDesc' not found (DoliSMQ is name of module).
// Module description, used if translation string 'ModuleDoliSIRHDesc' not found (DoliSIRH is name of module).
$this->description = $langs->trans('DoliSIRHDescription');
// Used only if file README.md and README-LL.md not found.
$this->descriptionlong = $langs->trans('DoliSIRHDescriptionLong');
Expand All @@ -83,7 +83,7 @@ public function __construct($db)
// Url to the file with your last numberversion of this module.
//$this->url_last_version = 'http://www.example.com/versionmodule.txt';

// Key used in llx_const table to save module status enabled/disabled (where DOLISMQ is value of property name of module in uppercase).
// Key used in llx_const table to save module status enabled/disabled (where DoliSIRH is value of property name of module in uppercase).
$this->const_name = 'MAIN_MODULE_' . strtoupper($this->name);

// Name of image file used for this module.
Expand Down Expand Up @@ -178,8 +178,8 @@ public function __construct($db)

// Constants.
// List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive).
// Example: $this->const=array(1 => array('DOLISMQ_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1),
// 2 => array('DOLISMQ_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1)
// Example: $this->const=array(1 => array('DoliSIRH_MYNEWCONST1', 'chaine', 'myvalue', 'This is a constant to add', 1),
// 2 => array('DoliSIRH_MYNEWCONST2', 'chaine', 'myvalue', 'This is another constant to add', 0, 'current', 1)
// );
$i = 0;
$this->const = [
Expand Down Expand Up @@ -244,7 +244,7 @@ public function __construct($db)

// Array to add new pages in new tabs.
// Example:
// $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@dolimeet:$user->rights->othermodule->read:/dolimeet/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.
// $this->tabs[] = array('data'=>'objecttype:+tabname2:SUBSTITUTION_Title2:mylangfile@dolisirh:$user->rights->othermodule->read:/dolisirh/mynewtab2.php?id=__ID__', // To add another new tab identified by code tabname2. Label will be result of calling all substitution functions on 'Title2' key.
// $this->tabs[] = array('data'=>'objecttype:-tabname:NU:conditiontoremove');
$this->tabs = [];
$pictoPath = dol_buildpath('/custom/dolisirh/img/dolisirh_color.png', 1);
Expand Down Expand Up @@ -302,7 +302,7 @@ public function __construct($db)
];

// Boxes/Widgets
// Add here list of php file(s) stored in dolismq/core/boxes that contains a class to show a widget.
// Add here list of php file(s) stored in dolisirh/core/boxes that contains a class to show a widget.
$this->boxes = [];

// Cronjobs (List of cron jobs entries to add when module is enabled).
Expand Down Expand Up @@ -443,6 +443,37 @@ public function __construct($db)
'user' => 0,
];

$this->menu[$r++] = [
'fk_menu' => 'fk_mainmenu=dolisirh',
'type' => 'left',
'titre' => $langs->trans('Certificate'),
'prefix' => '<i class="fas fa-user-graduate pictofixedwidth"></i>',
'mainmenu' => 'dolisirh',
'leftmenu' => 'certificate',
'url' => '/dolisirh/view/certificate/certificate_list.php',
'langs' => 'dolisirh@dolisirh',
'position' => 1000 + $r,
'enabled' => '$conf->dolisirh->enabled',
'perms' => '$user->rights->dolisirh->certificate->read',
'target' => '',
'user' => 0,
];

$this->menu[$r++] = [
'fk_menu' => 'fk_mainmenu=dolisirh,fk_leftmenu=certificate',
'type' => 'left',
'titre' => '<i class="fas fa-tags pictofixedwidth" style="padding-right: 4px;"></i>' . $langs->transnoentities('Categories'),
'mainmenu' => 'dolisirh',
'leftmenu' => 'certificatetags',
'url' => '/categories/index.php?type=certificate',
'langs' => 'dolisirh@dolisirh',
'position' => 1000 + $r,
'enabled' => '$conf->dolisirh->enabled && $conf->categorie->enabled',
'perms' => '$user->rights->dolisirh->lire && $user->rights->dolisirh->certificate->read && $user->rights->categorie->lire',
'target' => '',
'user' => 0,
];

$this->menu[$r++] = [
'fk_menu' => 'fk_mainmenu=dolisirh',
'type' => 'left',
Expand Down
7 changes: 5 additions & 2 deletions lib/dolisirh_certificate.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

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

Expand All @@ -33,5 +33,8 @@
*/
function certificate_prepare_head(Certificate $object): array
{
return saturne_object_prepare_head($object, [], [], true);
$moreParams['documentType'] = 'CertificateDocument';
$moreParams['attendantTableMode'] = 'simple';

return saturne_object_prepare_head($object, [], $moreParams, true);
}
20 changes: 20 additions & 0 deletions sql/certificate/llx_categorie_certificate.key.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- Copyright (C) 2021-2023 EVARISK <technique@evarisk.com>
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see https://www.gnu.org/licenses/.

ALTER TABLE llx_categorie_certificate ADD PRIMARY KEY pk_categorie_certificate (fk_categorie, fk_certificate);
ALTER TABLE llx_categorie_certificate ADD INDEX idx_categorie_certificate_fk_categorie (fk_categorie);
ALTER TABLE llx_categorie_certificate ADD INDEX idx_categorie_certificate_fk_certificate (fk_certificate);
ALTER TABLE llx_categorie_certificate ADD CONSTRAINT fk_categorie_certificate_categorie_rowid FOREIGN KEY (fk_categorie) REFERENCES llx_categorie (rowid);
ALTER TABLE llx_categorie_certificate ADD CONSTRAINT fk_categorie_certificate_dolisirh_certificate_rowid FOREIGN KEY (fk_certificate) REFERENCES llx_dolisirh_certificate (rowid);
20 changes: 20 additions & 0 deletions sql/certificate/llx_categorie_certificate.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- Copyright (C) 2021-2023 EVARISK <technique@evarisk.com>
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see https://www.gnu.org/licenses/.

CREATE TABLE llx_categorie_certificate(
fk_categorie integer NOT NULL,
fk_certificate integer NOT NULL,
import_key varchar(14)
) ENGINE=innodb;
Loading

0 comments on commit a138c77

Please sign in to comment.