diff --git a/.tx/config b/.tx/config index 03301ded378..3c8c49e40e9 100644 --- a/.tx/config +++ b/.tx/config @@ -146,6 +146,12 @@ source_file = htdocs/langs/en_US/holiday.lang source_lang = en_US type = MOZILLAPROPERTIES +[dolibarr.hrm] +file_filter = htdocs/langs//hrm.lang +source_file = htdocs/langs/en_US/hrm.lang +source_lang = en_US +type = MOZILLAPROPERTIES + [dolibarr.incoterm] file_filter = htdocs/langs//incoterm.lang source_file = htdocs/langs/en_US/incoterm.lang diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index 8d93dfc950c..6e7a4f7d868 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -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') @@ -57,6 +58,7 @@ if ($action == 'update') dolibarr_set_const($db, "MAIN_LANG_DEFAULT", $_POST["main_lang_default"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_MULTILANGS", $_POST["main_multilangs"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_SIZE_LISTE_LIMIT", $_POST["main_size_liste_limit"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "MAIN_SIZE_SHORTLISTE_LIMIT", $_POST["main_size_shortliste_limit"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_DISABLE_JAVASCRIPT", $_POST["main_disable_javascript"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_BUTTON_HIDE_UNAUTHORIZED", $_POST["MAIN_BUTTON_HIDE_UNAUTHORIZED"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_START_WEEK", $_POST["MAIN_START_WEEK"],'chaine',0,'',$conf->entity); @@ -82,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); @@ -204,6 +207,12 @@ if ($action == 'edit') // Edit print ' '; print ''; + // Max size of short lists on customer card + $var=!$var; + print ''.$langs->trans("DefaultMaxSizeShortListCustomerCard").''; + print ' '; + print ''; + // Disable javascript and ajax $var=!$var; print ''.$langs->trans("DisableJavascript").''; @@ -385,6 +394,11 @@ else // Show print ''.$langs->trans("DefaultMaxSizeList").'' . $conf->global->MAIN_SIZE_LISTE_LIMIT . ''; print ' '; print ""; + + $var=!$var; + print ''.$langs->trans("DefaultMaxSizeShortListCustomerCard").'' . $conf->global->MAIN_SIZE_SHORTLISTE_LIMIT . ''; + print ' '; + print ""; // Disable javascript/ajax $var=!$var; diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index a44a79da1f0..3e20d611785 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -376,17 +376,6 @@ if ($id > 0) $limit_field_type = (! empty($conf->global->MAIN_USE_JQUERY_JEDITABLE)) ? 'numeric' : 'amount'; print $form->editfieldval("OutstandingBill",'outstanding_limit',$object->outstanding_limit,$object,$user->rights->societe->creer,$limit_field_type,($object->outstanding_limit != '' ? price($object->outstanding_limit) : '')); if (empty($object->outstanding_limit)) print $langs->trans("NoLimit"); - // display amount and link to unpaid bill - $outstandingBills = $object->get_OutstandingBill(); - print ' (' . $langs->trans('CurrentOutstandingBill') . ': '; - print price($outstandingBills, '', $langs, 0, 0, - 1, $conf->currency); - if ($object->outstanding_limit != '') - { - if ($outstandingBills > $object->outstanding_limit) - print img_warning($langs->trans("OutstandingBillReached")); - //print ' / ' . price($soc->outstanding_limit); - } - print ')'; print ''; print ''; @@ -491,14 +480,24 @@ if ($id > 0) // Nbre max d'elements des petites listes - $MAXLIST=4; - $tableaushown=1; + $MAXLIST=$conf->global->MAIN_SIZE_SHORTLISTE_LIMIT; // Lien recap + $outstandingBills = $object->get_OutstandingBill(); + $warn = ''; + if ($object->outstanding_limit != '' && $object->outstanding_limit < $outstandingBills) + { + $warn = img_warning($langs->trans("OutstandingBillReached")); + } + print ''; print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; print ''; print '
'; - print '
'.$langs->trans("Summary").''.$langs->trans("ShowCustomerPreview").'
'.$langs->trans("Summary").''.$langs->trans("ShowCustomerPreview").'
'.$langs->trans("CurrentOutstandingBill").''.price($outstandingBills).$warn.'
'; print '
'; @@ -684,7 +683,6 @@ if ($id > 0) if ($num > 0) { print ''; - $tableaushown=1; print ''; print '
'; print ''; @@ -868,7 +866,6 @@ if ($id > 0) { print '
'.$langs->trans("LastSendings",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllSendings").' '.$num.''.img_picto($langs->trans("Statistics"),'stats').'
'; - $tableaushown=1; print ''; print ''; + + // Employee + print ''; + print ''; // Position/Job @@ -1205,6 +1211,11 @@ else } print ''."\n"; + // Employee + print ''."\n"; + // Position/Job print ''; print ''; @@ -1728,6 +1739,12 @@ else } print ''; + // Employee + print ''; + print ''; + // Position/Job print ''; print '
'; print ''; diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php index cfcd0a6f746..920419a8769 100644 --- a/htdocs/compta/recap-compta.php +++ b/htdocs/compta/recap-compta.php @@ -25,6 +25,7 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; $langs->load("companies"); if (! empty($conf->facture->enabled)) $langs->load("bills"); @@ -43,6 +44,7 @@ if ($user->societe_id > 0) * View */ +$form = new Form($db); $userstatic=new User($db); llxHeader(); @@ -58,28 +60,7 @@ if ($socid > 0) $head = societe_prepare_head($societe); dol_fiche_head($head, 'customer', $langs->trans("ThirdParty"), 0, 'company'); - - print "
'.$langs->trans("LastCustomersBills",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllBills").' '.$num.''.img_picto($langs->trans("Statistics"),'stats').'
\n"; - print '
'; - - print ''; - - // Name - print ''; - - // Prefix - if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field - { - print ''; - } - - print "
'.$langs->trans("Name").''.$societe->name.'
'.$langs->trans("Prefix").''; - print ($societe->prefix_comm?$societe->prefix_comm:' '); - print '
"; - - print "
\n"; - - print ''; + dol_banner_tab($societe, 'socid', '', ($user->societe_id?0:1), 'rowid', 'nom'); if (! empty($conf->facture->enabled) && $user->rights->facture->lire) { @@ -87,6 +68,18 @@ if ($socid > 0) print load_fiche_titre($langs->trans("CustomerPreview")); print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + $TData = array(); + $TDataSort = array(); $sql = "SELECT s.nom, s.rowid as socid, f.facnumber, f.amount, f.datef as df,"; $sql.= " f.paye as paye, f.fk_statut as statut, f.rowid as facid,"; @@ -95,7 +88,7 @@ if ($socid > 0) $sql.= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$societe->id; $sql.= " AND f.entity = ".$conf->entity; $sql.= " AND f.fk_user_valid = u.rowid"; - $sql.= " ORDER BY f.datef DESC"; + $sql.= " ORDER BY f.datef ASC"; $resql=$db->query($sql); if ($resql) @@ -103,23 +96,6 @@ if ($socid > 0) $var=true; $num = $db->num_rows($resql); - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - - if (! $num > 0) - { - print ''; - } - - $solde = 0; - // Boucle sur chaque facture for ($i = 0 ; $i < $num ; $i++) { @@ -133,29 +109,18 @@ if ($socid > 0) continue; } $totalpaye = $fac->getSommePaiement(); - - $var=!$var; - print ""; - - print "\n"; - print '\n"; - - print ''; - print '\n"; - if (($fac->statut == Facture::STATUS_ABANDONED ) || ($fac->statut == Facture::STATUS_CLOSED && ! $fact->close_code) ) $solde = $solde = $solde + $totalpaye; - else $solde = $solde + $fac->total_ttc; - - print ''; - print '\n"; - - // Author + $userstatic->id=$objf->userid; $userstatic->login=$objf->login; - print ''; - - print "\n"; + + $TData[] = array( + 'date' => $fac->date, + 'link' => $fac->getNomUrl(1), + 'status' => $fac->getLibStatut(2,$totalpaye), + 'amount' => $fac->total_ttc, + 'author' => $userstatic->getLoginUrl(1) + ); + $TDataSort[] = $fac->date; // Paiements $sql = "SELECT p.rowid, p.datep as dp, pf.amount, p.statut,"; @@ -166,6 +131,7 @@ if ($socid > 0) $sql.= " WHERE pf.fk_paiement = p.rowid"; $sql.= " AND p.entity = ".$conf->entity; $sql.= " AND pf.fk_facture = ".$fac->id; + $sql.= " ORDER BY p.datep ASC"; $resqlp = $db->query($sql); if ($resqlp) @@ -176,26 +142,21 @@ if ($socid > 0) while ($j < $nump) { $objp = $db->fetch_object($resqlp); - //$var=!$var; - print ""; - print '\n"; - print ''; - print "\n"; - print "\n"; - print ''; - $solde = $solde - $objp->amount; - print '\n"; - - // Author + + $paymentstatic = new Paiement($db); + $paymentstatic->id = $objp->rowid; + $userstatic->id=$objp->userid; $userstatic->login=$objp->login; - print ''; - - print ''; + + $TData[] = array( + 'date' => $db->jdate($objp->dp), + 'link' => $langs->trans("Payment") .' '. $paymentstatic->getNomUrl(1), + 'status' => '', + 'amount' => -$objp->amount, + 'author' => $userstatic->getLoginUrl(1) + ); + $TDataSort[] = $db->jdate($objp->dp); $j++; } @@ -212,9 +173,63 @@ if ($socid > 0) { dol_print_error($db); } + + if(empty($TData)) { + print ''; + } else { + + // Sort array by date + asort($TDataSort); + array_multisort($TData,$TDataSort); + + // Balance calculation + foreach($TData as &$data1) { + $balance += $data1['amount']; + $data1['balance'] += $balance; + } + + // Reverse array to have last elements on top + $TData = array_reverse($TData); + + $totalDebit = 0; + $totalCredit = 0; + + // Display array + foreach($TData as $data) { + $var=!$var; + print ""; + + print "\n"; + print '\n"; + + print ''; + print '\n"; + $totalDebit += ($data['amount'] > 0) ? abs($data['amount']) : 0; + print '\n"; + $totalCredit += ($data['amount'] > 0) ? 0 : abs($data['amount']); + print '\n"; + + // Author + print ''; + + print "\n"; + } + + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + } + print "
'.$langs->trans("Date").''.$langs->trans("Element").''.$langs->trans("Status").''.$langs->trans("Debit").''.$langs->trans("Credit").''.$langs->trans("Balance").''.$langs->trans("Author").'
'.$langs->trans("Date").' '.$langs->trans("Status").''.$langs->trans("Debit").''.$langs->trans("Credit").''.$langs->trans("Balance").' 
'.$langs->trans("NoInvoice").'
".dol_print_date($fac->date,'day')."'.img_object($langs->trans("ShowBill"),"bill")." ".$fac->ref."'.$fac->getLibStatut(2,$totalpaye).''.price($fac->total_ttc)." '.price($solde)."'; - print $userstatic->getLoginUrl(1); - print '
'.dol_print_date($db->jdate($objp->dp),'day')."'; - print '      '; // Decalage - print ''.img_object($langs->trans("ShowPayment"),"payment").' '.$langs->trans("Payment").' '.$objp->rowid.'  '.price($objp->amount).''.price($solde)."'; - print $userstatic->getLoginUrl(1); - print '
'.$langs->trans("NoInvoice").'
".dol_print_date($data['date'],'day')."'.$data['link']."'.$data['status'].''.(($data['amount'] > 0) ? price(abs($data['amount'])) : '')."'.(($data['amount'] > 0) ? '' : price(abs($data['amount'])))."'.price($data['balance'])."'; + print $data['author']; + print '
 '.price($totalDebit).''.price($totalCredit).' 
"; print "
"; } + + print ''; } else { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index abaf5d24837..896cc0824d0 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -886,7 +886,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r } else { $morehtmlright.=$object->getLibStatut(2); } - if (! empty($object->name_nalias)) $morehtmlref.='
'.$object->name_alias.'
'; + if (! empty($object->name_alias)) $morehtmlref.='
'.$object->name_alias.'
'; $morehtmlref.='
'; $morehtmlref.=$object->getBannerAddress('refaddress',$object); $morehtmlref.='
'; diff --git a/htdocs/core/lib/hrm.lib.php b/htdocs/core/lib/hrm.lib.php new file mode 100644 index 00000000000..f7f3ed11bd8 --- /dev/null +++ b/htdocs/core/lib/hrm.lib.php @@ -0,0 +1,120 @@ + + * + * 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 . + */ + +/** + * \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; +} + diff --git a/htdocs/core/modules/modHRM.class.php b/htdocs/core/modules/modHRM.class.php new file mode 100644 index 00000000000..16a0edd0c04 --- /dev/null +++ b/htdocs/core/modules/modHRM.class.php @@ -0,0 +1,251 @@ + + * + * 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 . + */ + +/** + * \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); + } +} diff --git a/htdocs/hrm/admin/admin_establishment.php b/htdocs/hrm/admin/admin_establishment.php new file mode 100644 index 00000000000..6a9cf961960 --- /dev/null +++ b/htdocs/hrm/admin/admin_establishment.php @@ -0,0 +1,126 @@ + + * + * 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 . + */ + +/** + * \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 = '' . $langs->trans("BackToModuleList") . ''; +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 ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + if ($num) + { + $establishmentstatic=new Establishment($db); + + while ($i < $num && $i < $max) + { + $obj = $db->fetch_object($result); + $fiscalyearstatic->id=$obj->rowid; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + $var=!$var; + $i++; + } + + } + else + { + print ''; + } + + print '
'.$langs->trans("Ref").''.$langs->trans("Name").''.$langs->trans("Address").''.$langs->trans("Zipcode").''.$langs->trans("Town").''.$langs->trans("Status").'
'.img_object($langs->trans("ShowEstablishment"),"building").' '.$obj->rowid.''.$obj->name.''.$obj->address.''.$obj->zip.''.$obj->town.''.$establishmentstatic->LibStatut($obj->status,5).'
'.$langs->trans("None").'
'; +} +else +{ + dol_print_error($db); +} + +dol_fiche_end(); + +// Buttons +print ''; + +llxFooter(); +$db->close(); diff --git a/htdocs/hrm/admin/admin_hrm.php b/htdocs/hrm/admin/admin_hrm.php new file mode 100644 index 00000000000..bc0487bad94 --- /dev/null +++ b/htdocs/hrm/admin/admin_hrm.php @@ -0,0 +1,58 @@ + + * + * 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 . + */ + +/** + * \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 = '' . $langs->trans("BackToModuleList") . ''; +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(); diff --git a/htdocs/hrm/admin/index.html b/htdocs/hrm/admin/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/hrm/class/establishment.class.php b/htdocs/hrm/class/establishment.class.php new file mode 100644 index 00000000000..c5ba77fd547 --- /dev/null +++ b/htdocs/hrm/class/establishment.class.php @@ -0,0 +1,324 @@ + + * + * 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 . + */ + +/** + * \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); + } + } + +} diff --git a/htdocs/hrm/class/index.html b/htdocs/hrm/class/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/hrm/establishment/card.php b/htdocs/hrm/establishment/card.php new file mode 100644 index 00000000000..533ad5117ff --- /dev/null +++ b/htdocs/hrm/establishment/card.php @@ -0,0 +1,410 @@ + + * + * 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 . + */ + +/** + * \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 '
'; + print ''; + print ''; + + dol_fiche_head(); + + print ''; + + // Name + print ''; + + // Address + print ''; + print ''; + print ''; + print ''; + + // Zipcode + print ''; + print ''; + print ''; + print ''; + + // Town + print ''; + print ''; + print ''; + print ''; + + // Country + print ''; + print ''; + print ''; + print ''; + + // Status + print ''; + print ''; + print ''; + + print '
'; + print ''; + print '
'; + print $formcompany->select_ziptown(GETPOST('zipcode', 'alpha'), 'zipcode', array ( + 'town', + 'selectcountry_id' + ), 6); + print '
'; + print $formcompany->select_ziptown(GETPOST('town', 'alpha'), 'town', array ( + 'zipcode', + 'selectcountry_id' + )); + print '
'; + print $form->select_country($mysoc->country_id,'country_id'); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); + print '
'; + print $form->selectarray('status',$status2label,GETPOST('status')); + print '
'; + + dol_fiche_end(); + + print '
'; + print ''; + print '     '; + print ''; + print '
'; + + print '
'; +} +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 '
' . "\n"; + print ''; + print ''; + print ''; + + print ''; + + // Ref + print ""; + print ''; + + // Name + print ''; + + // Address + print ''; + print ''; + print ''; + print ''; + + // Zipcode / Town + print ''; + print ''; + + // Country + print ''; + print ''; + print ''; + print ''; + + // Status + print ''; + + print '
'.$langs->trans("Ref").''; + print $object->rowid; + print '
'; + print ''; + print '
'; + print ''; + print '
'; + print $formcompany->select_ziptown($object->zip, 'zipcode', array ( + 'town', + 'selectcountry_id' + ), 6) . '
'; + print $formcompany->select_ziptown($object->town, 'town', array ( + 'zipcode', + 'selectcountry_id' + )) . '
'; + print $form->select_country($object->fk_pays,'country_id'); + if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); + print '
'; + print $form->selectarray('status',$status2label,$object->status); + print '
'; + + dol_fiche_end(); + + print '
'; + print ''; + print '     '; + print ''; + print '
'; + + print '
'; + } + 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 ''; + + $linkback = ''.$langs->trans("BackToList").''; + + // Ref + print ''; + + // Name + print ''; + print ''; + print ''; + print ''; + + // Address + print ''; + print ''; + print ''; + print ''; + + // Zipcode + print ''; + print ''; + print ''; + print ''; + + // Town + print ''; + print ''; + print ''; + print ''; + + // Country + print ''; + print ''; + print ''; + print ''; + + // Status + print ''; + + print "
'.$langs->trans("Ref").''; + print $object->rowid; + print ''; + print $linkback; + print '
'.$langs->trans("Name").''.$object->name.'
'.$langs->trans("Address").''.$object->address.'
'.$langs->trans("Zipcode").''.$object->zip.'
'.$langs->trans("Town").''.$object->town.'
'.$langs->trans("Country").''.getCountry($object->fk_pays,1).'
'.$langs->trans("Status").''.$object->getLibStatus(4).'
"; + + dol_fiche_end(); + + /* + * Barre d'actions + */ + + print '
'; + print ''.$langs->trans('Modify').''; + print ''.$langs->trans('Delete').''; + print '
'; + } + } + else + { + dol_print_error($db); + } +} + +llxFooter(); + +$db->close(); diff --git a/htdocs/hrm/establishment/index.html b/htdocs/hrm/establishment/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/hrm/establishment/info.php b/htdocs/hrm/establishment/info.php new file mode 100644 index 00000000000..2bf014481ac --- /dev/null +++ b/htdocs/hrm/establishment/info.php @@ -0,0 +1,57 @@ + + * + * 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 . + */ + +/** + * \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 '
'; + dol_print_object_info($object); + print '
'; + + print ''; +} + +$db->close(); + +llxFooter(); diff --git a/htdocs/hrm/index.html b/htdocs/hrm/index.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/htdocs/install/mysql/data/llx_c_hrm_department.sql b/htdocs/install/mysql/data/llx_c_hrm_department.sql new file mode 100644 index 00000000000..e6e4921f372 --- /dev/null +++ b/htdocs/install/mysql/data/llx_c_hrm_department.sql @@ -0,0 +1,43 @@ +-- ============================================================================ +-- Copyright (C) 2013 Jean-François Ferry +-- Copyright (C) 2015 Alexandre Spangaro +-- +-- 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 . +-- +-- ============================================================================ +-- + +-- +-- 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); diff --git a/htdocs/install/mysql/data/llx_c_hrm_function.sql b/htdocs/install/mysql/data/llx_c_hrm_function.sql new file mode 100644 index 00000000000..f8b56563689 --- /dev/null +++ b/htdocs/install/mysql/data/llx_c_hrm_function.sql @@ -0,0 +1,34 @@ +-- ============================================================================ +-- Copyright (C) 2013 Jean-François Ferry +-- Copyright (C) 2015 Alexandre Spangaro +-- +-- 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 . +-- +-- ============================================================================ +-- + +-- +-- 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); diff --git a/htdocs/install/mysql/data/llx_const.sql b/htdocs/install/mysql/data/llx_const.sql index 2c25765223e..95dfb2683f9 100644 --- a/htdocs/install/mysql/data/llx_const.sql +++ b/htdocs/install/mysql/data/llx_const.sql @@ -53,6 +53,7 @@ insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_M -- IHM -- insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_SIZE_LISTE_LIMIT','25','chaine','Longueur maximum des listes',0,0); +insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_SIZE_SHORTLISTE_LIMIT','4','chaine','Longueur maximum des listes courtes (fiche client)',0,0); insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_SHOW_WORKBOARD','1','yesno','Affichage tableau de bord de travail Dolibarr',0,0); insert into llx_const (name, value, type, note, visible) values ('MAIN_MENU_STANDARD','eldy_menu.php','chaine','Menu manager for internal users',0); diff --git a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql index 775a67b27fa..d426cd72105 100755 --- a/htdocs/install/mysql/migration/3.8.0-3.9.0.sql +++ b/htdocs/install/mysql/migration/3.8.0-3.9.0.sql @@ -20,6 +20,7 @@ INSERT INTO llx_const (name, value, type, note, visible) values (__ENCRYPT('MAIN_DELAY_EXPENSEREPORTS_TO_PAY')__,__ENCRYPT('31')__,'chaine','Tolérance de retard avant alerte (en jours) sur les notes de frais impayées',0); +INSERT INTO llx_const (name, value, type, note, visible) values ('MAIN_SIZE_SHORTLISTE_LIMIT','4','chaine','Longueur maximum des listes courtes (fiche client)',0); ALTER TABLE llx_accounting_system MODIFY COLUMN pcg_version varchar(32); ALTER TABLE llx_accountingaccount MODIFY COLUMN fk_pcg_version varchar(32); diff --git a/htdocs/install/mysql/migration/3.9.0-4.0.0.sql b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql new file mode 100644 index 00000000000..231b89ee507 --- /dev/null +++ b/htdocs/install/mysql/migration/3.9.0-4.0.0.sql @@ -0,0 +1,90 @@ +-- +-- 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; + diff --git a/htdocs/install/mysql/tables/llx_c_hrm_department.sql b/htdocs/install/mysql/tables/llx_c_hrm_department.sql new file mode 100644 index 00000000000..f9432d8b821 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_hrm_department.sql @@ -0,0 +1,26 @@ +-- +-- Copyright (C) 2013 Jean-François Ferry +-- Copyright (C) 2015 Alexandre Spangaro +-- +-- 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 . + +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; + diff --git a/htdocs/install/mysql/tables/llx_c_hrm_function.sql b/htdocs/install/mysql/tables/llx_c_hrm_function.sql new file mode 100644 index 00000000000..f3f87461866 --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_hrm_function.sql @@ -0,0 +1,27 @@ +-- +-- Copyright (C) 2013 Jean-François Ferry +-- Copyright (C) 2015 Alexandre Spangaro +-- +-- 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 . + +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; + diff --git a/htdocs/install/mysql/tables/llx_establishment.sql b/htdocs/install/mysql/tables/llx_establishment.sql new file mode 100644 index 00000000000..8ddc71e1fba --- /dev/null +++ b/htdocs/install/mysql/tables/llx_establishment.sql @@ -0,0 +1,41 @@ +-- ============================================================================ +-- Copyright (C) 2015 Alexandre Spangaro +-- +-- 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 . +-- +-- ============================================================================ +-- +-- 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; + diff --git a/htdocs/install/mysql/tables/llx_user.sql b/htdocs/install/mysql/tables/llx_user.sql index 47bbedb1fef..796566fb638 100644 --- a/htdocs/install/mysql/tables/llx_user.sql +++ b/htdocs/install/mysql/tables/llx_user.sql @@ -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, diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 28a6514328c..9bf9233f76b 100755 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -540,6 +540,8 @@ Module2900Name=GeoIPMaxmind Module2900Desc=GeoIP Maxmind conversions capabilities Module3100Name=Skype Module3100Desc=Add a Skype button into card of adherents / third parties / contacts +Module4000Name=HRM +Module4000Desc=Human resources management Module5000Name=Multi-company Module5000Desc=Allows you to manage multiple companies Module6000Name=Workflow diff --git a/htdocs/langs/en_US/hrm.lang b/htdocs/langs/en_US/hrm.lang new file mode 100644 index 00000000000..33c6c271261 --- /dev/null +++ b/htdocs/langs/en_US/hrm.lang @@ -0,0 +1,13 @@ +# Dolibarr language file - en_US - hrm +CHARSET=UTF-8 + +Establishments=Establishments +Establishment=Establishment +NewEstablishment=New establishment +DeleteEstablishment=Delete establishment +ConfirmDeleteEstablishment=Are-you sure to delete this establishment ? +OpenEtablishment=Open establishment +CloseEtablishment=Close establishment +Employees=Employees +Employee=Employee +NewEmployee=New employee diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 3df62aadcb5..ffc7d7c4777 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1610,6 +1610,12 @@ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $me $searchform.=printSearchForm(DOL_URL_ROOT.'/projet/list.php', DOL_URL_ROOT.'/projet/list.php', $langs->trans("Projects"), 'project', 'search_all', 'Q', 'searchleftproj', img_object('','projectpub')); } + if (! empty($conf->hrm->enabled) && ! empty($conf->global->MAIN_SEARCHFORM_EMPLOYEE) && $user->rights->hrm->employee->read) + { + $langs->load("hrm"); + $searchform.=printSearchForm(DOL_URL_ROOT.'/hrm/employee/list.php', DOL_URL_ROOT.'/hrm/employee/list.php', $langs->trans("Employees"), 'employee', 'search_all', 'M', 'searchleftemployee', img_object('','user')); + } + // Execute hook printSearchForm $parameters=array(); $reshook=$hookmanager->executeHooks('printSearchForm',$parameters); // Note that $action and $object may have been modified by some hooks diff --git a/htdocs/theme/eldy/img/object_building.png b/htdocs/theme/eldy/img/object_building.png new file mode 100644 index 00000000000..c9d1539dddc Binary files /dev/null and b/htdocs/theme/eldy/img/object_building.png differ diff --git a/htdocs/theme/md/img/object_building.png b/htdocs/theme/md/img/object_building.png new file mode 100644 index 00000000000..c9d1539dddc Binary files /dev/null and b/htdocs/theme/md/img/object_building.png differ diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 0241206de96..407941c28fd 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -722,6 +722,12 @@ if (($action == 'create') || ($action == 'adduserldap')) { print ''; } + print '
'.fieldLabel('Employee','employee',0).''; + print $form->selectyesno("employee",(isset($_POST['employee'])?GETPOST('employee'):0),1); print '
'.$langs->trans("Employee").''; + print yn($object->employee); + print '
'.$langs->trans("PostOrFunction").''.$object->job.'
'.fieldLabel('Employee','employee',0).''; + print $form->selectyesno("employee",$object->employee,1); + print '
'.$langs->trans("PostOrFunction").''; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index fdc3b8577cd..85a96ebe415 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -8,7 +8,7 @@ * Copyright (C) 2005 Lionel Cousteix * Copyright (C) 2011 Herve Prot * Copyright (C) 2013-2014 Philippe Grand - * Copyright (C) 2013 Alexandre Spangaro + * Copyright (C) 2013-2015 Alexandre Spangaro * Copyright (C) 2015 Marcos García * * This program is free software; you can redistribute it and/or modify @@ -46,6 +46,7 @@ class User extends CommonObject var $id=0; var $ldap_sid; var $search_sid; + var $employee; var $gender; var $email; var $skype; @@ -157,7 +158,7 @@ class User extends CommonObject $login=trim($login); // Get user - $sql = "SELECT u.rowid, u.lastname, u.firstname, u.gender, u.email, u.job, u.skype, u.signature, u.office_phone, u.office_fax, u.user_mobile,"; + $sql = "SELECT u.rowid, u.lastname, u.firstname, u.employee, u.gender, u.email, u.job, u.skype, u.signature, u.office_phone, u.office_fax, u.user_mobile,"; $sql.= " u.admin, u.login, u.note,"; $sql.= " u.pass, u.pass_crypted, u.pass_temp, u.api_key,"; $sql.= " u.fk_soc, u.fk_socpeople, u.fk_member, u.fk_user, u.ldap_sid,"; @@ -223,6 +224,8 @@ class User extends CommonObject $this->ldap_sid = $obj->ldap_sid; $this->lastname = $obj->lastname; $this->firstname = $obj->firstname; + + $this->employee = $obj->employee; $this->login = $obj->login; $this->gender = $obj->gender; @@ -1153,6 +1156,7 @@ class User extends CommonObject // Clean parameters $this->lastname = trim($this->lastname); $this->firstname = trim($this->firstname); + $this->employee = trim($this->employee); $this->login = trim($this->login); $this->gender = trim($this->gender); $this->pass = trim($this->pass); @@ -1193,6 +1197,7 @@ class User extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."user SET"; $sql.= " lastname = '".$this->db->escape($this->lastname)."'"; $sql.= ", firstname = '".$this->db->escape($this->firstname)."'"; + $sql.= ", employee = ".$this->employee; $sql.= ", login = '".$this->db->escape($this->login)."'"; $sql.= ", api_key = ".($this->api_key ? "'".$this->db->escape($this->api_key)."'" : "null"); $sql.= ", gender = ".($this->gender != -1 ? "'".$this->db->escape($this->gender)."'" : "null"); // 'man' or 'woman'