613 lines
25 KiB
PHP
613 lines
25 KiB
PHP
<?php
|
||
/**
|
||
* @api-readonly
|
||
* Returns NDT calculation data (no cache)
|
||
*/
|
||
$lineTypeWelderToIso = lineTypeWelderToIso();
|
||
$query = apply_welded_filter(db("weld_logs"));
|
||
$repairLogs = db("repair_logs")
|
||
|
||
->where("repair_status", "Not Done");
|
||
|
||
if(isset($type))
|
||
{
|
||
$_GET['type'] = $type;
|
||
}
|
||
|
||
if(isset($test_package_no))
|
||
{
|
||
$_GET['test_package_no'] = $test_package_no;
|
||
}
|
||
|
||
if(isset($iso_number2))
|
||
{
|
||
$_GET['iso_number2'] = $iso_number2;
|
||
}
|
||
|
||
|
||
if(!getesit("iso_number","")) {
|
||
$query = $query->where("iso_number", "like", "%" . get("iso_number") . "%");
|
||
}
|
||
|
||
if(!getesit("iso_number2","")) {
|
||
$query = $query->where("iso_number", get("iso_number2"));
|
||
}
|
||
|
||
|
||
|
||
if(!getesit("test_package_no", ""))
|
||
{
|
||
$query = $query->where("test_package_no", get("test_package_no"));
|
||
$repairLogs = $repairLogs->where("test_package_no", get("test_package_no"));
|
||
}
|
||
$query = $query
|
||
//->where("no_of_the_joint_as_per_as_built_survey", "not like", "%R%")
|
||
->get();
|
||
|
||
$repairLogs = $repairLogs->get();
|
||
|
||
$data = [];
|
||
$dataTotal = [];
|
||
$acceptTotal = [];
|
||
$pwhtYesTotal = [];
|
||
$pwhtNoTotal = [];
|
||
$pwhtDate = [];
|
||
$ferriteTotal = [];
|
||
$pmiTotal = [];
|
||
$rtTotal = [];
|
||
$logTypes = array_keys(log_test_types());
|
||
|
||
$jointsTotals = [];
|
||
|
||
$totalWeldedJoints = [];
|
||
|
||
$notAcceptTotal = [];
|
||
$repairTotal = [];
|
||
|
||
$requestNDT = [];
|
||
|
||
$rejCutResults = ['Cut / Резать', 'Reject / Reject', 'Repair / Ремонт'];
|
||
$accResults = ['Accept / Годен'];
|
||
$accResultsExtend = ['', 'Accept / Годен'];
|
||
$totalWithoutRejCut = [];
|
||
|
||
$isoToTP = [];
|
||
$isoToProject = [];
|
||
$isoToDesignArea = [];
|
||
|
||
|
||
foreach($query AS $q) {
|
||
$maxWelderNo = 2;
|
||
if($q->welder_1 == $q->welder_2) {
|
||
$maxWelderNo = 1;
|
||
}
|
||
|
||
$isoToTP[$q->line_number] = $q->test_package_no;
|
||
$isoToProject[$q->line_number] = $q->project;
|
||
$isoToDesignArea[$q->line_number] = $q->design_area;
|
||
|
||
|
||
|
||
for($welderNo = 1; $welderNo<=$maxWelderNo; $welderNo++) {
|
||
$arrayQ = (array) $q;
|
||
$welderName = get_welder_id($arrayQ['welder_'.$welderNo]);
|
||
|
||
if($welderName != "") {
|
||
|
||
foreach($logTypes AS $logType) {
|
||
$requestDate = $logType . '_request_date';
|
||
$testing_date = $logType . '_test_date';
|
||
$result_no = $logType . '_result';
|
||
if(!isset($requestNDT[$logType][$welderName][$q->line_number][$q->type_of_welds])) $requestNDT[$logType][$welderName][$q->line_number][$q->type_of_welds] = 0;
|
||
if(!rejected_date($q->$requestDate)) {
|
||
if($q->$testing_date == "") {
|
||
if($q->$result_no == "") {
|
||
|
||
$requestNDT[$logType][$welderName][$q->line_number][$q->type_of_welds]++;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
if(!isset($data[$welderName][$q->line_number][$q->type_of_welds]))
|
||
$data[$welderName][$q->line_number][$q->type_of_welds] = [];
|
||
|
||
if(!isset($data[$welderName][$q->line_number][$q->type_of_welds]['total']))
|
||
$data[$welderName][$q->line_number][$q->type_of_welds]['total'] = 0;
|
||
|
||
if(!isset($data[$welderName][$q->line_number][$q->type_of_welds]['total_acc']))
|
||
$data[$welderName][$q->line_number][$q->type_of_welds]['total_acc'] = 0;
|
||
|
||
if(!isset($data[$welderName][$q->line_number][$q->type_of_welds]['without_welding_total']))
|
||
$data[$welderName][$q->line_number][$q->type_of_welds]['without_welding_total'] = 0;
|
||
|
||
if(!isset($dataTotal[$q->line_number][$q->type_of_welds]))
|
||
$dataTotal[$q->line_number][$q->type_of_welds] = 0;
|
||
|
||
foreach($logTypes AS $logType) {
|
||
if(!isset($acceptTotal[$welderName][$q->line_number][$q->type_of_welds][$logType]))
|
||
$acceptTotal[$welderName][$q->line_number][$q->type_of_welds][$logType] = 0;
|
||
$notAcceptTotal[$welderName][$q->line_number][$q->type_of_welds][$logType] = 0;
|
||
}
|
||
|
||
|
||
if(!isset($pwhtYesTotal[$q->line_number][$q->type_of_welds]))
|
||
$pwhtYesTotal[$q->line_number][$q->type_of_welds] = 0;
|
||
|
||
if(!isset($pwhtNoTotal[$q->line_number][$q->type_of_welds]))
|
||
$pwhtNoTotal[$q->line_number][$q->type_of_welds] = 0;
|
||
|
||
if(!isset($pwhtDate[$q->line_number]))
|
||
$pwhtDate[$q->line_number] = 0;
|
||
|
||
if(!isset($ferriteTotal[$q->line_number]))
|
||
$ferriteTotal[$q->line_number] = 0;
|
||
|
||
if(!isset($totalWeldedJoints[$q->type_of_welds]))
|
||
$totalWeldedJoints[$q->type_of_welds] = 0;
|
||
|
||
if($q->welding_date!="") {
|
||
$data[$welderName][$q->line_number][$q->type_of_welds]['total']++;
|
||
} else {
|
||
$data[$welderName][$q->line_number][$q->type_of_welds]['without_welding_total']++;
|
||
}
|
||
|
||
if(!isset($jointsTotals[$q->line_number][$q->type_of_welds]))
|
||
$jointsTotals[$q->line_number][$q->type_of_welds] = 0;
|
||
|
||
$jointsTotals[$q->line_number][$q->type_of_welds]++;
|
||
|
||
if(!isset($totalWithoutRejCut[$welderName][$q->line_number][$q->type_of_welds]))
|
||
$totalWithoutRejCut[$welderName][$q->line_number][$q->type_of_welds] = 0;
|
||
|
||
|
||
if(!in_array($q->rt_result, $rejCutResults)) {
|
||
$totalWithoutRejCut[$welderName][$q->line_number][$q->type_of_welds]++;
|
||
}
|
||
|
||
if(!isset($totalAcc[$welderName][$q->line_number][$q->type_of_welds]))
|
||
$totalAcc[$welderName][$q->line_number][$q->type_of_welds] = 0;
|
||
|
||
if(in_array($q->rt_result, $accResults)) {
|
||
$totalAcc[$welderName][$q->line_number][$q->type_of_welds]++;
|
||
}
|
||
|
||
if(!isset($totalAccExtend[$welderName][$q->line_number][$q->type_of_welds]))
|
||
$totalAccExtend[$welderName][$q->line_number][$q->type_of_welds] = 0;
|
||
|
||
if(in_array($q->rt_result, $accResultsExtend)) {
|
||
$totalAccExtend[$welderName][$q->line_number][$q->type_of_welds]++;
|
||
$data[$welderName][$q->line_number][$q->type_of_welds]['total_acc']++;
|
||
}
|
||
|
||
$dataTotal[$q->line_number][$q->type_of_welds]++;
|
||
|
||
if($q->pwht == "YES") {
|
||
$pwhtYesTotal[$q->line_number][$q->type_of_welds]++;
|
||
} else {
|
||
$pwhtNoTotal[$q->line_number][$q->type_of_welds]++;
|
||
}
|
||
|
||
if($q->pwht_date != "") {
|
||
$pwhtDate[$q->line_number]++;
|
||
}
|
||
|
||
if($q->ferrite_scope == 100) {
|
||
$ferriteTotal[$q->line_number]++;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
$vtScope = 100;
|
||
foreach($logTypes AS $logType) {
|
||
$aq = (Array) $q;
|
||
if($aq[$logType . '_result'] == "Accept / Годен") {
|
||
$acceptTotal[$welderName][$q->line_number][$q->type_of_welds][$logType]++;
|
||
} elseif($aq[$logType . '_result'] != "") {
|
||
if($q->welding_date != "") {
|
||
$notAcceptTotal[$welderName][$q->line_number][$q->type_of_welds][$logType]++;
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
|
||
$data[$welderName][$q->line_number][$q->type_of_welds]['vt_scope'] = $vtScope;
|
||
$data[$welderName][$q->line_number][$q->type_of_welds]['rt_scope'] = (int) $q->rt_scope ? $q->rt_scope : 0;
|
||
$data[$welderName][$q->line_number][$q->type_of_welds]['ut_scope'] = (int) $q->ut_scope ? $q->ut_scope : 0;
|
||
$data[$welderName][$q->line_number][$q->type_of_welds]['pt_scope'] = (int) $q->pt_scope ? $q->pt_scope : 0;
|
||
$data[$welderName][$q->line_number][$q->type_of_welds]['mt_scope'] = (int) $q->mt_scope ? $q->mt_scope : 0 ;
|
||
$data[$welderName][$q->line_number][$q->type_of_welds]['ht_scope'] = (int) $q->ht_scope ? $q->ht_scope : 0 ;
|
||
$data[$welderName][$q->line_number][$q->type_of_welds]['pmi_scope'] = $q->pmi_scope ? $q->pmi_scope : 0;
|
||
$data[$welderName][$q->line_number][$q->type_of_welds]['ferrite_scope'] = (int) $q->ferrite_scope ? $q->ferrite_scope : 0;
|
||
$data[$welderName][$q->line_number][$q->type_of_welds]['pwht']= $q->pwht;
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
}
|
||
|
||
foreach($repairLogs AS $repairLog) {
|
||
|
||
if(!isset($repairTotal[$repairLog->welder_1][$repairLog->line_number][$repairLog->type_of_welds]))
|
||
$repairTotal[$repairLog->welder_1][$repairLog->line_number][$repairLog->type_of_welds] = 0;
|
||
|
||
$repairTotal[$repairLog->welder_1][$repairLog->line_number][$repairLog->type_of_welds]++;
|
||
|
||
if($repairLog->welder_2 != "") {
|
||
|
||
if($repairLog->welder_1 != $repairLog->welder_2) {
|
||
|
||
if(!isset($repairTotal[$repairLog->welder_2][$repairLog->line_number][$repairLog->type_of_welds]))
|
||
$repairTotal[$repairLog->welder_2][$repairLog->line_number][$repairLog->type_of_welds] = 0;
|
||
|
||
$repairTotal[$repairLog->welder_2][$repairLog->line_number][$repairLog->type_of_welds]++;
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
$refactoringData = [];
|
||
$refactoringData2 = [];
|
||
$manageData = [];
|
||
$scopeData = [];
|
||
|
||
$cols = [
|
||
'RT/UT',
|
||
'PT/MT',
|
||
'PMI',
|
||
'Ferrit',
|
||
'PWHT',
|
||
'Total Welded Joints',
|
||
];
|
||
$rows = [
|
||
'BW',
|
||
'FW',
|
||
'SW',
|
||
];
|
||
|
||
foreach($cols AS $col) {
|
||
foreach($rows AS $row) {
|
||
$manageData[$col][$row] = 0;
|
||
}
|
||
}
|
||
|
||
foreach($data AS $welder => $isoData) {
|
||
foreach($isoData AS $lineNumber => $weldData) {
|
||
$refactoringData[$welder][$lineNumber] = $weldData;
|
||
foreach($weldData AS $weldName => $subData) {
|
||
|
||
$grandTotal = $subData['total'];
|
||
$jointsTotal = $subData['without_welding_total'];
|
||
$pwhtScopeTotal = $pwhtYesTotal[$lineNumber][$weldName];
|
||
$pwhtDateTotal = $pwhtDate[$lineNumber];
|
||
$totalWeldedJoints[$weldName] += $grandTotal;
|
||
/*
|
||
if(isset($rtTotal[$welder][$lineNumber]))
|
||
// $subData['rt_scope'] = $rtTotal[$welder][$lineNumber];
|
||
*/
|
||
|
||
if(isset($acceptTotal[$welder][$lineNumber][$weldName])) {
|
||
$thisAcceptTotal = $acceptTotal[$welder][$lineNumber][$weldName];
|
||
}
|
||
|
||
if(isset($notAcceptTotal[$welder][$lineNumber][$weldName])) {
|
||
$thisNotAcceptTotal = $notAcceptTotal[$welder][$lineNumber][$weldName];
|
||
}
|
||
|
||
$rtScopeCalc = ceil( ( ( $subData['rt_scope'] * $subData['total_acc']) /100 - $thisNotAcceptTotal['rt'] ) );
|
||
|
||
if($weldName == "SW") {
|
||
$swTotal = $dataTotal[$lineNumber][$weldName];
|
||
$rtScopeCalc = ceil($subData['rt_scope'] * ($swTotal - $thisNotAcceptTotal['rt']) /100);
|
||
$rtTotal[$welder][$lineNumber] = $subData['rt_scope'];
|
||
//burası debuging yapılacak pmidaki gibi tüm alanlarda aynı değer
|
||
}
|
||
|
||
|
||
|
||
|
||
$thisFerriteTotal = 0;
|
||
if(isset($ferriteTotal[$lineNumber])) {
|
||
$thisFerriteTotal = $ferriteTotal[$lineNumber];
|
||
}
|
||
|
||
if($subData['pwht']=="NO" || $subData['pwht']=="") {
|
||
$pwhtBacklog = 0;
|
||
$htBacklog = 0;
|
||
} else {
|
||
$pwhtBacklog = ($grandTotal - $thisNotAcceptTotal['pwht']) - $thisAcceptTotal['pwht'];
|
||
$htBacklog = ($grandTotal - $thisNotAcceptTotal['ht']) - $thisAcceptTotal['ht'];
|
||
}
|
||
|
||
if($rtScopeCalc<0) {
|
||
$rtScopeCalc = 0;
|
||
}
|
||
|
||
|
||
$refactoringData[$welder][$lineNumber][$weldName]['rt_backlog'] = $rtScopeCalc;
|
||
|
||
$refactoringData[$welder][$lineNumber][$weldName]['vt_backlog'] = ceil($subData['vt_scope'] * ($grandTotal - $thisNotAcceptTotal['vt']) /100) - $thisAcceptTotal['vt'];
|
||
$refactoringData[$welder][$lineNumber][$weldName]['ut_backlog'] = ceil($subData['ut_scope'] * ($grandTotal - $thisNotAcceptTotal['ut']) /100) - $thisAcceptTotal['ut'];
|
||
$refactoringData[$welder][$lineNumber][$weldName]['pt_backlog'] = ceil($subData['pt_scope'] * ($grandTotal - $thisNotAcceptTotal['pt']) /100) - $thisAcceptTotal['pt'];
|
||
$refactoringData[$welder][$lineNumber][$weldName]['mt_backlog'] = ceil($subData['mt_scope'] * ($grandTotal - $thisNotAcceptTotal['mt']) /100) - $thisAcceptTotal['mt'];
|
||
$refactoringData[$welder][$lineNumber][$weldName]['ht_backlog'] = $htBacklog;
|
||
|
||
if(strpos($subData['pmi_scope'], "*") !== false) {
|
||
$subData['pmi_scope'] = str_replace("*", "", $subData['pmi_scope']);
|
||
if($grandTotal >= 2) {
|
||
$subData['pmi_scope'] = 2;
|
||
} elseif($grandTotal < 2) {
|
||
$subData['pmi_scope'] = 1;
|
||
}
|
||
$pmiBacklog = $subData['pmi_scope'] - $thisAcceptTotal['pmi'];
|
||
$pmiTotal[$welder][$lineNumber] = $subData['pmi_scope'];
|
||
//buraya joint type dan bağımsız olarak bir toplam yapmalıyız üstte değişken tanımı yapıldı.
|
||
|
||
} else {
|
||
|
||
if(isset($pmiTotal[$welder][$lineNumber]))
|
||
$subData['pmi_scope'] = $pmiTotal[$welder][$lineNumber];
|
||
|
||
$pmiBacklog = ceil($subData['pmi_scope'] * ($grandTotal - $thisNotAcceptTotal['pmi']) /100) - $thisAcceptTotal['pmi'];
|
||
}
|
||
|
||
$thisRepairTotal = 0;
|
||
if(isset($repairTotal[$welder][$lineNumber][$weldName])) {
|
||
$thisRepairTotal = $repairTotal[$welder][$lineNumber][$weldName];
|
||
}
|
||
|
||
|
||
|
||
|
||
$refactoringData[$welder][$lineNumber][$weldName]['pmi_backlog'] = $pmiBacklog;
|
||
|
||
$refactoringData[$welder][$lineNumber][$weldName]['pwht_backlog'] = $pwhtBacklog;
|
||
$refactoringData[$welder][$lineNumber][$weldName]['ferrite_backlog'] = ceil($subData['ferrite_scope'] * ($grandTotal - $thisNotAcceptTotal['ferrite']) /100) - $thisAcceptTotal['ferrite'];//ceil($thisFerriteTotal * $grandTotal /100) - $thisAcceptTotal;
|
||
|
||
$rowData = [
|
||
'welder' => $welder,
|
||
'line_number' => $lineNumber,
|
||
'project' => $isoToProject[$lineNumber] ?? null,
|
||
'design_area' => $isoToDesignArea[$lineNumber] ?? null,
|
||
'iso_number' => $lineTypeWelderToIso[$lineNumber . '|' . $weldName . '|' . $welder] ?? null,
|
||
'weld_name' => $weldName,
|
||
'vt_scope' => $subData['vt_scope'],
|
||
'rt_scope' => $subData['rt_scope'],
|
||
'ut_scope' => $subData['ut_scope'],
|
||
'pt_scope' => $subData['pt_scope'],
|
||
'mt_scope' => $subData['mt_scope'],
|
||
'pmi_scope' => $subData['pmi_scope'],
|
||
// 'ferrit_scope' => $thisFerriteTotal,
|
||
|
||
'pwht' => $subData['pwht'],
|
||
'vt_backlog' => ceil($subData['vt_scope'] * ($grandTotal - $thisNotAcceptTotal['vt']) /100) - $thisAcceptTotal['vt'],
|
||
'vt_rq' => $requestNDT['vt'][$welder][$lineNumber][$weldName],
|
||
'vt_balance' => (ceil($subData['vt_scope'] * ($grandTotal - $thisNotAcceptTotal['vt']) /100) - $thisAcceptTotal['vt']) - $requestNDT['vt'][$welder][$lineNumber][$weldName],
|
||
|
||
'rt_backlog' => $rtScopeCalc - $thisAcceptTotal['rt'],
|
||
'rt_rq' => $requestNDT['rt'][$welder][$lineNumber][$weldName],
|
||
'rt_balance' => ($rtScopeCalc - $thisAcceptTotal['rt']) - $requestNDT['rt'][$welder][$lineNumber][$weldName],
|
||
|
||
'ut_backlog' => ceil($subData['ut_scope'] * ($grandTotal - $thisNotAcceptTotal['ut']) /100) - $thisAcceptTotal['ut'],
|
||
'ut_rq' => $requestNDT['ut'][$welder][$lineNumber][$weldName],
|
||
'ut_balance' => (ceil($subData['ut_scope'] * ($grandTotal - $thisNotAcceptTotal['ut']) /100) - $thisAcceptTotal['ut']) - $requestNDT['ut'][$welder][$lineNumber][$weldName],
|
||
|
||
'pt_backlog' => ceil($subData['pt_scope'] * ($grandTotal - $thisNotAcceptTotal['pt']) /100) - $thisAcceptTotal['pt'],
|
||
'pt_rq' => $requestNDT['pt'][$welder][$lineNumber][$weldName],
|
||
'pt_balance' => (ceil($subData['pt_scope'] * ($grandTotal - $thisNotAcceptTotal['pt']) /100) - $thisAcceptTotal['pt']) - $requestNDT['pt'][$welder][$lineNumber][$weldName],
|
||
|
||
'mt_backlog' => ceil($subData['mt_scope'] * ($grandTotal - $thisNotAcceptTotal['mt']) /100) - $thisAcceptTotal['mt'],
|
||
'mt_rq' => $requestNDT['mt'][$welder][$lineNumber][$weldName],
|
||
'mt_balance' => (ceil($subData['mt_scope'] * ($grandTotal - $thisNotAcceptTotal['mt']) /100) - $thisAcceptTotal['mt']) - $requestNDT['mt'][$welder][$lineNumber][$weldName],
|
||
|
||
'ht_backlog' => $htBacklog,
|
||
'ht_rq' => array_sum($requestNDT['ht'][$welder][$lineNumber]),
|
||
'ht_balance' => $htBacklog - array_sum($requestNDT['ht'][$welder][$lineNumber]),
|
||
|
||
'pmi_backlog' => $pmiBacklog,
|
||
'pmi_rq' => array_sum($requestNDT['pmi'][$welder][$lineNumber]),
|
||
'pmi_balance' => $pmiBacklog - array_sum($requestNDT['pmi'][$welder][$lineNumber]),
|
||
|
||
'ferrite_backlog' => ceil($subData['ferrite_scope'] * ($grandTotal - $thisNotAcceptTotal['ferrite']) /100) - $thisAcceptTotal['ferrite'],
|
||
'ferrite_rq' => array_sum($requestNDT['ferrite'][$welder][$lineNumber]),
|
||
'ferrite_balance' => (ceil($subData['ferrite_scope'] * ($grandTotal - $thisNotAcceptTotal['ferrite']) /100) - $thisAcceptTotal['ferrite']) - array_sum($requestNDT['ferrite'][$welder][$lineNumber]),
|
||
|
||
'pwht_backlog' => $pwhtBacklog,
|
||
'pwht_rq' => array_sum($requestNDT['pwht'][$welder][$lineNumber]),
|
||
'pwht_balance' => $pwhtBacklog - array_sum($requestNDT['pwht'][$welder][$lineNumber]),
|
||
'remaining_repair' => $thisRepairTotal,
|
||
'grand_total' => $grandTotal,
|
||
'joints_total' => $jointsTotals[$lineNumber][$weldName],
|
||
'total_without_rej_cut' => $totalWithoutRejCut[$welder][$lineNumber][$weldName],
|
||
'total_acc' => $totalAcc[$welder][$lineNumber][$weldName],
|
||
'total_by_weld' => $totalWeldedJoints[$weldName],
|
||
// 'accept_total' => $thisAcceptTotal,
|
||
];
|
||
|
||
$refactoringData2[] = $rowData;
|
||
$pmiScope = $subData['pmi_scope'];
|
||
if($subData['pmi_scope'] == 1) $pmiScope = 100;
|
||
|
||
$scopeData['RT/UT'] = "{$subData['rt_scope']} / {$subData['ut_scope']}";
|
||
$scopeData['PT/MT'] = "{$subData['pt_scope']} / {$subData['mt_scope']}";
|
||
$scopeData['PMI'] = $pmiScope;
|
||
$scopeData['Ferrit'] = "$thisFerriteTotal";
|
||
$scopeData['PWHT'] = "{$subData['pwht']}";
|
||
$scopeData['Total Welded Joints'] = "";
|
||
|
||
if(in_array($weldName, $rows)) {
|
||
$manageData['RT/UT'][$weldName] += $rtScopeCalc - $thisAcceptTotal['rt'];
|
||
$manageData['RT/UT'][$weldName] += ceil($subData['ut_scope'] * ($grandTotal - $thisNotAcceptTotal['ut']) /100) - $thisAcceptTotal['ut'];
|
||
$manageData['PT/MT'][$weldName] += ceil($subData['pt_scope'] * ($grandTotal - $thisNotAcceptTotal['pt']) /100) - $thisAcceptTotal['pt'];
|
||
$manageData['PT/MT'][$weldName] += ceil($subData['mt_scope'] * ($grandTotal - $thisNotAcceptTotal['mt']) /100) - $thisAcceptTotal['mt'];
|
||
$manageData['Ferrit'][$weldName] += ceil($thisFerriteTotal * ($grandTotal - $thisNotAcceptTotal['ferrite']) /100) - $thisAcceptTotal['ferrite'];
|
||
$manageData['PWHT'][$weldName] += $pwhtBacklog;
|
||
$manageData['Total Welded Joints'][$weldName] = $totalWeldedJoints[$weldName];
|
||
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
|
||
|
||
if(getisset("iso_number") && !getisset("all")) {
|
||
|
||
|
||
|
||
$stats = [];
|
||
foreach($cols AS $col) {
|
||
$stats[] = [
|
||
'NDE' => @$col,
|
||
'Scope' => @$scopeData[$col],
|
||
'BW' => @$manageData[$col]['BW'],
|
||
'FW' => @$manageData[$col]['FW'],
|
||
'SW' => @$manageData[$col]['SW']
|
||
];
|
||
|
||
}
|
||
|
||
|
||
echo json_encode_tr($stats);
|
||
} else {
|
||
if(getesit("type", "backlogs")) {
|
||
$json = [];
|
||
$total = [];
|
||
$testTypes = array_keys(log_test_types());
|
||
unset($testTypes[0]); //ht
|
||
unset($testTypes[7]); //ferrite
|
||
foreach($refactoringData2 AS $data) {
|
||
foreach($testTypes AS $testType) {
|
||
if(!isset($total[$testType])) $total[$testType] = 0;
|
||
|
||
if($data[$testType . '_backlog']>0) {
|
||
$total[$testType] += $data[$testType . '_backlog'];
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
foreach($testTypes AS $testType) {
|
||
if($total[$testType] > 0) {
|
||
$json[] = [
|
||
'TYPE' => strtoupper($testType),
|
||
'BACKLOG' => $total[$testType]
|
||
];
|
||
} elseif($total[$testType]==0) {
|
||
$json[] = [
|
||
'TYPE' => strtoupper($testType),
|
||
'BACKLOG' => $total[$testType]
|
||
];
|
||
}
|
||
|
||
}
|
||
setting_put("ndtCalculationBacklogs", $json);
|
||
echo json_encode_tr($json);
|
||
|
||
} elseif(getesit("type", "test_packs")) {
|
||
$tpStats = [];
|
||
$tpISOStats = [];
|
||
foreach($refactoringData2 AS $row)
|
||
{
|
||
// Doğru ISO/TP ilişkisini kullanarak TP numarasını al
|
||
$tpNo = "";
|
||
if(isset($row['line_number']) && isset($isoToTP[$row['line_number']])) {
|
||
$tpNo = trim($isoToTP[$row['line_number']]);
|
||
} else if(isset($row['iso_number']) && isset($isoToTP[$row['iso_number']])) {
|
||
$tpNo = trim($isoToTP[$row['iso_number']]);
|
||
}
|
||
|
||
if($tpNo != "")
|
||
{
|
||
$testTypes = array_keys(log_test_types());
|
||
|
||
if(!isset($tpStats[$tpNo]))
|
||
{
|
||
$tpStats[$tpNo]['test_package_no'] = $tpNo;
|
||
foreach($testTypes AS $testType)
|
||
{
|
||
$tpStats[$tpNo][$testType] = 0;
|
||
}
|
||
}
|
||
|
||
if(!isset($tpISOStats[$tpNo][$row['iso_number']]))
|
||
{
|
||
$tpISOStats[$tpNo][$row['iso_number']]['test_package_no'] = $tpNo;
|
||
$tpISOStats[$tpNo][$row['iso_number']]['iso_number'] = $row['iso_number'];
|
||
foreach($testTypes AS $testType)
|
||
{
|
||
$tpISOStats[$tpNo][$row['iso_number']][$testType] = 0;
|
||
}
|
||
}
|
||
|
||
foreach($testTypes AS $testType)
|
||
{
|
||
// Backlog değeri kontrolü ve negatif değerleri sıfıra dönüştürme
|
||
$backlogValue = 0;
|
||
if(isset($row[$testType . '_backlog'])) {
|
||
$backlogValue = max(0, (int)$row[$testType . '_backlog']);
|
||
}
|
||
|
||
if($backlogValue > 0)
|
||
{
|
||
$tpStats[$tpNo][$testType] += $backlogValue;
|
||
$tpISOStats[$tpNo][$row['iso_number']][$testType] += $backlogValue;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
$tpStatsRefactor = [];
|
||
foreach($tpStats AS $tpStat)
|
||
{
|
||
$tpStatsRefactor[] = $tpStat;
|
||
}
|
||
|
||
$tpISOStatsRefactor = [];
|
||
foreach($tpISOStats AS $tpNo => $data)
|
||
{
|
||
foreach($data AS $d)
|
||
{
|
||
$tpISOStatsRefactor[] = $d;
|
||
}
|
||
|
||
}
|
||
|
||
|
||
$tpDatas = [
|
||
'tp_base' => $tpStatsRefactor,
|
||
'tp_base_iso' => $tpISOStatsRefactor,
|
||
'tpStats' => $tpStats,
|
||
'tpISOStats' => $tpISOStats,
|
||
];
|
||
$json = json_encode_tr($tpDatas);
|
||
setting_put("ndtCalculationTestPack", $json);
|
||
echo $json;
|
||
} else {
|
||
$json = json_encode_tr($refactoringData2);
|
||
setting_put("ndtCalculation", $json);
|
||
echo $json;
|
||
|
||
}
|
||
|
||
}
|
||
|
||
?>
|