Example #1
0
 function __construct()
 {
     $taxes = ord_calculate_tax_drop_down('c');
     foreach ($taxes as $rate) {
         $this->taxes[$rate['id']] = $rate['rate'] / 100;
     }
 }
Example #2
0
 function __construct()
 {
     $this->discount = 0;
     $taxes = ord_calculate_tax_drop_down('c');
     $this->taxes = array();
     foreach ($taxes as $rate) {
         $this->taxes[$rate['id']] = $rate['rate'] / 100;
     }
     $this->tax_rates = array();
     foreach ($taxes as $rate) {
         $this->tax_rates[$rate['id']] = $rate['rate'] . '%';
     }
 }
Example #3
0
 function formatArray()
 {
     global $db;
     // build the tax table to set the tax rates
     $tax_rates = ord_calculate_tax_drop_down('c');
     $this->order = array();
     // Here we map the received xml array to the pre-defined generic structure (application specific format later)
     // <OrderRequest>
     $this->order['function'] = $this->getNodeData(array('ACCESSREQUEST', 'ACCESSFUNCTION'), $this->arrOutput);
     $this->order['action'] = $this->getNodeData(array('ACCESSREQUEST', 'SALESORDERENTRY', 'ORDERREQUEST', 'REQUESTACTION'), $this->arrOutput);
     $this->order['reference_name'] = $this->getNodeData(array('ACCESSREQUEST', 'SALESORDERENTRY', 'ORDERREQUEST', 'REFERENCENAME'), $this->arrOutput);
     // <Originator>
     $this->order['store_id'] = $this->getNodeData(array('ACCESSREQUEST', 'SALESORDERENTRY', 'ORDERREQUEST', 'ORIGINATOR', 'STOREID'), $this->arrOutput);
     $this->order['sales_gl_account'] = $this->getNodeData(array('ACCESSREQUEST', 'SALESORDERENTRY', 'ORDERREQUEST', 'ORIGINATOR', 'SALESGLACCOUNT'), $this->arrOutput);
     $this->order['receivables_gl_acct'] = $this->getNodeData(array('ACCESSREQUEST', 'SALESORDERENTRY', 'ORDERREQUEST', 'ORIGINATOR', 'RECEIVABLESGLACCOUNT'), $this->arrOutput);
     // <OrderSummary>
     $this->order['order_id'] = $this->getNodeData(array('ACCESSREQUEST', 'SALESORDERENTRY', 'SALESORDER', 'ORDERSUMMARY', 'SALESORDERID'), $this->arrOutput);
     $this->order['purch_order_id'] = $this->getNodeData(array('ACCESSREQUEST', 'SALESORDERENTRY', 'SALESORDER', 'ORDERSUMMARY', 'PURCHASEORDERID'), $this->arrOutput);
     $this->order['post_date'] = $this->getNodeData(array('ACCESSREQUEST', 'SALESORDERENTRY', 'SALESORDER', 'ORDERSUMMARY', 'SALESORDERDATE'), $this->arrOutput);
     $this->order['order_total'] = $this->getNodeData(array('ACCESSREQUEST', 'SALESORDERENTRY', 'SALESORDER', 'ORDERSUMMARY', 'ORDERTOTAL'), $this->arrOutput);
     $this->order['tax_total'] = $this->getNodeData(array('ACCESSREQUEST', 'SALESORDERENTRY', 'SALESORDER', 'ORDERSUMMARY', 'TAXTOTAL'), $this->arrOutput);
     $this->order['freight_total'] = $this->getNodeData(array('ACCESSREQUEST', 'SALESORDERENTRY', 'SALESORDER', 'ORDERSUMMARY', 'SHIPPINGTOTAL'), $this->arrOutput);
     $this->order['freight_carrier'] = $this->getNodeData(array('ACCESSREQUEST', 'SALESORDERENTRY', 'SALESORDER', 'ORDERSUMMARY', 'SHIPPINGCARRIER'), $this->arrOutput);
     $this->order['freight_method'] = $this->getNodeData(array('ACCESSREQUEST', 'SALESORDERENTRY', 'SALESORDER', 'ORDERSUMMARY', 'SHIPPINGMETHOD'), $this->arrOutput);
     $this->order['discount_total'] = $this->getNodeData(array('ACCESSREQUEST', 'SALESORDERENTRY', 'SALESORDER', 'ORDERSUMMARY', 'DISCOUNTTOTAL'), $this->arrOutput);
     // <Payment>
     $this->order['payment']['holder_name'] = $this->getNodeData(array('ACCESSREQUEST', 'SALESORDERENTRY', 'SALESORDER', 'PAYMENT', 'CARDHOLDERNAME'), $this->arrOutput);
     $this->order['payment']['method'] = $this->getNodeData(array('ACCESSREQUEST', 'SALESORDERENTRY', 'SALESORDER', 'PAYMENT', 'METHOD'), $this->arrOutput);
     $this->order['payment']['type'] = $this->getNodeData(array('ACCESSREQUEST', 'SALESORDERENTRY', 'SALESORDER', 'PAYMENT', 'TYPE'), $this->arrOutput);
     $this->order['payment']['card_number'] = $this->getNodeData(array('ACCESSREQUEST', 'SALESORDERENTRY', 'SALESORDER', 'PAYMENT', 'CARDNUMBER'), $this->arrOutput);
     $this->order['payment']['exp_date'] = $this->getNodeData(array('ACCESSREQUEST', 'SALESORDERENTRY', 'SALESORDER', 'PAYMENT', 'EXPIRATIONDATE'), $this->arrOutput);
     $this->order['payment']['cvv2'] = $this->getNodeData(array('ACCESSREQUEST', 'SALESORDERENTRY', 'SALESORDER', 'PAYMENT', 'CVV2NUMBER'), $this->arrOutput);
     // Begin - additional operations added by PhreeSoft for PPS
     $this->order['payment']['hint'] = $this->getNodeData(array('ACCESSREQUEST', 'SALESORDERENTRY', 'SALESORDER', 'PAYMENT', 'HINT'), $this->arrOutput);
     $temp = $this->getNodeData(array('ACCESSREQUEST', 'SALESORDERENTRY', 'SALESORDER', 'PAYMENT', 'ENCVAL'), $this->arrOutput);
     $this->order['payment']['encval'] = base64_decode(strtr($temp, '-_,', '+/='));
     // End - additional operations added by PhreeSoft for PPS
     // <Customer> and <Billing> and <Shipping>
     $types = array('customer', 'billing', 'shipping');
     foreach ($types as $value) {
         $this->order[$value]['primary_name'] = $this->getNodeData(array('ACCESSREQUEST', 'SALESORDERENTRY', 'SALESORDER', strtoupper($value), 'COMPANYNAME'), $this->arrOutput);
         $this->order[$value]['contact'] = $this->getNodeData(array('ACCESSREQUEST', 'SALESORDERENTRY', 'SALESORDER', strtoupper($value), 'CONTACT'), $this->arrOutput);
         $this->order[$value]['address1'] = $this->getNodeData(array('ACCESSREQUEST', 'SALESORDERENTRY', 'SALESORDER', strtoupper($value), 'ADDRESS1'), $this->arrOutput);
         $this->order[$value]['address2'] = $this->getNodeData(array('ACCESSREQUEST', 'SALESORDERENTRY', 'SALESORDER', strtoupper($value), 'ADDRESS2'), $this->arrOutput);
         $this->order[$value]['city_town'] = $this->getNodeData(array('ACCESSREQUEST', 'SALESORDERENTRY', 'SALESORDER', strtoupper($value), 'CITYTOWN'), $this->arrOutput);
         $this->order[$value]['state_province'] = $this->getNodeData(array('ACCESSREQUEST', 'SALESORDERENTRY', 'SALESORDER', strtoupper($value), 'STATEPROVINCE'), $this->arrOutput);
         $this->order[$value]['postal_code'] = $this->getNodeData(array('ACCESSREQUEST', 'SALESORDERENTRY', 'SALESORDER', strtoupper($value), 'POSTALCODE'), $this->arrOutput);
         $this->order[$value]['country_code'] = $this->getNodeData(array('ACCESSREQUEST', 'SALESORDERENTRY', 'SALESORDER', strtoupper($value), 'COUNTRYCODE'), $this->arrOutput);
         $this->order[$value]['telephone'] = $this->getNodeData(array('ACCESSREQUEST', 'SALESORDERENTRY', 'SALESORDER', strtoupper($value), 'TELEPHONE'), $this->arrOutput);
         $this->order[$value]['email'] = $this->getNodeData(array('ACCESSREQUEST', 'SALESORDERENTRY', 'SALESORDER', strtoupper($value), 'EMAIL'), $this->arrOutput);
         if ($value == 'customer') {
             // additional information for the customer record
             $this->order[$value]['customer_id'] = $this->getNodeData(array('ACCESSREQUEST', 'SALESORDERENTRY', 'SALESORDER', strtoupper($value), 'CUSTOMERID'), $this->arrOutput);
         }
     }
     // <LineItems>
     $itemArray = $this->getSubArray('LINEITEMS', $this->arrOutput);
     $tempArray = array();
     $this->order['items'] = array();
     for ($i = 0; $i < count($itemArray); $i++) {
         $tempArray[0] = $itemArray[$i];
         // set to a single line item
         $item = array();
         $sku = $this->getNodeData(array('LINEITEMDETAILS', 'ITEMID'), $tempArray);
         // try to match sku and get the sales gl account
         $result = $db->Execute("select account_sales_income from " . TABLE_INVENTORY . " where sku = '" . $sku . "'");
         if ($result->RecordCount() > 0) {
             $item['sku'] = $sku;
             $item['gl_acct'] = $result->fields['account_sales_income'];
         } else {
             $result = $db->Execute("select sku, account_sales_income from " . TABLE_INVENTORY . " where description_short = '" . $sku . "'");
             $item['sku'] = $result->fields['sku'];
             $item['gl_acct'] = $result->fields['account_sales_income'];
         }
         $item['description'] = $this->getNodeData(array('LINEITEMDETAILS', 'DESCRIPTION'), $tempArray);
         $item['quantity'] = $this->getNodeData(array('LINEITEMDETAILS', 'QUANTITY'), $tempArray);
         $item['unit_price'] = $this->getNodeData(array('LINEITEMDETAILS', 'UNITPRICE'), $tempArray);
         $item['tax_percent'] = $this->getNodeData(array('LINEITEMDETAILS', 'SALESTAXPERCENT'), $tempArray);
         //			$item['sales_tax']   = $this->getNodeData(array('LINEITEMDETAILS','SALESTAX'), $tempArray);
         $item['taxable'] = $this->guess_tax_id($tax_rates, $item['tax_percent']);
         $item['total_price'] = $this->getNodeData(array('LINEITEMDETAILS', 'TOTALPRICE'), $tempArray);
         $this->order['items'][] = $item;
     }
     return true;
 }
Example #4
0
 function add_tax_journal_rows()
 {
     global $currencies;
     $total = 0;
     $auth_array = array();
     $tax_rates = ord_calculate_tax_drop_down('b');
     $tax_auths = gen_build_tax_auth_array();
     $tax_discount = $this->account_type == 'v' ? AP_TAX_BEFORE_DISCOUNT : AR_TAX_BEFORE_DISCOUNT;
     // calculate each tax value by authority per line item
     foreach ($this->journal_rows as $idx => $line_item) {
         if ($line_item['taxable'] > 0 && ($line_item['gl_type'] == $this->gl_type || $line_item['gl_type'] == 'frt')) {
             foreach ($tax_rates as $rate) {
                 if ($rate['id'] == $line_item['taxable']) {
                     $auths = explode(':', $rate['auths']);
                     foreach ($auths as $auth) {
                         $line_total = $line_item['debit_amount'] + $line_item['credit_amount'];
                         // one will always be zero
                         if (ENABLE_ORDER_DISCOUNT && $tax_discount == '0') {
                             $line_total = $line_total * (1 - $this->disc_percent);
                         }
                         $auth_array[$auth] += $tax_auths[$auth]['tax_rate'] / 100 * $line_total;
                     }
                 }
             }
         }
     }
     // calculate each tax total by authority and put into journal row array
     foreach ($auth_array as $auth => $auth_tax_collected) {
         if ($auth_tax_collected == '' && $tax_auths[$auth]['account_id'] == '') {
             continue;
         }
         if (ROUND_TAX_BY_AUTH == true) {
             $amount = number_format($auth_tax_collected, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places'], '.', '');
         } else {
             $amount = $auth_tax_collected;
         }
         $this->journal_rows[] = array('qty' => '1', 'gl_type' => 'tax', 'debit_amount' => $amount, 'description' => $tax_auths[$auth]['description_short'], 'gl_account' => $tax_auths[$auth]['account_id'], 'post_date' => $this->post_date);
         $total += $amount;
     }
     return $total;
 }
        }
        break;
    default:
}
/*****************   prepare to display templates  *************************/
// generate address arrays for javascript
$js_arrays = gen_build_acct_arrays();
// 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);
for ($i = 0; $i < count($gl_array_list); $i++) {
    $js_gl_array .= 'js_gl_array[' . $i . '] = new dropDownData("' . $gl_array_list[$i]['id'] . '", "' . $gl_array_list[$i]['text'] . '");' . chr(10);
}
// load the tax rates
$tax_rates = ord_calculate_tax_drop_down($account_type);
// generate a rate array parallel to the drop down for the javascript total calculator
$js_tax_rates = 'var tax_rates = new Array(' . count($tax_rates) . ');' . chr(10);
for ($i = 0; $i < count($tax_rates); $i++) {
    $js_tax_rates .= 'tax_rates[' . $i . '] = new salesTaxes("' . $tax_rates[$i]['id'] . '", "' . $tax_rates[$i]['text'] . '", "' . $tax_rates[$i]['rate'] . '");' . chr(10);
}
// load projects
$proj_list = ord_get_projects();
// generate a project list array parallel to the drop down for the javascript add line item function
$js_proj_list = 'var proj_list = new Array(' . count($proj_list) . ');' . chr(10);
for ($i = 0; $i < count($proj_list); $i++) {
    $js_proj_list .= 'proj_list[' . $i . '] = new dropDownData("' . $proj_list[$i]['id'] . '", "' . $proj_list[$i]['text'] . '");' . chr(10);
}
// Load shipping methods
$shipping_methods = ord_get_shipping_methods();
// see if current user points to a employee for sales rep default
Example #6
0
    $db->Execute("ALTER TABLE " . TABLE_USERS . " ADD inactive ENUM('0','1') NOT NULL DEFAULT '0' AFTER admin_name");
}
if (!defined('INVENTORY_AUTO_ADD')) {
    $db->Execute("ALTER TABLE " . TABLE_INVENTORY . " CHANGE `item_taxable` `item_taxable` INT( 11 ) NOT NULL DEFAULT '0'");
    $db->Execute("ALTER TABLE " . TABLE_JOURNAL_ITEM . " CHANGE `taxable` `taxable` INT( 11 ) NOT NULL DEFAULT '0'");
    $db->Execute("UPDATE " . TABLE_CONFIGURATION . " SET `set_function` = 'cfg_pull_down_tax_rate_list(' WHERE `configuration_key` = 'AP_ADD_SALES_TAX_TO_SHIPPING' LIMIT 1");
    $db->Execute("UPDATE " . TABLE_CONFIGURATION . " SET `set_function` = 'cfg_pull_down_tax_rate_list(' WHERE `configuration_key` = 'AR_ADD_SALES_TAX_TO_SHIPPING' LIMIT 1");
    if (!defined('INVENTORY_DEFAULT_TAX_ID')) {
        $result = $db->Execute("select tax_rate_id from " . TABLE_TAX_RATES . " order by tax_rate_id limit 1");
        define('INVENTORY_DEFAULT_TAX_ID', $result->fields['tax_rate_id']);
    }
    $db->Execute("update " . TABLE_INVENTORY . " set item_taxable = '" . INVENTORY_DEFAULT_TAX_ID . "' where item_taxable = '2'");
    $db->Execute("INSERT INTO " . TABLE_CONFIGURATION . " \r\n           ( `configuration_title` , `configuration_key` , `configuration_value` , `configuration_description` , `configuration_group_id` , `sort_order` , `last_modified` , `date_added` , `use_function` , `set_function` ) \r\n    VALUES ( 'Enable Automatic Creation of Inventory Items', 'INVENTORY_AUTO_ADD', '0', 'Allows the automatic creation of inventory items in the order screens.<br /><br /> SKUs are not required in PhreeBooks for non-trackable inventory types. This feature allows for the automatic creation of SKUs in the inventory database table. The inventory type used will be stock for inventory type GL accounts and non-stock for all other type accounts. The GL account used to determine the type is the account selected with the line item in the order screen.', '5', '55', NULL , now(), NULL , 'cfg_keyed_select_option(array(0 =>\\'No\\', 1=>\\'Yes\\'),' ),\r\n           ( 'Default Tax Rate For New Inventory Items', 'INVENTORY_DEFAULT_TAX', '" . INVENTORY_DEFAULT_TAX_ID . "', 'Determines the default tax rate to use when adding inventory items.<br /><br />NOTE: This value is applied to inventory Auto-Add but can be changed in the Inventory => Maintain screen. The tax rates are selected from the table tax_rates and must be setup through Setup => Sales tax Rates.', '5', '50', NULL , now(), NULL , 'cfg_pull_down_tax_rate_list(' );");
    require DIR_FS_MODULES . 'orders/functions/orders.php';
    // load the tax_rates id and rate
    $tax_rates = ord_calculate_tax_drop_down();
    // set non-taxable to no tax id (enum '0' turns to 1 when changing field type to integer)
    $db->Execute("update " . TABLE_JOURNAL_ITEM . " set taxable = 0 where taxable = 1");
    $result = $db->Execute("select id from " . TABLE_JOURNAL_MAIN . " where tax_auths = '0'");
    $clean_array = array();
    while (!$result->EOF) {
        $clean_array[] = $result->fields['id'];
        $result->MoveNext();
    }
    $db->Execute("update " . TABLE_JOURNAL_ITEM . " set taxable = 0 where ref_id in (" . implode(',', $clean_array) . ")");
    $result = $db->Execute("select distinct tax_auths from " . TABLE_JOURNAL_MAIN);
    while (!$result->EOF) {
        $rate_id = 0;
        foreach ($tax_rates as $key => $value) {
            // insert the rate id if it exists
            if ($tax_rates[$key]['auths'] == $result->fields['tax_auths']) {
Example #7
0
 function processOrder()
 {
     global $db, $messageStack;
     define('JOURNAL_ID', 10);
     // make them all sales orders for now
     define('GL_TYPE', 'soo');
     $this->msgDebug("\njournal_id = " . JOURNAL_ID . " and function = " . $this->function);
     $tax_rates = ord_calculate_tax_drop_down('c');
     $order = json_decode($_POST['Order'], true);
     // Here we map the received xml array to the pre-defined generic structure (application specific format later)
     if ($order['ReceivablesGLAccount'] != '') {
         // see if requestor specifies a AR account else use default
         define('DEF_GL_ACCT', $order['ReceivablesGLAccount']);
     } else {
         define('DEF_GL_ACCT', AR_DEFAULT_GL_ACCT);
     }
     $this->order = array('order_id' => $order['General']['OrderID'], 'purch_order_id' => $order['General']['PurchaseOrderID'], 'post_date' => $order['General']['OrderDate'], 'order_total' => $order['General']['OrderTotal'], 'tax_total' => $order['General']['TaxTotal'], 'freight_total' => $order['General']['ShippingTotal'], 'freight_carrier' => $order['General']['ShippingCarrier'], 'freight_method' => $order['General']['ShippingMethod'], 'rep_id' => $order['General']['SalesRepID'], 'payment' => array('holder_name' => $order['Payment']['CardHolderName'], 'method' => $order['Payment']['Method'], 'type' => $order['Payment']['CardType'], 'card_number' => $order['Payment']['CardNumber'], 'exp_date' => $order['Payment']['ExpirationDate'], 'cvv2' => $order['Payment']['CVV2Number']));
     // Billing and Shipping
     $types = array('billing' => 'Billing', 'shipping' => 'Shipping');
     foreach ($types as $key => $entry) {
         $this->order[$key] = array('primary_name' => $order[$entry]['CompanyName'], 'contact' => $order[$entry]['Contact'], 'address1' => $order[$entry]['Address1'], 'address2' => $order[$entry]['Address2'], 'city_town' => $order[$entry]['City'], 'state_province' => $order[$entry]['State'], 'postal_code' => $order[$entry]['PostalCode'], 'country_code' => $order[$entry]['Country'], 'telephone' => $order[$entry]['Telephone'], 'email' => $order[$entry]['Email']);
         if ($key == 'billing') {
             // additional information for the customer record
             $this->order[$key]['customer_id'] = $order[$entry]['CustomerID'];
         }
     }
     // if billing or shipping is blank, use customer address
     if ($this->order['billing']['primary_name'] == '' && $this->order['billing']['contact'] == '') {
         $this->order['billing'] = $this->order['customer'];
     }
     if ($this->order['shipping']['primary_name'] == '' && $this->order['shipping']['contact'] == '') {
         $this->order['shipping'] = $this->order['customer'];
     }
     // <LineItems>
     $this->order['items'] = array();
     foreach ($order['Item'] as $entry) {
         $item = array();
         $sku = $entry['ItemID'];
         // try to match sku and get the sales gl account
         $result = $db->Execute("SELECT account_sales_income FROM " . TABLE_INVENTORY . " WHERE sku='{$sku}'");
         if ($result->RecordCount() > 0) {
             $item['sku'] = $sku;
             $item['gl_acct'] = $result->fields['account_sales_income'];
         } else {
             $result = $db->Execute("SELECT sku, account_sales_income FROM " . TABLE_INVENTORY . " WHERE description_short='{$sku}'");
             $item['sku'] = $result->fields['sku'];
             $item['gl_acct'] = $result->fields['account_sales_income'];
         }
         $item['description'] = $entry['Description'];
         $item['quantity'] = $entry['Quantity'];
         $item['unit_price'] = $entry['UnitPrice'];
         $item['tax_percent'] = $entry['SalesTaxPercent'];
         //		$item['sales_tax']   = $entry['SalesTax']; // sales tax will be calculated
         $item['taxable'] = $this->guess_tax_id($tax_rates, $item['tax_percent']);
         $item['total_price'] = $entry['TotalPrice'];
         $this->order['items'][] = $item;
     }
     if (function_exists('xtra_order_data')) {
         xtra_order_data($this->order, $order);
     }
     $this->buildJournalEntry();
 }
Example #8
0
 function processOrder($objXML)
 {
     global $db, $messageStack;
     // build the tax table to set the tax rates
     switch ($this->function) {
         case 'SalesInvoice':
             define('JOURNAL_ID', 12);
             define('GL_TYPE', 'sos');
             break;
         case 'SalesOrder':
         default:
             define('JOURNAL_ID', 10);
             define('GL_TYPE', 'soo');
     }
     $messageStack->debug("\njournal_id = " . JOURNAL_ID . " and function = " . $this->function);
     $tax_rates = ord_calculate_tax_drop_down('c');
     // Here we map the received xml array to the pre-defined generic structure (application specific format later)
     if (!is_array($objXML->Request->Order)) {
         $objXML->Request->Order = array($objXML->Request->Order);
     }
     foreach ($objXML->Request->Order as $order) {
         if ($order->ReceivablesGLAccount != '') {
             // see if requestor specifies a AR account else use default
             define('DEF_GL_ACCT', $order->ReceivablesGLAccount);
         } else {
             define('DEF_GL_ACCT', AR_DEFAULT_GL_ACCT);
         }
         $this->order = array();
         $this->order['reference'] = $order->Reference;
         $this->order['store_id'] = $order->StoreID;
         $this->order['sales_gl_account'] = $order->SalesGLAccount;
         $this->order['receivables_gl_acct'] = $order->ReceivablesGLAccount;
         $this->order['order_id'] = $order->OrderID;
         $this->order['purch_order_id'] = $order->PurchaseOrderID;
         $this->order['post_date'] = $order->OrderDate;
         $this->order['order_total'] = $order->OrderTotal;
         $this->order['tax_total'] = $order->TaxTotal;
         $this->order['freight_total'] = $order->ShippingTotal;
         $this->order['freight_carrier'] = $order->ShippingCarrier;
         $this->order['freight_method'] = $order->ShippingMethod;
         $this->order['rep_id'] = $order->SalesRepID;
         //	  $this->order['discount_total']         = $order->DiscountTotal;
         // <Payment>
         $this->order['payment']['holder_name'] = $order->Payment->CardHolderName;
         $this->order['payment']['method'] = $order->Payment->Method;
         $this->order['payment']['type'] = $order->Payment->CardType;
         $this->order['payment']['card_number'] = $order->Payment->CardNumber;
         $this->order['payment']['exp_date'] = $order->Payment->ExpirationDate;
         $this->order['payment']['cvv2'] = $order->Payment->CVV2Number;
         // <Customer> and <Billing> and <Shipping>
         $types = array('customer', 'billing', 'shipping');
         foreach ($types as $value) {
             $entry = ucfirst($value);
             $this->order[$value]['primary_name'] = $order->{$entry}->CompanyName;
             $this->order[$value]['contact'] = $order->{$entry}->Contact;
             $this->order[$value]['address1'] = $order->{$entry}->Address1;
             $this->order[$value]['address2'] = $order->{$entry}->Address2;
             $this->order[$value]['city_town'] = $order->{$entry}->CityTown;
             $this->order[$value]['state_province'] = $order->{$entry}->StateProvince;
             $this->order[$value]['postal_code'] = $order->{$entry}->PostalCode;
             $this->order[$value]['country_code'] = $order->{$entry}->CountryCode;
             $this->order[$value]['telephone'] = $order->{$entry}->Telephone;
             $this->order[$value]['email'] = $order->{$entry}->Email;
             if ($value == 'customer') {
                 // additional information for the customer record
                 $this->order[$value]['customer_id'] = $order->{$entry}->CustomerID;
             }
         }
         // if billing or shipping is blank, use customer address
         if ($this->order['billing']['primary_name'] == '' && $this->order['billing']['contact'] == '') {
             $this->order['billing'] = $this->order['customer'];
         }
         if ($this->order['shipping']['primary_name'] == '' && $this->order['shipping']['contact'] == '') {
             $this->order['shipping'] = $this->order['customer'];
         }
         // <LineItems>
         $this->order['items'] = array();
         if (!is_array($order->Item)) {
             $order->Item = array($order->Item);
         }
         foreach ($order->Item as $entry) {
             $item = array();
             $sku = $entry->ItemID;
             // try to match sku and get the sales gl account
             $result = $db->Execute("select account_sales_income from " . TABLE_INVENTORY . " where sku = '" . $sku . "'");
             if ($result->RecordCount() > 0) {
                 $item['sku'] = $sku;
                 $item['gl_acct'] = $result->fields['account_sales_income'];
             } else {
                 $result = $db->Execute("select sku, account_sales_income from " . TABLE_INVENTORY . " where description_short = '" . $sku . "'");
                 $item['sku'] = $result->fields['sku'];
                 $item['gl_acct'] = $result->fields['account_sales_income'];
             }
             $item['description'] = $entry->Description;
             $item['quantity'] = $entry->Quantity;
             $item['unit_price'] = $entry->UnitPrice;
             $item['tax_percent'] = $entry->SalesTaxPercent;
             //		$item['sales_tax']   = $entry->SalesTax; // sales tax will be calculated
             $item['taxable'] = $this->guess_tax_id($tax_rates, $item['tax_percent']);
             $item['total_price'] = $entry->TotalPrice;
             $this->order['items'][] = $item;
         }
         if (function_exists('xtra_order_data')) {
             xtra_order_data($this->order, $order);
         }
         $this->buildJournalEntry();
         $this->buildJournalResponse();
     }
     return true;
 }
Example #9
0
 /**
  * this function will import orders from a csv file to the general journal.
  * @param string $lines_array
  * @return void|boolean
  */
 function processCSV($filename, $function = 'Sales')
 {
     global $db, $messageStack;
     $rows = $this->csv_to_array($_FILES[$filename]['tmp_name'], $delimiter = ',');
     $messageStack->debug("\nfinished parsing, extracted number of rows = " . sizeof($rows));
     switch ($function) {
         default:
         case 'Sales':
             define('JOURNAL_ID', 12);
             define('GL_TYPE', 'sos');
             break;
         case 'SalesOrder':
             define('JOURNAL_ID', 10);
             define('GL_TYPE', 'soo');
     }
     $tax_rates = ord_calculate_tax_drop_down('c');
     $count = 0;
     foreach ($rows as $csv_data) {
         // map csv to xml soap format
         $soap_order = new xml_orders();
         $soap_order->order = array();
         $soap_order->order['reference'] = $csv_data['Reference'];
         $soap_order->order['store_id'] = $csv_data['StoreID'];
         $soap_order->order['sales_gl_account'] = $csv_data['SalesGLAccount'];
         $soap_order->order['receivables_gl_acct'] = $csv_data['ReceivablesGLAccount'];
         $soap_order->order['order_id'] = $csv_data['OrderID'];
         $soap_order->order['purch_order_id'] = $csv_data['PurchaseOrderID'];
         $soap_order->order['post_date'] = $csv_data['OrderDate'];
         $soap_order->order['order_total'] = $csv_data['OrderTotal'];
         $soap_order->order['tax_total'] = $csv_data['TaxTotal'];
         $soap_order->order['freight_total'] = $csv_data['ShippingTotal'];
         $soap_order->order['freight_carrier'] = $csv_data['ShippingCarrier'];
         $soap_order->order['freight_method'] = $csv_data['ShippingMethod'];
         $soap_order->order['rep_id'] = $csv_data['SalesRepID'];
         // <Payment>
         $soap_order->order['payment']['holder_name'] = $csv_data['Payment->CardHolderName'];
         $soap_order->order['payment']['method'] = $csv_data['Payment->Method'];
         $soap_order->order['payment']['type'] = $csv_data['Payment->CardType'];
         $soap_order->order['payment']['card_number'] = $csv_data['Payment->CardNumber'];
         $soap_order->order['payment']['exp_date'] = $csv_data['Payment->ExpirationDate'];
         $soap_order->order['payment']['cvv2'] = $csv_data['Payment->CVV2Number'];
         // <Customer> and <Billing> and <Shipping>
         $types = array('customer', 'billing', 'shipping');
         foreach ($types as $value) {
             $entry = ucfirst($value);
             $soap_order->order[$value]['primary_name'] = $csv_data['$entry->CompanyName'];
             $soap_order->order[$value]['contact'] = $csv_data['$entry->Contact'];
             $soap_order->order[$value]['address1'] = $csv_data['$entry->Address1'];
             $soap_order->order[$value]['address2'] = $csv_data['$entry->Address2'];
             $soap_order->order[$value]['city_town'] = $csv_data['$entry->CityTown'];
             $soap_order->order[$value]['state_province'] = $csv_data['$entry->StateProvince'];
             $soap_order->order[$value]['postal_code'] = $csv_data['$entry->PostalCode'];
             $soap_order->order[$value]['country_code'] = $csv_data['$entry->CountryCode'];
             $soap_order->order[$value]['telephone'] = $csv_data['$entry->Telephone'];
             $soap_order->order[$value]['email'] = $csv_data['$entry->Email'];
             if ($value == 'customer') {
                 // additional information for the customer record
                 $soap_order->order[$value]['customer_id'] = $csv_data['$entry->CustomerID'];
             }
         }
         // if billing or shipping is blank, use customer address
         if ($soap_order->order['billing']['primary_name'] == '' && $soap_order->order['billing']['contact'] == '') {
             $soap_order->order['billing'] = $soap_order->order['customer'];
         }
         if ($soap_order->order['shipping']['primary_name'] == '' && $soap_order->order['shipping']['contact'] == '') {
             $soap_order->order['shipping'] = $soap_order->order['customer'];
         }
         // <LineItems>
         $soap_order->order['items'] = array();
         if (!is_array($csv_data['Item'])) {
             $csv_data['Item'] = array($csv_data['Item']);
         }
         foreach ($csv_data['Item'] as $entry) {
             $item = array();
             $sku = $entry->ItemID;
             // try to match sku and get the sales gl account
             $result = $db->Execute("SELECT account_sales_income FROM " . TABLE_INVENTORY . " WHERE sku='{$sku}'");
             if ($result->RecordCount() > 0) {
                 $item['sku'] = $sku;
                 $item['gl_acct'] = $result->fields['account_sales_income'];
             } else {
                 $result = $db->Execute("SELECT sku, account_sales_income FROM " . TABLE_INVENTORY . " WHERE description_short='{$sku}'");
                 $item['sku'] = $result->fields['sku'];
                 $item['gl_acct'] = $result->fields['account_sales_income'];
             }
             $item['description'] = $entry->Description;
             $item['quantity'] = $entry->Quantity;
             $item['unit_price'] = $entry->UnitPrice;
             $item['tax_percent'] = $entry->SalesTaxPercent;
             $item['taxable'] = $this->guess_tax_id($tax_rates, $item['tax_percent']);
             $item['total_price'] = $entry->TotalPrice;
             $soap_order->order['items'][] = $item;
         }
         //			if (function_exists('xtra_order_data')) xtra_order_data($soap_order->order, $csv_data);
         // Now post like soap transaction
         $soap_order->buildJournalEntry();
     }
     if (DEBUG) {
         $messageStack->write_debug();
     }
     $messageStack->add("Total lines processed: " . sizeof($rows), "success");
 }
Example #10
0
 function update($module)
 {
     global $db, $messageStack, $currencies;
     $error = false;
     if (MODULE_INVENTORY_STATUS < 3.1) {
         $tab_map = array('0' => '0');
         if (db_table_exists(DB_PREFIX . 'inventory_categories')) {
             $result = $db->Execute("select * from " . DB_PREFIX . 'inventory_categories');
             while (!$result->EOF) {
                 $updateDB = $db->Execute("insert into " . TABLE_EXTRA_TABS . " set\n\t\t\t  module_id = 'inventory',\n\t\t\t  tab_name = '" . $result->fields['category_name'] . "',\n\t\t\t  description = '" . $result->fields['category_description'] . "',\n\t\t\t  sort_order = '" . $result->fields['sort_order'] . "'");
                 $tab_map[$result->fields['category_id']] = db_insert_id();
                 $result->MoveNext();
             }
             $db->Execute("DROP TABLE " . DB_PREFIX . "inventory_categories");
         }
         if (db_table_exists(DB_PREFIX . 'inventory_categories')) {
             $result = $db->Execute("select * from " . DB_PREFIX . 'inventory_fields');
             while (!$result->EOF) {
                 $updateDB = $db->Execute("insert into " . TABLE_EXTRA_FIELDS . " set\n\t\t\t  module_id = 'inventory',\n\t\t\t  tab_id = '" . $tab_map[$result->fields['category_id']] . "',\n\t\t\t  entry_type = '" . $result->fields['entry_type'] . "',\n\t\t\t  field_name = '" . $result->fields['field_name'] . "',\n\t\t\t  description = '" . $result->fields['description'] . "',\n\t\t\t  params = '" . $result->fields['params'] . "'");
                 $result->MoveNext();
             }
             $db->Execute("DROP TABLE " . DB_PREFIX . "inventory_fields");
         }
         xtra_field_sync_list('inventory', TABLE_INVENTORY);
     }
     if (MODULE_INVENTORY_STATUS < 3.2) {
         if (!db_field_exists(TABLE_PRICE_SHEETS, 'type')) {
             $db->Execute("ALTER TABLE " . TABLE_PRICE_SHEETS . " ADD type char(1) NOT NULL default 'c' AFTER sheet_name");
         }
         if (!db_field_exists(TABLE_INVENTORY, 'price_sheet_v')) {
             $db->Execute("ALTER TABLE " . TABLE_INVENTORY . " ADD price_sheet_v varchar(32) default NULL AFTER price_sheet");
         }
         xtra_field_sync_list('inventory', TABLE_INVENTORY);
     }
     if (MODULE_INVENTORY_STATUS < 3.6) {
         $db->Execute("ALTER TABLE " . TABLE_INVENTORY . " ADD INDEX ( sku )");
         if (!db_field_exists(TABLE_INVENTORY, 'attachments')) {
             $db->Execute("ALTER TABLE " . TABLE_INVENTORY . " ADD attachments text AFTER last_journal_date");
         }
         if (!db_field_exists(TABLE_INVENTORY, 'full_price_with_tax')) {
             $db->Execute("ALTER TABLE " . TABLE_INVENTORY . " ADD full_price_with_tax FLOAT NOT NULL DEFAULT '0' AFTER full_price");
         }
         if (!db_field_exists(TABLE_INVENTORY, 'product_margin')) {
             $db->Execute("ALTER TABLE " . TABLE_INVENTORY . " ADD product_margin FLOAT NOT NULL DEFAULT '0' AFTER full_price_with_tax");
         }
         if (!db_field_exists(TABLE_EXTRA_FIELDS, 'use_in_inventory_filter')) {
             $db->Execute("ALTER TABLE " . TABLE_EXTRA_FIELDS . " ADD use_in_inventory_filter ENUM( '0', '1' ) NOT NULL DEFAULT '0'");
         }
         $db->Execute("alter table " . TABLE_INVENTORY . " CHANGE inactive inactive ENUM( '0', '1' ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '0'");
         xtra_field_sync_list('inventory', TABLE_INVENTORY);
         $db->Execute("update " . TABLE_INVENTORY . " set inventory_type = 'ma' where inventory_type = 'as'");
         $result = $db->Execute("select * from " . TABLE_EXTRA_FIELDS . " where module_id = 'inventory'");
         while (!$result->EOF) {
             $temp = unserialize($result->fields['params']);
             switch ($result->fields['field_name']) {
                 case 'serialize':
                     $temp['inventory_type'] = 'sa:sr';
                     break;
                 case 'item_taxable':
                 case 'purch_taxable':
                 case 'item_cost':
                 case 'price_sheet':
                 case 'price_sheet_v':
                 case 'full_price':
                 case 'full_price_with_tax':
                 case 'product_margin':
                     $temp['inventory_type'] = 'ci:ia:lb:ma:mb:mi:ms:ns:sa:sf:si:sr:sv';
                     break;
                 case 'image_with_path':
                     $temp['inventory_type'] = 'ia:ma:mb:mi:ms:ns:sa:si:sr';
                     break;
                 case 'account_cost_of_sales':
                     $temp['inventory_type'] = 'ia:lb:ma:mb:mi:ms:ns:sa:sf:si:sr:sv';
                     break;
                 case 'cost_method':
                     $temp['inventory_type'] = 'ia:ma:mb:mi:ms:ns:si';
                     break;
                 case 'item_weight':
                     $temp['inventory_type'] = 'ia:ma:mb:mi:ms:ns:sa:si:sr';
                     break;
                 case 'quantity_on_hand':
                 case 'minimum_stock_level':
                 case 'reorder_quantity':
                     $temp['inventory_type'] = 'ia:ma:mi:ns:sa:si:sr';
                     break;
                 case 'quantity_on_order':
                 case 'quantity_on_allocation':
                     $temp['inventory_type'] = 'ia:mi:sa:si:sr';
                     break;
                 case 'quantity_on_sales_order':
                     $temp['inventory_type'] = 'ia:ma:mi:sa:si:sr';
                     break;
                 case 'lead_time':
                     $temp['inventory_type'] = 'ai:ia:lb:ma:mb:mi:ms:ns:sa:sf:si:sr:sv';
                     break;
                 case 'upc_code':
                     $temp['inventory_type'] = 'ia:ma:mi:ns:sa:si:sr';
                     break;
                 default:
                     $temp['inventory_type'] = 'ai:ci:ds:ia:lb:ma:mb:mi:ms:ns:sa:sf:si:sr:sv';
             }
             $updateDB = $db->Execute("update " . TABLE_EXTRA_FIELDS . " set params = '" . serialize($temp) . "' where id = '" . $result->fields['id'] . "'");
             $result->MoveNext();
         }
         $haystack = array('attachments', 'account_sales_income', 'item_taxable', 'purch_taxable', 'image_with_path', 'account_inventory_wage', 'account_cost_of_sales', 'cost_method', 'lead_time');
         $result = $db->Execute("update " . TABLE_EXTRA_FIELDS . " set entry_type = 'check_box' where field_name = 'inactive'");
         $result = $db->Execute("select * from " . TABLE_EXTRA_FIELDS . " where module_id = 'inventory'");
         while (!$result->EOF) {
             $use_in_inventory_filter = '1';
             if (in_array($result->fields['field_name'], $haystack)) {
                 $use_in_inventory_filter = '0';
             }
             $updateDB = $db->Execute("update " . TABLE_EXTRA_FIELDS . " set use_in_inventory_filter = '" . $use_in_inventory_filter . "' where id = '" . $result->fields['id'] . "'");
             $result->MoveNext();
         }
         if (!db_table_exists(TABLE_INVENTORY_PURCHASE)) {
             foreach ($this->tables as $table => $sql) {
                 if ($table == TABLE_INVENTORY_PURCHASE) {
                     admin_install_tables(array($table => $sql));
                 }
             }
             if (db_field_exists(TABLE_INVENTORY, 'purch_package_quantity')) {
                 $result = $db->Execute("insert into " . TABLE_INVENTORY_PURCHASE . " ( sku, vendor_id, description_purchase, purch_package_quantity, purch_taxable, item_cost, price_sheet_v ) select sku, vendor_id, description_purchase, purch_package_quantity, purch_taxable, item_cost, price_sheet_v  from " . TABLE_INVENTORY);
                 $db->Execute("ALTER TABLE " . TABLE_INVENTORY . " DROP purch_package_quantity");
             } else {
                 $result = $db->Execute("insert into " . TABLE_INVENTORY_PURCHASE . " ( sku, vendor_id, description_purchase, purch_package_quantity, purch_taxable, item_cost, price_sheet_v ) select sku, vendor_id, description_purchase, 1, purch_taxable, item_cost, price_sheet_v  from " . TABLE_INVENTORY);
             }
         }
         require_once DIR_FS_MODULES . 'phreebooks/functions/phreebooks.php';
         $tax_rates = ord_calculate_tax_drop_down('c');
         $result = $db->Execute("SELECT id, item_taxable, full_price, item_cost FROM " . TABLE_INVENTORY);
         while (!$result->EOF) {
             $sql_data_array = array();
             $sql_data_array['full_price_with_tax'] = round((1 + $tax_rates[$result->fields['item_taxable']]['rate'] / 100) * $result->fields['full_price'], $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
             if ($result->fields['item_cost'] != '' && $result->fields['item_cost'] > 0) {
                 $sql_data_array['product_margin'] = round($sql_data_array['full_price_with_tax'] / $result->fields['item_cost'], $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
             }
             db_perform(TABLE_INVENTORY, $sql_data_array, 'update', "id = " . $result->fields['id']);
             $result->MoveNext();
         }
         mkdir(DIR_FS_MY_FILES . $_SESSION['company'] . '/inventory/attachments/', 0755, true);
     }
     if (MODULE_INVENTORY_STATUS < 3.7) {
         if (!db_field_exists(TABLE_INVENTORY_HISTORY, 'avg_cost')) {
             $db->Execute("ALTER TABLE " . TABLE_INVENTORY_HISTORY . " ADD avg_cost FLOAT NOT NULL DEFAULT '0' AFTER unit_cost");
             $db->Execute("UPDATE " . TABLE_INVENTORY_HISTORY . " SET avg_cost = unit_cost");
         }
         $result = $db->Execute("select id, params from " . TABLE_EXTRA_FIELDS . " where module_id = 'inventory' AND field_name = 'account_cost_of_sales'");
         $temp = unserialize($result->fields['params']);
         $temp['inventory_type'] = 'ai:ci:ds:ia:lb:ma:mb:mi:ms:ns:sa:sf:si:sr:sv';
         $updateDB = $db->Execute("update " . TABLE_EXTRA_FIELDS . " set params='" . serialize($temp) . "' where id='" . $result->fields['id'] . "'");
         $db->Execute("ALTER TABLE " . TABLE_INVENTORY . "\n\t\t\tCHANGE item_cost item_cost DOUBLE NOT NULL DEFAULT '0',\n\t\t\tCHANGE full_price full_price DOUBLE NOT NULL DEFAULT '0',\n\t\t\tCHANGE full_price_with_tax full_price_with_tax DOUBLE NOT NULL DEFAULT '0',\n\t\t\tCHANGE product_margin product_margin DOUBLE NOT NULL DEFAULT '0',\n\t\t\tCHANGE item_weight item_weight DOUBLE NOT NULL DEFAULT '0',\n\t\t\tCHANGE quantity_on_hand quantity_on_hand DOUBLE NOT NULL DEFAULT '0',\n\t\t\tCHANGE quantity_on_order quantity_on_order DOUBLE NOT NULL DEFAULT '0',\n\t\t\tCHANGE quantity_on_sales_order quantity_on_sales_order DOUBLE NOT NULL DEFAULT '0',\n\t\t\tCHANGE quantity_on_allocation quantity_on_allocation DOUBLE NOT NULL DEFAULT '0',\n\t\t\tCHANGE minimum_stock_level minimum_stock_level DOUBLE NOT NULL DEFAULT '0',\n\t\t\tCHANGE reorder_quantity reorder_quantity DOUBLE NOT NULL DEFAULT '0'");
         $db->Execute("ALTER TABLE " . TABLE_INVENTORY_ASSY_LIST . " CHANGE qty qty double NOT NULL default '0'");
         $db->Execute("ALTER TABLE " . TABLE_INVENTORY_COGS_OWED . " CHANGE qty qty double NOT NULL default '0'");
         $db->Execute("ALTER TABLE " . TABLE_INVENTORY_COGS_USAGE . " CHANGE qty qty double NOT NULL default '0'");
         $db->Execute("ALTER TABLE " . TABLE_INVENTORY_HISTORY . "\n\t\t\tCHANGE qty qty DOUBLE NOT NULL DEFAULT '0',\n\t\t\tCHANGE remaining remaining DOUBLE NOT NULL DEFAULT '0',\n\t\t\tCHANGE unit_cost unit_cost DOUBLE NOT NULL DEFAULT '0',\n\t\t\tCHANGE avg_cost avg_cost DOUBLE NOT NULL DEFAULT '0'");
         $db->Execute("ALTER TABLE " . TABLE_INVENTORY_PURCHASE . "\n\t\t\tCHANGE purch_package_quantity purch_package_quantity DOUBLE NOT NULL DEFAULT '0',\n\t\t\tCHANGE item_cost item_cost DOUBLE NOT NULL DEFAULT '0'");
     }
     if (version_compare(MODULE_INVENTORY_STATUS, '3.7.4', '<')) {
         if (!db_field_exists(TABLE_INVENTORY, 'product_markup')) {
             $db->Execute("ALTER TABLE " . TABLE_INVENTORY . " CHANGE product_margin product_markup DOUBLE NOT NULL DEFAULT '0'");
             $db->Execute("ALTER TABLE " . TABLE_INVENTORY . " ADD product_margin DOUBLE NOT NULL DEFAULT '0' AFTER product_markup");
             $db->Execute("insert into " . TABLE_EXTRA_FIELDS . " set module_id = 'inventory', tab_id = '0', entry_type = 'decimal', field_name = 'product_markup',\n\t\t\t\tdescription = 'product_markup', params = 'a:2:{s:4:\"type\";N;s:14:\"inventory_type\";s:39:\"lb:ma:ia:mb:ms:ci:ns:sa:sr:sv:mi:sf:si:\";}'");
         }
         $result = $db->Execute("SELECT i.id, i.full_price, i.item_cost, max(p.item_cost) as purchase_cost FROM " . TABLE_INVENTORY . " i left join " . TABLE_INVENTORY_PURCHASE . " p on (p.sku = i.sku) ");
         while (!$result->EOF) {
             $sql_data_array = array();
             if ($result->fields['purchase_cost'] > $result->fields['item_cost']) {
                 $sql_data_array['product_margin'] = round(($result->fields['full_price'] - $result->fields['purchase_cost']) / $result->fields['full_price'] * 100, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
                 db_perform(TABLE_INVENTORY, $sql_data_array, 'update', "id = " . $result->fields['id']);
             } else {
                 $sql_data_array['product_margin'] = round(($result->fields['full_price'] - $result->fields['item_cost']) / $result->fields['full_price'] * 100, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
                 db_perform(TABLE_INVENTORY, $sql_data_array, 'update', "id = " . $result->fields['id']);
             }
             $result->MoveNext();
         }
     }
     if (!$error) {
         xtra_field_sync_list('inventory', TABLE_INVENTORY);
         write_configure('MODULE_' . strtoupper($module) . '_STATUS', constant('MODULE_' . strtoupper($module) . '_VERSION'));
         $messageStack->add(sprintf(GEN_MODULE_UPDATE_SUCCESS, $module, constant('MODULE_' . strtoupper($module) . '_VERSION')), 'success');
     }
     return $error;
 }
Example #11
0
                    $db->Execute("update " . TABLE_INVENTORY . " set quantity_on_sales_order = " . $so[$sku] . " where id = " . $balance['id']);
                    $fix++;
                }
                $cnt++;
            }
        }
        $messageStack->Add(sprintf(INV_TOOLS_SO_PO_RESULT, $cnt, $fix), 'success');
        gen_add_audit_log(sprintf(INV_TOOLS_AUTDIT_LOG_SO_PO, $cnt), 'Fixed: ' . $fix);
        $default_tab_id = 'tools';
        break;
    default:
}
/*****************   prepare to display templates  *************************/
$category_array = xtra_field_get_tabs();
// build some general pull down arrays
$sel_yes_no = array(array('id' => '0', 'text' => TEXT_NO), array('id' => '1', 'text' => TEXT_YES));
$cost_methods = array(array('id' => 'f', 'text' => INV_TEXT_FIFO), array('id' => 'l', 'text' => INV_TEXT_LIFO), array('id' => 'a', 'text' => INV_TEXT_AVERAGE));
$sel_item_cost = array(array('id' => '0', 'text' => TEXT_NO), array('id' => 'PO', 'text' => TEXT_PURCH_ORDER), array('id' => 'PR', 'text' => TEXT_PURCHASE));
$sel_sales_tax = ord_calculate_tax_drop_down('c');
$sel_purch_tax = ord_calculate_tax_drop_down('v');
// some pre-defined gl accounts
$cog_chart = gen_coa_pull_down(2, false, true, false, $restrict_types = array(32));
// cogs types only
$inc_chart = gen_coa_pull_down(2, false, true, false, $restrict_types = array(30));
// income types only
$inv_chart = gen_coa_pull_down(2, false, true, false, $restrict_types = array(4, 34));
// inv, expenses types only
$include_header = true;
$include_footer = true;
$include_template = 'template_main.php';
define('PAGE_TITLE', BOX_INV_ADMIN);
Example #12
0
$custom_path = DIR_FS_WORKING . 'custom/pages/main/extra_actions.php';
if (file_exists($custom_path)) {
    include $custom_path;
}
/***************   Act on the action request   *************************/
/*****************   prepare to display templates  *************************/
// generate address arrays for javascript
$js_arrays = gen_build_company_arrays();
// load the tax rates
$tax_rates = ord_calculate_tax_drop_down($account_type);
// generate a rate array parallel to the drop down for the javascript total calculator
$js_tax_rates = 'var tax_rates = new Array();' . chr(10);
for ($i = 0; $i < count($tax_rates); $i++) {
    $js_tax_rates .= 'tax_rates[' . $i . '] = new salesTaxes("' . $tax_rates[$i]['id'] . '", "' . $tax_rates[$i]['text'] . '", "' . $tax_rates[$i]['rate'] . '");' . chr(10);
}
$ot_tax_rates = ord_calculate_tax_drop_down('v');
$js_ot_tax_rates = 'var ot_tax_rates = new Array();' . chr(10);
for ($i = 0; $i < count($ot_tax_rates); $i++) {
    $js_ot_tax_rates .= 'ot_tax_rates[' . $ot_tax_rates[$i]['id'] . '] = new purTaxes("' . $ot_tax_rates[$i]['id'] . '", "' . $ot_tax_rates[$i]['text'] . '", "' . $ot_tax_rates[$i]['rate'] . '");' . chr(10);
}
//payment modules
// generate payment choice arrays for receipt of payments
$js_pmt_types = 'var pmt_types = new Array();' . chr(10);
foreach ($payment_modules as $key => $pmts) {
    $pmt_method = $pmts['id'];
    ${$pmt_method} = new $pmt_method();
    if (${$pmt_method}->show_in_pos == false || ${$pmt_method}->pos_gl_acct == '') {
        unset($payment_modules[$key]);
    } else {
        $js_pmt_types .= 'pmt_types[\'' . $pmts['id'] . '\'] = "' . $pmts['text'] . '";' . chr(10);
    }