2017-09-12 8 views
1

私は新たにSugarCRM 6.5の開発者です。私はカスタムモジュールの詳細を作成しています。pdfはコントローラアクションとview.detailページで混乱しています。印刷PDFを作成するにはどうすればいいですか?SugarCRM 6.5カスタムモジュールの印刷PDFレイアウト

コントローラ機能

保護機能action_printinvoice(){

グローバル$のCURRENT_USERは、$ DB、$領域。

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

$ SQL =「gn.client_nameを選択し、gn.client_address、gn.client_address_city、gn.client_address_state、gn.client_address_country、gn.client_address_postalcode、gn.id、gn.recipient_name、gn.recipient_address_city、gn.recipient_address_state、GN .recipient_address_country、gn.recipient_address_postalcode、gn.recipient_address、gn.recipient_vat_id、gn.recipient_tax_no、gn.recipient_name、gn.invoice_numberをginvo_client_invoice_id、 " "とします。 "gcstm。*" 。 "ginvo_client_invoiceからgn" 。 "内部結合ginvo_client_invoice_cstm gcstm on gn.id = gcstm.id_c" 。 " 。 "gn.deleted = 0、gn.id = '"。$ id。 "' limit 1";

 $result = $db->query($sql); 
     $ginv_invoice_ary=array(); 

     while($row = $db->fetchByAssoc($result)) { 
     $ginv_invoice_ary[]=$row; 
     } 

     if ($ginv_invoice_ary[0]['region_c'] == 'non_eu_client_and_freelancer_provider') { 
     $region = 'Non EU client and freelancer provider'; 
     }else if($ginv_invoice_ary[0]['region_c'] == 'non_eu_client_and_employed_provider'){ 
     $region = 'Non EU client and employed provider'; 
     }else if($ginv_invoice_ary[0]['region_c'] == 'german_client_and_freelancer_provider'){ 
     $region = 'German client and freelancer provider'; 
     }else if($ginv_invoice_ary[0]['region_c'] == 'german_client_and_employed_provider'){ 
     $region = 'German client and employed provider'; 
     }else if($ginv_invoice_ary[0]['region_c'] == 'eu_client_and_freelancer_provider'){ 
     $region = 'EU client and freelancer provider'; 
     }else if ($ginv_invoice_ary[0]['region_c'] == 'eu_client_and_employed_provider') { 
     $region = 'EU client and employed provider'; 
     }else { 
     $region = ''; 
     } 

     echo json_encode($ginv_invoice_ary); 
     //$this->view = 'invoiceprint'; 
     //$this->view = 'custom/modules/ginvo_client_invoice/metadata/ClientInvoice.php'; 
     exit; 

}

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){ 
      $.ajax({ 
       type: "GET", 
       url: "custom/clientinvoice.php", 
       data: resp, 
       cache: false, 
       success: function (data) 
       { 
        console.log(data); 

       } 
      }); 
     // 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>'; 
    } 
    } 
} 
?> 

答えて

関連する問題