Example #1
0
function get_result($sql, $show_these)
{
    $ret = '';
    $result = mysql_query($sql);
    check_db_error();
    $ret .= '<table id="db_result">';
    $count = 1;
    $ret .= '<tr>';
    $ret .= '<td class="standout">#</td>';
    foreach ($show_these as $field) {
        $ret .= '<td class="standout">' . $field . '</td>';
    }
    $ret .= '</tr>';
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        #printf("ID: %s  Name: %s <br />", $row["id"], $row["forename"]);
        $ret .= '<tr>';
        $ret .= '<td>' . $count . '</td>';
        foreach ($show_these as $field) {
            $ret .= '<td>' . $row[$field] . '</td>';
        }
        $ret .= '</tr>';
        $count++;
    }
    $ret .= '</table>';
    mysql_free_result($result);
    return $ret;
}
Example #2
0
function check_po_changed()
{
    /*Now need to check that the order details are the same as they were when they were read into the Items array. If they've changed then someone else must have altered them */
    // Sherifoz 22.06.03 Compare against COMPLETED items only !!
    // Otherwise if you try to fullfill item quantities separately will give error.
    $sql = "SELECT item_code, quantity_ordered, quantity_received, qty_invoiced\n\t\tFROM purch_order_details\n\t\tWHERE order_no=" . $_SESSION['PO']->order_no . "\n\t\tAND (quantity_ordered > quantity_received)\n\t\tORDER BY po_detail_item";
    $result = db_query($sql, "could not query purch order details");
    check_db_error("Could not check that the details of the purchase order had not been changed by another user ", $sql);
    $line_no = 1;
    while ($myrow = db_fetch($result)) {
        $ln_item = $_SESSION['PO']->line_items[$line_no];
        // only compare against items that are outstanding
        $qty_outstanding = $ln_item->quantity - $ln_item->qty_received;
        if ($qty_outstanding > 0) {
            if ($ln_item->qty_inv != $myrow["qty_invoiced"] || $ln_item->stock_id != $myrow["item_code"] || $ln_item->quantity != $myrow["quantity_ordered"] || $ln_item->qty_received != $myrow["quantity_received"]) {
                return true;
            }
        }
        $line_no++;
    }
    /*loop through all line items of the order to ensure none have been invoiced */
    return false;
}
function do_donations()
{
    $amount = mysql_real_escape_string(safe('mc_gross'));
    $custom = mysql_real_escape_string(safe('custom'));
    // or 'transaction_subject'
    $custom = explode('|', $custom);
    $email = $custom[0];
    $gift_aid = $custom[1];
    // was item_number but it appears in PayPal customer page
    $gift_aid = $gift_aid == 'TAXPAYER_YES' ? 1 : 0;
    //--------------------------------------------------------------
    $row = mysql_fetch_assoc(mysql_query("SELECT id, email, title, forename, surname FROM " . TABLE_COMMUNITY . " WHERE email='" . $email . "'"));
    check_db_error();
    // id exists
    if ($row['email']) {
        $pid = $row['id'];
        insert_amount($pid, $amount, $gift_aid);
    } else {
        $sql_cmd = "\tINSERT INTO " . TABLE_COMMUNITY . " (dt, mdt, email)\n\t\t\t\t\t\tVALUES(\n\n\t\t\t\t\t\t\tNOW(),\n\t\t\t\t\t\t\tNOW(),\n\t\t\t\t\t\t\t'" . $email . "',\n\n\t\t\t\t\t\t)";
        mysql_query($sql_cmd);
        check_db_error();
        $pid = mysql_insert_id();
        insert_amount($pid, $amount, $gift_aid);
    }
    insert_value('donor', 1, $pid);
    //--------------------------------------------------------------
    // paypal address fields
    if (isset($_REQUEST['address_name'])) {
        $fields = array('first_name', 'last_name', 'payer_email', 'address_name', 'address_street', 'address_city', 'address_state', 'address_zip', 'address_country', 'address_country_code', 'residence_country', 'address_status');
        $sql_cmd = '';
        $sql_top = '';
        foreach ($fields as $name) {
            $sql_top .= $name . ',';
            if (isset($_REQUEST[$name])) {
                $sql_cmd .= '\'' . mysql_real_escape_string(safe($name)) . '\',';
            } else {
                $sql_cmd .= '\'\',';
            }
        }
        // remove last ,
        $sql_cmd = substr_replace($sql_cmd, "", -1);
        $sql_top = substr_replace($sql_top, "", -1);
        $sql_cmd = "\tINSERT INTO " . TABLE_PAYPAL . "\n\n\t\t\t\t\t\t(dt, pid, " . $sql_top . ")\n\n\t\t\t\t\t\tVALUES(\n\n\t\t\t\t\t\t\tNOW(),\n\t\t\t\t\t\t\t" . $pid . ",\n\t\t\t\t\t\t\t" . $sql_cmd . "\n\t\t\t\t\t)";
        /*
        		$sql_cmd = '';
        		foreach ($update_these as $name)
        			$sql_cmd .= $name . ' = \'' .$_REQUEST[$name] . '\',';
        
        		// remove last ,
        		$sql_cmd = substr_replace($sql_cmd ,"",-1);
        
        		$sql_cmd = ("	UPDATE " . TABLE_PAYPAL . " SET
        
        						mdt = NOW(),
        
        						" . $sql_cmd . "
        
        						WHERE id = '". $pid ."'
        
        				");
        */
        mysql_query($sql_cmd);
        check_db_error($sql_cmd);
    }
    //--------------------------------------------------------------
    //send emails (to donor & IBS)
    if ($row['title'] && $row['forename'] && $row['surname']) {
        $name = get_full_name($row);
    } else {
        $name = 'Subscriber';
    }
    send_email_auto_donor($name, $amount);
    send_email_donor($email, $name, $amount);
}
Example #4
0
check_db_error($db['blast_sth'], __FILE__, __LINE__);
$page_title = "Catalog RAD-Tag Sequence/BLAST Hits Viewer";
write_compact_header($page_title);
$result = $db['seq_sth']->execute(array($batch_id, $tag_id));
check_db_error($result, __FILE__, __LINE__);
$seqs = array();
// Add the marker itself to the sequence array, it won't
// be directly listed in the sequence table.
$a = array('id' => -1, 'catalog_id' => $tag_id, 'seq_id' => "", 'type' => "se_radtag");
array_push($seqs, $a);
while ($row = $result->fetchRow()) {
    $a = array('id' => $row['id'], 'catalog_id' => $row['catalog_id'], 'seq_id' => $row['seq_id'], 'type' => $row['type']);
    array_push($seqs, $a);
}
$result = $db['blast_sth']->execute(array($batch_id, $tag_id));
check_db_error($result, __FILE__, __LINE__);
$hits = array();
while ($row = $result->fetchRow()) {
    $a = array('sql_id' => $row['id'], 'query_id' => $row['query_id'], 'hit_id' => $row['hit_id'], 'query_len' => $row['query_len'], 'hit_len' => $row['hit_len'], 'score' => $row['score'], 'e_value' => $row['e_value'], 'pctid' => $row['percent_ident'], 'hsp_rank' => $row['hsp_rank'], 'aln_len' => $row['aln_len']);
    if (!isset($hits[$row['query_id']])) {
        $hits[$row['query_id']] = array();
    }
    array_push($hits[$row['query_id']], $a);
}
foreach ($seqs as $seq) {
    if (strlen($seq['seq_id']) > 0) {
        $query_id = $seq['catalog_id'] . "|" . $seq['seq_id'];
    } else {
        $query_id = $seq['catalog_id'];
    }
    $hsps = $hits[$query_id];
Example #5
0
function fetch_chrs(&$max_len)
{
    global $db, $batch_id;
    $max_len = 0;
    $chrs = array();
    $res = $db['chrs_sth']->execute($batch_id);
    check_db_error($res, __FILE__, __LINE__);
    while ($row = $res->fetchRow()) {
        if ($row['max_len'] > $max_len) {
            $max_len = $row['max_len'];
        }
        array_push($chrs, $row['chr']);
    }
    return $chrs;
}
Example #6
0
 function populate($start_group, $num_groups)
 {
     //
     // We only want to load genes between $start_gene and $end_gene.
     //
     $this->db['dbh']->setLimit($num_groups, $start_group);
     check_db_error($this->db['dbh'], __FILE__, __LINE__);
     $this->db['tag_sth'] = $this->db['dbh']->prepare($this->queries['tag']);
     check_db_error($this->db['tag_sth'], __FILE__, __LINE__);
     $this->prepare_filter_parameters();
     //
     // Fetch the results and populate the array of groups.
     //
     $result = $this->db['tag_sth']->execute($this->params);
     check_db_error($result, __FILE__, __LINE__);
     while ($row = $result->fetchRow()) {
         $locus = new Locus();
         $locus->id = $row['tag_id'];
         $locus->annotation = $row['external_id'];
         $locus->chr = $row['chr'];
         $locus->bp = $row['bp'];
         $locus->marker = $row['marker'];
         $locus->seq = $row['seq'];
         $locus->num_alleles = $row['alleles'];
         $locus->num_snps = $row['snps'];
         $locus->num_parents = $row['parents'];
         $locus->num_progeny = $row['progeny'];
         $locus->valid_progeny = $row['valid_progeny'];
         $locus->num_ests = $row['ests'];
         $locus->num_pe_tags = $row['pe_radtags'];
         $locus->num_blast = $row['blast_hits'];
         //
         // Fetch SNPs and Alleles
         //
         $snp_res = $this->db['snp_sth']->execute(array($this->batch, $locus->id));
         check_db_error($snp_res, __FILE__, __LINE__);
         while ($snp_row = $snp_res->fetchRow()) {
             $locus->snps .= $snp_row['col'] . "," . $snp_row['rank_1'] . ">" . $snp_row['rank_2'] . ";";
         }
         $locus->snps = substr($locus->snps, 0, -1);
         $all_res = $this->db['allele_sth']->execute(array($this->batch, $locus->id));
         check_db_error($all_res, __FILE__, __LINE__);
         while ($all_row = $all_res->fetchRow()) {
             $locus->alleles .= $all_row['allele'] . ";";
         }
         $locus->alleles = substr($locus->alleles, 0, -1);
         //
         // Add genotypes
         //
         $gen_res = $this->db['mat_sth']->execute(array($this->batch, $locus->id));
         check_db_error($genres, __FILE__, __LINE__);
         while ($gen_row = $gen_res->fetchRow()) {
             $locus->add_genotype($gen_row['id'], $gen_row['file'], $gen_row['allele']);
         }
         $this->loci[$row['tag_id']] = $locus;
     }
 }
Example #7
0
function on_submit($selected_parent, $selected_component = null)
{
    if (!check_num('quantity', 0)) {
        display_error(tr("The quantity entered must be numeric and greater than zero."));
        set_focus('quantity');
        return;
    }
    if (isset($selected_parent) && isset($selected_component)) {
        $sql = "UPDATE bom SET workcentre_added='" . $_POST['workcentre_added'] . "',\n\t\t\tloc_code='" . $_POST['loc_code'] . "',\n\t\t\tquantity= " . input_num('quantity') . "\n\t\t\tWHERE parent='" . $selected_parent . "'\n\t\t\tAND id='" . $selected_component . "'";
        check_db_error("Could not update this bom component", $sql);
        db_query($sql, "could not update bom");
    } elseif (!isset($selected_component) && isset($selected_parent)) {
        /*Selected component is null cos no item selected on first time round 
        		so must be adding a record must be Submitting new entries in the new 
        		component form */
        //need to check not recursive bom component of itself!
        if (!check_for_recursive_bom($selected_parent, $_POST['component'])) {
            /*Now check to see that the component is not already on the bom */
            $sql = "SELECT component FROM bom\n\t\t\t\tWHERE parent='{$selected_parent}'\n\t\t\t\tAND component='" . $_POST['component'] . "'\n\t\t\t\tAND workcentre_added='" . $_POST['workcentre_added'] . "'\n\t\t\t\tAND loc_code='" . $_POST['loc_code'] . "'";
            $result = db_query($sql, "check failed");
            if (db_num_rows($result) == 0) {
                $sql = "INSERT INTO bom (parent, component, workcentre_added, loc_code, quantity)\n\t\t\t\t\tVALUES ('{$selected_parent}', '" . $_POST['component'] . "', '" . $_POST['workcentre_added'] . "', '" . $_POST['loc_code'] . "', " . input_num('quantity') . ")";
                db_query($sql, "check failed");
                //$msg = tr("A new component part has been added to the bill of material for this item.");
            } else {
                /*The component must already be on the bom */
                display_error(tr("The selected component is already on this bom. You can modify it's quantity but it cannot appear more than once on the same bom."));
            }
        } else {
            display_error(tr("The selected component is a parent of the current item. Recursive BOMs are not allowed."));
        }
    }
}
Example #8
0
    $_POST['stock_id'] = get_global_stock_item();
}
start_table("class='tablestyle_noborder'");
stock_items_list_cells(tr("Item:"), 'stock_id', $_POST['stock_id']);
locations_list_cells(tr("From Location:"), 'StockLocation', null);
date_cells(tr("From:"), 'AfterDate', null, -30);
date_cells(tr("To:"), 'BeforeDate');
submit_cells('ShowMoves', tr("Show Movements"));
end_table();
end_form();
set_global_stock_item($_POST['stock_id']);
$before_date = date2sql($_POST['BeforeDate']);
$after_date = date2sql($_POST['AfterDate']);
$sql = "SELECT type, trans_no, tran_date, person_id, qty, reference\n\tFROM stock_moves\n\tWHERE loc_code='" . $_POST['StockLocation'] . "'\n\tAND tran_date >= '" . $after_date . "'\n\tAND tran_date <= '" . $before_date . "'\n\tAND stock_id = '" . $_POST['stock_id'] . "' ORDER BY tran_date,trans_id";
$result = db_query($sql, "could not query stock moves");
check_db_error("The stock movements for the selected criteria could not be retrieved", $sql);
start_table("{$table_style} width=70%");
$th = array(tr("Type"), tr("#"), tr("Reference"), tr("Date"), tr("Detail"), tr("Quantity In"), tr("Quantity Out"), tr("Quantity On Hand"));
table_header($th);
$sql = "SELECT SUM(qty) FROM stock_moves WHERE stock_id='" . $_POST['stock_id'] . "'\n\tAND loc_code='" . $_POST['StockLocation'] . "'\n\tAND tran_date < '" . $after_date . "'";
$before_qty = db_query($sql, "The starting quantity on hand could not be calculated");
$before_qty_row = db_fetch_row($before_qty);
$after_qty = $before_qty = $before_qty_row[0];
if (!isset($before_qty_row[0])) {
    $after_qty = $before_qty = 0;
}
start_row("class='inquirybg'");
label_cell("<b>" . tr("Quantity on hand before") . " " . $_POST['AfterDate'] . "</b>", "align=center colspan=7");
qty_cell($before_qty);
end_row();
$j = 1;
Example #9
0
$s .= '"' . $email . '"' . "\r\n";
$r = write_file($filename, $s);
//--------------------------------------------------------------
$r = send_newsletter_email($email);
$r = send_newsletter_auto_email($email);
//--------------------------------------------------------------
// add to DB
$row = mysql_fetch_assoc(mysql_query("SELECT id, email, title, forename, surname FROM " . TABLE_COMMUNITY . " WHERE email='" . $email . "'"));
check_db_error();
// id exists
if ($row['email']) {
    $pid = $row['id'];
} else {
    $sql_cmd = "\tINSERT INTO " . TABLE_COMMUNITY . " (dt, mdt, email)\n\t\t\t\t\tVALUES(\n\n\t\t\t\t\t\tNOW(),\n\t\t\t\t\t\tNOW(),\n\t\t\t\t\t\t'" . $email . "'\n\n\t\t\t\t\t)";
    mysql_query($sql_cmd);
    check_db_error();
    $pid = mysql_insert_id();
}
insert_value('newsletter', '1', $pid);
//--------------------------------------------------------------
// check for Facebook
//
// if fromFacebook is set then we must redirect to
// another Newsletter Thank You page
// otherwise it's an AJAX call expecting an exit($r)
//
if (isset($_REQUEST['fromFacebook'])) {
    header('Location: http://ibsproject.org/facebook/newsletter_thankyou.php');
} else {
    exit($r);
}
Example #10
0
</tr>

EOQ;
$db['dbh']->setLimit($display['pp'], $start_group - 1);
check_db_error($db['dbh'], __FILE__, __LINE__);
$query = "SELECT con_tag_id as id, tag_index.tag_id as tag_id, " . "depth, seq, catalog_id, " . "tag_index.deleveraged, tag_index.removed, tag_index.blacklisted " . "FROM tag_index " . "JOIN unique_tags ON (con_tag_id=unique_tags.id) " . "WHERE tag_index.batch_id=? AND tag_index.sample_id=?";
$query .= apply_query_filters($display);
$db['tag_sth'] = $db['dbh']->prepare($query);
check_db_error($db['tag_sth'], __FILE__, __LINE__);
$result = $db['tag_sth']->execute($param);
check_db_error($result, __FILE__, __LINE__);
while ($row = $result->fetchRow()) {
    // Query the database to find how many SNPs were found in this sample.
    $snps = array();
    $snp_res = $db['snp_sth']->execute(array($batch_id, $sample_id, $row['tag_id']));
    check_db_error($snp_res, __FILE__, __LINE__);
    while ($snp_row = $snp_res->fetchRow()) {
        array_push($snps, array('col' => $snp_row['col'], 'rank' => $snp_row['rank_2']));
    }
    print "<tr>\n" . "  <td><a href=\"{$root_path}/tag.php?db={$database}&batch_id={$batch_id}&sample_id={$sample_id}&tag_id={$row['tag_id']}&p={$display['p']}&pp={$display['pp']}\">" . "{$row['tag_id']}</a></td>\n" . "  <td>{$row['depth']}</td>\n";
    if (count($snps) == 0) {
        print "  <td>No</td>\n";
    } else {
        print "  <td>Yes <span class=\"s\">[" . count($snps) . "nuc]</span></td>\n";
    }
    $s = print_snps($row['tag_id'], $row['seq'], $row['seq'], $snps, true);
    print "  <td class=\"seq\"><div class=\"seq\">" . $s . "</div></td>\n";
    $row['catalog_id'] > 0 ? print "  <td><a href=\"{$root_path}/catalog.php?db={$database}&id={$batch_id}&filter_type[]=cata&filter_cata={$row['catalog_id']}\">{$row['catalog_id']}</a></td>\n" : (print "  <td><span style=\"color: #888888; font-weight: bold;\">absent</span></td>\n");
    print "</tr>\n";
}
print "<tr>\n" . "  <td colspan=\"5\" style=\"border: none; padding-top: 0px;\">\n";
Example #11
0
function correct_marker($display)
{
    global $db;
    $gtypes = array();
    $form_gtypes = array();
    //
    // Fetch the existing genotypes from the database
    //
    $result = $db['geno_sth']->execute(array($display['batch_id'], $display['tag_id']));
    check_db_error($result, __FILE__, __LINE__);
    while ($row = $result->fetchRow()) {
        $gtypes[$row['sample_id']] = array('id' => $row['id'], 'file' => $row['file'], 'genotype' => strtolower($row['genotype']), 'corrected' => $row['correction'], 'corrected_id' => $row['cid']);
    }
    //
    // Fetch the corrected genotypes from the submitted form
    //
    foreach ($_POST as $key => $value) {
        if (substr($key, 0, 5) != "gtype") {
            continue;
        }
        // ID should look like: 'gtype_batchid_catalogid_sampleid'
        $parts = explode("_", $key);
        $form_gtypes[$parts[3]] = strtolower($value);
        //print "Assigning $value to $parts[3]<br />\n";
    }
    foreach ($form_gtypes as $sample_id => $sample) {
        //print "LOOKING at sample ID: $sample_id: $sample, original value: " .  $gtypes[$sample_id]['genotype'] . "<br />\n";
        //
        // Is this genotype being reset to the original value? If so, delete the corrected record.
        //
        if ($sample == $gtypes[$sample_id]['genotype'] && strlen($gtypes[$sample_id]['corrected_id']) > 0) {
            $result = $db['del_sth']->execute($gtypes[$sample_id]['corrected_id']);
            check_db_error($result, __FILE__, __LINE__);
            //
            // Is the corrected value for this genotype being changed? If so, update the corrected record.
            //
        } else {
            if ($sample != $gtypes[$sample_id]['genotype'] && strlen($gtypes[$sample_id]['corrected_id']) > 0) {
                $result = $db['upd_sth']->execute(array(strtoupper($sample), $gtypes[$sample_id]['corrected_id']));
                check_db_error($result, __FILE__, __LINE__);
                //
                // Otherwise, add a new correction.
                //
            } else {
                if ($sample != $gtypes[$sample_id]['genotype']) {
                    $result = $db['ins_sth']->execute(array($display['batch_id'], $display['tag_id'], $sample_id, strtoupper($sample)));
                    check_db_error($result, __FILE__, __LINE__);
                }
            }
        }
    }
}
Example #12
0
/**
 * Update user record
 *
 * @access public
 * @return void
 */
function update_record($fields, $row, $insert_by)
{
    $sql_cmd = '';
    foreach ($fields as $name => $options) {
        if ($name != 'password_confirm') {
            $sql_cmd .= $name . ' = \'' . $_POST[$name] . '\',';
        }
    }
    // remove last ,
    $sql_cmd = substr_replace($sql_cmd, "", -1);
    $sql_cmd = "\tUPDATE " . TABLE_COMMUNITY . " SET\n\n\t\t\t\t\tmdt = NOW(),\n\t\t\t\t\t\n\t\t\t\t\t" . $sql_cmd . "\n\t\t\t\t\t\n\t\t\t\t\tWHERE " . $insert_by . " = '" . $_POST[$insert_by] . "'\n\n\t\t\t";
    mysql_query($sql_cmd);
    check_db_error($sql_cmd);
    // must set register for newsletter subscribers (insert_by email)
    if ($insert_by == 'email') {
        insert_value('register', '1', $row['id']);
    }
    // used for cookies
    $_POST['id'] = $row['id'];
    $_POST['name'] = $row['forename'];
    $_POST['admin'] = $row['admin'];
    return 'reg_updated';
}
Example #13
0
/**
 * Insert amount/gift_aid into DB
 *
 * @access public
 * @param int		person's id
 * @param float		amount
 * @return void
 */
function insert_amount($pid, $amount, $gift_aid)
{
    $sql_cmd = "\tINSERT INTO " . TABLE_DONATIONS . "(dt, pid, amount, gift_aid)\n\t\t\t\t\tVALUES(\n\n\t\t\t\t\t\tNOW(),\n\t\t\t\t\t\t'" . $pid . "',\n\t\t\t\t\t\t'" . $amount . "',\n\t\t\t\t\t\t'" . $gift_aid . "'\n\n\t\t\t\t\t)";
    mysql_query($sql_cmd);
    check_db_error();
}
Example #14
0
    update_sales_type($selected_id, $_POST['sales_type'], isset($_POST['tax_included']) ? 1 : 0, input_num('price_factor'));
    meta_forward($_SERVER['PHP_SELF']);
}
//----------------------------------------------------------------------------------------------------
if (isset($_GET['delete'])) {
    // PREVENT DELETES IF DEPENDENT RECORDS IN 'debtor_trans'
    $sql = "SELECT COUNT(*) FROM debtor_trans WHERE tpe='{$selected_id}'";
    $result = db_query($sql, "check failed");
    check_db_error("The number of transactions using this Sales type record could not be retrieved", $sql);
    $myrow = db_fetch_row($result);
    if ($myrow[0] > 0) {
        display_error(tr("Cannot delete this sale type because customer transactions have been created using this sales type."));
    } else {
        $sql = "SELECT COUNT(*) FROM debtors_master WHERE sales_type='{$selected_id}'";
        $result = db_query($sql, "check failed");
        check_db_error("The number of customers using this Sales type record could not be retrieved", $sql);
        $myrow = db_fetch_row($result);
        if ($myrow[0] > 0) {
            display_error(tr("Cannot delete this sale type because customers are currently set up to use this sales type."));
        } else {
            delete_sales_type($selected_id);
            meta_forward($_SERVER['PHP_SELF']);
        }
    }
    //end if sales type used in debtor transactions or in customers set up
}
//----------------------------------------------------------------------------------------------------
$result = get_all_sales_types();
start_table("{$table_style} width=30%");
$th = array(tr("Type Name"), 'Tax Incl', 'Price factor', '', '');
table_header($th);
Example #15
0
    $result = db_query($sql, "check failed");
    $myrow = db_fetch_row($result);
    if ($myrow[0] > 0) {
        $cancel_delete = 1;
        display_error(tr("Cannot delete this bank account because transactions have been created using this account."));
    }
    if (!$cancel_delete) {
        delete_bank_account($selected_id);
        meta_forward($_SERVER['PHP_SELF']);
    }
    //end if Delete bank account
}
/* Always show the list of accounts */
$sql = "SELECT bank_accounts.*, chart_master.account_name FROM bank_accounts, chart_master \n\tWHERE bank_accounts.account_code = chart_master.account_code";
$result = db_query($sql, "could not get bank accounts");
check_db_error("The bank accounts set up could not be retreived", $sql);
start_table("{$table_style} width='80%'");
$th = array(tr("GL Account"), tr("Bank"), tr("Account Name"), tr("Type"), tr("Number"), tr("Currency"), tr("Bank Address"));
table_header($th);
$k = 0;
while ($myrow = db_fetch($result)) {
    alt_table_row_color($k);
    label_cell($myrow["account_code"] . " " . $myrow["account_name"], "nowrap");
    label_cell($myrow["bank_name"], "nowrap");
    label_cell($myrow["bank_account_name"], "nowrap");
    label_cell(bank_account_types::name($myrow["account_type"]), "nowrap");
    label_cell($myrow["bank_account_number"], "nowrap");
    label_cell($myrow["bank_curr_code"], "nowrap");
    label_cell($myrow["bank_address"]);
    edit_link_cell("selected_id=" . $myrow["account_code"]);
    delete_link_cell("selected_id=" . $myrow["account_code"] . "&delete=1");
Example #16
0
function write_database($database)
{
    global $root_path, $img_path;
    //
    // Connect to the database
    //
    $db = db_connect($database);
    //
    // Prepare some SQL queries
    //
    $query = "SELECT id, date, description, type FROM batches";
    $db['batch_sth'] = $db['dbh']->prepare($query);
    check_db_error($db['batch_sth'], __FILE__, __LINE__);
    $page_title = "RAD-Tag Analyses";
    write_header($page_title);
    echo <<<EOQ
<h4 class="info_head">
  <img id="sources_img" src="{$img_path}/caret-d.png" />
  <a onclick="toggle_div('sources', '{$img_path}', 'page_state');">RAD-Tag Samples</a>
</h4>

<a name="results_top"></a>
<table class="db" style="width: 75%;">
<tr>
  <th style="width: 10%;">&nbsp;</th>
  <th style="width: 10%;">&nbsp;</th>
  <th style="width: 10%;">Batch ID</th>
  <th style="width: 10%;">Date</th>
  <th style="width: 10%;">Type</th> 
  <th style="width: 50%;">Description</th>
</tr>

EOQ;
    $result = $db['batch_sth']->execute();
    check_db_error($result, __FILE__, __LINE__);
    while ($row = $result->fetchRow()) {
        print "<tr>\n" . "  <td class=\"s\"><a href=\"{$root_path}/catalog.php?db={$database}&id={$row['id']}\">Catalog</a></td>\n" . "  <td class=\"s\"><a href=\"{$root_path}/samples.php?db={$database}&id={$row['id']}\">Samples</a></td>\n" . "  <td>" . $row['id'] . "</td>\n" . "  <td>" . $row['date'] . "</td>\n" . "  <td>" . $row['type'] . "</td>\n" . "  <td>" . $row['description'] . "</td>\n" . "</tr>\n";
    }
    echo <<<EOQ
</table>

EOQ;
    write_footer();
}
Example #17
0
  <th style="width: 12%;">Polymorphic Loci</th>
  <th style="width: 12%;">SNPs Found</th>
  <th style="width: 30%;">Source</th>
</tr>

EOQ;
$result = $db['samp_sth']->execute($batch_id);
check_db_error($result, __FILE__, __LINE__);
while ($row = $result->fetchRow()) {
    $snps = 0;
    $poly = 0;
    // Query the database to determine how many tags belong to this sample.
    $count_res = $db['count_sth']->execute(array($batch_id, $row['id']));
    check_db_error($count_res, __FILE__, __LINE__);
    $count_row = $count_res->fetchRow();
    $count = $count_row['count'];
    // Query the database to find how many SNPs were found in this sample.
    $count_res = $db['snp_sth']->execute(array($batch_id, $row['id']));
    check_db_error($count_res, __FILE__, __LINE__);
    while ($count_row = $count_res->fetchRow()) {
        $snps += $count_row['snps'];
        $poly += $count_row['snps'] > 0 ? 1 : 0;
    }
    print "<tr>\n" . "  <td><a href=\"{$root_path}/tags.php?db={$database}&batch_id={$batch['id']}&sample_id={$row['id']}\">{$row['id']}</a></td>\n" . "  <td>" . ucfirst($row['type']) . "</td>\n" . "  <td>" . $count . "</td>\n" . "  <td>" . $poly . "</td>\n" . "  <td>" . $snps . "</td>\n" . "  <td>" . $row['file'] . "</td>\n" . "</tr>\n";
}
echo <<<EOQ
</table>
</div>

EOQ;
write_footer();
Example #18
0
            display_note(get_gl_view_str(systypes::cost_update(), $update_no, tr("View the GL Journal Entries for this Cost Update")), 1, 0);
        }
    }
}
//-----------------------------------------------------------------------------------------
start_form(false, true);
if (!isset($_POST['stock_id'])) {
    $_POST['stock_id'] = get_global_stock_item();
}
echo "<center>" . tr("Item:") . "&nbsp;";
stock_costable_items_list('stock_id', $_POST['stock_id'], false, true);
echo "</center><hr>";
set_global_stock_item($_POST['stock_id']);
$sql = "SELECT description, units, last_cost, actual_cost, material_cost, labour_cost,\n\toverhead_cost, mb_flag\n\tFROM stock_master\n\tWHERE stock_id='" . $_POST['stock_id'] . "'\n\tGROUP BY description, units, last_cost, actual_cost, material_cost, labour_cost, overhead_cost, mb_flag";
$result = db_query($sql);
check_db_error("The cost details for the item could not be retrieved", $sql);
$myrow = db_fetch($result);
hidden("OldMaterialCost", $myrow["material_cost"]);
hidden("OldLabourCost", $myrow["labour_cost"]);
hidden("OldOverheadCost", $myrow["overhead_cost"]);
start_table($table_style2);
label_row(tr("Last Cost"), price_format($myrow["last_cost"]), "class='tableheader2'", "nowrap align=right");
amount_row(tr("Standard Material Cost Per Unit"), "material_cost", price_format($myrow["material_cost"]), "class='tableheader2'");
if ($myrow["mb_flag"] == 'M') {
    amount_row(tr("Standard Labour Cost Per Unit"), "labour_cost", price_format($myrow["labour_cost"]), "class='tableheader2'");
    amount_row(tr("Standard Overhead Cost Per Unit"), "overhead_cost", price_format($myrow["overhead_cost"]), "class='tableheader2'");
} else {
    hidden("labour_cost", 0);
    hidden("overhead_cost", 0);
}
end_table(1);