Results 1 to 2 of 2

Thread: Logic hook - process record.

  1. #1
    kinshibuya's Avatar
    kinshibuya is offline A Sugar Hero
    Join Date
    Jul 2008
    Location
    brasil
    Posts
    521

    Default Logic hook - process record.

    Hi. i want to show 4 fields in listview but they come from querys. i made it with logic hook but is not working! can anyone point me the rigth direction?

    /modules/custom/Cases/logic_hooks.php
    Code:
    <?php
    // Do not store anything in this file that is not part of the array or the hook version.  This file will	
    // be automatically rebuilt in the future. 
     $hook_version = 2; 
    $hook_array = Array(); 
    // position, file, function 
    //$hook_array['process_record'] = Array(); 
    $hook_array['process_record'][] = Array(3,'dtvenc', 'modules/Cases/CaseLogicHook.php','CaseLogicHook', 'dtvenc'); 
    
    
    
    ?>
    /modules/Cases/CaseLogicHook.php
    Code:
    <?php
    
     if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point'); 
    
    class CaseLogicHook { 
        function dtvenc(&$focus, $event, $arguments) { 
     // $focus->sla_c = $focus->sup_contratosuporte_cases_sla_critico_resolucao_hw + $focus->sup_contratosuporte_cases_sla_critico_atendimento_hw; 
    /*function action_ListView()
    {*/
    //$focus->view = 'list'; 
    //$GLOBALS['view'] = $focus->view; 
    
    global $db; 
    $query = "select (CASE WHEN c.priority='P0' THEN s.slacrireshw ELSE (CASE WHEN c.priority='P1' THEN s.slaaltreshw ELSE (CASE WHEN c.priority='P2' THEN s.slamedreshw ELSE s.slabaireshw END) END) END) as slareshw, " .
             "(CASE WHEN c.priority='P0' THEN s.slacriressw ELSE (CASE WHEN c.priority='P1' THEN s.slaaltressw ELSE (CASE WHEN c.priority='P2' THEN s.slamedressw ELSE s.slabairessw END) END) END) as slaressw, s.description, " .
    		 "ADDTIME(SUBTIME(c.date_entered,'03:00:00'), (CASE WHEN c.type='Software' THEN (CASE WHEN c.priority='P0' THEN s.slacriressw ELSE (CASE WHEN c.priority='P1' THEN s.slaaltressw ELSE (CASE WHEN c.priority='P2' THEN s.slamedressw ELSE s.slabairessw END) END) END) ELSE (CASE WHEN c.priority='P0' THEN s.slacrireshw ELSE (CASE WHEN c.priority='P1' THEN s.slaaltreshw ELSE (CASE WHEN c.priority='P2' THEN s.slamedreshw ELSE s.slabaireshw END) END) END) END)) as vencimento " .
    		 "from sup_contratosuporte s, sup_contratuporte_cases_c cstm, cases c where s.id=cstm.sup_contra8d4esuporte_ida and c.id=cstm.sup_contra20a5escases_idb and c.deleted=0 and cstm.deleted=0 and s.deleted=0 "; //and c.id= '" . $this->bean->id . "'";
    $result = $db->query($query, true);
    while($row = $db->fetchByAssoc($result))
    {
    $focus->bean->sup_contratosuporte_cases_sla_critico_resolucao_hw = $row['slareshw'];
    $focus->bean->sup_contratosuporte_cases_sla_critico_atendimento_hw = $row['slaressw'];
    $focus->bean->sup_contratosuporte_cases_descricao = $row['description'];
    $focus->bean->data_vencimento = $row['vencimento'] ;
    }
    
    
    }
    
    }
    //}
    
    ?>
    Priscila Kin Yamamoto Joranhezon
    Phone: +55 61 32010000
    priscila.joranhezon@nct.com.br
    NCT Informática Ltda

  2. #2
    kuske's Avatar
    kuske is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Germany
    Posts
    2,597

    Default Re: Logic hook - process record.

    Shouldn't you use $focus-> instead of $focus->bean-> ???

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. What logic hook should I use before create new record
    By AlexCh in forum Developer Help
    Replies: 4
    Last Post: 2010-08-10, 09:12 PM
  2. How make logic hook for create new record
    By meeric in forum Developer Help
    Replies: 6
    Last Post: 2009-01-02, 07:49 AM
  3. How to delete a record in a logic hook
    By twguk1516 in forum Developer Help
    Replies: 2
    Last Post: 2008-08-08, 08:56 AM
  4. Replies: 3
    Last Post: 2008-07-20, 06:09 PM
  5. Replies: 1
    Last Post: 2008-07-11, 05:56 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •