diff --git a/htdocs/bom/tpl/linkedobjectblock.tpl.php b/htdocs/bom/tpl/linkedobjectblock.tpl.php
index 1765e9a84c1..d00340a1322 100644
--- a/htdocs/bom/tpl/linkedobjectblock.tpl.php
+++ b/htdocs/bom/tpl/linkedobjectblock.tpl.php
@@ -64,7 +64,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) {
print '';
echo '
'.dol_print_date($objectlink->date_creation, 'day').' | ';
echo '';
- if ($user->rights->commande->lire) {
+ if ($user->hasRight('commande', 'lire')) {
$total = $total + $objectlink->total_ht;
echo price($objectlink->total_ht);
}
diff --git a/htdocs/bookcal/availabilities_agenda.php b/htdocs/bookcal/availabilities_agenda.php
index b4b848f17ed..16673d6b8a3 100644
--- a/htdocs/bookcal/availabilities_agenda.php
+++ b/htdocs/bookcal/availabilities_agenda.php
@@ -88,8 +88,8 @@ if ($id > 0 || !empty($ref)) {
// Set $enablepermissioncheck to 1 to enable a minimum low level of checks
$enablepermissioncheck = 0;
if ($enablepermissioncheck) {
- $permissiontoread = $user->rights->bookcal->availabilities->read;
- $permissiontoadd = $user->rights->bookcal->availabilities->write;
+ $permissiontoread = $user->hasRight('bookcal', 'availabilities', 'read');
+ $permissiontoadd = $user->hasRight('bookcal', 'availabilities', 'write');
} else {
$permissiontoread = 1;
$permissiontoadd = 1;
@@ -100,7 +100,7 @@ if ($enablepermissioncheck) {
//if ($user->socid > 0) $socid = $user->socid;
//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
-if (empty($conf->bookcal->enabled)) accessforbidden();
+if (!isModEnabled('bookcal')) accessforbidden();
if (!$permissiontoread) accessforbidden();
diff --git a/htdocs/bookcal/availabilities_card.php b/htdocs/bookcal/availabilities_card.php
index 7736229319d..ca9fd3bf8db 100644
--- a/htdocs/bookcal/availabilities_card.php
+++ b/htdocs/bookcal/availabilities_card.php
@@ -77,11 +77,11 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ
// Set $enablepermissioncheck to 1 to enable a minimum low level of checks
$enablepermissioncheck = 0;
if ($enablepermissioncheck) {
- $permissiontoread = $user->rights->bookcal->availabilities->read;
- $permissiontoadd = $user->rights->bookcal->availabilities->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
- $permissiontodelete = $user->rights->bookcal->availabilities->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
- $permissionnote = $user->rights->bookcal->availabilities->write; // Used by the include of actions_setnotes.inc.php
- $permissiondellink = $user->rights->bookcal->availabilities->write; // Used by the include of actions_dellink.inc.php
+ $permissiontoread = $user->hasRight('bookcal', 'availabilities', 'read');
+ $permissiontoadd = $user->hasRight('bookcal', 'availabilities', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
+ $permissiontodelete = $user->hasRight('bookcal', 'availabilities', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
+ $permissionnote = $user->hasRight('bookcal', 'availabilities', 'write'); // Used by the include of actions_setnotes.inc.php
+ $permissiondellink = $user->hasRight('bookcal', 'availabilities', 'write'); // Used by the include of actions_dellink.inc.php
} else {
$permissiontoread = 1;
$permissiontoadd = 1; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
@@ -97,7 +97,7 @@ $upload_dir = $conf->bookcal->multidir_output[isset($object->entity) ? $object->
//if ($user->socid > 0) $socid = $user->socid;
//$isdraft = (isset($object->status) && ($object->status == $object::STATUS_DRAFT) ? 1 : 0);
//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
-if (empty($conf->bookcal->enabled)) accessforbidden();
+if (!isModEnabled('bookcal')) accessforbidden();
if (!$permissiontoread) accessforbidden();
diff --git a/htdocs/bookcal/availabilities_contact.php b/htdocs/bookcal/availabilities_contact.php
index 58bbc4826a4..8dfa04288f7 100644
--- a/htdocs/bookcal/availabilities_contact.php
+++ b/htdocs/bookcal/availabilities_contact.php
@@ -53,8 +53,8 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ
// Set $enablepermissioncheck to 1 to enable a minimum low level of checks
$enablepermissioncheck = 0;
if ($enablepermissioncheck) {
- $permissiontoread = $user->rights->bookcal->availabilities->read;
- $permission = $user->rights->bookcal->availabilities->write;
+ $permissiontoread = $user->hasRight('bookcal', 'availabilities', 'read');
+ $permission = $user->hasRight('bookcal', 'availabilities', 'write');
} else {
$permissiontoread = 1;
$permission = 1;
@@ -65,7 +65,7 @@ if ($enablepermissioncheck) {
//if ($user->socid > 0) $socid = $user->socid;
//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
-if (empty($conf->bookcal->enabled)) accessforbidden();
+if (!isModEnabled('bookcal')) accessforbidden();
if (!$permissiontoread) accessforbidden();
diff --git a/htdocs/bookcal/availabilities_document.php b/htdocs/bookcal/availabilities_document.php
index 721f304d9d8..96700096ee6 100644
--- a/htdocs/bookcal/availabilities_document.php
+++ b/htdocs/bookcal/availabilities_document.php
@@ -78,8 +78,8 @@ if ($id > 0 || !empty($ref)) {
// Set $enablepermissioncheck to 1 to enable a minimum low level of checks
$enablepermissioncheck = 0;
if ($enablepermissioncheck) {
- $permissiontoread = $user->rights->bookcal->availabilities->read;
- $permissiontoadd = $user->rights->bookcal->availabilities->write; // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php
+ $permissiontoread = $user->hasRight('bookcal', 'availabilities', 'read');
+ $permissiontoadd = $user->hasRight('bookcal', 'availabilities', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles.inc.php
} else {
$permissiontoread = 1;
$permissiontoadd = 1;
@@ -90,7 +90,7 @@ if ($enablepermissioncheck) {
//if ($user->socid > 0) $socid = $user->socid;
//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
-if (empty($conf->bookcal->enabled)) accessforbidden();
+if (!isModEnabled('bookcal')) accessforbidden();
if (!$permissiontoread) accessforbidden();
@@ -192,9 +192,9 @@ if ($object->id) {
print dol_get_fiche_end();
$modulepart = 'bookcal';
- //$permissiontoadd = $user->rights->bookcal->availabilities->write;
+ //$permissiontoadd = $user->hasRight('bookcal', 'availabilities', 'write');
$permissiontoadd = 1;
- //$permtoedit = $user->rights->bookcal->availabilities->write;
+ //$permtoedit = $user->hasRight('bookcal', 'availabilities', 'write');
$permtoedit = 1;
$param = '&id='.$object->id;
diff --git a/htdocs/bookcal/availabilities_list.php b/htdocs/bookcal/availabilities_list.php
index 69594d45133..7c0ef05a02d 100644
--- a/htdocs/bookcal/availabilities_list.php
+++ b/htdocs/bookcal/availabilities_list.php
@@ -132,9 +132,9 @@ $arrayfields = dol_sort_array($arrayfields, 'position');
// Set $enablepermissioncheck to 1 to enable a minimum low level of checks
$enablepermissioncheck = 0;
if ($enablepermissioncheck) {
- $permissiontoread = $user->rights->bookcal->availabilities->read;
- $permissiontoadd = $user->rights->bookcal->availabilities->write;
- $permissiontodelete = $user->rights->bookcal->availabilities->delete;
+ $permissiontoread = $user->hasRight('bookcal', 'availabilities', 'read');
+ $permissiontoadd = $user->hasRight('bookcal', 'availabilities', 'write');
+ $permissiontodelete = $user->hasRight('bookcal', 'availabilities', 'delete');
} else {
$permissiontoread = 1;
$permissiontoadd = 1;
@@ -147,7 +147,7 @@ if ($user->socid > 0) accessforbidden();
//$socid = 0; if ($user->socid > 0) $socid = $user->socid;
//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
//restrictedArea($user, $object->element, 0, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
-if (empty($conf->bookcal->enabled)) accessforbidden('Module not enabled');
+if (!isModEnabled('bookcal')) accessforbidden('Module not enabled');
if (!$permissiontoread) accessforbidden();
diff --git a/htdocs/bookcal/availabilities_note.php b/htdocs/bookcal/availabilities_note.php
index 0717e618864..27cdbbce880 100644
--- a/htdocs/bookcal/availabilities_note.php
+++ b/htdocs/bookcal/availabilities_note.php
@@ -56,9 +56,9 @@ if ($id > 0 || !empty($ref)) {
// Set $enablepermissioncheck to 1 to enable a minimum low level of checks
$enablepermissioncheck = 0;
if ($enablepermissioncheck) {
- $permissiontoread = $user->rights->bookcal->availabilities->read;
- $permissiontoadd = $user->rights->bookcal->availabilities->write;
- $permissionnote = $user->rights->bookcal->availabilities->write; // Used by the include of actions_setnotes.inc.php
+ $permissiontoread = $user->hasRight('bookcal', 'availabilities', 'read');
+ $permissiontoadd = $user->hasRight('bookcal', 'availabilities', 'write');
+ $permissionnote = $user->hasRight('bookcal', 'availabilities', 'write'); // Used by the include of actions_setnotes.inc.php
} else {
$permissiontoread = 1;
$permissiontoadd = 1;
@@ -70,7 +70,7 @@ if ($enablepermissioncheck) {
//if ($user->socid > 0) $socid = $user->socid;
//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
-if (empty($conf->bookcal->enabled)) accessforbidden();
+if (!isModEnabled('bookcal')) accessforbidden();
if (!$permissiontoread) accessforbidden();
diff --git a/htdocs/bookcal/bookcalindex.php b/htdocs/bookcal/bookcalindex.php
index b268c3b811e..b76c8e9972d 100644
--- a/htdocs/bookcal/bookcalindex.php
+++ b/htdocs/bookcal/bookcalindex.php
@@ -71,7 +71,7 @@ print '';
// BEGIN MODULEBUILDER DRAFT MYOBJECT
// Draft MyObject
-if ($user->rights->bookcal->availabilities->read && !empty($conf->bookcal->enabled)) {
+if ($user->hasRight('bookcal', 'availabilities', 'read') && isModEnabled('bookcal')) {
$langs->load("orders");
$sql = "SELECT rowid, `ref`, fk_soc, fk_project, description, note_public, note_private, date_creation, tms, fk_user_creat, fk_user_modif, last_main_doc, import_key, model_pdf, status, firstname, lastname, email, `start`, duration";
@@ -143,8 +143,7 @@ $max = $conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
/* BEGIN MODULEBUILDER LASTMODIFIED MYOBJECT
// Last modified myobject
-if (! empty($conf->bookcal->enabled))
-{
+if (isModEnabled('bookcal')) {
$sql = "SELECT rowid, `ref`, fk_soc, fk_project, description, note_public, note_private, date_creation, tms, fk_user_creat, fk_user_modif, last_main_doc, import_key, model_pdf, status, firstname, lastname, email, `start`, duration";
$sql .= " FROM ". MAIN_DB_PREFIX . 'bookcal_booking';
print "here2";
diff --git a/htdocs/bookcal/booking_agenda.php b/htdocs/bookcal/booking_agenda.php
index 10452e6640f..b171b953b42 100644
--- a/htdocs/bookcal/booking_agenda.php
+++ b/htdocs/bookcal/booking_agenda.php
@@ -100,7 +100,7 @@ if ($enablepermissioncheck) {
//if ($user->socid > 0) $socid = $user->socid;
//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
-if (empty($conf->bookcal->enabled)) accessforbidden();
+if (!isModEnabled('bookcal')) accessforbidden();
if (!$permissiontoread) accessforbidden();
diff --git a/htdocs/bookcal/booking_card.php b/htdocs/bookcal/booking_card.php
index 8ce99806e2a..623bf142e60 100644
--- a/htdocs/bookcal/booking_card.php
+++ b/htdocs/bookcal/booking_card.php
@@ -97,7 +97,7 @@ $upload_dir = $conf->bookcal->multidir_output[isset($object->entity) ? $object->
//if ($user->socid > 0) $socid = $user->socid;
//$isdraft = (isset($object->status) && ($object->status == $object::STATUS_DRAFT) ? 1 : 0);
//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
-if (empty($conf->bookcal->enabled)) accessforbidden();
+if (!isModEnabled('bookcal')) accessforbidden();
if (!$permissiontoread) accessforbidden();
diff --git a/htdocs/bookcal/booking_contact.php b/htdocs/bookcal/booking_contact.php
index e315b320cad..ceec965f5b2 100644
--- a/htdocs/bookcal/booking_contact.php
+++ b/htdocs/bookcal/booking_contact.php
@@ -65,7 +65,7 @@ if ($enablepermissioncheck) {
//if ($user->socid > 0) $socid = $user->socid;
//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
-if (empty($conf->bookcal->enabled)) accessforbidden();
+if (!isModEnabled('bookcal')) accessforbidden();
if (!$permissiontoread) accessforbidden();
diff --git a/htdocs/bookcal/booking_document.php b/htdocs/bookcal/booking_document.php
index d4147051716..aadcb0f14c9 100644
--- a/htdocs/bookcal/booking_document.php
+++ b/htdocs/bookcal/booking_document.php
@@ -90,7 +90,7 @@ if ($enablepermissioncheck) {
//if ($user->socid > 0) $socid = $user->socid;
//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
-if (empty($conf->bookcal->enabled)) accessforbidden();
+if (!isModEnabled('bookcal')) accessforbidden();
if (!$permissiontoread) accessforbidden();
diff --git a/htdocs/bookcal/booking_list.php b/htdocs/bookcal/booking_list.php
index ad72f61de65..618e8e9bb0e 100644
--- a/htdocs/bookcal/booking_list.php
+++ b/htdocs/bookcal/booking_list.php
@@ -147,7 +147,7 @@ if ($user->socid > 0) accessforbidden();
//$socid = 0; if ($user->socid > 0) $socid = $user->socid;
//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
//restrictedArea($user, $object->element, 0, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
-if (empty($conf->bookcal->enabled)) accessforbidden('Module not enabled');
+if (!isModEnabled('bookcal')) accessforbidden('Module not enabled');
if (!$permissiontoread) accessforbidden();
diff --git a/htdocs/bookcal/booking_note.php b/htdocs/bookcal/booking_note.php
index c1f2146ec57..5b00686fc27 100644
--- a/htdocs/bookcal/booking_note.php
+++ b/htdocs/bookcal/booking_note.php
@@ -70,7 +70,7 @@ if ($enablepermissioncheck) {
//if ($user->socid > 0) $socid = $user->socid;
//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
//restrictedArea($user, $object->element, $object->id, $object->table_element, '', 'fk_soc', 'rowid', $isdraft);
-if (empty($conf->bookcal->enabled)) accessforbidden();
+if (!isModEnabled('bookcal')) accessforbidden();
if (!$permissiontoread) accessforbidden();
diff --git a/htdocs/bookcal/class/availabilities.class.php b/htdocs/bookcal/class/availabilities.class.php
index 6b4502e3364..c7e86a9f589 100644
--- a/htdocs/bookcal/class/availabilities.class.php
+++ b/htdocs/bookcal/class/availabilities.class.php
@@ -201,7 +201,7 @@ class Availabilities extends CommonObject
}
// Example to show how to set values of fields definition dynamically
- /*if ($user->rights->bookcal->availabilities->read) {
+ /*if ($user->hasRight('bookcal', 'availabilities', 'read')) {
$this->fields['myfield']['visible'] = 1;
$this->fields['myfield']['noteditable'] = 0;
}*/
@@ -516,7 +516,7 @@ class Availabilities extends CommonObject
return 0;
}
- /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->availabilities->write))
+ /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && $user->hasRight('bookcal', 'availabilities', 'write'))
|| (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->bookcal->availabilities->availabilities_advance->validate))))
{
$this->error='NotEnoughPermissions';
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index 5fc0de4c43f..20afbdcf62c 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -917,8 +917,8 @@ class Propal extends CommonObject
$this->line->tva_tx = $txtva;
$this->line->localtax1_tx = $txlocaltax1;
$this->line->localtax2_tx = $txlocaltax2;
- $this->line->localtax1_type = $localtaxes_type[0];
- $this->line->localtax2_type = $localtaxes_type[2];
+ $this->line->localtax1_type = empty($localtaxes_type[0]) ? '' : $localtaxes_type[0];
+ $this->line->localtax2_type = empty($localtaxes_type[2]) ? '' : $localtaxes_type[2];
$this->line->remise_percent = $remise_percent;
$this->line->subprice = $pu_ht;
$this->line->info_bits = $info_bits;
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index 86325cf8e37..1c72f0ef4ff 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -332,14 +332,14 @@ class Commande extends CommonOrder
'note_public' =>array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>1, 'visible'=>0, 'position'=>155),
'model_pdf' =>array('type'=>'varchar(255)', 'label'=>'PDFTemplate', 'enabled'=>1, 'visible'=>0, 'position'=>160),
//'facture' =>array('type'=>'tinyint(4)', 'label'=>'ParentInvoice', 'enabled'=>1, 'visible'=>-1, 'position'=>165),
- 'fk_account' =>array('type'=>'integer', 'label'=>'BankAccount', 'enabled'=>'$conf->banque->enabled', 'visible'=>-1, 'position'=>170),
+ 'fk_account' =>array('type'=>'integer', 'label'=>'BankAccount', 'enabled'=>'isModEnabled("banque")', 'visible'=>-1, 'position'=>170),
'fk_currency' =>array('type'=>'varchar(3)', 'label'=>'MulticurrencyID', 'enabled'=>1, 'visible'=>-1, 'position'=>175),
'fk_cond_reglement' =>array('type'=>'integer', 'label'=>'PaymentTerm', 'enabled'=>1, 'visible'=>-1, 'position'=>180),
'deposit_percent' =>array('type'=>'varchar(63)', 'label'=>'DepositPercent', 'enabled'=>1, 'visible'=>-1, 'position'=>181),
'fk_mode_reglement' =>array('type'=>'integer', 'label'=>'PaymentMode', 'enabled'=>1, 'visible'=>-1, 'position'=>185),
'date_livraison' =>array('type'=>'date', 'label'=>'DateDeliveryPlanned', 'enabled'=>1, 'visible'=>-1, 'position'=>190),
'fk_shipping_method' =>array('type'=>'integer', 'label'=>'ShippingMethod', 'enabled'=>1, 'visible'=>-1, 'position'=>195),
- 'fk_warehouse' =>array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Fk warehouse', 'enabled'=>'$conf->stock->enabled', 'visible'=>-1, 'position'=>200),
+ 'fk_warehouse' =>array('type'=>'integer:Entrepot:product/stock/class/entrepot.class.php', 'label'=>'Fk warehouse', 'enabled'=>'isModEnabled("stock")', 'visible'=>-1, 'position'=>200),
'fk_availability' =>array('type'=>'integer', 'label'=>'Availability', 'enabled'=>1, 'visible'=>-1, 'position'=>205),
'fk_input_reason' =>array('type'=>'integer', 'label'=>'InputReason', 'enabled'=>1, 'visible'=>-1, 'position'=>210),
//'fk_delivery_address' =>array('type'=>'integer', 'label'=>'DeliveryAddress', 'enabled'=>1, 'visible'=>-1, 'position'=>215),
@@ -2463,7 +2463,7 @@ class Commande extends CommonOrder
{
$remise = trim($remise) ?trim($remise) : 0;
- if ($user->rights->commande->creer) {
+ if ($user->hasRight('commande', 'creer')) {
$error = 0;
$this->db->begin();
@@ -2531,7 +2531,7 @@ class Commande extends CommonOrder
$remise = price2num($remise);
- if ($user->rights->commande->creer) {
+ if ($user->hasRight('commande', 'creer')) {
$error = 0;
$this->db->begin();
@@ -2591,7 +2591,7 @@ class Commande extends CommonOrder
public function set_date($user, $date, $notrigger = 0)
{
// phpcs:enable
- if ($user->rights->commande->creer) {
+ if ($user->hasRight('commande', 'creer')) {
$error = 0;
$this->db->begin();
@@ -2663,7 +2663,7 @@ class Commande extends CommonOrder
*/
public function setDeliveryDate($user, $delivery_date, $notrigger = 0)
{
- if ($user->rights->commande->creer) {
+ if ($user->hasRight('commande', 'creer')) {
$error = 0;
$this->db->begin();
@@ -2922,7 +2922,7 @@ class Commande extends CommonOrder
public function set_ref_client($user, $ref_client, $notrigger = 0)
{
// phpcs:enable
- if ($user->rights->commande->creer) {
+ if ($user->hasRight('commande', 'creer')) {
$error = 0;
$this->db->begin();
@@ -3174,17 +3174,17 @@ class Commande extends CommonOrder
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $mysoc, $localtaxes_type, 100, $this->multicurrency_tx, $pu_ht_devise);
- $total_ht = $tabprice[0];
+ $total_ht = $tabprice[0];
$total_tva = $tabprice[1];
$total_ttc = $tabprice[2];
$total_localtax1 = $tabprice[9];
$total_localtax2 = $tabprice[10];
- $pu_ht = $tabprice[3];
+ $pu_ht = $tabprice[3];
$pu_tva = $tabprice[4];
$pu_ttc = $tabprice[5];
// MultiCurrency
- $multicurrency_total_ht = $tabprice[16];
+ $multicurrency_total_ht = $tabprice[16];
$multicurrency_total_tva = $tabprice[17];
$multicurrency_total_ttc = $tabprice[18];
$pu_ht_devise = $tabprice[19];
diff --git a/htdocs/commande/tpl/linkedobjectblock.tpl.php b/htdocs/commande/tpl/linkedobjectblock.tpl.php
index a6a1fde3851..323ef0aefa6 100644
--- a/htdocs/commande/tpl/linkedobjectblock.tpl.php
+++ b/htdocs/commande/tpl/linkedobjectblock.tpl.php
@@ -55,7 +55,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) {
echo ' '.$objectlink->ref_client.' | ';
echo ' '.dol_print_date($objectlink->date, 'day').' | ';
echo ' ';
- if ($user->rights->commande->lire) {
+ if ($user->hasRight('commande', 'lire')) {
$total = $total + $objectlink->total_ht;
echo price($objectlink->total_ht);
}
diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php
index 4ea4306a465..d2117f426ca 100644
--- a/htdocs/compta/facture/card.php
+++ b/htdocs/compta/facture/card.php
@@ -2129,6 +2129,7 @@ if (empty($reshook)) {
$date_start = dol_mktime(GETPOST('date_start'.$predef.'hour'), GETPOST('date_start'.$predef.'min'), GETPOST('date_start'.$predef.'sec'), GETPOST('date_start'.$predef.'month'), GETPOST('date_start'.$predef.'day'), GETPOST('date_start'.$predef.'year'));
$date_end = dol_mktime(GETPOST('date_end'.$predef.'hour'), GETPOST('date_end'.$predef.'min'), GETPOST('date_end'.$predef.'sec'), GETPOST('date_end'.$predef.'month'), GETPOST('date_end'.$predef.'day'), GETPOST('date_end'.$predef.'year'));
$price_base_type = (GETPOST('price_base_type', 'alpha') ? GETPOST('price_base_type', 'alpha') : 'HT');
+ $tva_npr = "";
// Define special_code for special lines
$special_code = 0;
@@ -2157,8 +2158,7 @@ if (empty($reshook)) {
//$tva_tx = $datapriceofproduct['tva_tx'];
//$tva_npr = $datapriceofproduct['tva_npr'];
-
- $tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx));
+ $tmpvat = (float) price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx));
$tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx));
// Set unit price to use
diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php
index c4ec203eb97..ae2209acacc 100644
--- a/htdocs/compta/facture/prelevement.php
+++ b/htdocs/compta/facture/prelevement.php
@@ -406,7 +406,7 @@ if ($object->id > 0) {
print '';
print $object->getLibType();
print '';
- if ($object->module_source) {
+ if (!empty($object->module_source)) {
print ' ('.$langs->trans("POS").' '.$object->module_source.' - '.$langs->trans("Terminal").' '.$object->pos_source.')';
}
if ($object->type == $object::TYPE_REPLACEMENT) {
diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php
index 294c55da4c0..e2765f37adc 100644
--- a/htdocs/contrat/card.php
+++ b/htdocs/contrat/card.php
@@ -2116,7 +2116,7 @@ if ($action == 'create') {
if (isModEnabled('commande') && $object->statut > 0 && $object->nbofservicesclosed < $nbofservices) {
$langs->load("orders");
- if ($user->rights->commande->creer) {
+ if ($user->hasRight('commande', 'creer')) {
print dolGetButtonAction($langs->trans('CreateOrder'), '', 'default', DOL_URL_ROOT.'/commande/card.php?action=create&token='.newToken().'&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->thirdparty->id, '', true, $params);
} else {
$params['attr']['title'] = $langs->trans("NotEnoughPermissions");
diff --git a/htdocs/core/boxes/box_commandes.php b/htdocs/core/boxes/box_commandes.php
index f5764c8a575..f0534728aad 100644
--- a/htdocs/core/boxes/box_commandes.php
+++ b/htdocs/core/boxes/box_commandes.php
@@ -85,7 +85,7 @@ class box_commandes extends ModeleBoxes
$this->info_box_head = array('text' => $langs->trans("BoxTitleLast".(!empty($conf->global->MAIN_LASTBOX_ON_OBJECT_DATE) ? "" : "Modified")."CustomerOrders", $max));
- if ($user->rights->commande->lire) {
+ if ($user->hasRight('commande', 'lire')) {
$sql = "SELECT s.rowid as socid, s.nom as name, s.name_alias";
$sql .= ", s.code_client, s.code_compta, s.client";
$sql .= ", s.logo, s.email, s.entity";
diff --git a/htdocs/core/boxes/box_graph_orders_permonth.php b/htdocs/core/boxes/box_graph_orders_permonth.php
index 0d8f41bc6ea..47b10fa5749 100644
--- a/htdocs/core/boxes/box_graph_orders_permonth.php
+++ b/htdocs/core/boxes/box_graph_orders_permonth.php
@@ -103,7 +103,7 @@ class box_graph_orders_permonth extends ModeleBoxes
$prefix .= 'private-'.$user->id.'-'; // If user has no permission to see all, output dir is specific to user
}
- if ($user->rights->commande->lire) {
+ if ($user->hasRight('commande', 'lire')) {
$langs->load("orders");
$param_year = 'DOLUSERCOOKIE_box_'.$this->boxcode.'_year';
diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php
index 26d90d54fb8..cec7408f1ca 100644
--- a/htdocs/core/class/commondocgenerator.class.php
+++ b/htdocs/core/class/commondocgenerator.class.php
@@ -80,6 +80,11 @@ abstract class CommonDocGenerator
*/
public $format;
+ /**
+ * @var string pdf, odt, etc
+ */
+ public $type;
+
public $page_hauteur;
public $page_largeur;
public $marge_gauche;
diff --git a/htdocs/core/tpl/card_presend.tpl.php b/htdocs/core/tpl/card_presend.tpl.php
index 6bf4807ea6f..84febb58e4e 100644
--- a/htdocs/core/tpl/card_presend.tpl.php
+++ b/htdocs/core/tpl/card_presend.tpl.php
@@ -328,7 +328,7 @@ if ($action == 'presend') {
}
$contactarr = array();
- $contactarr = $tmpobject->liste_contact(-1, 'external');
+ $contactarr = $tmpobject->liste_contact(-1, 'external', 0, '', 1);
if (is_array($contactarr) && count($contactarr) > 0) {
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php
index c61249877a3..325559882d8 100644
--- a/htdocs/expedition/shipment.php
+++ b/htdocs/expedition/shipment.php
@@ -517,7 +517,7 @@ if ($id > 0 || !empty($ref)) {
print '| ';
print $langs->trans('IncotermLabel');
print ' | | ';
- if ($user->rights->commande->creer) {
+ if ($user->hasRight('commande', 'creer')) {
print ''.img_edit().'';
} else {
print ' ';
diff --git a/htdocs/fichinter/document.php b/htdocs/fichinter/document.php
index 3b4721d63a0..52d1019d755 100644
--- a/htdocs/fichinter/document.php
+++ b/htdocs/fichinter/document.php
@@ -127,7 +127,7 @@ if ($object->id) {
if (isModEnabled('project')) {
$langs->load("projects");
$morehtmlref .= ' '.$langs->trans('Project').' ';
- if ($user->rights->commande->creer) {
+ if ($user->hasRight('commande', 'creer')) {
if ($action != 'classify') {
//$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
$morehtmlref .= ' : ';
diff --git a/htdocs/fichinter/info.php b/htdocs/fichinter/info.php
index da1af1d613b..77e31705790 100644
--- a/htdocs/fichinter/info.php
+++ b/htdocs/fichinter/info.php
@@ -82,7 +82,7 @@ $morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl
if (isModEnabled('project')) {
$langs->load("projects");
$morehtmlref .= ' '.$langs->trans('Project').' ';
- if ($user->rights->commande->creer) {
+ if ($user->hasRight('commande', 'creer')) {
if ($action != 'classify') {
//$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
$morehtmlref .= ' : ';
diff --git a/htdocs/fichinter/note.php b/htdocs/fichinter/note.php
index 93bd60e519b..f80f08a44bc 100644
--- a/htdocs/fichinter/note.php
+++ b/htdocs/fichinter/note.php
@@ -92,7 +92,7 @@ if ($id > 0 || !empty($ref)) {
if (isModEnabled('project')) {
$langs->load("projects");
$morehtmlref .= ' '.$langs->trans('Project').' ';
- if ($user->rights->commande->creer) {
+ if ($user->hasRight('commande', 'creer')) {
if ($action != 'classify') {
//$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
$morehtmlref .= ' : ';
diff --git a/htdocs/install/mysql/data/llx_c_forme_juridique.sql b/htdocs/install/mysql/data/llx_c_forme_juridique.sql
index af625035804..93dfa941189 100644
--- a/htdocs/install/mysql/data/llx_c_forme_juridique.sql
+++ b/htdocs/install/mysql/data/llx_c_forme_juridique.sql
@@ -109,26 +109,18 @@ insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '228', 'VO
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (2, '229', 'VS0 - Vennootschap met sociaal oogmerk');
--- France: Extrait de https://www.insee.fr/fr/information/2028129
-insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'11','Artisan Commerçant (EI)');
-insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'12','Commerçant (EI)');
-insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'13','Artisan (EI)');
-insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'14','Officier public ou ministériel');
-insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'15','Profession libérale (EI)');
-insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'16','Exploitant agricole');
-insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'17','Agent commercial');
-insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'18','Associé Gérant de société');
-insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'19','Personne physique');
+-- France: Catégories niveau II - Extrait de https://www.insee.fr/fr/information/2028129 - Dernière mise à jour Septembre 2022
+insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'00','Organisme de placement collectif en valeurs mobilières sans personnalité morale');
+insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'10','Entrepreneur individuel');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'21','Indivision');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'22','Société créée de fait');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'23','Société en participation');
-insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'24','Société coopérative d''interet collectif (SCIC)');
-insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'25','Société coopérative de production à responsabilité limitée (SCOP)');
+insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'24','Fiducie');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'27','Paroisse hors zone concordataire');
-insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'29','Groupement de droit privé non doté de la personnalité morale');
+insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'28','Assujetti unique à la TVA');
+insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'29','Autre groupement de droit privé non doté de la personnalité morale');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'31','Personne morale de droit étranger, immatriculée au RCS');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'32','Personne morale de droit étranger, non immatriculée au RCS');
-insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'35','Régime auto-entrepreneur');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'41','Etablissement public ou régie à caractère industriel ou commercial');
@@ -136,18 +128,16 @@ insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'51','Soci
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'52','Société en nom collectif');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'53','Société en commandite');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'54','Société à responsabilité limitée (SARL)');
-insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'55','Société anonyme à conseil d administration');
+insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'55','Société anonyme à conseil d''administration');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'56','Société anonyme à directoire');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'57','Société par actions simplifiée (SAS)');
-insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'58','Entreprise Unipersonnelle à Responsabilité Limitée (EURL)');
-insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'59','Société par actions simplifiée unipersonnelle (SASU)');
-insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'60','Entreprise Individuelle à Responsabilité Limitée (EIRL)');
+insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'58','Société européenne');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'61','Caisse d''épargne et de prévoyance');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'62','Groupement d''intérêt économique (GIE)');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'63','Société coopérative agricole');
-insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'64','Société non commerciale d assurances');
+insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'64','Société d''assurance mutuelle');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'65','Société civile');
-insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'69','Personnes de droit privé inscrites au RCS');
+insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'69','Autre personne morale de droit privé inscrite au RCS');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'71','Administration de l état');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'72','Collectivité territoriale');
@@ -163,7 +153,7 @@ insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'85','Organ
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'91','Syndicat de propriétaires');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'92','Association loi 1901 ou assimilé');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'93','Fondation');
-insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'99','Personne morale de droit privé');
+insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'99','Autre personne morale de droit privé');
-- Germany
diff --git a/htdocs/modulebuilder/template/class/api_mymodule.class.php b/htdocs/modulebuilder/template/class/api_mymodule.class.php
index fdb56ff3c67..a48b2f5010b 100644
--- a/htdocs/modulebuilder/template/class/api_mymodule.class.php
+++ b/htdocs/modulebuilder/template/class/api_mymodule.class.php
@@ -54,6 +54,8 @@ class MyModuleApi extends DolibarrApi
$this->myobject = new MyObject($this->db);
}
+ /*begin methods CRUD*/
+
/**
* Get properties of a myobject object
*
@@ -307,6 +309,31 @@ class MyModuleApi extends DolibarrApi
}
+ /**
+ * Validate fields before create or update object
+ *
+ * @param array $data Array of data to validate
+ * @return array
+ *
+ * @throws RestException
+ */
+ private function _validate($data)
+ {
+ $myobject = array();
+ foreach ($this->myobject->fields as $field => $propfield) {
+ if (in_array($field, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat')) || $propfield['notnull'] != 1) {
+ continue; // Not a mandatory field
+ }
+ if (!isset($data[$field])) {
+ throw new RestException(400, "$field field missing");
+ }
+ $myobject[$field] = $data[$field];
+ }
+ return $myobject;
+ }
+
+ /*end methods CRUD*/
+
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
/**
* Clean sensible object datas
@@ -369,27 +396,4 @@ class MyModuleApi extends DolibarrApi
return $object;
}
-
- /**
- * Validate fields before create or update object
- *
- * @param array $data Array of data to validate
- * @return array
- *
- * @throws RestException
- */
- private function _validate($data)
- {
- $myobject = array();
- foreach ($this->myobject->fields as $field => $propfield) {
- if (in_array($field, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat')) || $propfield['notnull'] != 1) {
- continue; // Not a mandatory field
- }
- if (!isset($data[$field])) {
- throw new RestException(400, "$field field missing");
- }
- $myobject[$field] = $data[$field];
- }
- return $myobject;
- }
}
diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php
index 1df4f70c063..d5854fdc702 100644
--- a/htdocs/product/stats/commande.php
+++ b/htdocs/product/stats/commande.php
@@ -136,7 +136,7 @@ if ($id > 0 || !empty($ref)) {
print dol_get_fiche_end();
- if ($user->rights->commande->lire) {
+ if ($user->hasRight('commande', 'lire')) {
$sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client, c.rowid, d.total_ht as total_ht, c.ref,";
$sql .= " c.ref_client,";
$sql .= " c.date_commande, c.fk_statut as statut, c.facture, c.rowid as commandeid, d.rowid, d.qty";
diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php
index f69b82727f0..d1631d94d94 100644
--- a/htdocs/resource/element_resource.php
+++ b/htdocs/resource/element_resource.php
@@ -541,7 +541,7 @@ if (!$ret) {
if (isModEnabled('project')) {
$langs->load("projects");
$morehtmlref .= ' '.$langs->trans('Project').' ';
- if ($user->rights->commande->creer) {
+ if ($user->hasRight('commande', 'creer')) {
if ($action != 'classify') {
//$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : ';
$morehtmlref .= ' : ';
diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php
index 207bbca63b3..732c4a57326 100644
--- a/htdocs/stripe/class/stripe.class.php
+++ b/htdocs/stripe/class/stripe.class.php
@@ -365,11 +365,14 @@ class Stripe extends CommonObject
$stripeamount = $amount;
}
- $fee = $amount * ($conf->global->STRIPE_APPLICATION_FEE_PERCENT / 100) + $conf->global->STRIPE_APPLICATION_FEE;
- if ($fee >= $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL && $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL > $conf->global->STRIPE_APPLICATION_FEE_MINIMAL) {
- $fee = $conf->global->STRIPE_APPLICATION_FEE_MAXIMAL;
- } elseif ($fee < $conf->global->STRIPE_APPLICATION_FEE_MINIMAL) {
- $fee = $conf->global->STRIPE_APPLICATION_FEE_MINIMAL;
+ $fee = 0;
+ if (getDolGlobalString("STRIPE_APPLICATION_FEE_PERCENT")) {
+ $fee = $amount * ((float) getDolGlobalString("STRIPE_APPLICATION_FEE_PERCENT", '0') / 100) + (float) getDolGlobalString("STRIPE_APPLICATION_FEE", '0');
+ }
+ if ($fee >= (float) getDolGlobalString("STRIPE_APPLICATION_FEE_MAXIMAL", '0') && (float) getDolGlobalString("STRIPE_APPLICATION_FEE_MAXIMAL", '0') > (float) getDolGlobalString("STRIPE_APPLICATION_FEE_MINIMAL", '0')) {
+ $fee = (float) getDolGlobalString("STRIPE_APPLICATION_FEE_MAXIMAL", '0');
+ } elseif ($fee < (float) getDolGlobalString("STRIPE_APPLICATION_FEE_MINIMAL", '0')) {
+ $fee = (float) getDolGlobalString("STRIPE_APPLICATION_FEE_MINIMAL", '0');
}
if (!in_array($currency_code, $arrayzerounitcurrency)) {
$stripefee = round($fee * 100);
diff --git a/htdocs/workstation/class/workstation.class.php b/htdocs/workstation/class/workstation.class.php
index 14d5bab575f..3c54d670244 100644
--- a/htdocs/workstation/class/workstation.class.php
+++ b/htdocs/workstation/class/workstation.class.php
@@ -1,6 +1,7 @@
- * Copyright (C) 2020 Gauthier VERDOL
+/* Copyright (C) 2017 Laurent Destailleur
+ * Copyright (C) 2020 Gauthier VERDOL
+ * Copyright (C) 2023 Frédéric France
*
* 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
@@ -24,8 +25,6 @@
// Put here all includes required by your class file
require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
-//require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php';
-//require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php';
/**
* Class for Workstation
@@ -118,19 +117,30 @@ class Workstation extends CommonObject
public $rowid;
public $ref;
public $label;
- public $note_public;
- public $note_private;
+
public $date_creation;
public $tms;
public $fk_user_creat;
public $fk_user_modif;
- public $import_key;
+
+ /**
+ * @var int status enabled or disabled
+ */
public $status;
public $nb_operators_required;
public $thm_operator_estimated;
public $thm_machine_estimated;
// END MODULEBUILDER PROPERTIES
+ /**
+ * @var int[] array of ID
+ */
+ public $resources;
+
+ /**
+ * @var int[] array of ID
+ */
+ public $usergroups;
/**
* Constructor
@@ -155,12 +165,6 @@ class Workstation extends CommonObject
$this->fields['entity']['enabled'] = 0;
}
- // Example to show how to set values of fields definition dynamically
- /*if ($user->rights->workstation->workstation->read) {
- $this->fields['myfield']['visible'] = 1;
- $this->fields['myfield']['noteditable'] = 0;
- }*/
-
// Unset fields that are disabled
foreach ($this->fields as $key => $val) {
if (isset($val['enabled']) && empty($val['enabled'])) {
@@ -511,132 +515,6 @@ class Workstation extends CommonObject
return $this->deleteLineCommon($user, $idline, $notrigger);
}
-
- /**
- * Validate object
- *
- * @param User $user User making status change
- * @param int $notrigger 1=Does not execute triggers, 0= execute triggers
- * @return int <=0 if OK, 0=Nothing done, >0 if KO
- */
- public function validate($user, $notrigger = 0)
- {
- global $conf, $langs;
-
- require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-
- $error = 0;
-
- // Protection
- if ($this->status == self::STATUS_VALIDATED) {
- dol_syslog(get_class($this)."::validate action abandonned: already validated", LOG_WARNING);
- return 0;
- }
-
- /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->workstation->workstation->write))
- || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->workstation->workstation->workstation_advance->validate))))
- {
- $this->error='NotEnoughPermissions';
- dol_syslog(get_class($this)."::valid ".$this->error, LOG_ERR);
- return -1;
- }*/
-
- $now = dol_now();
-
- $this->db->begin();
-
- // Define new ref
- if (!$error && (preg_match('/^[\(]?PROV/i', $this->ref) || empty($this->ref))) { // empty should not happened, but when it occurs, the test save life
- $num = $this->getNextNumRef();
- } else {
- $num = $this->ref;
- }
- $this->newref = $num;
-
- if (!empty($num)) {
- // Validate
- $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
- $sql .= " SET ref = '".$this->db->escape($num)."',";
- $sql .= " status = ".self::STATUS_VALIDATED;
- if (!empty($this->fields['date_validation'])) {
- $sql .= ", date_validation = '".$this->db->idate($now)."'";
- }
- if (!empty($this->fields['fk_user_valid'])) {
- $sql .= ", fk_user_valid = ".$user->id;
- }
- $sql .= " WHERE rowid = ".((int) $this->id);
-
- dol_syslog(get_class($this)."::validate()", LOG_DEBUG);
- $resql = $this->db->query($sql);
- if (!$resql) {
- dol_print_error($this->db);
- $this->error = $this->db->lasterror();
- $error++;
- }
-
- if (!$error && !$notrigger) {
- // Call trigger
- $result = $this->call_trigger('WORKSTATION_VALIDATE', $user);
- if ($result < 0) {
- $error++;
- }
- // End call triggers
- }
- }
-
- if (!$error) {
- $this->oldref = $this->ref;
-
- // Rename directory if dir was a temporary ref
- if (preg_match('/^[\(]?PROV/i', $this->ref)) {
- // Now we rename also files into index
- $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'workstation/".$this->db->escape($this->newref)."'";
- $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'workstation/".$this->db->escape($this->ref)."' and entity = ".$conf->entity;
- $resql = $this->db->query($sql);
- if (!$resql) {
- $error++; $this->error = $this->db->lasterror();
- }
-
- // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments
- $oldref = dol_sanitizeFileName($this->ref);
- $newref = dol_sanitizeFileName($num);
- $dirsource = $conf->workstation->dir_output.'/workstation/'.$oldref;
- $dirdest = $conf->workstation->dir_output.'/workstation/'.$newref;
- if (!$error && file_exists($dirsource)) {
- dol_syslog(get_class($this)."::validate() rename dir ".$dirsource." into ".$dirdest);
-
- if (@rename($dirsource, $dirdest)) {
- dol_syslog("Rename ok");
- // Rename docs starting with $oldref with $newref
- $listoffiles = dol_dir_list($conf->workstation->dir_output.'/workstation/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/'));
- foreach ($listoffiles as $fileentry) {
- $dirsource = $fileentry['name'];
- $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource);
- $dirsource = $fileentry['path'].'/'.$dirsource;
- $dirdest = $fileentry['path'].'/'.$dirdest;
- @rename($dirsource, $dirdest);
- }
- }
- }
- }
- }
-
- // Set new ref and current status
- if (!$error) {
- $this->ref = $num;
- $this->status = self::STATUS_VALIDATED;
- }
-
- if (!$error) {
- $this->db->commit();
- return 1;
- } else {
- $this->db->rollback();
- return -1;
- }
- }
-
-
/**
* Set draft status
*
@@ -877,7 +755,7 @@ class Workstation extends CommonObject
$this->user_creation_id = $obj->fk_user_creat;
$this->user_modification_id = $obj->fk_user_modif;
- $this->date_creation = $this->db->jdate($obj->datec);
+ $this->date_creation = $this->db->jdate($obj->datec);
$this->date_modification = empty($obj->datem) ? '' : $this->db->jdate($obj->datem);
}
@@ -898,31 +776,6 @@ class Workstation extends CommonObject
$this->initAsSpecimenCommon();
}
- /**
- * Create an array of lines
- *
- * @return array|int array of lines if OK, <0 if KO
- */
- public function getLinesArray()
- {
- $this->lines = array();
-
- /*
- $objectline = new WorkstationLine($this->db);
- $result = $objectline->fetchAll('ASC', 'position', 0, 0, array('customsql'=>'fk_workstation = '.((int) $this->id)));
-
- if (is_numeric($result)) {
- $this->error = $objectline->error;
- $this->errors = $objectline->errors;
- return $result;
- }
-
- $this->lines = $result;
- */
-
- return $this->lines;
- }
-
/**
* Returns the reference to the following non used object depending on the active numbering module.
*
@@ -1016,34 +869,4 @@ class Workstation extends CommonObject
return $result;
}
-
- /**
- * Action executed by scheduler
- * CAN BE A CRON TASK. In such a case, parameters come from the schedule job setup field 'Parameters'
- * Use public function doScheduledJob($param1, $param2, ...) to get parameters
- *
- * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK)
- */
- public function doScheduledJob()
- {
- global $conf, $langs;
-
- //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log';
-
- $error = 0;
- $this->output = '';
- $this->error = '';
-
- dol_syslog(__METHOD__, LOG_DEBUG);
-
- $now = dol_now();
-
- $this->db->begin();
-
- // ...
-
- $this->db->commit();
-
- return $error;
- }
}
|
| |