| ';
print $langs->trans('IncotermLabel');
print ' | | ';
- if ($user->hasRight('commande', 'creer')) {
+ if ($permissiontoadd) {
print ''.img_edit().'';
} else {
print ' ';
diff --git a/htdocs/expensereport/card.php b/htdocs/expensereport/card.php
index ed74fc6d189..ac16d2a69a1 100644
--- a/htdocs/expensereport/card.php
+++ b/htdocs/expensereport/card.php
@@ -352,7 +352,7 @@ if (empty($reshook)) {
}
}
- if ($action == 'update_extras') {
+ if ($action == 'update_extras' && $user->hasRight('expensereport', 'creer')) {
$object->oldcopy = dol_clone($object, 2);
// Fill array 'array_options' with data from update form
diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php
index 00598b8f9ca..8dd6cd6fe21 100644
--- a/htdocs/fichinter/card.php
+++ b/htdocs/fichinter/card.php
@@ -749,7 +749,7 @@ if (empty($reshook)) {
$permissiontoadd = $user->hasRight('ficheinter', 'creer');
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
- if ($action == 'update_extras') {
+ if ($action == 'update_extras' && $user->hasRight('ficheinter', 'creer')) {
$object->oldcopy = dol_clone($object, 2);
$attribute_name = GETPOST('attribute', 'restricthtml');
diff --git a/htdocs/fourn/facture/card-rec.php b/htdocs/fourn/facture/card-rec.php
index f135c963f10..7fefb8a3c44 100644
--- a/htdocs/fourn/facture/card-rec.php
+++ b/htdocs/fourn/facture/card-rec.php
@@ -404,7 +404,7 @@ if (empty($reshook)) {
$db->rollback();
setEventMessages($line->error, $line->errors, 'errors');
}
- } elseif ($action == 'update_extras') {
+ } elseif ($action == 'update_extras' && $usercancreate) {
$object->oldcopy = dol_clone($object, 2);
// Fill array 'array_options' with data from update form
diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php
index 424f7f8405a..5424efd5754 100644
--- a/htdocs/fourn/facture/card.php
+++ b/htdocs/fourn/facture/card.php
@@ -1981,7 +1981,7 @@ if (empty($reshook)) {
exit;
}
}
- if ($action == 'update_extras') {
+ if ($action == 'update_extras' && $usercancreate) {
$object->oldcopy = dol_clone($object, 2);
// Fill array 'array_options' with data from add form
diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php
index f73a1df8f99..8a2297f5f93 100644
--- a/htdocs/holiday/card.php
+++ b/htdocs/holiday/card.php
@@ -155,149 +155,140 @@ if (empty($reshook)) {
}
// Add leave request
- if ($action == 'add') {
- // If no right to create a request
- if (!$cancreate) {
+ if ($action == 'add' && $cancreate) {
+ $object = new Holiday($db);
+
+ $db->begin();
+
+ $date_debut = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'));
+ $date_fin = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'));
+ $date_debut_gmt = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'), 1);
+ $date_fin_gmt = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'), 1);
+ $starthalfday = GETPOST('starthalfday');
+ $endhalfday = GETPOST('endhalfday');
+ $type = GETPOST('type');
+ $halfday = 0;
+ if ($starthalfday == 'afternoon' && $endhalfday == 'morning') {
+ $halfday = 2;
+ } elseif ($starthalfday == 'afternoon') {
+ $halfday = -1;
+ } elseif ($endhalfday == 'morning') {
+ $halfday = 1;
+ }
+
+ $approverid = GETPOSTINT('valideur');
+ $description = trim(GETPOST('description', 'restricthtml'));
+
+ // Check that leave is for a user inside the hierarchy or advanced permission for all is set
+ if (!$cancreateall) {
+ if (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {
+ if (!$user->hasRight('holiday', 'write')) {
+ $error++;
+ setEventMessages($langs->trans("NotEnoughPermissions"), null, 'errors');
+ } elseif (!in_array($fuserid, $childids)) {
+ $error++;
+ setEventMessages($langs->trans("UserNotInHierachy"), null, 'errors');
+ $action = 'create';
+ }
+ } else {
+ if (!$user->hasRight('holiday', 'write') && !$user->hasRight('holiday', 'writeall_advance')) {
+ $error++;
+ setEventMessages($langs->trans("NotEnoughPermissions"), null, 'errors');
+ } elseif (!$user->hasRight('holiday', 'writeall_advance') && !in_array($fuserid, $childids)) {
+ $error++;
+ setEventMessages($langs->trans("UserNotInHierachy"), null, 'errors');
+ $action = 'create';
+ }
+ }
+ }
+
+ // If no type
+ if ($type <= 0) {
+ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
$error++;
- setEventMessages($langs->trans('CantCreateCP'), null, 'errors');
$action = 'create';
}
+ // If no start date
+ if (empty($date_debut)) {
+ setEventMessages($langs->trans("NoDateDebut"), null, 'errors');
+ $error++;
+ $action = 'create';
+ }
+ // If no end date
+ if (empty($date_fin)) {
+ setEventMessages($langs->trans("NoDateFin"), null, 'errors');
+ $error++;
+ $action = 'create';
+ }
+ // If start date after end date
+ if ($date_debut > $date_fin) {
+ setEventMessages($langs->trans("ErrorEndDateCP"), null, 'errors');
+ $error++;
+ $action = 'create';
+ }
+
+ // Check if there is already holiday for this period
+ $verifCP = $object->verifDateHolidayCP($fuserid, $date_debut, $date_fin, $halfday);
+ if (!$verifCP) {
+ setEventMessages($langs->trans("alreadyCPexist"), null, 'errors');
+ $error++;
+ $action = 'create';
+ }
+
+ // If there is no Business Days within request
+ $nbopenedday = num_open_day($date_debut_gmt, $date_fin_gmt, 0, 1, $halfday);
+ if ($nbopenedday < 0.5) {
+ setEventMessages($langs->trans("ErrorDureeCP"), null, 'errors'); // No working day
+ $error++;
+ $action = 'create';
+ }
+
+ // If no validator designated
+ if ($approverid < 1) {
+ setEventMessages($langs->transnoentitiesnoconv('InvalidValidatorCP'), null, 'errors');
+ $error++;
+ }
+
+ $approverslist = $object->fetch_users_approver_holiday();
+ if (!in_array($approverid, $approverslist)) {
+ setEventMessages($langs->transnoentitiesnoconv('InvalidValidator'), null, 'errors');
+ $error++;
+ }
+
+ // Fill array 'array_options' with data from add form
+ $ret = $extrafields->setOptionalsFromPost(null, $object);
+ if ($ret < 0) {
+ $error++;
+ }
+
+ $result = 0;
+
if (!$error) {
- $object = new Holiday($db);
+ $object->fk_user = $fuserid;
+ $object->description = $description;
+ $object->fk_validator = $approverid;
+ $object->fk_type = $type;
+ $object->date_debut = $date_debut;
+ $object->date_fin = $date_fin;
+ $object->halfday = $halfday;
+ $object->entity = $conf->entity;
- $db->begin();
-
- $date_debut = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'));
- $date_fin = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'));
- $date_debut_gmt = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'), 1);
- $date_fin_gmt = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'), 1);
- $starthalfday = GETPOST('starthalfday');
- $endhalfday = GETPOST('endhalfday');
- $type = GETPOST('type');
- $halfday = 0;
- if ($starthalfday == 'afternoon' && $endhalfday == 'morning') {
- $halfday = 2;
- } elseif ($starthalfday == 'afternoon') {
- $halfday = -1;
- } elseif ($endhalfday == 'morning') {
- $halfday = 1;
- }
-
- $approverid = GETPOSTINT('valideur');
- $description = trim(GETPOST('description', 'restricthtml'));
-
- // Check that leave is for a user inside the hierarchy or advanced permission for all is set
- if (!$cancreateall) {
- if (!getDolGlobalString('MAIN_USE_ADVANCED_PERMS')) {
- if (!$user->hasRight('holiday', 'write')) {
- $error++;
- setEventMessages($langs->trans("NotEnoughPermissions"), null, 'errors');
- } elseif (!in_array($fuserid, $childids)) {
- $error++;
- setEventMessages($langs->trans("UserNotInHierachy"), null, 'errors');
- $action = 'create';
- }
- } else {
- if (!$user->hasRight('holiday', 'write') && !$user->hasRight('holiday', 'writeall_advance')) {
- $error++;
- setEventMessages($langs->trans("NotEnoughPermissions"), null, 'errors');
- } elseif (!$user->hasRight('holiday', 'writeall_advance') && !in_array($fuserid, $childids)) {
- $error++;
- setEventMessages($langs->trans("UserNotInHierachy"), null, 'errors');
- $action = 'create';
- }
- }
- }
-
- // If no type
- if ($type <= 0) {
- setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
- $error++;
- $action = 'create';
- }
-
- // If no start date
- if (empty($date_debut)) {
- setEventMessages($langs->trans("NoDateDebut"), null, 'errors');
- $error++;
- $action = 'create';
- }
- // If no end date
- if (empty($date_fin)) {
- setEventMessages($langs->trans("NoDateFin"), null, 'errors');
- $error++;
- $action = 'create';
- }
- // If start date after end date
- if ($date_debut > $date_fin) {
- setEventMessages($langs->trans("ErrorEndDateCP"), null, 'errors');
- $error++;
- $action = 'create';
- }
-
- // Check if there is already holiday for this period
- $verifCP = $object->verifDateHolidayCP($fuserid, $date_debut, $date_fin, $halfday);
- if (!$verifCP) {
- setEventMessages($langs->trans("alreadyCPexist"), null, 'errors');
- $error++;
- $action = 'create';
- }
-
- // If there is no Business Days within request
- $nbopenedday = num_open_day($date_debut_gmt, $date_fin_gmt, 0, 1, $halfday);
- if ($nbopenedday < 0.5) {
- setEventMessages($langs->trans("ErrorDureeCP"), null, 'errors'); // No working day
- $error++;
- $action = 'create';
- }
-
- // If no validator designated
- if ($approverid < 1) {
- setEventMessages($langs->transnoentitiesnoconv('InvalidValidatorCP'), null, 'errors');
+ $result = $object->create($user);
+ if ($result <= 0) {
+ setEventMessages($object->error, $object->errors, 'errors');
$error++;
}
+ }
- $approverslist = $object->fetch_users_approver_holiday();
- if (!in_array($approverid, $approverslist)) {
- setEventMessages($langs->transnoentitiesnoconv('InvalidValidator'), null, 'errors');
- $error++;
- }
+ // If no SQL error we redirect to the request card
+ if (!$error) {
+ $db->commit();
- // Fill array 'array_options' with data from add form
- $ret = $extrafields->setOptionalsFromPost(null, $object);
- if ($ret < 0) {
- $error++;
- }
-
- $result = 0;
-
- if (!$error) {
- $object->fk_user = $fuserid;
- $object->description = $description;
- $object->fk_validator = $approverid;
- $object->fk_type = $type;
- $object->date_debut = $date_debut;
- $object->date_fin = $date_fin;
- $object->halfday = $halfday;
- $object->entity = $conf->entity;
-
- $result = $object->create($user);
- if ($result <= 0) {
- setEventMessages($object->error, $object->errors, 'errors');
- $error++;
- }
- }
-
- // If no SQL error we redirect to the request card
- if (!$error) {
- $db->commit();
-
- header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
- exit;
- } else {
- $db->rollback();
- }
+ header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
+ exit;
+ } else {
+ $db->rollback();
}
}
@@ -324,7 +315,7 @@ if (empty($reshook)) {
$action = '';
}
- if ($action == 'update' && !GETPOSTISSET('savevalidator')) {
+ if ($action == 'update' && !GETPOSTISSET('savevalidator')) { // Test on permission done later
$date_debut = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'));
$date_fin = dol_mktime(0, 0, 0, GETPOST('date_fin_month'), GETPOST('date_fin_day'), GETPOST('date_fin_year'));
$date_debut_gmt = dol_mktime(0, 0, 0, GETPOST('date_debut_month'), GETPOST('date_debut_day'), GETPOST('date_debut_year'), 1);
@@ -459,7 +450,7 @@ if (empty($reshook)) {
}
// Action validate (+ send email for approval to the expected approver)
- if ($action == 'confirm_send') {
+ if ($action == 'confirm_send') { // Test on permission done later
$object->fetch($id);
// If draft and owner of leave
diff --git a/htdocs/product/card.php b/htdocs/product/card.php
index 458bda8d606..0bee0ac2500 100644
--- a/htdocs/product/card.php
+++ b/htdocs/product/card.php
@@ -431,14 +431,14 @@ if (empty($reshook)) {
include DOL_DOCUMENT_ROOT.'/core/actions_printing.inc.php';
// Barcode type
- if ($action == 'setfk_barcode_type' && $createbarcode) {
+ if ($action == 'setfk_barcode_type' && $usercancreate) {
$result = $object->setValueFrom('fk_barcode_type', GETPOST('fk_barcode_type'), '', null, 'text', '', $user, 'PRODUCT_MODIFY');
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
// Barcode value
- if ($action == 'setbarcode' && $createbarcode) {
+ if ($action == 'setbarcode' && $usercancreate) {
$result = $object->check_barcode(GETPOST('barcode'), GETPOST('barcode_type_code'));
if ($result >= 0) {
@@ -463,7 +463,7 @@ if (empty($reshook)) {
}
// Quick edit for extrafields
- if ($action == 'update_extras') {
+ if ($action == 'update_extras' && $usercancreate) {
$object->oldcopy = dol_clone($object, 2);
// Fill array 'array_options' with data from update form
@@ -1055,9 +1055,12 @@ if (empty($reshook)) {
}
- // Add product into object
- if ($object->id > 0 && $action == 'addin') {
+ // Add product into object (when PRODUCT_ADD_FORM_ADD_TO is set)
+ if ($object->id > 0 && $action == 'addin') { // Test on permission is done just after
$thirpdartyid = 0;
+ $permissiontoaddline = false;
+
+ // Get object and test permission
if (GETPOST('propalid') > 0) {
$propal = new Propal($db);
$result = $propal->fetch(GETPOST('propalid'));
@@ -1066,6 +1069,7 @@ if (empty($reshook)) {
exit;
}
$thirpdartyid = $propal->socid;
+ $permissiontoaddline = $user->hasRight('propal', 'creer');
} elseif (GETPOST('commandeid') > 0) {
$commande = new Commande($db);
$result = $commande->fetch(GETPOST('commandeid'));
@@ -1074,6 +1078,7 @@ if (empty($reshook)) {
exit;
}
$thirpdartyid = $commande->socid;
+ $permissiontoaddline = $user->hasRight('commande', 'creer');
} elseif (GETPOST('factureid') > 0) {
$facture = new Facture($db);
$result = $facture->fetch(GETPOST('factureid'));
@@ -1082,6 +1087,7 @@ if (empty($reshook)) {
exit;
}
$thirpdartyid = $facture->socid;
+ $permissiontoaddline = $user->hasRight('facture', 'creer');
}
if ($thirpdartyid > 0) {
@@ -1142,7 +1148,7 @@ if (empty($reshook)) {
}
}
- if (GETPOST('propalid') > 0) {
+ if (GETPOST('propalid') > 0 && $permissiontoaddline) {
// Define cost price for margin calculation
$buyprice = 0;
if (($result = $propal->defineBuyPrice($pu_ht, price2num(GETPOST('remise_percent'), '', 2), $object->id)) < 0) {
@@ -1182,7 +1188,7 @@ if (empty($reshook)) {
}
setEventMessages($langs->trans("ErrorUnknown").": $result", null, 'errors');
- } elseif (GETPOST('commandeid') > 0) {
+ } elseif (GETPOST('commandeid') > 0 && $permissiontoaddline) {
// Define cost price for margin calculation
$buyprice = 0;
if (($result = $commande->defineBuyPrice($pu_ht, price2num(GETPOST('remise_percent'), '', 2), $object->id)) < 0) {
@@ -1222,7 +1228,9 @@ if (empty($reshook)) {
header("Location: ".DOL_URL_ROOT."/commande/card.php?id=".urlencode((string) ($commande->id)));
exit;
}
- } elseif (GETPOST('factureid') > 0) {
+
+ setEventMessages($langs->trans("ErrorUnknown").": $result", null, 'errors');
+ } elseif (GETPOST('factureid') > 0 && $permissiontoaddline) {
// Define cost price for margin calculation
$buyprice = 0;
if (($result = $facture->defineBuyPrice($pu_ht, price2num(GETPOST('remise_percent'), '', 2), $object->id)) < 0) {
@@ -1267,6 +1275,8 @@ if (empty($reshook)) {
header("Location: ".DOL_URL_ROOT."/compta/facture/card.php?facid=".$facture->id);
exit;
}
+
+ setEventMessages($langs->trans("ErrorUnknown").": $result", null, 'errors');
}
} else {
$action = "";
@@ -3085,7 +3095,7 @@ if (getDolGlobalString('PRODUCT_ADD_FORM_ADD_TO') && $object->id && ($action ==
}
}
- //If any text is going to be printed, then we show the table
+ // If any text is going to be printed, then we show the table
if (!empty($html)) {
print ' | ';
}
-if ($object->element == 'stock') {
+if ($object->element == 'stockmouvement') {
print ''.$langs->trans("Product").' | ';
print '';
print img_picto('', 'product');
@@ -162,7 +162,7 @@ if ($object->element == 'stock') {
}
print ' | '.$langs->trans("NumberOfUnit").' | ';
print '';
-if ($object->element == 'product' || $object->element == 'stock') {
+if ($object->element == 'product' || $object->element == 'stockmouvement') {
print ' |