$masterData[$value]["userid"] = $returnArray["USER__BID"]; $masterData[$value]["email"] = $returnArray["EMAIL__BADDRESS"]; $masterData[$value]["pid"] = $returnArray["PID"]; $masterData[$value]["firstName"] = $returnArray["FIRST__BNAME"]; $masterData[$value]["lastName"] = $returnArray["LAST__BNAME"]; } echo '<h1> Affected Master Tickets </h1>'; echo '<em>Just got new bounce reports? <a href="updateForm.php" id="newReports">Click here to upload them.</a></em><br><br>'; echo '<button class="applyChanges">Apply Changes</button> <button id="toggleButton" onclick="expandAll()">Expand All</button><br><br><br>'; /*echo 'Sort By: <form method="get"><select name="sortBy" id="sortBy">'; echo '<option></option>'; echo '<option value="decCosts">Highest-Lowest Total Costs</option>'; echo '<option value="incCosts">Lowest-Highest Costs</option></select>'; echo '<input type="submit" value="go"></form>';*/ calculateTotalCosts(); if (isset($_GET['sortBy'])) { $sortType = $_GET['sortBy']; if (in_array("decCosts", $sortType, true)) { uasort($masterArray, "sortDecCosts"); } else { if (in_array("incCosts", $sortType, true)) { uasort($masterArray, "sortIncCosts"); } } } printValues(); function printValues() { global $masterArray, $masterData, $masterWithNew, $ticketData, $invalidReasons, $changesArray; $number = 0;
function getPdfVariables($contract) { global $app_list_strings; global $locale; $serviceArrays = array(); $oneTimeServiceArrays = array(); $productArrays = array(); $oneTimeProductArrays = array(); $pdfDataArray = array(); $contractVariables = array(); $calculatedCosts = array(); $imagesExist = false; $sep = get_number_seperators(); $vat_default = floatval(str_replace($sep[1], '.', $app_list_strings['oqc_vat_list']['default'])) / 100; //Get contract variables $contractVariables = getContractVariables($contract); //Get service data for processing $services = $contract->get_linked_beans('oqc_service', 'oqc_Service'); if (!empty($services)) { usort($services, array('oqc_Service', 'oqc_service_compare_position')); foreach ($services as $service) { $serviceArray = $service->toArray(); $serviceArray = sanatizeBeanArrayForLatex($serviceArray); $product = getProductBean($service); if ($product) { $productArray = $product->toArray(); $productArray = sanatizeBeanArrayForLatex($productArray); } else { $productArray = array(); } if (!empty($service->description)) { // Rewrite description with Latex converter output. $convertor = new oqc_HtmlToLatexConverter(); $serviceArray['description'] = $convertor->html2latex('<html><head></head><body>' . from_html($service->description) . '</body></html>'); } elseif (!empty($product->description)) { $convertor = new oqc_HtmlToLatexConverter(); $productArray['description'] = $convertor->html2latex('<html><head></head><body>' . from_html($product->description) . '</body></html>'); } // translate $serviceArray['zeitbezug_translated'] = $app_list_strings['zeitbezug_list'][$serviceArray['zeitbezug']]; if ($app_list_strings['unit_list'][$serviceArray['unit']]) { $serviceArray['unit'] = $app_list_strings['unit_list'][$serviceArray['unit']]; } $calc_vat = $serviceArray['oqc_vat'] == 'default' ? $vat_default : ($serviceArray['oqc_vat'] !== '' ? $serviceArray['oqc_vat'] : $vat_default); $serviceArray['oqc_vat'] = $calc_vat * 100; $serviceArray['discounted_price'] = $service->getDiscountedPrice($calc_vat); $serviceArray['discounted_price_tax_free'] = $service->getDiscountedPriceTaxFree(); $serviceArray['image_url'] = false; if ($product) { if ($product->getImageFilenameUrl()) { if (WINDOWS) { $serviceArray['image_url'] = str_replace("\\", "/", '"' . getcwd() . '"/' . $product->getImageFilenameUrl()); } else { $serviceArray['image_url'] = str_replace("\\", "/", getcwd() . '/' . $product->getImageFilenameUrl()); } } } $serviceArray['has_image'] = $serviceArray['image_url'] !== FALSE; // convenient flag for access from latex template $serviceArray['startdate'] = $contract->startdate; $serviceArray['enddate'] = $contract->enddate; //$GLOBALS['log']->error('getPdfVariables: '. var_export($serviceArray['oqc_vat'],true)); if (!empty($serviceArray['service_currency_id'])) { $currency = new Currency(); //$currency_id = -99; $currency->retrieve($serviceArray['service_currency_id']); //Convert currency symbols to latex equivalents here $serviceArray['currency_symbol'] = $currency->symbol; $serviceArray['currency_symbol'] = str_replace("€", '\\euro{}', $serviceArray['currency_symbol']); $serviceArray['currency_symbol'] = str_replace('$', '\\$', $serviceArray['currency_symbol']); $serviceArray['currency_symbol'] = str_replace("£", '{\\pounds}', $serviceArray['currency_symbol']); $serviceArray['currency_symbol'] = str_replace("¥", '{Y\\hspace*{-1.4ex}--}', $serviceArray['currency_symbol']); } if (!$imagesExist && $serviceArray['has_image']) { $imagesExist = true; } if ($service->zeitbezug == 'once') { $oneTimeServiceArrays[] = $serviceArray; $oneTimeProductArrays[] = $productArray; } else { $serviceArrays[] = $serviceArray; $productArrays[] = $productArray; } } // merge data from products and services, prefering service data $serviceData = array_map('array_merge', $productArrays, $serviceArrays); $oneTimeServiceData = array_map('array_merge', $oneTimeProductArrays, $oneTimeServiceArrays); } $costsTotal = calculateTotalCosts($serviceData, false); $oneTimeCostsTotal = calculateTotalCosts($oneTimeServiceData); //$currency_symbol = $serviceData = array('imagesExist' => $imagesExist, 'services' => $serviceData, 'oneTimeServices' => $oneTimeServiceData); $pdfDataArray = array_merge($contractVariables, $serviceData, $costsTotal, $oneTimeCostsTotal); //$GLOBALS['log']->error('Services: variable transferred to pdf: '. var_export($pdfDataArray,true)); return $pdfDataArray; }