1

Estoy realizando un formato PDF donde todos los item que esten por debajo de reorder_level (minimo) y con status = 1, son los que se mostraran en el documento.

Este es el codigo donde estoy haciendo una estructura json.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <?php echo'<title>Inventory To Reorder</title>';?>
</head>

<body onload="window.print()">
  <?php echo '<img src="http://localhost/WareHouse/assets/img/logo.png" style="position: absolute; top: 0; left: 0; height:6%; width:25%; margin-top:40px; margin-left:40px;"/>';?>
    <?php  echo '<center style="margin-top:120px; font-size:14pt;"><strong>Inventory To Reorder<strong></center>';?>
  <?php  echo '<label><center>____________________________________________________________________________</center></label><br>';?>
<?php

require_once('apis/connection.php');
    if(isset($_GET['status']))
    {
      $status = $_GET["status"];
      //Trae todos los item que esten por debajo de su minimo en stock.
      $connection = new MySqlServerConnection();
      $query = 'SELECT i.description_item,i.quantity,u.name_unit,i.reorder_Level,i.target_Stock,l.name_location,i.commentt,io.quantity_s
      FROM inventory_list AS i
      INNER JOIN unit_mesurement AS u ON id_unit = fkUnit
      INNER JOIN locatiON AS l on id_location = fkLocation
      INNER JOIN inventory_output as io on id_output = fkInventory
      WHERE i.quantity <= reorder_Level AND i.status = 1';

      $result = $connection->executeQuery($query,array($status));
      if ($result > 0) {
  ?>
  <center>
            <table class="table table-striped xd" border="1px;">
                <thead>
                <tr>
                    <th style="width: 3%;">Description</th>
                    <th style="width: 3%;">Quantity</th>
                    <th style="width: 3%;">Name Unit</th>
                    <th style="width: 3%;">Reorder Level</th>
                    <th style="width: 3%;">Target Stock</th>
                    <th style="width: 3%;">Area</th>
                    <th style="width: 3%;">Comment</th>
                </tr>
                </thead>
                <?php
                $arraycount=count($result);
                $i=0;
                $total=0;
                while ($i < $arraycount)
                {
                  ?>
                            <tr>
                             <td><center><?php echo $result[$i]['description_item']; ?></td>
                             <td><p style="color:red;" ><?php echo $result[$i]['quantity']; ?></p></td>
                             <td><?php echo $result[$i]['name_unit']; ?></td>
                             <td><?php echo $result[$i]['reorder_Level']; ?></td>
                             <td><?php echo $result[$i]['target_Stock']; ?></td>
                             <td><?php echo $result[$i]['name_location']; ?></td>
                             <td><?php echo $result[$i]['commentt']; ?></center></td>
                            </tr>
                <?php $i++;
              }
                ?>
            </table><br><br>
  </center>
      <?php
      }
    }
  ?>
</body>

Este es el resultado final, esto funciona perfectamente. No tengo ningun problema. introducir la descripción de la imagen aquí

En mi query, estoy trayendo tambien quantity_s(cantidad de salida) y lo que necesito es poner if de rangos de:

  if ((quantity_s >=  100)&&(quantity_s <= 200)) {
    $text = "Entre 100 y 200";

     if ((quantity_s >=  300)&&(quantity_s <= 500)) {
      $text = "Entre 300 y 500";
    }
  }

Necesito por ejemplo en mi quantity_s tengo 1500 se encuentra dentro del rango anterior, y en una nueva columna Usage, poner el letrero anterior.

       <th style="width: 3%;">Quantity</th>
        <th style="width: 3%;">Usage</th>
        <th style="width: 3%;">Name Unit</th>
        <th style="width: 3%;">Reorder Level</th>
        <th style="width: 3%;">Target Stock</th>
        <th style="width: 3%;">Area</th>
        <th style="width: 3%;">Comment</th>

Donde asigno los valores lo estoy poniendo asi:

 <td><?php echo $result[$i][$text]; ?></td>

Me manda el siguiente error, cuando genero el PDF.

Notice: Undefined variable: text in
C:\xampp\htdocs\WareHouse\reporte.php
on line 67
Notice: Undefined index: in
C:\xampp\htdocs\WareHouse\reporte.php
on line 67

1 respuesta 1

1

puedes hacerlo asi: utilizamos un switch true y le damos valores a comparar puedes usar if pero se me hace mas legible asi!

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <?php echo'<title>Inventory To Reorder</title>';?>
    </head>

    <body onload="window.print()">
      <?php echo '<img src="http://localhost/WareHouse/assets/img/logo.png" style="position: absolute; top: 0; left: 0; height:6%; width:25%; margin-top:40px; margin-left:40px;"/>';?>
        <?php  echo '<center style="margin-top:120px; font-size:14pt;"><strong>Inventory To Reorder<strong></center>';?>
      <?php  echo '<label><center>____________________________________________________________________________</center></label><br>';?>
    <?php

    require_once('apis/connection.php');
        if(isset($_GET['status']))
        {
          $status = $_GET["status"];
          //Trae todos los item que esten por debajo de su minimo en stock.
          $connection = new MySqlServerConnection();
          $query = 'SELECT i.description_item,i.quantity,u.name_unit,i.reorder_Level,i.target_Stock,l.name_location,i.commentt,io.quantity_s
          FROM inventory_list AS i
          INNER JOIN unit_mesurement AS u ON id_unit = fkUnit
          INNER JOIN locatiON AS l on id_location = fkLocation
          INNER JOIN inventory_output as io on id_output = fkInventory
          WHERE i.quantity <= reorder_Level AND i.status = 1';

          $result = $connection->executeQuery($query,array($status));
          if ($result > 0) {
      ?>
      <center>
                <table class="table table-striped xd" border="1px;">
                    <thead>
                    <tr>
                        <th style="width: 3%;">Description</th>
                        <th style="width: 3%;">Quantity S</th>
                        <th style="width: 3%;">Quantity</th>
                        <th style="width: 3%;">Name Unit</th>
                        <th style="width: 3%;">Reorder Level</th>
                        <th style="width: 3%;">Target Stock</th>
                        <th style="width: 3%;">Area</th>
                        <th style="width: 3%;">Comment</th>
                    </tr>
                    </thead>
                    <?php
                    $arraycount=count($result);
                    $i=0;
                    $total=0;
                    while ($i < $arraycount)
                    {
                      ?>
                                <tr>
                                 <td><center><?php echo $result[$i]['description_item']; ?></td>
<td><p style="color:red;" >
    <?php 
    $qs = $result[$i]['quantity_S'];
    switch (true) {
       case ($qs >= 1000 && $qs <= 2000) :
         echo "{$qs} se encuentra dentro del rango anterior de 1000 a 2000";
        break;

        case ($qs >= 2001 && $qs <= 3000) :
         echo "{$qs} se encuentra dentro del rango anterior de 2001 a 3000";
        break;

        case ($qs >= 3001 && $qs <= 4000) :
         echo "{$qs} se encuentra dentro del rango anterior de 3001 a 4000";
        break;
    }
     ?>
    </p></td>
                                 <td><p style="color:red;" ><?php echo $result[$i]['quantity']; ?></p></td>
                                 <td><?php echo $result[$i]['name_unit']; ?></td>
                                 <td><?php echo $result[$i]['reorder_Level']; ?></td>
                                 <td><?php echo $result[$i]['target_Stock']; ?></td>
                                 <td><?php echo $result[$i]['name_location']; ?></td>
                                 <td><?php echo $result[$i]['commentt']; ?></center></td>
                                </tr>
                    <?php $i++;
                  }
                    ?>
                </table><br><br>
      </center>
          <?php
          }
        }
      ?>
    </body>
2
  • Gracias, tu respuesta me ayudo a mi problema, solo cambie el || por un &&. Todo funciona de acuerdo a la quantity_s.
    – cosito
    el 10 dic. 2018 a las 20:11
  • hahahhaaha sorry no me fije xD
    – Bryro
    el 10 dic. 2018 a las 20:12

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.