SugarCRM 6.5 How to print php template? -


i newly sugarcrm 6.5 developer, have write view.detail.php file , controller file. how print template controller action json data php template. please me. have create controller , view.details code below.

controller

protected function action_printinvoice(){

global $current_user, $db, $region;

$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.recipient_tax_no, gn.recipient_name, gn.invoice_number ginvo_client_invoice_id, " . " gcstm.* " . "from ginvo_client_invoice gn " . " inner join ginvo_client_invoice_cstm gcstm on gn.id=gcstm.id_c " . "where " . " 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 , freelancer provider';       }else if($ginv_invoice_ary[0]['region_c'] == 'non_eu_client_and_employed_provider'){         $region = 'non eu client , employed provider';       }else if($ginv_invoice_ary[0]['region_c'] == 'german_client_and_freelancer_provider'){         $region = 'german client , freelancer provider';       }else if($ginv_invoice_ary[0]['region_c'] == 'german_client_and_employed_provider'){         $region = 'german client , employed provider';       }else if($ginv_invoice_ary[0]['region_c'] == 'eu_client_and_freelancer_provider'){         $region = 'eu client , freelancer provider';       }else if ($ginv_invoice_ary[0]['region_c'] == 'eu_client_and_employed_provider') {         $region = 'eu client , 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 * ginvo_client_invoice deleted=0 , 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>';     }   } } ?> 


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -