function confirm($_POST, $_FILES)
{
    extract($_POST);
    $importfile = tempnam("/tmp", "cubitimport_");
    $file = fopen($_FILES["compfile"]["tmp_name"], "r");
    if ($file == false) {
        return "<li class='err'>Cannot read file.</li>" . select_file();
    }
    db_conn('cubit');
    $Sl = "\n\t\tCREATE TABLE import_data (\n\t\t\tdes1 varchar, des2 varchar, des3 varchar, des4 varchar, \n\t\t\tdes5 varchar, des6 varchar, des7 varchar, des8 varchar, \n\t\t\tdes9 varchar, des10 varchar, des11 varchar, des12 varchar, \n\t\t\tdes13 varchar, des14 varchar, des15 varchar, des16 varchar\n\t\t)";
    $Ri = @db_exec($Sl);
    $Sl = "DELETE FROM import_data";
    $Ri = db_exec($Sl) or errDie("Unable to clear import table");
    while (!feof($file)) {
        $data = safe(fgets($file, 4096));
        $datas = explode(",", $data);
        if (!isset($datas[10])) {
            continue;
        }
        $Sl = "\n\t\t\tINSERT INTO import_data (\n\t\t\t\tdes1, des2, des3, des4, des5, des6, \n\t\t\t\tdes7, des8, des9, des10, des11\n\t\t\t) VALUES (\n\t\t\t\t'{$datas['0']}', '{$datas['1']}', '{$datas['2']}', '{$datas['3']}', '{$datas['4']}', '{$datas['5']}', \n\t\t\t\t'{$datas['6']}', '{$datas['7']}', '{$datas['8']}', '{$datas['9']}', '{$datas['10']}'\n\t\t\t)";
        $Rl = db_exec($Sl) or errDie("Unable to insert data.");
    }
    fclose($file);
    #get departments
    db_conn('exten');
    $get_deps = "SELECT * FROM departments ORDER BY deptname";
    $run_deps = db_exec($get_deps) or errDie("Unable to get department information.");
    if (pg_numrows($run_deps) < 1) {
        return "<li class='err'>No Departments Found. Please Add A Department.</li>";
    } else {
        $depdrop = "<select name='department'>";
        while ($darr = pg_fetch_array($run_deps)) {
            $depdrop .= "<option value='{$darr['deptname']}'>{$darr['deptname']}</option>";
        }
        $depdrop .= "</select>";
    }
    $out = "\n\t\t\t<h3>Customers Import</h3>\n\t\t\t<form action='" . SELF . "' method='POST'>\n\t\t\t<input type='hidden' name='key' value='write'>\n\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t<tr>\n\t\t\t\t\t<th colspan='2'>Select Department</th>\n\t\t\t\t</tr>\n\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t<td colspan='2'>{$depdrop}</td>\n\t\t\t\t</tr>\n\t\t\t\t" . TBL_BR . "\n\t\t\t\t<tr>\n\t\t\t\t\t<th>Acc No</th>\n\t\t\t\t\t<th>Name</th>\n\t\t\t\t\t<th>Postal Address</th>\n\t\t\t\t\t<th>Delivery Address</th>\n\t\t\t\t\t<th>VAT Number</th>\n\t\t\t\t\t<th>Contact Name</th>\n\t\t\t\t\t<th>Tell</th>\n\t\t\t\t\t<th>Cell</th>\n\t\t\t\t\t<th>Fax</th>\n\t\t\t\t\t<th>Email</th>\n\t\t\t\t\t<th>Website</th>\n\t\t\t\t</tr>";
    db_conn('cubit');
    $Sl = "SELECT * FROM import_data";
    $Ri = db_exec($Sl);
    $i = 0;
    $showbutton = "\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan='5' align='right'><input type='submit' value='Write &raquo;'></td>\n\t\t\t\t</tr>";
    while ($fd = pg_fetch_array($Ri)) {
        #check if there is a conflict ...
        $get_check = "SELECT * FROM customers WHERE accno = '{$fd['des1']}' LIMIT 1";
        $run_check = db_exec($get_check) or errDie("Unable to get customer information.");
        if (pg_numrows($run_check) > 0) {
            $fd['des1'] = "<li class='err'>{$fd['des1']}</li>";
            $showbutton = "";
        }
        $out .= "\n\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t<td>{$fd['des1']}</td>\n\t\t\t\t\t<td>{$fd['des2']}</td>\n\t\t\t\t\t<td>{$fd['des3']}</td>\n\t\t\t\t\t<td>{$fd['des4']}</td>\n\t\t\t\t\t<td>{$fd['des5']}</td>\n\t\t\t\t\t<td>{$fd['des6']}</td>\n\t\t\t\t\t<td>{$fd['des7']}</td>\n\t\t\t\t\t<td>{$fd['des8']}</td>\n\t\t\t\t\t<td>{$fd['des9']}</td>\n\t\t\t\t\t<td>{$fd['des10']}</td>\n\t\t\t\t\t<td>{$fd['des11']}</td>\n\t\t\t\t</tr>";
        $i++;
    }
    $out .= "\n\t\t\t\t<tr><td><br></td></tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td colspan='5'><li class='err'>Items in red indicate conflicts with current data. Please corrent the information in the import file.</li></td>\n\t\t\t\t</tr>\n\t\t\t\t{$showbutton}\n\t\t\t</form>\n\t\t\t</table>";
    return $out;
}
function confirm($_POST, $_FILES)
{
    extract($_POST);
    $importfile = tempnam("/tmp", "cubitimport_");
    $file = fopen($_FILES["compfile"]["tmp_name"], "r");
    if ($file == false) {
        return "<li class='err'>Cannot read file.</li>" . select_file();
    }
    db_conn('cubit');
    $Sl = "\n\t\tCREATE TABLE import_data (\n\t\t\tdes1 varchar, des2 varchar,\n\t\t\tdes3 varchar, des4 varchar,\n\t\t\tdes5 varchar, des6 varchar,\n\t\t\tdes7 varchar, des8 varchar,\n\t\t\tdes9 varchar, des10 varchar,\n\t\t\tdes11 varchar, des12 varchar,\n\t\t\tdes13 varchar, des14 varchar,\n\t\t\tdes15 varchar, des16 varchar\n\t\t)";
    $Ri = @db_exec($Sl);
    $Sl = "DELETE FROM import_data";
    $Ri = db_exec($Sl) or errDie("Unable to clear import table");
    while (!feof($file)) {
        $data = safe(fgets($file, 4096));
        $datas = explode(",", $data);
        if (!isset($datas[2])) {
            continue;
        }
        $code = safe($datas[0]);
        $description = safe($datas[1]);
        $amount = sprint($datas[3]);
        $camount = sprint($datas[2]);
        $balance = sprint($datas[5]);
        $units = safe($datas[4]);
        $Sl = "\n\t\t\tINSERT INTO import_data (\n\t\t\t\tdes1, des2, des3, des4, des5, des6\n\t\t\t) VALUES (\n\t\t\t\t'{$code}', '{$description}', '{$amount}', '{$balance}', '{$units}', '{$camount}'\n\t\t\t)";
        $Rl = db_exec($Sl) or errDie("Unable to insert data.");
    }
    fclose($file);
    #get stores
    db_conn('exten');
    $get_stores = "SELECT * FROM warehouses WHERE div = '" . USER_DIV . "' ORDER BY whname";
    $run_stores = db_exec($get_stores) or errDie("Unable to get stores information.");
    if (pg_numrows($run_stores) < 1) {
        return "Unable to get stores information.";
    } else {
        $storedrop = "<select name='store'>";
        while ($sarr = pg_fetch_array($run_stores)) {
            $storedrop .= "<option value='{$sarr['whid']}'>{$sarr['whname']}</option>";
        }
        $storedrop .= "</select>";
    }
    $out = "\n\t\t<h3>Stock Import</h3>\n\t\t<form action='" . SELF . "' method='POST'>\n\t\t\t<input type='hidden' name='key' value='write'>\n\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t<tr>\n\t\t\t\t\t<th colspan='3'>Select Store</th>\n\t\t\t\t</tr>\n\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t<td colspan='3'>{$storedrop}</td>\n\t\t\t\t</tr>\n\t\t\t\t" . TBL_BR . "\n\t\t\t\t<tr>\n\t\t\t\t\t<th>Stock Code</th>\n\t\t\t\t\t<th>Description</th>\n\t\t\t\t\t<th>Cost Price</th>\n\t\t\t\t\t<th>Selling Price</th>\n\t\t\t\t</tr>";
    db_conn('cubit');
    $Sl = "SELECT * FROM import_data";
    $Ri = db_exec($Sl);
    $i = 0;
    while ($fd = pg_fetch_array($Ri)) {
        $out .= "\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>{$fd['des1']}</td>\n\t\t\t\t<td>{$fd['des2']}</td>\n\t\t\t\t<td>{$fd['des6']}</td>\n\t\t\t\t<td>{$fd['des3']}</td>\n\t\t\t</tr>";
        $i++;
    }
    $out .= "\n\t\t\t<tr>\n\t\t\t\t<td colspan='3' align='right'><input type='submit' value='Write &raquo;'></td>\n\t\t\t</tr>\n\t\t</form>\n\t\t</table>";
    return $out;
}
function confirm($_POST, $_FILES)
{
    extract($_POST);
    $importfile = tempnam("/tmp", "cubitimport_");
    $file = fopen($_FILES["compfile"]["tmp_name"], "r");
    if ($file == false) {
        return "<li class='err'>Cannot read file.</li>" . select_file();
    }
    db_conn('cubit');
    $Sl = "\n\t\tCREATE TABLE import_data (\n\t\t\tdes1 varchar, des2 varchar,\n\t\t\tdes3 varchar, des4 varchar,\n\t\t\tdes5 varchar, des6 varchar,\n\t\t\tdes7 varchar, des8 varchar,\n\t\t\tdes9 varchar, des10 varchar,\n\t\t\tdes11 varchar, des12 varchar,\n\t\t\tdes13 varchar, des14 varchar,\n\t\t\tdes15 varchar, des16 varchar\n\t\t)";
    $Ri = @db_exec($Sl);
    $Sl = "DELETE FROM import_data";
    $Ri = db_exec($Sl) or errDie("Unable to clear import table");
    while (!feof($file)) {
        $data = safe(fgets($file, 4096));
        $datas = explode(",", $data);
        if (!isset($datas[7])) {
            continue;
        }
        $Sl = "\n\t\t\tINSERT INTO import_data (\n\t\t\t\tdes1, des2, des3, des4, des5, \n\t\t\t\tdes6, des7, des8\n\t\t\t) VALUES (\n\t\t\t\t'{$datas['0']}', '{$datas['1']}', '{$datas['2']}', '{$datas['3']}', '{$datas['4']}', \n\t\t\t\t'{$datas['5']}', '{$datas['6']}', '{$datas['7']}'\n\t\t\t)";
        $Rl = db_exec($Sl) or errDie("Unable to insert data.");
    }
    fclose($file);
    #get supplier department
    db_conn('exten');
    $get_deps = "SELECT * FROM departments ORDER BY deptname";
    $run_deps = db_exec($get_deps) or errDie("Unable to get department information.");
    if (pg_numrows($run_deps) < 1) {
        return "<li class='err'>Unable to get departments information.</li>";
    } else {
        $deptdrop = "<select name='department'>";
        while ($darr = pg_fetch_array($run_deps)) {
            $deptdrop .= "<option value='{$darr['deptid']}'>{$darr['deptname']}</option>";
        }
        $deptdrop .= "</select>";
    }
    $out = "\n\t\t\t<h3>Suppliers Import</h3>\n\t\t\t<form action='" . SELF . "' method='POST'>\n\t\t\t\t<input type='hidden' name='key' value='write'>\n\t\t\t<table " . TMPL_tblDflts . ">\n\t\t\t\t<tr>\n\t\t\t\t\t<th colspan='2'>Select Supplier Departments</th>\n\t\t\t\t</tr>\n\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t<td colspan='2'>{$deptdrop}</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>Acc No</th>\n\t\t\t\t\t<th>Name</th>\n\t\t\t\t\t<th>Address Address</th>\n\t\t\t\t\t<th>Vat Number</th>\n\t\t\t\t\t<th>Contact Name</th>\n\t\t\t\t\t<th>Tell</th>\n\t\t\t\t\t<th>Fax</th>\n\t\t\t\t\t<th>Website</th>\n\t\t\t\t</tr>";
    db_conn('cubit');
    $Sl = "SELECT * FROM import_data";
    $Ri = db_exec($Sl);
    $i = 0;
    while ($fd = pg_fetch_array($Ri)) {
        $out .= "\n\t\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t\t<td>{$fd['des1']}</td>\n\t\t\t\t\t<td>{$fd['des2']}</td>\n\t\t\t\t\t<td>{$fd['des3']}</td>\n\t\t\t\t\t<td>{$fd['des4']}</td>\n\t\t\t\t\t<td>{$fd['des5']}</td>\n\t\t\t\t\t<td>{$fd['des6']}</td>\n\t\t\t\t\t<td>{$fd['des7']}</td>\n\t\t\t\t\t<td>{$fd['des8']}</td>\n\t\t\t\t</tr>";
        $i++;
    }
    $out .= "\n\t\t\t<tr>\n\t\t\t\t<td colspan='3' align='right'><input type='submit' value='Write &raquo;'></td>\n\t\t\t</tr>\n\t\t</form>\n\t\t</table>";
    return $out;
}
Example #4
0
<?php

// Settings
$excludes_order = array('detail');
$includes_order = array('/\\d{5,8}(_big)?(_p\\d+)?\\.', '/waren', '/kaberen', '/moeren', '/kabeura', '/moeura');
$deselects = array('this-one-needs-duplicate');
$normal_depth = isset($_GET['depth']) ? intval($_GET['depth']) : 2;
if (!isset($_GET['file'])) {
    select_file();
} elseif (isset($_POST['generate'])) {
    generate_new_list();
} elseif (isset($_GET['calctotal'])) {
    calc_total();
} else {
    dupselect_ui();
}
function proper_size($size, $maxcnt = 0)
{
    $suffix = '';
    $suxAry = array("KB", "MB", "GB", "TB");
    $ccnt = $maxcnt ? $maxcnt : count($suxAry);
    for ($cnt = 0; $cnt < $ccnt; $cnt++) {
        if ($size > 1024) {
            $size /= 1024;
            $suffix = $suxAry[$cnt];
        }
    }
    return $suffix ? sprintf("%.1f", $size) . $suffix : $size . 'B';
}
function countchar($str, $chr)
{
function write5($_POST, $_FILES)
{
    extract($_POST);
    # CHECK IF THIS DATE IS IN THE BLOCKED RANGE
    $blocked_date_from = getCSetting("BLOCKED_FROM");
    $blocked_date_to = getCSetting("BLOCKED_TO");
    $bankid += 0;
    $importfile = tempnam("/tmp", "cubitimport_");
    $file = fopen($_FILES["compfile"]["tmp_name"], "r");
    if ($file == false) {
        return "<li class='err'>Cannot read file.</li>" . select_file();
    }
    db_conn('cubit');
    $linecount = 0;
    while (!feof($file)) {
        $linecount++;
        $data = safe(fgets($file, 4096));
        $datas = explode(",", $data);
        if (!isset($datas[0]) or strlen($data) < 1) {
            // || !custdate($datas[0])) {
            continue;
        }
        if ($linecount < 5) {
            continue;
        }
        $date = custdate($datas[0]);
        if (strtotime($date) >= strtotime($blocked_date_from) and strtotime($date) <= strtotime($blocked_date_to) and !user_is_admin(USER_ID)) {
            return "<li class='err'>Period Range Is Blocked. Only an administrator can process entries within this period.</li>";
        }
        $amount = $datas[2];
        $amount += 0;
        $amount = sprint($amount);
        $description = safe($datas[1]);
        $from = safe($datas[1]);
        $code = "";
        $ex1 = safe($datas[3]);
        $ex2 = "";
        $ex3 = "";
        $Sl = "SELECT * FROM statement_history WHERE date='{$date}' AND amount='{$amount}' AND description='{$description}' AND contra='{$from}' AND code='{$code}' AND ex1='{$ex1}' AND ex2='{$ex2}' AND ex3='{$ex3}'";
        $Ri = db_exec($Sl) or errDie("unable to check data.");
        if (pg_num_rows($Ri) < 1) {
            $Sl = "\n\t\t\t\tINSERT INTO statement_data (\n\t\t\t\t\tdate, amount, description, contra, code, ex1, ex2, ex3, by, bank, account\n\t\t\t\t) VALUES (\n\t\t\t\t\t'{$date}', '{$amount}', '{$description}', '{$from}', '{$code}', '{$ex1}', '{$ex2}', '{$ex3}', '" . USER_DIV . "', 'ABSA', '{$bankid}'\n\t\t\t\t)";
            $Ri = db_exec($Sl) or errDie("error importing statement.");
            $Sl = "\n\t\t\t\tINSERT INTO statement_history (\n\t\t\t\t\tdate, amount, description, contra, code, ex1, ex2, ex3, by, bank, account\n\t\t\t\t) VALUES (\n\t\t\t\t\t'{$date}', '{$amount}', '{$description}', '{$from}', '{$code}', '{$ex1}', '{$ex2}', '{$ex3}', '" . USER_DIV . "', 'ABSA', '{$bankid}'\n\t\t\t\t)";
            $Ri = db_exec($Sl) or errDie("error importing statement.");
        }
    }
    fclose($file);
    return enter_actions($_POST);
}
function enter_data($_POST, $_FILES = "")
{
    extract($_POST);
    if ($_FILES != "") {
        $importfile = tempnam("/tmp", "cubitimport_");
        $file = fopen($_FILES["compfile"]["tmp_name"], "r");
        if ($file == false) {
            return "<li class='err'>Cannot read file.</li>" . select_file();
        }
        db_conn('cubit');
        $Sl = "DROP TABLE import_data";
        $Ri = @db_exec_safe($Sl);
        $Sl = "\n\t\t\tCREATE TABLE import_data (\n\t\t\t\tid serial,\n\t\t\t\tdes1 varchar, des2 varchar,\n\t\t\t\tdes3 varchar, des4 varchar,\n\t\t\t\tdes5 varchar, des6 varchar,\n\t\t\t\tdes7 varchar, des8 varchar,\n\t\t\t\tdes9 varchar, des10 varchar,\n\t\t\t\tdes11 varchar, des12 varchar,\n\t\t\t\tdes13 varchar, des14 varchar,\n\t\t\t\tdes15 varchar, des16 varchar\n\t\t\t)";
        $Ri = @db_exec($Sl);
        $Sl = "DELETE FROM import_data";
        $Ri = db_exec($Sl) or errDie("Unable to clear import table");
        while (!feof($file)) {
            $data = safe(fgets($file, 4096));
            $datas = explode(",", $data);
            if (!isset($datas[1])) {
                continue;
            }
            $temp = explode('/', $datas['0']);
            $valtemp = $temp['0'];
            $datas['0'] = str_pad($valtemp, 4, "0") . "/" . $temp['1'];
            $datas[2] = sprint(abs($datas[2]));
            $datas[3] = sprint(abs($datas[3]));
            $Sl = "\n\t\t\t\tINSERT INTO import_data (\n\t\t\t\t\tdes1, des2, des3, des4\n\t\t\t\t) VALUES (\n\t\t\t\t\t'{$datas['0']}', '{$datas['1']}', '{$datas['2']}', '{$datas['3']}'\n\t\t\t\t)";
            $Rl = db_exec($Sl) or errDie("Unable to insert data.");
        }
        fclose($file);
    }
    global $_SESSION;
    $out = "\n\t\t<h3>Trial Balance Import</h3>\n\t\t<form action='" . SELF . "' method='POST'>\n\t\t\t<input type='hidden' name='key' value='enter2'>\n\t\t\t<input type='hidden' name='login' value='1'>\n\t\t\t<input type='hidden' name='div' value='{$_SESSION['USER_DIV']}'>\n\t\t\t<input type='hidden' name='login_user' value='{$_SESSION['USER_NAME']}'>\n\t\t\t<input type='hidden' name='login_pass' value='{$_SESSION['USER_PASS']}'>\n\t\t\t<input type='hidden' name='code' value='{$_SESSION['code']}'>\n\t\t\t<input type='hidden' name='comp' value='{$_SESSION['comp']}'>\n\t\t\t<input type='hidden' name='noroute' value='1'>\n\t\t<table " . TMPL_tblDflts . ">\n\t\t\t<tr>\n\t\t\t\t<td colspan='2' class='err'># Indicates an account (Number) that already exists</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td colspan='2' class='err'>! Indicates an account (Number) that is a duplicate of\n\t\t\t\t\tanother account number in the import file.</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td colspan='2' class='err'>In order to avoid errors, ensure that account numbers\n\t\t\t\t\tare in the correct format</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td colspan='2' class='err'>Remember to select the accounts to link to in the lists provided.\n\t\t\t\t\tIf the account you wish to link with does not exist, you can specify that the account\n\t\t\t\t\tshould be created. Do this by selecting one of the following options:<br />\n\t\t\t\t\t1. New Income Account, will create a new Income account<br />\n\t\t\t\t\t2. New Balance Account, will create and new Balance Sheet account<br />\n\t\t\t\t\t3. New Expense Account, will create a new Expense account.\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t\t" . TBL_BR . "\n\t\t\t<tr bgcolor='" . bgcolorc(1) . "'>\n\t\t\t\t<th>Period to import into:</th>\n\t\t\t\t<td>" . finMonList("prd", PRD_DB) . "</td>\n\t\t\t</tr>\n\t\t\t" . TBL_BR . "\n\t\t\t<tr>\n\t\t\t\t<th>Acc No</th>\n\t\t\t\t<th>Account Name</th>\n\t\t\t\t<th>Debit</th>\n\t\t\t\t<th>Credit</th>\n\t\t\t\t<th>Select Account to link to</th>\n\t\t\t</tr>";
    $accsql = new dbSelect("accounts", "core", array("order" => "accname"));
    $accsql->run();
    $acclist = array();
    while ($ai = $accsql->fetch_array()) {
        $acclist[$ai["accname"]] = $ai["accid"];
    }
    db_conn('cubit');
    $Sl = "SELECT * FROM import_data ORDER BY des1";
    $Ri = db_exec($Sl);
    $i = 0;
    $tot_debit = 0;
    $tot_credit = 0;
    db_conn('core');
    $newacc_selections = array();
    while ($fd = pg_fetch_array($Ri)) {
        $fid = $fd['id'];
        $bgcolor = bgcolor($i);
        $Accounts = "\n\t\t<select name='accounts[{$fid}]' id='accounts[{$fid}]'>\n\t\t<optgroup label='Create New Account'>\n\t\t\t<option value='n1'>New Income Account</option>\n\t\t\t<option value='n2'>New Expense Account</option>\n\t\t\t<option value='n3'>New Balance Account</option>\n\t\t</optgroup>\n\t\t<optgroup label='Use Existing Account'>";
        $has_sel = false;
        foreach ($acclist as $accname => $accid) {
            $sel = "";
            if (!$has_sel) {
                $m1 = isset($accounts[$fid]) && $accounts[$fid] == $accid;
                $m2 = $accname == $fd['des2'] && !isset($accounts[$fid]);
                $m3 = !empty($fd["des2"]) && stristr($accname, $fd['des2']) && !isset($accounts[$fid]) && !isset($acclist[$fd["des2"]]);
                if ($m1 || $m2 || $m3) {
                    $sel = "selected";
                    $has_sel = true;
                }
            }
            $Accounts .= "<option value='{$accid}' {$sel}>{$accname}</option>";
        }
        $Accounts .= "\n\t\t</optgroup>\n\t\t</select>";
        list($var1, $var2) = explode('/', $fd['des1']);
        if (!$has_sel) {
            if ($var1 >= MIN_INC && $var1 <= MAX_INC) {
                $newacc_selections[$fid] = "n1";
            } else {
                if ($var1 >= MIN_EXP && $var1 <= MAX_EXP) {
                    $newacc_selections[$fid] = "n2";
                } else {
                    if ($var1 >= MIN_BAL && $var1 <= MAX_BAL) {
                        $newacc_selections[$fid] = "n3";
                    }
                }
            }
        }
        db_conn('core');
        $get_check = "SELECT * FROM accounts WHERE topacc = '{$var1}' AND accnum = '{$var2}'";
        $run_check = db_exec($get_check) or errDie("Unable to get account check");
        if (pg_numrows($run_check) < 1) {
            $showerr = "";
        } else {
            $showerr = "<b class='err'>#</b>";
        }
        $check_dup = new dbSelect("import_data", "cubit", grp(m("where", "des1='{$fd['des1']}' AND id!='{$fd['id']}'")));
        $check_dup->run();
        if ($check_dup->num_rows() > 0) {
            $showerr .= "<b class='err'>!</b>";
        }
        $out .= "\n\t\t\t<tr class='" . bg_class() . "'>\n\t\t\t\t<td>{$showerr} {$fd['des1']}</td>\n\t\t\t\t<td>{$fd['des2']}</td>\n\t\t\t\t<td>{$fd['des3']}</td>\n\t\t\t\t<td>{$fd['des4']}</td>\n\t\t\t\t<td>{$Accounts}</td>\n\t\t\t</tr>";
        $tot_debit += $fd['des3'];
        $tot_credit += $fd['des4'];
    }
    $bgcolor = bgcolor($i);
    $tot_debit = sprint($tot_debit);
    $tot_credit = sprint($tot_credit);
    $out .= "\n\t\t<tr class='" . bg_class() . "'>\n\t\t\t<td colspan='2'>Total</td>\n\t\t\t<td align='right'>{$tot_debit}</td>\n\t\t\t<td align='right'>{$tot_credit}</td>\n\t\t</tr>";
    if ($tot_debit == $tot_credit) {
        $out .= "\n\t\t\t<tr>\n\t\t\t\t<td colspan='3' align='right'><input type='submit' value='Continue &raquo;'></td>\n\t\t\t</tr>";
    } else {
        $out .= "\n\t\t\t<li class='err'>The Total debit and credit are not the same. You cannot import a trial balance that doesnt balance.<br>\n\t\t\tPlease check the file you are trying to import, the total debits and total credits should be the same.<br>\n\t\t\tPlease fix the file and try again.</li>";
    }
    $out .= "\n\t\t</form>\n\t\t</table>\n\t\t<script>";
    foreach ($newacc_selections as $fid => $pval) {
        $out .= "l = document.getElementById('accounts[{$fid}]'); l.value='{$pval}';";
    }
    $out .= "\n\t</script>";
    return $out;
}
Example #7
0
    echo $id_domicilie;
    ?>
&id_signataire='+document.getElementById('signataire').value);" value="Envoyer !">
			</td>
	</table>
	
	
<?php 
} elseif ($_GET["action"] == "sortir") {
    insert_stat_sortie($_GET["id"], $_GET["nom_fichier"], $_GET["id_user"], $_GET["id_signataire"]);
    $sign = mysql_fetch_array(select_signataire($_GET["id_signataire"]), ENT_QUOTES);
    $domicilie = select_domicilie($_GET["id"]);
    $infos = mysql_fetch_array($domicilie, ENT_QUOTES);
    $dates = select_date($infos["id"]);
    $infos_dates = mysql_fetch_array($dates, ENT_QUOTES);
    $file = select_file($_GET["nom_fichier"]);
    $file_name = mysql_fetch_array($file, ENT_QUOTES);
    $CheminFichier = "../SORTIES/" . $file_name["nom_fichier"];
    $nouveau_fichier = $CheminFichier . "_temp.rtf";
    touch($CheminFichier);
    copy($CheminFichier, $nouveau_fichier);
    /*
    $fp=fopen($CheminFichier,"r"); // Ouverture du fichier avec le mode lecture
    
    $contenu="";
    while ( !feof ( $fp ) ){
          $contenu .= fgets ( $fp , 4096 ) ;
      echo $contenu."<br>";
    }
    */
    $contenu = file_get_contents($CheminFichier);