Add Module
-
- Znuny newbie
- Posts: 19
- Joined: 22 Jul 2015, 10:49
- Znuny Version: OTRS 4
- Real Name: Muhammad Hassanine Haddad
- Company: CIMEF
Add Module
Hello everybody i'm new in OTRS and i wanna some help please !
i want to create another Module "Machine". I read in the manual that i must create 4 files in different folders to create a module:
Kernel/Config/Files => here to create a group in the Sysconfig and to add the NavBar (from what I understood)
Kernel/Modules => here to developpe the code i think (from what I understood)
Kernel/System => here too (from what I understood)
Kernel/Output/HTML/Standard => here to create the interface of the module
In the interface (*.tt) i want to create something like a form, 2 input text "MachineID" and "Machine Model".
and to save those data, i want to create another table in database of the OTRS system but i don't know how, can someone help me please ?
Thanks
i want to create another Module "Machine". I read in the manual that i must create 4 files in different folders to create a module:
Kernel/Config/Files => here to create a group in the Sysconfig and to add the NavBar (from what I understood)
Kernel/Modules => here to developpe the code i think (from what I understood)
Kernel/System => here too (from what I understood)
Kernel/Output/HTML/Standard => here to create the interface of the module
In the interface (*.tt) i want to create something like a form, 2 input text "MachineID" and "Machine Model".
and to save those data, i want to create another table in database of the OTRS system but i don't know how, can someone help me please ?
Thanks
-
- Znuny guru
- Posts: 2210
- Joined: 13 Mar 2014, 09:16
- Znuny Version: 6.0.14
- Real Name: Rolf Straub
Re: Add Module
This is a very very broad question. Where exactly do you need help now? Did you follow the example in the manual to create a module?
Where did you fail ? What did you achieve ?
Where did you fail ? What did you achieve ?
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
-
- Znuny newbie
- Posts: 19
- Joined: 22 Jul 2015, 10:49
- Znuny Version: OTRS 4
- Real Name: Muhammad Hassanine Haddad
- Company: CIMEF
Re: Add Module
Sorry Mr,RStraub wrote:This is a very very broad question. Where exactly do you need help now? Did you follow the example in the manual to create a module?
Where did you fail ? What did you achieve ?
i think first of all that i must create a new table in database of the system to save the data there, i don't know how ?
Thanks for the quick answer ^^
-
- Znuny newbie
- Posts: 19
- Joined: 22 Jul 2015, 10:49
- Znuny Version: OTRS 4
- Real Name: Muhammad Hassanine Haddad
- Company: CIMEF
Re: Add Module
i found something ! i think it's in /$HOME_OTRS/scripts/database/otrs-schema.mysql.sql no ?
-
- Znuny guru
- Posts: 2210
- Joined: 13 Mar 2014, 09:16
- Znuny Version: 6.0.14
- Real Name: Rolf Straub
Re: Add Module
I think that's the setup script when you first install OTRS.
For your testing purpose, just login to your DB and execute a create table command:
http://dev.mysql.com/doc/refman/5.1/en/ ... table.html
Later you can add a create table to your .sopm file if you build a packe for your customization.
For your testing purpose, just login to your DB and execute a create table command:
http://dev.mysql.com/doc/refman/5.1/en/ ... table.html
Later you can add a create table to your .sopm file if you build a packe for your customization.
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
Re: Add Module
Hi,
OTRS is a complex application with more than 200 man years of development. So please tell us first what you want to achieve before starting any coding.
If the data at the end is ticket related, you most likely will not need additional data tables as you can store the information in dynamic fields. If you just want to add the data (ID and Model) to the ticket it can jut be done with configuration.
OTRS is a complex application with more than 200 man years of development. So please tell us first what you want to achieve before starting any coding.
If the data at the end is ticket related, you most likely will not need additional data tables as you can store the information in dynamic fields. If you just want to add the data (ID and Model) to the ticket it can jut be done with configuration.
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master
Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
"Testing": ((OTRS Community Edition)) and git Master
Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
-
- Znuny newbie
- Posts: 19
- Joined: 22 Jul 2015, 10:49
- Znuny Version: OTRS 4
- Real Name: Muhammad Hassanine Haddad
- Company: CIMEF
Re: Add Module
i want to create another module "Machine" tojojo wrote: OTRS is a complex application with more than 200 man years of development. So please tell us first what you want to achieve before starting any coding.
-Add machines in this module, just like customers or agents
-Search how many ticket has been opened for a specific MachineID
yeah i know that and already added 2 dynamic fields in the ticket, thank youjojo wrote: If the data at the end is ticket related, you most likely will not need additional data tables as you can store the information in dynamic fields. If you just want to add the data (ID and Model) to the ticket it can jut be done with configuration.
So i must add a "Create Table Machine etc... " in the /scripts/database/*.sql like i said ? and which file please ? thanks
-
- Znuny newbie
- Posts: 19
- Joined: 22 Jul 2015, 10:49
- Znuny Version: OTRS 4
- Real Name: Muhammad Hassanine Haddad
- Company: CIMEF
Re: Add Module
don't you think that's in the $HOME_OTRS/scripts/database/*.sql files ? because i found all the tables of the system created there.RStraub wrote:I think that's the setup script when you first install OTRS.
For your testing purpose, just login to your DB and execute a create table command:
http://dev.mysql.com/doc/refman/5.1/en/ ... table.html
Later you can add a create table to your .sopm file if you build a packe for your customization.
otherwhise can you give me more details about your solution please ?
-
- Znuny guru
- Posts: 2210
- Joined: 13 Mar 2014, 09:16
- Znuny Version: 6.0.14
- Real Name: Rolf Straub
Re: Add Module
No, I don't think that's the correct file. I highly doubt there's even a script to add a table.
What I meant is executing this:
What I meant is executing this:
Code: Select all
mysql -u YourUserName -D YourDBName -p
CREATE TABLE IF NOT EXISTS Machine (
id MEDIUMINT NOT NULL AUTO_INCREMENT,
name CHAR(50) NOT NULL,
PRIMARY KEY (id)
)
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
-
- Znuny newbie
- Posts: 19
- Joined: 22 Jul 2015, 10:49
- Znuny Version: OTRS 4
- Real Name: Muhammad Hassanine Haddad
- Company: CIMEF
Re: Add Module
thank you very much ! done !RStraub wrote:No, I don't think that's the correct file. I highly doubt there's even a script to add a table.
What I meant is executing this:
Code: Select all
mysql -u YourUserName -D YourDBName -p CREATE TABLE IF NOT EXISTS Machine ( id MEDIUMINT NOT NULL AUTO_INCREMENT, name CHAR(50) NOT NULL, PRIMARY KEY (id) )
can you help me now with the *.pm files to create the module please ?
i want to add machines, this is what i did in the Kernel/Modules/AddMachines.pm file
Code: Select all
package Kernel::Modules::AddMachines;
use strict;
use warnings;
use Kernel::System::AddMachines;
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {%Param};
bless( $Self, $Type );
# check needed objects
for my $Object (qw(ParamObject DBObject LayoutObject LogObject ConfigObject)) {
if ( !$Self->{$Object} ) {
$Self->{LayoutObject}->FatalError( Message => "Got no $Object!" );
}
}
# create additional objects
$Self->{MachinesObject} = Kernel::System::AddMachines->new(%Param);
return $Self;
}
sub Run {
my ( $Self, %Param ) = @_;
# permission check
if ( !$Self->{AccessRw} ) {
return $Self->{LayoutObject}->NoPermission(
Message => 'You need rw permission!',
WithHeader => 'yes',
);
}
# get parameters
my %GetParam;
for my $ParamName (qw(MachineID Modele)) {
$GetParam{$ParamName} = $Self->{ParamObject}->GetParam( Param => $ParamName );
}
# set default machine id
$GetParam{MachineID} ||= 0;
# ------------------------------------------------------------ #
# add
# ------------------------------------------------------------ #
if ( $Self->{Subaction} eq 'Add' ) {
# header
my $Output = $Self->{LayoutObject}->Header();
$Output .= $Self->{LayoutObject}->NavigationBar();
# HTML output
$Self->_Edit(
Action => 'Add',
%GetParam,
);
$Output .= $Self->{LayoutObject}->Output(
TemplateFile => 'AddMachines',
Data => \%Param,
);
# footer
$Output .= $Self->{LayoutObject}->Footer();
return $Output;
}
# ------------------------------------------------------------ #
# add action
# ------------------------------------------------------------ #
elsif ( $Self->{Subaction} eq 'AddAction' ) {
# challenge token check for write action
$Self->{LayoutObject}->ChallengeTokenCheck();
# header
my $Output = $Self->{LayoutObject}->Header();
$Output .= $Self->{LayoutObject}->NavigationBar();
# check required parameters
my %Error;
for my $ParamName (qw(MachineID Modele)) {
# if required field is not given
if ( !$GetParam{$ParamName} ) {
# add server error string for machine modele field
if ( $ParamName eq 'Modele' ) {
$Error{NameServerErrorMessage} = 'A machine should have a model!';
}
}
}
# send server error if any required parameters are missing
if (%Error) {
# HTML output
$Self->_Edit(
Action => 'Add',
%GetParam,
%Error,
);
$Output .= $Self->{LayoutObject}->Output(
TemplateFile => 'AddMachines',
Data => \%Param,
);
# footer
$Output .= $Self->{LayoutObject}->Footer();
return $Output;
}
# add new machine
my $MachineID = $Self->{MachinesObject}->MachinesAdd(
%GetParam,
UserID => $Self->{UserID},
);
# check error
if ( !$MachineID ) {
return $Self->{LayoutObject}->ErrorScreen();
}
# show notification
$Output .= $Self->{LayoutObject}->Notify( Info => 'Machine added!' );
# show overview
$Self->_Overview();
$Output .= $Self->{LayoutObject}->Output(
TemplateFile => 'AddMachines',
Data => \%Param,
);
# footer
$Output .= $Self->{LayoutObject}->Footer();
return $Output;
}
}
1;
-
- Znuny guru
- Posts: 2210
- Joined: 13 Mar 2014, 09:16
- Znuny Version: 6.0.14
- Real Name: Rolf Straub
Re: Add Module
I'm willing to support but not to quality check your code
Thus:
What is working - and what isn't ?
Thus:
What is working - and what isn't ?
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
Re: Add Module
Also, see my questions above. What is the scope of your module?
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master
Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
"Testing": ((OTRS Community Edition)) and git Master
Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
-
- Znuny newbie
- Posts: 19
- Joined: 22 Jul 2015, 10:49
- Znuny Version: OTRS 4
- Real Name: Muhammad Hassanine Haddad
- Company: CIMEF
Re: Add Module
you're rightRStraub wrote:I'm willing to support but not to quality check your code
i don't know what's wrong, Is there any compiler or a tool to debug if something's wrong ? synthax etc...RStraub wrote:What is working - and what isn't ?
When i click in the NavBar "Add Machine" Here's what i get
You do not have the required permissions to view the files attached to this post.
-
- Znuny guru
- Posts: 2210
- Joined: 13 Mar 2014, 09:16
- Znuny Version: 6.0.14
- Real Name: Rolf Straub
Re: Add Module
Watch the apache log while you try to access that page. It will tell you what's wrong.
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
-
- Znuny newbie
- Posts: 19
- Joined: 22 Jul 2015, 10:49
- Znuny Version: OTRS 4
- Real Name: Muhammad Hassanine Haddad
- Company: CIMEF
Re: Add Module
i want to create another module "Machine" tojojo wrote:Also, see my questions above. What is the scope of your module?
-Add machines in this module, just like customers or agents
-Search how many ticket has been opened for a specific MachineID
-
- Znuny newbie
- Posts: 19
- Joined: 22 Jul 2015, 10:49
- Znuny Version: OTRS 4
- Real Name: Muhammad Hassanine Haddad
- Company: CIMEF
Re: Add Module
/var/log/apache2/error.log here ?RStraub wrote:Watch the apache log while you try to access that page. It will tell you what's wrong.
-
- Znuny guru
- Posts: 2210
- Joined: 13 Mar 2014, 09:16
- Znuny Version: 6.0.14
- Real Name: Rolf Straub
Re: Add Module
Yes. I'd recommend doing a:
and while you tail it, access the page.
Code: Select all
tail -f /var/log/apache2/error.log
Currently using: OTRS 6.0.14 -- MariaDB -- Ubuntu 16 LTS
Re: Add Module
A dynamic field will also give you the needed report...
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master
Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
"Testing": ((OTRS Community Edition)) and git Master
Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
-
- Znuny newbie
- Posts: 19
- Joined: 22 Jul 2015, 10:49
- Znuny Version: OTRS 4
- Real Name: Muhammad Hassanine Haddad
- Company: CIMEF
Re: Add Module
really ? can you tell me how please ?jojo wrote:A dynamic field will also give you the needed report...