Created
          March 15, 2012 16:39 
        
      - 
      
- 
        Save demental/2045187 to your computer and use it in GitHub Desktop. 
    hooks on linksFormTables
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| // office/lib/hooks/Client.php | |
| class Client_hook | |
| { | |
| public static function alterLinkFromTables($links,$do) | |
| { | |
| require_once 'lib/CustomUtils.php'; | |
| CustomUtils::addTicketsClosedToLinks(&$links,$do); | |
| } | |
| } | |
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| // office/lib/CustomUtils.php | |
| class CustomUtils { | |
| public function addTicketsClosedToLinks(&$links,$do) | |
| { | |
| $canViewTickets = M_Office_Util::getGLobalOption('view','showtable','ticket_closed'); | |
| if(!$canViewTickets) return; | |
| $res = array(); | |
| foreach($links as $k =>$v) { | |
| if($v['table']=='ticket') { | |
| $t = M_Office_Util::doForModule('ticket'); | |
| $t->client_id = $do->id; | |
| $count = $t->count(); | |
| $open = array( | |
| 'table'=>'ticket', | |
| 'linkField'=>'client_id', | |
| 'field'=>'id', | |
| 'link'=>M_Office::URL(array('module'=>'ticket','filterField'=>'client_id','filterValue'=>$do->id),array('record')), | |
| 'nb'=>$count, | |
| 'tablename'=>'Tickets ouverts', | |
| 'add'=>false | |
| ); | |
| $res[]=$open; | |
| $t = M_Office_Util::doForModule('ticket_closed'); | |
| $t->client_id = $do->id; | |
| $count = $t->count(); | |
| $closed = array( | |
| 'table'=>'ticket', | |
| 'linkField'=>'client_id', | |
| 'field'=>'id', | |
| 'link'=>M_Office::URL(array('module'=>'ticket_closed','filterField'=>'client_id','filterValue'=>$do->id),array('record')), | |
| 'nb'=>$count, | |
| 'tablename'=>'Tickets clôturés', | |
| 'add'=>false | |
| ); | |
| $res[]=$closed; | |
| } else { | |
| $res[]=$v; | |
| } | |
| } | |
| $links = $res; | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment