function pf_process_contacts($strData, $Process)
{
    switch ($Process) {
        case "terms":
            return gen_terms_to_language($strData);
        case "branch":
            return contacts_get_short_name($strData);
        default:
            // Do nothing
    }
    return $strData;
    // No Process recognized, return original value
}
?>
';
var text_search          = '<?php 
echo TEXT_SEARCH;
?>
';
var text_enter_new       = '<?php 
echo TEXT_ENTER_NEW;
?>
';
var text_properties      = '<?php 
echo TEXT_PROPERTIES;
?>
';
var text_terms           = '<?php 
echo gen_terms_to_language('0', true, $account_type == "v" ? 'AP' : 'AR');
?>
';
var text_Please_Select   = '<?php 
echo GEN_HEADING_PLEASE_SELECT;
?>
';
var text_gl_acct         = '<?php 
echo TEXT_GL_ACCOUNT;
?>
';
var text_sales_tax       = '<?php 
echo ORD_TAXABLE;
?>
';
var text_price_manager   = '<?php 
if (ENABLE_MULTI_BRANCH) {
    ?>
            <td align="center"><?php 
    echo html_pull_down_menu('store_id', gen_get_store_ids(), $order->store_id ? $order->store_id : $_SESSION['admin_prefs']['def_store_id']);
    ?>
</td>
		  <?php 
}
?>
          <td align="center"><?php 
echo html_pull_down_menu('rep_id', gen_get_rep_ids($account_type), $order->rep_id ? $order->rep_id : $default_sales_rep);
?>
</td>
<?php 
if ($template_options['terms']) {
    echo '<td align="center">' . html_input_field('terms_text', gen_terms_to_language('0', true, 'ap'), 'readonly="readonly" size="25"') . '&nbsp;' . html_icon('apps/accessories-text-editor.png', ACT_TERMS_DUE, 'small', 'align="top" style="cursor:pointer" onclick="TermsList()"') . '</td>';
}
if ($template_options['terminal_date']) {
    echo '<td align="center">' . html_calendar_field($cal_terminal) . '</td>';
}
?>
          <td align="center">
			<?php 
echo html_pull_down_menu('gl_acct_id', $gl_array_list, $order->gl_acct_id, '');
?>
          </td>
        </tr>
		</tbody>
      </table>
	</td>
  </tr>
</td>
	   <td align="right"><?php 
echo INV_ENTRY_ITEM_TAXABLE;
?>
</td>
       <td><?php 
echo html_pull_down_menu('tax_id', $tax_rates, $cInfo->tax_id);
?>
</td>
       <td><?php 
echo ACT_CATEGORY_PAYMENT_TERMS;
?>
</td>
	   <td><?php 
echo html_hidden_field('terms', $cInfo->special_terms) . chr(10);
echo html_input_field('terms_text', gen_terms_to_language($cInfo->special_terms, true, $cInfo->terms_type), 'readonly="readonly" size="20"') . '&nbsp;' . chr(10);
echo html_icon('apps/accessories-text-editor.png', ACT_TERMS_DUE, 'small', 'style="cursor:pointer" onclick="TermsList()"');
?>
	   </td>
      </tr>
    </table>
  </fieldset>

<?php 
// *********************** Mailing/Main Address (only one allowed) ******************************
?>
  <fieldset>
    <legend><?php 
echo ACT_CATEGORY_M_ADDRESS;
?>
</legend>
function ProcessData($strData, $Process)
{
    global $currencies, $posted_currencies, $rw_xtra_jrnl_defs;
    //echo 'process = ' . $Process . ' and posted cur = '; print_r($posted_currencies); echo '<br />';
    switch ($Process) {
        case "uc":
            return strtoupper_utf8($strData);
        case "lc":
            return strtolower_utf8($strData);
        case "neg":
            return -$strData;
        case "rnd2d":
            if (!is_numeric($strData)) {
                return $strData;
            } else {
                return number_format(round($strData, 2), 2, '.', '');
            }
        case "rnd_dec":
            if (!is_numeric($strData)) {
                return $strData;
            } else {
                return $currencies->format($strData);
            }
        case "rnd_pre":
            if (!is_numeric($strData)) {
                return $strData;
            } else {
                return $currencies->precise($strData);
            }
        case "def_cur":
            if (!is_numeric($strData)) {
                return $strData;
            } else {
                return $currencies->format_full($strData, true, DEFAULT_CURRENCY, 1, 'fpdf');
            }
        case "null_dcur":
            if (!is_numeric($strData)) {
                return $strData;
            } else {
                return !$strData ? '' : $currencies->format_full($strData, true, DEFAULT_CURRENCY, 1, 'fpdf');
            }
        case "posted_cur":
            if (!is_numeric($strData)) {
                return $strData;
            } else {
                return $currencies->format_full($strData, true, $posted_currencies['currencies_code'], $posted_currencies['currencies_value'], 'fpdf');
            }
        case "null_pcur":
            if (!is_numeric($strData)) {
                return $strData;
            } else {
                return !$strData ? '' : $currencies->format_full($strData, true, $posted_currencies['currencies_code'], $posted_currencies['currencies_value'], 'fpdf');
            }
        case "dlr":
            if (!is_numeric($strData)) {
                return $strData;
            } else {
                return '$ ' . number_format(round($strData, 2), 2);
            }
        case "euro":
            if (!is_numeric($strData)) {
                return $strData;
            } else {
                return chr(128) . ' ' . number_format(round($strData, 2), 2);
            }
            // assumes standard FPDF fonts
        // assumes standard FPDF fonts
        case "n2wrd":
            return value_to_words_en_us($strData);
            // for checks primarily
        // for checks primarily
        case "terms":
            return gen_terms_to_language($strData, $short = true, $type = 'ar');
        case "date":
            return gen_spiffycal_db_date_short($strData);
        case "null-dlr":
            return !$strData ? '' : '$ ' . number_format($strData, 2);
        case "ordr_qty":
            return pull_order_qty($strData);
        case "branch":
            return rw_get_branch_name($strData);
        case "rep_id":
            return rw_get_user_name($strData);
        case "ship_name":
            return rw_get_ship_name($strData);
        case 'j_desc':
            return isset($rw_xtra_jrnl_defs[$strData]) ? $rw_xtra_jrnl_defs[$strData] : $strData;
        case 'yesBno':
            return $strData ? TEXT_YES : '';
        case 'printed':
            return $strData ? '' : TEXT_DUPLICATE;
    }
    $processed_value = false;
    if (function_exists('rw_extra_processing')) {
        $processed_value = rw_extra_processing($strData, $Process);
    }
    return $processed_value === false ? $strData : $processed_value;
    // do nothing if Process not recognized
}
Beispiel #6
0
    }
    // clear the rep field if not set to a contact
}
// Now fill the order, if it is requested
if (sizeof($order->fields) > 0) {
    // correct check boxes since changing the values will not affect the check status but change the value behind it
    $order->fields['cb_closed'] = $order->fields['closed'] == '1' ? 1 : 0;
    $order->fields['cb_waiting'] = $order->fields['waiting'] == '1' ? 1 : 0;
    $order->fields['cb_drop_ship'] = $order->fields['drop_ship'] == '1' ? 1 : 0;
    unset($order->fields['closed']);
    unset($order->fields['waiting']);
    unset($order->fields['drop_ship']);
    // some adjustments based on what we are doing
    $order->fields['search'] = $contact->fields['short_name'];
    $order->fields['post_date'] = gen_locale_date($order->fields['post_date']);
    $order->fields['terms_text'] = gen_terms_to_language($order->fields['terms'], true, $terms_type);
    $order->fields['disc_percent'] = '0';
    if ($order->fields['terminal_date'] == '000-00-00' || $order->fields['terminal_date'] == '') {
        unset($order->fields['terminal_date']);
    } else {
        $order->fields['terminal_date'] = gen_locale_date($order->fields['terminal_date']);
    }
    if (!$order->fields['rep_id']) {
        unset($order->fields['rep_id']);
    }
    $ship_level = explode(':', $order->fields['shipper_code']);
    $order->fields['ship_carrier'] = $ship_level[0];
    $order->fields['ship_service'] = $ship_level[1];
    $order->fields['attach_exist'] = file_exists(PHREEBOOKS_DIR_MY_ORDERS . 'order_' . $oID . '.zip') ? 1 : 0;
    if ($so_po) {
        // opening a SO/PO for Invoice/Receive
    case 9:
        $req_date = date(DATE_FORMAT, time());
        $template_options['terminal_date'] = array('title' => constant('ORD_TEXT_' . JOURNAL_ID . '_EXPIRES'), 'field' => '<script type="text/javascript">dateRequired.writeControl(); dateRequired.displayLeft=true; dateRequired.dateFormat="' . DATE_FORMAT_SPIFFYCAL . '";</script>');
        $template_options['terms'] = array('title' => ACT_TERMS_DUE, 'field' => html_input_field('terms_text', gen_terms_to_language('0', true, 'ap'), 'readonly="readonly" size="25"') . '&nbsp;' . html_icon('apps/accessories-text-editor.png', ACT_TERMS_DUE, 'small', 'align="top" style="cursor:pointer" onclick="TermsList()"'));
        $template_options['closed'] = array('title' => TEXT_CLOSE, 'field' => html_checkbox_field('closed', '1', $order->closed ? true : false, '', ''));
        break;
    case 10:
        $req_date = date(DATE_FORMAT, time());
        $template_options['terminal_date'] = array('title' => constant('ORD_TEXT_' . JOURNAL_ID . '_EXPIRES'), 'field' => '<script type="text/javascript">dateRequired.writeControl(); dateRequired.displayLeft=true; dateRequired.dateFormat="' . DATE_FORMAT_SPIFFYCAL . '";</script>');
        $template_options['terms'] = array('title' => ACT_TERMS_DUE, 'field' => html_input_field('terms_text', gen_terms_to_language('0', true, 'ap'), 'readonly="readonly" size="25"') . '&nbsp;' . html_icon('apps/accessories-text-editor.png', ACT_TERMS_DUE, 'small', 'align="top" style="cursor:pointer" onclick="TermsList()"'));
        $template_options['closed'] = array('title' => TEXT_CLOSE, 'field' => html_checkbox_field('closed', '1', $order->closed ? true : false, '', ''));
        break;
    case 12:
        $req_date = date(DATE_FORMAT, time());
        $template_options['terminal_date'] = array('title' => constant('ORD_TEXT_' . JOURNAL_ID . '_EXPIRES'), 'field' => '<script type="text/javascript">dateRequired.writeControl(); dateRequired.displayLeft=true; dateRequired.dateFormat="' . DATE_FORMAT_SPIFFYCAL . '";</script>');
        $template_options['terms'] = array('title' => ACT_TERMS_DUE, 'field' => html_input_field('terms_text', gen_terms_to_language('0', true, 'ap'), 'readonly="readonly" size="25"') . '&nbsp;' . html_icon('apps/accessories-text-editor.png', ACT_TERMS_DUE, 'small', 'align="top" style="cursor:pointer" onclick="TermsList()"'));
        break;
    case 13:
    case 19:
    case 21:
        $req_date = date(DATE_FORMAT, time());
        break;
    default:
}
$include_header = true;
$include_footer = true;
$include_tabs = false;
$include_calendar = true;
$include_template = 'template_main.php';
// include display template (required)
define('PAGE_TITLE', constant('ORD_TEXT_' . JOURNAL_ID . '_WINDOW_TITLE'));
Beispiel #8
0
// +-----------------------------------------------------------------+
//  Path: /modules/contacts/ajax/load_contact.php
//
/**************   Check user security   *****************************/
$xml = NULL;
$security_level = validate_ajax_user();
/**************  include page specific files    *********************/
gen_pull_language('contacts');
/**************   page specific initialization  *************************/
$cID = db_prepare_input($_GET['cID']);
$error = false;
// select the customer and build the contact record
$contact = $db->Execute("select * from " . TABLE_CONTACTS . " where id = '" . $cID . "'");
$type = $contact->fields['type'];
$terms_type = $type == 'c' ? 'AR' : 'AP';
$contact->fields['terms_text'] = gen_terms_to_language($contact->fields['special_terms'], true, $terms_type);
$contact->fields['ship_gl_acct_id'] = $type == 'v' ? AP_DEF_FREIGHT_ACCT : AR_DEF_FREIGHT_ACCT;
$bill_add = $db->Execute("select * from " . TABLE_ADDRESS_BOOK . " \n  where ref_id = '" . $cID . "' and type in ('" . $type . "m', '" . $type . "b')");
//fix some special fields
if (!$contact->fields['dept_rep_id']) {
    unset($contact->fields['dept_rep_id']);
}
// clear the rep field if not set to a contact
$ship_add = $db->Execute("select * from " . TABLE_ADDRESS_BOOK . " \n  where ref_id = '" . $cID . "' and type in ('" . $type . "m', '" . $type . "s')");
// build the form data
if ($contact->fields) {
    $xml .= "\t<Contact>\n";
    foreach ($contact->fields as $key => $value) {
        $xml .= "\t" . xmlEntry($key, $value);
    }
    $xml .= "\t</Contact>\n";
echo html_radio_field('special_terms', 3, $terms[0] == '3' ? true : false, '', 'onclick="changeOptions()"') . ACT_SPECIAL_TERMS . '<br />' . chr(10);
echo html_radio_field('special_terms', 4, $terms[0] == '4' ? true : false, '', 'onclick="changeOptions()"') . ACT_DAY_NEXT_MONTH . '<br />' . chr(10);
echo html_radio_field('special_terms', 5, $terms[0] == '5' ? true : false, '', 'onclick="changeOptions()"') . ACT_END_OF_MONTH . chr(10);
?>
		</td>
		<td class="main" valign="top">
<?php 
// terms[3] may contain either the net days or a date, set the defaults
if ($terms[0] == '4' || $terms[0] == '5') {
    $net_terms = constant($terms_type . '_NUM_DAYS_DUE');
    $date_terms = $terms[3];
} else {
    $net_terms = $terms[3] != '' ? $terms[3] : constant($terms_type . '_NUM_DAYS_DUE');
    $date_terms = '';
}
echo TEXT_CURRENT . ' - ' . gen_terms_to_language($cInfo->special_terms, false, $terms_type) . '<br />' . chr(10);
echo ACT_DISCOUNT . html_input_field('early_percent', $terms[1] != '' ? $terms[1] : constant($terms_type . '_PREPAYMENT_DISCOUNT_PERCENT'), 'size="4"') . ACT_EARLY_DISCOUNT . '<br />' . chr(10);
echo ACT_DUE_IN . html_input_field('early_days', $terms[2] != '' ? $terms[2] : constant($terms_type . '_PREPAYMENT_DISCOUNT_DAYS'), 'size="3"') . ACT_TERMS_EARLY_DAYS . '<br />' . chr(10);
echo ACT_TERMS_NET . html_input_field('standard_days', $net_terms, 'size="3"') . ACT_TERMS_STANDARD_DAYS . '<br />' . chr(10);
?>
<script type="text/javascript">
	dateReference.writeControl(); dateReference.dateFormat="<?php 
echo DATE_FORMAT_SPIFFYCAL;
?>
";
</script>
<?php 
if ($terms[0] == '4' || $terms[0] == '5') {
    echo '<script type="text/javascript">';
    echo "document.accounts.elements['due_date'].value = '" . $date_terms . "';";
    echo '</script>';
Beispiel #10
0
    case 'v':
        $toolbar->add_help('07.02.02.04');
        break;
}
echo $toolbar->build_toolbar();
// Build the page
?>
<h1><?php 
echo ACT_POPUP_TERMS_WINDOW_TITLE;
?>
</h1>
<table class="ui-widget" style="border-collapse:collapse;width:100%">
 <tbody class="ui-widget-content">
  <tr>
	<td colspan="2"><?php 
echo ACT_TERMS_DEFAULT . ' ' . gen_terms_to_language('0', false, $terms_type) . '<br />' . chr(10);
?>
</td>
  </tr>
  <tr>
	<td>
<?php 
if ($_GET['val']) {
    $terms = explode(':', $_GET['val']);
} else {
    $terms = array('0' => 0);
}
//echo 'terms='; print_r($terms); echo '<br />';
echo html_radio_field('special_terms', 0, $terms[0] == '0' ? true : false, '', 'onclick="changeOptions()"') . ACT_TERMS_USE_DEFAULTS . '<br />' . chr(10);
echo html_radio_field('special_terms', 1, $terms[0] == '1' ? true : false, '', 'onclick="changeOptions()"') . ACT_COD_SHORT . '<br />' . chr(10);
echo html_radio_field('special_terms', 2, $terms[0] == '2' ? true : false, '', 'onclick="changeOptions()"') . ACT_PREPAID . '<br />' . chr(10);
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 . 'accounts/language/' . $_SESSION['language'] . '/language.php';
/**************   page specific initialization  *************************/
$id = (int) $_GET['id'];
/***************   Act on the action request   *************************/
// Load the customer status
$customer = $db->Execute("select c.type, c.inactive, c.special_terms, a.notes \r\n  from " . TABLE_CONTACTS . " c inner join " . TABLE_ADDRESS_BOOK . " a on c.id = a.ref_id \r\n  where c.id = " . $id . " and a.type like '%m'");
$notes = str_replace(chr(10), "<br />", $customer->fields['notes']);
$type = $customer->fields['type'] == 'v' ? 'AP' : 'AR';
$special_terms = gen_terms_to_language($customer->fields['special_terms'], $short = false, $type);
$terms = explode(':', $customer->fields['special_terms']);
$credit_limit = $terms[4] ? $terms[4] : constant($type . '_CREDIT_LIMIT_AMOUNT');
$due_days = $terms[3] ? $terms[3] : constant($type . '_NUM_DAYS_DUE');
$due_date = gen_specific_date($today, -$due_days);
// load the aged status
$today = date('Y-m-d');
$late_30 = gen_specific_date($today, $type == 'AP' ? -AP_AGING_DATE_1 : -AR_AGING_PERIOD_1);
$late_60 = gen_specific_date($today, $type == 'AP' ? -AP_AGING_DATE_2 : -AR_AGING_PERIOD_2);
$late_90 = gen_specific_date($today, $type == 'AP' ? -AP_AGING_DATE_3 : -AR_AGING_PERIOD_3);
$new_data = array('balance_0' => '0', 'balance_30' => '0', 'balance_60' => '0', 'balance_90' => '0');
$inv_jid = $type == 'AP' ? '6, 7' : '12, 13';
$pmt_jid = $type == 'AP' ? '20' : '18';
$total_outstanding = 0;
$past_due = 0;
$sql = "select id from " . TABLE_JOURNAL_MAIN . " \r\n\twhere bill_acct_id = " . $id . " and journal_id in (" . $inv_jid . ") and closed = '0'";
Beispiel #12
0
function calculate_aging($id, $type = 'c', $special_terms = '0')
{
    global $db;
    $output = array();
    if (!$id) {
        return $output;
    }
    $today = date('Y-m-d');
    $terms = explode(':', $special_terms);
    $credit_limit = $terms[4] ? $terms[4] : constant(($type == 'v' ? 'AP' : 'AR') . '_CREDIT_LIMIT_AMOUNT');
    $due_days = $terms[3] ? $terms[3] : constant(($type == 'v' ? 'AP' : 'AR') . '_NUM_DAYS_DUE');
    $due_date = gen_specific_date($today, -$due_days);
    $late_30 = gen_specific_date($today, $type == 'v' ? -AP_AGING_DATE_1 : -AR_AGING_PERIOD_1);
    $late_60 = gen_specific_date($today, $type == 'v' ? -AP_AGING_DATE_2 : -AR_AGING_PERIOD_2);
    $late_90 = gen_specific_date($today, $type == 'v' ? -AP_AGING_DATE_3 : -AR_AGING_PERIOD_3);
    $output = array('balance_0' => '0', 'balance_30' => '0', 'balance_60' => '0', 'balance_90' => '0');
    $inv_jid = $type == 'v' ? '6, 7' : '12, 13';
    $pmt_jid = $type == 'v' ? '20' : '18';
    $total_outstanding = 0;
    $past_due = 0;
    $sql = "select id from " . TABLE_JOURNAL_MAIN . " \n\t\twhere bill_acct_id = " . $id . " and journal_id in (" . $inv_jid . ") and closed = '0'";
    $open_inv = $db->Execute($sql);
    while (!$open_inv->EOF) {
        $result = $db->Execute("select debit_amount, credit_amount from " . TABLE_JOURNAL_ITEM . " where gl_type = 'ttl' and ref_id = " . $open_inv->fields['id']);
        $result2 = $db->Execute("select journal_id, post_date from " . TABLE_JOURNAL_MAIN . " where id = " . $open_inv->fields['id']);
        $total_billed = $result->fields['debit_amount'] - $result->fields['credit_amount'];
        $post_date = $result2->fields['post_date'];
        $result = $db->Execute("select sum(debit_amount) as debits, sum(credit_amount) as credits \n\t    from " . TABLE_JOURNAL_ITEM . " where so_po_item_ref_id = '" . $open_inv->fields['id'] . "' and gl_type in ('pmt', 'chk')");
        $total_paid = $result->fields['credits'] - $result->fields['debits'];
        $balance = $total_billed - $total_paid;
        if ($type == 'v') {
            $balance = -$balance;
        }
        // start the placement in aging array
        if ($post_date < $due_date) {
            $past_due += $balance;
        }
        if ($post_date < $late_90) {
            $output['balance_90'] += $balance;
            $total_outstanding += $balance;
        } elseif ($post_date < $late_60) {
            $output['balance_60'] += $balance;
            $total_outstanding += $balance;
        } elseif ($post_date < $late_30) {
            $output['balance_30'] += $balance;
            $total_outstanding += $balance;
        } elseif ($post_date <= $today) {
            $output['balance_0'] += $balance;
            $total_outstanding += $balance;
        }
        // else it's in the future
        $open_inv->MoveNext();
    }
    $output['total'] = $total_outstanding;
    $output['past_due'] = $past_due;
    $output['credit_limit'] = $credit_limit;
    $output['terms_lang'] = gen_terms_to_language($special_terms, false, $type == 'v' ? 'AP' : 'AR');
    return $output;
}