Exemplo n.º 1
0
Arquivo: func.php Projeto: qquk/IBAG
function country_sum($query, $flag, $ch)
{
    echo "\n        <td class='main_oper_list' align=center valign=top width=50%>\n            <table width=100% border=0 cellspacing=1 cellpadding=1>\n                <tr>\n                    <td class='main_oper_list' align=center valign=top width=50%>\n                      <table width=100% border=0 cellspacing=2 cellpadding=0>";
    $total = 0;
    $total_all = 0;
    $sum = 0;
    $total_addsum = array_fill(0, 20, 0);
    $total_addsum_name = array_fill(0, 20, "");
    $itog_total_addsum = array_fill(0, 20, 0);
    $i = 0;
    $result_country = mysql_query($query) or die(mysql_error("Ошибка запроса"));
    while (list($div_id, $divname) = mysql_fetch_row($result_country)) {
        $query = "select let_id,letsum  from letters l where";
        if ($flag == 1) {
            $query .= "  div_id=";
        } elseif ($flag == 2) {
            $query .= "  sourcediv_id=";
        }
        $query .= "{$div_id} ";
        if ($ch != 0) {
            $query .= "and let_id in(";
            $query1 = "";
            while (list($index, $value) = each($ch)) {
                $query1 .= "{$value},";
                $query .= "{$value},";
            }
            $query = substr($query, 0, -1);
            $query1 = substr($query1, 0, -1);
            $query .= ");";
            reset($ch);
        } else {
            if (!isset($_GET['head'])) {
                require "oper/letters/search_add_query_ctrl.php";
            } else {
                require "letters/search_add_query_ctrl.php";
            }
        }
        $res = mysql_query($query) or die(mysql_error());
        while ($row = mysql_fetch_array($res)) {
            $total_summ = get_full_letter_summ($row['let_id']);
            $total += $total_summ;
            $sum += $row['letsum'];
            $query_addsum = "select last_id,lastname from letaddsummtypes,letactiontypes\n                                    where letaddsummtypes.lat_id=letactiontypes.lat_id  ";
            $res2 = mysql_query($query_addsum) or die(mysql_error());
            while ($row2 = mysql_fetch_array($res2)) {
                $last_summ = get_letter_summ($row2['last_id'], $row['let_id']);
                if ($last_summ != 0) {
                    $total_addsum[$i] += $last_summ;
                    if ($row2['lastname'] != "") {
                        $total_addsum_name[$i] = $row2['lastname'];
                    }
                }
                $i++;
            }
            $i = 0;
        }
        if ($total != 0) {
            $str = number_format($total, 2, '.', ' ');
            $str3 = number_format($sum, 2, '.', ' ');
            $s1 = get_div_parent($div_id);
            echo "\n                                    <tr>\n                                        <td class='total_oper_text' valign=center width=50% align=right>\n                                            {$s1}.<b>{$divname}</b>\n                                        </td>\n                                        <td class='total_oper_text'>\n                                            <table width=100% border=0 cellspacing=0 cellpadding=2>\n                                                  <tr>\n                                                    <td class='let_list_data' style='BORDER: 0px solid;font-size=7pt;color:#888888' align=right valign=center width=15% align=left>\n                                                        к передаче\n                                                    </td>\n                                                    <td class='let_list_data' style='BORDER: 0px solid;font-size=8pt;color:#990000' valign=center width=15% align=right>\n                                                        {$str3}\n                                                    </td>\n                                                </tr>";
            while (list($index, $value) = each($total_addsum)) {
                if ($value == 0) {
                    break;
                }
                echo "\n                                                        <tr>\n                                                            <td class='let_list_data' style='BORDER: 0px solid;font-size=7pt;color:#888888' align=right valign=center width=15% align=left>\n                                                                {$total_addsum_name[$index]}";
                $itog_total_addsum[$index] += $total_addsum[$index];
                echo "\n                                                            </td>\n                                                            <td class='let_list_data' style='BORDER: 0px solid;font-size=8pt;color:#996666' valign=center width=15% align=right>";
                $str1 = number_format($value, 2, '.', ' ');
                echo "\n                                                                {$str1}\n                                                            </td>\n                                                        </tr>";
            }
            reset($total_addsum);
            echo "\n                                            </table>\n                                        </td >\n\n                                    </tr>\n\n\n                        ";
            $total_all += $sum;
            $total_addsum = array_fill(0, 20, 0);
        }
        $total = 0;
        $sum = 0;
    }
    $totalstr = number_format($total_all, 2, '.', ' ');
    echo "\n\n\n\n\n            <tr>\n             <td align=right class='total_oper_text' style='background-color:#EEEEEE' valign=center width=50%>\n              <b>ИТОГО  &nbsp;</b>\n             </td>\n             <td class='total_oper_num' style='background-color:#EEEEEE' valign=center width=50% align=right>\n                <table width=100% border=0 cellspacing=0 cellpadding=2>\n                    ";
    echo "\n                        <tr>\n                          <td class='total_oper_text' style='background-color:#EEEEEE;BORDER: 0px solid;' align=right valign=center width=15% align=left>\n                              к передаче\n                          </td>\n\n                          <td class='total_oper_num' style='background-color:#EEEEEE;BORDER: 0px solid;'  valign=center width=15% align=right>";
    echo "  <b>{$totalstr}</b>\n\n                          </td>\n                      </tr>";
    while (list($index, $value) = each($total_addsum_name)) {
        if ($total_addsum_name[$index] == "") {
            break;
        }
        echo "\n                        <tr>\n                          <td class='total_oper_text' style='background-color:#EEEEEE;BORDER: 0px solid;'  align=right valign=center width=15% align=left>\n                              {$total_addsum_name[$index]}\n                          </td>\n\n                          <td class='total_oper_num'  style='background-color:#EEEEEE;BORDER: 0px solid;' valign=center width=15% align=right>";
        $str1 = number_format($itog_total_addsum[$index], 2, '.', ' ');
        echo " {$str1}\n\n                          </td>\n                      </tr>";
    }
    echo "\n\n                </table>\n             </td>\n            </tr>\n            </table>\n            </td>\n\n            ";
    echo "\n        </tr>\n          <tr><td height=1></td></tr>\n        </table>\n      </td>";
}
Exemplo n.º 2
0
 if (!isset($_GET['head'])) {
     echo "\n\t                              <td bgcolor=white width=60 class='let_list_data'>\n\t                               <table width=100% border=0 cellspacing=0 cellpadding=2>\n\t                               <tr> ";
 }
 echo "\n\t                                <td class='let_list_data' style='";
 if (!isset($_GET['head'])) {
     echo "BORDER: 0px solid;";
 }
 echo "'> <font color=#990000>" . $row['divname'] . "</font></td>";
 if (!isset($_GET['head'])) {
     echo "\n\t                               </tr>\n\n\t                               </table>\n\t                              </td>";
 }
 echo "\n\n\n\n\t                          <td bgcolor=white width=110 class='let_list_data'>\n\t                           <table width=100% border=0 cellspacing=0 cellpadding=2>\n\t                           <tr>\n\t                            <td class='let_list_data' style='BORDER: 0px solid;' align=right width=100%>\n\t                             <table width=100% border=0 cellspacing=0 cellpadding=0>\n\t                             <tr>\n\t                              <td width=50% class='let_list_data' style='BORDER: 0px solid;font-size=7pt;color:#888888' align=right>сумма</td>\n\t                              <td class='let_list_data' style='BORDER: 0px solid;font-size=8pt;color:#990000' align=right>" . $let_summ . "</td>\n\t                             </tr>";
 $query = "select * from letaddsummtypes";
 $res2 = mysql_query($query) or die(mysql_error());
 while ($row2 = mysql_fetch_array($res2)) {
     $last_summ = number_format(get_letter_summ($row2['last_id'], $row['let_id']), 2, '.', ' ');
     convert_cyr_string($row2['lastname'], k, w);
     if ($last_summ != '0.00') {
         echo "\n\t                             <tr>\n\t                              <td class='let_list_data' style='BORDER: 0px solid;font-size=7pt;color:#888888' align=right>" . $row2['lastname'] . "</td>\n\t                              <td class='let_list_data' style='BORDER: 0px solid;font-size=8pt;color:#996666' align=right>" . $last_summ . "</td>\n\t                             </tr>";
     }
 }
 echo "\n                             \t\t<tr>\n\t                                  <td class='let_list_data' style='BORDER: 0px solid;font-size=7pt;color:#888888' align=right>к передаче</td>\n\n\t                                <td class='let_list_data' style='BORDER: 0px solid;color:#990000' align=right><b>" . $total_summ . "</b></td>\n\t                               </tr>\n\t                             </table>\n\t                           </tr>\n\t                           </table>\n\t                          </td>\n\n                              ";
 if (!isset($_GET['head'])) {
     echo "\n\t                            <td bgcolor=white width=120 class='let_list_data'>\n\t                               <table width=100% border=0 cellspacing=0 cellpadding=2>\n\t                               <tr> ";
 }
 echo "\n\t                            <td class='let_list_data' style='";
 if (!isset($_GET['head'])) {
     echo "BORDER: 0px solid;";
 }
 echo "color:#444444'>";
 if ($row['payeeisbank'] == 0) {