Ejemplo n.º 1
0
 public function __construct($data = [], $connection = null)
 {
     $this->connection = $connection;
     foreach (['id', 'shipment_reference', 'tracking_url'] as $prop) {
         if (isset($data[$prop])) {
             $this->{$prop} = $data[$prop];
         }
     }
     foreach (['sender', 'recipient'] as $prop) {
         $this->{$prop} = isset($data[$prop]) ? Address::import($data[$prop]) : null;
     }
     $this->product = isset($data['product']) ? Product::import($data['product']) : null;
     if (isset($data['parcels'])) {
         $this->parcels = [];
         foreach ($data['parcels'] as $parcel_data) {
             $this->parcels[] = Parcel::import($parcel_data);
         }
     }
     if (isset($data['labels'])) {
         $this->labels = [];
         foreach ($data['labels'] as $url) {
             $this->labels[] = Label::import($url, $connection);
         }
     }
     if (isset($data['order'])) {
         $this->order = Order::import($data['order'], $connection);
     }
     if (isset($data['allow'])) {
         $this->allow = $data['allow'];
     }
 }
Ejemplo n.º 2
0
    function costToShip()
    {
        return $this->getVolume() * 0.6;
    }
}
?>

<!DOCTYPE html>
<html>
<head>
    <title>Shipping Details Page</title>
</head>
  <body>
      <h1>Shipping Costs</h1>
      <?php 
$get_weight = $_GET["weight"];
$get_length = $_GET["length"];
$get_width = $_GET["width"];
$get_height = $_GET["height"];
$new_parcel = new Parcel($_GET["weight"], $_GET["length"], $_GET["width"], $_GET["height"]);
$get_volume = $new_parcel->getVolume();
$get_price = $new_parcel->costToShip();
if (!$get_weight || !$get_length || !$get_height || !$get_width) {
    echo "<p>You must enter all data fields to calculate a cost! Try again!</p>";
} else {
    echo "<p>Your parcel weight is: {$get_weight} </p>\n            <p>Your parcel length is: {$get_length} </p>\n            <p>Your parcel width is: {$get_width} </p>\n            <p>Your parcel height is: {$get_height} </p>\n            <p>Your parcel volume is: {$get_volume} </p>\n            <p>Your cost to ship: \${$get_price} </p>";
}
?>
  </body>
</html>
Ejemplo n.º 3
0
    {
        return $this->weight;
    }
    function volume($vol_height, $vol_width, $vol_length)
    {
        $volume = $vol_height * $vol_width * $vol_length;
        return $volume;
    }
    function costToShip($volume, $weight)
    {
        $shipping_cost = $volume * $weight / 500;
        $formatted_price = number_format($shipping_cost, 2);
        return $formatted_price;
    }
}
$parcel = new Parcel();
$parcel->setHeight($_GET["height"]);
$parcel->setWidth($_GET["width"]);
$parcel->setLength($_GET["length"]);
$parcel->setWeight($_GET["weight"]);
?>

<!DOCTYPE html>
<html>
  <head>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>
    <h1>Parcel</h1>
Ejemplo n.º 4
0
    function setWeight($new_weight)
    {
        $this->weight = (int) $new_weight;
    }
    // $parcel_dimensions = array($length, $height, $width);
    function volume()
    {
        return $this->length * $this->height * $this->width;
    }
    function costToShip()
    {
        $total_volume = $this->volume();
        return $total_volume * $this->weight / 100000;
    }
}
$new_parcel = new Parcel($_GET["length"], $_GET["height"], $_GET["width"], $_GET["weight"]);
?>

<!DOCTYPE html>
<html>
<head>
    <title>Parcel Shipping Cost Homepage</title>
</head>
<body>
    <h1>Your Parcel Shipping Cost</h1>
    <ul>
      <?php 
$total_length = $new_parcel->getLength();
$total_height = $new_parcel->getHeight();
$total_width = $new_parcel->getWidth();
$total_weight = $new_parcel->getWeight();
Ejemplo n.º 5
0
        $this->length = $new_length;
    }
    function getLength()
    {
        return $this->length;
    }
    function setWeight($new_weight)
    {
        $this->weight = $new_weight;
    }
    function getWeight()
    {
        return $this->weight;
    }
}
$newParcel = new Parcel($_GET['height'], $_GET['width'], $_GET['length'], $_GET['weight']);
?>

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Parcels</title>
  </head>
  <body>
      <h1>Your Parcel Details:</h1>
      <?php 
if ($newParcel->getHeight() > 0 && $newParcel->getWidth() > 0 && $newParcel->getLength() > 0 && $newParcel->getWeight() > 0) {
    $show_height = $newParcel->getHeight();
    $show_width = $newParcel->getWidth();
    $show_length = $newParcel->getLength();
Ejemplo n.º 6
0
<?php

require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../src/Parcel.php";
$app = new Silex\Application();
$app->get("/", function () {
    return "\n        <!DOCTYPE html>\n        <html>\n        <head>\n            <link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css'>\n            <title>Parcel Price</title>\n        </head>\n        <body>\n            <div class='container'>\n                <h1>How much will it cost to ship this Parcel?</h1>\n                <p>Complete all fields in the form below to calculate the cost to ship your Parcel.</p>\n                <form action='price_parcel'>\n                    <div class='form-group'>\n                        <label for='height'>Height (in inches):</label>\n                        <input id='height' name='height' class='form-control' type='number'>\n                    </div>\n                    <div class='form-group'>\n                        <label for='length'>Length (in inches):</label>\n                        <input id='length' name='length' class='form-control' type='number'>\n                    </div>\n                    <div class='form-group'>\n                        <label for='width'>Width (in inches):</label>\n                        <input id='width' name='width' class='form-control' type='number'>\n                    </div>\n                    <div class='form-group'>\n                        <label for='weight'>Weight (in ounces):</weight>\n                        <input id='weight' name='weight' class='form-control' type='number'>\n                    </div>\n                    <button type='submit' class='btn-success'>Name That Price!</button>\n                </form>\n            </div>\n        </body>\n        </html>\n        ";
});
$app->get("/price_parcel", function () {
    $my_parcel = new Parcel($_GET['height'], $_GET['length'], $_GET['width'], $_GET['weight']);
    $size = $my_parcel->volume();
    $ship_weight = $my_parcel->costToShip();
    if ($size != 0 && $ship_weight != 0) {
        return "<h3>A parcel with a volume of {$size} inches, will cost \${$ship_weight} to ship.</h3>";
    } else {
        return "<h3>Error: One or more fields were blank</h3>";
    }
});
return $app;
Ejemplo n.º 7
0
        $this->weight = $changed_weight;
    }
    function getWeight()
    {
        return $this->weight;
    }
    function getVolume()
    {
        return $this->volume;
    }
}
$weight = $_GET["weight"];
$calculator_length = $_GET["length"];
$calculator_width = $_GET["width"];
$calculator_height = $_GET["height"];
$new_parcel = new Parcel($weight);
$new_parcel->volume($calculator_length, $calculator_width, $calculator_height);
?>

<html>
  <head>
    <title></title>
  </head>
  <body>
    <?php 
echo "<h1>" . $new_parcel->getWeight() . "</h1>";
echo "<h1>" . $new_parcel->getVolume() . "</h1>";
?>

  </body>
</html>
Ejemplo n.º 8
0
        $this->height = $new_height;
    }
    function getHeight()
    {
        return $this->height;
    }
    function setWeight($new_weight)
    {
        $this->weight = $new_weight;
    }
    function getWeight()
    {
        return $this->weight;
    }
}
$user_parcel = new Parcel($_GET["length"], $_GET["width"], $_GET["height"], $_GET["weight"]);
?>

<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
  <title>Parcel Results!</title>
</head>
<body>
  <h1>Here are the results of your parcel inqury</h1>
  <?php 
echo $user_parcel->getLength();
echo $user_parcel->getWidth();
echo $user_parcel->getHeight();
echo $user_parcel->getWeight();
Ejemplo n.º 9
0

<!DOCTYPE html>
<html>
<head>
    <title>Send a parcel</title>
</head>
<body>
    <h1>Parcel site!</h1>
    <ul>
        <?php 
$parcel_weight = $_GET["weight"];
$parcel_height = $_GET["height"];
$parcel_width = $_GET["width"];
$parcel_length = $_GET["length"];
$new_parcel = new Parcel($parcel_weight, $parcel_height, $parcel_width, $parcel_length);
$get_volume = $new_parcel->volume();
$get_cost = $new_parcel->costToShip();
if (empty($parcel_weight) || empty($parcel_height) || empty($parcel_width) || empty($parcel_length)) {
    echo "please fill all form fields with numeric values";
} else {
    echo "<p> Weight: " . $parcel_weight . "</p>";
    echo "<p> Height: " . $parcel_height . "</p>";
    echo "<p> Width: " . $parcel_width . "</p>";
    echo "<p> Length: " . $parcel_length . "</p>";
    echo "<p> Volume: " . $get_volume . "</p>";
    echo "<p> Cost to Ship: " . $get_cost . "</p>";
}
?>
    </ul>
</body>
Ejemplo n.º 10
0
        $this->height = $newHeight;
    }
    function getHeight()
    {
        return $this->height;
    }
    function setWeight($newWeight)
    {
        $this->weight = $newWeight;
    }
    function getWeight()
    {
        return $this->weight;
    }
}
$my_parcel = new Parcel($_GET["width"], $_GET["length"], $_GET["height"], $_GET["weight"]);
?>

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
    <title>Shipping Cost</title>
</head>
<body>
    <div class="container">
    <?php 
$shippingCost = $my_parcel->costToShip();
$parcelWidth = $my_parcel->getWidth();
$parcelLength = $my_parcel->getLength();
$parcelHeight = $my_parcel->getHeight();
Ejemplo n.º 11
0
    function getWeight()
    {
        return $this->weight;
    }
    function volume()
    {
        return $this->height * $this->weight * $this->width;
    }
    function callToShip()
    {
        $floated_shipping = (double) $this->weight * 1000 / $this->height;
        $formatted_shipping = number_format($floated_shipping, 2);
        return $formatted_shipping;
    }
}
$new_parcel = new Parcel();
$new_parcel->setHeight($height);
$new_parcel->setWidth($width);
$new_parcel->setWeight($weight);
?>

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title></title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.5/css/materialize.min.css">
  </head>
  <body>
    <div class="container">
      <ul>
Ejemplo n.º 12
0
    }
}
setlocale(LC_MONETARY, 'en_US');
// Adds locaation info for monetry value
$isParcel = false;
$error = "";
if (empty($_GET['length']) || is_nan($_GET['length'])) {
    $error = "length";
} elseif (empty($_GET['width']) || is_nan($_GET['width'])) {
    $error = "width";
} elseif (empty($_GET['height']) || is_nan($_GET['height'])) {
    $error = "height";
} elseif (empty($_GET['weight']) || is_nan($_GET['weight'])) {
    $error = "weight";
} else {
    $your_parcel = new Parcel($_GET['length'], $_GET['width'], $_GET['height'], $_GET['weight']);
    $isParcel = true;
}
?>

<html>
    <head>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
        <title>Your Parcel</title>
        <style media="screen">
            .hidden {
                display: none;
            }
        </style>
    </head>
    <body>
Ejemplo n.º 13
0
//   $w = $object->getWidth();
//   $l = $object->getLength();
//   $v = $h * $w * $l;
//   return $v;
// }
?>

<!DOCTYPE html>
<html>
<head>
    <title>Pricing</title>
</head>
<body>
    <h1>Here is yo shipping cost</h1>
    <?php 
$object = new Parcel($_GET["height"], $_GET["length"], $_GET["width"], $_GET["weight"]);
$object_volume = $object->volume();
$object_weight = $object->getWeight();
$finalPrice = $object->totalPrice();
$object_height = $object->getHeight();
$object_width = $object->getWidth();
$object_length = $object->getLength();
if ($object_volume == 0 || $object_weight == 0) {
    echo "Please make sure all fields are completed.";
}
?>
    <p>Volume of package: <?php 
echo $object_volume . " square inches" . " (" . $object_height . "in x " . $object_length . "in x " . $object_width . "in)";
?>
</p>
    <p>Weight: <?php 
<?php

class Parcel
{
    public $weight;
    public $destinationAddress;
    public $destinationCountry;
    public function setWeight($weight)
    {
        echo "weight set to: " . $weight . "\n";
        $this->weight = $weight;
        return $this;
    }
    public function setCountry($country)
    {
        echo "destination country is: " . $country . "\n";
        $this->destinationCountry = $country;
        return $this;
    }
}
//end of Parcel class
$myparcel = new Parcel();
$myparcel->setWeight(5)->setCountry('Peru');
Ejemplo n.º 15
0
<?php

$form_weight = $_GET["weight"];
$form_length = $_GET["length"];
$form_width = $_GET["width"];
$form_height = $_GET["height"];
$valid_parcel = true;
if ($form_weight <= 0 || $form_length <= 0 || $form_width <= 0 || $form_height <= 0) {
    $valid_parcel = false;
}
$user_parcel = new Parcel($form_weight, $form_length, $form_width, $form_height);
class Parcel
{
    private $weight;
    private $length;
    private $width;
    private $height;
    function __construct($weight, $length, $width, $height)
    {
        $this->weight = $weight;
        $this->length = $length;
        $this->width = $width;
        $this->height = $height;
    }
    function costToShip()
    {
        $formatted_price = number_format($this->getVolume() / 100, 2);
        return $formatted_price;
    }
    //getters and setters
    function setWeight($new_weight)
Ejemplo n.º 16
0
          </div>
          <div class="form-group">
            <label for="height">Enter the Height: </label>
            <input id="height" name="height" class="form-control" type="text">
          </div>
          <div class="form-group">
            <label for="weight">Enter the Weight: </label>
            <input id="weight" name="weight" class="form-control" type="text">
          </div>
          <button type="submit" class="btn">Submit</button>
        </form>
      </div>
    </body>';
});
$app->get('/parcel', function () {
    $first_parcel = new Parcel($_GET["length"], $_GET["width"], $_GET["height"], $_GET["weight"]);
    $first_parcel->setLength($_GET["length"]);
    $first_parcel->setWidth($_GET["width"]);
    $first_parcel->setHeight($_GET["height"]);
    ?>
      <title>Answers</title>

      <h1> Here are the answers below: </h1>

<?php 
    $first_parcel_length = $first_parcel->getLength();
    if ($first_parcel->getlength() == 0) {
        echo "<p>Length: A number please!</p>";
    } else {
        echo "<p>Length: {$first_parcel_length} (ft)</p>";
    }
        return $this->weight;
    }
    function setWeight($weight)
    {
        $this->weight = $weight;
    }
    function volume()
    {
        return $this->length * $this->width * $this->height;
    }
    function costToShip()
    {
        return $this->height + $this->width + ($this->length + $this->weight);
    }
}
$shoes = new Parcel(0, 0, 0, 0);
$shoes->setLength($_GET["length"]);
$shoes->setWidth($_GET["width"]);
$shoes->setHeight($_GET["height"]);
$shoes->setWeight($_GET["weight"]);
?>
<!DOCTYPE html>
<head>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
    <title>Parcel shipping cost</title>
</head>
<body>
    <div class="container">
        <h1>Shipping cost:</h1>
        <?php 
if (empty($shoes->getLength()) || empty($shoes->getWidth()) || (empty($shoes->getHeight()) || empty($shoes->getWeight()))) {
Ejemplo n.º 18
0
    function setHeight($parcel_height)
    {
        $this->height = $parcel_height;
    }
    // Volume calculator
    function volume()
    {
        return $this->length * $this->width * $this->height;
    }
    // Calculate the cost to ship
    function costToShip()
    {
        return $this->weight * 0.8;
    }
}
$usrPackage = new Parcel($_GET["weight"], $_GET["length"], $_GET["width"], $_GET["height"], $_GET["carrier"]);
?>

<!DOCTYPE html>
<html>
<head>
      <title>Shipping Calculator</title>
</head>
<body>
   <h1>Ship Stuff</h1>
   <ul>
        <?php 
$shippingPrice = $usrPackage->costToShip();
$packageVolume = $usrPackage->volume();
echo "<li> Package:</li>";
echo "<ul>";
Ejemplo n.º 19
0
        $this->weight = $newWeight;
    }
    function getWeight()
    {
        return $this->weight;
    }
    function volume()
    {
        return $this->height * $this->width * $this->length;
    }
    function costToShip()
    {
        return 0.0015 * ($this->volume() * $this->weight);
    }
}
$partyParcel = new Parcel($_GET["height"], $_GET["width"], $_GET["length"], $_GET["weight"]);
?>

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
    <title>PACKAGE INFO</title>
</head>
<body>
    <?php 
if (empty($partyParcel->getHeight()) || empty($partyParcel->getWidth()) || empty($partyParcel->getLength()) || empty($partyParcel->getWeight())) {
    echo "You missed a parameter";
} else {
    echo "<h1>HEIGHT: " . $partyParcel->getHeight() . "</h1>";
    echo "<h1>WIDTH: " . $partyParcel->getWidth() . "</h1>";
Ejemplo n.º 20
0
    }
    function getWeight()
    {
        return $this->weight;
    }
    function volume()
    {
        return $this->length * $this->width * $this->height;
    }
    function costToShip()
    {
        $curVolume = $this->volume();
        return $curVolume * 1 + $this->weight * 1;
    }
}
$parcel = new Parcel($_GET["length"], $_GET["width"], $_GET["height"], $_GET["weight"]);
?>


<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>
    <form action="parcel.php">
      <label for="length">Length</label>
      <input id="length" name="length" type="number">
      <label for="width">Width</label>
      <input id="width" name="width" type="number">
Ejemplo n.º 21
0
        die("{$property} is not an integer");
    } elseif ($_GET[$property] == "") {
        die("{$property} was not defined");
    }
}
?>

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Parcel Printout</title>
  </head>
  <body>
    <?php 
$customer_parcel = new Parcel($_GET["length"], $_GET["width"], $_GET["height"], $_GET["weight"]);
$length = $customer_parcel->getLength();
$width = $customer_parcel->getWidth();
$height = $customer_parcel->getHeight();
$weight = $customer_parcel->getWeight();
$volume = $customer_parcel->volume();
$cost = $customer_parcel->costToShip();
echo "<p> Parcel length: {$length} </P>";
echo "<p> Parcel width: {$width} </P>";
echo "<p> Parcel height: {$height} </P>";
echo "<p> Parcel weight: {$weight} </P>";
echo "<p> Parcel volume: {$volume} </P>";
echo "<p> Parcel cost: \${$cost} </P>";
?>
  </body>
</html>
Ejemplo n.º 22
0
            } else {
                $shipping_type_cost = 20.0;
            }
        }
        if ($this->volume() < 50) {
            return $shipping_type_cost = $shipping_type_cost + $shipping_range_by_volume[0];
        } else {
            if ($this->volume() >= 50 && $this->volume() < 100) {
                return $shipping_type_cost = $shipping_type_cost + $shipping_range_by_volume[1];
            } else {
                return $shipping_type_cost = $shipping_type_cost + $shipping_range_by_volume[2];
            }
        }
    }
}
$a = new Parcel($_GET["length"], $_GET["width"], $_GET["height"], $_GET["weight"]);
?>

<!DOCTYPE html>
<html>

<head>
  <title></title>

</head>
<body>
  <ul>
<?php 
$theString = "<li> The Parcel Length is: ";
$theString .= $a->getLength();
$theString .= "</li>";