コード例 #1
0
ファイル: Generate.php プロジェクト: bagermen/Examples
 /**
  * @param array $opts - массив опций для генерации отчета:
  * $opts = array (
  *   "filename" => Имя файла для генерации (default: file.rtf)
  *   "tpl" => Обработчик данных отчета
  *   "time" => Опция позволяет добавить дату и время генерации в название файла (default: false)
  * )
  *
  * @param array  $data - массив данных, по которым получаем отчет
  * @param string $optfile - имя файла настроек для генератора RTF (default: rtf_config.inc)
  * @return bool - выводит false в случае неудачи
  */
 public static function generate($opts, $data, $optfile = 'rtf_config.inc')
 {
     $result = false;
     $opts = (array) $opts;
     $data = (array) $data;
     $opts = array("filename" => array_key_exists("filename", $opts) ? $opts["filename"] : "file.rtf", "tpl" => array_key_exists("tpl", $opts) ? $opts["tpl"] : "", "time" => array_key_exists("time", $opts) ? $opts["time"] : false);
     $finfo = pathinfo($opts["filename"]);
     $name = $finfo["filename"];
     if ($opts["time"]) {
         $cur_date = toZendDate('now');
         $name .= "_" . $cur_date->get(getTimeFormat('datetimef'));
     }
     $opts["filename"] = $name . "." . $finfo["extension"];
     $tpl = ucfirst(strtolower($opts["tpl"]));
     $postfix = isEtpGazprom() ? 'Gaz' : 'Etp';
     $class = 'Model_Docs_' . $postfix . "_" . $tpl;
     try {
         if (class_exists($class)) {
             $template = new $class($data);
             $template->prepare();
             self::renderTpl($opts["filename"], $template, $optfile);
         }
         return $result;
     } catch (ResponseException $e) {
         return array('success' => false, 'message' => $e->getMessage());
     }
 }
コード例 #2
0
ファイル: basic.php プロジェクト: kix23/GetSimpleCMS
/**
 * Time Output using locale
 *
 * @since 3.4
 * @param  str $dt Date/Time String
 * @return str
 */
function output_time($dt = null)
{
    if (isset($dt)) {
        $dt = strtotime($dt);
    }
    if (getTimeFormat()) {
        return formatDate(getTimeFormat(), $dt);
    }
}
コード例 #3
0
    $status[$row['Variable_name']] = $row['Value'];
}
$filter = getPrefixArray($status);
// values that will be formatted as times
$timeValues = array('Uptime', 'Uptime_since_flush_status');
$tplSqlbrowserGeneralStatus = new MSDTemplate();
$tplSqlbrowserGeneralStatus->set_filenames(array('tplSqlbrowserGeneralStatus' => 'tpl/sqlbrowser/general/status.tpl'));
if ($selectedFilter != '-1') {
    $query = 'SHOW GLOBAL STATUS LIKE \'' . $selectedFilter . '_%\'';
    $res = $dbo->query($query, MsdDbFactory::ARRAY_ASSOC);
}
if (@sizeof($res) == 0) {
    $tpl->assign_block_vars('NO_STATUS', array());
} else {
    if (count($filter) > 0) {
        $tplSqlbrowserGeneralStatus->assign_block_vars('FILTER', array('SEL_FILTER' => Html::getOptionlist($filter, $selectedFilter)));
    }
    $i = 0;
    foreach ($status as $key => $val) {
        if ($selectedFilter != '-1' && substr($key, 0, strlen($selectedFilter)) != $selectedFilter) {
            continue;
        }
        if (in_array($key, $timeValues)) {
            $val = getTimeFormat($val);
        } else {
            $val = String::formatNumber($val);
        }
        $tplSqlbrowserGeneralStatus->assign_block_vars('ROW', array('ROWCLASS' => $i % 2 ? 'dbrow' : 'dbrow1', 'NR' => $i + 1, 'VAR_NAME' => $key, 'VAR_VALUE' => $val));
        $i++;
    }
}
コード例 #4
0
// Authenticate
require("class.AuthenticationManager.php");
if (!$authenticationManager->isLoggedIn()) {
	Header("Location: login.php?redirect=$_SERVER[PHP_SELF]");
	exit;
}

// Connect to database.
$dbh = dbConnect();
$contextUser = strtolower($_SESSION['contextUser']);
  
//load local vars from superglobals
$trans_num = $_REQUEST['trans_num'];

//get the timeformat
$timeFormat = getTimeFormat();

$dateFormatString = ($timeFormat == "12") ? "%m/%d/%Y %h:%i%p": "%m/%d/%Y %H:%i";

$query = "SELECT DATE_FORMAT(start_time, '$dateFormatString') as formattedStartTime, ".
					"DATE_FORMAT(end_time, '$dateFormatString') as formattedEndTime, ".
			   "(unix_timestamp(end_time) - unix_timestamp(start_time)) as time,".
			   "log_message, " .
			   "$PROJECT_TABLE.title AS projectTitle, " .
			   "$PROJECT_TABLE.proj_status AS projectStatus, ".
			   "$TASK_TABLE.name AS taskName, " .
			   "$TASK_TABLE.status AS taskStatus, ".
			   "$CLIENT_TABLE.organisation, ".
			   "$USER_TABLE.first_name, ".
			   "$USER_TABLE.last_name " .
			   "FROM $TIMES_TABLE, $PROJECT_TABLE, $TASK_TABLE, $USER_TABLE, $CLIENT_TABLE ".
コード例 #5
0
// if we restore a MySQLDumper-Backup we know the nr of records and can
// calculate the estimated time from it
// if we restore a backup from another program we need to rely on the filesize
//which is not accurate
// when the file is gzipped, but we can't help it because there is no way to
// get the exact file pointer position in a gzipped file.
// So we give our best to guess the corect position (see line 117 above)
if ($restore['progress_overall_percent'] > 0) {
    $percentageDone = $restore['progress_overall_percent'];
} else {
    $percentageDone = $restore['progress_file_percent'];
}
$estimatedTime = 0;
if ($percentageDone > 0) {
    $estimatedTime = (100 - $percentageDone) * ($elapsed / $percentageDone);
    $r['estimated_end'] = getTimeFormat($estimatedTime);
} else {
    $r['estimated_end'] = $lang['L_UNKNOWN'];
}
// check if new log-messages have been added
$messages = getArrayDiffAssocRecursive($_SESSION['log'], $_SESSION['temp_log']);
if (isset($messages['actions']) && is_array($messages['actions'])) {
    $r['actions'] = implode('<br />', $messages['actions']);
}
if (isset($messages['errors']) && is_array($messages['errors'])) {
    $r['errors'] = implode('<br />', $messages['errors']);
}
$_SESSION['log'] = $_SESSION['log'] + $_SESSION['temp_log'];
// save actual values to session
$_SESSION['restore'] = $restore;
echo $json->encode($r);
コード例 #6
0
ファイル: functions.php プロジェクト: macall/jsd
function getGoodsArray($item)
{
    /**
     * has_attr: 0:无属性; 1:有属性
     * 有商品属性在要购买时,要选择属性后,才能购买(用户在列表中点:购买时,要再弹出一个:商品属性选择对话框)
     * change_cart_request_server:
     * 编辑购买车商品时,需要提交到服务器端,让服务器端通过一些判断返回一些信息回来(如:满多少钱,可以免运费等一些提示)
     * 0:提交,1:不提交;
     *
     * num_unit: 单位
     * limit_num: 库存数量
     *
     */
    $goods = array();
    $goods['city_name'] = "";
    $goods['goods_id'] = $item['id'];
    $goods['title'] = emptyTag($item['name']);
    if (empty($item['sub_name'])) {
        $goods['sub_name'] = emptyTag($item['name']);
    } else {
        $goods['sub_name'] = emptyTag($item['sub_name']);
    }
    //$goods['image']=get_abs_img_root(make_img($item['img'],0));
    $goods['image'] = get_abs_img_root(get_spec_image($item['img'], 320, 194, 1));
    //get_abs_img_root( get_spec_image($v['o_path'],160,0,0));
    $goods['buy_count'] = $item['buy_count'];
    $goods['start_date'] = $item['begin_time'];
    $goods['end_date'] = $item['end_time'];
    $goods['ori_price'] = round($item['origin_price'], 2);
    $goods['cur_price'] = round($item['current_price'], 2);
    if (empty($item['brief'])) {
        $goods['goods_brief'] = $item['name'];
    } else {
        $goods['goods_brief'] = $item['brief'];
    }
    $goods['ori_price_format'] = format_price($goods['ori_price']);
    $goods['cur_price_format'] = format_price($goods['cur_price']);
    $goods['discount'] = $item['discount'];
    $sp_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "supplier_location where supplier_id = " . $item['supplier_id'] . " order by is_main desc");
    $goods['address'] = $sp_info['address'];
    // 地址未完
    $goods['num_unit'] = "";
    //$item['num_unit'];
    $limit_num = intval($item['max_bought']);
    //如果库存为0时,不设置为:99999,不限制购买数量;
    if ($limit_num == 0) {
        $limit_num = 99999;
    }
    $goods['limit_num'] = $limit_num;
    $goods['goods_desc'] = $item['description'];
    $goods['is_shop'] = $item['is_shop'];
    $goods['is_hot'] = $item['is_hot'];
    $goods['notes'] = $item['notes'];
    $goods['package'] = $item['package'];
    $goods['supplier_location_id'] = $GLOBALS['db']->getOne("select location_id from " . DB_PREFIX . "deal_location_link where deal_id = " . $item['id']);
    $goods['any_refund'] = $item['any_refund'];
    $goods['expire_refund'] = $item['expire_refund'];
    //标签列表
    //支持随时退款
    $ext_label = array();
    if ($goods['any_refund'] == 1) {
        $ext_label[] = array('type' => 0, 'ico' => '', 'name' => '支持随时退款');
    }
    //支持过期退款
    if ($goods['expire_refund'] == 1) {
        $ext_label[] = array('type' => 1, 'ico' => '', 'name' => '支持过期退款');
    }
    $goods['ext_label'] = $ext_label;
    $goods['time_status'] = $item['time_status'];
    $goods['end_time'] = $item['end_time'];
    $goods['begin_time'] = $item['begin_time'];
    $goods['sp_location_id'] = $sp_info['id'];
    //供应商信息
    $goods['sp_detail'] = $sp_info['name'];
    //供应商信息
    $goods['sp_tel'] = $sp_info['tel'];
    /*供应商电话*/
    $pattern = "/<img([^>]*)\\/>/i";
    $replacement = "<img width=300 \$1 />";
    $goods['goods_desc'] = get_abs_img_root(format_html_content_image($goods['goods_desc'], 300));
    $goods['goods_desc'] = preg_replace($pattern, $replacement, $goods['goods_desc']);
    $goods['saving_format'] = $item['save_price_format'];
    if ($goods['end_date'] == 0) {
        $goods['less_time'] = "none";
        //永不过期,无倒计时
        $goods['less_time_format'] = "999天";
        //永不过期,无倒计时
    } else {
        $goods['less_time'] = $goods['end_date'] - get_gmtime();
        if ($goods['less_time'] < 0) {
            $goods['less_time'] = 0;
        }
        $goods['less_time_format'] = getTimeFormat($goods['less_time']);
    }
    $goods['has_attr'] = 0;
    //has_attr: 0:无属性; 1:有属性
    if ($item['is_delivery'] == 1) {
        $goods['has_delivery'] = 1;
        $goods['has_mcod'] = 1;
    } else {
        $goods['has_delivery'] = 0;
        $goods['has_mcod'] = 0;
    }
    if ($goods['cart_type'] == 0) {
        $goods['has_cart'] = 1;
        //1:可以跟其它商品一起放入购物车购买;0:不能放入购物车,只能独立购买
    } else {
        $goods['has_cart'] = 0;
    }
    $goods['change_cart_request_server'] = 1;
    $goods['is_refund'] = $item['is_refund'];
    /*0:不支持退款; 1:支持退款*/
    $goods['avg_point'] = $item['avg_point'];
    /*购买点评平均分*/
    $goods['distance'] = $item['distance'];
    $goods['attr'] = getAttrArray($item['id']);
    if (intval($goods['attr']['has_attr_1']) > 0 || intval($goods['attr']['has_attr_2']) > 0) {
        $goods['has_attr'] = 1;
    }
    //$goods['share_content']=msubstr($topic['content']).get_domain().str_replace("mapi/","",url("shop","topic",array("id"=>$topic['id'])));
    $goods['share_url'] = get_domain() . str_replace("sjmapi/", "", url("index", "deal#" . $item['id']));
    $goods['share_content'] = emptyTag($item['name']) . $goods['share_url'];
    return $goods;
}
コード例 #7
0
 * @package         MySQLDumper
 * @version         SVN: $rev: 1207 $
 * @author          $Author$
 * @lastmodified    $Date$
 */
if (!defined('MSD_VERSION')) {
    die('No direct access.');
}
include './inc/define_icons.php';
$dump = $_SESSION['dump'];
$tplDumpFinished = new MSDTemplate();
$tplDumpFinished->set_filenames(array('tplDumpFinished' => 'tpl/dump/dump_finished.tpl'));
$recordsTotal = String::formatNumber((int) $dump['records_total']);
$tablesTotal = $dump['tables_total'];
$msg = sprintf($lang['L_DUMP_ENDERGEBNIS'], $tablesTotal, $recordsTotal);
$tplDumpFinished->assign_vars(array('ICON_OPEN_FILE' => $icon['small']['open_file'], 'ICON_EDIT' => $icon['small']['edit'], 'ICON_VIEW' => $icon['small']['view'], 'SESSION_ID' => session_id(), 'BACKUPPATH' => $config['paths']['backup'], 'PAGE_REFRESHS' => $dump['page_refreshs'], 'TIME_ELAPSED' => getTimeFormat(time() - $dump['dump_start_time']), 'MSG' => $msg));
if (count($dump['databases']) > 1) {
    $msg = sprintf($lang['L_MULTIDUMP_FINISHED'], count($dump['databases']));
    $tplDumpFinished->assign_block_vars('MULTIDUMP', array('MSG' => $msg));
}
$i = 1;
foreach ($_SESSION['log']['files_created'] as $file) {
    $fileSize = @filesize($config['paths']['backup'] . $file);
    $tplDumpFinished->assign_block_vars('FILE', array('NR' => $i, 'ROWCLASS' => $i % 2 ? 'dbrow' : 'dbrow1', 'FILENAME' => $file, 'FILENAME_URLENCODED' => urlencode($file), 'FILESIZE' => byteOutput($fileSize)));
    $i++;
}
$i = 1;
foreach ($_SESSION['log']['actions'] as $message) {
    $timestamp = substr($message, 0, 19);
    $message = substr($message, 20);
    $tplDumpFinished->assign_block_vars('ACTION', array('NR' => $i, 'ROWCLASS' => $i % 2 ? 'dbrow' : 'dbrow1', 'TIMESTAMP' => $timestamp, 'ACTION' => $message));
コード例 #8
0
 * http://www.mysqldumper.net
 *
 * @package         MySQLDumper
 * @version         SVN: $rev: $
 * @author          $Author$
 * @lastmodified    $Date$
 */
// Restore is finished
include './inc/define_icons.php';
$restore = $_SESSION['restore'];
$tplRestoreFinished = new MSDTemplate();
$tplRestoreFinished->set_filenames(array('tplRestoreFinished' => 'tpl/restore/restore_finished.tpl'));
$recordsInserted = String::formatNumber($restore['records_inserted']);
$recordsInserted = sprintf($lang['L_RECORDS_INSERTED'], $recordsInserted);
$tablesCreated = sprintf($lang['L_RESTORE_COMPLETE'], $restore['table_ready']);
$timeElapsed = getTimeFormat(time() - $restore['restore_start_time']);
$tplRestoreFinished->assign_vars(array('SESSION_ID' => session_id(), 'ICON_OPEN_FILE' => $icon['small']['open_file'], 'ICON_EDIT' => $icon['small']['edit'], 'ICON_VIEW' => $icon['small']['view'], 'SESSION_ID' => session_id(), 'BACKUPPATH' => $config['paths']['backup'], 'PAGE_REFRESHS' => $restore['page_refreshs'], 'TIME_ELAPSED' => $timeElapsed, 'TABLES_CREATED' => $tablesCreated, 'RECORDS_INSERTED' => $recordsInserted, 'ICONPATH' => $config['files']['iconpath']));
if (count($_SESSION['log']['errors']) > 0) {
    $i = 1;
    $tplRestoreFinished->assign_block_vars('ERRORS', array());
    foreach ($_SESSION['log']['errors'] as $logError) {
        $timestamp = substr($logError, 0, 19);
        $message = substr($logError, 20);
        $tplRestoreFinished->assign_block_vars('ERRORS.ERROR', array('NR' => $i, 'ROWCLASS' => $i % 2 ? 'dbrow' : 'dbrow1', 'TIMESTAMP' => $timestamp, 'MSG' => $message));
        $i++;
    }
}
$i = 1;
foreach ($_SESSION['log']['actions'] as $logAction) {
    $timestamp = substr($logAction, 0, 19);
    $message = substr($logAction, 20);
コード例 #9
0
ファイル: Reconciliation.php プロジェクト: bagermen/Examples
 protected function renderTransaction($data)
 {
     $rows = array();
     foreach ($data as $tr) {
         $data = array();
         $data[] = "<tr><td valign=middle>" . $tr['date']->get(getTimeFormat("date")) . "</td>";
         if ($tr['colored']) {
             $tr['doc'] = '<font color=#CC0000>' . $tr['doc'] . '</font>';
         }
         $data[] = '<td align=center valign=middle>' . $tr['doc'] . '</td>';
         $data[] = '<td align=right valign=middle>' . ($tr['debet'] != 0 ? HumanizePrice($tr['debet'], true) : "") . '</td>';
         $data[] = '<td align=right valign=middle>' . ($tr['credit'] != 0 ? HumanizePrice($tr['credit'], true) : "") . '</td>';
         $data[] = "<td valign=middle></td>\n         <td align=center valign=middle></td>\n         <td align=right valign=middle></td>\n         <td align=right valign=middle></td>\n       </tr>";
         $rows[] = implode("", $data);
     }
     return implode("", $rows);
 }