Topic: New tab

I would like to add some new tab.
How do i create one new and how do i specify the position ?

barney

Re: New tab

You can take a look at this thread https://frontaccounting.com/punbb/viewtopic.php?id=1869 where evilive trying to create a new extension

Regards, [url=http://captainkuro.com]captain_kuro[/url]

Re: New tab

Very helpful...
thanks, barney

Re: New tab

Still struggling....

What is wrong?
I added a folder 'claim' in modules, then put in hooks.php and travel.php:
hooks.php:
<?php
define ('SS_CL',71<<8);

class claim_app extends application
{
        function claim_app()
        {
                $this->application("claim", _($this->help_context = "&Claim"));

                $this->add_module(_("Claim Application"));
                $this->add_lapp_function(0, _("Sales Travelling Claim"),
                        $path_to_root.'/modules/claim/travel.php', 'SA_CLAPPLY', MENU_CLAIM);

                $this->add_extensions();
        }
}


class hooks_claim extends hooks {
        var $module_name = 'claim'; // extension module name.

        function install_tabs($app) {
                set_ext_domain('modules/claim');        // set text domain for gettext
                $app->add_application(new claim_app); // add menu tab defined by example_class
                set_ext_domain();
        }


        function install_access()
        {
                $security_sections[SS_CL] =     _("Claim");

                $security_areas['SA_CLAPPLY'] = array(SS_CL|1, _("Claim Application"));
                $security_areas['SA_CLCHECK'] = array(SS_CL|2, _("Check Claim"));
                $security_areas['SA_CLAPPROVE'] = array(SS_CL|3, _("Approve Claim"));
                $security_areas['SA_CLPAYMENT'] = array(SS_CL|4, _("Release Payment"));
                $security_areas['SA_CLVIEW'] = array(SS_CL|5, _("View My Claim"));

                return array($security_areas, $security_sections);
        }

}

?>

travel.php:
<?php
/**********************************************
Author: Joe Hunt
Name: Import of CSV formatted customers
Free software under GNU GPL

This module helps to upload a bunch a customers from a csv file.
Modified by Gaston Huot 20100626 to take into account the new security included in version 2.2 and add a few colums:
-Customer short name
-Sales_Group for the branch. In this case you have to specify the id, not the name-despription
***********************************************/
$page_security = 'SA_CLAPPLY';
$path_to_root="../..";

include($path_to_root . "/includes/session.inc");
add_access_extensions();

page("Import of CSV formatted Customers");

include_once($path_to_root . "/includes/ui.inc");
include_once($path_to_root . "/includes/data_checks.inc");

include_once($path_to_root . "/sales/includes/db/branches_db.inc");
include_once($path_to_root . "/sales/includes/db/customers_db.inc");

error_reporting(E_ALL);
ini_set("display_errors", "on");

if (isset($_POST['import']))
{
    if (isset($_FILES['imp']) && $_FILES['imp']['name'] != '')
    {
        $filename = $_FILES['imp']['tmp_name'];
        $sep = $_POST['sep'];

        $fp = @fopen($filename, "r");
        if (!$fp)
            die("can not open file $filename");

        $lines = $i = $j = 0;
        // id; name; short_name; address1; address2; address3; address4; area; sales_group; phone; fax; email; contact; tax_id; currency; tax_group; gruppe; ktoart; mandant; ktotyp; adresse; sammelkto; bebuchbarkeit; EULand; EUWarenbewegung; EUDreiecksgeschaeft; zahlungskond;
        while ($data = fgetcsv($fp, 4096, $sep))
        {
            if ($lines++ == 0)
                continue;
            list($id, $name, $short_name, $addr1, $addr2, $addr3, $addr4, $area, $sales_group, $phone, $fax, $email, $contact, $tax_id, $currency, $tax_group, $gruppe, $ktoart, $mandant, $ktotyp, $adresse, $sammelkto, $bebuchbarkeit, $euland, $euwarenbewegung, $eudreiecksgeschaeft, $zahlungskond) = $data;
            $name = db_escape($name);
            $short_name= db_escape($short_name);
            $addr = "";
            if ($addr1 != "")
                $addr .= "$addr1\n";
            if ($addr2 != "")
                $addr .= "$addr2\n";
            if ($addr3 != "")
                $addr .= "$addr3\n";
            if ($addr4 != "")
                $addr .= "$addr4\n";
            $addr = db_escape($addr);
            $sql = "SELECT area_code, description FROM ".TB_PREF."areas WHERE description='$area'";

            $result = db_query($sql, "could not get area");

            $row = db_fetch_row($result);
            if (!$row)
            {
                $sql = "INSERT INTO ".TB_PREF."areas (description) VALUES ('$area')";
                db_query($sql,"The sales area could not be added");
                $area_code = db_insert_id();
            }
            else
                $area_code = $row[0];
            if ($currency == "")
                $currency = get_company_pref("curr_default");
            else
            {
                $row = get_currency($currency);
                if (!$row)
                    add_currency($currency, "", "", "", "");
            }
            $taxgid = "";
            if ($tax_group != "") {
                $sql = "select id from ".TB_PREF."tax_groups WHERE name='".$tax_group."'";
                $result = db_query($sql, "Non Taxable Group");
                $row = db_fetch_row($result);
                if ($row) $taxgid = $row[0];
            }
            if ($taxgid == "") $taxgid = $_POST['tax_group_id'];
            if ($id != "")
                $sql = "SELECT debtor_no FROM ".TB_PREF."debtors_master WHERE debtor_no=$id";
            else
                $sql = "SELECT debtor_no FROM ".TB_PREF."debtors_master WHERE name=$name";
            $result = db_query($sql,"customer could not be retreived");
            $row = db_fetch_row($result);
            if (!$row)
            {
                if ($id != "")
                {
                    $sql = "INSERT INTO ".TB_PREF."debtors_master (debtor_no, name, debtor_ref, address, email,
                        tax_id, curr_code, sales_type, payment_terms, credit_status, zahlungskond)
                        VALUES ($id, $name, $short_name, $addr, '$email', '$tax_id', '$currency', {$_POST['sales_type']},
                        {$_POST['payment_terms']}, 1, $zahlungskond)";
                }
                else
                {
                    $sql = "INSERT INTO ".TB_PREF."debtors_master (name, debtor_ref, address, email,
                        tax_id, curr_code, sales_type, payment_terms, credit_status, zahlungskond)
                        VALUES ($name, $short_name , $addr, '$email', '$tax_id', '$currency', {$_POST['sales_type']},
                        {$_POST['payment_terms']}, 1, $zahlungskond)";
                }
                // print $sql . "<br>/n";
                db_query($sql, "The customer could not be added");
                if ($id == "")
                    $id = db_insert_id();
                $sql = "INSERT INTO ".TB_PREF."cust_branch (debtor_no, br_name, branch_ref, br_address, area, salesman, group_no,
                    phone, fax, contact_name, email, default_location, tax_group_id, sales_account,
                    sales_discount_account, receivables_account, payment_discount_account, br_post_address)
                    VALUES ($id, $name, $short_name, $addr, '$area_code', '{$_POST['salesman']}', '$sales_group', '$phone', '$fax',
                    '$contact', '$email', '{$_POST['default_location']}', $taxgid, '{$_POST['sales_account']}',
                    '{$_POST['sales_discount_account']}', '{$_POST['receivables_account']}',
                    '{$_POST['payment_discount_account']}', $addr)";
                // print $sql . "<br>/n";
                db_query($sql, "The customer branch could not be added");

                $i++;
            }
            else
            {
                $sql = "UPDATE ".TB_PREF."debtors_master
      SET address=$addr,
                    email='$email',
                    tax_id='$tax_id',
                    debtor_ref=$short_name,
                    curr_code='$currency',
                    sales_type={$_POST['sales_type']},
                    payment_terms={$_POST['payment_terms']},
                    zahlungskond='$zahlungskond'
                    WHERE name=$name";

                // print $sql . "<br>/n";
                db_query($sql, "The customer could not be updated");

                $j++;
            }
        }
        @fclose($fp);

        display_notification("$i customer posts created, $j customer posts updated.");

    }
    else
        display_error("No CSV file selected");
}

start_form(true);

start_table(TABLESTYLE2, "width=40%");
   
table_section_title("Default GL Accounts");

$company_record = get_company_prefs();

if (!isset($_POST['sales_account']) || $_POST['sales_account'] == "")
       $_POST['sales_account'] = $company_record["default_sales_act"];

if (!isset($_POST['sales_discount_account']) || $_POST['sales_discount_account'] == "")
       $_POST['sales_discount_account'] = $company_record["default_sales_discount_act"];

if (!isset($_POST['receivables_account']) || $_POST['receivables_account'] == "")
    $_POST['receivables_account'] = $company_record["debtors_act"];

if (!isset($_POST['payment_discount_account']) || $_POST['payment_discount_account'] == "")
    $_POST['payment_discount_account'] = $company_record["default_prompt_payment_act"];

if (!isset($_POST['sep']))
    $_POST['sep'] = ";";

gl_all_accounts_list_row("Sales Account:", 'sales_account', $_POST['sales_account']);
gl_all_accounts_list_row("Sales Discount Account:", 'sales_discount_account', $_POST['sales_discount_account']);
gl_all_accounts_list_row("Receivables Account:", 'receivables_account', $_POST['receivables_account']);
gl_all_accounts_list_row("Payment Discount Account:", 'payment_discount_account', $_POST['payment_discount_account']);

table_section_title("Separator, Location, Tax Type, Sales Type, Sales Person and Payment Terms");
text_row("Field separator:", 'sep', $_POST['sep'], 2, 1);
locations_list_row("Location:", 'default_location', null);
// This was a bug. Wrong Tax list - Tax Location not Item Tax Types
//item_tax_types_list_row("Item Tax Type:", 'tax_group_id', null);
tax_groups_list_row(_("Default Tax Group:"), 'tax_group_id', null);
sales_types_list_row("Sales Type:", 'sales_type', null);
sales_persons_list_row("Sales Person", 'salesman', null);
payment_terms_list_row("Payment Terms", 'payment_terms', null);
label_row("CSV Import File:", "<input type='file' id='imp' name='imp'>");

end_table(1);

submit_center('import', "Import CSV File");

end_form();

end_page();

?>


Then i installed the extension, made it active, but no success: Nothing can't be seen....    sad


Any idea?
barney

Re: New tab

Files looks roughly right. You have to install and activate the extension for every company you want via Install/Activate Extensions.
Janusz

Re: New tab

have you enable the access for your logged in account for this extension?
for example if you are logging in as "admin" which means the role System Administrator, you have to open Access Setup menu and enable all priviledges of Claim extension for the role System Administration.
After you enable them, logout and login again to see whether you can see anything now.

Regards, [url=http://captainkuro.com]captain_kuro[/url]

Re: New tab

Well, I adapted installed_extensions.php:
----------------------------------------
  43 =>
  array (
    'package' => 'claim',
    'name' => 'claim',
    'version' => '2.3.4',
    'type' => 'extension',
    'active' => true,
    'path' => 'modules/claim',
  ),
----------------------------------------
Wrong, right, necessary??
But the claim extension never shows in the privileges part of system administration??? 
Hmm??  sad
barney

Re: New tab

@ captain_kuro:
Well, the extension shows now in system administratin, after adding security codes in access_levels.inc.
I thought, install_acess in hooks.php would do this for me. Unfortunately not. Maybe that's the reason, because no tab is added?!?!
Is there a way to see what happens during installation of an extension, i mean beside debugging??
barney

Re: New tab

have you followed itronics advice? have you made sure claim extension is active for the current company?

kuro

Regards, [url=http://captainkuro.com]captain_kuro[/url]

Re: New tab

Where do i activate the extension for the current company?
barneyfa

Re: New tab

Setup > Install/Activate extensions > Choose the company desired in select box above

kuro

Regards, [url=http://captainkuro.com]captain_kuro[/url]

Re: New tab

Thksalotlancelot!!!

Thats it. Great  smile and of course: my fault. sad

Thks again,
barney

Re: New tab

Am also going through this problem and I don't seem to get it fixed, I have no idea what am doing wrongly, I have scoured the forums and can't figure out. Am trying to install new Human Resource tab and here is my code

<?php
define ('SS_HR',102<<8);

class human_resource extends application
{
        function human_resource()
        {
                global $path_to_root;
               
           
                $this->application("hr", _($this->help_context = "&Human Resource"));

                $this->add_module(_("Human Resource"));
                $this->add_lapp_function(0, _("Staff"),
                        $path_to_root.'/modules/human_resource/staff.php', 'SA_STAFF');
               

                $this->add_module(_("Payroll Management"));
                $this->add_lapp_function(1, _("Payroll Management"),
                        $path_to_root.'/modules/human_resource/payroll.php', 'SA_PAYROLL');
               

                $this->add_extensions();
        }
}


class hooks_hr extends hooks {
        var $module_name = 'human_resource'; // extension module name.

        function install_tabs($app) {
                set_ext_domain('modules/human_resource');        // set text domain for gettext
                $app->add_application(new human_resource); // add menu tab defined by example_class
                set_ext_domain();
        }


        function install_access()
        {
                $security_sections[SS_HR] = _("Human Resource");

                $security_areas['SA_HR'] = array(SS_HR|1, _("Human Resource"));
                $security_areas['SA_PR'] = array(SS_HR|2, _("Payroll"));
               
                return array($security_areas, $security_sections);
        }

}

?>

Re: New tab

As far as I remember:
Check installed_extensions.php and
check access setup (privileges).

barney