title: 'Rent'
notice: 'Micro foncier 4BE'
default_table: 'rent'
- map:
- "SELECT addr FROM addr WHERE id='@id'": ".rows.place td.id, .rows.rent td.idplace"
- "SELECT name FROM tenant WHERE id='@id'": ".rows.rent td.idtenant"
# NEW- NB 10.01.16
tables:
vertical-align: top;
}
-.db div.rows .row span {
+.db div.rows label {
width: 70%;
display: inline-block;
white-space: normal;
: false
;
- if ($opt['is_html'] and !$this->p('action')) echo $this->html_menu();
+ if ($opt['is_html'] and !$this->p('action') and !$this->p('inc')) {
+ echo $this->html_menu();
+
+ } elseif ($opt['is_html'] and !$this->p('inc')) {
+ echo $this->form_hidden();
+
+ }
+
+ if ($opt['is_html']) echo '<div class="results">'.NB_EOL;
# Use the module out when format unknow
$out_conf = null;
}
+ if ($opt['is_html']) out::$type = 'html';
$count = 0;
while ($row = $st->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_NEXT)) {
$count++;
+ if ($opt['is_html'] and !$out_conf) {
+ foreach ($row as $k=>$v) {
+ if (!isset($this->extras[$k])) $row[$k] = out::format($v);
+ }
+ }
+
#
# Head
#
} # < out
+ if ($opt['is_html']) {
+ echo '</div>'.NB_EOL;
+ }
+
$st->closeCursor();
return $count;
}
public function rows_end_div($opt=array()) {
+ return '</div>'.NB_EOL;
}
public function sql_name($value=null) {
));
$r .= '</span>';
- // Dbs
+ // Dbs - see default.js if you change class
if (!empty($this->db()->dbs) and count($this->db()->dbs)>1) {
$r .= '<span class="label">';
$r .= '<label for="db">Db</label>'.html_select_array($this->db()->dbs,array(
- 'html' => 'class="dbs" name="db" onchange="document.location=\''.preg_replace('/\?.*$/','',$_SERVER['REQUEST_URI']).'?db=\'+this.value"',
+ 'html' => 'class="dbs" id="db" name="db" onchange="document.location=\''.preg_replace('/\?.*$/','',$_SERVER['REQUEST_URI']).'?db=\'+this.value"',
'selected' => self::p('db'),
'prettyText' => true,
));
$r .= '</span>';
}
- // Tables
+ // Tables - see default.js if you change class
$r .= '<span class="label">';
$r .= '<label for="table">Tables</label>'.html_select_array(array_keys($this->db()->tables()),array(
- 'html' => 'class="tables" name="table" id="table"',
+ 'html' => 'class="tables" id="table" name="table" id="table"',
'selected' => $this->p('table'),
'prettyText' => true,
));
#public static function zaza() { return (is_object($this) ? 'TRUE' : 'FALSE'); }
public static function test() { return 'TEST'; }
+ public function __construct($opt = array()) {
+ foreach ($opt as $k => $v) {
+ if ( ! array_key_exists($k,$this) ) self::bye("Unknow param $k = `$v`");
+ $this->$k = is_array($v) ? $v : trim($v);
+ }
+ }
public function __sleep() { return array_keys((array)$this); }
#public function __wakeup() { }
}
# yaml
- if (!self::is_hash($row)) return out_yaml($row,$o);
+ if (!self::is_hash($row)) {
+ #bye($row);
+ }
+
+ if (!self::is_hash($row)) unset($o['head_max_len']);
+ if (is_array($row) and count($row)>1) $o['head_max_len'] = strlen(count($row));
+ #if (!self::is_hash($row)) return out_yaml($row,$o);
# text
- foreach ($row as $k => $v) { echo sprintf("%-".(!empty($o['head_max_len']) ? $o['head_max_len']+1 : 10)."s: %s\n",$k,self::escape($v)); }
+ foreach ($row as $k => $v) {
+ echo sprintf("%"
+ .(!empty($o['head_max_len']) ? '-'.($o['head_max_len']+1) : '')
+ ."s: %s\n",$k,self::escape($v)
+ );
+ }
#foreach ($row as $k => $v) { echo "$k: ".self::escape($v)."\n"; }
return true;
return;
}
- public static function escape($v,$type=null) {
- static $replace_flags = null;
-
+ public static function format($v) {
$is_scalar = is_scalar($v);
$v = self::scalar($v);
if ($v==='') $is_scalar = true;
- if ($replace_flags === null) {
+ $v = self::escape($v);
+
+ if (!$is_scalar and strpos($type,'html') !== false) $v = '<pre>'.NB_EOL.$v.NB_EOL.'</pre>';
+ return $v;
+ }
+
+ public static function escape($v,$type=null,$charset=null) {
+ if ($charset === null) $type = self::$charset;
+
+ static $replace_flags = null;
+
+ if ($replace_flags === null and $charset=null and $type=null) {
#$replace_flags = ENT_COMPAT | ENT_DISALLOWED;
$replace_flags = ENT_COMPAT;
-
if ($type === null) $type = self::$type;
+
if (!$type) {
return $v;
$replace_flags = $replace_flags | ENT_HTML5;
} else { # text
- return str_replace("\n",'|',$v);
- return $v;
- return preg_replace('/\n/','',$v);
+# NB 06.04.16 $v = str_replace("\n",'|',$v);
+# NB 06.04.16 $v = preg_replace('/\n/','',$v);
}
}
- $v = htmlspecialchars($v,$replace_flags,strtoupper(self::$charset));
- if (!$is_scalar and strpos($type,'html') !== false) $v = '<pre>'.NB_EOL.$v.NB_EOL.'</pre>';
+ $v = htmlspecialchars($v,$replace_flags,strtoupper($charset));
return $v;
}
);
#$data = array( array('a'=>'A'), array('b'=>'B'), array('c'=>'C') );
$field = array();
-$o = new Out($argv[2] ? $argv[2] : 'yaml',$data,$field);
+$o = out::rows($argv[2] ? $argv[2] : 'yaml',$data,$field);
?>
<?php
require_once(dirname(__FILE__).'/nb.php');
+require_once(dirname(__FILE__).'/out.php');
/*
if (
!@$_SERVER['DOCUMENT_ROOT'] and (realpath($argv[0]) == __FILE__)
/*
Create
*/
- function __construct($opt = array()) {
+ public function __construct($opt = array()) {
//// opt
foreach ($opt as $k => $v) {
/*
Funtions
*/
- function out($v) {
+ public static function out($v) {
echo $v;
}
- function to_array($v) {
+ public static function to_array($v) {
return (is_array($v) ? $v : array($v));
}
return mb_strtoupper(mb_substr($str,0,1)).mb_strtolower(mb_substr($str,1,mb_strlen($str)));
}
- function js_quote($str) {
+ public static function js_quote($str) {
return "'".str_replace("'","\'",$str)."'";
}
- function ansi2html($v) {
+ public static function ansi2html($v) {
$html = array(
sprintf('%c[1;',27) => sprintf('<bold>%c[0;',27),
);
}
- function str2txt($v) {
+ public static function str2txt($v) {
static $replace_flags = null;
static $charset = null;
if ($replace_flags === null) {
/*
Output
*/
- function begin() {
+ public function begin() {
$this->headers();
return $doctype;
}
- function head() {
+ public function head() {
$head = '';
#$head .= '</head>'.NB_EOL; return $head;
$head .= '<meta name="viewport" content="width=device-width, initial-scale=1" />'.NB_EOL;
- foreach ($this->to_array($this->css) as $v) {
+ foreach (self::to_array($this->css) as $v) {
$head .= '<link type="text/css" rel="stylesheet" href="' . $v . '" />'.NB_EOL;
}