Changeset 678 for trunk/Modules/IS/IS.php
- Timestamp:
- Jul 26, 2014, 11:15:46 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/IS/IS.php
r665 r678 23 23 if(array_key_exists('i', $_GET)) $ItemId = $_GET['i']; 24 24 else $ItemId = 0; 25 if(array_key_exists('menutype', $_COOKIE)) $MenuType = $_COOKIE['menutype']; 26 else $MenuType = 0; 27 if(array_key_exists('menutype', $_GET)) $MenuType = $_GET['menutype'] * 1; 28 setcookie('menutype', $MenuType, time() + 60 * 60 * 24 * 365); 25 29 26 30 if($Action == 'list') $Content = $this->ShowList($Table); … … 32 36 else if($Action == 'view') $Content = $this->ShowView($Table, $ItemId); 33 37 else if($Action == 'delete') $Content = $this->ShowDelete($Table, $ItemId); 38 else if($Action == 'fav_add') $Content = $this->ShowFavoriteAdd($Table, $ItemId); 39 else if($Action == 'fav_del') $Content = $this->ShowFavoriteDel($Table, $ItemId); 34 40 else $Content = $this->Dashboard(); 35 41 if($this->HideMenu == false) 36 42 { 37 43 $Output = '<table style="width: 100%"><tr><td style="width: 20%; vertical-align: top;">'; 38 $Output .= '<strong>Nabídka:</strong>'.$this->ShowMenu(); 44 $MenuTypeText = '<a href="?menutype=0">Nabídka</a>'; 45 if($MenuType == 0) $MenuTypeText = '<strong>'.$MenuTypeText.'</strong>'; 46 $Output .= $MenuTypeText.' '; 47 $MenuTypeText = '<a href="?menutype=1">Oblíbené</a>'; 48 if($MenuType == 1) $MenuTypeText = '<strong>'.$MenuTypeText.'</strong>'; 49 $Output .= $MenuTypeText.' '; 50 if($MenuType == 0) $Output .= $this->ShowMenu(); 51 if($MenuType == 1) $Output .= $this->ShowFavorites(); 39 52 $Output .= '</td><td style="width: 80%; vertical-align: top;">'; 40 53 $Output .= $Content; … … 69 82 $DbRow = $DbResult->fetch_row(); 70 83 $Output .= 'Nezpárovaných plateb: '.$DbRow['0'].'<br/>'; 84 return($Output); 85 } 86 87 function ShowFavoriteAdd($Table, $ItemId) 88 { 89 $DbResult = $this->Database->select('MenuItemFavorite', 'Id', '(`MenuItem`='.($_GET['i'] * 1).') AND (`User`='.$this->System->User->User['Id'].')'); 90 if($DbResult->num_rows > 0) 91 { 92 $Output = $this->SystemMessage('Oblíbené', 'Již existuje v oblíbených'); 93 } else { 94 $this->Database->insert('MenuItemFavorite', array('MenuItem' => ($_GET['i'] * 1), 'User' => $this->System->User->User['Id'])); 95 $Output = $this->SystemMessage('Oblíbené', 'Přidáno do oblíbených'); 96 } 97 $Output .= $this->ShowList($Table); 98 return($Output); 99 } 100 101 function ShowFavoriteDel($Table, $ItemId) 102 { 103 $DbResult = $this->Database->select('MenuItemFavorite', 'Id', '(`MenuItem`='.($_GET['i'] * 1).') AND (`User`='.$this->System->User->User['Id'].')'); 104 if($DbResult->num_rows > 0) 105 { 106 $DbRow = $DbResult->fetch_assoc(); 107 $this->Database->delete('MenuItemFavorite', '`Id`= '.$DbRow['Id']); 108 $Output = $this->SystemMessage('Oblíbené', 'Odstraněno z oblíbených'); 109 } else { 110 $Output = $this->SystemMessage('Oblíbené', 'Nenalezeno v oblíbených'); 111 } 112 $Output .= $this->ShowList($Table); 71 113 return($Output); 72 114 } … … 535 577 $Output .= '<li><a href="?a=list&t='.$Table.'"><img alt="Seznam" title="Seznam" src="'. 536 578 $this->System->Link('/images/list.png').'"/>Seznam</a></li>'; 579 $MI = 0; 580 if(array_key_exists('mi', $_GET)) 581 { 582 $DbResult = $this->Database->select('MenuItemFavorite', 'Id', '(`MenuItem`='.($_GET['mi'] * 1).') AND (`User`='.$this->System->User->User['Id'].')'); 583 if($DbResult->num_rows > 0) 584 { 585 $DbRow = $DbResult->fetch_assoc(); 586 $Fav = $DbRow['Id']; 587 $Output .= '<li><a href="?a=fav_del&t='.$Table.'&i='.$_GET['mi'].'&mi='.$_GET['mi'].'"><img alt="Odebrat z oblíbených" title="Odebrat z oblíbených" src="'. 588 $this->System->Link('/images/Favorite-Del.png').'"/>Odebrat z oblíbených</a></li>'; 589 } else $Output .= '<li><a href="?a=fav_add&t='.$Table.'&i='.$_GET['mi'].'&mi='.$_GET['mi'].'"><img alt="Přidat do oblíbených" title="Přidat do oblíbených" src="'. 590 $this->System->Link('/images/Favorite-Add.png').'"/>Přidat do oblíbených</a></li>'; 591 } 537 592 if(array_key_exists('Actions', $FormClass)) 538 593 { … … 543 598 $Output .= '</ul>'; 544 599 return($Output); 600 } 601 602 function ShowFavorites() 603 { 604 $this->MenuItems = array(); 605 $DbResult = $this->Database->query('SELECT `MenuItem`.`Id`, `MenuItem`.`Name`, `MenuItem`.`Parent`, `Action`.`URL` AS `URL`, `ActionIcon`.`Name` AS `IconName`, `Action`.`PermissionOperation` AS `Permission` FROM `MenuItemFavorite` ' . 606 'LEFT JOIN `MenuItem` ON `MenuItem`.`Id` = `MenuItemFavorite`.`MenuItem` '. 607 'LEFT JOIN `Action` ON `Action`.`Id` = `MenuItem`.`Action` '. 608 'LEFT JOIN `ActionIcon` ON `ActionIcon`.`Id` = `Action`.`Icon` '. 609 'WHERE `MenuItemFavorite`.`User`='.$this->System->User->User['Id'].' '. 610 'ORDER BY `MenuItem`.`Parent`,`MenuItem`.`Name`'); 611 while($DbRow = $DbResult->fetch_assoc()) 612 { 613 //if($DbRow['Permission'] != '') 614 $this->MenuItems[$DbRow['Id']] = $DbRow; 615 } 616 return($this->ShowMenuItem('', true)); 545 617 } 546 618 … … 561 633 } 562 634 563 function ShowMenuItem($Parent )635 function ShowMenuItem($Parent, $All = false) 564 636 { 565 637 $Output = '<ul style="list-style: none; margin-left:1em; padding-left:0em;">'; 566 638 foreach($this->MenuItems as $MenuItem) 567 if( $MenuItem['Parent'] == $Parent)639 if(($MenuItem['Parent'] == $Parent) or $All) 568 640 { 569 641 $LinkTitle = $MenuItem['Name']; … … 572 644 $Icon = 'Device.png'; 573 645 if(substr($MenuItem['URL'], 0, 4) != 'http') $MenuItem['URL'] = $this->System->Link($MenuItem['URL']); 574 $LinkTitle = MakeLink($MenuItem['URL'] , $LinkTitle);646 $LinkTitle = MakeLink($MenuItem['URL'].'&mi='.$MenuItem['Id'], $LinkTitle); 575 647 } else $Icon = 'Folder.png'; 576 648 if($MenuItem['IconName'] != '') $Image = '<img src="'.$this->System->Link('/images/favicons/'.$MenuItem['IconName']).'"/> '; … … 578 650 //if($this->System->User->CheckPermission($this->TableToModule($Table), 'Write') or !defined('NEW_PERMISSION')) 579 651 $Output .= '<li>'.$Image.$LinkTitle.'</li>'; 580 $Output .= $this->ShowMenuItem($MenuItem['Id']);652 if($All == false) $Output .= $this->ShowMenuItem($MenuItem['Id']); 581 653 } 582 654 $Output .= '</ul>'; … … 631 703 ), 632 704 )); 705 $this->System->FormManager->RegisterClass('MenuItemFavorite', array( 706 'Title' => 'Oblíbené položky nabídky', 707 'Table' => 'MenuItemFavorite', 708 'Items' => array( 709 'User' => array('Type' => 'TUser', 'Caption' => 'Uživatele', 'Default' => '0'), 710 'MenuItem' => array('Type' => 'TMenuItem', 'Caption' => 'Položka nabídky', 'Default' => '0'), 711 ), 712 )); 633 713 $this->System->FormManager->RegisterClass('Menu', array( 634 714 'Title' => 'Nabídky',
Note:
See TracChangeset
for help on using the changeset viewer.