query($sqlquery); // $result = $db->query($sqlquery . " UNION " . $sqlquery2); if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage()); while ($row = $result->fetch_assoc()): $retArray[$row["cs_id"]] = array($row["hq_id"], $row["cs_eid"], $row["cmp_sustainability_email"], $row["cmp_sustainability_interval"]); endwhile; $result->free(); return $retArray; } if ($argv[1] == "acapella7890") : // Error reporting error_reporting(E_ERROR | E_WARNING | E_PARSE); $path = getAbsoluteSystemPath(); $passwd = "acapella7890"; $logFile = $path . "/log/sustainability.log"; $logDebug = true; $emptyArgument = "\"\""; $currDatetime = getDateTime("0"); // Format: "YmdHi" $limit = $argv[2]; // Max number of customers to pe processesd if (!isset($limit) || !is_numeric($limit)) : $limit = ""; endif; // Get current month $curMonth = date("n"); $curYear = date("Y"); $quartals = array(1 => 1,2 => 1,3 => 1,4 => 2,5 => 2,6 => 2,7 => 3,8 => 3,9 => 3,10 => 4,11 => 4,12 => 4); $currentQuartal = $quartals[$curMonth]; // Get jobs $csArr = getCustomersForSustainabilityReport($limit); $cskArr = array_keys($csArr); $cskArrLen = count($cskArr); for ($i = 0; $i < $cskArrLen; $i++) : $csId = $cskArr[$i]; $hqId = $csArr[$csId][0]; $csEid = $csArr[$csId][1]; $cmpSustainabilityEmail = $csArr[$csId][2]; $cmpSustainabilityInterval = $csArr[$csId][3]; $doContinue = false; switch ($cmpSustainabilityInterval) { case 0: // monthly $doContinue = true; break; case 1: if ($curMonth == 1 || $curMonth == 4 || $curMonth == 7 || $curMonth == 10) : $doContinue = true; endif; break; case 2: if ($curMonth == 1) : $doContinue = true; endif; break; } if ($doContinue) : $csIsMeta = false; $tmpCsIdsSub = getColVectorFromDB2ArrayByClause("customer", "cs_id", "cs_id_parent = '" . $csId . "'"); if (count($tmpCsIdsSub) > 0) : $csIsMeta = true; endif; // Call script for (meta-)customer $cmd = "php " . $path . "/tools/auto_trigger_jobs_sustainability_customer_report.php " . $passwd . " " . ($csIsMeta ? "cs_meta" : "cs") . " " . $csId . " " . $cmpSustainabilityInterval . " &"; // echo $cmd . "\n"; $cmdOutput = null; exec($cmd, $cmdOutput); // print_r($cmdOutput); echo "\n\n"; sleep(3); endif; if ($logDebug) : writeToFile($logFile, $currDatetime . "[hq_id=" . $hqId . "][cs_id=" . $csId . "][cs_eid=" . $csEid . "][cmp_sustainability_email=" . $cmpSustainabilityEmail . "][cmpSustainabilityInterval=" . $cmpSustainabilityInterval . "]"); endif; endfor; endif; ?>