浏览代码

rollerstorage menu fixes

szollosil 9 月之前
父节点
当前提交
961f95bcce
共有 1 个文件被更改,包括 34 次插入11 次删除
  1. 34 11
      custom/rollerstorage/core/modules/modRollerstorage.class.php

+ 34 - 11
custom/rollerstorage/core/modules/modRollerstorage.class.php

@@ -294,21 +294,21 @@ class modRollerstorage extends DolibarrModules
 			$this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used)
 			$this->rights[$r][1] = $warehouse['ref'] . ' (Olvasás)'; // Permission label
 			$this->rights[$r][4] = 'rollerhistory';
-			$this->rights[$r][5] = 'read_'.$warehouse['rowid']; // In php code, permission will be checked by test if ($user->rights->rollerstorage->rollerhistory->read_1)
+			$this->rights[$r][5] = 'read_' . $warehouse['rowid']; // In php code, permission will be checked by test if ($user->rights->rollerstorage->rollerhistory->read_1)
 			$r++;
 		}
 		foreach ($warehousesFromDB as $warehouse) {
 			$this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used)
 			$this->rights[$r][1] = $warehouse['ref'] . ' (írás)'; // Permission label
 			$this->rights[$r][4] = 'rollerhistory';
-			$this->rights[$r][5] = 'write_'.$warehouse['rowid']; // In php code, permission will be checked by test if ($user->rights->rollerstorage->rollerhistory->read_1)
+			$this->rights[$r][5] = 'write_' . $warehouse['rowid']; // In php code, permission will be checked by test if ($user->rights->rollerstorage->rollerhistory->read_1)
 			$r++;
 		}
 		foreach ($warehousesFromDB as $warehouse) {
 			$this->rights[$r][0] = $this->numero . sprintf("%02d", $r + 1); // Permission id (must not be already used)
 			$this->rights[$r][1] = $warehouse['ref'] . ' (törlés)'; // Permission label
 			$this->rights[$r][4] = 'rollerhistory';
-			$this->rights[$r][5] = 'delete_'.$warehouse['rowid']; // In php code, permission will be checked by test if ($user->rights->rollerstorage->rollerhistory->read_1)
+			$this->rights[$r][5] = 'delete_' . $warehouse['rowid']; // In php code, permission will be checked by test if ($user->rights->rollerstorage->rollerhistory->read_1)
 			$r++;
 		}
 		/* END MODULEBUILDER PERMISSIONS */
@@ -395,8 +395,8 @@ class modRollerstorage extends DolibarrModules
 			'target' => '',
 			'user' => 2, // 0=Menu for internal users, 1=external users, 2=both
 		);
-		
-		foreach ($warehousesFromDB as $warehouse) {
+
+		foreach ($this->getWarehouses("'1'") as $warehouse) {
 			$this->menu[$r++] = array(
 				'fk_menu' => 'fk_mainmenu=rollerstorage',
 				// '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
@@ -425,17 +425,38 @@ class modRollerstorage extends DolibarrModules
 			'titre' => 'Devices',
 			'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth valignmiddle"'),
 			'mainmenu' => '',
-			'leftmenu' => 'device_stock',
-			'url' => '/rollerstorage/rollerstorageinventoryindex.php?inventory_id=5',
+			'leftmenu' => 'roller_stock',
+			//'url' => '/rollerstorage/rollerstorageinventoryindex.php?inventory_id=' . $warehouse['rowid'],
 			'langs' => 'rollerstorage@rollerstorage',
 			// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
 			'position' => 1000 + $r,
 			'enabled' => 'isModEnabled("rollerstorage")',
 			// Define condition to show or hide menu entry. Use 'isModEnabled("rollerstorage")' if entry must be visible if module is enabled.
-			'perms' => '$user->hasRight("rollerstorage", "rollerhistory", "read_5")',
+			'perms' => '$user->hasRight("rollerstorage", "rollerhistory", "read_roller_stock")',
 			'target' => '',
 			'user' => 2, // 0=Menu for internal users, 1=external users, 2=both
 		);
+		foreach ($this->getWarehouses("'2'") as $warehouse) {
+			$this->menu[$r++] = array(
+				'fk_menu' => 'fk_mainmenu=rollerstorage',
+				// '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
+				'type' => 'left',
+				// This is a Left menu entry
+				'titre' => $warehouse['ref'],
+				'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth valignmiddle"'),
+				'mainmenu' => '',
+				'leftmenu' => 'device_stock_inventories_' . $warehouse['rowid'],
+				'url' => '/rollerstorage/rollerstorageinventoryindex.php?inventory_id=' . $warehouse['rowid'],
+				'langs' => 'rollerstorage@rollerstorage',
+				// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
+				'position' => 1000 + $r,
+				'enabled' => 'isModEnabled("rollerstorage")',
+				// Define condition to show or hide menu entry. Use 'isModEnabled("rollerstorage")' if entry must be visible if module is enabled.
+				'perms' => '$user->hasRight("rollerstorage", "rollerhistory", "read_' . $warehouse['rowid'] . '")',
+				'target' => '',
+				'user' => 2, // 0=Menu for internal users, 1=external users, 2=both
+			);
+		}
 		/* foreach ($this->getWarehouses("'2'") as $warehouse) {
 			$this->menu[$r++] = array(
 				'fk_menu' => 'fk_mainmenu=rollerstorage',
@@ -654,7 +675,8 @@ class modRollerstorage extends DolibarrModules
 		return $warehousesArray;
 	}
 
-	public function updateStatus($db, $object, $id, $objForHistory){
+	public function updateStatus($db, $object, $id, $objForHistory)
+	{
 		$sql = "UPDATE " . $db->prefix() . $object->table_element . " SET status = '{$objForHistory->status}' WHERE rowid = {$id}";
 		$result = $db->query($sql);
 		$rollerHistory = new RollerHistory($db);
@@ -662,7 +684,8 @@ class modRollerstorage extends DolibarrModules
 		return $result;
 	}
 
-	public function updateStatusAndWarehouse($db, $object, $id, $objForHistory){
+	public function updateStatusAndWarehouse($db, $object, $id, $objForHistory)
+	{
 		$sql = "UPDATE " . $db->prefix() . $object->table_element . " SET status = '{$objForHistory->status}', fk_warehouse = {$objForHistory->fk_warehouse}  WHERE rowid = {$id}";
 		$result = $db->query($sql);
 		$rollerHistory = new RollerHistory($db);
@@ -755,4 +778,4 @@ class modRollerstorage extends DolibarrModules
 		$sql = array();
 		return $this->_remove($sql, $options);
 	}
-}
+}