-1

我想在我自己的 joomla2.5 工资模块中添加“打印按钮”。我的模块default.php是:

<?php
$document =& JFactory::getDocument();
$document->addStyleSheet(JURI::base() . 'modules/mod_salary/assets/style.css');
$document->addStyleSheet(JURI::base() . 'modules/mod_salary/assets/print.css'); 
defined('_JEXEC') or die('Restricted access');
    $user = &JFactory::getUser();
    $tbn = $params ->get('table_name');
    $t = $params->get('total_fields');
    $p = $params->get('pay_fields');
    $d = $params->get('deficits_fields');
    $e = $params->get('debt_fields');
    $er = $params->get('debr_fields');
    $wh =$params->get('workhours_fields');//work hours detail
    $emp = $params->get('emp_fields');
    $date =F.$params->get('date_fields');
    $work =F.$params->get('work_fields');
    $bank =F.$params->get('bank_fields');

                $payed = explode (";", $p);
                $deficits = explode (";", $d);
                $debt = explode (";", $e);
                $debr = explode (";", $er);
                $whd = explode (";", $wh);
                echo "<table class='sample' width=100%>";
                echo "<tr>";
                  echo "<td colspan=6>"."<center>"."<h3>"."</center>"."</td>";
                  echo "</tr>";               
                      echo "<tr>";
                      echo "<td>"."فيش حقوقي متعلق به "." "."<b>".$user->name." "."</b> "."دارای شماره پرسنلي"."<b> ".$user->username."</b>"."  مربوط به  "."<b>".$item->$date."</b>"."</td>";
                      echo "</tr>"."<tr>";
                      echo "<td>"."محل کار :"."<b> ".$item->F6."</b>"."  ، "."کارکرد : "."<b>".$item->$work."</b>"."  روز  ،   "."شماره حساب بانکی : "."<b>".$item->$bank."</b>"."</td>";
                      echo "</tr>";
                      echo "<td>"."<table width=100%>";
                      //سر تیتر ستون ها 
                      echo "<td style='background-color:cornsilk; border-color:#D5D5FF' width=34%>"."پرداخت ها"."</td>";
                      echo "<td style='background-color:cornsilk; border-color:#D5D5FF' width=33%>"."کسری ها"."</td>";
                      echo "<td style='background-color:cornsilk; border-color:#D5D5FF' width=33%>"."بدهی ها"."</td>";
                      // ستون ها
                      // ستون پرداخت ها
                      echo "<tr>"."<td>";
                        echo"<table class='s' width=100%>";
                        echo "<tr>";
                        $result = count($payed);
                        for($i=0;$i<$result;$i++){
                        $pay='F'.$payed[$i];
                            if (!empty($item->$pay)){
                                echo "<td style='vertical-align:middle'>".JText::_($pay)."</td>";
                                echo "<td style='text-align:left'>"."<h4>".number_format($item->$pay)."</h4>"."</td>";
                                $paytotal=$item->$pay+$paytotal;  // متغییر پرداخت کل
                                echo "</tr>";
                                }
                            }
                        echo "</table>";
                        echo "</td>";
                //ستون کسورات
                    echo "<td>";
                        echo"<table class='s' width=100%>";
                        echo "<tr>";
                        $result = count($deficits);
                            for($i=0;$i<$result;$i++){
                                $def='F'.$deficits[$i];
                                    if (!empty($item->$def)){
                                    echo "<td  style='vertical-align:middle'>".JText::_($def)."</td>";
                                    echo "<td style='text-align:left'>"."<h4>".number_format($item->$def)."</h4>"."</td>";
                                    $deftotal=$item->$def+$deftotal;  // متغییر کسری کل
                                    echo "</tr>";
                                    }
                            }
                            echo "</table>";
                            echo "</td>";

                    //ستون بدهی ها
                    echo "<td>";
                        echo"<table class='s' width=100%>";
                        echo"<tr>"."<td>"."عنوان"."</td>"."<td>"."مبلغ"."</td>"."<td>"."مانده"."</td>"."</tr>";
                        echo "<tr>";
                        $result = count($debt);
                            for($i=0;$i<$result;$i++){
                                $deb='F'.$debt[$i];
                                $debres='F'.$debr[$i];
                                    if (!empty($item->$deb)){
                                    echo "<td  style='vertical-align:middle'>".JText::_($deb)."</td>";
                                    echo "<td style='text-align:left'>"."<h4>".number_format($item->$deb)."</h4>"."</td>";
                                    echo "<td style='text-align:left'>"."<h4>".number_format($item->$debres)."</h4>"."</td>";
                                    $debtotal=$item->$deb+$debtotal;                                    // متغییر بدهی کل
                                    //$debtreservtotal=$item->$debres+$debreservtotal;                  // متغییر باقیمانده بدهی
                                    echo "</tr>";
                                    }
                            }
                            echo "</table>";
                            echo "</td>";
                        echo "</tr>";
                        echo "<tr>"."<td style='background-color:#F7F7F7; text-align:center; vertical-align:middle'>".JText::_(TOTALPAY)."<h3>".number_format($paytotal)."</h3>"."</td>"."<td style='background-color:#F7F7F7; text-align:center'>".JText::_(TOTALDEF)."<h3>".number_format($deftotal)."</h3>"."</td>"."<td style='background-color:#F7F7F7; text-align:center'>".JText::_(TOTALDEB)."<h3>".number_format($debtotal)."</h3>"."</td>";
                        echo "</tr>";
                        $finallpay=$paytotal-($deftotal+$debtotal);
                        echo "<tr>"."<td colspan=6 style='text-align:center; background-color: cornsilk; vertical-align:middle; direction:rtl' >".JText::_(FINALLPAY)."<h3>".number_format($finallpay)."</h3>"."</td>"."</tr>"."<h4>";
                echo "</table>";
                echo "<p>";
                echo"<table  width=100%>";
                        echo "<td>"."<table width=100%>";
                        echo"<tr>"."<td colspan=10 style='background-color: lavender'>"."<center>"."<h3>"." ریز کارکرد ماهیانه "."</h3>"."</center>"."</td>"."</tr>";
                        echo "<tr>";
                        $result = count($whd);
                            for($i=0;$i<$result;$i++){
                                $whs='F'.$whd[$i];
                                    if (!empty($item->$whs)){
                                    echo "<td width=67%>".JText::_($whs)."</td>";
                                    echo "<td width=33% style='text-align:center'>"."<h4>".number_format($item->$whs)."</h4>"."</td>";
                                    echo "</tr>";
                                    }
                            }
                    echo "</td>"."</table>";
                echo"</table>";
                echo"<a href='javascript:window.print()'>"."Print this Article"."</a>";

            echo "<a href='http://**************'>"."<img width='113' height='37' border='0' style='float: left;' alt='بازگشت به صفحه اصلی' src='images/back.gif'>"."</a>";
            echo "</table>";
?>

当我使用 Java Script Function 打印所有图像时。我想将此数据库报告打印到 A4 ISO 纸上。我用Joomla2.5!并制作我的 style.css 和 print.css。

4

1 回答 1

1

我不确定我是否完全按照,但如果您不希望在 print.css 中打印时显示图像

img {
    display:none;
}

您还应该使用百分比宽度,以便页面上的主包装器应该是 100%,而不是 992px(例如)

于 2012-11-13T17:27:48.797 回答