diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php
index 900c8017f55..322ffcd4942 100755
--- a/htdocs/salaries/card.php
+++ b/htdocs/salaries/card.php
@@ -48,9 +48,11 @@ $id = GETPOSTINT('id');
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09');
$cancel = GETPOST('cancel', 'aZ09');
-$accountid = GETPOST('accountid', 'int') > 0 ? GETPOST('accountid', 'int') : 0;
-$projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : GETPOST('fk_project', 'int'));
$confirm = GETPOST('confirm');
+
+$label = GETPOST('label', 'alphanohtml');
+$projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : GETPOST('fk_project', 'int'));
+$accountid = GETPOST('accountid', 'int') > 0 ? GETPOST('accountid', 'int') : 0;
if (GETPOSTISSET('auto_create_paiement') || $action === 'add') {
$auto_create_paiement = GETPOST("auto_create_paiement", "int");
} else {
@@ -61,7 +63,6 @@ $datep = dol_mktime(12, 0, 0, GETPOST("datepmonth", 'int'), GETPOST("datepday",
$datev = dol_mktime(12, 0, 0, GETPOST("datevmonth", 'int'), GETPOST("datevday", 'int'), GETPOST("datevyear", 'int'));
$datesp = dol_mktime(12, 0, 0, GETPOST("datespmonth", 'int'), GETPOST("datespday", 'int'), GETPOST("datespyear", 'int'));
$dateep = dol_mktime(12, 0, 0, GETPOST("dateepmonth", 'int'), GETPOST("dateepday", 'int'), GETPOST("dateepyear", 'int'));
-$label = GETPOST('label', 'alphanohtml');
$fk_user = GETPOSTINT('userid');
$object = new Salary($db);
@@ -686,7 +687,7 @@ if ($id) {
$morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->salaries->write, 'string', '', 0, 1);
$morehtmlref .= $object->label;
} else {
- $morehtmlref .= '
'.$langs->trans('Label').' : ';
+ $morehtmlref .= $langs->trans('Label').' : ';
$morehtmlref .= '
';
}
- //Employee
+ // Employee
if ($action != 'editfk_user') {
if ($object->getSommePaiement() > 0 && !empty($object->fk_user)) {
$userstatic = new User($db);
@@ -739,7 +740,7 @@ if ($id) {
$morehtmlref .= '';
} else {
diff --git a/htdocs/salaries/document.php b/htdocs/salaries/document.php
index ea21b49159c..4f49858eb7a 100644
--- a/htdocs/salaries/document.php
+++ b/htdocs/salaries/document.php
@@ -35,6 +35,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php';
require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
+if (!empty($conf->projet->enabled)) {
+ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
+ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
+}
// Load translation files required by the page
$langs->loadLangs(array("compta", "bills", "users", "salaries", "hrm"));
@@ -44,6 +48,9 @@ $ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09');
$confirm = GETPOST('confirm', 'alpha');
+$label = GETPOST('label', 'alphanohtml');
+$projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : GETPOST('fk_project', 'int'));
+
// Get parameters
$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
@@ -62,9 +69,29 @@ if (!$sortfield) {
$sortfield = "name";
}
+$object = new Salary($db);
+$extrafields = new ExtraFields($db);
+
+$childids = $user->getAllChildIds(1);
+
+// fetch optionals attributes and labels
+$extrafields->fetch_name_optionals_label($object->table_element);
+
$object = new Salary($db);
if ($id > 0 || !empty($ref)) {
$object->fetch($id, $ref);
+
+ // Check current user can read this salary
+ $canread = 0;
+ if (!empty($user->rights->salaries->readall)) {
+ $canread = 1;
+ }
+ if (!empty($user->rights->salaries->read) && $object->fk_user > 0 && in_array($object->fk_user, $childids)) {
+ $canread = 1;
+ }
+ if (!$canread) {
+ accessforbidden();
+ }
}
$upload_dir = $conf->salaries->dir_output.'/'.dol_sanitizeFileName($object->id);
@@ -84,12 +111,26 @@ restrictedArea($user, 'salaries', $object->id, 'salary', '');
include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
+// Link to a project
+if ($action == 'classin' && $user->rights->banque->modifier) {
+ $object->fetch($id);
+ $object->setProject($projectid);
+}
+
+// set label
+if ($action == 'setlabel' && $user->rights->salaries->write) {
+ $object->fetch($id);
+ $object->label = $label;
+ $object->update($user);
+}
+
/*
* View
*/
$form = new Form($db);
+if (!empty($conf->projet->enabled)) $formproject = new FormProjets($db);
$title = $langs->trans('Salary')." - ".$langs->trans('Documents');
$help_url = "";
@@ -116,7 +157,53 @@ if ($object->id) {
$userstatic = new User($db);
$userstatic->fetch($object->fk_user);
- $morehtmlref .= $langs->trans('Employee').' : '.$userstatic->getNomUrl(1);
+ // Label
+ if ($action != 'editlabel') {
+ $morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->salaries->write, 'string', '', 0, 1);
+ $morehtmlref .= $object->label;
+ } else {
+ $morehtmlref .= $langs->trans('Label').' : ';
+ $morehtmlref .= '';
+ }
+
+ $morehtmlref .= '
'.$langs->trans('Employee').' : '.$userstatic->getNomUrl(1);
+
+ // Project
+ if (!empty($conf->projet->enabled)) {
+ $morehtmlref .= '
'.$langs->trans('Project').' ';
+ if ($user->rights->salaries->write) {
+ if ($action != 'classify') {
+ $morehtmlref .= ''.img_edit($langs->transnoentitiesnoconv('SetProject')).' : ';
+ }
+ if ($action == 'classify') {
+ //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
+ $morehtmlref .= '';
+ } else {
+ $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
+ }
+ } else {
+ if (!empty($object->fk_project)) {
+ $proj = new Project($db);
+ $proj->fetch($object->fk_project);
+ $morehtmlref .= '';
+ $morehtmlref .= $proj->ref;
+ $morehtmlref .= '';
+ } else {
+ $morehtmlref .= '';
+ }
+ }
+ }
+
$morehtmlref .= '';
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', '');
@@ -136,7 +223,7 @@ if ($object->id) {
print dol_print_date($object->dateep, 'day');
print '';
- print '| ' . $langs->trans("Amount") . ' | ' . price($object->amount, 0, $langs, 1, -1, -1, $conf->currency) . ' |
';
+ print '| ' . $langs->trans("Amount") . ' | ' . price($object->amount, 0, $langs, 1, -1, -1, $conf->currency) . ' |
';
print '| '.$langs->trans("NbOfAttachedFiles").' | '.count($filearray).' |
';
diff --git a/htdocs/salaries/info.php b/htdocs/salaries/info.php
index 0f94f405fa1..173e03c2c7d 100644
--- a/htdocs/salaries/info.php
+++ b/htdocs/salaries/info.php
@@ -28,6 +28,10 @@ require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
+if (!empty($conf->projet->enabled)) {
+ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
+ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
+}
// Load translation files required by the page
$langs->loadLangs(array("compta", "bills", "users", "salaries", "hrm"));
@@ -36,23 +40,68 @@ $id = GETPOST('id', 'int');
$ref = GETPOST('ref', 'alpha');
$action = GETPOST('action', 'aZ09');
-$object = new Salary($db);
-if ($id > 0 || !empty($ref)) {
- $object->fetch($id, $ref);
-}
+$label = GETPOST('label', 'alphanohtml');
+$projectid = (GETPOST('projectid', 'int') ? GETPOST('projectid', 'int') : GETPOST('fk_project', 'int'));
// Security check
$socid = GETPOST('socid', 'int');
if ($user->socid) {
$socid = $user->socid;
}
+
+$object = new Salary($db);
+$extrafields = new ExtraFields($db);
+
+$childids = $user->getAllChildIds(1);
+
+// fetch optionals attributes and labels
+$extrafields->fetch_name_optionals_label($object->table_element);
+
+$object = new Salary($db);
+if ($id > 0 || !empty($ref)) {
+ $object->fetch($id, $ref);
+
+ // Check current user can read this salary
+ $canread = 0;
+ if (!empty($user->rights->salaries->readall)) {
+ $canread = 1;
+ }
+ if (!empty($user->rights->salaries->read) && $object->fk_user > 0 && in_array($object->fk_user, $childids)) {
+ $canread = 1;
+ }
+ if (!$canread) {
+ accessforbidden();
+ }
+}
+
restrictedArea($user, 'salaries', $object->id, 'salary', '');
+/*
+ * Actions
+ */
+
+// Link to a project
+if ($action == 'classin' && $user->rights->banque->modifier) {
+ $object->fetch($id);
+ $object->setProject($projectid);
+}
+
+// set label
+if ($action == 'setlabel' && $user->rights->salaries->write) {
+ $object->fetch($id);
+ $object->label = $label;
+ $object->update($user);
+}
+
+
+
/*
* View
*/
+if (!empty($conf->projet->enabled)) $formproject = new FormProjets($db);
+
$title = $langs->trans('Salary')." - ".$langs->trans('Info');
$help_url = "";
llxHeader("", $title, $help_url);
@@ -72,7 +121,54 @@ $morehtmlref = '';
$userstatic = new User($db);
$userstatic->fetch($object->fk_user);
-$morehtmlref .= $langs->trans('Employee').' : '.$userstatic->getNomUrl(1);
+
+// Label
+if ($action != 'editlabel') {
+ $morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, $user->rights->salaries->write, 'string', '', 0, 1);
+ $morehtmlref .= $object->label;
+} else {
+ $morehtmlref .= $langs->trans('Label').' : ';
+ $morehtmlref .= '
';
+}
+
+$morehtmlref .= '
'.$langs->trans('Employee').' : '.$userstatic->getNomUrl(1);
+
+// Project
+if (!empty($conf->projet->enabled)) {
+ $morehtmlref .= '
'.$langs->trans('Project').' ';
+ if ($user->rights->salaries->write) {
+ if ($action != 'classify') {
+ $morehtmlref .= '
'.img_edit($langs->transnoentitiesnoconv('SetProject')).' : ';
+ }
+ if ($action == 'classify') {
+ //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
+ $morehtmlref .= '
';
+ } else {
+ $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
+ }
+ } else {
+ if (!empty($object->fk_project)) {
+ $proj = new Project($db);
+ $proj->fetch($object->fk_project);
+ $morehtmlref .= '
';
+ $morehtmlref .= $proj->ref;
+ $morehtmlref .= '';
+ } else {
+ $morehtmlref .= '';
+ }
+ }
+}
+
$morehtmlref .= '
';
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', '');