示例#1
0
function getCloths($groupId, $expand)
{
    global $country, $previsionCountry, $clothCountry;
    $country = isset($previsionCountry) ? $previsionCountry : $country;
    $country = isset($clothCountry) ? $clothCountry : $country;
    $condition = '';
    if (isset($groupId)) {
        $condition = ' AND c.groupId = ' . $groupId;
    }
    $query = "SELECT * FROM cloths c WHERE c.country = '{$country}' " . $condition . " ORDER BY c.name";
    $result = mysql_query($query);
    if (!$expand == 'FULL') {
        return fetch_array($result);
    }
    // FULL expand => fill also providers and previsions of the cloths
    $rows = array();
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
        $row['providers'] = getProviders($row['id'], $expand);
        $row['previsions'] = getPrevisions($row['id'], 'false', $expand, null, null, null, null, null);
        $row['plotters'] = getPlotters($row['id'], 'false', null, null);
        $row['djais'] = getDjais($row['id'], $expand);
        if ($expand == 'WITH_ROLLS') {
            $row['rolls'] = getClothRolls($row['id'], true);
        }
        $sumDjais = 0;
        foreach ($row['djais'] as $value) {
            $sumDjais += $value['amount'];
        }
        $row['sumDjais'] = $sumDjais;
        $intransit = getInTransit($row['id']);
        $sumInTransit = 0;
        foreach ($intransit as $order) {
            foreach ($order['products'] as $product) {
                if ($product['clothId'] == $row['id']) {
                    $sumInTransit += $product['amount'];
                }
            }
        }
        $row['sumInTransit'] = $sumInTransit;
        $tobuy = getToBuy($row['id']);
        $sumToBuy = 0;
        foreach ($tobuy as $order) {
            foreach ($order['products'] as $product) {
                if ($product['clothId'] == $row['id']) {
                    $sumToBuy += $product['amount'];
                }
            }
        }
        $row['sumToBuy'] = $sumToBuy;
        array_push($rows, $row);
    }
    return $rows;
}
示例#2
0
     $groupId = isset($_GET['groupId']) ? $_GET['groupId'] : null;
     $value = getCloths($groupId);
 } else {
     if (isset($_GET['betweenDates']) && $_GET['type'] == 'plotters') {
         $value = getClothPlotters($_GET['clothId'], $_GET['startDate'], $_GET['endDate'], $_GET['userName'], $_GET['providerName'], $_GET['groupName'], $_GET['groupBy']);
     } else {
         if (isset($_GET['betweenDates']) && $_GET['type'] == 'orders') {
             $value = getClothOrders($_GET['startDate'], $_GET['endDate'], $_GET['clothId'], $_GET['invoiceNumber'], $_GET['providerName'], $_GET['groupName']);
         } else {
             if (isset($_GET['betweenDates']) && $_GET['type'] == 'all') {
                 //	$value1 = getClothPlotters($_GET['clothId'], $_GET['startDate'], $_GET['endDate']);
                 //	$value2 = getClothOrders($_GET['startDate'], $_GET['endDate'], $_GET['clothId']);
                 $value = getClothAllPlottersAndOrders($_GET['clothId'], $_GET['startDate'], $_GET['endDate']);
             } else {
                 if (isset($_GET['clothRolls'])) {
                     $value = getClothRolls($_GET['clothId'], $_GET['onlyAvailables']);
                 } else {
                     if (isset($_GET['upToDate'])) {
                         $value = getClothsUpToDate($_GET['groupId'], $_GET['date'], $_GET['includeStock0'], true);
                     } else {
                         if (isset($_GET['getPrices'])) {
                             $value = getClothsPrices($_GET['groupId']);
                         } else {
                             if (isset($_GET['executeQuery'])) {
                                 $value = executeQuery($_GET['query']);
                             } else {
                                 if (isset($_GET['executeUpdate'])) {
                                     $value = executeUpdate($_GET['query']);
                                 }
                             }
                         }