doulu1325 2016-06-16 02:59
浏览 27

PHP:从复选框中的选定值中获取数据以创建PDF

It is my first time to debug other programmers work so I am kinda lost in its codes, anyway this is just the last simple thing I need to accomplish in this system. I already created the search page and all I need now is to create a function how to print the selected values in the checkbox.

I already created a function for creating pdf.

Controller

public function create_pdf_certificate($acctNo,$certReason,$dlCertType)
{
    $this->load->model('model_access','access');
    //$this->access->check_login();
    //$this->access->check_print_access();

    $this->load->model('model_account','account');
    $this->load->model('model_admin','admin');
    $this->load->model('model_constants','constants');
    $this->load->helper('to_pdf');
    $this->load->helper('file');

    $acctNo = str_replace("%7C","|",$acctNo);

    $data['accounts']   = $this->account->get_account($acctNo);
    $data['cert']       = $this->admin->get_treasury_dept_info();
    $data['clientName'] = $data['accounts'][0]->clientName;
    $data['certReason'] = $certReason;

    if($dlCertType == 'INDICORP')
        $html       = $this->load->view('pdf_download/indicorp', $data, true);
                    //$this->load->view('pdf_download/indicorp', $data);
    elseif($dlCertType == 'AUDIT')
    {
        $data['audit']  = $this->admin->get_audit_partner_info();
        $html           = $this->load->view('pdf_download/audit', $data, true);
                        //$this->load->view('pdf_download/audit', $data);
    }
    else
        $html       = $this->load->view('pdf_download/summary', $data, true);
                    //$this->load->view('pdf_download/summary', $data);

    $filename   = 'account'.date('mdY');

    create_pdf($html,$filename.time(), true);
}

and here is my MODEL

        if(count($res) > 0)
    {
        $i = 1;
        foreach($res as $row)
        {

                        $output['aaData'][] = array(
                                "<input type='checkbox' name='checkbox".$i."' id='checkbox".$i."' value='".$row->clientId."' />",
                                $row->clientName,
                                $row->product,
                                $row->accountNo,
                                $row->valueDate,
                                $row->maturityDate,
                                $row->ccy,
                                $row->principal,
                                $row->interestRate,
                                $row->maturityAmt
                                );
         $i++;
        }
    }
    //print_r($output);
    //return $output;
    return json_encode( $output );

Here is my view codes, I have this fieldset that also select the certificate type that I want to use a template.

    <fieldset style="width:990px;" >
    <div>
        <table id="searchTable" class="tableHeader" border="1" cellspacing="0" width="100%">
            <thead>
                <tr>
                    <th>SELECT</th>
                    <th>CLIENT</th>
                    <th>PROD TYPE</th>
                    <th>REF ACCNT NO.</th>
                    <th>VALUE DATE</th>
                    <th>MATURITY DATE</th>
                    <th>CCY</th>
                    <th>PRINCIPAL</th>
                    <th>RATE (%)</th>
                    <th>MATURITY AMNT</th>
                </tr>
            </thead>

            <tbody style="color: black" class="tableRow">
            </tbody>
        </table>

        <script>
            $(document).ready(function() {


                $('#searchTable').dataTable( {
                            "sPaginationType": "full_numbers",
                            "bAutoWidth": false,
                            "bProcessing": true,
                            "bServerSide": true,
                            "sAjaxSource": "<?php echo site_url() ?>/search/get_account",
                            "sServerMethod": "GET",
                            "fnServerData": function ( sSource, aoData, fnCallback ) 

                    {
                        aoData.push( { "name": "txtClient",     "value": "<?php echo $_POST["txtClient"]; ?>" } );
                        aoData.push( { "name": "txtAccntNo",    "value": "<?php echo $_POST["txtAccntNo"]; ?>" } );
                        aoData.push( { "name": "txtGrpAcctName","value": "<?php echo $_POST["txtGrpAcctName"]; ?>" } );
                        aoData.push( { "name": "txtDate",       "value": "<?php echo $_POST["txtDate"]; ?>" } );



                        $.getJSON( sSource, aoData, function (json) 
                        {
                            fnCallback(json)
                        } );
                    },
                    "aoColumns": [ 
                                  { "sClass": "centerAligned"   , "bSortable" : false }, //SELECT
                                  { "sClass": "centerAligned"   , "bSortable" : false }, //CLIENT
                                  { "sClass": "centerAligned"   , "bSortable" : false }, //PROD TYPE
                                  { "sClass": "centerAligned"   , "bSortable" : false }, //REF ACCNT NO.
                                  { "sClass": "centerAligned"   , "bSortable" : false }, //VALUE DATE
                                  { "sClass": "centerAligned"   , "bSortable" : false }, //MATURITY DATE
                                  { "sClass": "centerAligned"   , "bSortable" : false }, //CCY
                                  { "sClass": "leftAligned"     , "bSortable" : false }, //PRINCIPAL
                                  { "sClass": "leftAligned"     , "bSortable" : false }, //RATE (%)
                                  { "sClass": "leftAligned"     , "bSortable" : false }, //MATURITY AMNT
                                  ]
                } );
            } );
        </script>                       
    </div>
    <hr/>
    <table class="formTable" cellspacing="0" align="center">
        <tr>
            <td class="label" width="200px">Reason: <span class="required">*</span></td>
            <td class="field" width="300px"><?php echo form_textarea($formCertReason); ?></td>
            <td class="field">
                <hr style="visibility: hidden"/>
                <div class="btnHolder">
                  <a id="colDownloadBtn" href="#" onclick="Account.checkRequiredFields();"> <?php echo $_POST['certType']; ?>
                    <img src="<?php echo base_url(); ?>public/images/form/btn_download_cert.gif" style="cursor: pointer;" />
                  </a>
                </div>
            </td>
        </tr>
    </table> 
</fieldset>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题