Beispiel #1
0
include_once $path_to_root . "/includes/date_functions.inc";
include_once $path_to_root . "/admin/db/company_db.inc";
include_once $path_to_root . "/admin/db/maintenance_db.inc";
include_once $path_to_root . "/includes/ui.inc";
//---------------------------------------------------------------------------------------------
if ($id = find_submit('Delete', false)) {
    $extensions = get_company_extensions();
    if ($extensions[$id]['type'] == 'chart' && uninstall_package($extensions[$id]['package'])) {
        unset($extensions[$id]);
        if (update_extensions($extensions)) {
            display_notification(_("Selected chart has been successfully deleted"));
            meta_forward($_SERVER['PHP_SELF']);
        }
    }
}
if ($id = find_submit('Update', false)) {
    install_extension($id);
}
//---------------------------------------------------------------------------------------------
start_form(true);
div_start('ext_tbl');
start_table(TABLESTYLE);
$th = array(_("Chart"), _("Installed"), _("Available"), _("Encoding"), "", "");
table_header($th);
$k = 0;
$mods = get_charts_list();
foreach ($mods as $pkg_name => $ext) {
    $available = @$ext['available'];
    $installed = @$ext['version'];
    $id = @$ext['local_id'];
    $encoding = @$ext['encoding'];
Beispiel #2
0
    write_extensions($exts, get_post('extset'));
    if (get_post('extset') == user_company()) {
        $installed_extensions = $exts;
    }
    if (!$result) {
        display_error(_('Status change for some extensions failed.'));
        $Ajax->activate('ext_tbl');
        // refresh settings display
    } else {
        display_notification(_('Current active extensions set has been saved.'));
    }
}
if ($id = find_submit('Update', false)) {
    install_extension($id);
}
if ($id = find_submit('Local', false)) {
    local_extension($id);
}
if ($Mode == 'RESET') {
    $selected_id = -1;
    unset($_POST);
}
//---------------------------------------------------------------------------------------------
start_form(true);
if (list_updated('extset')) {
    $Ajax->activate('_page_body');
}
$set = get_post('extset', -1);
echo "<center>" . _('Extensions:') . "&nbsp;&nbsp;";
echo extset_list('extset', null, true);
echo "</center><br>";
{
    $_SESSION['pay_items']->remove_gl_item($id);
    line_start_focus();
}
//-----------------------------------------------------------------------------------------------
function handle_new_item()
{
    if (!check_item_data()) {
        return;
    }
    $amount = ($_SESSION['pay_items']->trans_type == ST_BANKPAYMENT ? 1 : -1) * input_num('amount');
    $_SESSION['pay_items']->add_gl_item($_POST['code_id'], $_POST['dimension_id'], $_POST['dimension2_id'], $amount, $_POST['LineMemo']);
    line_start_focus();
}
//-----------------------------------------------------------------------------------------------
$id = find_submit('Delete');
if ($id != -1) {
    handle_delete_item($id);
}
if (isset($_POST['AddItem'])) {
    handle_new_item();
}
if (isset($_POST['UpdateItem'])) {
    handle_update_item();
}
if (isset($_POST['CancelItemChanges'])) {
    line_start_focus();
}
if (isset($_POST['go'])) {
    display_quick_entries($_SESSION['pay_items'], $_POST['person_id'], input_num('totamount'), $_SESSION['pay_items']->trans_type == ST_BANKPAYMENT ? QE_PAYMENT : QE_DEPOSIT);
    $_POST['totamount'] = price_format(0);
    //	$_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)) {
            if (!change_tpl_flag($id)) {
                break;
            }
        }
    }
    $Ajax->activate('_page_body');
}
//------------------------------------------------------------------------------------------------
    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);
            }
        } else {
Beispiel #6
0
$id3 = find_submit('Delete');
if ($id3 != -1) {
    $_SESSION['supp_trans']->remove_grn_from_trans($id3);
    $Ajax->activate('grn_items');
    reset_tax_input();
}
$id4 = find_submit('Delete2');
if ($id4 != -1) {
    $_SESSION['supp_trans']->remove_gl_codes_from_trans($id4);
    clear_fields();
    reset_tax_input();
    $Ajax->activate('gl_items');
}
$id2 = -1;
if ($_SESSION["wa_current_user"]->can_access('SA_GRNDELETE')) {
    $id2 = find_submit('void_item_id');
    if ($id2 != -1) {
        remove_not_invoice_item($id2);
        display_notification(sprintf(_('All yet non-invoiced items on delivery line # %d has been removed.'), $id2));
    }
}
if (isset($_POST['go'])) {
    $Ajax->activate('gl_items');
    display_quick_entries($_SESSION['supp_trans'], $_POST['qid'], input_num('totamount'), QE_SUPPINV);
    $_POST['totamount'] = price_format(0);
    $Ajax->activate('totamount');
    reset_tax_input();
}
start_form();
invoice_header($_SESSION['supp_trans']);
if ($_POST['supplier_id'] == '') {
 function tab_changed($name)
 {
     $to = find_submit("{$name}_", false);
     if (!$to) {
         return null;
     }
     return array('from' => $from = get_post("_{$name}_sel"), 'to' => $to);
 }
    foreach ($_POST as $postkey => $postval) {
        if (strpos($postkey, "qty_recd") === 0) {
            $id = substr($postkey, strlen("qty_recd"));
            $id = (int) $id;
            commit_item_data($id);
        }
    }
}
//--------------------------------------------------------------------------------------------------
$id3 = find_submit('Delete');
if ($id3 != -1) {
    $_SESSION['supp_trans']->remove_grn_from_trans($id3);
    $Ajax->activate('grn_items');
    reset_tax_input();
}
$id4 = find_submit('Delete2');
if ($id4 != -1) {
    $_SESSION['supp_trans']->remove_gl_codes_from_trans($id4);
    clear_fields();
    reset_tax_input();
    $Ajax->activate('gl_items');
}
if (isset($_POST['RefreshInquiry'])) {
    $Ajax->activate('grn_items');
    reset_tax_input();
}
if (isset($_POST['go'])) {
    $Ajax->activate('gl_items');
    display_quick_entries($_SESSION['supp_trans'], $_POST['qid'], input_num('totamount'), QE_SUPPINV);
    $_POST['totamount'] = price_format(0);
    $Ajax->activate('totamount');
//-----------------------------------------------------------------------------------
if ($Mode == 'Delete') {
    if (!has_quick_entry_lines($selected_id)) {
        delete_quick_entry($selected_id);
        display_notification(_('Selected quick entry has been deleted'));
        $Mode = 'RESET';
    } else {
        display_error(_("The Quick Entry has Quick Entry Lines. Cannot be deleted."));
        set_focus('description');
    }
}
if (find_submit('Edit') != -1) {
    $Mode2 = 'RESET2';
    set_focus('description');
}
if (find_submit('BEd') != -1 || get_post('ADD_ITEM2')) {
    set_focus('actn');
}
if ($Mode2 == 'BDel') {
    delete_quick_entry_line($selected_id2);
    display_notification(_('Selected quick entry line has been deleted'));
    $Mode2 = 'RESET2';
}
//-----------------------------------------------------------------------------------
if ($Mode == 'RESET') {
    $selected_id = -1;
    $_POST['description'] = $_POST['type'] = '';
    $_POST['base_desc'] = _('Base Amount');
    $_POST['base_amount'] = price_format(0);
    $_POST['bal_type'] = 0;
}
    $name = "chgtpl" . $row['order_no'];
    $value = $row['type'] ? 1 : 0;
    // save also in hidden field for testing during 'Update'
    return checkbox(null, $name, $value, true, _('Set this order as a template for direct deliveries/invoices')) . hidden('last[' . $row['order_no'] . ']', $value, false);
}
//---------------------------------------------------------------------------------------------
// Update db record if respective checkbox value has changed.
//
function change_tpl_flag($id)
{
    global $Ajax;
    $sql = "UPDATE " . TB_PREF . "sales_orders SET type = !type WHERE order_no={$id}";
    db_query($sql, "Can't change sales order type");
    $Ajax->activate('orders_tbl');
}
$id = find_submit('_chgtpl');
if ($id != -1) {
    change_tpl_flag($id);
}
if (isset($_POST['Update']) && isset($_POST['last'])) {
    foreach ($_POST['last'] as $id => $value) {
        if ($value != check_value('chgtpl' . $id)) {
            change_tpl_flag($id);
        }
    }
}
$show_dates = !in_array($_POST['order_view_mode'], array('OutstandingOnly', 'InvoiceTemplates', 'DeliveryTemplates'));
//---------------------------------------------------------------------------------------------
//	Order range form
//
if (get_post('_OrderNumber_changed') || get_post('_OrderReference_changed')) {
Beispiel #11
0
simple_page_mode(true);
check_db_has_tax_types(_("There are no tax types defined. Define tax types before defining tax groups."));
//-----------------------------------------------------------------------------------
if ($Mode == 'ADD_ITEM' || $Mode == 'UPDATE_ITEM') {
    //initialise no input errors assumed initially before we test
    $input_error = 0;
    if (strlen($_POST['name']) == 0) {
        $input_error = 1;
        display_error(_("The tax group name cannot be empty."));
        set_focus('name');
    }
    if ($input_error != 1) {
        // create an array of the taxes and array of rates
        $taxes = array();
        $rates = array();
        while (($id = find_submit('tax_type_id')) != -1) {
            $taxes[] = $id;
            $rates[] = get_tax_type_default_rate($id);
            unset($_POST['tax_type_id' . $id]);
        }
        if ($selected_id != -1) {
            update_tax_group($selected_id, $_POST['name'], $_POST['tax_shipping'], $taxes, $rates);
            display_notification(_('Selected tax group has been updated'));
        } else {
            add_tax_group($_POST['name'], $_POST['tax_shipping'], $taxes, $rates);
            display_notification(_('New tax group has been added'));
        }
        $Mode = 'RESET';
    }
}
//-----------------------------------------------------------------------------------
Beispiel #12
0
            $type = $row['filetype'] ? $row['filetype'] : 'application/octet-stream';
            header("Content-type: " . $type);
            header('Content-Length: ' . $row['filesize']);
            //if ($type == 'application/octet-stream')
            //	header('Content-Disposition: attachment; filename='.$row['filename']);
            //else
            header("Content-Disposition: inline");
            echo file_get_contents(company_path() . "/attachments/" . $row['unique_name']);
            exit;
        }
    }
}
if (isset($_GET['dl'])) {
    $download_id = $_GET['dl'];
} else {
    $download_id = find_submit('download');
}
if ($download_id != -1) {
    $row = get_attachment($download_id);
    if ($row['filename'] != "") {
        if (in_ajax()) {
            $Ajax->redirect($_SERVER['PHP_SELF'] . '?dl=' . $download_id);
        } else {
            $type = $row['filetype'] ? $row['filetype'] : 'application/octet-stream';
            header("Content-type: " . $type);
            header('Content-Length: ' . $row['filesize']);
            header('Content-Disposition: attachment; filename=' . $row['filename']);
            echo file_get_contents(company_path() . "/attachments/" . $row['unique_name']);
            exit;
        }
    }
Beispiel #13
0
}
//--------------------------------------------------------------------------------------------------
start_form();
start_table(TABLESTYLE_NOBORDER);
start_row();
security_roles_list_cells(_("Role:") . "&nbsp;", 'role', null, true, true, check_value('show_inactive'));
$new_role = get_post('role') == '';
check_cells(_("Show inactive:"), 'show_inactive', null, true);
end_row();
end_table();
echo "<hr>";
if (get_post('_show_inactive_update')) {
    $Ajax->activate('role');
    set_focus('role');
}
if (find_submit('_Section')) {
    $Ajax->activate('details');
}
//-----------------------------------------------------------------------------------------------
div_start('details');
start_table(TABLESTYLE2);
text_row(_("Role name:"), 'name', null, 20, 22);
text_row(_("Role description:"), 'description', null, 50, 52);
record_status_list_row(_("Current status:"), 'inactive');
end_table(1);
start_table(TABLESTYLE, "width=40%");
$k = $j = 0;
//row colour counter
$ext = $sec = $m = -1;
foreach (sort_areas($security_areas) as $area => $parms) {
    // system setup areas are accessable only for site admins i.e.
    imc_list_cells(_("IMC:"), 'imc', null, false, true);
    text_cells(_("#:"), 'customNum');
    submit_cells('Search', _("Search"), '', _('Refresh Inquiry'), 'default');
    hidden('sales_id', $_POST['sales_id']);
    end_row();
    end_table();
    div_end();
    if (get_post('_show_inactive_update')) {
        $Ajax->activate('imc');
        set_focus('imc');
    }
} else {
    display_error("Enter some IMC/Salesman.");
    hidden('imc');
}
$edit_id = find_submit("Edit");
if ($edit_id != -1) {
    $myrow = db_fetch(get_selected_salesman($edit_id));
    $company_data = get_company_prefs();
    $branch = get_branch($myrow["branch_code"]);
    $branch_data = get_branch_accounts($myrow['branch_code']);
    clear_data();
    $_POST['sales'] = $myrow['salesman_name'];
    //get imc name
    $_POST['invoice_no'] = $myrow['customized_no'];
    //get invoice number
    $_POST['client'] = $myrow['br_name'];
    //get customer name
    $_POST['br_id'] = $myrow['debtor_no'];
    $_POST['order_no'] = $myrow['order_'];
    $dt = get_discount($branch_data['sales_discount_account'], $myrow['type'], $myrow['trans_no']);