is not already on this credit note */
                if ($_SESSION['SO_AllowSameItemMultipleTimes'] == 0 and strcasecmp($OrderItem->StockID, $_POST['NewItem']) == 0) {
                    $AlreadyOnThisCredit = 1;
                    prnMsg(_('The item selected is already on this credit the system will not allow the same item on the credit note more than once. However you can change the quantity credited of the existing line if necessary.'), 'warn');
                }
            }
            /* end of the foreach loop to look for preexisting items of the same code */
            if ($AlreadyOnThisCredit != 1) {
                $sql = "SELECT stockmaster.description,\n\t\t\t\t\t\t\t\tstockmaster.longdescription,\n\t\t\t\t\t\t\t\tstockmaster.stockid,\n\t\t\t\t\t\t\t\tstockmaster.units,\n\t\t\t\t\t\t\t\tstockmaster.volume,\n\t\t\t\t\t\t\t\tstockmaster.grossweight,\n\t\t\t\t\t\t\t\tstockmaster.mbflag,\n\t\t\t\t\t\t\t\tstockmaster.discountcategory,\n\t\t\t\t\t\t\t\tstockmaster.controlled,\n\t\t\t\t\t\t\t\tstockmaster.decimalplaces,\n\t\t\t\t\t\t\t\tstockmaster.serialised,\n\t\t\t\t\t\t\t\t(materialcost+labourcost+overheadcost) AS standardcost,\n\t\t\t\t\t\t\t\tstockmaster.taxcatid\n\t\t\t\t\t\t\tFROM stockmaster\n\t\t\t\t\t\t\tWHERE stockmaster.stockid = '" . $_POST['NewItem'] . "'";
                $ErrMsg = _('The item details could not be retrieved because');
                $DbgMsg = _('The SQL used to retrieve the item details but failed was');
                $result1 = DB_query($sql, $ErrMsg, $DbgMsg);
                $myrow = DB_fetch_array($result1);
                $LineNumber = $_SESSION['CreditItems' . $identifier]->LineCounter;
                /*validate the data returned before adding to the items to credit */
                if ($_SESSION['CreditItems' . $identifier]->add_to_cart($myrow['stockid'], 1, $myrow['description'], $myrow['longdescription'], GetPrice($_POST['NewItem'], $_SESSION['CreditItems' . $identifier]->DebtorNo, $_SESSION['CreditItems' . $identifier]->Branch), 0, $myrow['units'], $myrow['volume'], $myrow['grossweight'], 0, $myrow['mbflag'], Date($_SESSION['DefaultDateFormat']), 0, $myrow['discountcategory'], $myrow['controlled'], $myrow['serialised'], $myrow['decimalplaces'], '', 'No', -1, $myrow['taxcatid'], '', '', '', $myrow['standardcost']) == 1) {
                    $_SESSION['CreditItems' . $identifier]->GetTaxes($LineNumber);
                    if ($myrow['controlled'] == 1) {
                        /*Qty must be built up from serial item entries */
                        $_SESSION['CreditItems' . $identifier]->LineItems[$LineNumber]->Quantity = 0;
                    }
                }
            }
            /* end of if not already on the credit note */
        }
        /* end of if its a new item */
        /* This is where the credit note as selected should be displayed  reflecting any deletions or insertions*/
        echo '<table cellpadding="2" class="selection">
				<tr>
					<th>' . _('Item Code') . '</th>
					<th>' . _('Item Description') . '</th>
function OverheadSale($transaction_id, $prod_id, $quantity)
{
    $self_cost = GetPrice($prod_id);
    $cost = GetPricelistPrice($prod_id);
    mysql_query("INSERT INTO `sale_transaction_detail`\n\t\t\t\t\t(`transaction_id`, `production_id`, `product_quantity`, `self_cost`, `cost`)\n\t\t\t\t VALUES\n\t\t\t\t\t({$transaction_id}, {$prod_id}, {$quantity}, {$self_cost}, {$cost})");
}
Example #3
0
 } else {
     //for full template
     $pdf->addTextWrap(50, $YPos, 70, $FontSize, $myrow['stockid'], '', 0, $fill);
     if (file_exists($_SESSION['part_pics_dir'] . '/' . $myrow['stockid'] . '.jpg')) {
         $pdf->Image($_SESSION['part_pics_dir'] . '/' . $myrow['stockid'] . '.jpg', 135, $Page_Height - $Top_Margin - $YPos + 10, 45, 35);
     }
     /*end checked file exist*/
     $pdf->addTextWrap(180, $YPos, 200, $FontSize, $myrow['description'], '', 0, $fill);
     $pdf->addTextWrap(355, $YPos, 40, $FontSize, locale_number_format($myrow['fromquantity'] - $InTransitQuantityAtFrom, $myrow['decimalplaces']), 'right', 0, $fill);
     $pdf->addTextWrap(405, $YPos, 40, $FontSize, locale_number_format($myrow['quantity'] + $InTransitQuantityAtTo, $myrow['decimalplaces']), 'right', 0, $fill);
     $pdf->addTextWrap(450, $YPos, 40, 11, locale_number_format($ShipQty, $myrow['decimalplaces']), 'right', 0, $fill);
     $pdf->addTextWrap(510, $YPos, 40, $FontSize, '_________', 'right', 0, $fill);
 }
 if ($template == 'fullprices') {
     // looking for price info
     $DefaultPrice = GetPrice($myrow['stockid'], $ToCustomer, $ToBranch, $db, false);
     if ($myrow['discountcategory'] != "") {
         $DiscountLine = ' -> ' . _('Discount Category') . ':' . $myrow['discountcategory'];
     } else {
         $DiscountLine = '';
     }
     if ($DefaultPrice != 0) {
         $PriceLine = $ToPriceList . ":" . locale_number_format($DefaultPrice, $ToDecimalPlaces) . " " . $ToCurrency . $DiscountLine;
         $pdf->addTextWrap(180, $YPos - 0.5 * $line_height, 200, $FontSize, $PriceLine, '', 0, $fill);
     }
 }
 if ($YPos < $Bottom_Margin + $line_height + 200) {
     PrintHeader($pdf, $YPos, $PageNumber, $Page_Height, $Top_Margin, $Left_Margin, $Page_Width, $Right_Margin, $Trf_ID, $FromLocation, $ToLocation, $template, $CategoryDescription);
 }
 // Create loctransfers records for each record
 $sql2 = "INSERT INTO loctransfers (reference,\n\t\t\t\t\t\t\t\t\t\t\t\tstockid,\n\t\t\t\t\t\t\t\t\t\t\t\tshipqty,\n\t\t\t\t\t\t\t\t\t\t\t\tshipdate,\n\t\t\t\t\t\t\t\t\t\t\t\tshiploc,\n\t\t\t\t\t\t\t\t\t\t\t\trecloc)\n\t\t\t\t\t\t\t\t\t\t\tVALUES ('" . $Trf_ID . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $myrow['stockid'] . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $ShipQty . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $Now . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['FromLocation'] . "',\n\t\t\t\t\t\t\t\t\t\t\t\t'" . $_POST['ToLocation'] . "')";
                    $AlreadyOnThisCredit = 1;
                    prnMsg(_('The item selected is already on this credit the system will not allow the same item on the credit note more than once. However you can change the quantity credited of the existing line if necessary.'), 'warn');
                }
            }
            /* end of the foreach loop to look for preexisting items of the same code */
            if ($AlreadyOnThisCredit != 1) {
                foreach ($NewItem_array as $key => $value) {
                    $NewItem = $key;
                    $sql = "SELECT stockmaster.description,\n\t\t\t\t\t\t\t\t\tstockmaster.stockid,\n\t\t\t\t\t\t\t\t\tstockmaster.units as stockunits,\n\t\t\t\t\t\t\t\t\tstockmaster.volume,\n\t\t\t\t\t\t\t\t\tstockmaster.kgs,\n\t\t\t\t\t\t\t\t\tstockmaster.mbflag,\n\t\t\t\t\t\t\t\t\tstockmaster.discountcategory,\n\t\t\t\t\t\t\t\t\tstockmaster.controlled,\n\t\t\t\t\t\t\t\t\tstockmaster.decimalplaces,\n\t\t\t\t\t\t\t\t\tstockmaster.serialised,\n\t\t\t\t\t\t\t\t\t(materialcost+labourcost+overheadcost) AS standardcost,\n\t\t\t\t\t\t\t\t\tstockmaster.taxcatid\n\t\t\t\t\t\t\t\tFROM stockmaster\n\t\t\t\t\t\t\t\tWHERE stockmaster.stockid = '" . $NewItem . "'";
                    $ErrMsg = _('The item details could not be retrieved because');
                    $DbgMsg = _('The SQL used to retrieve the item details but failed was');
                    $result1 = DB_query($sql, $db, $ErrMsg, $DbgMsg);
                    $myrow = DB_fetch_array($result1);
                    $LineNumber = $_SESSION['CreditItems' . $identifier]->LineCounter;
                    /*validate the data returned before adding to the items to credit */
                    $Price = GetPrice($NewItem, $_SESSION['CreditItems' . $identifier]->DebtorNo, $_SESSION['CreditItems' . $identifier]->Branch, $db);
                    if ($_SESSION['CreditItems' . $identifier]->add_to_cart($myrow['stockid'], $value, $myrow['description'], $Price[0], 0, $_POST['Units' . $myrow['stockid']], $myrow['volume'], $myrow['kgs'], 0, $myrow['mbflag'], Date($_SESSION['DefaultDateFormat']), 0, $myrow['discountcategory'], 0, $myrow['controlled'], $myrow['serialised'], $myrow['decimalplaces'], $Price[2], '', 'No', -1, $myrow['taxcatid'], '', '', $myrow['standardcost'], 1, 0, 1, $Price[1]) == 1) {
                        $_SESSION['CreditItems' . $identifier]->GetTaxes($LineNumber);
                        if ($myrow['controlled'] == 1) {
                            /*Qty must be built up from serial item entries */
                            $_SESSION['CreditItems' . $identifier]->LineItems[$LineNumber]->Quantity = 0;
                        }
                    }
                }
                /* end of if not already on the credit note */
            }
            /* end of if its a new item */
        }
        /* This is where the credit note as selected should be displayed  reflecting any deletions or insertions*/
        echo '<font color="red"><table cellpadding="2" class="selection">
				<tr>
{
    $jsonArr = substr(file_get_contents("http://finance.google.com/finance/info?client=ig&q=" . $symbolString), 4);
    $jsonObj = json_decode($jsonArr, true);
    $retArr = array();
    foreach ($jsonObj as $value) {
        array_push($retArr, $value['l']);
    }
    return $retArr;
}
//apply formatting for query string
function FormatString($symbol)
{
    $symbolString = "";
    if (is_array($symbol)) {
        $len = count($symbol);
        $i = 0;
        foreach ($symbol as $value) {
            $symbolString .= $value;
            if ($len - $i != 1) {
                $symbolString .= ",";
            }
            $i++;
        }
    } else {
        return $symbol;
    }
    return $symbolString;
}
echo GetPrice("aapl");
echo GetPrice("aapl", "msft");
Example #6
0
<?php

require 'includes/connect.inc.php';
require 'includes/functions.php';
header('Content-Type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>';
$wi = $_GET['wi'];
$hi = $_GET['hi'];
$datab = $_GET['db'];
$quantity = $_GET['quantity'];
$result = GetPrice($wi, $hi, $datab);
echo '<response>';
echo '<price>';
echo '<current-width>';
echo $wi . '"';
echo '</current-width>';
echo '<current-length>';
echo $hi . '"';
echo '</current-length>';
echo '<price-current>';
echo '$ ' . $result * 0.22 * $quantity;
echo '</price-current>';
echo '<price-prev>';
echo '$ ' . $result * $quantity;
echo '</price-prev>';
echo '</price>';
echo '</response>';
Example #7
0
 //$link = 'http://' . $_SERVER["SERVER_NAME"] . JRoute::_(true, 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id='.$product_id);
 //$link = JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id='.$product_id);
 // ALCON
 $link = 'http://' . $_SERVER["SERVER_NAME"] . "/" . $siteid . "/shop/" . strtolower($product_type[0]) . "/" . strtolower($id) . "-" . $siteid . "-detail";
 //$link = 'http://' . $_SERVER["SERVER_NAME"] . "/" . 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id='.$product_id;
 //$product_result_row[4];  Had to Change because this was			          																for downloadable products
 //	$image_link = $feed_url . "/components/com_virtuemart/shop_image/product/" . $product_result_row[5];
 // ALCON
 $image_link = $product_result_row[$i][5];
 $additional_image_link = array();
 //	$additional_image_link = GetAdditionalImages($product_id); //may have to do something because needs to return an array
 $condition = "new";
 //$availability = $product_result_row[6];
 $availability = "in stock";
 $tmp_price = array();
 $tmp_price = explode("|", GetPrice($product_id));
 $price = round($tmp_price[1] * $curr, 0);
 $sale_price = round($tmp_price[0] * $curr, 0);
 //$priceconverted=$this->_CurrencyDisplay->priceDisplay($price, 144);
 if ($debug == 1) {
     //	echo "price converted:".$priceconverted . "<br />";
 }
 //$currency = GetCurrency($product_id);
 $brand = GetBrand($product_id);
 $mpn = $id;
 $shipping = $shipping_cost;
 $shipping_weight = $product_result_row[$i][7];
 $writer->startElement('item');
 $writer->startElement('g:id');
 $writer->text($id);
 //$id is the SKU
function SyncProductPrices($ShowMessages, $LastTimeRun, $db, $db_oc, $oc_tableprefix, $EmailText = '')
{
    if ($EmailText != '') {
        $EmailText = $EmailText . "Product Price Sync" . "\n" . PrintTimeInformation($db);
    }
    /* let's get the webERP price list and base currency for the online customer */
    list($PriceList, $Currency) = GetOnlinePriceList($db);
    /* Look for the late modifications of prices table in webERP */
    $SQL = "SELECT prices.stockid,\r\n\t\t\t\tstockmaster.discountcategory\r\n\t\t\tFROM prices, stockmaster\r\n\t\t\tWHERE prices.stockid = stockmaster.stockid\r\n\t\t\t\tAND prices.typeabbrev ='" . $PriceList . "'\r\n\t\t\t\tAND prices.currabrev ='" . $Currency . "'\r\n\t\t\t\tAND (prices.date_created >= '" . $LastTimeRun . "'\r\n\t\t\t\t\tOR prices.date_updated >= '" . $LastTimeRun . "')\r\n\t\t\tORDER BY prices.stockid";
    $result = DB_query($SQL, $db);
    if (DB_num_rows($result) != 0) {
        if ($ShowMessages) {
            echo '<p class="page_title_text" align="center"><strong>' . _('Product Prices Updates') . '</strong></p>';
            echo '<div>';
            echo '<table class="selection">';
            $TableHeader = '<tr>
								<th>' . _('StockID') . '</th>
								<th>' . _('New Price') . '</th>
								<th>' . _('Discount Category') . '</th>
								<th>' . _('Action') . '</th>
							</tr>';
            echo $TableHeader;
        }
        $DbgMsg = _('The SQL statement that failed was');
        $UpdateErrMsg = _('The SQL to update Product Prices in Opencart failed');
        $k = 0;
        //row colour counter
        $i = 0;
        while ($myrow = DB_fetch_array($result)) {
            $k = StartEvenOrOddRow($k);
            /* Field Matching */
            $Model = $myrow['stockid'];
            $CustomerCode = GetWeberpCustomerIdFromCurrency(OPENCART_DEFAULT_CURRENCY, $db);
            $Price = GetPrice($myrow['stockid'], $CustomerCode, $CustomerCode, $db);
            // Get the price without any discount from webERP
            $ManufacturerId = $myrow['manufacturers_id'];
            $DiscountCategory = $myrow['discountcategory'];
            // Let's get the OpenCart primary key for product
            $ProductId = GetOpenCartProductId($Model, $db_oc, $oc_tableprefix);
            $Action = "Update";
            $sqlUpdate = "UPDATE " . $oc_tableprefix . "product SET\r\n\t\t\t\t\t\t\tprice = '" . $Price . "'\r\n\t\t\t\t\t\tWHERE product_id = '" . $ProductId . "'";
            $resultUpdate = DB_query_oc($sqlUpdate, $UpdateErrMsg, $DbgMsg, true);
            // update discounts if needed
            MaintainOpenCartDiscountForItem($ProductId, $Price, $DiscountCategory, $PriceList, $db, $db_oc, $oc_tableprefix);
            if ($ShowMessages) {
                printf('<td>%s</td>
						<td class="number">%s</td>
						<td>%s</td>
						<td>%s</td>
						</tr>', $Model, locale_number_format($Price, 2), $DiscountCategory, $Action);
            }
            if ($EmailText != '') {
                $EmailText = $EmailText . str_pad($Model, 20, " ") . " = " . locale_number_format($Price, 2) . " = " . $DiscountCategory . " --> " . $Action . "\n";
            }
            $i++;
        }
        if ($ShowMessages) {
            echo '</table>
					</div>
					</form>';
        }
    }
    if ($ShowMessages) {
        prnMsg(locale_number_format($i, 0) . ' ' . _('Product Prices synchronized from webERP to OpenCart'), 'success');
    }
    if ($EmailText != '') {
        $EmailText = $EmailText . locale_number_format($i, 0) . ' ' . _('Product Prices synchronized from webERP to OpenCart') . "\n\n";
    }
    return $EmailText;
}