Fix #7123 - getting abra ready to test
[Pman.Xtuple] / Import / Report.php
1 <?php
2
3
4 require_once 'Pman/Roo.php';
5
6 class Pman_Xtuple_Import_Report extends Pman_Roo
7 {
8     
9     /**
10      *  get .. same as roo... 
11      * 
12      */
13     
14     function getAuth()
15     {
16         if (HTML_FlexyFramework::get()->cli) {
17             return true;
18         }
19         return parent::getAuth();
20     }
21     
22     
23     function get()
24     {
25         PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this, 'onPearError'));
26
27         //DB_DataObject::DebugLevel(1);
28
29        $this->jerr('not suppoprted');
30     }
31     
32     
33     function post( )
34     {
35         PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this, 'onPearError'));
36        // DB_DAtaObject::debugLevel(1);
37         $this->sessionState(0); // turn off the session..
38         
39         $img = DB_DataObject::Factory('images');
40         $img->setFrom(array(
41             'onid' => 0,
42             'ontable' => 'report'
43         ));
44         $img->onUpload(false);
45          
46         $fc = file_get_contents($img->getStoreName());
47         $rep = DB_DataObject::Factory('report');
48         $rep->get($_REQUEST['onid']);
49         
50         $mrep = DB_DataObject::Factory('report');
51         $mrep->report_name  = $rep->report_name;
52         $mrep->orderBy('report_grade DESC');
53         $mrep->limit(1);
54         $mrep->find(true);
55         
56         $nrep=  DB_DataObject::Factory('report');
57         $nrep->setFrom($mrep->toArray());
58         $nrep->report_source = $fc;
59         $nrep->report_grade = $mrep->report_grade + 1;
60         $nrep->report_loaddate = $nrep->sqlValue('NOW()');
61         $id =  $nrep->insert();
62         $this->addEvent('REPORTUP', $nrep, $nrep->report_name . ' uploaded');
63         $this->jok($id);
64         
65         
66          
67     }
68
69 }