<?php
/*=======================================================\
|                        Church                          |
|--------------------------------------------------------|
\=======================================================*/ 
define ('SS_CHURCH', 251<<8);

class Church_app extends application {
	
    function __construct() {
        global $path_to_root;
        
       parent::__construct("church", _($this->help_context = "church"));
        
        $this->add_module(_("Transactions"));
        $this->add_lapp_function(0, _('Add Project'), $path_to_root.'/modules/kanban/manage/add_project.php?', 'SA_PROJ_MANAGER', MENU_TRANSACTION);
		$this->add_lapp_function(0, _('Add Group Targets'), $path_to_root.'/modules/church/manage/addprojecttargets.php', 'SA_GRP_TARGET', MENU_TRANSACTION);
		$this->add_lapp_function(0, _('Add Member Pledges'), $path_to_root.'/modules/church/manage/addcontributions.php?type=81', 'SA_MMBR_CONT', MENU_TRANSACTION);
		$this->add_lapp_function(0, _('Add Member Contribution'), $path_to_root.'/modules/church/manage/addcontributions.php?type=80', 'SA_MMBR_CONT', MENU_TRANSACTION);
		$this->add_rapp_function(0, _('Member SMS'), $path_to_root.'/modules/church/manage/membersms.php', 'SA_MMBR_SMS', MENU_TRANSACTION);
		$this->add_rapp_function(0, _('SMS Balance'), $path_to_root.'/modules/church/manage/sms_balance.php', 'SA_MMBR_SMS', MENU_TRANSACTION);
   
        $this->add_module(_("Inquiries and Reports"));
		$this->add_lapp_function(1, _('Projects List'), $path_to_root.'/modules/kanban/manage/projects.php?', 'SA_PROJ_MANAGER', MENU_INQUIRY);
                $this->add_lapp_function(1, _('Group Targets'), $path_to_root.'/modules/church/manage/grouptargets.php?', 'SA_GRP_TARGET', MENU_INQUIRY);
                $this->add_lapp_function(1, _('Member Transactions'), $path_to_root.'/modules/church/manage/membertransactions.php?', 'SA_MMBR_CONT', MENU_INQUIRY);
                $this->add_rapp_function(1, _('Member &Reports'), $path_to_root.'/reporting/reports_main.php?Class=11', 'SA_MMBR_CONT', MENU_REPORT);
        
        $this->add_module(_("Maintenance"));
		$this->add_lapp_function(2, _('Members'), $path_to_root.'/modules/church/manage/member.php', 'SA_MMBR', MENU_ENTRY);
		$this->add_lapp_function(2, _('Import Members CSV'), $path_to_root.'/modules/church/manage/import_members.php', 'SA_MMBR', MENU_ENTRY);
		$this->add_lapp_function(2, _('Groups'), $path_to_root.'/modules/church/manage/group.php', 'SA_MMBR_GRP', MENU_ENTRY);
		$this->add_rapp_function(2, _('Setup'), $path_to_root.'/modules/church/manage/church_setup.php', 'SA_MMBR_GRP', MENU_ENTRY);
		
        	
		$this->add_extensions();
    }
}

class hooks_Church extends hooks {
    function __construct() {
 		$this->module_name = 'church';
 	}
    
    function install_tabs($app) {
        $app->add_application(new Church_app);
    }
    
    function install_access() {
        $security_sections[SS_CHURCH] =  _("church");
        $security_areas['SA_MMBR'] = array(SS_CHURCH|1, _("MEMBER ENTRY"));
        $security_areas['SA_MMBRTR'] = array(SS_CHURCH|1, _("Member Transactions"));
        $security_areas['SA_MMBR_GRP'] = array(SS_CHURCH|1, _("Member Groups"));
        $security_areas['SA_PROJ_MANAGER'] = array(SS_CHURCH|1, _("Mamage Projects"));
        $security_areas['SA_GRP_TARGET'] = array(SS_CHURCH|1, _("Mamage Group Targets"));
        $security_areas['SA_MMBR_CONT'] = array(SS_CHURCH|1, _("Member Contributions"));
        $security_areas['SA_MMBR_SMS'] = array(SS_CHURCH|1, _("Member SMS"));
        return array($security_areas, $security_sections);
    }
    
    function activate_extension($company, $check_only=true) {
        global $db_connections;
        
        $updates = array( 'update.sql' => array(''));
 
        return $this->update_databases($company, $updates, $check_only);
    }
	
    function deactivate_extension($company, $check_only=true) {
        global $db_connections;

        $updates = array('remove.sql' => array(''));

        return $this->update_databases($company, $updates, $check_only);
    }
}
