Example #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;
}
Example #2
0
                         $value = updatePrevisionStateWithDeliveryType($_GET['deliveryType']);
                     } else {
                         if (isset($_GET['updateAllPrevisionsStates'])) {
                             $value = updateAllPrevisionsStates();
                         } else {
                             if (isset($_GET['acceptStateChange'])) {
                                 $value = acceptStateChange($json);
                             } else {
                                 if (isset($_GET['weeksBySeason'])) {
                                     $value = updateWeeksBySeason($json);
                                 } else {
                                     if (isset($_GET['listForProduction'])) {
                                         $value = getPrevisions(null, null, $expand, true, null, $_GET['sellerCode'], $_GET['offset'], $json);
                                     } else {
                                         if (isset($_GET['listHistoric'])) {
                                             $value = getPrevisions(null, null, $expand, null, true, $_GET['sellerCode'], $_GET['offset'], $json);
                                         } else {
                                             $value = savePrevision($json);
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
 //return JSON array
 exit(json_encode($value));
Example #3
0
                    // deprecated - use with POST
                    $value = getPrevisions(null, null, $expand, null, true, $_GET['sellerCode']);
                } else {
                    if (isset($_GET['expand']) && $_GET['expand'] == 'NONE') {
                        $value = getPrevisionsBasic();
                    } else {
                        if (isset($_GET['checkAllClothsCutted'])) {
                            $value = checkAllClothsCutted($_GET['previsionId']);
                        } else {
                            if (isset($_GET['updateAllPrevisionsStates'])) {
                                $value = updateAllPrevisionsStates($_GET['updateClothId'], $_GET['limit'], $_GET['offset']);
                            } else {
                                if (isset($_GET['updatePrevisionState'])) {
                                    $value = updatePrevisionState($_GET['updateClothId']);
                                } else {
                                    if (isset($_GET['weeksBySeason'])) {
                                        $value = getWeeksBySeason($_GET['weeksBySeason']);
                                    } else {
                                        $value = getPrevisions(null, $designed, $expand, null);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
//return JSON array
exit(json_encode($value));