1

(17 replies, posted in FA Modifications)

I dont see what's wrong, your data are stored normally with no loss and you're able to follow all transactions correctly.
if you really need to manage begin, commit and rollback here's a beginning of the answer:

http://stackoverflow.com/questions/9584833/mysql-autoincrement-value-jumps-by-2-when-i-add-a-transcaction-im-my-php-code

check the last answer.

2

(9 replies, posted in Wish List)

Checking the db_query() function shows that its returns false on an error. So use the return status. It will return false if it fails, which you can log (or whatever you want to do) and then continue.

$result_a = db_query($sqla);
$result_b = db_query($sqlb);
$result_Cb = db_query($sqlCb);

if ( $result_a && $result_b && $result_Cb ) {
                db_query("COMMIT");
                echo display_notification_centered(_("Database transaction was successful."));
            } else {       
                db_query("ROLLBACK");
               echo display_notification_centered(_("transaction rolled back"));
                exit;
            }

3

(3 replies, posted in Announcements)

we're using it as our lead erp product for our clients (small and medium business).
Implementing, developping modules and adapting it to the context of our customers.
And so far, people are satisfied.

4

(1 replies, posted in Wish List)

i would like to know if there is a project to create a report manager in FA.
The way reports are managed is a somehow limitative. A report manager allow the user  to create and adapt the report to their needs.
thanx

5

(6 replies, posted in Translations)

there is a lot of spanish version (chili, mexico, etc )
which one are you talking about?

hay varios versiónes en español (chile, México, etc), de que estás hablando?
revise este enlace:  https://github.com/apmuthu/frontaccounting/tree/master/extensions/Languages

nothing is difficult if you keep trying. i just started php a couple of months ago, and i'm still learning ....

for extension i download the sources from the git repository. Usually you'll find in the folder extension  a hooks.php which redefine functions from hooks.inc.
each function is used to process a certain task during the installation.
for example:   

function install_tabs($app) {
// $app->add_application(new example_class); // add menu tab defined by example_class
    }

all the functions are well documented, sometimes with code example.
well, the trick is to copy files where needed, copy code where needed, execute sql, add access rights ..... etc.
i still don't master all process,  sometimes i need to go through debugging process to find what's wrong. that's it.
hope this help

8

(2 replies, posted in FA Modifications)

you need to add a new module:
-define a new class that inherits from application in the applications folder.
- import that class in the frontaccounting.php and add a line :

        $this->applications = array();
//line to add under
        $this->add_application(new new_module_app());

this should do the trick, the position of your tab depends on which line you added your module.
you also need to redefine add_module(), add_lapp_function() and >add_rapp_function() in ordre to show blocks and links in your module.
define also the access levels for your pages in access_levels.inc (includes folder).

for themes : just unzipped the archive and drop it in the themes folder, they'll appear in the theme combobox.
for languages, you can either install it manually using the FA wizard for that : see install manually, you'll need to download the xx_XX.po and xx_XX.mo. the wizard is pretty straithforward.; or you can create a xx_XX folder under the lang folder, then copy the po and .mo file. you need to set some modifications in installed_languages.inc, there is a template you can follow.
the extension: it's more tricky. i'll send a more detailled post tomorow (i hope) for the extension installation.

check the access rights, or change $go_debug = 2 (config.php) and post results.

11

(1 replies, posted in Accounts Receivable)

something like this, i think at the beginning of the page:

     if (strlen($_POST['dimension']) == '') 
    {
        $input_error = 1;
        display_error( _("The dimension name must be entered."));        
        set_focus('dimension');
    }

if you want to force the user to choose a specific value  in particular, the best way is to use hidden or an output field where the user can't modify it.

i had the same pb, at the end  i gave up. i just installed anything i need manually.

13

(4 replies, posted in Wish List)

you just need to read the code , the first 50 lines;

if (isset($_GET['ModifyOrderNumber']) && is_numeric($_GET['ModifyOrderNumber'])) {

    $_SESSION['page_title'] = _($help_context = "Modify Purchase Order #") . $_GET['ModifyOrderNumber'];
    create_new_po(ST_PURCHORDER, $_GET['ModifyOrderNumber']);
    copy_from_cart();
} elseif (isset($_GET['NewOrder'])) {

    $_SESSION['page_title'] = _($help_context = "Purchase Order Entry");
    create_new_po(ST_PURCHORDER, 0);
    copy_from_cart();
} elseif (isset($_GET['NewGRN'])) {

    $_SESSION['page_title'] = _($help_context = "Direct GRN Entry");
    create_new_po(ST_SUPPRECEIVE, 0);
    copy_from_cart();
} elseif (isset($_GET['NewInvoice'])) {

    $_SESSION['page_title'] = _($help_context = "Direct Purchase Invoice Entry");
    create_new_po(ST_SUPPINVOICE, 0);
    copy_from_cart();
}

it's a pattern-like: isset($_GET['NewOrder']) tests what is sent next to the url po_entry_items.php?NewInvoice,
if it's true, the code calls the function create_new_po(ST_SUPPINVOICE, 0); which create a purch_order object (see po_class.inc). this class can define three type : order/grn/invoice by changing the $trans_type value.
ST_SUPPINVOICE is defined at the beginning (see set_page_security).
the object display is handled by display_po_items() and display_po_header() which display the $_SESSION['PO'] or $cart based on the value of $trans_type.

ps: @FA_developpers, please use braces when using "if () statement", i have  a hard time reading the code.....

14

(17 replies, posted in FA Modifications)

Obviously pdo wins. but since, i'm a java developer it's hard for me to talk about poo while there is no item class, account class and so on.
if i was to implement an orm in FA, i would certainly rewrite all xxxxx_db.inc and use a lot of pojo-like object to handle data in a more appropriate way.
i dont know if this is relevant in php (i'm still a newbie: couple of mounths since i've started php), but until there is a significant upgrade to FA core, using mysqli is just fine by me.
here is the last update to my connect_db.inc (with no DB_escape_string() this time):

<?php

/*
 * using mysqli_connect instead of mysql_connect
 */

function set_global_connection($company = -1) {
    global $db, $transaction_level, $db_connections;

    cancel_transaction();
    // cancel all aborted transactions if any
    $transaction_level = 0;

    if ($company == -1) {
        $company = $_SESSION["wa_current_user"]->company;
    }

    $_SESSION["wa_current_user"]->cur_con = $company;

    $connection = $db_connections[$company];
    $db = mysqli_connect($connection["host"], $connection["dbuser"], $connection["dbpassword"]);
    mysqli_select_db($db, $connection["dbname"]);
    return $db;
}

$db_duplicate_error_code = 1062;

//DB wrapper functions to change only once for whole application

function db_query($sql, $err_msg = null) {
    global $db, $show_sql, $sql_trail, $select_trail, $go_debug, $sql_queries, $Ajax, $db_connections, $db_last_inserted_id;

    // set current db prefix
    $cur_prefix = $db_connections[$_SESSION["wa_current_user"]->cur_con]['tbpref'];
    $sql = str_replace(TB_PREF, $cur_prefix, $sql);

    if ($show_sql) {
        $Ajax->activate('footer_debug');
        $sql_queries .= "<pre>$sql</pre>\n<hr>";
    }

    $result = mysqli_query($db, $sql);

    if ($sql_trail) {
        $db_last_inserted_id = mysqli_insert_id($db);
        // preserve in case trail insert is done
        if ($select_trail || (strstr($sql, 'SELECT') === false)) {
            mysqli_query($db, "INSERT INTO " . $cur_prefix . "sql_trail
                (`sql`, `result`, `msg`)
                VALUES(" . db_escape($sql) . "," . ($result ? 1 : 0) . ",
                " . db_escape($err_msg) . ")");
        }
    }

    if ($err_msg != null || $go_debug) {
        $exit = $err_msg != null;
        if (function_exists('xdebug_call_file'))
            check_db_error('<br>At file ' . xdebug_call_file() . ':' . xdebug_call_line() . ':<br>' . $err_msg, $sql, $exit);
        else
            check_db_error($err_msg, $sql, $exit);
    }
    return $result;
}

function db_fetch_row($result) {
    return mysqli_fetch_row($result);
}

function db_fetch_assoc($result) {
    return mysqli_fetch_assoc($result);
}

function db_fetch($result) {
    return mysqli_fetch_array($result);
}

function db_seek(&$result, $record) {
    return mysqli_data_seek($result, $record);
}

function db_free_result($result) {
    if ($result) {
        mysqli_free_result($result);
    }
}

function db_num_rows($result) {
    return mysqli_num_rows($result);
}

function db_num_fields($result) {
    return mysqli_num_fields($result);
}

function db_escape($value = "", $nullify = false) {
    global $db;
    $value = @html_entity_decode($value, ENT_QUOTES, $_SESSION['language']->encoding);
    $value = @htmlspecialchars($value, ENT_QUOTES, $_SESSION['language']->encoding);

    //reset default if second parameter is skipped
    $nullify = ($nullify === null) ? (false) : ($nullify);

    //check for null/unset/empty strings
    if ((!isset($value)) || (is_null($value)) || ($value === "")) {
        $value = ($nullify) ? ("NULL") : ("''");
    } else {
        if (is_string($value)) {

            $value = "'" . mysqli_real_escape_string($db, $value) . "'";
        } else if (!is_numeric($value)) {
            //value is not a string nor numeric
            display_error("ERROR: incorrect data type send to sql query");
            echo '<br><br>';
            exit();
        }
    }
    return $value;
}

function db_error_no() {
    return mysqli_connect_errno();
}

function db_error_msg($db) {
    return mysqli_error($db);
}

function db_insert_id() {
    global $db_last_inserted_id, $sql_trail, $db;
    return $sql_trail ? $db_last_inserted_id : mysqli_insert_id($db);
}

function db_num_affected_rows() {
    global $db;
    return mysqli_affected_rows($db);
}

function db_field_name($result, $n) {
    //return mysqli_field_name($result, $n);
    $fieldinfo = mysqli_fetch_field_direct($result, $n);
    return $fieldinfo->name;
}

function db_create_db($connection) {
    $db = mysqli_connect($connection["host"], $connection["dbuser"], $connection["dbpassword"]);
    if (!mysqli_select_db($db, $connection["dbname"])) {
        $sql = "CREATE DATABASE IF NOT EXISTS " . $connection["dbname"] . "";
        if (!mysqli_query($db, $sql) || !mysqli_select_db($db, $connection["dbname"])) {
            return 0;
        }
    }
    return $db;
}

function db_drop_db($connection) {

    if ($connection["tbpref"] == "") {
        $sql = "DROP DATABASE IF EXISTS " . $connection["dbname"] . "";
        return mysqli_query($db, $sql);
    } else {
        $res = db_query("show table status");
        $all_tables = array();
        while ($row = db_fetch($res)) {
            $all_tables[] = $row;
        }
        // get table structures
        foreach ($all_tables as $table) {
            if (strpos($table['Name'], $connection["tbpref"]) === 0) {
                db_query("DROP TABLE `" . $table['Name'] . "`");
            }
        }
        //deleting the tables, how??
        return true;
    }
}

function db_close($dbase = null) {
    global $db;

    if (!$dbase) {
        $dbase = $db;
    }
    return mysqli_close($dbase);
}

?>

15

(17 replies, posted in FA Modifications)

i was experiencing some bug while saving non utf8 strings, after some tests i modified the DB_escape_string :

 
function DB_escape_string($String) {
    global $db;
//    return mysqli_real_escape_string($db, htmlspecialchars($String, ENT_COMPAT, 'utf-8', false));
    return mysqli_real_escape_string($db, $String);
}

16

(4 replies, posted in Wish List)

sorry i didnt understand your question? can you be more explicite?
what section you dont undrestand? what's your objective? what do you intend to do?

17

(4 replies, posted in Wish List)

well, we haven't made a choice on what tool to use yet. and i don't think it will be of great intrest since we're making modification to FA and our wiki will be most likely written in french and arabic (perhaps also in spanish : still in dicussion).
i'll make the translation to english and try to adpat it to the original FA if this could help, thus said it'll take me some time so be patient....

18

(2 replies, posted in Setup)

check in the database for you login/pwd. to verify your pwd you can reverse the encryption. i believe FA uses MD5, there is a plenty of tools for that purpose (http://www.md5rainbow.com).
if you still have the same probleme, change $go_debug to 2 and post results

19

(1 replies, posted in Report Bugs here)

i dont see what's wrong.
&# 039;  stands for an apostrophe, it's normal for sql query to use apostrophe.
executed in php your query will provide something like :
INSERT INTO 2_sales_orders (order_no, type, debtor_no, trans_type, branch_code, customer_ref, reference, comments, ord_date, order_type, ship_via, deliver_to, delivery_address, contact_phone, freight_cost, from_stk_loc, delivery_date, payment_terms, total) VALUES ('50','0','2', '30','3', '','auto','','2013-11-19', '1', '1','Ventas Al Contado','Km. 15.5 Carretera a Masaya.', '55555555', '0', 'DEF', '2013-11-19','5','2300').
as long as there is no error in the execution  of your erp, that should be fine.
you'r talking about x_sql_trail, it's used to store all executed queries, for audit or tracking purposes. if you see it as an issue, you can always modify  the function db_query($sql, $err_msg = null) (connect_db.php) to force using an apostrophe instead of   &# 039;

20

(2 replies, posted in FA Modifications)

check this topic :
https://frontaccounting.com/punbb/viewtopic.php?id=1778

21

(4 replies, posted in Announcements)

i got the same message error!
is it a private repository? do i need to use my login&pass?

22

(17 replies, posted in FA Modifications)

ostertagi@yahoo.fr

23

(4 replies, posted in Wish List)

yes, i already know that.
our objective was to limit the access outside our site for security reasons. i guess we'll make our own wiki from scratsh.
thanx

24

(4 replies, posted in Wish List)

Hello,
is there a way to download the wiki pages from FA's website?
Although, it's very explicite and helpful for new users, i would like to add it to my FA installation, so all the needed help'll be directly available offline into our LAN.
thanx

25

(17 replies, posted in FA Modifications)

thanx, i missed this one!!