Add admin & first version to manage establishment
This commit is contained in:
parent
cd7c5645c7
commit
8f8de587b8
@ -62,7 +62,7 @@ class modHRM extends DolibarrModules
|
|||||||
$this->dirs = array ();
|
$this->dirs = array ();
|
||||||
|
|
||||||
// Config pages
|
// Config pages
|
||||||
$this->config_page_url = array('admin_hrm.php');
|
$this->config_page_url = array('admin_hrm.php@hrm');
|
||||||
|
|
||||||
// Dependencies
|
// Dependencies
|
||||||
$this->depends = array();
|
$this->depends = array();
|
||||||
|
|||||||
126
htdocs/hrm/admin/admin_establishment.php
Normal file
126
htdocs/hrm/admin/admin_establishment.php
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
<?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.statut";
|
||||||
|
$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("Statut").'</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->statut,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();
|
||||||
58
htdocs/hrm/admin/admin_hrm.php
Normal file
58
htdocs/hrm/admin/admin_hrm.php
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<?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_ihrm.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();
|
||||||
0
htdocs/hrm/admin/index.html
Normal file
0
htdocs/hrm/admin/index.html
Normal file
324
htdocs/hrm/class/establishment.class.php
Normal file
324
htdocs/hrm/class/establishment.class.php
Normal file
@ -0,0 +1,324 @@
|
|||||||
|
<?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/custom/ihrm/class/establishment.class.php
|
||||||
|
* \ingroup iHRM
|
||||||
|
* \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='ihrm_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 $statut; // 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."ihrm_establishment (";
|
||||||
|
$sql.= "name";
|
||||||
|
$sql.= ", address";
|
||||||
|
$sql.= ", zip";
|
||||||
|
$sql.= ", town";
|
||||||
|
$sql.= ", statut";
|
||||||
|
$sql.= ", entity";
|
||||||
|
$sql.= ", datec";
|
||||||
|
$sql.= ", fk_user_author";
|
||||||
|
$sql.= ") VALUES (";
|
||||||
|
$sql.= " '".$this->name."'";
|
||||||
|
$sql.= ", '".$this->address."'";
|
||||||
|
$sql.= ", '".$this->zip."'";
|
||||||
|
$sql.= ", '".$this->town."'";
|
||||||
|
$sql.= ", ".$this->statut;
|
||||||
|
$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 . "ihrm_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."ihrm_establishment";
|
||||||
|
$sql .= " SET name = '".$this->name."'";
|
||||||
|
$sql .= ", address = '".$this->address."'";
|
||||||
|
$sql .= ", zip = '".$this->zip."'";
|
||||||
|
$sql .= ", town = '".$this->town."'";
|
||||||
|
$sql .= ", statut = '".$this->statut."'";
|
||||||
|
$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, statut";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."ihrm_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->statut = $obj->statut;
|
||||||
|
|
||||||
|
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."ihrm_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 getLibStatut($mode=0)
|
||||||
|
{
|
||||||
|
return $this->LibStatut($this->statut,$mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Give a label from a status
|
||||||
|
*
|
||||||
|
* @param int $statut 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 LibStatut($statut,$mode=0)
|
||||||
|
{
|
||||||
|
global $langs;
|
||||||
|
|
||||||
|
if ($mode == 0)
|
||||||
|
{
|
||||||
|
return $langs->trans($this->statuts[$statut]);
|
||||||
|
}
|
||||||
|
if ($mode == 1)
|
||||||
|
{
|
||||||
|
return $langs->trans($this->statuts_short[$statut]);
|
||||||
|
}
|
||||||
|
if ($mode == 2)
|
||||||
|
{
|
||||||
|
if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts_short[$statut]);
|
||||||
|
if ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]),'statut8').' '.$langs->trans($this->statuts_short[$statut]);
|
||||||
|
}
|
||||||
|
if ($mode == 3)
|
||||||
|
{
|
||||||
|
if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4');
|
||||||
|
if ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut8');
|
||||||
|
}
|
||||||
|
if ($mode == 4)
|
||||||
|
{
|
||||||
|
if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]);
|
||||||
|
if ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut8').' '.$langs->trans($this->statuts[$statut]);
|
||||||
|
}
|
||||||
|
if ($mode == 5)
|
||||||
|
{
|
||||||
|
if ($statut==0 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut4');
|
||||||
|
if ($statut==1 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut8');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.'ihrm_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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
0
htdocs/hrm/class/index.html
Normal file
0
htdocs/hrm/class/index.html
Normal file
415
htdocs/hrm/establishment/card.php
Normal file
415
htdocs/hrm/establishment/card.php
Normal file
@ -0,0 +1,415 @@
|
|||||||
|
<?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/custom/ihrm/establishment/card.php
|
||||||
|
* \brief Page to show an establishment
|
||||||
|
*/
|
||||||
|
$res = @include ("../../main.inc.php"); // For root directory
|
||||||
|
if (! $res)
|
||||||
|
$res = @include ("../../../main.inc.php"); // For "custom" directory
|
||||||
|
if (! $res)
|
||||||
|
die("Include of main fails");
|
||||||
|
|
||||||
|
require_once ('../core/lib/ihrm.lib.php');
|
||||||
|
require_once ('../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("compta");
|
||||||
|
|
||||||
|
// 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 statut
|
||||||
|
static $tmpstatut2label=array(
|
||||||
|
'0'=>'OpenEtablishment',
|
||||||
|
'1'=>'CloseEtablishment'
|
||||||
|
);
|
||||||
|
$statut2label=array('');
|
||||||
|
foreach ($tmpstatut2label as $key => $val) $statut2label[$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->statut = GETPOST('statut','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>';
|
||||||
|
|
||||||
|
// Statut
|
||||||
|
print '<tr>';
|
||||||
|
print '<td class="fieldrequired"><label for="statut">'.$langs->trans("Statut").'</label></td>';
|
||||||
|
print '<td>';
|
||||||
|
print $form->selectarray('statut',$statut2label,GETPOST('statut'));
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
print '</table>';
|
||||||
|
|
||||||
|
dol_fiche_end();
|
||||||
|
|
||||||
|
print '<div class="center">';
|
||||||
|
print '<input class="button" type="submit" value="'.$langs->trans("Save").'">';
|
||||||
|
print ' ';
|
||||||
|
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@ihrm');
|
||||||
|
|
||||||
|
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>';
|
||||||
|
|
||||||
|
// Statut
|
||||||
|
print '<tr><td><label for="statut">'.$langs->trans("Statut").'</label></td><td>';
|
||||||
|
print $form->selectarray('statut',$statut2label,$object->statut);
|
||||||
|
print '</td></tr>';
|
||||||
|
|
||||||
|
print '</table>';
|
||||||
|
|
||||||
|
dol_fiche_end();
|
||||||
|
|
||||||
|
print '<div class="center">';
|
||||||
|
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
|
||||||
|
print ' ';
|
||||||
|
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@ihrm');
|
||||||
|
|
||||||
|
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>';
|
||||||
|
|
||||||
|
// Statut
|
||||||
|
print '<tr><td>'.$langs->trans("Status").'</td><td colspan="2">'.$object->getLibStatut(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();
|
||||||
0
htdocs/hrm/establishment/index.html
Normal file
0
htdocs/hrm/establishment/index.html
Normal file
59
htdocs/hrm/establishment/info.php
Normal file
59
htdocs/hrm/establishment/info.php
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
<?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/custom/ihrm/establishment/info.php
|
||||||
|
* \brief Page to show info of an establishment
|
||||||
|
*/
|
||||||
|
|
||||||
|
require '../../main.inc.php';
|
||||||
|
|
||||||
|
require_once ('../core/lib/ihrm.lib.php');
|
||||||
|
require_once ('../class/establishment.class.php');
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||||
|
|
||||||
|
$langs->load("admin");
|
||||||
|
$langs->load("compta");
|
||||||
|
|
||||||
|
// 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@ihrm');
|
||||||
|
|
||||||
|
print '<table width="100%"><tr><td>';
|
||||||
|
dol_print_object_info($object);
|
||||||
|
print '</td></tr></table>';
|
||||||
|
|
||||||
|
print '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$db->close();
|
||||||
|
|
||||||
|
llxFooter();
|
||||||
0
htdocs/hrm/index.html
Normal file
0
htdocs/hrm/index.html
Normal file
BIN
htdocs/theme/eldy/img/object_building.png
Normal file
BIN
htdocs/theme/eldy/img/object_building.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 563 B |
BIN
htdocs/theme/md/img/object_building.png
Normal file
BIN
htdocs/theme/md/img/object_building.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 563 B |
Loading…
Reference in New Issue
Block a user