),
'row_parse_pre' => function(&$r) {
- #extra: "rent * (1 + ( strftime('%m',end)+12*strftime('%Y',end) ) - ( strftime('%m',start)+12*strftime('%Y',start) ))"
- #$r['rent_year'] = $r['rent'] * (1 + ( date('m',strtotime($r['end']))+12
- $r['Total'] = $r['rent'] + $r['charge'];
-# NB 16.05.16 if (1) $r['rent_year'] = sprintf('%.2f',$r['rent'] * (1 +
-# NB 16.05.16 ( date('m',strtotime($r['end'])) + 12 * date('Y',strtotime($r['end'])) )
-# NB 16.05.16 -
-# NB 16.05.16 ( date('m',strtotime($r['start'])) + 12 * date('Y',strtotime($r['start'])) )
-# NB 16.05.16 ));
+ $r['month'] = $r['rent'] + $r['charge'];
+
$start_month = date('m',strtotime($r['start']));
$end_month = date('m',strtotime($r['end']));
if (date('Y',strtotime($r['end'])) > date('Y',strtotime($r['start']))) $end_month = 12;
- $r['rent_year'] = sprintf('%.2f',$r['rent'] * (1 + $end_month - $start_month));
- $r['months_year'] = (1 + $end_month - $start_month);
+ $r['months'] = (1 + $end_month - $start_month);
+
+ $r['total'] = sprintf('%d',$r['rent'] * $r['months']);
},
'row_parse_post' => ((empty($GLOBALS['Db']) or Db::php_cli()) ? null : function(&$r) {
if (!isset($templates)) {
$templates = $GLOBALS['Db']->rows("SELECT id FROM template",PDO::FETCH_NUM);
foreach ($templates as $k=>$t) {
- $templates[$k] = '<a href="template/?id='.$t[0].'&idplace=:idplace&idtenant=:idtenant&start=:start">'.preg_replace('/\.\w+$/','',$t[0]).'</a>';
+ $templates[$k] = '<a class="small" href="template/?id='.$t[0].'&idplace=:idplace&idtenant=:idtenant&start=:start">'.preg_replace('/\.\w+$/','',$t[0]).'</a>';
}
}
$r['revision'] .= preg_replace_callback('/:(\w+)/',function($m) use(&$r) {return $r[$m[1]];},$t).' ';
}
$r['revision'] = trim($r['revision']);
+ tennant_doc($r);
}),
),
},$path);
}
+function tennant_doc(&$r) {
+ $url = '';
+ foreach (['idtenant','id'] as $k) {
+ if (isset($r[$k])) $url = '/data/tenant/'.$r[$k];
+ }
+ if (!$url) return;
+
+ if (!isset($r['doc'])) $r['doc'] = '';
+#debug($_SERVER['DOCUMENT_ROOT'].$url);
+ if (
+
+ # Web url
+ (
+ empty($r['doc']) and file_exists( $dir = $_SERVER['DOCUMENT_ROOT'].$url )
+ )
+
+ # Absolute path
+ or (
+ ( $dir = untilde($r['doc']) )
+ and file_exists($dir) and is_dir($dir)
+ and ($url='' or 1)
+ )
+
+ ) {
+
+ foreach (ls_dir($dir,true) as $p) {
+ #$r['doc'] .= '/data/tenant/'.$p;
+ $r['doc'] .= sprintf('<a href="%s" class="small">%s</a> ',"$url/$p",preg_replace('@^.*?([^/\.]+).*?$@','\1',$p));
+ }
+
+ }
+
+}
+
#die(untilde('~/.gitconfig'));
if (!empty($_SERVER['DOCUMENT_ROOT'])) {
$CONF['_rent']['tables']['tenant'] = array(
- 'row_parse_post' => function(&$r) {
- $url = '/data/tenant/'.$r['id'];
-
- if (
- (
- (!$doc=$r['doc']) and file_exists( $dir = $_SERVER['DOCUMENT_ROOT'].$url )
- ) or (
- ( $dir = untilde($r['doc']) )
- and file_exists($dir) and is_dir($dir)
- and ($url='' or 1)
- )
- ) {
- #debug($_SERVER['DOCUMENT_ROOT'].'/data/tenant/');
- foreach (ls_dir($dir,true) as $p) {
- #$r['doc'] .= '/data/tenant/'.$p;
- $r['doc'] .= sprintf('<a href="%s" class="small">%s</a> ',"$url/$p",preg_replace('@^.*?([^/\.]+).*?$@','\1',$p));
- }
- }
- },
+ 'row_parse_post' => 'tennant_doc',
);
}