2017-02-14 31 views
2

我試圖從「機會」報表中檢索數據。報表生成過程中的Sugarcrm從相關字段檢索數據

這是我的場景:機會模塊,字段sales_person是來自users模塊的相關字段。

Bids模塊我有一個relate字段與機會。

報告生成過程中,我試圖檢索機會中的sales_person名稱。但它不在Bids報告field_lists中列出。

我的字典Bids

'opportunity_id_c' => array(
      'required' => false, 
      'name' => 'opportunity_id_c', 
      'vname' => 'LBL_OPPORTUNITY_OPPORTUNITY_ID', 
      'type' => 'id', 
      'reportable' => true, 
      'calculated' => false, 
      'len' => 36, 
      'size' => '20', 
     ), 
     'opportunity' => array(
      'required' => false, 
      'source' => 'non-db', 
      'name' => 'opportunity', 
      'vname' => 'LBL_OPPORTUNITY', 
      'type' => 'relate', 
      'reportable' => true, 
      'unified_search' => false, 
      'merge_filter' => 'disabled', 
      'len' => '255', 
      'size' => '20', 
      'id_name' => 'opportunity_id_c', 
      'ext2' => 'Opportunities', 
      'module' => 'Opportunities', 
      'rname' => 'name', 
      'quicksearch' => 'enabled', 
      'studio' => 'visible', 
     ), 

關係:

$dictionary['Opportunity']['fields']['opportunities_procurements'] = [ 
    'name' => 'opportunities_procurements', 
    'type' => 'link', 
    'relationship' => 'opportunities_procurements', 
    'module' => 'Procurement', 
    'bean_name' => 'Procurement', 
    'source' => 'non-db', 
    'vname' => '', 
]; 

$dictionary['Opportunity']['relationships']['opportunities_procurements'] = [ 
    'lhs_module' => 'Opportunities', 
    'lhs_table' => 'opportunities', 
    'lhs_key' => 'id', 
    'rhs_module' => 'Procurement', 
    'rhs_table' => 'procurement', 
    'rhs_key' => 'opportunity_id_c', 
    'relationship_type' => 'one-to-many', 
]; 

這是我的嘗試:我試圖創建在投標模塊類似場opportunity命名爲opportunity_sales_user和字典,而不是'rname' => 'name',我使用'rname' => 'sales_person',但我沒有得到數據,因爲sales_person是相關記錄。我在Reports中找不到價值。

如何創建完整的關係,以便我可以在Bids報告生成中獲得sales_person值?

回答

0

我面臨同樣的問題,所以,我選擇寫一個簡單的SQL查詢

global $db; 
     $query = "Your Sql to get Reports"; 
     $re = $db->query($query); 
     $data = ''; 
     while ($row = $db->fetchByAssoc($re)) { 
      your code 
     } 
+0

沒有ü哪裏寫的嗎? – TomPHP

+0

如果你在Dashlet中做了那麼你必須創建自定義的Dashlets –