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             
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                     
36                     foreach($cobapply->fetchAll() as $coba){
37                         print_r($coba);exit;
38                         $coba->delete();
39                         $coba->void($this);
40                         
41                         $checkitem = DB_DataObject::factory('checkitem');
42                         $checkitem->autoJoin();
43                         $checkitem->checkitem_aropen_id = $coba->cobapply_aropen_id;
44                         $checkitem->whereAdd("
45                             join_checkitem_checkhead_id_checkhead_id.checkhead_posted = TRUE
46                             AND
47                             join_checkitem_checkhead_id_checkhead_id.checkhead_void = FALSE
48                             AND
49                             join_checkitem_checkhead_id_checkhead_id.checkhead_deleted = FALSE
50
51                         ");
52                         
53                         foreach ($checkitem->fetchAll() as $checki){
54                             $checkhead = $checki->checkhead();
55                             $checkhead->voidPostedCheck($this);
56                         }
57                     }
58                 }
59                 
60                 
61             }
62             
63             
64         }
65         
66         exit;
67     }
68     
69         
70 }