SugarCRM 6.5如何打印php模板?

SugarCRM 6.5如何打印php模板?,sugarcrm,Sugarcrm,我是SugarCRM 6.5的新开发人员,我有write view.detail.php文件和controller文件。如何打印模板控制器动作json数据php模板。请帮帮我。我在下面创建了控制器和view.details代码 控制器 受保护的函数操作\u printinvoice(){ 全局$当前用户,$db$区域 $db=DBManagerFactory::getInstance(); $id=$_POST['record'] $sql="选择gn.client\u name、gn.clie

我是SugarCRM 6.5的新开发人员,我有write view.detail.php文件和controller文件。如何打印模板控制器动作json数据php模板。请帮帮我。我在下面创建了控制器和view.details代码

控制器

受保护的函数操作\u printinvoice(){

全局$当前用户,$db$区域

$db=DBManagerFactory::getInstance(); $id=$_POST['record']

$sql="选择gn.client\u name、gn.client\u address、gn.client\u address\u city、gn.client\u state、gn.client\u address\u country、gn.client\u postalcode、gn.id、gn.recipient\u name、gn.recipient\u address\u city、gn.recipient\u address\u state、gn.recipient\u address\u postalcode、gn.recipient\u address\u address、gnax\u编号、gn.recipient\u名称、gn.invoice\u编号作为ginvo\u客户\u发票\u id,“ “gcstm.*” “来自ginvo_客户_发票为gn” “在gn.id=gcstm.id\u c上作为gcstm的内部连接ginvo\u客户\u发票\u cstm” “哪里” “gn.deleted=0且gn.id='”$id.“'limit 1”

}

View.detail.php

<?php
require_once('include/MVC/View/views/view.detail.php');
// require_once('modules/ginvo_client_invoice/view/invoice.php');

class ginvo_client_invoiceViewDetail extends ViewDetail {

function ginvo_client_invoiceViewDetail(){
parent::ViewDetail();
}

function display(){

  echo $ginv_invoice_ary;
//$this->populateQuoteTemplates();
$this->displayPopupHtml();
parent::display();
}

function populateQuoteTemplates(){

  global $app_list_strings, $current_user;

  $inv_id = $this->bean->id;

  $sql = "SELECT * FROM ginvo_client_invoice WHERE deleted=0 AND id='$inv_id'";

  $res = $this->bean->db->query($sql);

  $app_list_strings[] = array();

  while($row = $this->bean->db->fetchByAssoc($res)){
    if($row){
      $app_list_strings[$row] = $row;

    }
  }
}

function displayPopupHtml(){

  global $app_list_strings,$app_strings, $mod_strings;

  $templates = array_keys($app_list_strings);

  if($templates){


    echo '  
     <script>
    function showPopup(task){
      var record = \''.$this->bean->id.'\';
      var fdata = {\'record\':record};
      var params = jQuery.param(fdata);
      $.ajax({
        type:\'post\',
        data: fdata,
      //  dataType: "json",
      //  url:\'custom/client_invoice.php?\'+params,
        //url:\'custom/modules/ginvo_client_invoice/ClientInvoice.php?\'+params,
        url:\'index.php?module=ginvo_client_invoice&action=printinvoice\',
        error:function(resp){},
        success:function(resp){
          console.log(resp);
        //  location.reload(true);
        }
      });
    // var w = window.open(\'custom/ClientInvoice.php\');
    //
    // $(w).ready(function(){
    //     w.print();
    // });

  }
   </script>';
   }
  else{
    echo '<script>
    function showPopup(task){

    alert(\''.$current_user.'\');
    }
    </script>';
    }
  }
}
?>

<?php
require_once('include/MVC/View/views/view.detail.php');
// require_once('modules/ginvo_client_invoice/view/invoice.php');

class ginvo_client_invoiceViewDetail extends ViewDetail {

function ginvo_client_invoiceViewDetail(){
parent::ViewDetail();
}

function display(){

  echo $ginv_invoice_ary;
//$this->populateQuoteTemplates();
$this->displayPopupHtml();
parent::display();
}

function populateQuoteTemplates(){

  global $app_list_strings, $current_user;

  $inv_id = $this->bean->id;

  $sql = "SELECT * FROM ginvo_client_invoice WHERE deleted=0 AND id='$inv_id'";

  $res = $this->bean->db->query($sql);

  $app_list_strings[] = array();

  while($row = $this->bean->db->fetchByAssoc($res)){
    if($row){
      $app_list_strings[$row] = $row;

    }
  }
}

function displayPopupHtml(){

  global $app_list_strings,$app_strings, $mod_strings;

  $templates = array_keys($app_list_strings);

  if($templates){


    echo '  
     <script>
    function showPopup(task){
      var record = \''.$this->bean->id.'\';
      var fdata = {\'record\':record};
      var params = jQuery.param(fdata);
      $.ajax({
        type:\'post\',
        data: fdata,
      //  dataType: "json",
      //  url:\'custom/client_invoice.php?\'+params,
        //url:\'custom/modules/ginvo_client_invoice/ClientInvoice.php?\'+params,
        url:\'index.php?module=ginvo_client_invoice&action=printinvoice\',
        error:function(resp){},
        success:function(resp){
          console.log(resp);
        //  location.reload(true);
        }
      });
    // var w = window.open(\'custom/ClientInvoice.php\');
    //
    // $(w).ready(function(){
    //     w.print();
    // });

  }
   </script>';
   }
  else{
    echo '<script>
    function showPopup(task){

    alert(\''.$current_user.'\');
    }
    </script>';
    }
  }
}
?>