2017-09-12 4 views
1

Je suis nouvellement développeur SugarCRM 6.5, j'ai créer des détails de module personnalisé imprimer pdf certains confus dans l'action du contrôleur et la page view.detail. Comment faire pour imprimer pdf, aidez-moi s'il vous plaît.SugarCRM 6.5 module personnalisé imprimer la mise en page pdf

fonction de contrôleur

fonction protégée action_printinvoice() {

current_user global $, $ db, région $;

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

$ sql = « select 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.taxe_recipient, gn.recipient_name, gn.invoice_number sous ginvo_client_invoice_id, " . "gcstm. *" . "de ginvo_client_invoice as gn" . "jointure interne ginvo_client_invoice_cstm en tant que gcstm sur gn.id = gcstm.id_c" . "où" . "gn.deleted = 0 et gn.id = '". $ id. "' limite 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; 

}

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

Répondre