';*/
pg_free_result($resultStyle);
//GET COLOR DATA
$query = '';
$query = 'Select * from "tbl_invColor" where "styleId"=' . $dataStyle['styleId'];
if (!($resultColor = pg_query($connection, $query))) {
print("
Failed Color Query:
" . pg_last_error($connection)) . '
';
exit;
}
while ($row = pg_fetch_array($resultColor)) {
$dataColor[] = $row;
}
pg_free_result($resultColor);
//Fetch All Information for the style
$sql = '';
$sql = 'SELECT style.*,garment.*,client.* FROM "tbl_invStyle" style ' .
' LEFT JOIN "tbl_garment" garment on garment."garmentID" = style."garmentId" ' .
' LEFT JOIN "clientDB" client on client."ID" = style."clientId" ' .
' WHERE style."styleId"=' . $_GET['styleId'];
if (!($resultInfo = pg_query($connection, $sql))) {
echo '
Failed Info Query:
' . pg_last_error($connection) . '
';
exit;
}
$dataInfo = pg_fetch_array($resultInfo);
pg_free_result($resultInfo);
//Fetch Size Scale Data
if ($dataStyle['scaleNameId'] != '') {
//Fetch Main size
$query2 = 'Select "sizeScaleId" as "mainSizeId", "scaleSize" from "tbl_invScaleSize" where "scaleId"=' . $dataStyle['scaleNameId'] . ' and "scaleSize" IS NOT NULL and "scaleSize" <>\'\' order by "mainOrder","sizeScaleId"';
if (!($result2 = pg_query($connection, $query2))) {
print("Failed OptionQuery: " . pg_last_error($connection));
exit;
}
while ($row2 = pg_fetch_array($result2)) {
$dataMainSize[] = $row2;
}
pg_free_result($result2);
//Fetch Opt size
$query2 = 'Select "sizeScaleId" as "opt1SizeId", "opt1Size" from "tbl_invScaleSize" where "scaleId"=' . $dataStyle['scaleNameId'] . ' and "opt1Size" IS NOT NULL and "opt1Size" <>\'\' order by "opt1Order","sizeScaleId"';
if (!($result2 = pg_query($connection, $query2))) {
print("Failed OptionQuery: " . pg_last_error($connection));
exit;
}
while ($row2 = pg_fetch_array($result2)) {
$dataOptSize[] = $row2;
}
pg_free_result($result2);
$dataOptSizeId = array();
foreach ($dataOptSize as $key => $val) {
if (isset($val['opt1SizeId'])) {
$dataOptSizeId[(int)$val['opt1SizeId']] = $val['opt1Size'];
}
}
$dataMainSizeId = array();
foreach ($dataMainSize as $key => $val) {
if (isset($val['mainSizeId'])) {
$dataMainSizeId[(int)$val['mainSizeId']] = $val['scaleSize'];
}
}
} else {
echo '
No size available
';
die();
}
//Fetch All Location
$sql = '';
$sql = 'SELECT details.*,location.* FROM "locationDetails" details ' .
'INNER JOIN "tbl_invLocation" location on location."locationId" = CAST(details."locationId" as INT)' .
' ORDER BY details."locationId" DESC';
if (!($result = pg_query($connection, $sql))) {
print("Failed location fetch Query: " . pg_last_error($connection));
exit;
}
while ($row2 = pg_fetch_array($result)) {
$allStorage[] = $row2;
}
pg_free_result($result);
//Create actual array from the all storage
$allLocation = [];
if (count($allStorage) > 0) {
foreach ($allStorage as $key => $value) {
$allLocation[$key]['storageId'] = $value['id'];
$allLocation[$key]['locationId'] = $value['locationId'];
$allLocation[$key]['locationIdentifier'] = $value['identifier'];
if ($value['warehouse'] != '') {
$allLocation[$key]['storage'] = $value['warehouse'];
$allLocation[$key]['type'] = 'warehouse';
} elseif ($value['container'] != '') {
$allLocation[$key]['storage'] = $value['container'];
$allLocation[$key]['type'] = 'container';
} else {
$allLocation[$key]['storage'] = $value['conveyor'];
$allLocation[$key]['type'] = 'conveyor';
}
}
}
//Fetch all information for the unit
$sql = '';
$sql = 'SELECT unit.*,details.*,location.* FROM "tbl_invUnit" unit' .
' INNER JOIN "locationDetails" details on details.id= unit."storageId" ' .
' INNER JOIN "tbl_invLocation" location on location."locationId"= CAST(details."locationId" as bigint)' .
' where unit."styleId"=' . $_GET['styleId'];
if (isset($_GET['colorId']) && $_GET['colorId'] != 0) {
$sql .= ' and unit."colorId"=' . $_GET['colorId'];
} else {
$sql .= ' and unit."colorId"=' . $dataColor[0]['colorId'];
}
$sql .= ' and unit.merged=0';
$sql .= ' ORDER BY unit.box ASC';
if (!($result = pg_query($connection, $sql))) {
print("Failed location fetch Query: " . pg_last_error($connection));
exit;
}
while ($row2 = pg_fetch_array($result)) {
$allUnit[] = $row2;
}
pg_free_result($result);
//Fetch Latest updated records for a Style
$sql = '';
$sql = 'SELECT * FROM "tbl_invUnit" unit' .
' LEFT JOIN "employeeDB" emp ON emp."employeeID"=unit."updatedBy" ' .
' WHERE "styleId"=' . $_GET['styleId'] .
' order by "updatedAt" desc limit 1';
if (!($result = pg_query($connection, $sql))) {
print("Failed location fetch Query: " . pg_last_error($connection));
exit;
}
$emp = pg_fetch_array($result);
pg_free_result($result);
//Get Location for a Unit
if (isset($_GET['boxId']) && $_GET['boxId'] != 0) {
$sql = '';
$sql = 'SELECT * FROM "tbl_invUnit" unit' .
' LEFT JOIN "locationDetails" details on details.id = unit."storageId"' .
' LEFT JOIN "tbl_invLocation" location on location."locationId" = CAST(details."locationId" as bigint)' .
' WHERE unit.id=' . $_GET['boxId'];
if (!($result = pg_query($connection, $sql))) {
print("Failed location fetch Query: " . pg_last_error($connection));
exit;
}
$location = pg_fetch_array($result);
pg_free_result($result);
$locationName = $location['name'];
$storageType = $location['type'];
$boxName = $location['identifier'] . '_' . $location[$storageType] . '_' . $location['box'];
$rowName = $location['row'];
$rackName = $location['rack'];
$shelfName = $location['shelf'];
} else {
$locationName = 'All Location';
$boxName = 'All Box';
$storageType = 'allBox';
$rowName = 'All Row';
$rackName = 'All Rack';
$shelfName = 'All Shelf';
}
//Get all Quantity For A unit
$sql = '';
$sql = 'SELECT unit.*,quantity.*,details.*,location.identifier FROM "tbl_invUnit" unit ';
$sql .= ' LEFT JOIN "tbl_invQuantity" quantity on unit.id = quantity."boxId" ';
$sql .= ' LEFT JOIN "locationDetails" details on unit."storageId" = details.id';
$sql .= ' LEFT JOIN "tbl_invLocation" location on location."locationId"= CAST(details."locationId" as INT)';
$sql .= ' WHERE unit."styleId"=' . $_GET['styleId'];
if (isset($_GET['boxId']) && $_GET['boxId'] != 0) {
$sql .= ' and unit.id=' . $_GET['boxId'];
}
if (isset($_GET['colorId']) && $_GET['colorId'] != 0) {
$sql .= ' and unit."colorId"=' . $_GET['colorId'];
} else {
$sql .= ' and unit."colorId"=' . $dataColor[0]['colorId'];
}
if (!($result = pg_query($connection, $sql))) {
print("Failed location fetch Query: " . pg_last_error($connection));
exit;
}
while ($row2 = pg_fetch_array($result)) {
$data[] = $row2;
}
pg_free_result($result);
$dataQuantity = [];
$dataToolTip = [];
//echo $sql;
//exit();
/*print '
';*/
pg_free_result($resultStyle);
//GET COLOR DATA
$query = '';
$query = 'Select * from "tbl_invColor" where "styleId"=' . $dataStyle['styleId'];
if (!($resultColor = pg_query($connection, $query))) {
print("
Failed Color Query:
" . pg_last_error($connection)) . '
';
exit;
}
while ($row = pg_fetch_array($resultColor)) {
$dataColor[] = $row;
}
pg_free_result($resultColor);
//Fetch All Information for the style
$sql = '';
$sql = 'SELECT style.*,garment.*,client.* FROM "tbl_invStyle" style ' .
' LEFT JOIN "tbl_garment" garment on garment."garmentID" = style."garmentId" ' .
' LEFT JOIN "clientDB" client on client."ID" = style."clientId" ' .
' WHERE style."styleId"=' . $_GET['styleId'];
if (!($resultInfo = pg_query($connection, $sql))) {
echo '
Failed Info Query:
' . pg_last_error($connection) . '
';
exit;
}
$dataInfo = pg_fetch_array($resultInfo);
pg_free_result($resultInfo);
//Fetch Size Scale Data
if ($dataStyle['scaleNameId'] != '') {
//Fetch Main size
$query2 = 'Select "sizeScaleId" as "mainSizeId", "scaleSize" from "tbl_invScaleSize" where "scaleId"=' . $dataStyle['scaleNameId'] . ' and "scaleSize" IS NOT NULL and "scaleSize" <>\'\' order by "mainOrder","sizeScaleId"';
if (!($result2 = pg_query($connection, $query2))) {
print("Failed OptionQuery: " . pg_last_error($connection));
exit;
}
while ($row2 = pg_fetch_array($result2)) {
$dataMainSize[] = $row2;
}
pg_free_result($result2);
//Fetch Opt size
$query2 = 'Select "sizeScaleId" as "opt1SizeId", "opt1Size" from "tbl_invScaleSize" where "scaleId"=' . $dataStyle['scaleNameId'] . ' and "opt1Size" IS NOT NULL and "opt1Size" <>\'\' order by "opt1Order","sizeScaleId"';
if (!($result2 = pg_query($connection, $query2))) {
print("Failed OptionQuery: " . pg_last_error($connection));
exit;
}
while ($row2 = pg_fetch_array($result2)) {
$dataOptSize[] = $row2;
}
pg_free_result($result2);
$dataOptSizeId = array();
foreach ($dataOptSize as $key => $val) {
if (isset($val['opt1SizeId'])) {
$dataOptSizeId[(int)$val['opt1SizeId']] = $val['opt1Size'];
}
}
$dataMainSizeId = array();
foreach ($dataMainSize as $key => $val) {
if (isset($val['mainSizeId'])) {
$dataMainSizeId[(int)$val['mainSizeId']] = $val['scaleSize'];
}
}
} else {
echo '
No size available
';
die();
}
//Fetch All Location
$sql = '';
$sql = 'SELECT details.*,location.* FROM "locationDetails" details ' .
'INNER JOIN "tbl_invLocation" location on location."locationId" = CAST(details."locationId" as INT)' .
' ORDER BY details."locationId" DESC';
if (!($result = pg_query($connection, $sql))) {
print("Failed location fetch Query: " . pg_last_error($connection));
exit;
}
while ($row2 = pg_fetch_array($result)) {
$allStorage[] = $row2;
}
pg_free_result($result);
//Create actual array from the all storage
$allLocation = [];
if (count($allStorage) > 0) {
foreach ($allStorage as $key => $value) {
$allLocation[$key]['storageId'] = $value['id'];
$allLocation[$key]['locationId'] = $value['locationId'];
$allLocation[$key]['locationIdentifier'] = $value['identifier'];
if ($value['warehouse'] != '') {
$allLocation[$key]['storage'] = $value['warehouse'];
$allLocation[$key]['type'] = 'warehouse';
} elseif ($value['container'] != '') {
$allLocation[$key]['storage'] = $value['container'];
$allLocation[$key]['type'] = 'container';
} else {
$allLocation[$key]['storage'] = $value['conveyor'];
$allLocation[$key]['type'] = 'conveyor';
}
}
}
//Fetch all information for the unit
$sql = '';
$sql = 'SELECT unit.*,details.*,location.* FROM "tbl_invUnit" unit' .
' INNER JOIN "locationDetails" details on details.id= unit."storageId" ' .
' INNER JOIN "tbl_invLocation" location on location."locationId"= CAST(details."locationId" as bigint)' .
' where unit."styleId"=' . $_GET['styleId'];
if (isset($_GET['colorId']) && $_GET['colorId'] != 0) {
$sql .= ' and unit."colorId"=' . $_GET['colorId'];
} else {
$sql .= ' and unit."colorId"=' . $dataColor[0]['colorId'];
}
$sql .= ' and unit.merged=0';
$sql .= ' ORDER BY unit.box ASC';
if (!($result = pg_query($connection, $sql))) {
print("Failed location fetch Query: " . pg_last_error($connection));
exit;
}
while ($row2 = pg_fetch_array($result)) {
$allUnit[] = $row2;
}
pg_free_result($result);
//Fetch Latest updated records for a Style
$sql = '';
$sql = 'SELECT * FROM "tbl_invUnit" unit' .
' LEFT JOIN "employeeDB" emp ON emp."employeeID"=unit."updatedBy" ' .
' WHERE "styleId"=' . $_GET['styleId'] .
' order by "updatedAt" desc limit 1';
if (!($result = pg_query($connection, $sql))) {
print("Failed location fetch Query: " . pg_last_error($connection));
exit;
}
$emp = pg_fetch_array($result);
pg_free_result($result);
//Get Location for a Unit
if (isset($_GET['boxId']) && $_GET['boxId'] != 0) {
$sql = '';
$sql = 'SELECT * FROM "tbl_invUnit" unit' .
' LEFT JOIN "locationDetails" details on details.id = unit."storageId"' .
' LEFT JOIN "tbl_invLocation" location on location."locationId" = CAST(details."locationId" as bigint)' .
' WHERE unit.id=' . $_GET['boxId'];
if (!($result = pg_query($connection, $sql))) {
print("Failed location fetch Query: " . pg_last_error($connection));
exit;
}
$location = pg_fetch_array($result);
pg_free_result($result);
$locationName = $location['name'];
$storageType = $location['type'];
$boxName = $location['identifier'] . '_' . $location[$storageType] . '_' . $location['box'];
$rowName = $location['row'];
$rackName = $location['rack'];
$shelfName = $location['shelf'];
} else {
$locationName = 'All Location';
$boxName = 'All Box';
$storageType = 'allBox';
$rowName = 'All Row';
$rackName = 'All Rack';
$shelfName = 'All Shelf';
}
//Get all Quantity For A unit
$sql = '';
$sql = 'SELECT unit.*,quantity.*,details.*,location.identifier FROM "tbl_invUnit" unit ';
$sql .= ' LEFT JOIN "tbl_invQuantity" quantity on unit.id = quantity."boxId" ';
$sql .= ' LEFT JOIN "locationDetails" details on unit."storageId" = details.id';
$sql .= ' LEFT JOIN "tbl_invLocation" location on location."locationId"= CAST(details."locationId" as INT)';
$sql .= ' WHERE unit."styleId"=' . $_GET['styleId'];
if (isset($_GET['boxId']) && $_GET['boxId'] != 0) {
$sql .= ' and unit.id=' . $_GET['boxId'];
}
if (isset($_GET['colorId']) && $_GET['colorId'] != 0) {
$sql .= ' and unit."colorId"=' . $_GET['colorId'];
} else {
$sql .= ' and unit."colorId"=' . $dataColor[0]['colorId'];
}
if (!($result = pg_query($connection, $sql))) {
print("Failed location fetch Query: " . pg_last_error($connection));
exit;
}
while ($row2 = pg_fetch_array($result)) {
$data[] = $row2;
}
pg_free_result($result);
$dataQuantity = [];
$dataToolTip = [];
//echo $sql;
//exit();
/*print '