Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2023-03-02 15:25:27 +01:00
commit 3f2e042f23
35 changed files with 131 additions and 307 deletions

View File

@ -64,7 +64,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) {
print '</td>';
echo '<td class="linkedcol-date">'.dol_print_date($objectlink->date_creation, 'day').'</td>';
echo '<td class="linkedcol-amount right">';
if ($user->rights->commande->lire) {
if ($user->hasRight('commande', 'lire')) {
$total = $total + $objectlink->total_ht;
echo price($objectlink->total_ht);
}

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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;

View File

@ -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();

View File

@ -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();

View File

@ -71,7 +71,7 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
// 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";

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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';

View File

@ -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;

View File

@ -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];

View File

@ -55,7 +55,7 @@ foreach ($linkedObjectBlock as $key => $objectlink) {
echo '<td class="linkedcol-ref">'.$objectlink->ref_client.'</td>';
echo '<td class="linkedcol-date center">'.dol_print_date($objectlink->date, 'day').'</td>';
echo '<td class="linkedcol-amount right">';
if ($user->rights->commande->lire) {
if ($user->hasRight('commande', 'lire')) {
$total = $total + $objectlink->total_ht;
echo price($objectlink->total_ht);
}

View File

@ -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

View File

@ -406,7 +406,7 @@ if ($object->id > 0) {
print '<span class="badgeneutral">';
print $object->getLibType();
print '</span>';
if ($object->module_source) {
if (!empty($object->module_source)) {
print ' <span class="opacitymediumbycolor paddingleft">('.$langs->trans("POS").' '.$object->module_source.' - '.$langs->trans("Terminal").' '.$object->pos_source.')</span>';
}
if ($object->type == $object::TYPE_REPLACEMENT) {

View File

@ -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");

View File

@ -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";

View File

@ -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';

View File

@ -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;

View File

@ -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';

View File

@ -517,7 +517,7 @@ if ($id > 0 || !empty($ref)) {
print '<table width="100%" class="nobordernopadding"><tr><td>';
print $langs->trans('IncotermLabel');
print '<td><td class="right">';
if ($user->rights->commande->creer) {
if ($user->hasRight('commande', 'creer')) {
print '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'/expedition/shipment.php?id='.$object->id.'&action=editincoterm&token='.newToken().'">'.img_edit().'</a>';
} else {
print '&nbsp;';

View File

@ -127,7 +127,7 @@ if ($object->id) {
if (isModEnabled('project')) {
$langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($user->rights->commande->creer) {
if ($user->hasRight('commande', 'creer')) {
if ($action != 'classify') {
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token='.newToken().'&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref .= ' : ';

View File

@ -82,7 +82,7 @@ $morehtmlref .= $langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl
if (isModEnabled('project')) {
$langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($user->rights->commande->creer) {
if ($user->hasRight('commande', 'creer')) {
if ($action != 'classify') {
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token='.newToken().'&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref .= ' : ';

View File

@ -92,7 +92,7 @@ if ($id > 0 || !empty($ref)) {
if (isModEnabled('project')) {
$langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($user->rights->commande->creer) {
if ($user->hasRight('commande', 'creer')) {
if ($action != 'classify') {
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token='.newToken().'&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref .= ' : ';

View File

@ -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

View File

@ -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;
}
}

View File

@ -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";

View File

@ -541,7 +541,7 @@ if (!$ret) {
if (isModEnabled('project')) {
$langs->load("projects");
$morehtmlref .= '<br>'.$langs->trans('Project').' ';
if ($user->rights->commande->creer) {
if ($user->hasRight('commande', 'creer')) {
if ($action != 'classify') {
//$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token='.newToken().'&id=' . $fichinter->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
$morehtmlref .= ' : ';

View File

@ -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);

View File

@ -1,6 +1,7 @@
<?php
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2020 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
/* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2020 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
* Copyright (C) 2023 Frédéric France <frederic.france@netlogic.fr>
*
* 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;
}
}