Example #1
0
 function render($id, $title)
 {
     global $path_to_root;
     include_once $path_to_root . "/includes/ui.inc";
     $today = date2sql(Today());
     $sql = "SELECT bank_act, bank_account_name, SUM(amount) balance FROM " . TB_PREF . "bank_trans bt" . " INNER JOIN " . TB_PREF . "bank_accounts ba ON bt.bank_act = ba.id" . " WHERE trans_date < '{$today}'" . " AND inactive <> 1";
     if ($this->data_filter != '') {
         $sql .= ' AND ' . $this->data_filter;
     }
     $sql .= " GROUP BY bank_act, bank_account_name" . " ORDER BY bank_account_name";
     $result = db_query($sql);
     br();
     $th = array(_("Account"), _("Balance"));
     start_table(TABLESTYLE, "width=98%");
     table_header($th);
     $k = 0;
     //row colour counter
     while ($myrow = db_fetch($result)) {
         alt_table_row_color($k);
         label_cell($myrow["bank_account_name"]);
         amount_cell($myrow['balance']);
         end_row();
     }
     end_table(1);
 }
function get_transactions()
{
    $data_after = date2sql($_POST['TransAfterDate']);
    $date_to = date2sql($_POST['TransToDate']);
    $sql = "SELECT debtor_trans.*,\n\t\tdebtors_master.name AS CustName, debtors_master.curr_code AS CustCurrCode,\n    \t(debtor_trans.ov_amount + debtor_trans.ov_gst + " . "debtor_trans.ov_freight + debtor_trans.ov_freight_tax + debtor_trans.ov_discount)\n\t\tAS TotalAmount,\n\t\tdebtor_trans.alloc AS Allocated,\n\t\t((debtor_trans.type = 10)\n\t\tAND debtor_trans.due_date < '" . date2sql(Today()) . "') AS OverDue\n    \tFROM debtor_trans, debtors_master\n    \tWHERE debtors_master.debtor_no = debtor_trans.debtor_no\n\t\t\tAND (debtor_trans.ov_amount + debtor_trans.ov_gst + " . "debtor_trans.ov_freight + debtor_trans.ov_freight_tax + debtor_trans.ov_discount != 0)\n    \t\tAND debtor_trans.tran_date >= '{$data_after}'\n    \t\tAND debtor_trans.tran_date <= '{$date_to}'";
    if ($_POST['customer_id'] != reserved_words::get_all()) {
        $sql .= " AND debtor_trans.debtor_no = '" . $_POST['customer_id'] . "'";
    }
    if (isset($_POST['filterType']) && $_POST['filterType'] != reserved_words::get_all()) {
        if ($_POST['filterType'] == '1' || $_POST['filterType'] == '2') {
            $sql .= " AND debtor_trans.type = 10 ";
        } elseif ($_POST['filterType'] == '3') {
            $sql .= " AND debtor_trans.type = " . systypes::cust_payment();
        } elseif ($_POST['filterType'] == '4') {
            $sql .= " AND debtor_trans.type = 11 ";
        }
        if ($_POST['filterType'] == '2') {
            $today = date2sql(Today());
            $sql .= " AND debtor_trans.due_date < '{$today}'\n\t\t\t\tAND (round(abs(debtor_trans.ov_amount + " . "debtor_trans.ov_gst + debtor_trans.ov_freight + " . "debtor_trans.ov_freight_tax + debtor_trans.ov_discount) - debtor_trans.alloc,6) > 0) ";
        }
    } else {
        $sql .= " AND debtor_trans.type != 13 ";
    }
    if (!check_value('showSettled')) {
        $sql .= " AND (round(abs(debtor_trans.ov_amount + debtor_trans.ov_gst + " . "debtor_trans.ov_freight + debtor_trans.ov_freight_tax + " . "debtor_trans.ov_discount) - debtor_trans.alloc,6) != 0) ";
    }
    $sql .= " ORDER BY debtor_trans.tran_date";
    return db_query($sql, "No transactions were returned");
}
Example #3
0
function get_transactions()
{
    $date_after = date2sql($_POST['TransAfterDate']);
    $date_to = date2sql($_POST['TransToDate']);
    $sql = "SELECT debtor_trans.*,debtors_master.name AS CustName," . "debtors_master.curr_code AS CustCurrCode," . "(debtor_trans.ov_amount + debtor_trans.ov_gst + " . "debtor_trans.ov_freight + debtor_trans.ov_freight_tax + " . "debtor_trans.ov_discount) AS " . "TotalAmount, debtor_trans.alloc AS Allocated, " . "((debtor_trans.type = 10) " . "AND debtor_trans.due_date < '" . date2sql(Today()) . "') AS OverDue " . "FROM debtor_trans, debtors_master " . "WHERE debtors_master.debtor_no = debtor_trans.debtor_no " . "AND debtor_trans.tran_date >= '{$date_after}' " . "AND debtor_trans.tran_date <= '{$date_to}'";
    if ($_POST['customer_id'] != reserved_words::get_all()) {
        $sql .= " AND debtor_trans.debtor_no = '" . $_POST['customer_id'] . "'";
    }
    if ($_POST['filterType'] != reserved_words::get_all()) {
        if ($_POST['filterType'] == '1') {
            $sql .= " AND (debtor_trans.type = 10 OR debtor_trans.type = 1) ";
        } elseif ($_POST['filterType'] == '2') {
            $sql .= " AND (debtor_trans.type = 10) ";
        } elseif ($_POST['filterType'] == '3') {
            $sql .= " AND (debtor_trans.type = " . systypes::cust_payment() . " OR debtor_trans.type = 2) ";
        } elseif ($_POST['filterType'] == '4') {
            $sql .= " AND debtor_trans.type = 11 ";
        } elseif ($_POST['filterType'] == '5') {
            $sql .= " AND debtor_trans.type = 13 ";
        }
        if ($_POST['filterType'] == '2') {
            $today = date2sql(Today());
            $sql .= " AND debtor_trans.due_date < '{$today}' " . "AND (debtor_trans.ov_amount + debtor_trans.ov_gst + " . "debtor_trans.ov_freight_tax + debtor_trans.ov_freight + " . "debtor_trans.ov_discount - debtor_trans.alloc > 0) ";
        }
    }
    $sql .= " ORDER BY debtor_trans.tran_date DESC,debtor_trans.type," . "debtor_trans.trans_no ";
    return db_query($sql, "No transactions were returned");
}
Example #4
0
function get_transactions()
{
    global $db;
    $date_after = date2sql($_POST['TransAfterDate']);
    $date_to = date2sql($_POST['TransToDate']);
    // Sherifoz 22.06.03 Also get the description
    $sql = "SELECT supp_trans.type, supp_trans.trans_no,\n    \tsupp_trans.tran_date, supp_trans.reference, supp_trans.supp_reference,\n    \t(supp_trans.ov_amount + supp_trans.ov_gst  + supp_trans.ov_discount) AS TotalAmount, supp_trans.alloc AS Allocated,\n\t\t((supp_trans.type = 20 OR supp_trans.type = 21) AND supp_trans.due_date < '" . date2sql(Today()) . "') AS OverDue,\n    \t(ABS(supp_trans.ov_amount + supp_trans.ov_gst  + supp_trans.ov_discount - supp_trans.alloc) <= 0.005) AS Settled,\n\t\tsuppliers.curr_code, suppliers.supp_name, supp_trans.due_date\n    \tFROM supp_trans, suppliers\n    \tWHERE suppliers.supplier_id = supp_trans.supplier_id\n     \tAND supp_trans.tran_date >= '{$date_after}'\n    \tAND supp_trans.tran_date <= '{$date_to}'";
    if ($_POST['supplier_id'] != reserved_words::get_all()) {
        $sql .= " AND supp_trans.supplier_id = '" . $_POST['supplier_id'] . "'";
    }
    if (isset($_POST['filterType']) && $_POST['filterType'] != reserved_words::get_all()) {
        if ($_POST['filterType'] == '1') {
            $sql .= " AND (supp_trans.type = 20 OR supp_trans.type = 2)";
        } elseif ($_POST['filterType'] == '2') {
            $sql .= " AND supp_trans.type = 20 ";
        } elseif ($_POST['filterType'] == '3') {
            $sql .= " AND (supp_trans.type = 22 OR supp_trans.type = 1) ";
        } elseif ($_POST['filterType'] == '4' || $_POST['filterType'] == '5') {
            $sql .= " AND supp_trans.type = 21  ";
        }
        if ($_POST['filterType'] == '2' || $_POST['filterType'] == '5') {
            $today = date2sql(Today());
            $sql .= " AND supp_trans.due_date < '{$today}' ";
        }
    }
    $sql .= " ORDER BY supp_trans.tran_date";
    return db_query($sql, "No supplier transactions were returned");
}
Example #5
0
function getAverageCost($stock_id, $to_date)
{
    if ($to_date == null) {
        $to_date = Today();
    }
    $to_date = date2sql($to_date);
    $sql = "SELECT standard_cost, price, tran_date, type, trans_no, qty, person_id FROM " . TB_PREF . "stock_moves\n\t\tWHERE stock_id=" . db_escape($stock_id) . "\n\t\tAND tran_date <= '{$to_date}' AND standard_cost > 0.001 AND qty <> 0 AND type <> " . ST_LOCTRANSFER;
    $sql .= " ORDER BY tran_date";
    $result = db_query($sql, "No standard cost transactions were returned");
    if ($result == false) {
        return 0;
    }
    $qty = $old_qty = $count = $old_std_cost = $tot_cost = 0;
    while ($row = db_fetch($result)) {
        $qty += $row['qty'];
        $price = get_domestic_price($row, $stock_id, $qty, $old_std_cost, $old_qty);
        $old_std_cost = $row['standard_cost'];
        $tot_cost += $price;
        $count++;
        $old_qty = $qty;
    }
    if ($count == 0) {
        return 0;
    }
    return $tot_cost / $count;
}
 function render($id, $title)
 {
     global $path_to_root, $systypes_array;
     include_once $path_to_root . "/includes/ui.inc";
     $start_date = add_days(Today(), -$this->days_past);
     $end_date = add_days(Today(), $this->days_future);
     $result = get_bank_trans_for_bank_account($this->bank_act, $start_date, $end_date);
     start_table(TABLESTYLE, 'width=98%');
     $th = array(_("#"), _("Date"), _("Receipt"), _("Payment"), _("Balance"), _("Person/Item"), _("Memo"), "");
     table_header($th);
     $bfw = get_balance_before_for_bank_account($this->bank_act, $start_date);
     $credit = $debit = 0;
     start_row("class='inquirybg' style='font-weight:bold'");
     label_cell(_("Opening Balance") . " - " . $start_date, "colspan=4");
     display_debit_or_credit_cells($bfw);
     label_cell("");
     label_cell("", "colspan=2");
     end_row();
     $running_total = $bfw;
     if ($bfw > 0) {
         $debit += $bfw;
     } else {
         $credit += $bfw;
     }
     $j = 1;
     $k = 0;
     //row colour counter
     while ($myrow = db_fetch($result)) {
         alt_table_row_color($k);
         $running_total += $myrow["amount"];
         label_cell(get_trans_view_str($myrow["type"], $myrow["trans_no"]));
         $trandate = sql2date($myrow["trans_date"]);
         label_cell($trandate);
         display_debit_or_credit_cells($myrow["amount"]);
         amount_cell($running_total);
         label_cell(payment_person_name($myrow["person_type_id"], $myrow["person_id"]));
         label_cell(get_comments_string($myrow["type"], $myrow["trans_no"]));
         label_cell(get_gl_view_str($myrow["type"], $myrow["trans_no"]));
         end_row();
         if ($myrow["amount"] > 0) {
             $debit += $myrow["amount"];
         } else {
             $credit += $myrow["amount"];
         }
         if ($j == 12) {
             $j = 1;
             table_header($th);
         }
         $j++;
     }
     //end of while loop
     start_row("class='inquirybg' style='font-weight:bold'");
     label_cell(_("Ending Balance") . " - " . $end_date, "colspan=4");
     amount_cell($debit + $credit);
     label_cell("");
     label_cell("", "colspan=2");
     end_row();
     end_table(2);
 }
Example #7
0
function check_overdue($row)
{
    global $trans_type;
    if ($trans_type == ST_SALESQUOTE) {
        return date1_greater_date2(Today(), sql2date($row['delivery_date']));
    } else {
        return $row['type'] == 0 && date1_greater_date2(Today(), sql2date($row['ord_date'])) && $row['TotDelivered'] < $row['TotQuantity'];
    }
}
 function render($id, $title)
 {
     global $path_to_root;
     include_once $path_to_root . "/includes/ui.inc";
     include_once $path_to_root . "/reporting/includes/class.graphic.inc";
     if (!defined('FLOAT_COMP_DELTA')) {
         define('FLOAT_COMP_DELTA', 0.004);
     }
     if (!isset($this->top)) {
         $this->top = 10;
     }
     $begin = begin_fiscalyear();
     $today = Today();
     $begin1 = date2sql($begin);
     $today1 = date2sql($today);
     $sql = "SELECT SUM((trans.ov_amount + trans.ov_discount) * rate) AS total, s.supplier_id, s.supp_name FROM\n            " . TB_PREF . "supp_trans AS trans, " . TB_PREF . "suppliers AS s WHERE trans.supplier_id=s.supplier_id\n            AND (trans.type = " . ST_SUPPINVOICE . " OR trans.type = " . ST_SUPPCREDIT . ")\n            AND tran_date >= '{$begin1}' AND tran_date <= '{$today1}' ";
     if ($this->data_filter != '') {
         $sql .= ' AND ' . $this->data_filter;
     }
     $sql .= "GROUP by s.supplier_id ORDER BY total DESC, s.supplier_id " . " LIMIT " . $this->top;
     $result = db_query($sql);
     if ($this->graph_type == 'Table') {
         $th = array(_("Supplier"), _("Amount"));
         start_table(TABLESTYLE, "width=98%");
         table_header($th);
         $k = 0;
         //row colour counter
         while ($myrow = db_fetch($result)) {
             alt_table_row_color($k);
             $name = $myrow["supplier_id"] . " " . $myrow["supp_name"];
             label_cell($name);
             amount_cell($myrow['total']);
             end_row();
         }
         end_table(1);
     } else {
         $pg = new graph();
         $i = 0;
         while ($myrow = db_fetch($result)) {
             $name = $myrow["supplier_id"] . " " . $myrow["supp_name"];
             $pg->x[$i] = $name;
             $pg->y[$i] = $myrow['total'];
             $i++;
         }
         $pg->title = $title;
         $pg->axis_x = _("Supplier");
         $pg->axis_y = _("Amount");
         $pg->graphic_1 = $today;
         $pg->type = 2;
         $pg->skin = 1;
         $pg->built_in = false;
         $filename = company_path() . "/pdf_files/" . uniqid("") . ".png";
         $pg->display($filename, true);
         echo "<img src='{$filename}' border='0' alt='{$title}' style='max-width:100%'>";
     }
 }
 function menu_footer($no_menu, $is_index)
 {
     global $version, $allow_demo_mode, $app_title, $power_url, $power_by, $path_to_root, $Pagehelp, $Ajax;
     include_once $path_to_root . "/includes/date_functions.inc";
     $context = array('isIndex' => $is_index, 'date' => Today(), 'time' => Now());
     if ($no_menu == false) {
         $footer = ThemeBootstrap::get()->renderBlock('page.twig.html', 'footer', $context);
         echo $footer;
     }
 }
Example #10
0
 function render($id, $title)
 {
     global $path_to_root;
     if (!isset($this->top)) {
         $this->top = 10;
     }
     global $path_to_root;
     $pg = new graph();
     $begin = begin_fiscalyear();
     $today = Today();
     $begin1 = date2sql($begin);
     $today1 = date2sql($today);
     $sql = "SELECT SUM(-t.amount) AS total, d.reference, d.name FROM\n            " . TB_PREF . "gl_trans AS t," . TB_PREF . "dimensions AS d WHERE\n            (t.dimension_id = d.id OR t.dimension2_id = d.id) AND\n            t.tran_date >= '{$begin1}' AND t.tran_date <= '{$today1}' ";
     if ($this->data_filter != '') {
         $sql .= ' AND ' . $this->data_filter;
     }
     $sql .= "GROUP BY d.id ORDER BY total DESC LIMIT " . $this->top;
     $result = db_query($sql, "Transactions could not be calculated");
     if ($this->graph_type == 'Table') {
         $title = _("Top 10 Dimensions in fiscal year");
         br(2);
         display_heading($title);
         br();
         $th = array(_("Dimension"), _("Amount"));
         start_table(TABLESTYLE, "width=98%");
         table_header($th);
         $k = 0;
         //row colour counter
         while ($myrow = db_fetch($result)) {
             alt_table_row_color($k);
             label_cell($myrow['reference'] . " " . $myrow["name"]);
             amount_cell($myrow['total']);
             end_row();
         }
         end_table(2);
     } else {
         $pg = new graph();
         $i = 0;
         while ($myrow = db_fetch($result)) {
             $pg->x[$i] = $myrow['reference'] . " " . $myrow["name"];
             $pg->y[$i] = abs($myrow['total']);
             $i++;
         }
         $pg->title = $title;
         $pg->axis_x = _("Dimension");
         $pg->axis_y = _("Amount");
         $pg->graphic_1 = $today;
         $pg->type = 5;
         $pg->skin = 1;
         $pg->built_in = false;
         $filename = company_path() . "/pdf_files/" . uniqid("") . ".png";
         $pg->display($filename, true);
         echo "<img src='{$filename}' border='0' alt='{$title}' style='max-width:100%'>";
     }
 }
Example #11
0
 function render($id, $title)
 {
     global $path_to_root;
     include_once $path_to_root . "/reporting/includes/class.graphic.inc";
     if (!defined('FLOAT_COMP_DELTA')) {
         define('FLOAT_COMP_DELTA', 0.004);
     }
     if (!isset($this->top)) {
         $this->top = 10;
     }
     $begin = begin_fiscalyear();
     $today = Today();
     $begin1 = date2sql($begin);
     $today1 = date2sql($today);
     $sql = "SELECT SUM((ov_amount + ov_discount) * rate * IF(trans.type = " . ST_CUSTCREDIT . ", -1, 1)) AS total,d.debtor_no, d.name" . " FROM " . TB_PREF . "debtor_trans AS trans, " . TB_PREF . "debtors_master AS d" . " WHERE trans.debtor_no=d.debtor_no" . " AND (trans.type = " . ST_SALESINVOICE . " OR trans.type = " . ST_CUSTCREDIT . ")" . " AND tran_date >= '{$begin1}' AND tran_date <= '{$today1}'";
     if ($this->data_filter != '') {
         $sql .= ' AND ' . $this->data_filter;
     }
     $sql .= " GROUP by d.debtor_no ORDER BY total DESC, d.debtor_no " . " LIMIT " . $this->top;
     $result = db_query($sql);
     if ($this->graph_type == 'Table') {
         $th = array(null, _("Customer"), _("Amount"));
         start_table(TABLESTYLE, "width=98%");
         table_header($th);
         $k = 0;
         //row colour counter
         $i = 0;
         while ($myrow = db_fetch($result)) {
             alt_table_row_color($k);
             label_cell(viewer_link($myrow["debtor_no"], 'sales/inquiry/customer_inquiry.php?customer_id=' . $myrow["debtor_no"]));
             label_cell(viewer_link($myrow["name"], 'sales/inquiry/customer_inquiry.php?customer_id=' . $myrow["debtor_no"]));
             amount_cell($myrow['total']);
             end_row();
         }
         end_table(1);
     } else {
         $pg = new graph();
         $i = 0;
         while ($myrow = db_fetch($result)) {
             $pg->x[$i] = $myrow["debtor_no"] . " " . $myrow["name"];
             $pg->y[$i] = $myrow['total'];
             $i++;
         }
         $pg->title = $title;
         $pg->axis_x = _("Customer");
         $pg->axis_y = _("Amount");
         $pg->graphic_1 = $today;
         $pg->type = 2;
         $pg->skin = 1;
         $pg->built_in = false;
         $filename = company_path() . "/pdf_files/" . uniqid("") . ".png";
         $pg->display($filename, true);
         echo "<img src='{$filename}' border='0' alt='{$title}' style='max-width:100%'>";
     }
 }
Example #12
0
 function render($id, $title)
 {
     global $path_to_root;
     include_once $path_to_root . "/reporting/includes/class.graphic.inc";
     $begin = begin_fiscalyear();
     $today = Today();
     $begin1 = date2sql($begin);
     $today1 = date2sql($today);
     $sql = "SELECT SUM(amount) AS total, c.class_name, c.ctype FROM\n            " . TB_PREF . "gl_trans," . TB_PREF . "chart_master AS a, " . TB_PREF . "chart_types AS t,\n            " . TB_PREF . "chart_class AS c WHERE\n            account = a.account_code AND a.account_type = t.id AND t.class_id = c.cid\n            AND IF(c.ctype > 3, tran_date >= '{$begin1}', tran_date >= '0000-00-00')\n            AND tran_date <= '{$today1}' ";
     if ($this->data_filter != '') {
         $sql .= ' AND ' . $this->data_filter;
     }
     $sql .= " GROUP BY c.cid ORDER BY c.cid";
     $result = db_query($sql, "Transactions could not be calculated");
     $calculated = _("Calculated Return");
     if ($this->graph_type == 'Table') {
         start_table(TABLESTYLE2, "width=98%");
         $total = 0;
         while ($myrow = db_fetch($result)) {
             if ($myrow['ctype'] > 3) {
                 $total += $myrow['total'];
                 $myrow['total'] = -$myrow['total'];
             }
             label_row($myrow['class_name'], number_format2($myrow['total'], user_price_dec()), "class='label' style='font-weight:bold;'", "style='font-weight:bold;' align=right");
         }
         label_row("&nbsp;", "");
         label_row($calculated, number_format2(-$total, user_price_dec()), "class='label' style='font-weight:bold;'", "style='font-weight:bold;' align=right");
         end_table(1);
     } else {
         $pg = new graph();
         $i = 0;
         $total = 0;
         while ($myrow = db_fetch($result)) {
             if ($myrow['ctype'] > 3) {
                 $total += $myrow['total'];
                 $myrow['total'] = -$myrow['total'];
                 $pg->x[$i] = $myrow['class_name'];
                 $pg->y[$i] = abs($myrow['total']);
                 $i++;
             }
         }
         $pg->x[$i] = $calculated;
         $pg->y[$i] = -$total;
         $pg->title = $title;
         $pg->axis_x = _("Class");
         $pg->axis_y = _("Amount");
         $pg->graphic_1 = $today;
         $pg->type = 5;
         $pg->skin = 1;
         $pg->built_in = false;
         $filename = company_path() . "/pdf_files/" . uniqid("") . ".png";
         $pg->display($filename, true);
         echo "<img src='{$filename}' border='0' alt='{$title}' style='max-width:100%'>";
     }
 }
 public function getLastExchangeRate($rest, $currencyCode)
 {
     $date = date2sql(Today());
     $sql = "SELECT rate_buy, max(date_) as date_ FROM " . TB_PREF . "exchange_rates WHERE curr_code = " . db_escape($id) . " AND date_ <= '{$date}' GROUP BY rate_buy ORDER BY date_ Desc LIMIT 1";
     $result = db_query($sql, "could not query exchange rates");
     if (db_num_rows($result) == 0) {
         // no stored exchange rate, just return 0
         api_success_response(json_encode(array('curr_abrev' => $id, 'rate' => 0, 'date' => $date)));
     }
     $myrow = db_fetch_row($result);
     api_success_response(json_encode(array('curr_abrev' => $id, 'rate' => $myrow[0], 'date' => $myrow[1])));
 }
Example #14
0
 public function update()
 {
     $this->load->model('modgenerador');
     $this->modgenerador->getFromInput();
     $statusActual = $this->input->post("frm_generador_activo_current");
     if ($this->modgenerador->getActivo() != $statusActual) {
         $this->modgenerador->setFechaactivo(Today());
     }
     $this->modgenerador->updateToDatabase();
     echo $this->modgenerador->getIdgenerador();
     $this->modsesion->addLog("actualizar", $this->modgenerador->getIdgenerador(), $this->modgenerador->getRazonsocial(), "generador", "relrutgen");
 }
Example #15
0
function handle_new_order()
{
    if (isset($_SESSION['transfer_items'])) {
        $_SESSION['transfer_items']->clear_items();
        unset($_SESSION['transfer_items']);
    }
    session_register("transfer_items");
    $_SESSION['transfer_items'] = new items_cart();
    $_POST['AdjDate'] = Today();
    if (!is_date_in_fiscalyear($_POST['AdjDate'])) {
        $_POST['AdjDate'] = end_fiscalyear();
    }
    $_SESSION['transfer_items']->tran_date = $_POST['AdjDate'];
}
Example #16
0
function getYTD($dim)
{
    $date = Today();
    $date = begin_fiscalyear($date);
    date2sql($date);
    $sql = "SELECT SUM(amount) AS Balance\n\t\tFROM\n\t\t\t" . TB_PREF . "gl_trans\n\t\tWHERE (dimension_id = '{$dim}' OR dimension2_id = '{$dim}')\n\t\tAND tran_date >= '{$date}'";
    $TransResult = db_query($sql, "No transactions were returned");
    if (db_num_rows($TransResult) == 1) {
        $DemandRow = db_fetch_row($TransResult);
        $balance = $DemandRow[0];
    } else {
        $balance = 0.0;
    }
    return $balance;
}
function display_reval()
{
    global $Refs;
    start_form();
    start_table(TABLESTYLE2);
    if (!isset($_POST['date'])) {
        $_POST['date'] = Today();
    }
    date_row(_("Date for Revaluation:"), 'date', '', null, 0, 0, 0, null, true);
    ref_row(_("Reference:"), 'ref', '', $Refs->get_next(ST_JOURNAL));
    textarea_row(_("Memo:"), 'memo_', null, 40, 4);
    end_table(1);
    submit_center('submit', _("Revaluate Currencies"), true, false);
    end_form();
}
Example #18
0
 function menu_footer($no_menu, $is_index)
 {
     global $path_to_root, $power_url, $power_by;
     include_once $path_to_root . "/includes/date_functions.inc";
     if ($no_menu == false) {
         echo "<div id='footer'>\n";
         if (isset($_SESSION['wa_current_user'])) {
             echo "<span class='power'><a target='_blank' href='{$power_url}'>{$power_by}</a></span\n";
             echo "<span class='date'>" . Today() . " | " . Now() . "</span>\n";
             echo "<span class='date'>" . show_users_online() . "</span>\n";
         }
         echo "</div>\n";
     }
     echo "</div>\n";
     echo "</div>\n";
 }
Example #19
0
function display_controls()
{
    global $table_style2;
    start_form(false, true);
    if (!isset($_POST['supplier_id'])) {
        $_POST['supplier_id'] = get_global_supplier(false);
    }
    if (!isset($_POST['DatePaid'])) {
        $_POST['DatePaid'] = Today();
        if (!is_date_in_fiscalyear($_POST['DatePaid'])) {
            $_POST['DatePaid'] = end_fiscalyear();
        }
    }
    start_table($table_style2, 5, 7);
    echo "<tr><td valign=top>";
    // outer table
    echo "<table>";
    bank_accounts_list_row(tr("From Bank Account:"), 'bank_account', null, true);
    amount_row(tr("Amount of Payment:"), 'amount');
    amount_row(tr("Amount of Discount:"), 'discount');
    date_row(tr("Date Paid") . ":", 'DatePaid');
    echo "</table>";
    echo "</td><td valign=top class='tableseparator'>";
    // outer table
    echo "<table>";
    supplier_list_row(tr("Payment To:"), 'supplier_id', null, false, true);
    set_global_supplier($_POST['supplier_id']);
    $supplier_currency = get_supplier_currency($_POST['supplier_id']);
    $bank_currency = get_bank_account_currency($_POST['bank_account']);
    if ($bank_currency != $supplier_currency) {
        exchange_rate_display($bank_currency, $supplier_currency, $_POST['DatePaid']);
    }
    bank_trans_types_list_row(tr("Payment Type:"), 'PaymentType', null);
    ref_row(tr("Reference:"), 'ref', references::get_next(22));
    text_row(tr("Memo:"), 'memo_', null, 52, 50);
    echo "</table>";
    echo "</td></tr>";
    end_table(1);
    // outer table
    submit_center('ProcessSuppPayment', tr("Enter Payment"));
    if ($bank_currency != $supplier_currency) {
        display_note(tr("The amount and discount are in the bank account's currency."), 2, 0);
    }
    end_form();
}
Example #20
0
 public function __construct()
 {
     $this->idpartida = 0;
     $this->fecha = Today();
     $this->hora = Hora();
     $this->cantidad = 0;
     $this->concepto = "";
     $this->preciounitario = 0.0;
     $this->descuento = 0.0;
     $this->importe = 0.0;
     $this->status = 0;
     $this->usuario = 0;
     $this->idpedido = 0;
     $this->idproducto = 0;
     $this->preciobase = "";
     $this->impuesoporc = "";
     $this->impuesto = "";
 }
Example #21
0
function trans_qty_unit_cost($stock_id, $location = null, $from_date, $to_date, $inward = true)
{
    if ($from_date == null) {
        $from_date = Today();
    }
    $from_date = date2sql($from_date);
    if ($to_date == null) {
        $to_date = Today();
    }
    $to_date = date2sql($to_date);
    $sql = "SELECT AVG (standard_cost)   FROM " . TB_PREF . "stock_moves\n\t\tWHERE stock_id=" . db_escape($stock_id) . "\n\t\tAND tran_date >= '{$from_date}' \n\t\tAND tran_date <= '{$to_date}'";
    if ($location != '') {
        $sql .= " AND loc_code = " . db_escape($location);
    }
    if ($inward) {
        $sql .= " AND qty > 0 ";
    } else {
        $sql .= " AND qty < 0 ";
    }
    $result = db_query($sql, "QOH calculation failed");
    $myrow = db_fetch_row($result);
    return $myrow[0];
}
Example #22
0
 function render($id, $title)
 {
     global $path_to_root;
     include_once $path_to_root . "/includes/ui.inc";
     if (!defined('FLOAT_COMP_DELTA')) {
         define('FLOAT_COMP_DELTA', 0.004);
     }
     $today = date2sql(Today());
     $sql = "SELECT trans.trans_no, trans.reference, trans.tran_date, trans.due_date, debtor.debtor_no,\n            debtor.name, branch.br_name, debtor.curr_code,\n            (trans.ov_amount + trans.ov_gst + trans.ov_freight\n                + trans.ov_freight_tax + trans.ov_discount) AS total,\n            (trans.ov_amount + trans.ov_gst + trans.ov_freight\n                + trans.ov_freight_tax + trans.ov_discount - trans.alloc) AS remainder,\n            DATEDIFF('{$today}', trans.due_date) AS days\n            FROM " . TB_PREF . "debtor_trans as trans, " . TB_PREF . "debtors_master as debtor,\n                " . TB_PREF . "cust_branch as branch\n            WHERE debtor.debtor_no = trans.debtor_no AND trans.branch_code = branch.branch_code\n                AND trans.type = " . ST_SALESINVOICE . " AND (trans.ov_amount + trans.ov_gst + trans.ov_freight\n                + trans.ov_freight_tax + trans.ov_discount - trans.alloc) > " . FLOAT_COMP_DELTA . "\n                AND DATEDIFF('{$today}', trans.due_date) > 0 ORDER BY days DESC";
     if ($this->data_filter != '') {
         $sql .= ' AND ' . $this->data_filter;
     }
     $result = db_query($sql);
     $title = db_num_rows($result) . _(" Overdue Sales Invoices");
     br(1);
     display_heading($title);
     br();
     $th = array("#", _("Date"), _("Due Date"), _("Customer"), _("Currency"), _("Total"), _("Remainder"), _("Days"));
     start_table(TABLESTYLE, "width=98%");
     table_header($th);
     $k = 0;
     //row colour counter
     while ($myrow = db_fetch($result)) {
         alt_table_row_color($k);
         label_cell(get_trans_view_str(ST_SALESINVOICE, $myrow["trans_no"]));
         label_cell(sql2date($myrow['tran_date']));
         label_cell(sql2date($myrow['due_date']));
         $name = $myrow["debtor_no"] . " " . $myrow["name"];
         label_cell($name);
         label_cell($myrow['curr_code']);
         amount_cell($myrow['total']);
         amount_cell($myrow['remainder']);
         label_cell($myrow['days'], "align='right'");
         end_row();
     }
     end_table(1);
 }
Example #23
0
 function render($id, $title)
 {
     global $path_to_root;
     include_once $path_to_root . "/includes/ui.inc";
     $end_date = date2sql(add_days(Today(), $this->days_future));
     $role_id = $_SESSION["wa_current_user"]->access;
     $sql = "SELECT id, description, next_date FROM " . TB_PREF . "dashboard_reminders " . " WHERE next_date < '{$end_date}'" . " AND role_id = '{$role_id}'";
     if ($this->data_filter != '') {
         $sql .= ' AND ' . $this->data_filter;
     }
     $sql .= " ORDER BY next_date";
     $result = db_query($sql);
     br();
     $th = array(_("Actioned"), _("Date"), _("Description"));
     start_table(TABLESTYLE, "id='reminder' width=98%");
     table_header($th);
     $k = 0;
     //row colour counter
     while ($myrow = db_fetch($result)) {
         $nextdate = sql2date($myrow["next_date"]);
         if (date1_greater_date2(Today(), $nextdate)) {
             $extra = "class='reminder_overdue'";
         } elseif (Today() == $nextdate) {
             $extra = "class='reminder_due'";
         } else {
             $extra = "class='reminder'";
         }
         alt_table_row_color($k);
         $js = 'setTimeout(function(){updateToDoData(' . $myrow["id"] . ');}, 0);';
         check_cells(null, null, null, $js);
         label_cell($nextdate, $extra);
         label_cell("<pre>" . $myrow["description"] . "</pre>", $extra);
         end_row();
     }
     end_table(1);
 }
Example #24
0
function Hoy()
{
    return DateToMx(Today());
}
    table_section_title(_(""));
    label_row(_(" Gross Earning"), $gross, 'style="color:#A86A0B; background-color:#F2F6D5;"', 'style="color:#A86A0B; background-color:#F2F6D5;"');
    table_section(2);
    table_section_title(_("Deduction"));
    label_row(_(" Provident Fund:"), $pf, null, 30, 30);
    label_row(_(" LOP Amount:"), $lop_amount, null, 30, 30);
    label_row(_(" Monthly Amount:"), $staff_loan, null, 30, 30);
    label_row(_(" Other Deduction:"), $tds, null, 30, 30);
    label_row(_(" Total Deductions"), $total_ded, 'style="color:#f55; background-color:#fed;"', 'style="color:#f55; background-color:#fed;"');
    label_row(_(" "), '', null, 30, 30);
    label_row(_(" Net Salary Payable:"), $total_net, 'style="color:#107B0F; background-color:#B7DBC1;"', 'style="color:#107B0F; background-color:#B7DBC1;"');
    end_outer_table(1);
    if (!db_has_employee_payslip($_POST['year'], $_POST['month'], $_POST['empl_id'])) {
        start_table(TABLESTYLE2);
        echo '<tr>';
        $from = Today();
        $from = add_days($from, 1);
        $bal = get_balance_before_for_bank_account(1, $from);
        //echo $trans_no = kv_get_next_trans_no(99) + 1;
        if ($total_net <= $bal) {
            submit_cells('pay_salary', _("Process Payout"), '', _('Show Results'), 'default');
        } else {
            display_warning(" Your Current Account Balance is lower than the payout!.");
        }
        echo '</tr>';
        end_table();
    } else {
        display_warning(" Paid Already!.");
    }
    div_end();
}
Example #26
0
 public function buildObjectHTML($CRLF, $TAB, $PREFIX)
 {
     $dq = '"';
     $fieldName = $PREFIX . $this->objectProperty['sob_all_name'];
     //   		$fieldTitle      = $this->objectProperty['sob_all_title'];
     $fieldTitle = "<div id='{$fieldName}" . "_title'>" . $this->objectProperty['sob_all_title'] . '</div>';
     if (!$this->displayThisObject) {
         //--set it blank so no title will be displayed
         $fieldTitle = '';
     }
     $fieldValue = htmlentities($this->objectValue);
     $type = $this->objectProperty['sob_all_type'];
     $id = uniqid('', true);
     $pValue = addEscapes($this->objectValue);
     $ses = $_GET['ses'];
     $s = "INSERT INTO zzsys_variable (zzsys_variable_id, sva_id, sva_expiry_date, sva_session_id, sva_name, sva_value, sys_added)  ";
     $s = $s . "VALUES ('{$id}', '{$this->formsessionID}', '" . nuDateAddDays(Today(), 2) . "', '{$ses}', '{$fieldName}', '{$pValue}', '" . date('Y-m-d H:i:s') . "')";
     if ($type != 'words') {
         nuRunQuery($s);
     }
     if ($type == 'button') {
         $htmlString = $this->buildHTMLForButton($CRLF, $TAB, $fieldName, $fieldTitle, $fieldValue, $PREFIX);
     }
     if ($type == 'display') {
         $htmlString = $this->buildHTMLForDisplay($CRLF, $TAB, $fieldName, $fieldTitle, $fieldValue);
     }
     if ($type == 'dropdown') {
         $htmlString = $this->buildHTMLForDropdown($CRLF, $TAB, $fieldName, $fieldTitle, $fieldValue, $PREFIX);
     }
     if ($type == 'graph') {
         $htmlString = $this->buildHTMLForGraph($CRLF, $TAB, $fieldName, $fieldTitle, $fieldValue);
     }
     if ($type == 'html') {
         $htmlString = $this->buildHTMLForHtml($CRLF, $TAB, $fieldName, $fieldTitle, $fieldValue);
     }
     if ($type == 'inarray') {
         $htmlString = $this->buildHTMLForInarray($CRLF, $TAB, $fieldName, $fieldTitle, $fieldValue, $PREFIX);
     }
     if ($type == 'listbox') {
         $htmlString = $this->buildHTMLForListbox($CRLF, $TAB, $fieldName, $fieldTitle, $fieldValue);
     }
     if ($type == 'lookup') {
         $htmlString = $this->buildHTMLForLookup($CRLF, $TAB, $fieldName, $fieldTitle, $fieldValue, $PREFIX);
     }
     if ($type == 'text') {
         $htmlString = $this->buildHTMLForText($CRLF, $TAB, $fieldName, $fieldTitle, $fieldValue, $PREFIX);
     }
     if ($type == 'textarea') {
         $htmlString = $this->buildHTMLForTextarea($CRLF, $TAB, $fieldName, $fieldTitle, $fieldValue, $PREFIX);
     }
     if ($type == 'words') {
         $htmlString = $this->buildHTMLForWords($CRLF, $TAB);
     }
     if ($type == 'subform') {
         $htmlString = $this->buildHTMLForSubform($CRLF, $TAB, $fieldName, $fieldTitle, $this->objectProperty['sob_subform_blank_rows'], $this->objectProperty['zzsys_object_id']);
     }
     nuRunQuery("DROP TABLE IF EXISTS `{$this->TT}`");
     return $htmlString;
 }
Example #27
0
function check_overdue($row)
{
    return !$row["closed"] && date_diff2(Today(), sql2date($row["required_by"]), "d") > 0;
}
Example #28
0
read_po($_GET['trans_no'], $purchase_order);
echo "<br>";
display_po_summary($purchase_order, true);
start_table(TABLESTYLE, "width='90%'", 6);
echo "<tr><td valign=top>";
// outer table
display_heading2(_("Line Details"));
start_table(TABLESTYLE, "width='100%'");
$th = array(_("Item Code"), _("Item Description"), _("Quantity"), _("Unit"), _("Price"), _("Requested By"), _("Line Total"), _("Quantity Received"), _("Quantity Invoiced"));
table_header($th);
$total = $k = 0;
$overdue_items = false;
foreach ($purchase_order->line_items as $stock_item) {
    $line_total = $stock_item->quantity * $stock_item->price;
    // if overdue and outstanding quantities, then highlight as so
    if ($stock_item->quantity - $stock_item->qty_received > 0 && date1_greater_date2(Today(), $stock_item->req_del_date)) {
        start_row("class='overduebg'");
        $overdue_items = true;
    } else {
        alt_table_row_color($k);
    }
    label_cell($stock_item->stock_id);
    label_cell($stock_item->item_description);
    $dec = get_qty_dec($stock_item->stock_id);
    qty_cell($stock_item->quantity, false, $dec);
    label_cell($stock_item->units);
    amount_decimal_cell($stock_item->price);
    label_cell($stock_item->req_del_date);
    amount_cell($line_total);
    qty_cell($stock_item->qty_received, false, $dec);
    qty_cell($stock_item->qty_inv, false, $dec);
        display_footer_exit();
    }
    update_last_sent_recurrent_invoice($tmpl_no, $to);
    return $invno;
}
function calculate_from($myrow)
{
    if ($myrow["last_sent"] == '0000-00-00') {
        $from = sql2date($myrow["begin"]);
    } else {
        $from = sql2date($myrow["last_sent"]);
    }
    return $from;
}
if (!isset($_POST['date'])) {
    $_POST['date'] = Today();
}
$id = find_submit("create");
if ($id != -1) {
    $Ajax->activate('_page_body');
    $date = $_POST['date'];
    if (is_date_in_fiscalyear($date)) {
        $invs = array();
        $myrow = get_recurrent_invoice($id);
        $from = calculate_from($myrow);
        $to = add_months($from, $myrow['monthly']);
        $to = add_days($to, $myrow['days']);
        if ($myrow['debtor_no'] == 0) {
            $cust = get_cust_branches_from_group($myrow['group_no']);
            while ($row = db_fetch($cust)) {
                $invs[] = create_recurrent_invoices($row['debtor_no'], $row['branch_code'], $myrow['order_no'], $myrow['id'], $date, $from, $to);
    update_reconciled_values($reconcile_id, $reconcile_value, $_POST['reconcile_date'], input_num('end_balance'), $_POST['bank_account']);
    $Ajax->activate('reconciled');
    $Ajax->activate('difference');
    return true;
}
if (!isset($_POST['reconcile_date'])) {
    // init page
    $_POST['reconcile_date'] = new_doc_date();
    //	$_POST['bank_date'] = date2sql(Today());
}
if (list_updated('bank_account')) {
    $Ajax->activate('bank_date');
    update_data();
}
if (list_updated('bank_date')) {
    $_POST['reconcile_date'] = get_post('bank_date') == '' ? Today() : sql2date($_POST['bank_date']);
    update_data();
}
if (get_post('_reconcile_date_changed')) {
    $_POST['bank_date'] = check_date() ? date2sql(get_post('reconcile_date')) : '';
    $Ajax->activate('bank_date');
    update_data();
}
$id = find_submit('_rec_');
if ($id != -1) {
    change_tpl_flag($id);
}
if (isset($_POST['Reconcile'])) {
    set_focus('bank_date');
    foreach ($_POST['last'] as $id => $value) {
        if ($value != check_value('rec_' . $id)) {