function assets_tabs()
 {
     global $db, $messageStack;
     $this->security_id = $_SESSION['admin_security'][SECURITY_ASSET_MGT_TABS];
     $this->db_table = TABLE_ASSETS_TABS;
     $this->title = BOX_ASSET_MODULE_TABS;
     $this->extra_buttons = false;
     $this->help_path = '';
     // make sure the module is installed
     $result = $db->Execute("SHOW TABLES LIKE '" . TABLE_ASSETS . "'");
     if ($result->RecordCount() == 0) {
         $messageStack->add_session(ASSET_MGR_NOT_INSTALLED, 'caution');
         gen_redirect(html_href_link(FILENAME_DEFAULT, 'cat=assets&module=admin', 'SSL'));
     }
 }
Example #2
0
     gen_add_audit_log(PRICE_SHEETS_LOG . ($_REQUEST['action'] == 'save') ? TEXT_SAVE : TEXT_UPDATE, $sheet_name);
     gen_redirect(html_href_link(FILENAME_DEFAULT, gen_get_all_get_params(array('psID', 'action')), 'SSL'));
     break;
 case 'delete':
     validate_security($security_level, 4);
     $id = (int) db_prepare_input($_GET['psID']);
     $result = $db->Execute("select sheet_name, type, default_sheet from " . TABLE_PRICE_SHEETS . " where id = " . $id);
     $sheet_name = $result->fields['sheet_name'];
     $type = $result->fields['type'];
     if ($result->fields['default_sheet'] == '1') {
         $messageStack->add(PRICE_SHEET_DEFAULT_DELETED, 'caution');
     }
     $db->Execute("delete from " . TABLE_PRICE_SHEETS . " where id = '{$id}'");
     $db->Execute("delete from " . TABLE_INVENTORY_SPECIAL_PRICES . " where price_sheet_id = '{$id}'");
     gen_add_audit_log(PRICE_SHEETS_LOG . TEXT_DELETE, $sheet_name);
     gen_redirect(html_href_link(FILENAME_DEFAULT, gen_get_all_get_params(array('psID', 'action')) . '&type=' . $type, 'SSL'));
     break;
 case 'revise':
     validate_security($security_level, 2);
     $old_id = db_prepare_input($_GET['psID']);
     $result = $db->Execute("select * from " . TABLE_PRICE_SHEETS . " where id = {$old_id}");
     $old_rev = $result->fields['revision'];
     $output_array = array('sheet_name' => $result->fields['sheet_name'], 'type' => $type, 'revision' => $result->fields['revision'] + 1, 'effective_date' => gen_specific_date($result->fields['effective_date'], 1), 'default_sheet' => $result->fields['default_sheet'], 'default_levels' => $result->fields['default_levels']);
     db_perform(TABLE_PRICE_SHEETS, $output_array, 'insert');
     $id = db_insert_id();
     // this is used by the edit function later on.
     // expire the old sheet
     $db->Execute("UPDATE " . TABLE_PRICE_SHEETS . " SET expiration_date='" . gen_specific_date($result->fields['effective_date'], 1) . "' WHERE id={$old_id}");
     // Copy special pricing information to new sheet
     $levels = $db->Execute("select inventory_id, price_levels from " . TABLE_INVENTORY_SPECIAL_PRICES . " where price_sheet_id = {$old_id}");
     while (!$levels->EOF) {
Example #3
0
$result = $db->Execute("select admin_prefs from " . TABLE_USERS . " where admin_id = " . $_SESSION['admin_id']);
$prefs = unserialize($result->fields['admin_prefs']);
/***************   hook for custom actions  ***************************/
$custom_path = DIR_FS_WORKING . 'custom/pages/profile/extra_actions.php';
if (file_exists($custom_path)) {
    include $custom_path;
}
/***************   Act on the action request   *************************/
switch ($_REQUEST['action']) {
    case 'save':
        validate_security($security_level, 4);
        $prefs['theme'] = db_prepare_input($_POST['theme']);
        $prefs['menu'] = db_prepare_input($_POST['menu']);
        $prefs['colors'] = db_prepare_input($_POST['colors']);
        if (!$prefs['colors']) {
            $error = $messageStack->add(GEN_ERROR_NO_THEME_COLORS, 'error');
            break;
        }
        db_perform(TABLE_USERS, array('admin_prefs' => serialize($prefs)), 'update', 'admin_id = ' . $_SESSION['admin_id']);
        $_SESSION['admin_prefs']['theme'] = $prefs['theme'];
        $_SESSION['admin_prefs']['menu'] = $prefs['menu'];
        $_SESSION['admin_prefs']['colors'] = $prefs['colors'];
        gen_redirect(html_href_link(FILENAME_DEFAULT, gen_get_all_get_params(), 'SSL'));
        break;
    default:
}
/*****************   prepare to display templates  *************************/
$include_header = true;
$include_footer = true;
$include_template = 'template_main.php';
define('PAGE_TITLE', BOX_HEADING_PROFILE);
Example #4
0
function validate_gl_balances($action)
{
    global $db, $currencies, $messageStack;
    $fiscal_years = array();
    $sql = "select distinct fiscal_year, min(period) as first_period, max(period) as last_period\r\n\t  from " . TABLE_ACCOUNTING_PERIODS . " group by fiscal_year order by fiscal_year ASC";
    $result = $db->Execute($sql);
    while (!$result->EOF) {
        $fiscal_years[] = array('fiscal_year' => $result->fields['fiscal_year'], 'first_period' => $result->fields['first_period'], 'last_period' => $result->fields['last_period']);
        $result->MoveNext();
    }
    $beg_bal = array();
    $bad_accounts = array();
    foreach ($fiscal_years as $fiscal_year) {
        $sql = "select account_id, period, beginning_balance, (beginning_balance + debit_amount - credit_amount) as next_beg_bal\r\n\t\tfrom " . TABLE_CHART_OF_ACCOUNTS_HISTORY . " \r\n\t\twhere period >= " . $fiscal_year['first_period'] . " and period <= " . $fiscal_year['last_period'] . " \r\n\t\torder by period, account_id";
        $result = $db->Execute($sql);
        while (!$result->EOF) {
            $period = $result->fields['period'];
            $next_period = $period + 1;
            $gl_account = $result->fields['account_id'];
            $beg_balance = $currencies->format($result->fields['beginning_balance']);
            $next_beg_bal = $currencies->format($result->fields['next_beg_bal']);
            $beg_bal[$next_period][$gl_account] = $next_beg_bal;
            if ($period != 1 && $beg_bal[$period][$gl_account] != $beg_balance) {
                if ($action != 'coa_hist_fix') {
                    $messageStack->add(sprintf(GEN_ADM_TOOLS_REPAIR_ERROR_MSG, $period, $gl_account, $beg_bal[$period][$gl_account], $beg_balance), 'caution');
                }
                $bad_accounts[$period][$gl_account] = array('sync' => '1');
            }
            // check posted transactions to account to see if they match
            $posted = $db->Execute("select sum(debit_amount) as debit, sum(credit_amount) as credit \r\n\t\t  from " . TABLE_JOURNAL_MAIN . " m join " . TABLE_JOURNAL_ITEM . " i on m.id = i.ref_id\r\n\t\t  where period = " . $period . " and gl_account = '" . $gl_account . "' \r\n\t\t  and journal_id in (2, 6, 7, 12, 13, 14, 16, 18, 19, 20, 21)");
            $posted_bal = $currencies->format($result->fields['beginning_balance'] + $posted->fields['debit'] - $posted->fields['credit']);
            if ($posted_bal != $next_beg_bal) {
                if ($action != 'coa_hist_fix') {
                    $messageStack->add(sprintf(GEN_ADM_TOOLS_REPAIR_ERROR_MSG, $period, $gl_account, $posted_bal, $next_beg_bal), 'caution');
                }
                $bad_accounts[$period][$gl_account] = array('sync' => '1', 'debit' => $posted->fields['debit'], 'credit' => $posted->fields['credit']);
            }
            $result->MoveNext();
        }
        // roll the fiscal year balances
        $result = $db->Execute("select id from " . TABLE_CHART_OF_ACCOUNTS . " where account_type = 44");
        $retained_earnings_acct = $result->fields['id'];
        // select list of accounts that need to be closed, adjusted
        $sql = "select id from " . TABLE_CHART_OF_ACCOUNTS . " where account_type in (30, 32, 34, 42, 44)";
        $result = $db->Execute($sql);
        $acct_list = array();
        while (!$result->EOF) {
            $beg_bal[$next_period][$result->fields['id']] = 0;
            $acct_list[] = $result->fields['id'];
            $result->MoveNext();
        }
        // fetch the totals for the closed accounts
        $sql = "select sum(beginning_balance + debit_amount - credit_amount) as retained_earnings \r\n\t\tfrom " . TABLE_CHART_OF_ACCOUNTS_HISTORY . " \r\n\t\twhere account_id in ('" . implode("','", $acct_list) . "') and period = " . $period;
        $result = $db->Execute($sql);
        $beg_bal[$next_period][$retained_earnings_acct] = $currencies->format($result->fields['retained_earnings']);
    }
    if ($action == 'coa_hist_fix') {
        // find the affected accounts
        if (sizeof($bad_accounts) > 0) {
            // *************** START TRANSACTION *************************
            $db->transStart();
            $glEntry = new journal();
            $min_period = 999999;
            foreach ($bad_accounts as $period => $acct_array) {
                foreach ($acct_array as $gl_acct => $value) {
                    $min_period = min($period, $min_period);
                    // find first period that has an error
                    $glEntry->affected_accounts[$gl_acct] = 1;
                    if (isset($value['debit'])) {
                        // the history doesn't match posted data, repair
                        $db->Execute("update " . TABLE_CHART_OF_ACCOUNTS_HISTORY . " \r\n\t\t\t    set debit_amount = " . $value['debit'] . ", credit_amount = " . $value['credit'] . " \r\n\t\t\t    where period = " . $period . " and account_id = '" . $gl_acct . "'");
                    }
                }
            }
            $debug = true;
            if ($glEntry->update_chart_history_periods($min_period - 1)) {
                // from prior period than the error account
                $db->transCommit();
                $messageStack->add_session(GEN_ADM_TOOLS_REPAIR_COMPLETE, 'success');
                gen_add_audit_log(GEN_ADM_TOOLS_REPAIR_LOG_ENTRY);
                gen_redirect(html_href_link(FILENAME_DEFAULT, gen_get_all_get_params(array('action')) . 'action=coa_hist_test', 'SSL'));
            }
        }
    }
    if (sizeof($bad_accounts) == 0) {
        $messageStack->add(GEN_ADM_TOOLS_REPAIR_SUCCESS, 'success');
    } else {
        $messageStack->add(GEN_ADM_TOOLS_REPAIR_ERROR, 'error');
    }
}
switch ($_REQUEST['action']) {
    case 'save':
        foreach ($dashboards as $dashboard) {
            // build add and delete list
            // if post is set and not in my_profile -> add
            if (isset($_POST[$dashboard['dashboard_id']]) && !in_array($dashboard['dashboard_id'], $my_profile)) {
                include_once DIR_FS_MODULES . $dashboard['module_id'] . '/dashboards/' . $dashboard['dashboard_id'] . '/' . $dashboard['dashboard_id'] . '.php';
                $dbItem = new $dashboard['dashboard_id']();
                $dbItem->menu_id = $menu_id;
                $dbItem->module_id = $dashboard['module_id'];
                $dbItem->Install();
            }
            // if post is not set and in my_profile -> delete
            if (!isset($_POST[$dashboard['dashboard_id']]) && in_array($dashboard['dashboard_id'], $my_profile)) {
                // delete it
                include_once DIR_FS_MODULES . $dashboard['module_id'] . '/dashboards/' . $dashboard['dashboard_id'] . '/' . $dashboard['dashboard_id'] . '.php';
                $dbItem = new $dashboard['dashboard_id']();
                $dbItem->menu_id = $menu_id;
                $dbItem->module_id = $dashboard['module_id'];
                $dbItem->Remove();
            }
        }
        gen_redirect(html_href_link(FILENAME_DEFAULT, '&module=phreedom&page=main&mID=' . $menu_id, 'SSL'));
        break;
    default:
}
/*****************   prepare to display templates  *************************/
$include_header = true;
$include_footer = true;
$include_template = 'template_main.php';
define('PAGE_TITLE', CP_ADD_REMOVE_BOXES);
                    $fields = $result->fields;
                    $fields['admin_security'] = load_full_access_security();
                    $result = db_perform(TABLE_USERS, $fields, 'insert');
                }
            }
        }
        if (!$error) {
            // reset SESSION['company'] to new company and redirect to install->store_setup
            $messageStack->add(SETUP_CO_MGR_CREATE_SUCCESS, 'success');
            gen_add_audit_log(SETUP_CO_MGR_LOG . ($action == 'new' ? TEXT_NEW : TEXT_COPY), $company);
            $_SESSION['company'] = $company;
            // save the necessary db variables to continue setup
            $_SESSION['db_server'] = $db_server;
            $_SESSION['db_user'] = $db_user;
            $_SESSION['db_pw'] = $db_pw;
            gen_redirect(html_href_link(DIR_WS_MODULES . 'install/index.php?main_page=' . ($action == 'new' ? 'admin_setup' : 'store_setup') . '&language=' . $_SESSION['language'], '', 'SSL'));
        }
        break;
    case 'delete':
        $company = $_SESSION['companies'][$_POST['company']];
        // Failsafe to prevent current company from being deleted accidently
        if ($company != $_SESSION['company']) {
            $db->Execute("drop database " . $company);
            delete_dir(DIR_FS_MY_FILES . $company);
        }
        gen_add_audit_log(SETUP_CO_MGR_LOG . TEXT_DELETE, $company);
        $messageStack->add(SETUP_CO_MGR_DELETE_SUCCESS, 'success');
        break;
    default:
}
/*****************   prepare to display templates  *************************/
            $order->item_rows[0] = array('pstd' => '1', 'id' => '', 'desc' => db_prepare_input($_POST['desc_1']), 'total' => $currencies->clean_value(db_prepare_input($_POST['total_1'])), 'acct' => db_prepare_input($_POST['acct_1']));
            $post_credit = $order->post_ordr($action);
            if (!$post_credit) {
                $order = new objectInfo($_POST);
                $order->post_date = gen_db_date_short($_POST['post_date']);
                // fix the date to original format
                $order->id = $_POST['id'] != '' ? $_POST['id'] : '';
                // will be null unless opening an existing purchase/receive
                $messageStack->add(GL_ERROR_NO_POST, 'error');
            }
            gen_add_audit_log(AUDIT_LOG_DESC, $order->purchase_invoice_id, $order->total_amount);
            if (DEBUG) {
                $messageStack->write_debug();
            }
            if ($action == 'save') {
                gen_redirect(html_href_link(FILENAME_DEFAULT, gen_get_all_get_params(array('action')), 'SSL'));
            }
            // else print or print_update, fall through and load javascript to call form_popup and clear form
        } else {
            // else there was a post error, display and re-display form
            $order = new objectInfo($_POST);
            $order->post_date = gen_db_date_short($_POST['post_date']);
            // fix the date to original format
            $order->id = $_POST['id'] != '' ? $_POST['id'] : '';
            // will be null unless opening an existing purchase/receive
            $messageStack->add(GL_ERROR_NO_POST, 'error');
        }
        break;
    default:
}
/*****************   prepare to display templates  *************************/
// | This program is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of  |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   |
// | GNU General Public License for more details.                    |
// |                                                                 |
// | The license that is bundled with this package is located in the |
// | file: /doc/manual/ch01-Introduction/license.html.               |
// | If not, see http://www.gnu.org/licenses/                        |
// +-----------------------------------------------------------------+
//  Path: /modules/general/pages/pw_lost/pre_process.php
//
/**************  include page specific files    *********************/
require DIR_FS_WORKING . 'functions/general.php';
/**************   page specific initialization  *************************/
if (isset($_POST['login'])) {
    gen_redirect(html_href_link(FILENAME_DEFAULT, 'cat=general&amp;module=login', 'SSL'));
}
$error_check = false;
if (isset($_POST['submit'])) {
    if (!$_POST['admin_email']) {
        $error_check = true;
        $email_message = ERROR_WRONG_EMAIL_NULL;
    }
    $_SESSION['company'] = $_SESSION['companies'][$_POST['company']];
    $admin_email = db_prepare_input($_POST['admin_email']);
    $sql = "select admin_id, admin_name, admin_email, admin_pass \r\n  \tfrom " . TABLE_USERS . " where admin_email = '" . db_input($admin_email) . "'";
    $result = $db->Execute($sql);
    if (!($admin_email == $result->fields['admin_email'])) {
        $error_check = true;
        $email_message = ERROR_WRONG_EMAIL;
    }
}
/**************  include page specific files    *********************/
@(include_once DIR_FS_WORKING . 'config.php');
// pull the current config info, if it is there
@(include_once DIR_FS_WORKING . 'language/' . $_SESSION['language'] . '/language.php');
require_once DIR_FS_MODULES . 'services/shipping/language/' . $_SESSION['language'] . '/language.php';
require_once DIR_FS_WORKING . 'functions/zencart.php';
require_once DIR_FS_MODULES . 'inventory/functions/inventory.php';
require_once DIR_FS_WORKING . 'classes/parser.php';
require_once DIR_FS_WORKING . 'classes/zencart.php';
require_once DIR_FS_WORKING . 'classes/bulk_upload.php';
/**************   page specific initialization  *************************/
// make sure the module is installed
if (!defined('ZENCART_URL')) {
    $messageStack->add_session(ZENCART_MOD_NOT_INSTALLED, 'caution');
    gen_redirect(html_href_link(FILENAME_DEFAULT, 'cat=zencart&module=admin', 'SSL'));
}
$error = false;
$ship_date = $_POST['ship_date'] ? gen_db_date_short($_POST['ship_date']) : date('Y-m-d');
$action = isset($_GET['action']) ? $_GET['action'] : $_POST['todo'];
/***************   hook for custom actions  ***************************/
$custom_path = DIR_FS_MY_FILES . 'custom/zencart/main/extra_actions.php';
if (file_exists($custom_path)) {
    include $custom_path;
}
/***************   Act on the action request   *************************/
switch ($action) {
    case 'upload':
        $upXML = new zencart();
        $id = db_prepare_input($_POST['rowSeq']);
        if ($upXML->submitXML($id, 'product_ul')) {
Example #10
0
 function Execute($zf_sql, $zf_limit = false, $zf_cache = false, $zf_cachetime = 0)
 {
     global $zc_cache, $messageStack;
     if ($zf_limit) {
         $zf_sql = $zf_sql . ' LIMIT ' . $zf_limit;
     }
     if ($zf_cache and $zc_cache->sql_cache_exists($zf_sql) and !$zc_cache->sql_cache_is_expired($zf_sql, $zf_cachetime)) {
         $obj = new queryFactoryResult();
         $obj->cursor = 0;
         $obj->is_cached = true;
         $obj->sql_query = $zf_sql;
         $zp_result_array = $zc_cache->sql_cache_read($zf_sql);
         $obj->result = $zp_result_array;
         if (sizeof($zp_result_array) > 0) {
             $obj->EOF = false;
             while (list($key, $value) = each($zp_result_array[0])) {
                 $obj->fields[$key] = $value;
             }
             return $obj;
         } else {
             $obj->EOF = true;
         }
     } elseif ($zf_cache) {
         $zc_cache->sql_cache_expire_now($zf_sql);
         $time_start = explode(' ', microtime());
         $obj = new queryFactoryResult();
         $obj->sql_query = $zf_sql;
         if (!$this->db_connected) {
             $this->set_error('0', DB_ERROR_NOT_CONNECTED);
         }
         $zp_db_resource = @mysql_query($zf_sql, $this->link);
         if (!$zp_db_resource) {
             $this->set_error(@mysql_errno(), @mysql_error());
         }
         $obj->resource = $zp_db_resource;
         $obj->cursor = 0;
         $obj->is_cached = true;
         if ($obj->RecordCount() > 0) {
             $obj->EOF = false;
             $zp_ii = 0;
             while (!$obj->EOF) {
                 $zp_result_array = @mysql_fetch_array($zp_db_resource);
                 if ($zp_result_array) {
                     while (list($key, $value) = each($zp_result_array)) {
                         if (!preg_match('/^[0-9]/', $key)) {
                             $obj->result[$zp_ii][$key] = $value;
                         }
                     }
                 } else {
                     $obj->Limit = $zp_ii;
                     $obj->EOF = true;
                 }
                 $zp_ii++;
             }
             while (list($key, $value) = each($obj->result[$obj->cursor])) {
                 if (!preg_match('/^[0-9]/', $key)) {
                     $obj->fields[$key] = $value;
                 }
             }
             $obj->EOF = false;
         } else {
             $obj->EOF = true;
         }
         $zc_cache->sql_cache_store($zf_sql, $obj->result);
         $time_end = explode(' ', microtime());
         $query_time = $time_end[1] + $time_end[0] - $time_start[1] - $time_start[0];
         $this->total_query_time += $query_time;
         $this->count_queries++;
         return $obj;
     } else {
         $time_start = explode(' ', microtime());
         $obj = new queryFactoryResult();
         if (!$this->db_connected) {
             $this->set_error('0', DB_ERROR_NOT_CONNECTED);
         }
         $zp_db_resource = @mysql_query($zf_sql, $this->link);
         if (!$zp_db_resource) {
             if ($_POST['page'] == 'ajax' || $_GET['page'] == 'ajax') {
                 $messageStack->debug("\n\nThe failing sql was: " . $zf_sql);
                 $messageStack->debug("\n\nmySQL returned: " . @mysql_errno($this->link) . ' ' . @mysql_error($this->link));
                 if (defined('FILENAME_DEFAULT')) {
                     $messageStack->write_debug();
                 }
                 echo createXmlHeader() . xmlEntry('error', 'There was a SQL Error: ' . @mysql_error($this->link)) . createXmlFooter();
                 die;
             }
             if (method_exists($messageStack, 'debug')) {
                 $messageStack->debug("\n\nThe failing sql was: " . $zf_sql);
                 $messageStack->debug("\n\nmySQL returned: " . @mysql_errno($this->link) . ' ' . @mysql_error($this->link));
                 if (defined('FILENAME_DEFAULT')) {
                     $messageStack->write_debug();
                     $messageStack->add('The last transaction had a SQL database error.', 'error');
                     gen_redirect(html_href_link(FILENAME_DEFAULT, 'cat=phreedom&page=main&amp;action=crash', 'SSL'));
                 } else {
                     echo str_replace("\n", '<br />', $messageStack->debug_info);
                     die;
                 }
             } else {
                 echo str_replace("\n", '<br />', $messageStack->debug_info);
                 die;
             }
         }
         $obj->resource = $zp_db_resource;
         $obj->cursor = 0;
         if ($obj->RecordCount() > 0) {
             $obj->EOF = false;
             $zp_result_array = @mysql_fetch_array($zp_db_resource);
             if ($zp_result_array) {
                 while (list($key, $value) = each($zp_result_array)) {
                     if (!preg_match('/^[0-9]/', $key)) {
                         $obj->fields[$key] = $value;
                     }
                 }
                 $obj->EOF = false;
             } else {
                 $obj->EOF = true;
             }
         } else {
             $obj->EOF = true;
         }
         $time_end = explode(' ', microtime());
         $query_time = $time_end[1] + $time_end[0] - $time_start[1] - $time_start[0];
         $this->total_query_time += $query_time;
         $this->count_queries++;
         //$messageStack->add("query execution time = $query_time and sql = $zf_sql<br>".chr(13));
         return $obj;
     }
 }
function validate_security($security_level = 0, $required_level = 1)
{
    global $messageStack;
    if ($security_level < $required_level) {
        $messageStack->add(ERROR_NO_PERMISSION, 'error');
        gen_redirect(html_href_link(FILENAME_DEFAULT, gen_get_all_get_params(array('action')), 'SSL'));
    }
    return true;
}
        if (AUTO_UPDATE_PERIOD) {
            gen_auto_update_period();
        }
        gen_add_audit_log(GEN_LOG_LOGIN . $admin_name);
        // check for session timeout to reload to requested page
        $get_params = '';
        if (isset($_SESSION['pb_cat'])) {
            $get_params = 'cat=' . $_SESSION['pb_cat'];
            $get_params .= '&amp;module=' . $_SESSION['pb_module'];
            if (isset($_SESSION['pb_jID'])) {
                $get_params .= '&amp;jID=' . $_SESSION['pb_jID'];
            }
            if (isset($_SESSION['pb_type'])) {
                $get_params .= '&amp;type=' . $_SESSION['pb_type'];
            }
        }
        gen_redirect(html_href_link(FILENAME_DEFAULT, $get_params, 'SSL'));
    } else {
        // Note: This is assigned to admin id = 1 since the user is not logged in.
        gen_add_audit_log(GEN_LOG_LOGIN_FAILED . $admin_name);
    }
}
// prepare to display form
if (isset($_COOKIE['pb_company'])) {
    $admin_company = $_COOKIE['pb_company'];
    $admin_language = $_COOKIE['pb_language'];
    $admin_theme = $_COOKIE['pb_theme'];
} else {
    $admin_theme = 'default';
}
define('PAGE_TITLE', TITLE);
Example #13
0
         require_once DIR_FS_MODULES . 'phreebooks/functions/phreebooks.php';
         $dates = gen_get_dates();
         validate_fiscal_year($dates['ThisYear'], '1', $dates['ThisYear'] . '-' . $dates['ThisMonth'] . '-01');
         build_and_check_account_history_records();
         gen_auto_update_period(false);
     }
     if (!$error) {
         // reset SESSION['company'] to new company and redirect to install->store_setup
         $db->Execute("update " . TABLE_CONFIGURATION . " set configuration_value = '" . $co_name . "' \n\t    where configuration_key = 'COMPANY_NAME'");
         $messageStack->add(SETUP_CO_MGR_CREATE_SUCCESS, 'success');
         gen_add_audit_log(SETUP_CO_MGR_LOG . TEXT_COPY, $db_name);
         $_SESSION['db_server'] = $db_server;
         $_SESSION['company'] = $db_name;
         $_SESSION['db_user'] = $db_user;
         $_SESSION['db_pw'] = $db_pw;
         gen_redirect(html_href_link(FILENAME_DEFAULT, $get_parmas, ENABLE_SSL_ADMIN ? 'SSL' : 'NONSSL'));
     } else {
         // restore db connection
         $db = new queryFactory();
         $db->connect(DB_SERVER_HOST, DB_SERVER_USERNAME, DB_SERVER_PASSWORD, DB_DATABASE);
     }
     $default_tab_id = 'manager';
     break;
 case 'delete_co':
     $db_name = $_SESSION['companies'][$_POST['del_company']];
     // Failsafe to prevent current company from being deleted accidently
     $backup = new backup();
     if ($db_name == 'none') {
         $error = $messageStack->add(SETUP_CO_MGR_NO_SELECTION, 'error');
     }
     if (!$error && $db_name != $_SESSION['company']) {
}
/**************  include page specific files    *********************/
@(include_once DIR_FS_WORKING . 'config.php');
// pull the current config info, if it is there
@(include_once DIR_FS_WORKING . 'language/' . $_SESSION['language'] . '/language.php');
require_once DIR_FS_MODULES . 'services/shipping/language/' . $_SESSION['language'] . '/language.php';
require_once DIR_FS_WORKING . 'functions/oscommerce.php';
require_once DIR_FS_MODULES . 'inventory/functions/inventory.php';
require_once DIR_FS_WORKING . 'classes/parser.php';
require_once DIR_FS_WORKING . 'classes/oscommerce.php';
require_once DIR_FS_WORKING . 'classes/bulk_upload.php';
/**************   page specific initialization  *************************/
// make sure the module is installed
if (!defined('OSCOMMERCE_URL')) {
    $messageStack->add_session(OSCOMMERCE_MOD_NOT_INSTALLED, 'caution');
    gen_redirect(html_href_link(FILENAME_DEFAULT, 'cat=oscommerce&module=admin', 'SSL'));
}
$error = false;
$ship_date = $_POST['ship_date'] ? gen_db_date_short($_POST['ship_date']) : date('Y-m-d');
$action = isset($_GET['action']) ? $_GET['action'] : $_POST['todo'];
/***************   hook for custom actions  ***************************/
$custom_path = DIR_FS_MY_FILES . 'custom/oscommerce/main/extra_actions.php';
if (file_exists($custom_path)) {
    include $custom_path;
}
/***************   Act on the action request   *************************/
switch ($action) {
    case 'upload':
        $upXML = new oscommerce();
        $id = db_prepare_input($_POST['rowSeq']);
        if ($upXML->submitXML($id, 'product_ul')) {
Example #15
0
            }
        } else {
            $include_template = 'template_install.php';
            define('PAGE_TITLE', TITLE_INSTALL);
        }
        break;
    case 'finish':
        $include_template = 'template_finish.php';
        define('PAGE_TITLE', INSTALL_TITLE_FINISH);
        break;
    case 'open_company':
        require '../includes/configure.php';
        $path = (ENABLE_SSL_ADMIN == 'true' ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_ADMIN;
        define('DIR_WS_FULL_PATH', $path);
        // full http path (or https if secure)
        gen_redirect(html_href_link('index.php', '', 'SSL'));
        break;
}
/*****************   prepare to display templates  *************************/
$sel_yes_no = array(array('id' => '0', 'text' => TEXT_NO), array('id' => '1', 'text' => TEXT_YES));
$sel_fy_month = array(array('id' => '01', 'text' => TEXT_JAN), array('id' => '02', 'text' => TEXT_FEB), array('id' => '03', 'text' => TEXT_MAR), array('id' => '04', 'text' => TEXT_APR), array('id' => '05', 'text' => TEXT_MAY), array('id' => '06', 'text' => TEXT_JUN), array('id' => '07', 'text' => TEXT_JUL), array('id' => '08', 'text' => TEXT_AUG), array('id' => '09', 'text' => TEXT_SEP), array('id' => '10', 'text' => TEXT_OCT), array('id' => '11', 'text' => TEXT_NOV), array('id' => '12', 'text' => TEXT_DEC));
$sel_fy_year = array();
for ($i = 0; $i < 6; $i++) {
    $sel_fy_year[] = array('id' => date('Y') + $i - 5, 'text' => date('Y') + $i - 5);
}
// Determine http path
$srvr_http = 'http://' . $_SERVER['HTTP_HOST'];
$srvr_https = 'https://' . $_SERVER['HTTP_HOST'];
// find the license
if (file_exists('../modules/phreedom/language/' . $lang . '/manual/ch01-Introduction/license.html')) {
    $license_path = '../modules/phreedom/language/' . $lang . '/manual/ch01-Introduction/license.html';
                 $result = $db->Execute("select qty, sku_id, wo_id from " . TABLE_WO_JOURNAL_MAIN . " where id = {$id}");
                 $temp = $db->Execute("select allocate from " . TABLE_WO_MAIN . " where id = '" . $result->fields['wo_id'] . "'");
                 $allocate = $temp->fields['allocate'];
                 if ($allocate) {
                     allocation_adjustment($result->fields['sku_id'], 0, $result->fields['qty']);
                 }
                 gen_add_audit_log(sprintf(WO_AUDIT_LOG_WO_COMPLETE, $id));
                 $messageStack->add(sprintf(WO_MESSAGE_SUCCESS_COMPLETE, $id), 'success');
                 gen_redirect(html_href_link(FILENAME_DEFAULT, gen_get_all_get_params(array('action')), 'SSL'));
             }
         }
     }
     if (!$error) {
         gen_add_audit_log(sprintf(WO_AUDIT_LOG_STEP_COMPLETE, $step));
         $messageStack->add(sprintf(WO_MESSAGE_STEP_UPDATE_SUCCESS, $step), 'success');
         gen_redirect(html_href_link(FILENAME_DEFAULT, gen_get_all_get_params(array('action')) . '&action=build&id=' . $id, 'SSL'));
     } else {
         $messageStack->add(WO_MESSAGE_MAIN_ERROR, 'error');
         $_REQUEST['action'] = 'build';
         $_POST['rowSeq'] = $id;
         // make it look like an edit
     }
     // fall through like build to reload
 // fall through like build to reload
 case 'edit':
 case 'build':
     $id = isset($_POST['rowSeq']) ? $_POST['rowSeq'] : $_GET['id'];
     if (!$id) {
         $_REQUEST['action'] = '';
         $error = true;
         break;
/**************   Check user security   *****************************/
$security_level = $_SESSION['admin_security'][SECURITY_TRANSLATOR_MGT];
if ($security_level == 0) {
    // not supposed to be here
    $messageStack->add_session(ERROR_NO_PERMISSION, 'error');
    gen_redirect(html_href_link(FILENAME_DEFAULT, '', 'SSL'));
}
/**************  include page specific files    *********************/
require_once DIR_FS_WORKING . 'language/en_us/language.php';
require_once DIR_FS_WORKING . 'classes/class.Translator.php';
/**************   page specific initialization  *************************/
// make sure the module is installed
$result = $db->Execute("SHOW TABLES LIKE '" . TABLE_TRANSLATOR_RELEASES . "'");
if ($result->RecordCount() == 0) {
    $messageStack->add_session(TRANSLATOR_MGR_NOT_INSTALLED, 'caution');
    gen_redirect(html_href_link(FILENAME_DEFAULT, 'cat=translator&module=admin', 'SSL'));
}
$action = isset($_GET['action']) ? $_GET['action'] : $_POST['action'];
$error = false;
/***************   Act on the action request   *************************/
define('TEMPLATE_DIR', DIR_FS_WORKING . 'templates/');
define('UPLOAD_DIR', DIR_FS_MY_FILES);
define('STORAGE_DIR', DIR_FS_MY_FILES . 'translator/storage/');
define('INSTALL_TEMP_DIR', DIR_FS_MY_FILES . 'translator/install_temp/');
define('INSTALL_DIR', DIR_FS_WORKING);
$translator = new Translator('index', $db);
$replace = array();
// set some defaults for the toolbar
$toolbar->icon_list['cancel']['params'] = 'onclick="location.href = \'' . html_href_link(FILENAME_DEFAULT, '', 'SSL') . '\'"';
$toolbar->icon_list['open']['show'] = false;
$toolbar->icon_list['delete']['show'] = false;
         }
     }
     if (!$error) {
         $temp = $db->Execute("select next_shipment_num from " . TABLE_CURRENT_STATUS);
         $shipment_num = $temp->fields['next_shipment_num'];
         $labels_array = array();
         foreach ($result as $shipment) {
             $sql_array = array('ref_id' => $sInfo->purchase_invoice_id, 'shipment_id' => $shipment_num, 'carrier' => $shipping_module, 'method' => $sInfo->ship_method, 'ship_date' => $sInfo->terminal_date, 'deliver_date' => $shipment['delivery_date'], 'tracking_id' => $shipment['tracking'], 'cost' => $shipment['net_cost']);
             db_perform(TABLE_SHIPPING_LOG, $sql_array, 'insert');
             $labels_array[] = $shipment['tracking'];
         }
         $db->Execute("update " . TABLE_CURRENT_STATUS . " set next_shipment_num = next_shipment_num + 1");
         gen_add_audit_log(SHIPPING_LOG_FEDEX_LABEL_PRINTED, $shipment_num . '-' . $sInfo->purchase_invoice_id);
         // load the window to print the label
         $tracking_list = implode(':', $labels_array);
         gen_redirect(html_href_link(FILENAME_DEFAULT, gen_get_all_get_params(array('module', 'carrier', 'labels', 'date')) . 'module=popup_label_viewer&carrier=' . $shipping_module . '&date=' . $sInfo->terminal_date . '&labels=' . $tracking_list, 'SSL'));
     } else {
         $messageStack->add(SHIPPING_FEDEX_NO_PACKAGES, 'error');
         $sInfo->ship_country_code = gen_get_country_iso_3_from_2($sInfo->ship_country_code);
     }
     break;
 case 'delete':
     $shipment_id = db_prepare_input($_GET['sID']);
     $result = $db->Execute("select method, ship_date from " . TABLE_SHIPPING_LOG . " where shipment_id = " . (int) $shipment_id);
     $ship_method = $result->fields['method'];
     if ($result->RecordCount() == 0 || !$ship_method) {
         $messageStack->add(SHIPPING_FEDEX_DELETE_ERROR, 'error');
         $error = true;
         break;
     }
     if ($result->fields['ship_date'] < date('Y-m-d', time())) {
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   |
// | GNU General Public License for more details.                    |
// |                                                                 |
// | The license that is bundled with this package is located in the |
// | file: /doc/manual/ch01-Introduction/license.html.               |
// | If not, see http://www.gnu.org/licenses/                        |
// +-----------------------------------------------------------------+
//  Path: /modules/banking/pages/popup_bills_accts/pre_process.php
//
/**************   Check user security   *****************************/
$security_level = (int) $_SESSION['admin_id'];
// for popups, just make sure they are logged in
if ($security_level == 0) {
    // no permission to enter page, error and redirect to home page
    $messageStack->add_session(ERROR_NO_PERMISSION, 'error');
    gen_redirect(html_href_link(FILENAME_DEFAULT, '', 'SSL'));
}
/**************  include page specific files    *********************/
require DIR_FS_WORKING . 'language/' . $_SESSION['language'] . '/language.php';
require DIR_FS_WORKING . 'functions/banking.php';
/**************   page specific initialization  *************************/
define('JOURNAL_ID', $_GET['jID']);
define('ACCOUNT_TYPE', $_GET['type']);
switch (JOURNAL_ID) {
    default:
    case 18:
        $terms_type = 'AR';
        $default_purchase_invoice_id = 'DP' . date('Ymd', time());
        break;
    case 20:
        $terms_type = 'AP';
             $file_name = $file_path . $tracking_num . '.lpt';
             if (!($handle = fopen($file_name, 'r'))) {
                 $error = $messageStack->add('Cannot open file (' . $file_name . ')', 'error');
             }
             $label_data .= fread($handle, filesize($file_path));
             fclose($handle);
         }
         if (!$error) {
             $auto_print = true;
             $label_data = str_replace("\r", "", addslashes($label_data));
             // for javascript multi-line
             $label_data = str_replace("\n", "\\n", $label_data);
         }
     } else {
         // send to viewer window
         gen_redirect(html_href_link(FILENAME_DEFAULT, 'module=shipping&page=popup_label_viewer&method=' . $shipping_module . '&date=' . $date . '&labels=' . $labels, 'SSL'));
     }
     break;
 case 'delete':
     $shipment_id = db_prepare_input($_GET['sID']);
     $result = $db->Execute("select method, ship_date from " . TABLE_SHIPPING_LOG . " where shipment_id = " . (int) $shipment_id);
     $ship_method = $result->fields['method'];
     if ($result->RecordCount() == 0 || !$ship_method) {
         $messageStack->add(SHIPPING_DELETE_ERROR, 'error');
         $error = true;
         break;
     }
     if ($result->fields['ship_date'] < date('Y-m-d')) {
         // only allow delete if shipped today or in future
         $messageStack->add(SHIPPING_CANNOT_DELETE, 'error');
         $error = true;
 function Execute($zf_sql, $zf_limit = false, $zf_cache = false, $zf_cachetime = 0)
 {
     global $zc_cache, $messageStack;
     if ($zf_limit) {
         $zf_sql = $zf_sql . ' LIMIT ' . $zf_limit;
     }
     if ($zf_cache and $zc_cache->sql_cache_exists($zf_sql) and !$zc_cache->sql_cache_is_expired($zf_sql, $zf_cachetime)) {
         $obj = new queryFactoryResult();
         $obj->cursor = 0;
         $obj->is_cached = true;
         $obj->sql_query = $zf_sql;
         $zp_result_array = $zc_cache->sql_cache_read($zf_sql);
         $obj->result = $zp_result_array;
         if (sizeof($zp_result_array) > 0) {
             $obj->EOF = false;
             while (list($key, $value) = each($zp_result_array[0])) {
                 $obj->fields[$key] = $value;
             }
             return $obj;
         } else {
             $obj->EOF = true;
         }
     } elseif ($zf_cache) {
         $zc_cache->sql_cache_expire_now($zf_sql);
         $time_start = explode(' ', microtime());
         $obj = new queryFactoryResult();
         $obj->sql_query = $zf_sql;
         if (!$this->db_connected) {
             $this->set_error('0', DB_ERROR_NOT_CONNECTED);
         }
         $zp_db_resource = @mysql_query($zf_sql, $this->link);
         if (!$zp_db_resource) {
             $this->set_error(@mysql_errno(), @mysql_error());
         }
         $obj->resource = $zp_db_resource;
         $obj->cursor = 0;
         $obj->is_cached = true;
         if ($obj->RecordCount() > 0) {
             $obj->EOF = false;
             $zp_ii = 0;
             while (!$obj->EOF) {
                 $zp_result_array = @mysql_fetch_array($zp_db_resource);
                 if ($zp_result_array) {
                     while (list($key, $value) = each($zp_result_array)) {
                         if (!preg_match('/^[0-9]/', $key)) {
                             $obj->result[$zp_ii][$key] = $value;
                         }
                     }
                 } else {
                     $obj->Limit = $zp_ii;
                     $obj->EOF = true;
                 }
                 $zp_ii++;
             }
             while (list($key, $value) = each($obj->result[$obj->cursor])) {
                 if (!preg_match('/^[0-9]/', $key)) {
                     $obj->fields[$key] = $value;
                 }
             }
             $obj->EOF = false;
         } else {
             $obj->EOF = true;
         }
         $zc_cache->sql_cache_store($zf_sql, $obj->result);
         $time_end = explode(' ', microtime());
         $query_time = $time_end[1] + $time_end[0] - $time_start[1] - $time_start[0];
         $this->total_query_time += $query_time;
         $this->count_queries++;
         return $obj;
     } else {
         $time_start = explode(' ', microtime());
         $obj = new queryFactoryResult();
         if (!$this->db_connected) {
             $this->set_error('0', DB_ERROR_NOT_CONNECTED);
         }
         $zp_db_resource = @mysql_query($zf_sql, $this->link);
         if (!$zp_db_resource) {
             if (method_exists($messageStack, 'debug')) {
                 $messageStack->debug("\n\nThe failing sql was: " . $zf_sql);
                 $messageStack->debug("\n\nmySQL returned: " . @mysql_errno($this->link) . ' ' . @mysql_error($this->link));
                 $messageStack->write_debug();
                 $messageStack->add_session('The last transaction had a SQL database error.', 'error');
                 gen_redirect(html_href_link(FILENAME_DEFAULT, 'cat=general&module=crash', 'SSL'));
             }
             echo 'The failing sql was: ' . $zf_sql . '<br><br>';
             $this->set_error(@mysql_errno($this->link), @mysql_error($this->link));
         }
         $obj->resource = $zp_db_resource;
         $obj->cursor = 0;
         if ($obj->RecordCount() > 0) {
             $obj->EOF = false;
             $zp_result_array = @mysql_fetch_array($zp_db_resource);
             if ($zp_result_array) {
                 while (list($key, $value) = each($zp_result_array)) {
                     if (!preg_match('/^[0-9]/', $key)) {
                         $obj->fields[$key] = $value;
                     }
                 }
                 $obj->EOF = false;
             } else {
                 $obj->EOF = true;
             }
         } else {
             $obj->EOF = true;
         }
         $time_end = explode(' ', microtime());
         $query_time = $time_end[1] + $time_end[0] - $time_start[1] - $time_start[0];
         $this->total_query_time += $query_time;
         $this->count_queries++;
         return $obj;
     }
 }
Example #22
0
 function showDropDown()
 {
     global $db, $messageStack;
     foreach ($this->store_ids as $store) {
         $temp[] = $store['id'];
     }
     $sql = "select till_id, description from " . $this->db_table . " where store_id in (" . implode(',', $temp) . ")";
     $result = $db->Execute($sql);
     if ($result->RecordCount() == 0) {
         // trigger_error("Before continuing set a till for this store. This will contain default values to allow this page to work", E_USER_ERROR);// there should always be a till because of defaults values.
         $messageStack->add("Before continuing set a till for this store.<br> This will contain default values to allow this page to work", 'error');
         gen_redirect(html_href_link(FILENAME_DEFAULT, '', 'SSL'));
     }
     if (defined('ENABLE_ENCRYPTION') && ENABLE_ENCRYPTION == true && (!isset($_SESSION['admin_encrypt']) || $_SESSION['admin_encrypt'] == '')) {
         $messageStack->add("Error - Encryption key not set! The encryption key must be set to use the POS module.", 'error');
         gen_redirect(html_href_link(FILENAME_DEFAULT, '', 'SSL'));
     }
     if ($result->RecordCount() == 1) {
         return false;
     } else {
         return true;
     }
 }