DatabaseColumns.php
[Pman.Core] / DatabaseColumns.php
1 <?php
2
3 require_once 'Pman.php';
4
5 class Pman_Core_DatabaseColumns extends Pman {
6     
7     
8     function getAuth()
9     {
10         parent::getAuth(); // load company!
11         $au = $this->getAuthUser();
12        
13         if (!$au) {  
14             $this->jerr("Not authenticated", array('authFailure' => true));
15         }
16         if (!$au->pid()   ) { // not set up yet..
17             $this->jerr("Not authenticated", array('authFailure' => true));
18         }
19         
20         
21         $this->authUser = $au;
22         return true;
23     }
24     
25     function get($table) {
26         $d = DB_DAtaObject::Factory($table);
27         $re = $d->autoJoin();
28         //echo '<PRE>';print_r($re);
29         $ret = array ();
30         
31         foreach($re['join_names'] as $c=>$f) {
32             $re['cols'][$c] = $f;
33         }
34         
35         
36         foreach($re['cols'] as $c=>$f) {
37             $ret[]  = array(
38                 'name' => $c,
39                 'val' => $f
40             );
41             
42         }
43         
44         
45         require_once 'Pman/Core/SimpleExcel.php';
46         $x = new Pman_Core_SimpleExcel(
47             array($bt,$et, $ut), array(
48             'formats' => array(
49                 'vtop' => array('vAlign' => 'top'),
50                 'vcenter' => array('vAlign' => 'vcenter'),
51                 
52                 'percent' => array('vAlign' => 'vcenter', 'numFormat' => '0%'),
53                 'money' => array('vAlign' => 'vcenter', 'numFormat' => '$#,###'),
54                 'date' => array('vAlign' => 'vcenter', 'numFormat' => 'd/M/Y'),
55             ),
56             'workbooks' => array(
57                 array(
58                     'workbook' => 'Business',
59                     'cols' => explode('|', 'keyIdentity_taxId|description|type|countryIso3|countryRegion|addr1|addr2|addr3|city|zip')
60                 ),
61                 array(
62                     'workbook' => 'Employment',
63                     'cols' => explode('|', 'emailAddress|identity_taxId')
64                 ),
65                 array(
66                     'workbook' => 'Users',
67                     'cols' => explode('|', 'generateLogin|firstName|middleName|lastName|emailAddress|locale|countryIso3|countryRegion|addr1|addr2|addr3|city|zip|userStatus')
68                 ),
69             )
70             
71         ));
72         $x->send('test_'. date('d_M_Y').'.xls');
73         $this->jdata($ret);
74         
75         
76     }
77 }