Example #1
0
    // Check the date is OK
    if (isset($_POST['ConfirmedDate']) and !Is_Date($_POST['ConfirmedDate'])) {
        $InputErrors = 1;
        prnMsg(_('An invalid date entry was made') . '. ' . _('The date entry must be in the format') . ' ' . $_SESSION['DefaultDateFormat'], 'warn');
    }
    /* This check is not appropriate where orders need to be entered in retrospectively in some cases this check will be appropriate and this should be uncommented
    
    	 elseif (Date1GreaterThanDate2(Date($_SESSION['DefaultDateFormat'],$EarliestDispatch), $_POST['DeliveryDate'])){
    		$InputErrors =1;
    		echo '<br><b>' . _('The delivery details cannot be updated because you are attempting to set the date the order is to be dispatched earlier than is possible. No dispatches are made on Saturday and Sunday. Also, the dispatch cut off time is') .  $_SESSION['DispatchCutOffTime']  . _(':00 hrs. Orders placed after this time will be dispatched the following working day.');
    	}
    
    	*/
    if ($InputErrors == 0) {
        if ($_SESSION['DoFreightCalc'] == True) {
            list($_POST['FreightCost'], $BestShipper) = CalcFreightCost($_SESSION['Items' . $identifier]->total, $_POST['BrAdd2'], $_POST['BrAdd3'], $_SESSION['Items' . $identifier]->totalVolume, $_SESSION['Items' . $identifier]->totalWeight, $_SESSION['Items' . $identifier]->Location, $db);
            if (!empty($BestShipper)) {
                $_POST['FreightCost'] = round($_POST['FreightCost'], 2);
                $_POST['ShipVia'] = $BestShipper;
            } else {
                prnMsg(_($_POST['FreightCost']), 'warn');
            }
        }
        $sql = 'SELECT custbranch.brname,
				custbranch.braddress1,
				custbranch.braddress2,
				custbranch.braddress3,
				custbranch.braddress4,
				custbranch.braddress5,
				custbranch.braddress6,
				custbranch.phoneno,
        echo '</a></td>';
    }
    echo '</tr>';
    if (strlen($LnItm->Narrative) > 1) {
        $narrative = str_replace('\\r\\n', '<br>', $LnItm->Narrative);
        echo $RowStarter . '<td colspan=12>' . stripslashes($narrative) . '</td></tr>';
    }
}
//end foreach ($line)
/*Don't re-calculate freight if some of the order has already been delivered -
depending on the business logic required this condition may not be required.
It seems unfair to charge the customer twice for freight if the order
was not fully delivered the first time ?? */
if (!isset($_SESSION['Items']->FreightCost)) {
    if ($_SESSION['DoFreightCalc'] == True) {
        list($FreightCost, $BestShipper) = CalcFreightCost($_SESSION['Items']->total, $_SESSION['Items']->BrAdd2, $_SESSION['Items']->BrAdd3, $_SESSION['Items']->totalVolume, $_SESSION['Items']->totalWeight, $_SESSION['Items']->Location, $db);
        $_SESSION['Items']->ShipVia = $BestShipper;
    }
    if (is_numeric($FreightCost)) {
        $FreightCost = $FreightCost / $_SESSION['CurrencyRate'];
    } else {
        $FreightCost = 0;
    }
    if (!is_numeric($BestShipper)) {
        $SQL = 'SELECT shipper_id FROM shippers WHERE shipper_id=' . $_SESSION['Default_Shipper'];
        $ErrMsg = _('There was a problem testing for a default shipper because');
        $TestShipperExists = DB_query($SQL, $db, $ErrMsg);
        if (DB_num_rows($TestShipperExists) == 1) {
            $BestShipper = $_SESSION['Default_Shipper'];
        } else {
            $SQL = 'SELECT shipper_id FROM shippers';
        }
    }
    echo '</tr>';
    if (mb_strlen($LnItm->Narrative) > 1) {
        $Narrative = str_replace('\\r\\n', '<br />', $LnItm->Narrative);
        echo $RowStarter . '<td colspan="12">' . stripslashes($Narrative) . '</td></tr>';
    }
}
//end foreach ($line)
/*Don't re-calculate freight if some of the order has already been delivered -
depending on the business logic required this condition may not be required.
It seems unfair to charge the customer twice for freight if the order
was not fully delivered the first time ?? */
if (!isset($_SESSION['Items' . $identifier]->FreightCost)) {
    if ($_SESSION['DoFreightCalc'] == True) {
        list($FreightCost, $BestShipper) = CalcFreightCost($_SESSION['Items' . $identifier]->total, $_SESSION['Items' . $identifier]->BrAdd2, $_SESSION['Items' . $identifier]->BrAdd3, $_SESSION['Items' . $identifier]->BrAdd4, $_SESSION['Items' . $identifier]->BrAdd5, $_SESSION['Items' . $identifier]->BrAdd6, $_SESSION['Items' . $identifier]->totalVolume, $_SESSION['Items' . $identifier]->totalWeight, $_SESSION['Items' . $identifier]->Location, $_SESSION['Items' . $identifier]->DefaultCurrency, $db);
        $_SESSION['Items' . $identifier]->ShipVia = $BestShipper;
    }
    if (is_numeric($FreightCost)) {
        $FreightCost = $FreightCost / $_SESSION['CurrencyRate'];
    } else {
        $FreightCost = 0;
    }
    if (!is_numeric($BestShipper)) {
        $SQL = "SELECT shipper_id FROM shippers WHERE shipper_id='" . $_SESSION['Default_Shipper'] . "'";
        $ErrMsg = _('There was a problem testing for a default shipper because');
        $TestShipperExists = DB_query($SQL, $ErrMsg);
        if (DB_num_rows($TestShipperExists) == 1) {
            $BestShipper = $_SESSION['Default_Shipper'];
        } else {
            $SQL = "SELECT shipper_id FROM shippers";