addDataParam('s', $from_date); $dataParams->addDataParam('s', $to_date); $result = $wrapperObj->executeQuery($sql, $dataParams); if ($result === false) { showierror($sql); } $array_1 = array(); foreach ($result as $row) { $array_1[$row['upc']] = $row['days_taken']; } $sql = 'SELECT r.upc, DATEDIFF(r.ingestion_completed, cd.date_received) AS days_taken FROM releases r INNER JOIN cd_receive cd ON r.upc = cd.upc WHERE r.upc > 0 AND r.ingestion_completed BETWEEN ? AND ? AND DATEDIFF(r.ingestion_completed, cd.date_received) <= 25'; $dataParams = new QueryData(); $dataParams->addDataParam('s', $from_date); $dataParams->addDataParam('s', $to_date); $result = $wrapperObj->executeQuery($sql, $dataParams); if ($result === false) { showierror($sql); } $array_2 = array(); foreach ($result as $row) { $array_2[$row['upc']] = $row['days_taken']; } $sql = 'SELECT r.upc, DATEDIFF(IF(r.ingestion_completed IS NULL OR r.ingestion_completed = "0000-00-00", r.release_date, r.ingestion_completed), ears.date) AS days_taken FROM releases r INNER JOIN release_status ears ON r.release_id = ears.release_id WHERE r.ingestion_completed BETWEEN ? AND ? AND ears.status = "orchard_processing"'; $dataParams = new QueryData(); $dataParams->addDataParam('s', $from_date); $dataParams->addDataParam('s', $to_date); $result = $wrapperObj->executeQuery($sql, $dataParams); if ($result === false) { showierror($sql); } $array_3 = array(); foreach ($result as $row) { $array_3[$row['upc']] = $row['days_taken']; } $sql = 'SELECT r.upc, DATEDIFF(MIN(eo.encoder_delivery_date), IF(r.ingestion_completed IS NULL OR r.ingestion_completed = "0000-00-00", r.release_date, r.ingestion_completed)) AS days_taken FROM encoding_order eo INNER JOIN encoding_order_detail eod ON eo.encoding_order_id = eod.encoding_order_id INNER JOIN releases r ON r.upc = eod.upc WHERE eo.encoder_delivery_date BETWEEN ? AND ? AND eo.type = "track" AND eo.order_status = "close" AND r.upc NOT IN ( SELECT eodx.upc FROM encoding_order eox INNER JOIN encoding_order_detail eodx ON eox.encoding_order_id = eodx.encoding_order_id WHERE eox.encoder_delivery_date < ? AND eox.type = "track" AND eox.order_status = "close" AND eodx.upc = eod.upc ) GROUP BY r.upc HAVING days_taken <= 25'; $dataParams = new QueryData(); $dataParams->addDataParam('s', $from_date); $dataParams->addDataParam('s', $to_date); $dataParams->addDataParam('s', $from_date); $result = $wrapperObj->executeQuery($sql, $dataParams); if ($result === false) { showierror($sql); } $array_4 = array(); foreach ($result as $row) { $array_4[$row['upc']] = $row['days_taken']; } $sql = 'SELECT dd.upc, DATEDIFF(MIN(dd.date_delivered), MAX(eo.encoder_delivery_date)) AS days_taken FROM encoding_order eo INNER JOIN encoding_order_detail eod ON eo.encoding_order_id = eod.encoding_order_id INNER JOIN delivery_history dd ON dd.upc = eod.upc WHERE eo.type = "track" AND eo.order_status = "close" AND eo.encoder_id = dd.encoder_id AND eo.encoder_id IN (1,9) AND eo.encoder_delivery_date < dd.date_delivered AND dd.date_delivered BETWEEN ? AND ? GROUP BY dd.upc'; $dataParams = new QueryData(); $dataParams->addDataParam('s', $from_date); $dataParams->addDataParam('s', $to_date); $result = $wrapperObj->executeQuery($sql, $dataParams); if ($result === false) { showierror($sql); } $array_5 = array(); foreach ($result as $row) { $array_5[$row['upc']] = $row['days_taken']; } $count1 = count($array_1) ? round(array_sum($array_1) / count(array_keys($array_1))) : ''; $count2 = count($array_2) ? round(array_sum($array_2) / count(array_keys($array_2))) : ''; $count3 = count($array_3) ? round(array_sum($array_3) / count(array_keys($array_3))) : ''; $count4 = count($array_4) ? round(array_sum($array_4) / count(array_keys($array_4))) : ''; $count5 = count($array_5) ? round(array_sum($array_5) / count(array_keys($array_5))) : ''; $varTable .= ' Average # of Days per Release CD Received to Date Ripped ' . ($no_url ? $count1 : '' . $count1 . '') . ' CD Received to Uploaded to OA ' . ($no_url ? $count2 : '' . $count2 . '') . ' Uploaded to OA to Transferred to Content ' . ($no_url ? $count3 : '' . $count3 . '') . ' Transferred to Content to Delivered to Encoder ' . ($no_url ? $count4 : '' . $count4 . '') . ' Delivered to Encoder to 1st Delivery ' . ($no_url ? $count5 : '' . $count5 . '') . ' '; ?>