Пример #1
0
function ie_process_the_data($value, $process_key, $export = true)
{
    global $currencies;
    switch ($process_key) {
        case 'real_r2':
            return $currencies->clean_value($value);
        case 'date':
            // assumes m/d/yyyy format
            if ($export) {
                return date(DATE_FORMAT, strtotime($value));
            } else {
                return gen_db_date_short($value, $separator = '/');
            }
        case 'date-time':
            return date(DATE_TIME_FORMAT, strtotime($value));
        case 'trim':
            return trim($value);
        case 'none':
            return $value;
        default:
            return $value;
    }
}
Пример #2
0
 $order->store_id = db_prepare_input($_POST['store_id']);
 if ($order->store_id == '') {
     $order->store_id = 0;
 }
 $order->description = constant('GENERAL_JOURNAL_' . JOURNAL_ID . '_DESC');
 $order->recur_id = db_prepare_input($_POST['recur_id']);
 $order->recur_frequency = db_prepare_input($_POST['recur_frequency']);
 //	$order->sales_tax_auths     = db_prepare_input($_POST['sales_tax_auths']);
 $order->admin_id = $_SESSION['admin_id'];
 $order->rep_id = db_prepare_input($_POST['rep_id']);
 $order->gl_acct_id = db_prepare_input($_POST['gl_acct_id']);
 $order->terms = db_prepare_input($_POST['terms']);
 $order->drop_ship = isset($_POST['drop_ship']) ? $_POST['drop_ship'] : 0;
 $order->waiting = JOURNAL_ID == 6 || JOURNAL_ID == 7 ? isset($_POST['waiting']) ? 1 : 0 : 0;
 $order->closed = $_POST['closed'] == '1' ? 1 : 0;
 $order->terminal_date = gen_db_date_short($_POST['terminal_date']);
 $order->item_count = db_prepare_input($_POST['item_count']);
 $order->weight = db_prepare_input($_POST['weight']);
 $order->printed = db_prepare_input($_POST['printed']);
 // currency values (convert to DEFAULT_CURRENCY to store in db)
 $order->currencies_code = db_prepare_input($_POST['currencies_code']);
 $order->currencies_value = db_prepare_input($_POST['currencies_value']);
 $order->subtotal = $currencies->clean_value(db_prepare_input($_POST['subtotal']), $order->currencies_code) / $order->currencies_value;
 // don't need unless for verification
 $order->disc_gl_acct_id = db_prepare_input($_POST['disc_gl_acct_id']);
 $order->discount = $currencies->clean_value(db_prepare_input($_POST['discount']), $order->currencies_code) / $order->currencies_value;
 $order->disc_percent = $order->subtotal ? 1 - ($order->subtotal - $order->discount) / $order->subtotal : 0;
 $order->ship_gl_acct_id = db_prepare_input($_POST['ship_gl_acct_id']);
 $order->freight = $currencies->clean_value(db_prepare_input($_POST['freight']), $order->currencies_code) / $order->currencies_value;
 $order->sales_tax = $currencies->clean_value(db_prepare_input($_POST['sales_tax']), $order->currencies_code) / $order->currencies_value;
 $order->total_amount = $currencies->clean_value(db_prepare_input($_POST['total']), $order->currencies_code) / $order->currencies_value;
 function processCSV($upload_name = '')
 {
     global $coa, $db, $currencies, $messageStack;
     if (!$this->cyberParse($upload_name)) {
         return false;
     }
     // parse the submitted string, check for csv errors
     //echo 'parsed string = '; print_r($this->records); echo '<br />';
     $row_id = 0;
     while ($row_id < count($this->records)) {
         $current_order = $this->records[$row_id];
         // pre-process and check for errors
         if (!in_array($current_order['gl_acct'], $coa) || !in_array($current_order['inv_gl_acct'], $coa)) {
             $messageStack->add(GL_BEG_BAL_ERROR_1 . ($row_id + 1), 'error');
             return false;
         }
         if (!$current_order['order_id']) {
             switch (JOURNAL_ID) {
                 case 6:
                     $messageStack->add(GL_BEG_BAL_ERROR_2A . ($row_id + 1) . GL_BEG_BAL_ERROR_2B, 'caution');
                     $this->records[$row_id]['waiting'] = 1;
                     break;
                 default:
                     $messageStack->add(GL_BEG_BAL_ERROR_3 . ($row_id + 1), 'error');
                     return false;
             }
         }
         $this->records[$row_id]['post_date'] = gen_db_date_short($current_order['post_date']);
         // from mm/dd/yyyy to YYYY-MM-DD
         if (!validate_db_date($this->records[$row_id]['post_date'])) {
             $messageStack->add(GL_BEG_BAL_ERROR_4A . ($row_id + 1) . GL_BEG_BAL_ERROR_4B . DATE_FORMAT, 'error');
             return false;
         }
         switch (JOURNAL_ID) {
             // total amount is calculated for PO/SOs
             case 6:
             case 12:
                 $this->records[$row_id]['total_amount'] = $currencies->clean_value($current_order['total_amount']);
                 if ($current_order['total_amount'] == 0) {
                     $messageStack->add(GL_BEG_BAL_ERROR_5 . ($row_id + 1), 'caution');
                     $this->records[$row_id]['skip_this_record'] = 1;
                 }
             default:
         }
         // TBD check for duplicate so/po/invoice numbers
         $row_id++;
     }
     // start processing
     if (is_array($this->records)) {
         // *************** START TRANSACTION *************************
         $db->transStart();
         if (!$this->submitJournalEntry()) {
             $db->transRollback();
             return false;
         }
         $db->transCommit();
         // post the chart of account values
         // *************** END TRANSACTION *************************
     }
     return true;
 }
Пример #4
0
define('AUDIT_LOG_DESC', BNK_20_ENTER_BILLS);
$post_success = false;
$error = false;
$action = isset($_GET['action']) ? $_GET['action'] : $_POST['todo'];
$post_date = $_POST['post_date'] ? gen_db_date_short($_POST['post_date']) : ($_GET['post_date'] ? $_GET['post_date'] : date('Y-m-d', time()));
$_GET['post_date'] = $post_date;
$period = gen_calculate_period($post_date);
if (!$period) {
    // bad post_date was submitted
    $action = '';
    $post_date = date('Y-m-d', time());
    $period = 0;
}
$invoice_date = $_POST['invoice_date'] ? gen_db_date_short($_POST['invoice_date']) : ($_GET['invoice_date'] ? $_GET['invoice_date'] : date('Y-m-d', time()));
$_GET['invoice_date'] = $invoice_date;
$discount_date = $_POST['discount_date'] ? gen_db_date_short($_POST['discount_date']) : ($_GET['discount_date'] ? $_GET['discount_date'] : date('Y-m-d', time()));
$_GET['discount_date'] = $discount_date;
$gl_acct_id = $_POST['gl_acct_id'] ? db_prepare_input($_POST['gl_acct_id']) : ($_GET['gl_acct_id'] ? $_GET['gl_acct_id'] : AP_PURCHASE_INVOICE_ACCOUNT);
$_GET['gl_acct_id'] = $gl_acct_id;
$gl_disc_acct_id = $_POST['gl_disc_acct_id'] ? db_prepare_input($_POST['gl_disc_acct_id']) : ($_GET['gl_disc_acct_id'] ? $_GET['gl_disc_acct_id'] : AP_DISCOUNT_PURCHASE_ACCOUNT);
$_GET['gl_disc_acct_id'] = $gl_disc_acct_id;
$purch_order_id = db_prepare_input($_POST['purch_order_id']);
// reference text
$purchase_invoice_id = db_prepare_input($_POST['purchase_invoice_id']);
// PhreeBooks starting check number
if (!$purchase_invoice_id) {
    $result = $db->Execute("select next_check_num from " . TABLE_CURRENT_STATUS);
    $purchase_invoice_id = $result->fields['next_check_num'];
}
/***************   hook for custom actions  ***************************/
$custom_path = DIR_FS_MY_FILES . 'custom/banking/bills/extra_actions.php';
Пример #5
0
// | file: /doc/manual/ch01-Introduction/license.html.               |
// | If not, see http://www.gnu.org/licenses/                        |
// +-----------------------------------------------------------------+
//  Path: /modules/services/pages/ship_mgr/pre_process.php
//
/**************   Check user security   *****************************/
$security_level = $_SESSION['admin_security'][SECURITY_ID_SHIPPING_MANAGER];
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 . 'shipping/language/' . $_SESSION['language'] . '/language.php';
/**************   page specific initialization  *************************/
$date = $_GET['search_date'] ? gen_db_date_short($_GET['search_date']) : date('Y-m-d', time());
$search_text = $_GET['search_text'] == TEXT_SEARCH ? '' : db_input(db_prepare_input($_GET['search_text']));
$action = isset($_GET['action']) ? $_GET['action'] : $_POST['todo'];
$module_id = isset($_POST['module_id']) ? $_POST['module_id'] : '';
$row_seq = isset($_POST['rowSeq']) ? $_POST['rowSeq'] : '';
$file_extension = substr($PHP_SELF, strrpos($PHP_SELF, '.'));
$directory_array = array();
// load standard modules
define('DEFAULT_MOD_DIR', DIR_FS_WORKING . 'shipping/');
if ($dir = @dir(DEFAULT_MOD_DIR . 'modules/')) {
    while ($file = $dir->read()) {
        if (!is_dir(DEFAULT_MOD_DIR . 'modules/' . $file)) {
            if (substr($file, strrpos($file, '.')) == $file_extension) {
                $directory_array[] = $file;
            }
        }
Пример #6
0
     $asset_path = substr($asset_path, 0, strlen($asset_path) - 1);
 }
 // remove trailing '/' if there
 $asset_type = db_prepare_input($_POST['asset_type']);
 $sql_data_array = array();
 $asset_fields = $db->Execute("select field_name, entry_type from " . TABLE_ASSETS_FIELDS);
 while (!$asset_fields->EOF) {
     $field_name = $asset_fields->fields['field_name'];
     if (!isset($_POST[$field_name]) && $asset_fields->fields['entry_type'] == 'check_box') {
         $sql_data_array[$field_name] = '0';
         // special case for unchecked check boxes
     } elseif (isset($_POST[$field_name]) && $field_name != 'id') {
         $sql_data_array[$field_name] = db_prepare_input($_POST[$field_name]);
     }
     if ($asset_fields->fields['entry_type'] == 'date_time') {
         $sql_data_array[$field_name] = $sql_data_array[$field_name] ? gen_db_date_short($sql_data_array[$field_name]) : '';
     }
     $asset_fields->MoveNext();
 }
 // special cases for checkboxes of system fields (don't return a POST value if unchecked)
 $remove_image = $_POST['remove_image'] == '1' ? true : false;
 unset($sql_data_array['remove_image']);
 // this is not a db field, just an action
 $sql_data_array['inactive'] = $sql_data_array['inactive'] == '1' ? '1' : '0';
 // special cases for monetary values in system fields
 $sql_data_array['full_price'] = $currencies->clean_value($sql_data_array['full_price']);
 $sql_data_array['asset_cost'] = $currencies->clean_value($sql_data_array['asset_cost']);
 // TBD - validate input
 if ($remove_image) {
     // update the image with relative path
     $_POST['image_with_path'] = '';
Пример #7
0
// | 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/banking/ajax/acct_balance.php
//
/**************   Check user security   *****************************/
// None
/**************  include page specific files    *********************/
require DIR_FS_MODULES . 'banking/functions/banking.php';
/**************   page specific initialization  *************************/
$gl_acct_id = $_GET['gl_acct_id'] ? db_prepare_input($_GET['gl_acct_id']) : AP_PURCHASE_INVOICE_ACCOUNT;
$post_date = $_GET['post_date'] ? gen_db_date_short($_GET['post_date']) : date('Y-m-d', time());
$period = gen_calculate_period($post_date);
if (!$period) {
    // bad post_date was submitted
    $post_date = date('Y-m-d', time());
    $period = 0;
}
$xml = xmlEntry("value", load_cash_acct_balance($post_date, $gl_acct_id, $period));
// error check
//put it all together
$str = createXmlHeader('acctbal');
$str .= $xml;
$str .= createXmlFooter();
echo $str;
die;
Пример #8
0
if (file_exists($custom_path)) {
    include $custom_path;
}
/***************   Act on the action request   *************************/
switch ($action) {
    case 'save':
    case 'update':
        if ($security_level < 2) {
            $messageStack->add_session(ERROR_NO_PERMISSION, 'error');
            gen_redirect(html_href_link(FILENAME_DEFAULT, gen_get_all_get_params(array('action')), 'SSL'));
            break;
        }
        $id = db_prepare_input($_POST['id']);
        $sheet_name = db_prepare_input($_POST['sheet_name']);
        $revision = db_prepare_input($_POST['revision']);
        $effective_date = gen_db_date_short($_POST['effective_date']);
        $default_sheet = isset($_POST['default_sheet']) ? 1 : 0;
        $encoded_prices = array();
        for ($i = 0, $j = 1; $i < MAX_NUM_PRICE_LEVELS; $i++, $j++) {
            $price = $currencies->clean_value(db_prepare_input($_POST['price_' . $j]));
            $adj = db_prepare_input($_POST['adj_' . $j]);
            $adj_val = $currencies->clean_value(db_prepare_input($_POST['adj_val_' . $j]));
            $rnd = db_prepare_input($_POST['rnd_' . $j]);
            $rnd_val = $currencies->clean_value(db_prepare_input($_POST['rnd_val_' . $j]));
            $level_data = $_POST['price_' . $j] ? $price : '0';
            $level_data .= ':' . db_prepare_input($_POST['qty_' . $j]);
            $level_data .= ':' . db_prepare_input($_POST['src_' . $j]);
            $level_data .= ':' . ($_POST['adj_' . $j] ? $adj : '0');
            $level_data .= ':' . ($_POST['adj_val_' . $j] ? $adj_val : '0');
            $level_data .= ':' . ($_POST['rnd_' . $j] ? $rnd : '0');
            $level_data .= ':' . ($_POST['rnd_val_' . $j] ? $rnd_val : '0');
Пример #9
0
/**************  include page specific files    *********************/
require DIR_FS_WORKING . 'language/' . $_SESSION['language'] . '/language.php';
require DIR_FS_WORKING . 'functions/rma.php';
/**************   page specific initialization  *************************/
// make sure the module is installed
$result = $db->Execute("SHOW TABLES LIKE '" . TABLE_RMA . "'");
if ($result->RecordCount() == 0) {
    $messageStack->add_session(RMA_MGR_NOT_INSTALLED, 'caution');
    gen_redirect(html_href_link(FILENAME_DEFAULT, 'cat=rma&module=admin', 'SSL'));
}
$error = false;
$processed = false;
$cInfo = new objectInfo(array());
$creation_date = $_POST['creation_date'] ? gen_db_date_short($_POST['creation_date']) : date('Y-m-d', time());
$receive_date = $_POST['receive_date'] ? gen_db_date_short($_POST['receive_date']) : '';
$closed_date = $_POST['closed_date'] ? gen_db_date_short($_POST['closed_date']) : '';
$search_text = $_POST['search_text'] ? db_input(db_prepare_input($_POST['search_text'])) : db_input(db_prepare_input($_GET['search_text']));
if ($search_text == TEXT_SEARCH) {
    $search_text = '';
}
$action = isset($_GET['action']) ? $_GET['action'] : $_POST['todo'];
if (!$action && $search_text != '') {
    $action = 'search';
}
// if enter key pressed and search not blank
/***************   hook for custom actions  ***************************/
$custom_path = DIR_FS_MY_FILES . 'custom/rma/main/extra_actions.php';
if (file_exists($custom_path)) {
    include $custom_path;
}
/***************   Act on the action request   *************************/
Пример #10
0
$action = isset($_GET['action']) ? $_GET['action'] : $_POST['todo'];
/***************   hook for custom actions  ***************************/
$custom_path = DIR_FS_MY_FILES . 'custom/accounts/popup_accts/extra_actions.php';
if (file_exists($custom_path)) {
    include $custom_path;
}
/***************   Act on the action request   *************************/
switch ($action) {
    case 'save':
        $i = 1;
        while (true) {
            if (!isset($_POST['eta_date_' . $i])) {
                break;
            }
            if ($_POST['eta_date_' . $i] != '') {
                $new_date = gen_db_date_short($_POST['eta_date_' . $i]);
                $rID = $_POST['id_' . $i];
                $db->Execute("update " . TABLE_JOURNAL_ITEM . " set date_1 = '" . $new_date . "' where id = " . $rID);
            }
            $i++;
        }
        gen_add_audit_log(ORD_DELIVERY_DATES . TEXT_EDIT, $result->fields['purchase_invoice_id']);
        break;
    default:
}
/*****************   prepare to display templates  *************************/
$gl_type = JOURNAL_ID == 4 || JOURNAL_ID == 6 ? 'poo' : 'soo';
$sql = " select m.purchase_invoice_id, i.id, i.sku, i.qty, i.description, i.date_1 \r\n\tfrom " . TABLE_JOURNAL_MAIN . " m inner join " . TABLE_JOURNAL_ITEM . " i on m.id = i.ref_id \r\n\twhere i.ref_id = " . $oID . " and i.gl_type = '" . $gl_type . "'";
$ordr_items = $db->Execute($sql);
$num_items = $ordr_items->RecordCount();
$include_header = false;
Пример #11
0
/***************   hook for custom actions  ***************************/
$custom_path = DIR_FS_MY_FILES . 'custom/inventory/assemblies/extra_actions.php';
if (file_exists($custom_path)) {
    include $custom_path;
}
/***************   Act on the action request   *************************/
switch ($action) {
    case 'save':
        // security check
        if ($security_level < 2) {
            $messageStack->add_session(ERROR_NO_PERMISSION, 'error');
            gen_redirect(html_href_link(FILENAME_DEFAULT, gen_get_all_get_params(array('action')), 'SSL'));
            break;
        }
        // retrieve and clean input values
        $glEntry->post_date = gen_db_date_short($_POST['post_date']);
        $glEntry->purchase_invoice_id = db_prepare_input($_POST['purchase_invoice_id']);
        $glEntry->admin_id = $_SESSION['admin_id'];
        $sku = db_prepare_input($_POST['sku_1']);
        $qty = db_prepare_input($_POST['qty_1']);
        $desc = db_prepare_input($_POST['desc_1']);
        $stock = db_prepare_input($_POST['stock_1']);
        $serial = db_prepare_input($_POST['serial_1']);
        // check for errors and prepare extra values
        $glEntry->period = gen_calculate_period($glEntry->post_date);
        if (!$glEntry->period) {
            $error = true;
        }
        // if unbuild, test for stock to go negative
        $result = $db->Execute("select account_inventory_wage, quantity_on_hand \r\n\t    from " . TABLE_INVENTORY . " where sku = '" . $sku . "'");
        $sku_inv_acct = $result->fields['account_inventory_wage'];
Пример #12
0
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_MODULES . 'gen_ledger/language/' . $_SESSION['language'] . '/language.php';
require DIR_FS_MODULES . 'gen_ledger/classes/gen_ledger.php';
require DIR_FS_WORKING . 'functions/inventory.php';
/**************   page specific initialization  *************************/
define('JOURNAL_ID', 16);
// Adjustment Journal
define('GL_TYPE', '');
$error = false;
$post_date = $_POST['post_date'] ? gen_db_date_short($_POST['post_date']) : date('Y-m-d');
$period = gen_calculate_period($post_date);
if (!$period) {
    $error = true;
}
$action = isset($_GET['action']) ? $_GET['action'] : $_POST['todo'];
/***************   hook for custom actions  ***************************/
$custom_path = DIR_FS_MY_FILES . 'custom/inventory/transfer/extra_actions.php';
if (file_exists($custom_path)) {
    include $custom_path;
}
/***************   Act on the action request   *************************/
switch ($action) {
    case 'save':
        // security check
        if ($security_level < 2) {
Пример #13
0
                if (DEBUG) {
                    $messageStack->write_debug();
                }
                gen_add_audit_log(GL_LOG_ADD_JOURNAL . TEXT_DELETE, $delGL->purchase_invoice_id);
                gen_redirect(html_href_link(FILENAME_DEFAULT, gen_get_all_get_params(array('action')), 'SSL'));
            }
            // *************** END TRANSACTION *************************
        }
        $db->transRollback();
        $messageStack->add(GL_ERROR_NO_DELETE, 'error');
        if (DEBUG) {
            $messageStack->write_debug();
        }
        $cInfo = new objectInfo($_POST);
        // if we are here, there was an error, reload page
        $cInfo->post_date = gen_db_date_short($_POST['post_date']);
        break;
    case 'edit':
        $oID = (int) $_GET['oID'];
        if ($security_level < 2) {
            $messageStack->add_session(ERROR_NO_PERMISSION, 'error');
            gen_redirect(html_href_link(FILENAME_DEFAULT, gen_get_all_get_params(array('action')), 'SSL'));
            break;
        }
        $cInfo = new objectInfo(array());
        break;
    default:
}
/*****************   prepare to display templates  *************************/
// load gl accounts
$gl_array_list = gen_coa_pull_down();
Пример #14
0
    include $custom_path;
}
/***************   Act on the action request   *************************/
switch ($action) {
    case 'update':
        if ($security_level < 3) {
            $messageStack->add_session(ERROR_NO_PERMISSION, 'error');
            gen_redirect(html_href_link(FILENAME_DEFAULT, gen_get_all_get_params(array('action')), 'SSL'));
            break;
        }
        // propagate into remaining fiscal years if the last date was changed.
        $fy_array = array();
        $x = 0;
        while (isset($_POST['start_' . $x])) {
            $update_period = db_prepare_input($_POST['per_' . $x]);
            $fy_array = array('start_date' => gen_db_date_short(db_prepare_input($_POST['start_' . $x])), 'end_date' => gen_db_date_short(db_prepare_input($_POST['end_' . $x])));
            db_perform(TABLE_ACCOUNTING_PERIODS, $fy_array, 'update', 'period = ' . (int) $update_period);
            $x++;
        }
        // see if there is a disconnect between fiscal years
        $next_period = $update_period + 1;
        $next_start_date = date('Y-m-d', strtotime($fy_array['end_date']) + 60 * 60 * 24);
        $result = $db->Execute("select start_date from " . TABLE_ACCOUNTING_PERIODS . " where period = " . $next_period);
        if ($result->RecordCount() > 0) {
            // next FY exists, check it
            if ($next_start_date != $result->fields['start_date']) {
                $fy_array = array('start_date' => $next_start_date);
                db_perform(TABLE_ACCOUNTING_PERIODS, $fy_array, 'update', 'period = ' . (int) $next_period);
                $messageStack->add(GL_ERROR_FISCAL_YEAR_SEQ, 'caution');
                $fy++;
            }
Пример #15
0
function gen_build_sql_date($date_prefs, $df)
{
    global $db;
    $dates = gen_get_dates();
    $DateArray = explode(':', $date_prefs);
    $t = time();
    $ds = '0000-00-00';
    // pick a start date a long time ago
    $de = '2199-00-00';
    // pick an end date a long time from now
    switch ($DateArray[0]) {
        // based on the date choice selected
        default:
        case "a":
            // All, skip the date addition to the where statement, all dates in db
            $d = '';
            $fildesc = '';
            break;
        case "b":
            // Date Range
            $d = '';
            $fildesc = RW_RPT_DATERANGE;
            if ($DateArray[1] != '') {
                $ds = gen_db_date_short($DateArray[1]);
                $d .= $df . " >= '" . $ds . "'";
                $fildesc .= ' ' . TEXT_FROM . ' ' . $DateArray[1];
            }
            if ($DateArray[2] != '') {
                // a value entered, check
                if (strlen($d) > 0) {
                    $d .= ' and ';
                }
                $de = gen_specific_date(gen_db_date_short($DateArray[2]), 1);
                $d .= $df . " < '" . $de . "'";
                $fildesc .= ' ' . TEXT_TO . ' ' . $DateArray[2];
            }
            $fildesc .= '; ';
            break;
        case "c":
            // Today (specify range for datetime type fields to match for time parts)
            $ds = $dates['Today'];
            $de = gen_specific_date($dates['Today'], 1);
            $d = $df . " >= '" . $ds . "' and " . $df . " < '" . $de . "'";
            $fildesc = RW_RPT_DATERANGE . ' = ' . gen_date_short($dates['Today']) . '; ';
            break;
        case "d":
            // This Week
            $ds = date('Y-m-d', mktime(0, 0, 0, $dates['ThisMonth'], date('j', $t) - date('w', $t), $dates['ThisYear']));
            $de = gen_specific_date(date('Y-m-d', mktime(0, 0, 0, $dates['ThisMonth'], date('j', $t) - date('w', $t) + 6, $dates['ThisYear'])), 1);
            $d = $df . " >= '" . $ds . "' and " . $df . " < '" . $de . "'";
            $fildesc = RW_RPT_DATERANGE . ' ' . TEXT_FROM . ' ' . gen_date_short($ds) . ' ' . TEXT_TO . ' ' . gen_date_short(gen_specific_date($de, -1)) . '; ';
            break;
        case "e":
            // This Week to Date
            $ds = date('Y-m-d', mktime(0, 0, 0, $dates['ThisMonth'], date('j', $t) - date('w', $t), $dates['ThisYear']));
            $de = gen_specific_date($dates['Today'], 1);
            $d = $df . " >= '" . $ds . "' and " . $df . " < '" . $de . "'";
            $fildesc = RW_RPT_DATERANGE . ' ' . TEXT_FROM . ' ' . gen_date_short($ds) . ' ' . TEXT_TO . ' ' . gen_date_short($dates['Today']) . '; ';
            break;
        case "f":
            // This Month
            $ds = date('Y-m-d', mktime(0, 0, 0, $dates['ThisMonth'], 1, $dates['ThisYear']));
            $de = gen_specific_date(date('Y-m-d', mktime(0, 0, 0, $dates['ThisMonth'], $dates['TotalDays'], $dates['ThisYear'])), 1);
            $d = $df . " >= '" . $ds . "' and " . $df . " < '" . $de . "'";
            $fildesc = RW_RPT_DATERANGE . ' ' . TEXT_FROM . ' ' . gen_date_short($ds) . ' ' . TEXT_TO . ' ' . gen_date_short(gen_specific_date($de, -1)) . '; ';
            break;
        case "g":
            // This Month to Date
            $ds = date('Y-m-d', mktime(0, 0, 0, $dates['ThisMonth'], 1, $dates['ThisYear']));
            $de = gen_specific_date($dates['Today'], 1);
            $d = $df . " >= '" . $ds . "' and " . $df . " < '" . $de . "'";
            $fildesc = RW_RPT_DATERANGE . ' ' . TEXT_FROM . ' ' . gen_date_short($ds) . ' ' . TEXT_TO . ' ' . gen_date_short($dates['Today']) . '; ';
            break;
        case "h":
            // This Quarter
            $QtrStrt = CURRENT_ACCOUNTING_PERIOD - (CURRENT_ACCOUNTING_PERIOD - 1) % 3;
            $temp = gen_calculate_fiscal_dates($QtrStrt);
            $ds = $temp['start_date'];
            $temp = gen_calculate_fiscal_dates($QtrStrt + 2);
            $de = gen_specific_date($temp['end_date'], 1);
            $d = $df . " >= '" . $ds . "' and " . $df . " < '" . $de . "'";
            $fildesc = RW_RPT_DATERANGE . ' ' . TEXT_FROM . ' ' . gen_date_short($ds) . ' ' . TEXT_TO . ' ' . gen_date_short($temp['end_date']) . '; ';
            break;
        case "i":
            // Quarter to Date
            $QtrStrt = CURRENT_ACCOUNTING_PERIOD - (CURRENT_ACCOUNTING_PERIOD - 1) % 3;
            $temp = gen_calculate_fiscal_dates($QtrStrt);
            $ds = $temp['start_date'];
            $de = gen_specific_date($dates['Today'], 1);
            $d = $df . " >= '" . $ds . "' and " . $df . " < '" . $de . "'";
            $fildesc = RW_RPT_DATERANGE . ' ' . TEXT_FROM . ' ' . gen_date_short($ds) . ' ' . TEXT_TO . ' ' . gen_date_short($dates['Today']) . '; ';
            break;
        case "j":
            // This Year
            $YrStrt = CURRENT_ACCOUNTING_PERIOD - (CURRENT_ACCOUNTING_PERIOD - 1) % 12;
            $temp = gen_calculate_fiscal_dates($YrStrt);
            $ds = $temp['start_date'];
            $temp = gen_calculate_fiscal_dates($YrStrt + 11);
            $de = gen_specific_date($temp['end_date'], 1);
            $d = $df . " >= '" . $ds . "' and " . $df . " < '" . $de . "'";
            $fildesc = RW_RPT_DATERANGE . ' ' . TEXT_FROM . ' ' . gen_date_short($ds) . ' ' . TEXT_TO . ' ' . gen_date_short($temp['end_date']) . '; ';
            break;
        case "k":
            // Year to Date
            $YrStrt = CURRENT_ACCOUNTING_PERIOD - (CURRENT_ACCOUNTING_PERIOD - 1) % 12;
            $temp = gen_calculate_fiscal_dates($YrStrt);
            $ds = $temp['start_date'];
            $de = gen_specific_date($dates['Today'], 1);
            $d = $df . " >= '" . $ds . "' and " . $df . " < '" . $de . "'";
            $fildesc = RW_RPT_DATERANGE . ' ' . TEXT_FROM . ' ' . gen_date_short($ds) . ' ' . TEXT_TO . ' ' . gen_date_short($dates['Today']) . '; ';
            break;
        case "l":
            // This Period
            $ds = CURRENT_ACCOUNTING_PERIOD_START;
            $de = gen_specific_date(CURRENT_ACCOUNTING_PERIOD_END, 1);
            $d = $df . " >= '" . $ds . "' and " . $df . " < '" . $de . "'";
            $fildesc = TEXT_PERIOD . ' ' . CURRENT_ACCOUNTING_PERIOD . ' (' . gen_date_short(CURRENT_ACCOUNTING_PERIOD_START) . ' ' . TEXT_TO . ' ' . gen_date_short(CURRENT_ACCOUNTING_PERIOD_END) . '); ';
            break;
        case "z":
            // date by period
            $temp = gen_calculate_fiscal_dates($DateArray[1]);
            $ds = $temp['start_date'];
            $de = $temp['end_date'];
            $d = 'period = ' . $DateArray[1];
            $fildesc = TEXT_PERIOD . ' ' . $DateArray[1] . ' (' . gen_date_short($ds) . ' ' . TEXT_TO . ' ' . gen_date_short($de) . '); ';
            break;
    }
    $dates = array('sql' => $d, 'description' => $fildesc, 'start_date' => $ds, 'end_date' => $de);
    return $dates;
}
Пример #16
0
    require DIR_FS_MY_FILES . 'custom/services/shipping/modules/' . $module_name . '.php';
}
$subject_module = new $module_name();
$sID = $_GET['sID'] ? (int) $_GET['sID'] : 0;
$carrier = $module_name ? $module_name : '';
$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/services/popup_tracking/extra_actions.php';
if (file_exists($custom_path)) {
    include $custom_path;
}
/***************   Act on the action request   *************************/
switch ($action) {
    case 'save':
        $sql_data_array = array('carrier' => db_prepare_input($_POST['carrier']), 'ref_id' => db_prepare_input($_POST['ref_id']), 'method' => db_prepare_input($_POST['method']), 'ship_date' => gen_db_date_short($_POST['ship_date']), 'deliver_date' => gen_db_date_short($_POST['deliver_date']), 'tracking_id' => db_prepare_input($_POST['tracking_id']), 'cost' => $currencies->clean_value($_POST['cost']));
        if (!$sID) {
            // it's a new entry
            $result = $db->Execute("select next_shipment_num from " . TABLE_CURRENT_STATUS);
            $sql_data_array['shipment_id'] = $result->fields['next_shipment_num'];
            db_perform(TABLE_SHIPPING_LOG, $sql_data_array, 'insert');
            $db->Execute("update " . TABLE_CURRENT_STATUS . " set next_shipment_num = next_shipment_num + 1");
            gen_add_audit_log(SHIPPING_SHIPMENT_DETAILS . ' - ' . TEXT_INSERT, $sID);
        } else {
            // update
            db_perform(TABLE_SHIPPING_LOG, $sql_data_array, 'update', "id = " . $sID);
            gen_add_audit_log(SHIPPING_SHIPMENT_DETAILS . ' - ' . TEXT_UPDATE, $sID);
        }
        $close_popup = true;
        break;
    default:
Пример #17
0
$security_level = $_SESSION['admin_security'][SECURITY_ID_GEN_ADMIN_TOOLS];
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'] . '/admin_tools.php';
require DIR_FS_MODULES . 'gen_ledger/language/' . $_SESSION['language'] . '/language.php';
require DIR_FS_WORKING . 'functions/general.php';
require DIR_FS_MODULES . 'gen_ledger/classes/gen_ledger.php';
/**************   page specific initialization  *************************/
// determine what button was pressed, if any
$action = isset($_GET['action']) ? $_GET['action'] : $_POST['todo'];
$start_date = $_POST['start_date'] ? gen_db_date_short($_POST['start_date']) : CURRENT_ACCOUNTING_PERIOD_START;
$end_date = $_POST['end_date'] ? gen_db_date_short($_POST['end_date']) : CURRENT_ACCOUNTING_PERIOD_END;
$error = false;
/***************   hook for custom actions  ***************************/
$custom_path = DIR_FS_MY_FILES . 'custom/general/admin_tools/extra_actions.php';
if (file_exists($custom_path)) {
    include $custom_path;
}
/***************   Act on the action request   *************************/
switch ($action) {
    case 'backup_log':
        require DIR_FS_MODULES . 'install/functions/install.php';
        if (ini_get('max_execution_time') < 20000) {
            set_time_limit(20000);
        }
        $dest_dir = DIR_FS_MY_FILES . 'backups/';
        $company_dir = DIR_FS_MY_FILES . $_SESSION['company'] . '/';
Пример #18
0
function calculate_terms_due_dates($post_date, $terms_encoded, $type = 'AR')
{
    $terms = explode(':', $terms_encoded);
    $date_details = gen_get_dates($post_date);
    $result = array();
    switch ($terms[0]) {
        default:
        case '0':
            // Default terms
            $result['discount'] = constant($type . '_PREPAYMENT_DISCOUNT_PERCENT') / 100;
            $result['net_date'] = gen_specific_date($post_date, constant($type . '_NUM_DAYS_DUE'));
            if ($result['discount'] != 0) {
                $result['early_date'] = gen_specific_date($post_date, constant($type . '_PREPAYMENT_DISCOUNT_DAYS'));
            } else {
                $result['early_date'] = gen_specific_date($post_date, 1000);
                // move way out
            }
            break;
        case '1':
            // Cash on Delivery (COD)
        // Cash on Delivery (COD)
        case '2':
            // Prepaid
            $result['discount'] = 0;
            $result['early_date'] = $post_date;
            $result['net_date'] = $post_date;
            break;
        case '3':
            // Special terms
            $result['discount'] = $terms[1] / 100;
            $result['early_date'] = gen_specific_date($post_date, $terms[2]);
            $result['net_date'] = gen_specific_date($post_date, $terms[3]);
            break;
        case '4':
            // Due on day of next month
            $result['discount'] = $terms[1] / 100;
            $result['early_date'] = gen_specific_date($post_date, $terms[2]);
            $result['net_date'] = gen_db_date_short($terms[3]);
            break;
        case '5':
            // Due at end of month
            $result['discount'] = $terms[1] / 100;
            $result['early_date'] = gen_specific_date($post_date, $terms[2]);
            $result['net_date'] = date('Y-m-d', mktime(0, 0, 0, $date_details['ThisMonth'], $date_details['TotalDays'], $date_details['ThisYear']));
            break;
    }
    return $result;
}
Пример #19
0
require DIR_FS_WORKING . 'shipping/language/' . $_SESSION['language'] . '/modules/' . $shipping_module . '.php';
require DIR_FS_WORKING . 'shipping/functions/shipping.php';
require DIR_FS_WORKING . 'shipping/classes/shipping.php';
require DIR_FS_WORKING . 'shipping/modules/' . $shipping_module . '.php';
/**************   page specific initialization  *************************/
$error = false;
$sInfo = new shipment();
// load defaults
$action = isset($_GET['action']) ? $_GET['action'] : $_POST['todo'];
/***************   Act on the action request   *************************/
switch ($action) {
    case 'save':
        $sInfo->purchase_invoice_id = db_prepare_input($_POST['purchase_invoice_id']);
        $sInfo->ship_method = db_prepare_input($_POST['ship_method']);
        $sInfo->ship_date = gen_db_date_short($_POST['ship_date']);
        $sInfo->deliver_date = gen_db_date_short($_POST['deliver_date']);
        $sInfo->tracking_id = db_prepare_input($_POST['tracking_id']);
        $sInfo->cost = $currencies->clean_value($_POST['cost']);
        $temp = $db->Execute("select next_shipment_num from " . TABLE_CURRENT_STATUS);
        $sql_array = array('ref_id' => $sInfo->purchase_invoice_id, 'shipment_id' => $temp->fields['next_shipment_num'], 'carrier' => $shipping_module, 'method' => $sInfo->ship_method, 'ship_date' => $sInfo->ship_date, 'deliver_date' => $sInfo->deliver_date, 'tracking_id' => $sInfo->tracking_id, 'cost' => $sInfo->cost);
        db_perform(TABLE_SHIPPING_LOG, $sql_array, 'insert');
        $db->Execute("update " . TABLE_CURRENT_STATUS . " set next_shipment_num = next_shipment_num + 1");
        gen_add_audit_log(SHIPPING_LOG_FEDEX_LABEL_PRINTED, $sInfo->purchase_invoice_id);
        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 || !$shipment_id) {
            $messageStack->add(SHIPPING_FEDEX_DELETE_ERROR, 'error');
            $error = true;
Пример #20
0
// 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')) {
            gen_add_audit_log(ZENCART_UPLOAD_PRODUCT, $upXML->sku);
        }
        break;
Пример #21
0
                $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  *************************/
// load the gl account beginning balance
$acct_balance = load_cash_acct_balance($post_date, $gl_acct_id, $period);
// load gl accounts
$gl_array_list = gen_coa_pull_down();
// generate the list of gl accounts and fill js arrays for dynamic pull downs
$js_gl_array = 'var js_gl_array = new Array(' . count($gl_array_list) . ');' . chr(10);
Пример #22
0
         break;
     }
     $shipment = new fedex();
     if ($shipment->deleteLabel($ship_method, $shipment_id)) {
         $db->Execute("delete from " . TABLE_SHIPPING_LOG . " where shipment_id = " . $shipment_id);
         gen_add_audit_log(SHIPPING_FEDEX_LABEL_DELETED, $shipment_id);
         $messageStack->convert_add_to_session();
         // save any messages for reload
     } else {
         $error = true;
     }
     break;
 case 'close':
     $date = $_GET['date'] ? $_GET['date'] : date('Y-m-d', time());
     $shipment = new fedex();
     $shipment->close_date = $_POST['search_date'] ? gen_db_date_short($_POST['search_date']) : date('Y-m-d', time());
     $shipment->closeFedEx($date);
     gen_add_audit_log(SHIPPING_FEDEX_END_OF_DAY, $tracking_id);
     break;
 case 'report':
     $date = $_GET['date'] ? $_GET['date'] : date('Y-m-d');
     break;
 default:
     $oID = db_prepare_input($_GET['oID']);
     $sql = "select shipper_code, ship_primary_name, ship_contact, ship_address1, ship_address2, \r\n\t\tship_city_town, ship_state_province, ship_postal_code, ship_country_code, ship_telephone1, \r\n\t\tship_email, purchase_invoice_id, purch_order_id, total_amount  \r\n\t\tfrom " . TABLE_JOURNAL_MAIN . " where id = " . (int) $oID;
     $result = $db->Execute($sql);
     if (is_array($result->fields)) {
         while (list($key, $value) = each($result->fields)) {
             $sInfo->{$key} = $value;
         }
         $temp = explode(':', $result->fields['shipper_code']);