/** * Get related SalesOrder items * * @param int $crmid salesorder id * @return array $array[index][fieldname] = fieldvalue */ function getRelatedSalesOrderItems($crmid) { global $adb, $log; $log->debug("Entering customer portal function getRelatedSalesOrderItems"); $module = 'Products'; $sc_info = array(); if (vtlib_isModuleActive($module) !== true) { return $sc_info; } $query = "SELECT vtiger_inventoryproductrel.*, vtiger_products.* " . "FROM vtiger_inventoryproductrel " . "INNER JOIN vtiger_products ON vtiger_inventoryproductrel.productid = vtiger_products.productid " . "INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_inventoryproductrel.productid AND vtiger_crmentity.deleted = 0 " . "WHERE vtiger_inventoryproductrel.id = ?"; $res = $adb->pquery($query, array($crmid)); $rows = $adb->num_rows($res); for ($i = 0; $i < $rows; $i++) { $qty = $adb->query_result($res, $i, 'quantity'); $sc_info[$i]['productid' . $adb->query_result($res, $i, 'productid')] = $qty; $sc_info[$i][getTranslatedString('LBL_PRODUCT_CODE', $module)] = $adb->query_result($res, $i, 'product_no'); $sc_info[$i][getTranslatedString('LBL_PRODUCT_NAME', $module)] = $adb->query_result($res, $i, 'productname'); $sym = getCurrencySymbol($res, $i, 'currency_id'); $listprice = $adb->query_result($res, $i, 'listprice'); $sc_info[$i][getTranslatedString('LBL_PB_LIST_PRICE', 'SalesOrder')] = getCurrencyValue($sym, $listprice); $sc_info[$i][getTranslatedString('Quantity', 'SalesOrder')] = number_format($qty); } $log->debug("Exiting customerportal function getRelatedSalesOrderItems"); return $sc_info; }
<?php include 'functions.php'; include '../includes/configure.php'; include '../includes/functions/database.php'; include '../includes/database_tables.php'; include '../includes/functions/general.php'; tep_db_connect() or die('Unable to connect to database'); $post_update_list = array('customers_id', 'start_date', 'stop_date', 'currency'); $db_update_list = array('customers_id', 'date_purchased', 'orders_date_finished', 'currency'); $set_update_list = create_update_list($post_update_list, $db_update_list); if (!empty($set_update_list)) { $orders_id = $_POST['id']; $query = "update " . TABLE_ORDERS . " set {$set_update_list} where orders_id = " . $orders_id; tep_db_query($query); // Updating the currency value if (postNotEmpty('currency')) { $currency_value = getCurrencyValue($_POST['currency']); $query = 'update ' . TABLE_ORDERS . ' set currency_value = "' . $currency_value . '"'; tep_db_query($query); } }