title: Compare numbers through a loop to set a status accordingly
body: <p>Let me change my question completely to explain myself better;</p>
  
  <p>I have an order;</p>
  
  <p><a href="https://i.stack.imgur.com/3mKpI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3mKpI.png" alt="enter image description here"></a></p>
  
  <p>An order have multiple order rows. Each order row has two fields; Quantity ordered, and quantity delivered.</p>
  
  <p>If <strong>all</strong> order rows' quantities delivered are the same as the quantity ordered, the entire order should get a status of '100% delivered'. </p>
  
  <p>If multiple or even one order row's quantities delivered <strong>does not match</strong> the quantities ordered the entire order should get a status of 'partly delivered'. </p>
  
  <p>If no order row have any deliveries (<strong>if all deliveries stands on 0</strong>) the status should be '0% delivered'.</p>
  
  <p>What I have so far looks only at the last order row of the entire order because all the previous rows gets overridden by the latest check. This is my code;</p>
  
  <pre><code>public function deliveryAction(Request $request, $id) {
      $em = $this-&gt;getDoctrine()-&gt;getManager();
      $order = $em-&gt;getRepository('QiBssBaseBundle:PmodOrder')-&gt;find($id);
  
      $orderRowsDelivered = $request-&gt;request-&gt;all();
  
      $delivered = "0%";
  
      foreach ($orderRowsDelivered['order_row_id'] as $orderRowId =&gt; $quantityDelivered) {
          if($quantityDelivered != '' || $quantityDelivered != null) {
              $orderRow = $em-&gt;getRepository("QiBssBaseBundle:PmodOrderRow")-&gt;find($orderRowId);
  
              $orderDelivered = new PmodDelivery();
  
              $orderDelivered-&gt;setOrderRow($orderRow);
              $orderDelivered-&gt;setQuantity($quantityDelivered);
              $orderDelivered-&gt;setTimeArrived(new \DateTime());
  
              $em-&gt;persist($orderDelivered);
              $em-&gt;flush();
  
              if($orderRow-&gt;getQuantityDelivered() &gt; 0 &amp;&amp; $orderRow-&gt;getQuantityDelivered() &lt; $orderRow-&gt;getQuantity()) {
                  $delivered = "partly";
              } elseif ($orderRow-&gt;getQuantityDelivered() == $orderRow-&gt;getQuantity()) {
                  $delivered = "100%";
              }                
          }
      }
  
      var_dump($delivered);exit;
  
      return new RedirectResponse ... ;
  }
  </code></pre>
  
  <p>Because as of this moment he looks at the last one with 10 and 8 in the example image, and give a status of 'partly', as soon as the 'quantity delivered' amounts is entered. But he should take all rows together.</p>
  
  <p>I hope this makes more sense.</p>