VoidSalesAndPurchaseOrders.php
[Pman.Xtuple] / VoidSalesAndPurchaseOrders.php
1 <?php
2 require_once 'Pman/Roo.php';
3
4 class Pman_Xtuple_VoidSalesAndPurchaseOrders extends Pman_Roo
5 {   
6     function getAuth()
7     {
8         if (HTML_FlexyFramework::get()->cli) {
9             return false;
10         }
11         return parent::getAuth();
12     }
13    
14     function get()
15     {
16         $this->transObj = DB_DataObject::Factory('cohead');
17         
18         $this->transObj->query('BEGIN');
19         
20         PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array($this, 'onPearError'));
21         
22         $cohead = DB_DataObject::factory('cohead');
23         $cohead->whereAdd("
24             cohead_status != 'X'
25             AND
26             cohead_id = 14462
27         ");
28         $cohead->orderBy('cohead_id DESC');
29         $cohead->find();
30         
31         while ($cohead->fetch()){
32             $co = clone ($cohead);
33             
34             $cobmiscs = $co->cobmiscs();
35             
36             foreach ($cobmiscs as $cobmisc){
37                 $cobapply = DB_DataObject::factory('cobapply');
38                 $cobapply->cobapply_cobmisc_id = $cobmisc->pid();
39                 
40                 if($cobapply->count()){
41                     
42                     foreach($cobapply->fetchAll() as $coba){
43                         
44                         $coba->delete();
45                         $coba->void($this);
46                         
47                         $checkitem = DB_DataObject::factory('checkitem');
48                         $checkitem->autoJoin();
49                         $checkitem->checkitem_aropen_id = $coba->cobapply_aropen_id;
50                         print_r($checkitem->fetchAll());exit;
51                         $checkitem->whereAdd("
52                             join_checkitem_checkhead_id_checkhead_id.checkhead_posted = TRUE
53                             AND
54                             join_checkitem_checkhead_id_checkhead_id.checkhead_void = FALSE
55                             AND
56                             join_checkitem_checkhead_id_checkhead_id.checkhead_deleted = FALSE
57
58                         ");
59                         print_r($checkitem->fetchAll());exit;
60                         foreach ($checkitem->fetchAll() as $checki){
61                             $checkhead = $checki->checkhead();
62                             $checkhead->voidPostedCheck($this);
63                         }
64                     }
65                 }
66                 
67                 
68             }
69             
70             
71         }
72         $this->jerr('ROLL BACK');
73         exit;
74     }
75     
76         
77 }