doutao6380 2015-10-12 05:32
浏览 47

PHP:ajax表单提交然后只有打印的结果

I am trying to ajax submit PHP form, it's working fine. Now whatever the result coming from PHP is getting stored in div. I want that result to print.

Here is code,

        <label>Customer. :</label>
                      <select type="text" class="form-control required" id="customer"  name="customer" onChange="get_part(this)">               

                      <option value="">Select Customer </option>
                    <?php 
                    foreach($customer_data as $ss){
                         ?>
                         <option value="<?php echo $ss['customer_id'] ;?>"
                    <?php if($edit_data!=NULL && $edit_data['customer']== $ss['customer_id']){echo "selected=selected";}?>><?php echo $ss['name'] ;?>
                       </option>
                    <?php   
                        }
                    ?>

                    </select>
                    </div>

                   <div class="col-lg-10 col-xs-4 form-group">
                      <label>Part no. :</label>
                      <select type="text" class="form-control required" id="part"  name="part" onChange="get_lotno(this)">               

                      <option value="">Select Part no</option>
                    <?php 
                    foreach($parts_data as $pp){
                         ?>
                         <option value="<?php echo $pp['part_id'] ;?>"
                    <?php if($edit_data!=NULL && $edit_data['part']== $pp['part_id']){echo "selected=selected";}?>><?php echo $pp['part_no'] ;?>
                       </option>
                    <?php   
                        }
                    ?>

                    </select>
                    </div>
                  <div class="col-lg-10 col-xs-4 form-group">
                 <label>Lot No. :</label>
                <select type="text" class="form-control required" id="order_id"  name="order_id" onChange="get_lotdetails(this)">               

                      <option value="">Select Lot No</option>

                    </select>
                  </div>

                  <div class="col-lg-5 col-xs-4 form-group">
                 <label>Lot Quantity :</label>
                 <input type="text" name="lotqnty" id="lotqnty" class="form-control" readonly>
                  </div>
                  <div class="col-lg-5 col-xs-4 form-group">
                 <label>Lot Rem. Qty :</label>
                  <input type="text" name="lotremqnty" id="lotremqnty" class="form-control" readonly>
                  </div>
                  </div>
               </div><!-- /.box-body -->
                    <div class="box-footer">
                    <button type="submit" id="submit" class="btn btn-primary">Start Test</button>
                    </div>

              </div><!-- /.box -->
 </form>

          <div class="row">

            <div class="col-xs-12">

              <div class="box">

               <div class="box-header"></div><!-- /.box-header -->
                <div class="box-body"  id="table_div">



                </div><!-- /.box-body -->
              </div><!-- /.box -->
            </div><!-- /.col -->
          </div><!-- /.row -->
        </section><!-- /.content -->
      </div><!-- /.content-wrapper -->
       <?php $this->load->view('admin/pages/footer.php') ?>
    </div><!-- ./wrapper -->


     <script type="text/javascript">
      $(function () {

       $("#form").validate({
      rules: {
          customer: {required: true},
          part: {required: true}
      },
      submitHandler: function(form) {
            $.ajax({
            type: "POST",
            url:'<?php echo base_url()?>admin/test/createSave',
            data:'&customer_id='+$("#customer").val()+'&order_id='+$("#order_id").val()+'&part_id='+$("#part").val(),
            cache: false,
            async:false,
            beforeSend : function ()
            {
                $("#submit").addClass("disabled");
                $("#table_div").html('<div align="center"><img src="<?=base_url()?>admindata/dist/img/table_loader.GIF"></div>');
            },
            success: function (data) {

            $("#ajax_loader").hide();

                $("#table_div").html(data);

                $("#lotremqnty").val($("#rem_lot_qty").val());
                $("#submit").removeClass("disabled");


        }); 
      });

On success tabular format content comes for label printing.

Anybody can help me with label printing through PHP.

Label Printer:Toshiba B-EV4T

thanks in advance

  • 写回答

1条回答 默认 最新

  • douduan7295 2016-04-01 12:48
    关注

    Use php_printer() for label printing, you have to do trial n error to align properly

    e.g

       $your_printer_name = "TEC B-EV4 (203 dpi)";
            printer_start_doc($handle, "My Document");
        printer_start_page($handle);
        printer_set_option($handle, PRINTER_RESOLUTION_X, "text");
        //  printer_set_option($handle, PRINTER_MODE, "text");
        //  printer_set_option($handle, PRINTER_TEXT_ALIGN, PRINTER_TA_CENTER);
        //  printe_write($handle, "UNI-TECH Automation Pvt.Ltd. 
    ". $part_no.$sr_no.$result.$date.$time.$operator."
    ". $part_no_val.$sr_no_val.$result_val.$date_val.$time_val.$operator_val,1,1);
    
            $font_face = "Draft Condensed";
            $font_height =24;
            $font_width = 12;
        $font=printer_create_font($font_face,$font_height,$font_width,PRINTER_FW_HEAVY,false,false,false,0);
        printer_select_font($handle,$font);
            printer_delete_font($font);
    
            $font=printer_create_font($font_face,$font_height,$font_width,PRINTER_FW_BOLD,false,false,false,0);
        printer_select_font($handle,$font);
            printer_draw_text($handle,$part_no,5,35);
            printer_draw_text($handle,$sr_no,225,35);
            printer_draw_text($handle,$result,325,35);
            printer_draw_text($handle,$date,415,35);
            printer_draw_text($handle,$time,530,35);
    
    
    
            printer_delete_font($font);
                $font=printer_create_font($font_face,$font_height,$font_width,PRINTER_FW_BOLD,false,false,false,0);
        printer_select_font($handle,$font);
        //  printer_draw_text($handle,$part_no_val.$sr_no_val.$result_val.$date_val.$time_val,5,140);
    
            printer_draw_text($handle,$part_no_val,5,70);
            printer_draw_text($handle,$sr_no_val,225,70);
            printer_draw_text($handle,$result_val,335,70);
            printer_draw_text($handle,$date_val,415,70);
            printer_draw_text($handle,$time_val,530,70);
    
                printer_delete_font($font);
    
                $pen = printer_create_pen(PRINTER_PEN_SOLID,4, "000000");
        printer_select_pen($handle, $pen);
                printer_draw_line($handle, 2, 2, 605, 2);
                printer_draw_line($handle, 2, 2, 2,100 );
                printer_draw_line($handle, 2, 30, 605, 30);
                printer_draw_line($handle, 2, 60, 605, 60);
                printer_draw_line($handle, 2, 100, 605, 100);
                printer_draw_line($handle, 605, 2, 605, 100);
                printer_delete_pen($pen);
    
    
                $this->load->library('phpqrcode/ciqrcode');
    
                $params['data'] = "$part_no-$part_no_val 
      $sr_no-$sr_no_val 
     $result-$result_val 
     $date-$date_val 
     $time-$time_val 
     $operator-$operator_val 
    ";
                $params['level'] = 'H';
                $params['size'] = 5;
                $params['savename'] = 'qrcode/test.png';
                $this->ciqrcode->generate($params); 
                $this->load->library('ToBmp');  
                $ToBMP = new ToBmp();
    
                // convert png to bmp
                $ToBMP->image_info('qrcode/test.png');
                $ToBMP->new_width  = 125;
                $ToBMP->new_height = 125;
                $ToBMP->imagebmp("qrcode/test.bmp");
    
                printer_set_option($handle, PRINTER_MODE, "RAW");
                printer_draw_bmp($handle, "qrcode\\test.bmp",615, 2, 125,125);
            //set the font characteristics here
    
        //printer_draw_text($handle,"My PDF file content below",10,10);
        //here loop through your pdf file and print the line by line or else get the entire content inside the string at once and print
    
    
    
            printer_end_page($handle);
        printer_end_doc($handle);
            printer_close($handle);
    
    评论

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP