function appendExtraInfo($clothRows, $upToDate) { $result = array(); foreach ($clothRows as $row) { $row['previsions'] = getPrevisionsUpToDate($row['clothId'], $upToDate); $row['plotters'] = getPlotters($row['clothId'], 'false', null, $upToDate); $row['ordersInTransit'] = getInTransitUpToDate($row['clothId'], $upToDate); array_push($result, $row); } return $result; }
<?php // Get list of all users or one in particualr if the id is given include_once '../include/headers.php'; include_once '../include/dbutils.php'; include_once '../include/main.php'; include_once 'domain/plotters.php'; db_connect(); $cutted = isset($_GET['cutted']) ? $_GET['cutted'] : 'false'; $clothId = isset($_GET['clothId']) ? $_GET['clothId'] : null; if (isset($_GET['search'])) { $value = getPlotters($clothId, null, $_GET['search'], null); } else { if (isset($_GET['hasPlotterCuts'])) { $value = hasPlotterCuts($_GET['previsionId']); } else { $value = getPlotters($clothId, $cutted, null, null); } } //return JSON array exit(json_encode($value));
function fillClothDisponibility(&$clothsDisponibility, $clothId) { // check if we already have the values in the array $c = findClothById($clothId, $clothsDisponibility); if (!$c) { $c = new stdClass(); $c->id = $clothId; $sumInTransit = 0; $inTransitType = array(); foreach (getInTransit($clothId) as $order) { foreach ($order['products'] as $product) { if ($product['clothId'] == $clothId) { $sumInTransit += $product['amount']; // $inTransitType = $order['deliveryType']; $transit = new stdClass(); $transit->type = $order['deliveryType']; $transit->amount = $product['amount']; $transit->used = 0; array_push($inTransitType, $transit); } } } $c->mtsInTransit = $sumInTransit; $c->inTransitType = $inTransitType; // available stock (available in rolls - plotters) $providers = getProviders($clothId); $sumAvailable = 0; foreach ($providers as $provider) { $sumAvailable += $provider['stock']; } $plotters = getPlotters($clothId, 'false', null, null); $sumPlotters = 0; foreach ($plotters as $plotter) { $sumPlotters += $plotter['mtsDesign']; } $c->mtsAvailable = $sumAvailable; // - $sumPlotters; // we dont rest the plotters, we consider available if still in plotter $c->mtsPlotter = $sumPlotters; // extra info for the second iteration of ufa and uft set $c->totalUFA = 0; $c->totalUFT = 0; $c->sumNewUFA = 0; $c->sumNewUFT = 0; array_push($clothsDisponibility, $c); } }