]> git.nbdom.net Git - nb.git/commitdiff
etc/dbs
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 11 Apr 2016 13:16:23 +0000 (14:16 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Mon, 11 Apr 2016 13:16:23 +0000 (14:16 +0100)
etc/dbs/nb.php [new file with mode: 0644]
etc/dbs/postfix.php [new file with mode: 0644]
etc/dbs/puppetdb.php [new file with mode: 0644]
etc/dbs/rent.php [new file with mode: 0644]

diff --git a/etc/dbs/nb.php b/etc/dbs/nb.php
new file mode 100644 (file)
index 0000000..077c144
--- /dev/null
@@ -0,0 +1,8 @@
+<?php
+$CONF['nb'] = array (
+  'host' => 'admin.izideal.vpn',
+  'type' => 'mysql',
+  'name' => 'nb',
+  '_import' => array('_rent','_nico'),
+);
+?>
diff --git a/etc/dbs/postfix.php b/etc/dbs/postfix.php
new file mode 100644 (file)
index 0000000..d07fb0f
--- /dev/null
@@ -0,0 +1,8 @@
+<?php
+$CONF['postfix'] = array (
+  'title' => 'Postfix on Izideal',
+  'type' => 'mysql',
+  'host' => 'media.izideal.vpn',
+  'user' => 'postfix',
+);
+?>
diff --git a/etc/dbs/puppetdb.php b/etc/dbs/puppetdb.php
new file mode 100644 (file)
index 0000000..da64d6d
--- /dev/null
@@ -0,0 +1,25 @@
+<?php
+$CONF['puppetdb'] = array (
+  'title' => 'Puppetdb',
+  'host' => 'big',
+  'type' => 'pgsql',
+  'user' => 'puppetdb',
+  'default_table' => 'view_hosts',
+  'row_parse' => function(&$r) {
+    foreach ($r as $k=>$v) {
+      $r[$k] = preg_replace('/(:\d\d)\.\d+/','\1',$v);
+    }
+  },
+# NB 11.04.16   'tables' => 
+# NB 11.04.16   array (
+# NB 11.04.16     'hosts' => 
+# NB 11.04.16     array (
+# NB 11.04.16       'row_parse_pre' => function(&$r) {
+# NB 11.04.16         foreach ($r as $k=>$v) {
+# NB 11.04.16           $r[$k] = preg_replace('/(:\d\d)\.\d+/','\1',$v);
+# NB 11.04.16         }
+# NB 11.04.16       },
+# NB 11.04.16     ),
+# NB 11.04.16   ),
+);
+?>
diff --git a/etc/dbs/rent.php b/etc/dbs/rent.php
new file mode 100644 (file)
index 0000000..e3311b1
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+$CONF['_rent'] = array (
+  'Title' => 'Rent',
+  'notice' => 'Micro foncier 4BE',
+  'default_table' => 'rent',
+
+  'tables' => array(
+
+    'place' => array(
+      'replace' => array (
+        'id' => 'addr.addr',
+      ),
+    ),
+
+    'rent' => array(
+      'orderby' => 'start desc, end desc',
+
+      'replace' => array (
+        'idtenant' => 'tenant.name',
+        'idplace' => 'addr.addr',
+      ),
+
+      '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'];
+        if (1) $r['rent_year'] = sprintf('%.2f',$r['rent'] * (1 +
+          ( date('m',strtotime($r['end'])) + 12 * date('Y',strtotime($r['end'])) )
+          - 
+          ( date('m',strtotime($r['start'])) + 12 * date('Y',strtotime($r['start'])) )
+        ));
+      },
+
+      'row_parse_post' => ((empty($GLOBALS['Db']) or Db::php_cli()) ? null : function(&$r) {
+        static $templates;
+        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].'&amp;idplace=:idplace&amp;idtenant=:idtenant&amp;start=:start">'.preg_replace('/\.\w+$/','',$t[0]).'</a>';
+          }
+        }
+
+        $r['revision'] = '';
+        foreach ($templates as $t) {
+          $r['revision'] .= preg_replace_callback('/:(\w+)/',function($m) use(&$r) {return $r[$m[1]];},$t).' ';
+        }
+        $r['revision'] = trim($r['revision']);
+
+      }),
+    ),
+
+  ),
+);
+
+$CONF['rent'] = array (
+  'order' => 1,
+  'pdo' => 'sqlite:/opt/rent/rent.db',
+  '_import' => '_rent',
+);
+
+?>