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         $cohead = DB_DataObject::factory('cohead');
17         $cohead->whereAdd("
18             cohead_status != 'X'
19             AND
20             cohead_id = 14462
21         ");
22         $cohead->orderBy('cohead_id DESC');
23         $cohead->find();
24         
25         while ($cohead->fetch()){
26             $co = clone ($cohead);
27             print_r($co);exit;
28             $cobmiscs = $co->cobmiscs();
29             
30             foreach ($cobmiscs as $cobmisc){
31                 $cobapply = DB_DataObject::factory('cobapply');
32                 $cobapply->cobapply_cobmisc_id = $cobmisc->pid();
33                 
34                 if($cobapply->count()){
35                     foreach($cobapply->fetchAll() as $coba){
36                         
37                         $coba->delete();
38                         $coba->void($this);
39                         
40                         $checkitem = DB_DataObject::factory('checkitem');
41                         $checkitem->autoJoin();
42                         $checkitem->checkitem_aropen_id = $coba->cobapply_aropen_id;
43                         $checkitem->whereAdd("
44                             join_checkitem_checkhead_id_checkhead_id.checkhead_posted = TRUE
45                             AND
46                             join_checkitem_checkhead_id_checkhead_id.checkhead_void = FALSE
47                             AND
48                             join_checkitem_checkhead_id_checkhead_id.checkhead_deleted = FALSE
49
50                         ");
51                         
52                         foreach ($checkitem->fetchAll() as $checki){
53                             $checkhead = $checki->checkhead();
54                             $checkhead->voidPostedCheck($this);
55                         }
56                     }
57                 }
58                 
59                 
60             }
61             
62             
63         }
64         
65         exit;
66     }
67     
68         
69 }