diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php
index 2854a631e42..aa73c9cdc8a 100644
--- a/htdocs/core/actions_massactions.inc.php
+++ b/htdocs/core/actions_massactions.inc.php
@@ -1507,6 +1507,57 @@ if (!$error && ($massaction == 'approveleave' || ($action == 'approveleave' && $
}
}
+if (!$error && ($massaction == 'increaseholiday' || ($action == 'increaseholiday' && $confirm == 'yes')) && $permissiontoapprove) {
+ $db->begin();
+ $objecttmp = new $objectclass($db);
+ $nbok = 0;
+ $typeholiday = GETPOST('typeholiday', 'alpha');
+ $nbdaysholidays = GETPOST('nbdaysholidays', 'double');
+
+ if ($nbdaysholidays <= 0) {
+ setEventMessages($langs->trans("WrongAmount"), "", 'errors');
+ $error++;
+ }
+
+ if (!$error) {
+ foreach ($toselect as $toselectid) {
+ $balancecpuser = $objecttmp->getCPforUser($toselectid, $typeholiday);
+ if (!empty($balancecpuser)) {
+ $newnbdaysholidays = $nbdaysholidays + $balancecpuser;
+ } else {
+ $newnbdaysholidays = $nbdaysholidays;
+ }
+ $result = $holiday->addLogCP($user->id, $toselectid, $langs->transnoentitiesnoconv('ManualUpdate'), $newnbdaysholidays, $typeholiday);
+ if ($result <= 0) {
+ setEventMessages($holiday->error, $holiday->errors, 'errors');
+ $error++;
+ break;
+ }
+
+ $objecttmp->updateSoldeCP($toselectid, $newnbdaysholidays, $typeholiday);
+ if ($result > 0) {
+ $nbok++;
+ } else {
+ setEventMessages("", $langs->trans("ErrorUpdatingUsersCP"), 'errors');
+ $error++;
+ break;
+ }
+ }
+ }
+
+ if (!$error) {
+ if ($nbok > 1) {
+ setEventMessages($langs->trans("HolidayRecordsIncreased", $nbok), null, 'mesgs');
+ } elseif ($nbok == 1) {
+ setEventMessages($langs->trans("HolidayRecordIncreased"), null, 'mesgs');
+ }
+ $db->commit();
+ $toselect=array();
+ } else {
+ $db->rollback();
+ }
+}
+
$parameters['toselect'] = $toselect;
$parameters['uploaddir'] = $uploaddir;
$parameters['massaction'] = $massaction;
diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php
index 0efee8461dc..3e7a3cc291a 100644
--- a/htdocs/core/class/extrafields.class.php
+++ b/htdocs/core/class/extrafields.class.php
@@ -80,6 +80,7 @@ class ExtraFields
'datetime'=>'DateAndTime',
'boolean'=>'Boolean',
'price'=>'ExtrafieldPrice',
+ 'pricecy'=>'ExtrafieldPriceWithCurrency',
'phone'=>'ExtrafieldPhone',
'mail'=>'ExtrafieldMail',
'url'=>'ExtrafieldUrl',
@@ -113,7 +114,7 @@ class ExtraFields
*
* @param string $attrname Code of attribute
* @param string $label label of attribute
- * @param string $type Type of attribute ('boolean','int','varchar','text','html','date','datehour','price','phone','mail','password','url','select','checkbox','separate',...)
+ * @param string $type Type of attribute ('boolean','int','varchar','text','html','date','datehour','price', 'pricecy', 'phone','mail','password','url','select','checkbox','separate',...)
* @param int $pos Position of attribute
* @param string $size Size/length definition of attribute ('5', '24,8', ...). For float, it contains 2 numeric separated with a comma.
* @param string $elementtype Element type. Same value than object->table_element (Example 'member', 'product', 'thirdparty', ...)
@@ -182,7 +183,7 @@ class ExtraFields
* This is a private method. For public method, use addExtraField.
*
* @param string $attrname code of attribute
- * @param int $type Type of attribute ('boolean', 'int', 'varchar', 'text', 'html', 'date', 'datehour','price','phone','mail','password','url','select','checkbox', ...)
+ * @param int $type Type of attribute ('boolean', 'int', 'varchar', 'text', 'html', 'date', 'datehour','price','pricecy','phone','mail','password','url','select','checkbox', ...)
* @param string $length Size/length of attribute ('5', '24,8', ...)
* @param string $elementtype Element type ('member', 'product', 'thirdparty', 'contact', ...)
* @param int $unique Is field unique or not
@@ -217,6 +218,9 @@ class ExtraFields
} elseif ($type == 'price') {
$typedb = 'double';
$lengthdb = '24,8';
+ } elseif ($type == 'pricecy') {
+ $typedb = 'varchar';
+ $lengthdb = '64';
} elseif ($type == 'phone') {
$typedb = 'varchar';
$lengthdb = '20';
@@ -567,6 +571,9 @@ class ExtraFields
} elseif ($type == 'price') {
$typedb = 'double';
$lengthdb = '24,8';
+ } elseif ($type == 'pricecy') {
+ $typedb = 'varchar';
+ $lengthdb = '64';
} elseif ($type == 'phone') {
$typedb = 'varchar';
$lengthdb = '20';
@@ -1089,6 +1096,16 @@ class ExtraFields
$value = price($value);
}
$out = ' '.$langs->getCurrencySymbol($conf->currency);
+ } elseif ($type == 'pricecy') {
+ $currency = $conf->currency;
+ if (!empty($value)) {
+ // $value in memory is a php string like '10.01:USD'
+ $pricetmp = explode(':', $value);
+ $currency = !empty($pricetmp[1]) ? $pricetmp[1] : $conf->currency;
+ $value = price($pricetmp[0]);
+ }
+ $out = ' ';
+ $out .= $form->selectCurrency($currency, $keyprefix.$key.$keysuffix.'currency_id');
} elseif ($type == 'double') {
if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format.
$value = price($value);
@@ -1624,6 +1641,17 @@ class ExtraFields
if ($value || $value == '0') {
$value = price($value, 0, $langs, 0, $conf->global->MAIN_MAX_DECIMALS_TOT, -1).' '.$langs->getCurrencySymbol($conf->currency);
}
+ } elseif ($type == 'pricecy') {
+ $currency = $conf->currency;
+ if (!empty($value)) {
+ // $value in memory is a php string like '0.01:EUR'
+ $pricetmp = explode(':', $value);
+ $currency = !empty($pricetmp[1]) ? $pricetmp[1] : $conf->currency;
+ $value = $pricetmp[0];
+ }
+ if ($value || $value == '0') {
+ $value = price($value, 0, $langs, 0, $conf->global->MAIN_MAX_DECIMALS_TOT, -1, $currency);
+ }
} elseif ($type == 'select') {
$valstr = (!empty($param['options'][$value]) ? $param['options'][$value] : '');
if (($pos = strpos($valstr, "|")) !== false) {
@@ -2095,6 +2123,8 @@ class ExtraFields
} elseif (in_array($key_type, array('price', 'double'))) {
$value_arr = GETPOST("options_".$key, 'alpha');
$value_key = price2num($value_arr);
+ } elseif (in_array($key_type, array('pricecy', 'double'))) {
+ $value_key = price2num(GETPOST("options_".$key, 'alpha')).':'.GETPOST("options_".$key."currency_id", 'alpha');
} elseif (in_array($key_type, array('html'))) {
$value_key = GETPOST("options_".$key, 'restricthtml');
} elseif (in_array($key_type, array('text'))) {
diff --git a/htdocs/core/lib/categories.lib.php b/htdocs/core/lib/categories.lib.php
index 8ff1dbb97ae..ee69ccf4a87 100644
--- a/htdocs/core/lib/categories.lib.php
+++ b/htdocs/core/lib/categories.lib.php
@@ -80,7 +80,10 @@ function categories_prepare_head(Categorie $object, $type)
*/
function categoriesadmin_prepare_head()
{
- global $langs, $conf, $user;
+ global $langs, $conf, $user, $db;
+
+ $extrafields = new ExtraFields($db);
+ $extrafields->fetch_name_optionals_label('categorie');
$langs->load("categories");
@@ -94,6 +97,10 @@ function categoriesadmin_prepare_head()
$head[$h][0] = DOL_URL_ROOT.'/categories/admin/categorie_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFieldsCategories");
+ $nbExtrafields = $extrafields->attributes['categorie']['count'];
+ if ($nbExtrafields > 0) {
+ $head[$h][1] .= ''.$nbExtrafields.'';
+ }
$head[$h][2] = 'attributes_categories';
$h++;
diff --git a/htdocs/core/lib/member.lib.php b/htdocs/core/lib/member.lib.php
index f235be0d070..5cad13a6e57 100644
--- a/htdocs/core/lib/member.lib.php
+++ b/htdocs/core/lib/member.lib.php
@@ -20,8 +20,8 @@
*/
/**
- * \file htdocs/core/lib/member.lib.php
- * \brief Functions for module members
+ * \file htdocs/core/lib/member.lib.php
+ * \brief Functions for module members
*/
/**
@@ -184,7 +184,11 @@ function member_type_prepare_head(AdherentType $object)
*/
function member_admin_prepare_head()
{
- global $langs, $conf, $user;
+ global $langs, $conf, $user, $db;
+
+ $extrafields = new ExtraFields($db);
+ $extrafields->fetch_name_optionals_label('adherent');
+ $extrafields->fetch_name_optionals_label('adherent_type');
$h = 0;
$head = array();
@@ -207,11 +211,19 @@ function member_admin_prepare_head()
$head[$h][0] = DOL_URL_ROOT.'/adherents/admin/member_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFieldsMember");
+ $nbExtrafields = $extrafields->attributes['adherent']['count'];
+ if ($nbExtrafields > 0) {
+ $head[$h][1] .= ''.$nbExtrafields.'';
+ }
$head[$h][2] = 'attributes';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/adherents/admin/member_type_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFieldsMemberType");
+ $nbExtrafields = $extrafields->attributes['adherent_type']['count'];
+ if ($nbExtrafields > 0) {
+ $head[$h][1] .= ''.$nbExtrafields.'';
+ }
$head[$h][2] = 'attributes_type';
$h++;
diff --git a/htdocs/core/lib/order.lib.php b/htdocs/core/lib/order.lib.php
index 80d2c0c534d..5c77f8ab821 100644
--- a/htdocs/core/lib/order.lib.php
+++ b/htdocs/core/lib/order.lib.php
@@ -42,7 +42,7 @@ function commande_prepare_head(Commande $object)
$h = 0;
$head = array();
- if (isModEnabled('commande') && $user->rights->commande->lire) {
+ if (isModEnabled('commande') && $user->hasRight('commande', 'lire')) {
$head[$h][0] = DOL_URL_ROOT.'/commande/card.php?id='.$object->id;
$head[$h][1] = $langs->trans("CustomerOrder");
$head[$h][2] = 'order';
@@ -61,27 +61,27 @@ function commande_prepare_head(Commande $object)
}
if ((isModEnabled('expedition_bon') && $user->hasRight('expedition', 'lire'))
- || ($conf->delivery_note->enabled && $user->hasRight('expedition', 'delivery', 'lire'))) {
+ || (isModEnabled('delivery_note') && $user->hasRight('expedition', 'delivery', 'lire'))) {
$nbShipments = $object->getNbOfShipments();
$nbReceiption = 0;
$head[$h][0] = DOL_URL_ROOT.'/expedition/shipment.php?id='.$object->id;
$text = '';
- if ($conf->expedition_bon->enabled) {
+ if (isModEnabled('expedition_bon')) {
$text .= $langs->trans("Shipments");
}
- if ($conf->expedition_bon->enabled && $conf->delivery_note->enabled) {
+ if (isModEnabled('expedition_bon') && isModEnabled('delivery_note')) {
$text .= ' - ';
}
- if ($conf->delivery_note->enabled) {
+ if (isModEnabled('delivery_note')) {
$text .= $langs->trans("Receivings");
}
if ($nbShipments > 0 || $nbReceiption > 0) {
$text .= ''.($nbShipments ? $nbShipments : 0);
}
- if ($conf->expedition_bon->enabled && $conf->delivery_note->enabled && ($nbShipments > 0 || $nbReceiption > 0)) {
+ if (isModEnabled('expedition_bon') && isModEnabled('delivery_note') && ($nbShipments > 0 || $nbReceiption > 0)) {
$text .= ' - ';
}
- if ($conf->expedition_bon->enabled && $conf->delivery_note->enabled && ($nbShipments > 0 || $nbReceiption > 0)) {
+ if (isModEnabled('expedition_bon') && isModEnabled('delivery_note') && ($nbShipments > 0 || $nbReceiption > 0)) {
$text .= ($nbReceiption ? $nbReceiption : 0);
}
if ($nbShipments > 0 || $nbReceiption > 0) {
@@ -147,7 +147,11 @@ function commande_prepare_head(Commande $object)
*/
function order_admin_prepare_head()
{
- global $langs, $conf, $user;
+ global $langs, $conf, $user, $db;
+
+ $extrafields = new ExtraFields($db);
+ $extrafields->fetch_name_optionals_label('commande');
+ $extrafields->fetch_name_optionals_label('commandedet');
$h = 0;
$head = array();
@@ -161,11 +165,19 @@ function order_admin_prepare_head()
$head[$h][0] = DOL_URL_ROOT.'/admin/order_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFields");
+ $nbExtrafields = $extrafields->attributes['commande']['count'];
+ if ($nbExtrafields > 0) {
+ $head[$h][1] .= ''.$nbExtrafields.'';
+ }
$head[$h][2] = 'attributes';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/admin/orderdet_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFieldsLines");
+ $nbExtrafields = $extrafields->attributes['commandedet']['count'];
+ if ($nbExtrafields > 0) {
+ $head[$h][1] .= ''.$nbExtrafields.'';
+ }
$head[$h][2] = 'attributeslines';
$h++;
@@ -188,7 +200,7 @@ function getCustomerOrderPieChart($socid = 0)
$result = '';
- if (empty($conf->commande->enabled) || empty($user->rights->commande->lire)) {
+ if (!isModEnabled('commande') || !$user->hasRight('commande', 'lire')) {
return '';
}
@@ -278,7 +290,7 @@ function getCustomerOrderPieChart($socid = 0)
$result .= "\n";
}
}
- if ($conf->use_javascript_ajax) {
+ if (!empty($conf->use_javascript_ajax)) {
$result .= ' ';
$usersupervisor = new User($db);
foreach ($listUsers as $users) {
+ $arrayofselected = is_array($toselect) ? $toselect : array();
+
// If user has not permission to edit/read all, we must see only subordinates
if (empty($user->rights->holiday->readall)) {
if (($users['rowid'] != $user->id) && (!in_array($users['rowid'], $userchilds))) {
@@ -389,11 +414,21 @@ if (count($typeleaves) == 0) {
print '';
// Button modify
- print '';
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php
index dc4ef707a4e..d44c73129da 100644
--- a/htdocs/core/tpl/admin_extrafields_add.tpl.php
+++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php
@@ -97,6 +97,7 @@ $listofexamplesforlink = 'Societe:societe/class/societe.class.php
Contact:con
else if (type == 'password') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true); default_value.val('').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helppassword").show();}
else if (type == 'boolean') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();}
else if (type == 'price') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();}
+ else if (type == 'pricecy') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();}
else if (type == 'select') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helpselect").show();}
else if (type == 'sellist') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helpsellist").show();}
else if (type == 'radio') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helpselect").show();}
diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php
index f16526533ff..2e8511acf8e 100644
--- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php
+++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php
@@ -96,6 +96,7 @@ $listofexamplesforlink = 'Societe:societe/class/societe.class.php
Contact:con
else if (type == 'password') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); required.val('').prop('disabled', true); default_value.val('').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helppassword").show();}
else if (type == 'boolean') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();}
else if (type == 'price') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();}
+ else if (type == 'pricecy') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").hide(); jQuery("#helpchkbxlst").hide();}
else if (type == 'select') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helpselect").show();}
else if (type == 'sellist') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helpsellist").show();}
else if (type == 'radio') { size.val('').prop('disabled', true); unique.removeAttr('checked').prop('disabled', true); jQuery("#value_choice").show(); jQuery(".spanforparamtooltip").hide(); jQuery("#helpselect").show();}
diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php
index 656b5b263aa..795797c2848 100644
--- a/htdocs/core/tpl/massactions_pre.tpl.php
+++ b/htdocs/core/tpl/massactions_pre.tpl.php
@@ -283,6 +283,29 @@ if ($massaction == 'preapproveleave') {
print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassLeaveApproval"), $langs->trans("ConfirmMassLeaveApprovalQuestion", count($toselect)), "approveleave", null, 'yes', 0, 200, 500, 1);
}
+if ($massaction == 'preincreaseholiday') {
+ $langs->load("holiday", "hrm");
+ require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php';
+ $staticholiday = new Holiday($db);
+ $arraytypeholidays = $staticholiday->getTypes(1, 1);
+ $formquestion[] = array();
+ $labeltypes = array();
+ foreach ($typeleaves as $key => $val) {
+ $labeltypes[$val['id']] = ($langs->trans($val['code']) != $val['code']) ? $langs->trans($val['code']) : $langs->trans($val['label']);
+ }
+ $formquestion [] = array( 'type' => 'other',
+ 'name' => 'typeofholiday',
+ 'label' => $langs->trans("Type"),
+ 'value' => $form->selectarray('typeholiday', $labeltypes, GETPOST('typeholiday', 'alpha'), 1)
+ );
+ $formquestion [] = array( 'type' => 'other',
+ 'name' => 'nbdaysholydays',
+ 'label' => $langs->trans("NumberDayAddMass"),
+ 'value' => ''
+ );
+ print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassIncreaseHoliday"), $langs->trans("ConfirmMassIncreaseHolidayQuestion", count($toselect)), "increaseholiday", $formquestion, 1, 0, 200, 500, 1);
+}
+
// Allow Pre-Mass-Action hook (eg for confirmation dialog)
$parameters = array(
'toselect' => $toselect,
diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php
index 486315f36ac..f47a4128c65 100644
--- a/htdocs/holiday/define_holiday.php
+++ b/htdocs/holiday/define_holiday.php
@@ -46,6 +46,9 @@ $search_supervisor = GETPOST('search_supervisor', 'int');
$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
+$toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected into a list
+$confirm = GETPOST('confirm', 'alpha');
+
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
if (empty($page) || $page == -1) {
$page = 0;
@@ -113,14 +116,13 @@ if (empty($reshook)) {
}
// Mass actions
- /*
- $objectclass='Skeleton';
- $objectlabel='Skeleton';
- $permissiontoread = $user->rights->skeleton->read;
- $permissiontodelete = $user->rights->skeleton->delete;
- $uploaddir = $conf->skeleton->dir_output;
+ $objectclass = 'Holiday';
+ $objectlabel = 'Holiday';
+ $permissiontoread = $user->hasRight('holiday', 'read');
+ $permissiontodelete = $user->hasRight('holiday', 'delete');
+ $permissiontoapprove = $user->hasRight('holiday', 'approve');
+ $uploaddir = $conf->holiday->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
- */
// Si il y a une action de mise à jour
if ($action == 'update' && GETPOSTISSET('update_cp')) {
@@ -213,6 +215,17 @@ if ($result < 0) {
setEventMessages($holiday->error, $holiday->errors, 'errors');
}
+// List of mass actions available
+$arrayofmassactions = array(
+ //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"),
+ //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"),
+ //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"),
+);
+if ($user->hasRight("holiday", "approve")) {
+ $arrayofmassactions['preincreaseholiday'] = img_picto('', 'add', 'class="pictofixedwidth"').$langs->trans("IncreaseHolidays");
+}
+$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
+
print '