id) { case 'orders': $app->add_rapp_function(0, _('Order Extra'), $path_to_root.'/modules/order_line_extra/order_lines_view.php', 'SA_SALESTRANSVIEW'); } } function install_access() { $security_sections[SS_ORDERLINEX] = _("Order Line Extra"); $security_areas['SA_ORDERLINEX_EDIT'] = array(SS_ORDERLINEX|1, _("Edit lines")); return array($security_areas, $security_sections); } /* This method is called on extension activation for company. */ function activate_extension($company, $check_only=true) { global $db_connections; $updates = array( 'alter_sales_order_details.sql' => array('sales_order_details','required_date'), 'create_denorm_order_details_queue.sql' => array('denorm_order_details_queue'), 'create_denorm_qoh.sql' => array('denorm_qoh'), 'create_order_summary_view.sql' => array('order_summary_view'), ); return $this->update_databases($company, $updates, $check_only) && update_queue_quantities() && update_qoh_for_item();; } function deactivate_extension($company, $check_only=true) { global $db_connections; $updates = array( 'clean_sales_order_details.sql' => array('ugly_hack') // FIXME: just an ugly hack to clean database on deactivation ); return $this->update_databases($company, $updates, $check_only); } function get_allowed_quantity($detail_id, $opts) { $location = array_shift($opts); $date = array_shift($opts); $qoh = array_shift($opts); $sql = "select quantity_before from ".TB_PREF."denorm_order_details_queue where id = $detail_id"; $result = db_query($sql); $quantity_before = 0; if($row=db_fetch($result)) { $quantity_before = $row['quantity_before']; } return max($qoh - $quantity_before, 0); } } ?>