Qual: Respect database rules
Qual: Add indexes
This commit is contained in:
parent
a6b2eab439
commit
d3ef78df47
@ -32,6 +32,8 @@ require_once DOL_DOCUMENT_ROOT. '/user/class/user.class.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT. '/user/class/usergroup.class.php';
|
require_once DOL_DOCUMENT_ROOT. '/user/class/usergroup.class.php';
|
||||||
|
|
||||||
$action=GETPOST('action');
|
$action=GETPOST('action');
|
||||||
|
$optName=GETPOST('optName');
|
||||||
|
$optValue=GETPOST('optValue');
|
||||||
|
|
||||||
$langs->load("admin");
|
$langs->load("admin");
|
||||||
$langs->load("holiday");
|
$langs->load("holiday");
|
||||||
@ -155,7 +157,6 @@ if ($action == "add")
|
|||||||
$message.= '<br /><div class="warning">'.$langs->trans('AddCPforUsers').'</div>';
|
$message.= '<br /><div class="warning">'.$langs->trans('AddCPforUsers').'</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
dol_htmloutput_mesg($message);
|
dol_htmloutput_mesg($message);
|
||||||
|
|
||||||
|
|
||||||
@ -163,45 +164,41 @@ if ($action == "add")
|
|||||||
}
|
}
|
||||||
elseif ($action == 'create_event')
|
elseif ($action == 'create_event')
|
||||||
{
|
{
|
||||||
$error = false;
|
$error = 0;
|
||||||
|
|
||||||
if (!empty($_POST['optName']))
|
$optName = trim($optName);
|
||||||
|
$optValue = price2num($optValue,2);
|
||||||
|
|
||||||
|
if (! $optName)
|
||||||
{
|
{
|
||||||
$optName = trim($_POST['optName']);
|
$message='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Name")).'</div>';
|
||||||
} else {
|
$error++;
|
||||||
$error = true;
|
|
||||||
}
|
}
|
||||||
|
if (! $optValue > 0)
|
||||||
if (!empty($_POST['optValue']))
|
|
||||||
{
|
{
|
||||||
$optValue = price2num($_POST['optValue'],2);
|
$message='<div class="error">'.$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Value")).'</div>';
|
||||||
} else {
|
$error++;
|
||||||
$error = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$cp->optName = $optName;
|
$cp->optName = $optName;
|
||||||
$cp->optValue = $optValue;
|
$cp->optValue = $optValue;
|
||||||
|
|
||||||
if($error)
|
if (! $error)
|
||||||
{
|
|
||||||
$message = 'ErrorCreateEventCP';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
$result = $cp->createEventCP($user);
|
$result = $cp->createEventCP($user);
|
||||||
|
|
||||||
if($result > 0)
|
if($result > 0)
|
||||||
{
|
{
|
||||||
$message = 'OkCreateEventCP';
|
$message = 'OkCreateEventCP';
|
||||||
|
$optName='';
|
||||||
|
$optValue='';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$message = 'ErrorCreateEventCP';
|
$message = '<div class="error">'.$cp->error.'</div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dol_htmloutput_mesg($message);
|
dol_htmloutput_mesg($message);
|
||||||
|
|
||||||
}
|
}
|
||||||
elseif($action == 'event' && isset($_POST['update_event']))
|
elseif($action == 'event' && isset($_POST['update_event']))
|
||||||
{
|
{
|
||||||
@ -210,10 +207,10 @@ elseif($action == 'event' && isset($_POST['update_event']))
|
|||||||
$eventId = array_keys($_POST['update_event']);
|
$eventId = array_keys($_POST['update_event']);
|
||||||
$eventId = $eventId[0];
|
$eventId = $eventId[0];
|
||||||
|
|
||||||
$eventName = $_POST['optName'];
|
$eventName = $optName;
|
||||||
$eventName = $eventName[$eventId];
|
$eventName = $eventName[$eventId];
|
||||||
|
|
||||||
$eventValue = $_POST['optValue'];
|
$eventValue = $optValue;
|
||||||
$eventValue = $eventValue[$eventId];
|
$eventValue = $eventValue[$eventId];
|
||||||
|
|
||||||
if(!empty($eventName)) {
|
if(!empty($eventName)) {
|
||||||
@ -242,7 +239,6 @@ elseif($action == 'event' && isset($_POST['update_event']))
|
|||||||
}
|
}
|
||||||
|
|
||||||
dol_htmloutput_mesg($message);
|
dol_htmloutput_mesg($message);
|
||||||
|
|
||||||
}
|
}
|
||||||
elseif($action && isset($_POST['delete_event']))
|
elseif($action && isset($_POST['delete_event']))
|
||||||
{
|
{
|
||||||
@ -353,16 +349,14 @@ if($cp_events == 1) {
|
|||||||
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'?leftmenu=setup" name="event_update">'."\n";
|
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'?leftmenu=setup" name="event_update">'."\n";
|
||||||
print '<input type="hidden" name="action" value="event" />'."\n";
|
print '<input type="hidden" name="action" value="event" />'."\n";
|
||||||
|
|
||||||
print '<h5>'.$langs->trans('TitleUpdateEventCP').'</h5>'."\n";
|
|
||||||
|
|
||||||
print '<table class="noborder" width="100%">'."\n";
|
print '<table class="noborder" width="100%">'."\n";
|
||||||
print '<tbody>'."\n";
|
print '<tbody>'."\n";
|
||||||
print '<tr class="liste_titre">'."\n";
|
print '<tr class="liste_titre">'."\n";
|
||||||
|
|
||||||
print '<td class="liste_titre" width="40%">'.$langs->trans('NameEventCP').'</td>'."\n";
|
print '<td class="liste_titre" width="40%">'.$langs->trans('NameEventCP').'</td>'."\n";
|
||||||
print '<td class="liste_titre">'.$langs->trans('ValueOptionCP').'</td>'."\n";
|
print '<td class="liste_titre" width="20%">'.$langs->trans('ValueOptionCP').'</td>'."\n";
|
||||||
print '<td class="liste_titre">'.$langs->trans('UpdateEventOptionCP').'</td>'."\n";
|
print '<td class="liste_titre"> </td>'."\n";
|
||||||
print '<td class="liste_titre" align="right">'.$langs->trans('DeleteEventOptionCP').'</td>'."\n";
|
print '<td class="liste_titre"> </td>'."\n";
|
||||||
|
|
||||||
print '</tr>'."\n";
|
print '</tr>'."\n";
|
||||||
|
|
||||||
@ -373,7 +367,7 @@ if($cp_events == 1) {
|
|||||||
print '<tr '.$bc[$var].'>'."\n";
|
print '<tr '.$bc[$var].'>'."\n";
|
||||||
print '<td><input class="flat" type="text" size="40" name="optName['.$infos_event['rowid'].']" value="'.$infos_event['name'].'" /></td>'."\n";
|
print '<td><input class="flat" type="text" size="40" name="optName['.$infos_event['rowid'].']" value="'.$infos_event['name'].'" /></td>'."\n";
|
||||||
print '<td><input class="flat" type="text" size="2" name="optValue['.$infos_event['rowid'].']" value="'.$infos_event['value'].'" /> '.$langs->trans('Jours').'</td>'."\n";
|
print '<td><input class="flat" type="text" size="2" name="optValue['.$infos_event['rowid'].']" value="'.$infos_event['value'].'" /> '.$langs->trans('Jours').'</td>'."\n";
|
||||||
print '<td><input type="submit" class="button" name="update_event['.$infos_event['rowid'].']" value="'.dol_escape_htmltag($langs->trans("Update")).'"/></td>'."\n";
|
print '<td><input type="submit" class="button" name="update_event['.$infos_event['rowid'].']" value="'.dol_escape_htmltag($langs->trans("Save")).'"/></td>'."\n";
|
||||||
print '<td width="20px" align="right"><input type="image" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/delete.png" name="delete_event['.$infos_event['rowid'].']" style="border:0;"/></td>'."\n";
|
print '<td width="20px" align="right"><input type="image" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/delete.png" name="delete_event['.$infos_event['rowid'].']" style="border:0;"/></td>'."\n";
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
@ -388,6 +382,7 @@ if($cp_events == 1) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'?leftmenu=setup" name="event_create">'."\n";
|
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'?leftmenu=setup" name="event_create">'."\n";
|
||||||
|
print '<input type="hidden" name="action" value="create_event" />'."\n";
|
||||||
|
|
||||||
print $langs->trans('TitleCreateEventCP');
|
print $langs->trans('TitleCreateEventCP');
|
||||||
|
|
||||||
@ -398,16 +393,14 @@ print '<tr class="liste_titre">';
|
|||||||
|
|
||||||
print '<td class="liste_titre" width="40%">'.$langs->trans('NameEventCP').'</td>';
|
print '<td class="liste_titre" width="40%">'.$langs->trans('NameEventCP').'</td>';
|
||||||
print '<td class="liste_titre" width="20%">'.$langs->trans('ValueOptionCP').'</td>';
|
print '<td class="liste_titre" width="20%">'.$langs->trans('ValueOptionCP').'</td>';
|
||||||
print '<td class="liste_titre">'.$langs->trans('CreateEventCP').'</td>';
|
print '<td class="liste_titre"> </td>';
|
||||||
|
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
print '<input type="hidden" name="action" value="create_event" />'."\n";
|
|
||||||
|
|
||||||
print '<tr class="pair">';
|
print '<tr class="pair">';
|
||||||
print '<td><input class="flat" type="text" size="40" name="optName" value="" /></td>'."\n";
|
print '<td><input class="flat" type="text" size="40" name="optName" value="'.(is_array($optName)?'':$optName).'" /></td>'."\n";
|
||||||
print '<td><input class="flat" type="text" size="2" name="optValue" value="" /> '.$langs->trans('Jours').'</td>'."\n";
|
print '<td><input class="flat" type="text" size="2" name="optValue" value="'.(is_array($optValue)?'':$optValue).'" /> '.$langs->trans('Jours').'</td>'."\n";
|
||||||
print '<td><input type="submit" class="button" name="button" value="'.$langs->trans('ValidEventCP').'" /></td>'."\n";
|
print '<td><input type="submit" class="button" name="button" value="'.$langs->trans('CreateEventCP').'" /></td>'."\n";
|
||||||
print '</tr>'."\n";
|
print '</tr>'."\n";
|
||||||
|
|
||||||
print '</tbody>';
|
print '</tbody>';
|
||||||
|
|||||||
21
htdocs/install/mysql/tables/llx_holiday.key.sql
Normal file
21
htdocs/install/mysql/tables/llx_holiday.key.sql
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
-- ===================================================================
|
||||||
|
-- Copyright (C) 2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
--
|
||||||
|
-- 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 2 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 <http://www.gnu.org/licenses/>.
|
||||||
|
--
|
||||||
|
-- ===================================================================
|
||||||
|
|
||||||
|
ALTER TABLE llx_holiday ADD INDEX idx_holiday_fk_user (fk_user);
|
||||||
|
ALTER TABLE llx_holiday ADD INDEX idx_holiday_date_debut (date_debut);
|
||||||
|
ALTER TABLE llx_holiday ADD INDEX idx_holiday_date_fin (date_fin);
|
||||||
@ -1,19 +1,19 @@
|
|||||||
CREATE TABLE llx_holiday
|
CREATE TABLE llx_holiday
|
||||||
(
|
(
|
||||||
rowid INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||||
fk_user INT( 11 ) NOT NULL ,
|
fk_user integer NOT NULL,
|
||||||
date_create DATETIME NOT NULL ,
|
date_create DATETIME NOT NULL,
|
||||||
description VARCHAR( 255 ) NOT NULL ,
|
description VARCHAR( 255 ) NOT NULL,
|
||||||
date_debut DATE NOT NULL ,
|
date_debut DATE NOT NULL,
|
||||||
date_fin DATE NOT NULL ,
|
date_fin DATE NOT NULL,
|
||||||
statut INT( 11 ) NOT NULL DEFAULT '1',
|
statut integer NOT NULL DEFAULT '1',
|
||||||
fk_validator INT( 11 ) NOT NULL ,
|
fk_validator integer NOT NULL,
|
||||||
date_valid DATETIME NULL DEFAULT NULL ,
|
date_valid DATETIME DEFAULT NULL,
|
||||||
fk_user_valid INT( 11 ) NULL DEFAULT NULL ,
|
fk_user_valid integer DEFAULT NULL,
|
||||||
date_refuse DATETIME NULL DEFAULT NULL ,
|
date_refuse DATETIME DEFAULT NULL,
|
||||||
fk_user_refuse INT( 11 ) NULL DEFAULT NULL ,
|
fk_user_refuse integer DEFAULT NULL,
|
||||||
date_cancel DATETIME NULL DEFAULT NULL ,
|
date_cancel DATETIME DEFAULT NULL,
|
||||||
fk_user_cancel INT( 11 ) NULL DEFAULT NULL,
|
fk_user_cancel integer DEFAULT NULL,
|
||||||
detail_refuse varchar( 250 ) NULL DEFAULT NULL
|
detail_refuse varchar( 250 ) DEFAULT NULL
|
||||||
)
|
)
|
||||||
ENGINE=innodb;
|
ENGINE=innodb;
|
||||||
@ -1,6 +1,24 @@
|
|||||||
|
-- ===================================================================
|
||||||
|
-- Copyright (C) 2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
--
|
||||||
|
-- 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 2 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 <http://www.gnu.org/licenses/>.
|
||||||
|
--
|
||||||
|
-- ===================================================================
|
||||||
|
|
||||||
CREATE TABLE llx_holiday_config
|
CREATE TABLE llx_holiday_config
|
||||||
(
|
(
|
||||||
rowid INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||||
name VARCHAR( 255 ) NOT NULL UNIQUE,
|
name VARCHAR( 255 ) NOT NULL UNIQUE,
|
||||||
value TEXT NULL
|
value TEXT NULL
|
||||||
)
|
)
|
||||||
|
|||||||
19
htdocs/install/mysql/tables/llx_holiday_events.key.sql
Normal file
19
htdocs/install/mysql/tables/llx_holiday_events.key.sql
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
-- ===================================================================
|
||||||
|
-- Copyright (C) 2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
--
|
||||||
|
-- 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 2 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 <http://www.gnu.org/licenses/>.
|
||||||
|
--
|
||||||
|
-- ===================================================================
|
||||||
|
|
||||||
|
ALTER TABLE llx_holiday_events ADD UNIQUE INDEX uk_holiday_name (name, entity);
|
||||||
@ -1,7 +1,26 @@
|
|||||||
|
-- ===================================================================
|
||||||
|
-- Copyright (C) 2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
--
|
||||||
|
-- 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 2 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 <http://www.gnu.org/licenses/>.
|
||||||
|
--
|
||||||
|
-- ===================================================================
|
||||||
|
|
||||||
CREATE TABLE llx_holiday_events
|
CREATE TABLE llx_holiday_events
|
||||||
(
|
(
|
||||||
rowid INT( 11 ) NOT NULL PRIMARY KEY AUTO_INCREMENT ,
|
rowid integer NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||||
name VARCHAR( 255 ) NOT NULL ,
|
entity integer DEFAULT 1 NOT NULL, -- multi company id
|
||||||
value TEXT NOT NULL
|
name VARCHAR( 255 ) NOT NULL,
|
||||||
|
value TEXT NOT NULL
|
||||||
)
|
)
|
||||||
ENGINE=innodb;
|
ENGINE=innodb;
|
||||||
@ -1,11 +1,29 @@
|
|||||||
|
-- ===================================================================
|
||||||
|
-- Copyright (C) 2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
--
|
||||||
|
-- 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 2 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 <http://www.gnu.org/licenses/>.
|
||||||
|
--
|
||||||
|
-- ===================================================================
|
||||||
|
|
||||||
CREATE TABLE llx_holiday_logs
|
CREATE TABLE llx_holiday_logs
|
||||||
(
|
(
|
||||||
rowid INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
|
rowid integer NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||||
date_action DATETIME NOT NULL ,
|
date_action DATETIME NOT NULL,
|
||||||
fk_user_action INT( 11 ) NOT NULL ,
|
fk_user_action integer NOT NULL,
|
||||||
fk_user_update INT( 11 ) NOT NULL ,
|
fk_user_update integer NOT NULL,
|
||||||
type_action VARCHAR( 255 ) NOT NULL ,
|
type_action VARCHAR( 255 ) NOT NULL,
|
||||||
prev_solde VARCHAR( 255 ) NOT NULL ,
|
prev_solde VARCHAR( 255 ) NOT NULL,
|
||||||
new_solde VARCHAR( 255 ) NOT NULL
|
new_solde VARCHAR( 255 ) NOT NULL
|
||||||
)
|
)
|
||||||
ENGINE=innodb;
|
ENGINE=innodb;
|
||||||
@ -1,6 +1,6 @@
|
|||||||
CREATE TABLE llx_holiday_users
|
CREATE TABLE llx_holiday_users
|
||||||
(
|
(
|
||||||
fk_user INT( 11 ) NOT NULL PRIMARY KEY,
|
fk_user integer NOT NULL PRIMARY KEY,
|
||||||
nb_holiday FLOAT( 5 ) NOT NULL DEFAULT '0'
|
nb_holiday real NOT NULL DEFAULT '0'
|
||||||
)
|
)
|
||||||
ENGINE=innodb;
|
ENGINE=innodb;
|
||||||
Loading…
Reference in New Issue
Block a user