Add denorm_qoh
[order_line_extra.git] / hooks.php
1 <?php
2 // ----------------------------------------------------------------
3 // $ Revision:  1.0 $
4 // Creator: Maxime Bourge
5 // date_:   2013-05-04
6 // Title:   Order Line Extra
7 // Free software under GNU GPL
8 // ----------------------------------------------------------------
9 define ('SS_ORDERLINEX', 100<<8);
10
11 include_once('includes/db_order_lines.inc');
12
13 class hooks_order_line_extra extends hooks {
14         var $module_name = 'order_line_extra';
15
16         /*
17                 Install additonal menu options provided by module
18         */
19     function install_tabs($app) {
20         global $path_to_root;
21
22     }
23
24     function install_options($app) {
25         global $path_to_root;
26                                 switch($app->id) {
27                                         case 'orders':
28                                                 $app->add_rapp_function(0, _('Order Extra'), 
29                                                         $path_to_root.'/modules/order_line_extra/order_lines_view.php', 'SA_SALESTRANSVIEW');
30                                 }
31     }
32
33     function install_access()
34         {
35         $security_sections[SS_ORDERLINEX] =  _("Order Line Extra");
36                 $security_areas['SA_ORDERLINEX_EDIT'] = array(SS_ORDERLINEX|1, _("Edit lines"));
37
38                 return array($security_areas, $security_sections);
39         }
40
41     /* This method is called on extension activation for company.   */
42     function activate_extension($company, $check_only=true)
43     {
44         global $db_connections;
45
46         $updates = array(
47                                                 'alter_sales_order_details.sql' => array('sales_order_details','required_date'),
48                                                 'create_denorm_order_details_queue.sql' => array('denorm_order_details_queue'),
49                                                 'create_denorm_qoh.sql' => array('denorm_qoh'),
50         );
51
52                                 return $this->update_databases($company, $updates, $check_only)
53                                                                 && update_queue_quantities()
54                                                                 && update_qoh_for_item();;
55     }
56
57     function deactivate_extension($company, $check_only=true)
58     {
59         global $db_connections;
60
61         $updates = array(
62             'clean_sales_order_details.sql' => array('ugly_hack') // FIXME: just an ugly hack to clean database on deactivation
63         );
64
65         return $this->update_databases($company, $updates, $check_only);
66     }
67 }
68 ?>