Skip to content
Snippets Groups Projects
Commit 8df59134 authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Merge pull request #3705 from aspangaro/develop-hrm

New : Module HRM
parents cac4a85c aac88519
No related branches found
No related tags found
No related merge requests found
Showing
with 1621 additions and 4 deletions
......@@ -146,6 +146,12 @@ source_file = htdocs/langs/en_US/holiday.lang
source_lang = en_US
type = MOZILLAPROPERTIES
[dolibarr.hrm]
file_filter = htdocs/langs/<lang>/hrm.lang
source_file = htdocs/langs/en_US/hrm.lang
source_lang = en_US
type = MOZILLAPROPERTIES
[dolibarr.incoterm]
file_filter = htdocs/langs/<lang>/incoterm.lang
source_file = htdocs/langs/en_US/incoterm.lang
......
......@@ -37,6 +37,7 @@ $langs->load("companies");
$langs->load("products");
$langs->load("members");
$langs->load("projects");
$langs->load("hrm");
if (! $user->admin) accessforbidden();
......@@ -46,10 +47,10 @@ $action = GETPOST('action');
if (! defined("MAIN_MOTD")) define("MAIN_MOTD","");
// List of supported permanent search area
$searchform=array("MAIN_SEARCHFORM_SOCIETE", "MAIN_SEARCHFORM_CONTACT", "MAIN_SEARCHFORM_PRODUITSERVICE", "MAIN_SEARCHFORM_PRODUITSERVICE_SUPPLIER", "MAIN_SEARCHFORM_ADHERENT", "MAIN_SEARCHFORM_PROJECT");
$searchformconst=array($conf->global->MAIN_SEARCHFORM_SOCIETE,$conf->global->MAIN_SEARCHFORM_CONTACT,$conf->global->MAIN_SEARCHFORM_PRODUITSERVICE,$conf->global->MAIN_SEARCHFORM_PRODUITSERVICE_SUPPLIER,$conf->global->MAIN_SEARCHFORM_ADHERENT,$conf->global->MAIN_SEARCHFORM_PROJECT);
$searchformtitle=array($langs->trans("Companies"), $langs->trans("Contacts"), $langs->trans("ProductsAndServices"), $langs->trans("ProductsAndServices").' ('.$langs->trans("SupplierRef").')', $langs->trans("Members"), $langs->trans("Projects"));
$searchformmodule=array('Module1Name','Module1Name','Module50Name','Module50Name','Module310Name','Module400Name');
$searchform=array("MAIN_SEARCHFORM_SOCIETE", "MAIN_SEARCHFORM_CONTACT", "MAIN_SEARCHFORM_PRODUITSERVICE", "MAIN_SEARCHFORM_PRODUITSERVICE_SUPPLIER", "MAIN_SEARCHFORM_ADHERENT", "MAIN_SEARCHFORM_PROJECT", "MAIN_SEARCHFORM_EMPLOYEE");
$searchformconst=array($conf->global->MAIN_SEARCHFORM_SOCIETE,$conf->global->MAIN_SEARCHFORM_CONTACT,$conf->global->MAIN_SEARCHFORM_PRODUITSERVICE,$conf->global->MAIN_SEARCHFORM_PRODUITSERVICE_SUPPLIER,$conf->global->MAIN_SEARCHFORM_ADHERENT,$conf->global->MAIN_SEARCHFORM_PROJECT,$conf->global->MAIN_SEARCHFORM_EMPLOYEE);
$searchformtitle=array($langs->trans("Companies"), $langs->trans("Contacts"), $langs->trans("ProductsAndServices"), $langs->trans("ProductsAndServices").' ('.$langs->trans("SupplierRef").')', $langs->trans("Members"), $langs->trans("Projects"), $langs->trans("Employees"));
$searchformmodule=array('Module1Name','Module1Name','Module50Name','Module50Name','Module310Name','Module4000Name');
if ($action == 'update')
......@@ -83,6 +84,7 @@ if ($action == 'update')
dolibarr_set_const($db, "MAIN_SEARCHFORM_PRODUITSERVICE_SUPPLIER",$_POST["MAIN_SEARCHFORM_PRODUITSERVICE_SUPPLIER"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_SEARCHFORM_ADHERENT", $_POST["MAIN_SEARCHFORM_ADHERENT"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_SEARCHFORM_PROJECT", $_POST["MAIN_SEARCHFORM_PROJECT"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_SEARCHFORM_EMPLOYEE", $_POST["MAIN_SEARCHFORM_EMPLOYEE"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_HELPCENTER_DISABLELINK", $_POST["MAIN_HELPCENTER_DISABLELINK"],'chaine',0,'',0); // Param for all entities
dolibarr_set_const($db, "MAIN_MOTD", dol_htmlcleanlastbr($_POST["main_motd"]),'chaine',0,'',$conf->entity);
......
<?php
/* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.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 <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/core/lib/hrm.lib.php
* \ingroup HRM
* \brief Library for hrm
*/
$langs->load('hrm');
/**
* Return head table for employee tabs screen
*
* @param object $object contact
* @return array head table of tabs
*/
function employee_prepare_head($object) {
global $langs, $conf, $user;
$h = 0;
$head = array ();
$head [$h] [0] = DOL_URL_ROOT.'/hrm/employee/card.php?id=' . $object->id;
$head [$h] [1] = $langs->trans("Card");
$head [$h] [2] = 'card';
$h ++;
complete_head_from_modules($conf, $langs, $object, $head, $h, 'employee');
$head [$h] [0] = DOL_URL_ROOT.'/hrm/employee/info.php?id=' . $object->id;
$head [$h] [1] = $langs->trans("Info");
$head [$h] [2] = 'info';
$h ++;
complete_head_from_modules($conf, $langs, $object, $head, $h, 'employee', 'remove');
return $head;
}
/**
* Return head table for establishment tabs screen
*
* @param Establishment $object Object related to tabs
* @return array Array of tabs to show
*/
function establishment_prepare_head($object)
{
global $langs, $conf;
$h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT.'/hrm/establishment/card.php?id=' . $object->id;
$head[$h][1] = $langs->trans("Card");
$head[$h][2] = 'card';
$h++;
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'establishment');
$head[$h][0] = DOL_URL_ROOT.'/hrm/establishment/info.php?id=' . $object->id;
$head[$h][1] = $langs->trans("Info");
$head[$h][2] = 'info';
$h++;
complete_head_from_modules($conf,$langs,$object,$head,$h,'establishment','remove');
return $head;
}
/**
* Return array head with list of tabs to view object informations
*
* @return array head
*/
function hrm_admin_prepare_head()
{
global $langs, $conf, $user;
$h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT.'/hrm/admin/admin_hrm.php';
$head[$h][1] = $langs->trans("Parameters");
$head[$h][2] = 'parameters';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/hrm/admin/admin_establishment.php';
$head[$h][1] = $langs->trans("Establishments");
$head[$h][2] = 'establishments';
$h++;
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,'',$head,$h,'hrm_admin');
complete_head_from_modules($conf,$langs,'',$head,$h,'hrm_admin','remove');
return $head;
}
<?php
/* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.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 <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/core/modules/modHRM.class.php
* \ingroup HRM
* \brief Description and activation file for module HRM
*/
include_once (DOL_DOCUMENT_ROOT . "/core/modules/DolibarrModules.class.php");
/**
* \class modHRM
* \brief Class to describe and activate the HRM module
*/
class modHRM extends DolibarrModules
{
/**
* Constructor.
* Define names, constants, directories, boxes, permissions
*
* @param DoliDB $db
*/
public function __construct($db)
{
global $langs, $conf;
$this->db = $db;
$this->numero = 4000;
$this->rights_class = 'hrm';
$this->family = "hr";
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
$this->name = preg_replace ( '/^mod/i', '', get_class ( $this ) );
$this->description = "Gestion des ressources humaines";
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
$this->version = 'develop';
$this->const_name = 'MAIN_MODULE_' . strtoupper ( $this->name );
$this->special = 0;
// $this->picto = '';
// define triggers
$this->module_parts = array();
// Data directories to create when module is enabled
$this->dirs = array();
// Config pages
$this->config_page_url = array('admin_hrm.php@hrm');
// Dependencies
$this->depends = array();
$this->requiredby = array(/*"
modSalaries,
modExpenseReport,
modHoliday
"*/);
$this->conflictwith = array();
$this->phpmin = array (
5,
3
); // Minimum version of PHP required by module
$this->need_dolibarr_version = array (
3,
7
); // Minimum version of Dolibarr required by module
$this->langfiles = array (
"hrm"
);
// Dictionnaries
$this->dictionnaries=array(
'langs'=>'hrm',
'tabname'=>array(
MAIN_DB_PREFIX."c_hrm_department",
MAIN_DB_PREFIX."c_hrm_function"
),
'tablib'=>array(
"DepartmentDict",
"FunctionDict"
),
'tabsql'=>array(
'SELECT rowid, pos, code, label, active FROM '.MAIN_DB_PREFIX.'c_hrm_department',
'SELECT rowid, pos, code, label, c_level, active FROM '.MAIN_DB_PREFIX.'c_hrm_department'
),
'tabsqlsort'=>array(
'rowid ASC',
'rowid ASC'
),
'tabfield'=>array(
"code,label",
"code,label"
),
'tabfieldvalue'=>array(
"code,label",
"code,label"
),
'tabfieldinsert'=>array(
"code,label",
"code,label"
),
'tabrowid'=>array(
"rowid",
"rowid"
),
'tabcond'=>array(
'$conf->hrm->enabled',
'$conf->hrm->enabled'
)
);
// Constantes
$this->const = array ();
$r = 0;
// Boxes
$this->boxes = array ();
// Permissions
$this->rights = array(); // Permission array used by this module
$r = 0;
$this->rights[$r][0] = 4001;
$this->rights[$r][1] = 'See employees';
$this->rights[$r][3] = 1;
$this->rights[$r][4] = 'employee';
$this->rights[$r][5] = 'read';
$r ++;
$this->rights[$r][0] = 4002;
$this->rights[$r][1] = 'Create employees';
$this->rights[$r][3] = 1;
$this->rights[$r][4] = 'employee';
$this->rights[$r][5] = 'write';
$r ++;
$this->rights[$r][0] = 4003;
$this->rights[$r][1] = 'Delete employees';
$this->rights[$r][3] = 1;
$this->rights[$r][4] = 'employee';
$this->rights[$r][5] = 'delete';
$r ++;
$this->rights[$r][0] = 4004;
$this->rights[$r][1] = 'Export employees';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'employee';
$this->rights[$r][5] = 'export';
$r ++;
// Main menu entries
$this->menus = array (); // List of menus to add
$r = 0;
$this->menu[$r] = array (
'fk_menu' => 'fk_mainmenu=hrm',
'type' => 'left',
'titre' => 'Employees',
'leftmenu' => 'employee',
'mainmenu' => 'hrm',
'url' => '/hrm/employee/index.php',
'langs' => 'hrm',
'position' => 100,
'enabled' => '$user->rights->hrm->employee->read',
'perms' => '$user->rights->hrm->employee->read',
'target' => '',
'user' => 0
);
$r ++;
$this->menu[$r] = array(
'fk_menu' => 'fk_mainmenu=hrm,fk_leftmenu=employee',
'type' => 'left',
'titre' => 'NewEmployee',
'mainmenu' => 'hrm',
'url' => '/hrm/employee/card.php?action=create',
'langs' => 'hrm',
'position' => 101,
'enabled' => '$user->rights->hrm->employee->write',
'perms' => '$user->rights->hrm->employee->write',
'target' => '',
'user' => 0
);
$r ++;
$this->menu[$r] = array(
'fk_menu' => 'fk_mainmenu=hrm,fk_leftmenu=employee',
'type' => 'left',
'titre' => 'List',
'mainmenu' => 'hrm',
'url' => '/hrm/employee/list.php',
'langs' => 'hrm',
'position' => 102,
'enabled' => '$user->rights->hrm->employee->read',
'perms' => '$user->rights->hrm->employee->read',
'target' => '',
'user' => 0
);
$r ++;
$this->menu[$r] = array(
'fk_menu' => 'fk_mainmenu=hrm,fk_leftmenu=employee',
'type' => 'left',
'titre' => 'Statistics',
'mainmenu' => 'hrm',
'url' => '/hrm/employee/stats.php',
'langs' => 'hrm',
'position' => 103,
'enabled' => '$user->rights->hrm->employee->read',
'perms' => '$user->rights->hrm->employee->read',
'target' => '',
'user' => 0
);
$r ++;
}
/**
* Function called when module is enabled.
* The init function add constants, boxes, permissions and menus
* (defined in constructor) into Dolibarr database.
* It also creates data directories
*
* @param string $options Enabling module ('', 'noboxes')
* @return int if OK, 0 if KO
*/
function init($options='')
{
// Permissions
$this->remove($options);
$sql = array();
return $this->_init($sql,$options);
}
}
<?php
/* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.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 <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/hrm/admin/admin_establishment.php
* \ingroup HRM
* \brief HRM Establishment module setup page
*/
require('../../main.inc.php');
require_once DOL_DOCUMENT_ROOT.'/core/lib/hrm.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once DOL_DOCUMENT_ROOT.'/hrm/class/establishment.class.php';
$langs->load("admin");
$langs->load('hrm');
if (! $user->admin)
accessforbidden();
$error=0;
$action = GETPOST('action', 'alpha');
$object = new Establishment($db);
/*
* Actions
*/
/*
* View
*/
$page_name = "Establishments";
llxHeader('', $langs->trans($page_name));
$form = new Form($db);
dol_htmloutput_mesg($mesg);
// Subheader
$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>';
print load_fiche_titre($langs->trans($page_name), $linkback);
// Configuration header
$head = hrm_admin_prepare_head();
dol_fiche_head($head, 'establishments', $langs->trans("HRM"), 0, "user");
$sql = "SELECT e.rowid, e.name, e.address, e.zip, e.town, e.status";
$sql.= " FROM ".MAIN_DB_PREFIX."establishment as e";
$sql.= " WHERE e.entity = ".$conf->entity;
$result = $db->query($sql);
if ($result)
{
$var=false;
$num = $db->num_rows($result);
$i = 0;
// Load attribute_label
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Ref").'</td>';
print '<td>'.$langs->trans("Name").'</td>';
print '<td>'.$langs->trans("Address").'</td>';
print '<td>'.$langs->trans("Zipcode").'</td>';
print '<td>'.$langs->trans("Town").'</td>';
print '<td align="right">'.$langs->trans("Status").'</td>';
print '</tr>';
if ($num)
{
$establishmentstatic=new Establishment($db);
while ($i < $num && $i < $max)
{
$obj = $db->fetch_object($result);
$fiscalyearstatic->id=$obj->rowid;
print '<tr '.$bc[$var].'>';
print '<td><a href="admin_establishment_card.php?id='.$obj->rowid.'">'.img_object($langs->trans("ShowEstablishment"),"building").' '.$obj->rowid.'</a></td>';
print '<td align="left">'.$obj->name.'</td>';
print '<td align="left">'.$obj->address.'</td>';
print '<td align="left">'.$obj->zip.'</td>';
print '<td align="left">'.$obj->town.'</td>';
print '<td align="right">'.$establishmentstatic->LibStatut($obj->status,5).'</td>';
print '</tr>';
$var=!$var;
$i++;
}
}
else
{
print '<tr '.$bc[$var].'><td colspan="6">'.$langs->trans("None").'</td></tr>';
}
print '</table>';
}
else
{
dol_print_error($db);
}
dol_fiche_end();
// Buttons
print '<div class="tabsAction">';
print '<a class="butAction" href="../establishment/card.php?action=create">'.$langs->trans("NewEstablishment").'</a>';
print '</div>';
llxFooter();
$db->close();
<?php
/* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.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 <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/hrm/admin/admin_hrm.php
* \ingroup HRM
* \brief HRM module setup page
*/
require('../../main.inc.php');
require_once DOL_DOCUMENT_ROOT.'/core/lib/hrm.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
$langs->load("admin");
$langs->load('hrm');
if (! $user->admin)
accessforbidden();
$action = GETPOST('action', 'alpha');
/*
* Actions
*/
/*
* View
*/
$page_name = "Parameters";
llxHeader('', $langs->trans($page_name));
$form = new Form($db);
dol_htmloutput_mesg($mesg);
// Subheader
$linkback = '<a href="' . DOL_URL_ROOT . '/admin/modules.php">' . $langs->trans("BackToModuleList") . '</a>';
print load_fiche_titre($langs->trans($page_name), $linkback);
// Configuration header
$head = hrm_admin_prepare_head();
dol_fiche_head($head, 'parameters', $langs->trans("HRM"), 0, "user");
llxFooter();
$db->close();
<?php
/* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.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 <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/hrm/class/establishment.class.php
* \ingroup HRM
* \brief File of class to manage establishments
*/
require_once DOL_DOCUMENT_ROOT .'/core/class/commonobject.class.php';
/**
* Class to manage establishments
*/
class Establishment extends CommonObject
{
public $element='establishment';
public $table_element='establishment';
public $table_element_line = '';
public $fk_element = 'fk_establishment';
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
var $rowid;
var $name;
var $address;
var $zip;
var $town;
var $status; // 0=open, 1=closed
var $entity;
var $statuts=array();
var $statuts_short=array();
/**
* Constructor
*
* @param DoliDB $db Database handler
*/
function __construct($db)
{
$this->db = $db;
$this->statuts_short = array(0 => 'Opened', 1 => 'Closed');
$this->statuts = array(0 => 'Opened', 1 => 'Closed');
return 1;
}
/**
* Create object in database
*
* @param User $user User making creation
* @return int <0 if KO, >0 if OK
*/
function create($user)
{
global $conf;
$error = 0;
$now=dol_now();
$this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."establishment (";
$sql.= "name";
$sql.= ", address";
$sql.= ", zip";
$sql.= ", town";
$sql.= ", status";
$sql.= ", entity";
$sql.= ", datec";
$sql.= ", fk_user_author";
$sql.= ") VALUES (";
$sql.= " '".$this->name."'";
$sql.= ", '".$this->address."'";
$sql.= ", '".$this->zip."'";
$sql.= ", '".$this->town."'";
$sql.= ", ".$this->status;
$sql.= ", ".$conf->entity;
$sql.= ", '".$this->db->idate($now)."'";
$sql.= ", ". $user->id;
$sql.= ")";
$this->db->begin();
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$resql = $this->db->query($sql);
if (! $resql) {
$error ++;
$this->errors[] = "Error " . $this->db->lasterror();
}
if (! $error) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "establishment");
}
// Commit or rollback
if ($error) {
foreach ( $this->errors as $errmsg ) {
dol_syslog(get_class($this) . "::create " . $errmsg, LOG_ERR);
$this->error .= ($this->error ? ', ' . $errmsg : $errmsg);
}
$this->db->rollback();
return - 1 * $error;
} else {
$this->db->commit();
return $this->id;
}
}
/**
* Update record
*
* @param User $user User making update
* @return int <0 if KO, >0 if OK
*/
function update($user)
{
global $langs;
// Check parameters
if (empty($this->name))
{
$this->error='ErrorBadParameter';
return -1;
}
$this->db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."establishment";
$sql .= " SET name = '".$this->name."'";
$sql .= ", address = '".$this->address."'";
$sql .= ", zip = '".$this->zip."'";
$sql .= ", town = '".$this->town."'";
$sql .= ", status = '".$this->status."'";
$sql .= ", fk_user_mod = " . $user->id;
$sql .= " WHERE rowid = ".$this->id;
dol_syslog(get_class($this) . "::update sql=" . $sql, LOG_DEBUG);
$result = $this->db->query($sql);
if ($result) {
$this->db->commit();
return 1;
} else {
$this->error = $this->db->lasterror();
$this->db->rollback();
return - 1;
}
}
/**
* Load an object from database
*
* @param int $id Id of record to load
* @return int <0 if KO, >0 if OK
*/
function fetch($id)
{
$sql = "SELECT rowid, name, address, zip, town, status";
$sql.= " FROM ".MAIN_DB_PREFIX."establishment";
$sql.= " WHERE rowid = ".$id;
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$result = $this->db->query($sql);
if ( $result )
{
$obj = $this->db->fetch_object($result);
$this->id = $obj->rowid;
$this->name = $obj->name;
$this->address = $obj->address;
$this->zip = $obj->zip;
$this->town = $obj->town;
$this->status = $obj->status;
return 1;
}
else
{
$this->error=$this->db->lasterror();
return -1;
}
}
/**
* Delete record
*
* @param int $id Id of record to delete
* @return int <0 if KO, >0 if OK
*/
function delete($id)
{
$this->db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."establishment WHERE rowid = ".$id;
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
$this->db->commit();
return 1;
}
else
{
$this->error=$this->db->lasterror();
$this->db->rollback();
return -1;
}
}
/**
* Give a label from a status
*
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
* @return string Label
*/
function getLibStatus($mode=0)
{
return $this->LibStatus($this->status,$mode);
}
/**
* Give a label from a status
*
* @param int $status Id status
* @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
* @return string Label
*/
function LibStatus($status,$mode=0)
{
global $langs;
if ($mode == 0)
{
return $langs->trans($this->statuts[$status]);
}
if ($mode == 1)
{
return $langs->trans($this->statuts_short[$status]);
}
if ($mode == 2)
{
if ($status==0) return img_picto($langs->trans($this->statuts_short[$status]),'status4').' '.$langs->trans($this->statuts_short[$status]);
if ($status==1) return img_picto($langs->trans($this->statuts_short[$status]),'status8').' '.$langs->trans($this->statuts_short[$status]);
}
if ($mode == 3)
{
if ($status==0 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]),'status4');
if ($status==1 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]),'status8');
}
if ($mode == 4)
{
if ($status==0 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]),'status4').' '.$langs->trans($this->statuts[$status]);
if ($status==1 && ! empty($this->statuts_short[$status])) return img_picto($langs->trans($this->statuts_short[$status]),'status8').' '.$langs->trans($this->statuts[$status]);
}
if ($mode == 5)
{
if ($status==0 && ! empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]),'status4');
if ($status==1 && ! empty($this->statuts_short[$status])) return $langs->trans($this->statuts_short[$status]).' '.img_picto($langs->trans($this->statuts_short[$status]),'status8');
}
}
/**
* Information on record
*
* @param int $id Id of record
* @return void
*/
function info($id)
{
$sql = 'SELECT e.rowid, e.datec, e.fk_user_author, e.tms, e.fk_user_mod';
$sql.= ' FROM '.MAIN_DB_PREFIX.'establishment as e';
$sql.= ' WHERE e.rowid = '.$id;
dol_syslog(get_class($this)."::fetch info", LOG_DEBUG);
$result = $this->db->query($sql);
if ($result)
{
if ($this->db->num_rows($result))
{
$obj = $this->db->fetch_object($result);
$this->id = $obj->rowid;
if ($obj->fk_user_author)
{
$cuser = new User($this->db);
$cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser;
}
if ($obj->fk_user_modif)
{
$muser = new User($this->db);
$muser->fetch($obj->fk_user_mod);
$this->user_modification = $muser;
}
$this->date_creation = $this->db->jdate($obj->datec);
$this->date_modification = $this->db->jdate($obj->tms);
}
$this->db->free($result);
}
else
{
dol_print_error($this->db);
}
}
}
<?php
/* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.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 <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/hrm/establishment/card.php
* \brief Page to show an establishment
*/
require('../../main.inc.php');
require_once DOL_DOCUMENT_ROOT.'/core/lib/hrm.lib.php';
require_once DOL_DOCUMENT_ROOT.'/hrm/class/establishment.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
$langs->load("admin");
$langs->load("hrm");
// Security check
if (! $user->admin) accessforbidden();
$error=0;
$action = GETPOST('action','alpha');
$cancel = GETPOST('cancel', 'alpha');
$confirm = GETPOST('confirm','alpha');
$id = GETPOST('id','int');
// List of status
static $tmpstatus2label=array(
'0'=>'OpenEtablishment',
'1'=>'CloseEtablishment'
);
$status2label=array('');
foreach ($tmpstatus2label as $key => $val) $status2label[$key]=$langs->trans($val);
$object = new Establishment($db);
/*
* Actions
*/
if ($action == 'confirm_delete' && $confirm == "yes")
{
$result=$object->delete($id);
if ($result >= 0)
{
header("Location: ../admin/admin_establishment.php");
exit;
}
else
{
setEventMessage($object->error, 'errors');
}
}
else if ($action == 'add')
{
if (! $cancel)
{
$error=0;
$object->name = GETPOST('name', 'alpha');
if (empty($object->name))
{
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Name")), 'errors');
$error++;
}
if (empty($error))
{
$tmparray=getCountry(GETPOST('country_id','int'),'all',$db,$langs,0);
if (! empty($tmparray['id']))
{
$object->country_id =$tmparray['id'];
$object->country_code =$tmparray['code'];
$object->country_label=$tmparray['label'];
}
$object->address = GETPOST('address', 'alpha');
$object->zip = GETPOST('zipcode', 'alpha');
$object->town = GETPOST('town', 'alpha');
$object->fk_pays = $object->country_id;
$object->status = GETPOST('status','int');
$object->fk_user_author = $user->id;
$object->datec = dol_now();
$id = $object->create($user);
if ($id > 0)
{
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
exit;
}
else
{
setEventMessage($object->error, 'errors');
$action='create';
}
}
else
{
$action='create';
}
}
else
{
header("Location: ../admin/admin_establishment.php");
exit;
}
}
// Update record
else if ($action == 'update')
{
$error = 0;
if (! $cancel) {
$name = GETPOST('name', 'alpha');
if (empty($name)) {
setEventMessage($langs->trans('ErrorFieldRequired', $langs->trans('NameProperty')), 'errors');
$error ++;
}
$typeid = GETPOST('typeid', 'int');
if (empty($typeid)) {
setEventMessage($langs->trans('ErrorFieldRequired', $langs->trans('TypeProperty')), 'errors');
$error ++;
}
if (empty($error)) {
$object->name = GETPOST('name', 'alpha');
$object->address = GETPOST('address', 'alpha');
$object->zip = GETPOST('zipcode', 'alpha');
$object->town = GETPOST('town', 'alpha');
$object->fk_pays = GETPOST('country_id', 'int');
$object->rowid = GETPOST('id');
$object->fk_user_mod = $user->id;
$id = $object->update();
if ($id > 0)
{
header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $id);
exit;
}
else
{
setEventMessage($object->error, 'errors');
$action='create';
}
}
} else {
header("Location: card.php?id=" . $id);
exit;
}
}
/*
* View
*/
llxHeader();
$form = new Form($db);
$formcompany = new FormCompany($db);
/*
* Action create
*/
if ($action == 'create')
{
print load_fiche_titre($langs->trans("NewEstablishment"));
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="add">';
dol_fiche_head();
print '<table class="border" width="100%">';
// Name
print '<tr><td class="fieldrequired"><label for="name">'.$langs->trans("Name").'</label></td><td><input name="name" id="name" size="32" value="' . GETPOST("name") . '"></td></tr>';
// Address
print '<tr>';
print '<td><label for="address">' . $langs->trans("Address") . '</label></td>';
print '<td>';
print '<input name="address" id="address" size="32" value="' . $object->address . '">';
print '</td>';
print '</tr>';
// Zipcode
print '<tr>';
print '<td><label for="zipcode">' . $langs->trans('Zip') . '</label></td>';
print '<td>';
print $formcompany->select_ziptown(GETPOST('zipcode', 'alpha'), 'zipcode', array (
'town',
'selectcountry_id'
), 6);
print '</td>';
print '</tr>';
// Town
print '<tr>';
print '<td><label for="town">' . $langs->trans('Town') . '</label></td>';
print '<td>';
print $formcompany->select_ziptown(GETPOST('town', 'alpha'), 'town', array (
'zipcode',
'selectcountry_id'
));
print '</td>';
print '</tr>';
// Country
print '<tr>';
print '<td><label for="selectcountry_id">' . $langs->trans("Country") . '</label></td>';
print '<td class="maxwidthonsmartphone">';
print $form->select_country($mysoc->country_id,'country_id');
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
print '</td>';
print '</tr>';
// Status
print '<tr>';
print '<td class="fieldrequired"><label for="status">'.$langs->trans("Status").'</label></td>';
print '<td>';
print $form->selectarray('status',$status2label,GETPOST('status'));
print '</td></tr>';
print '</table>';
dol_fiche_end();
print '<div class="center">';
print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
print '</div>';
print '</form>';
}
else if ($id)
{
$result = $object->fetch($id);
if ($result > 0)
{
$head = establishment_prepare_head($object);
if ($action == 'edit')
{
dol_fiche_head($head, 'card', $langs->trans("Establishment"), 0, 'building');
print '<form name="update" action="' . $_SERVER["PHP_SELF"] . '" method="POST">' . "\n";
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
print '<input type="hidden" name="id" value="'.$id.'">';
print '<table class="border" width="100%">';
// Ref
print "<tr>";
print '<td width="20%">'.$langs->trans("Ref").'</td><td>';
print $object->rowid;
print '</td></tr>';
// Name
print '<tr><td class="fieldrequired"><label for="name">'.$langs->trans("Name").'</label></td><td>';
print '<input name="name" id="name" class="flat" size="32" value="'.$object->name.'">';
print '</td></tr>';
// Address
print '<tr>';
print '<td><label for="address">' . $langs->trans("Address") . '</label></td>';
print '<td>';
print '<input name="address" id="address" size="32" value="' . $object->address . '">';
print '</td>';
print '</tr>';
// Zipcode / Town
print '<tr><td><label for="zipcode">' . $langs->trans('Zip') . '</label></td><td>';
print $formcompany->select_ziptown($object->zip, 'zipcode', array (
'town',
'selectcountry_id'
), 6) . '</tr>';
print '<tr><td><label for="town">' . $langs->trans('Town') . '</label></td><td>';
print $formcompany->select_ziptown($object->town, 'town', array (
'zipcode',
'selectcountry_id'
)) . '</td></tr>';
// Country
print '<tr>';
print '<td><label for="selectcountry_id">' . $langs->trans("Country") . '</label></td>';
print '<td class="maxwidthonsmartphone">';
print $form->select_country($object->fk_pays,'country_id');
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
print '</td>';
print '</tr>';
// Status
print '<tr><td><label for="status">'.$langs->trans("Status").'</label></td><td>';
print $form->selectarray('status',$status2label,$object->status);
print '</td></tr>';
print '</table>';
dol_fiche_end();
print '<div class="center">';
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">';
print '</div>';
print '</form>';
}
else
{
/*
* Confirm delete
*/
if ($action == 'delete')
{
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$id,$langs->trans("DeleteEstablishment"),$langs->trans("ConfirmDeleteEstablishment"),"confirm_delete");
}
dol_fiche_head($head, 'card', $langs->trans("Establishment"), 0, 'building');
print '<table class="border" width="100%">';
$linkback = '<a href="../admin/admin_establishment.php">'.$langs->trans("BackToList").'</a>';
// Ref
print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td width="50%">';
print $object->rowid;
print '</td><td width="25%">';
print $linkback;
print '</td></tr>';
// Name
print '<tr>';
print '<td>'.$langs->trans("Name").'</td>';
print '<td colspan="2">'.$object->name.'</td>';
print '</tr>';
// Address
print '<tr>';
print '<td>'.$langs->trans("Address").'</td>';
print '<td colspan="2">'.$object->address.'</td>';
print '</tr>';
// Zipcode
print '<tr>';
print '<td>'.$langs->trans("Zipcode").'</td>';
print '<td colspan="2">'.$object->zip.'</td>';
print '</tr>';
// Town
print '<tr>';
print '<td>'.$langs->trans("Town").'</td>';
print '<td colspan="2">'.$object->town.'</td>';
print '</tr>';
// Country
print '<tr>';
print '<td>'.$langs->trans("Country").'</td>';
print '<td colspan="2">'.getCountry($object->fk_pays,1).'</td>';
print '</tr>';
// Status
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="2">'.$object->getLibStatus(4).'</td></tr>';
print "</table>";
dol_fiche_end();
/*
* Barre d'actions
*/
print '<div class="tabsAction">';
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=edit&id='.$id.'">'.$langs->trans('Modify').'</a>';
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=delete&id='.$id.'">'.$langs->trans('Delete').'</a>';
print '</div>';
}
}
else
{
dol_print_error($db);
}
}
llxFooter();
$db->close();
<?php
/* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.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 <http://www.gnu.org/licenses/>.
*/
/**
* \file htdocs/hrm/establishment/info.php
* \brief Page to show info of an establishment
*/
require('../../main.inc.php');
require_once DOL_DOCUMENT_ROOT.'/core/lib/hrm.lib.php';
require_once DOL_DOCUMENT_ROOT.'/hrm/class/establishment.class.php';
$langs->load("admin");
$langs->load("hrm");
// Security check
if (! $user->admin) accessforbidden();
$id = GETPOST('id','int');
// View
llxHeader();
if ($id)
{
$object = new Establishment($db);
$object->fetch($id);
$object->info($id);
$head = establishment_prepare_head($object);
dol_fiche_head($head, 'info', $langs->trans("Establishment"), 0, 'building');
print '<table width="100%"><tr><td>';
dol_print_object_info($object);
print '</td></tr></table>';
print '</div>';
}
$db->close();
llxFooter();
-- ============================================================================
-- Copyright (C) 2013 Jean-François Ferry <jfefe@aternatik.fr>
-- Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.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 <http://www.gnu.org/licenses/>.
--
-- ============================================================================
--
--
-- Ne pas placer de commentaire en fin de ligne, ce fichier est parsé lors
-- de l'install et tous les sigles '--' sont supprimés.
--
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(1, 5,'MANAGEMENT', 'Management', 1);
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(2, 10,'GESTION', 'Gestion', 1);
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(3, 15,'TRAINING', 'Training', 1);
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(4, 20,'IT', 'Inform. Technology (IT)', 1);
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(5, 25,'MARKETING', 'Marketing', 1);
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(6, 30,'SALES', 'Sales', 1);
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(7, 35,'LEGAL', 'Legal', 1);
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(8, 40,'FINANCIAL', 'Financial accounting', 1);
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(9, 45,'HUMANRES', 'Human resources', 1);
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(10, 50,'PURCHASING', 'Purchasing', 1);
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(11, 55,'SERVICES', 'Services', 1);
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(12, 60,'CUSTOMSERV', 'Customer service', 1);
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(13, 65,'CONSULTING', 'Consulting', 1);
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(14, 70,'LOGISTIC', 'Logistics', 1);
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(15, 75,'CONSTRUCT', 'Engineering/design', 1);
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(16, 80,'PRODUCTION', 'Manufacturing', 1);
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(17, 85,'QUALITY', 'Quality assurance', 1);
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(18, 85,'MAINT', 'Plant assurance', 1);
-- ============================================================================
-- Copyright (C) 2013 Jean-François Ferry <jfefe@aternatik.fr>
-- Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.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 <http://www.gnu.org/licenses/>.
--
-- ============================================================================
--
--
-- Ne pas placer de commentaire en fin de ligne, ce fichier est parsé lors
-- de l'install et tous les sigles '--' sont supprimés.
--
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(1, 5,'EXECBOARD', 'Executive board', 0, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(2, 10, 'MANAGDIR', 'Managing director', 1, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(3, 15, 'ACCOUNTMANAG', 'Account manager', 0, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(3, 20, 'ENGAGDIR', 'Engagement director', 1, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(4, 25, 'DIRECTOR', 'Director', 1, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(5, 30, 'PROJMANAG', 'Project manager', 0, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(6, 35, 'DEPHEAD', 'Department head', 0, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(7, 40, 'SECRETAR', 'Secretary', 0, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(8, 45, 'EMPLOYEE', 'Department employee', 0, 1);
--
-- Be carefull to requests order.
-- This file must be loaded by calling /install/index.php page
-- when current version is 3.9.0 or higher.
--
-- To rename a table: ALTER TABLE llx_table RENAME TO llx_table_new;
-- To add a column: ALTER TABLE llx_table ADD COLUMN newcol varchar(60) NOT NULL DEFAULT '0' AFTER existingcol;
-- To rename a column: ALTER TABLE llx_table CHANGE COLUMN oldname newname varchar(60);
-- To drop a column: ALTER TABLE llx_table DROP COLUMN oldname;
-- To change type of field: ALTER TABLE llx_table MODIFY COLUMN name varchar(60);
-- To drop a foreign key: ALTER TABLE llx_table DROP FOREIGN KEY fk_name;
-- To restrict request to Mysql version x.y use -- VMYSQLx.y
-- To restrict request to Pgsql version x.y use -- VPGSQLx.y
-- To make pk to be auto increment (mysql): VMYSQL4.3 ALTER TABLE llx_c_shipment_mode CHANGE COLUMN rowid rowid INTEGER NOT NULL AUTO_INCREMENT;
-- To make pk to be auto increment (postgres): VPGSQL8.2 NOT POSSIBLE. MUST DELETE/CREATE TABLE
-- To set a field as NULL: VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name DROP NOT NULL;
-- To set a field as default NULL: VPGSQL8.2 ALTER TABLE llx_table ALTER COLUMN name SET DEFAULT NULL;
-- -- VPGSQL8.2 DELETE FROM llx_usergroup_user WHERE fk_user NOT IN (SELECT rowid from llx_user);
-- -- VMYSQL4.1 DELETE FROM llx_usergroup_user WHERE fk_usergroup NOT IN (SELECT rowid from llx_usergroup);
CREATE TABLE IF NOT EXISTS llx_c_hrm_function
(
rowid integer PRIMARY KEY,
pos tinyint DEFAULT 0 NOT NULL,
code varchar(16) NOT NULL,
label varchar(50),
c_level tinyint DEFAULT 0 NOT NULL,
active tinyint DEFAULT 1 NOT NULL
)ENGINE=innodb;
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(1, 5,'EXECBOARD', 'Executive board', 0, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(2, 10, 'MANAGDIR', 'Managing director', 1, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(3, 15, 'ACCOUNTMANAG', 'Account manager', 0, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(3, 20, 'ENGAGDIR', 'Engagement director', 1, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(4, 25, 'DIRECTOR', 'Director', 1, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(5, 30, 'PROJMANAG', 'Project manager', 0, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(6, 35, 'DEPHEAD', 'Department head', 0, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(7, 40, 'SECRETAR', 'Secretary', 0, 1);
INSERT INTO llx_c_hrm_function (rowid, pos, code, label, c_level, active) VALUES(8, 45, 'EMPLOYEE', 'Department employee', 0, 1);
CREATE TABLE IF NOT EXISTS llx_c_hrm_department
(
rowid integer PRIMARY KEY,
pos tinyint DEFAULT 0 NOT NULL,
code varchar(16) NOT NULL,
label varchar(50),
active tinyint DEFAULT 1 NOT NULL
)ENGINE=innodb;
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(1, 5,'MANAGEMENT', 'Management', 1);
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(2, 10,'GESTION', 'Gestion', 1);
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(3, 15,'TRAINING', 'Training', 1);
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(4, 20,'IT', 'Inform. Technology (IT)', 1);
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(5, 25,'MARKETING', 'Marketing', 1);
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(6, 30,'SALES', 'Sales', 1);
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(7, 35,'LEGAL', 'Legal', 1);
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(8, 40,'FINANCIAL', 'Financial accounting', 1);
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(9, 45,'HUMANRES', 'Human resources', 1);
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(10, 50,'PURCHASING', 'Purchasing', 1);
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(11, 55,'SERVICES', 'Services', 1);
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(12, 60,'CUSTOMSERV', 'Customer service', 1);
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(13, 65,'CONSULTING', 'Consulting', 1);
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(14, 70,'LOGISTIC', 'Logistics', 1);
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(15, 75,'CONSTRUCT', 'Engineering/design', 1);
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(16, 80,'PRODUCTION', 'Manufacturing', 1);
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(17, 85,'QUALITY', 'Quality assurance', 1);
INSERT INTO llx_c_hrm_department (rowid, pos, code, label, active) VALUES(18, 85,'MAINT', 'Plant assurance', 1);
CREATE TABLE IF NOT EXISTS llx_establishment (
rowid integer NOT NULL auto_increment PRIMARY KEY,
entity integer NOT NULL DEFAULT 1,
name varchar(50),
address varchar(255),
zip varchar(25),
town varchar(50),
fk_state integer DEFAULT 0,
fk_country integer DEFAULT 0,
profid1 varchar(20),
profid2 varchar(20),
profid3 varchar(20),
phone varchar(20),
fk_user_author integer NOT NULL,
fk_user_mod integer NOT NULL,
datec datetime NOT NULL,
tms timestamp NOT NULL,
status tinyint DEFAULT 1
) ENGINE=InnoDB;
ALTER TABLE llx_user ADD COLUMN employee tinyint DEFAULT 0 AFTER ref_int;
--
-- Copyright (C) 2013 Jean-François Ferry <jfefe@aternatik.fr>
-- Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.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 <http://www.gnu.org/licenses/>.
create table llx_c_hrm_department
(
rowid integer PRIMARY KEY,
pos tinyint DEFAULT 0 NOT NULL,
code varchar(16) NOT NULL,
label varchar(50),
active tinyint DEFAULT 1 NOT NULL
)ENGINE=innodb;
--
-- Copyright (C) 2013 Jean-François Ferry <jfefe@aternatik.fr>
-- Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.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 <http://www.gnu.org/licenses/>.
create table llx_c_hrm_function
(
rowid integer PRIMARY KEY,
pos tinyint DEFAULT 0 NOT NULL,
code varchar(16) NOT NULL,
label varchar(50),
c_level tinyint DEFAULT 0 NOT NULL,
active tinyint DEFAULT 1 NOT NULL
)ENGINE=innodb;
-- ============================================================================
-- Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.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 <http://www.gnu.org/licenses/>.
--
-- ============================================================================
--
-- Structure de la table llx_establishment
--
CREATE TABLE IF NOT EXISTS llx_establishment (
rowid integer NOT NULL auto_increment PRIMARY KEY,
entity integer NOT NULL DEFAULT 1,
name varchar(50),
address varchar(255),
zip varchar(25),
town varchar(50),
fk_state integer DEFAULT 0,
fk_country integer DEFAULT 0,
profid1 varchar(20),
profid2 varchar(20),
profid3 varchar(20),
phone varchar(20),
fk_user_author integer NOT NULL,
fk_user_mod integer NOT NULL,
datec datetime NOT NULL,
tms timestamp NOT NULL,
status tinyint DEFAULT 1
) ENGINE=InnoDB;
......@@ -25,6 +25,8 @@ create table llx_user
ref_ext varchar(50), -- reference into an external system (not used by dolibarr)
ref_int varchar(50), -- reference into an internal system (deprecated)
employee tinyint DEFAULT 0, -- employee 0/1
datec datetime,
tms timestamp,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment