Exemple #1
0
function insert_subtotal(&$row_node, &$subtotal, $break_level)
{
    // $row_node is the row to insert the subtotal after.
    global $doc, $clone_tr, $subtotal_column_start, $xtbody;
    // For when there are no rows.
    if (is_null($row_node)) {
        return;
    }
    // Create a subtotal row to put subtotal values into.
    $subtotal_row = $doc->create_element("tr");
    $subtotal_row = $row_node->clone_node(true);
    $subtotal_row->set_attribute("class", "subtotal");
    $subtotal_cols = $subtotal_row->get_elements_by_tagname("td");
    // Put the subtotal values into cells.
    for ($i = $break_level; $i < $subtotal_column_start; $i++) {
        replace_content($subtotal_cols[$i], "");
    }
    $subtotal_cols[max(0, $break_level - 1)]->set_content(" Total");
    for ($i = $subtotal_column_start; $i < count($subtotal_cols); $i++) {
        if ($subtotal[$i] != 0) {
            replace_content($subtotal_cols[$i], number_format($subtotal[$i], 2));
            unset($subtotal[$i]);
        } else {
            replace_content($subtotal_cols[$i], "");
        }
    }
    // Insert the row into the xml doc
    if (is_null($row_node->next_sibling())) {
        $xtbody->append_child($subtotal_row);
    } else {
        $row_node->insert_before($subtotal_row, $row_node->next_sibling());
    }
}
Exemple #2
0
function document_create($result, $id, $template, $module)
{
    global $CONF, $DB;
    //Fetch Template
    //if (!isset($result[ref_template])) return 0;
    $rs_temp = $DB->Execute("SELECT * FROM INT_document_template WHERE id=" . $template);
    $this_template = $rs_temp->FetchRow();
    //Read template from sxw
    list($tmpdir, $this_page) = read_sxw_template($template . ".sxw");
    //print "tmpdir: $tmpdir<br>";
    if (isset($result[ref_prat][realval])) {
        $rp = $result[ref_prat][realval][0];
    } else {
        $rp = $pres[ref_id];
    }
    //Fetch Pratica
    $rs_prat = $DB->Execute("SELECT * FROM pratiche WHERE id=" . $rp);
    $this_pratica = $rs_prat->FetchRow();
    //Fetch Cliente
    $rs_cli = $DB->Execute("SELECT * FROM contact WHERE id=" . $this_pratica[pr_ref_idcliente]);
    $this_cli = $rs_cli->FetchRow();
    //Fetch avversario
    $this_avv = array();
    $avv = explode(',,', $this_pratica[pr_ref_idavvr]);
    if (is_numeric($avv[0])) {
        $rs_avv = $DB->Execute("SELECT * FROM contact WHERE id=" . $avv[0]);
        $old_avv = $rs_avv->FetchRow();
        foreach ($old_avv as $k => $v) {
            $this_avv["avv_{$k}"] = $v;
        }
    }
    $this_result = array_merge($this_cli, $this_avv, $this_pratica);
    //Replace content tags
    $this_page = replace_content($this_page, $this_result);
    //print "dest: ".$CONF[path_base].$CONF[dir_upload].$module."/".$result[filename].".sxw<br>";
    //Write sxw
    write_sxw($tmpdir, $this_page, $CONF[path_base] . $CONF[dir_upload] . $module . "/" . $result[filename] . '-' . $id . "-1.sxw");
    //$md5f=md5_file($CONF[path_base].$CONF[dir_upload].$module."/".$result[filename].'-'.$id."-1.sxw");
    //$rs_updf=$DB-Execute("UPDATE document set checksum='".$md5f."' WHERE id=$id");
    return $result[filename] . '-' . $id . "-1.sxw";
}
 public function getComment()
 {
     if (!IS_AJAX) {
         E('页面不存在!');
     }
     $page = I('page', 1, 'intval');
     $count = M('Message')->count();
     $limit = 5;
     $total = ceil($count / $limit);
     $offset = $limit * ($page - 1) . ',' . $limit;
     //上一页
     $prev = $page - 1 > 0 ? $page - 1 : 1;
     //下一页
     $next = $page + 1 > $total ? $total : $page + 1;
     $comment = M('comment')->limit($offset)->order('addtime DESC')->select();
     if ($comment) {
         $str = '';
         foreach ($comment as $v) {
             $str .= '<dl class="comment_content">';
             $str .= '<dt><a href="' . U('/' . $v['uid']) . '">';
             $str .= '<img src="';
             $str .= __ROOT__;
             if ($user['face']) {
                 $str .= '/Uploads/Face/' . $user['face'];
             } else {
                 $str .= '/Public/Images/phiz/aini.gif';
             }
             $str .= '" alt="' . $user['username'] . '" width="30" height="30"/>';
             $str .= '</a></dt><dd>';
             $str .= '<a href="' . U('/' . $v['uid']) . '" class="comment_name">';
             $str .= "hhahahh" . '</a> : ' . replace_content($v['content']);
             $str .= '&nbsp;&nbsp;( ' . time_format($v['addtime']) . ' )';
             $str .= '</dd></dl>';
         }
         $str .= "<div id='page'><a href='javascript:;' page='1' >首页</a>|<a href='javascript:;' page='{$prev}'>上一页</a>|<a  href='javascript:;' page='{$next}'>下一页</a>|<a href='javascript:;' page='{$total}' >末页</a></div>";
         echo $str;
     } else {
         echo 'false';
     }
 }
                if (!is_null($params)) {
                    $content = content_filters($content, $params);
                }
                $fp = fopen($dest, 'a+');
                fwrite($fp, $content, strlen($content));
                fclose($fp);
                chmod($dest, G5_FILE_PERMISSION);
            } else {
                return false;
            }
        } else {
            if (empty($dest)) {
                $dest = $ImgPath . basename($src);
            }
            if (is_file(G5_WS_ADMIN_PATH . '/templates/' . $src) && file_exists(G5_WS_ADMIN_PATH . '/templates/' . $src)) {
                $content = file_get_contents(G5_WS_ADMIN_PATH . '/templates/' . $src);
                $fp = fopen($dest, 'a+');
                fwrite($fp, $content, strlen($content));
                fclose($fp);
                chmod($dest, G5_FILE_PERMISSION);
            } else {
                return false;
            }
        }
    }
}
foreach ($files as $file) {
    $dest = str_replace(array('$CssPath$', '$JsPath$', '$ImgPath$'), array($CssPath, $JsPath, $ImgPath), $file->dest);
    $content = replace_content($file->src, $dest, $file->filters);
}
// debugout( 'exit', 1 );