Skip to content

Commit

Permalink
Merge remote-tracking branch 'Dolibarr/19.0' into 19
Browse files Browse the repository at this point in the history
  • Loading branch information
fappels committed Mar 27, 2024
2 parents 8931986 + dc43a7e commit a4bd2b5
Show file tree
Hide file tree
Showing 14 changed files with 95 additions and 87 deletions.
8 changes: 6 additions & 2 deletions htdocs/core/class/stats.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,12 @@ public function getNbByMonthWithPrevYear($endyear, $startyear, $cachedelay = 0,
dol_mkdir($conf->user->dir_temp);
}
$fp = fopen($newpathofdestfile, 'w');
fwrite($fp, json_encode($data));
fclose($fp);
if ($fp) {
fwrite($fp, json_encode($data));
fclose($fp);
} else {
dol_syslog("Failed to save cache file ".$newpathofdestfile);
}
dolChmod($newpathofdestfile);

$this->lastfetchdate[get_class($this).'_'.__FUNCTION__] = $nowgmt;
Expand Down
144 changes: 74 additions & 70 deletions htdocs/core/modules/modStock.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function __construct($db)
$this->const[$r][0] = "MOUVEMENT_ADDON_PDF";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "stdmovement";
$this->const[$r][3] = 'Name of PDF model of stock mouvement';
$this->const[$r][3] = 'Name of PDF model of stock movement';
$this->const[$r][4] = 0;

$r++;
Expand All @@ -113,78 +113,82 @@ public function __construct($db)
$this->rights = array();
$this->rights_class = 'stock';

$this->rights[0][0] = 1001;
$this->rights[0][1] = 'Lire les stocks';
$this->rights[0][2] = 'r';
$this->rights[0][3] = 0;
$this->rights[0][4] = 'lire';
$this->rights[0][5] = '';

$this->rights[1][0] = 1002;
$this->rights[1][1] = 'Creer/Modifier les stocks';
$this->rights[1][2] = 'w';
$this->rights[1][3] = 0;
$this->rights[1][4] = 'creer';
$this->rights[1][5] = '';

$this->rights[2][0] = 1003;
$this->rights[2][1] = 'Supprimer les stocks';
$this->rights[2][2] = 'd';
$this->rights[2][3] = 0;
$this->rights[2][4] = 'supprimer';
$this->rights[2][5] = '';

$this->rights[3][0] = 1004;
$this->rights[3][1] = 'Lire mouvements de stocks';
$this->rights[3][2] = 'r';
$this->rights[3][3] = 0;
$this->rights[3][4] = 'mouvement';
$this->rights[3][5] = 'lire';

$this->rights[4][0] = 1005;
$this->rights[4][1] = 'Creer/modifier mouvements de stocks';
$this->rights[4][2] = 'w';
$this->rights[4][3] = 0;
$this->rights[4][4] = 'mouvement';
$this->rights[4][5] = 'creer';

$this->rights[5][0] = 1011;
$this->rights[5][1] = 'inventoryReadPermission'; // Permission label
$this->rights[5][3] = 0; // Permission by default for new user (0/1)
$this->rights[5][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
$this->rights[5][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

$this->rights[6][0] = 1012;
$this->rights[6][1] = 'inventoryCreatePermission'; // Permission label
$this->rights[6][3] = 0; // Permission by default for new user (0/1)
$this->rights[6][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
$this->rights[6][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

$this->rights[6][0] = 1013;
$this->rights[6][1] = 'inventoryDeletePermission'; // Permission label
$this->rights[6][3] = 0; // Permission by default for new user (0/1)
$this->rights[6][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
$this->rights[6][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
$r = 0;

$this->rights[$r][0] = 1001;
$this->rights[$r][1] = 'Read stocks';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'lire';
$this->rights[$r][5] = '';

$r++;
$this->rights[$r][0] = 1002;
$this->rights[$r][1] = 'Create/Modify stocks';
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'creer';
$this->rights[$r][5] = '';

$r++;
$this->rights[$r][0] = 1003;
$this->rights[$r][1] = 'Delete stock';
$this->rights[$r][2] = 'd';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'supprimer';
$this->rights[$r][5] = '';

$r++;
$this->rights[$r][0] = 1004;
$this->rights[$r][1] = 'Read stock movements';
$this->rights[$r][2] = 'r';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'mouvement';
$this->rights[$r][5] = 'lire';

$r++;
$this->rights[$r][0] = 1005;
$this->rights[$r][1] = 'Create/modify stock movements';
$this->rights[$r][2] = 'w';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'mouvement';
$this->rights[$r][5] = 'creer';

$r++;
$this->rights[$r][0] = 1011;
$this->rights[$r][1] = 'inventoryReadPermission'; // Permission label
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
$this->rights[$r][5] = 'read'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

$r++;
$this->rights[$r][0] = 1012;
$this->rights[$r][1] = 'inventoryCreatePermission'; // Permission label
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
$this->rights[$r][5] = 'write'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

$r++;
$this->rights[$r][0] = 1013;
$this->rights[$r][1] = 'inventoryDeletePermission'; // Permission label
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
$this->rights[$r][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
$this->rights[8][0] = 1014;
$this->rights[8][1] = 'inventoryValidatePermission'; // Permission label
$this->rights[8][3] = 0; // Permission by default for new user (0/1)
$this->rights[8][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
$this->rights[8][5] = 'validate'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

$this->rights[9][0] = 1015;
$this->rights[9][1] = 'inventoryChangePMPPermission'; // Permission label
$this->rights[9][3] = 0; // Permission by default for new user (0/1)
$this->rights[9][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
$this->rights[9][5] = 'changePMP'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

$this->rights[10][0] = 1016;
$this->rights[10][1] = 'inventoryDeletePermission'; // Permission label
$this->rights[10][3] = 0; // Permission by default for new user (0/1)
$this->rights[10][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
$this->rights[10][5] = 'delete'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
$r++;
$this->rights[$r][0] = 1014;
$this->rights[$r][1] = 'inventoryValidatePermission'; // Permission label
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
$this->rights[$r][5] = 'validate'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)

$r++;
$this->rights[$r][0] = 1015;
$this->rights[$r][1] = 'inventoryChangePMPPermission'; // Permission label
$this->rights[$r][3] = 0; // Permission by default for new user (0/1)
$this->rights[$r][4] = 'inventory_advance'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
$this->rights[$r][5] = 'changePMP'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2)
}

// Main menu entries
Expand Down
6 changes: 3 additions & 3 deletions htdocs/fourn/facture/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -650,17 +650,17 @@
$listofcategoryid = '';
foreach ($searchCategoryProductList as $searchCategoryProduct) {
if (intval($searchCategoryProduct) == -2) {
$searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."facture_fourn_det as fd WHERE fd.fk_facture_fourn = f.rowid AND p.rowid = ck.fk_product)";
$searchCategoryProductSqlList[] = "NOT EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."facture_fourn_det as fd WHERE fd.fk_facture_fourn = f.rowid AND fd.fk_product = ck.fk_product)";
} elseif (intval($searchCategoryProduct) > 0) {
if ($searchCategoryProductOperator == 0) {
$searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."facture_fourn_det as fd WHERE fd.fk_facture_fourn = f.rowid AND p.rowid = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).")";
$searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."facture_fourn_det as fd WHERE fd.fk_facture_fourn = f.rowid AND fd.fk_product = ck.fk_product AND ck.fk_categorie = ".((int) $searchCategoryProduct).")";
} else {
$listofcategoryid .= ($listofcategoryid ? ', ' : '') .((int) $searchCategoryProduct);
}
}
}
if ($listofcategoryid) {
$searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."facture_fourn_det as fd WHERE fd.fk_facture_fourn = f.rowid AND p.rowid = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
$searchCategoryProductSqlList[] = " EXISTS (SELECT ck.fk_product FROM ".MAIN_DB_PREFIX."categorie_product as ck, ".MAIN_DB_PREFIX."facture_fourn_det as fd WHERE fd.fk_facture_fourn = f.rowid AND fd.fk_product = ck.fk_product AND ck.fk_categorie IN (".$db->sanitize($listofcategoryid)."))";
}
if ($searchCategoryProductOperator == 1) {
if (!empty($searchCategoryProductSqlList)) {
Expand Down
2 changes: 1 addition & 1 deletion htdocs/product/agenda.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
$picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product');
print dol_get_fiche_head($head, 'agenda', $titre, -1, $picto);

$linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1&type='.$object->type.'">'.$langs->trans("BackToList").'</a>';
$object->next_prev_filter = "fk_product_type = ".((int) $object->type);

$shownav = 1;
Expand Down
2 changes: 1 addition & 1 deletion htdocs/product/composition/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@
* Product card
*/
if ($user->hasRight('produit', 'lire') || $user->hasRight('service', 'lire')) {
$linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1&type='.$object->type.'">'.$langs->trans("BackToList").'</a>';

$shownav = 1;
if ($user->socid && !in_array('product', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) {
Expand Down
2 changes: 1 addition & 1 deletion htdocs/product/document.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@
}


$linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1&type='.$object->type.'">'.$langs->trans("BackToList").'</a>';
$object->next_prev_filter = "fk_product_type = ".((int) $object->type);

$shownav = 1;
Expand Down
2 changes: 1 addition & 1 deletion htdocs/product/fournisseurs.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@

print dol_get_fiche_head($head, 'suppliers', $titre, -1, $picto);

$linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1&type='.$object->type.'">'.$langs->trans("BackToList").'</a>';
$object->next_prev_filter = "fk_product_type = ".((int) $object->type);

$shownav = 1;
Expand Down
4 changes: 2 additions & 2 deletions htdocs/product/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -861,11 +861,11 @@
$params['forcenohideoftext'] = 1;
}
$newcardbutton .= dolGetButtonTitleSeparator();
if ($type === "" || $type == Product::TYPE_PRODUCT) {
if ((isModEnabled('product') && $type === "") || $type == Product::TYPE_PRODUCT) {
$label = 'NewProduct';
$newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&type=0', '', $perm, $params);
}
if ($type === "" || $type == Product::TYPE_SERVICE) {
if ((isModEnabled('service') && $type === "") || $type == Product::TYPE_SERVICE) {
$label = 'NewService';
$newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/product/card.php?action=create&type=1', '', $perm, $params);
}
Expand Down
2 changes: 1 addition & 1 deletion htdocs/product/note.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@

print dol_get_fiche_head($head, 'note', $titre, -1, $picto);

$linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1&type='.$object->type.'">'.$langs->trans("BackToList").'</a>';
$object->next_prev_filter = "fk_product_type = ".((int) $object->type);

$shownav = 1;
Expand Down
2 changes: 1 addition & 1 deletion htdocs/product/price.php
Original file line number Diff line number Diff line change
Expand Up @@ -884,7 +884,7 @@

print dol_get_fiche_head($head, 'price', $titre, -1, $picto);

$linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1&type='.$object->type.'">'.$langs->trans("BackToList").'</a>';
$object->next_prev_filter = "fk_product_type = ".((int) $object->type);

$shownav = 1;
Expand Down
2 changes: 1 addition & 1 deletion htdocs/product/stats/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@

print dol_get_fiche_head($head, 'stats', $titre, -1, $picto);

$linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1&type='.$object->type.'">'.$langs->trans("BackToList").'</a>';

dol_banner_tab($object, 'ref', $linkback, ($user->socid ? 0 : 1), 'ref', '', '', '', 0, '', '', 1);

Expand Down
2 changes: 1 addition & 1 deletion htdocs/product/stats/facture.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
}

$linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1&type='.$object->type.'">'.$langs->trans("BackToList").'</a>';

$shownav = 1;
if ($user->socid && !in_array('product', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) {
Expand Down
2 changes: 1 addition & 1 deletion htdocs/product/stock/product.php
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@

dol_htmloutput_events();

$linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1&type='.$object->type.'">'.$langs->trans("BackToList").'</a>';

$shownav = 1;
if ($user->socid && !in_array('stock', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) {
Expand Down
2 changes: 1 addition & 1 deletion htdocs/product/traduction.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@

print dol_get_fiche_head($head, 'translation', $titre, 0, $picto);

$linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
$linkback = '<a href="'.DOL_URL_ROOT.'/product/list.php?restore_lastsearch_values=1&type='.$object->type.'">'.$langs->trans("BackToList").'</a>';

$shownav = 1;
if ($user->socid && !in_array('product', explode(',', getDolGlobalString('MAIN_MODULES_FOR_EXTERNAL')))) {
Expand Down

0 comments on commit a4bd2b5

Please sign in to comment.