/** * Perform a schema comparison on provided databases */ public function data($isReplace, $algorithm, $upFile, $showChanges, $targetdb, $sourcedb) { $this->isReady(); // Grab list of tables for each database $tables = array($targetdb->getTables(), $sourcedb->getTables()); // Grab tables that are in both $matchingTables = array_intersect(array_keys($tables[0]), array_keys($tables[1])); // target - source $matchingNewTables = array_diff(array_keys($tables[1]), array_keys($tables[0])); // source - target $bar = new ProgressBar('Comparing different table data and fill new tables..', true, 0, 400, 40, "#cccccc", "blue", "cdata"); $bar->initialize(count($matchingTables) + count($matchingNewTables)); // total number of tables // Try to do quick checksum comparison foreach ($matchingTables as $tableName) { if ($algorithm == "groupby") { if ($targetdb->server != $sourcedb->server) { die('Actually Cannot execute group by algorithm on different hosts: ' . $targetdb->server . ' - ' . $this->sourcedb->server); } $this->groupByMethod($tables, $tableName, $isReplace, $upFile, $showChanges, $targetdb, $sourcedb); } else { //processing use only array $rows = array($tables[0][$tableName]->getRows(), $tables[1][$tableName]->getRows()); // Look for new/missing rows $newRows = array_diff_key($rows[1], $rows[0]); // while approach, to limit the memory consume not copying the array as in foreach reset($newRows); while (list($key, $value) = each($newRows)) { $this->rowsSetDiff($value, "new"); } unset($newRows); $missingRows = array_diff_key($rows[0], $rows[1]); reset($missingRows); while (list($key, $value) = each($missingRows)) { $this->rowsSetDiff($value, "missing"); } unset($missingRows); // Find rows that exist in both $compareRows = array_intersect_key($rows[0], $rows[1]); reset($compareRows); while (list($key, $value) = each($compareRows)) { $this->rowsSetDiff($value, "compare", $rows[1][$key], $isReplace); } unset($compareRows, $rows); $upFile->fillData($this); } // Prune rows that havent got diffs $tables[0][$tableName]->pruneRows(); $tables[1][$tableName]->pruneRows(); $bar->increase(); } foreach ($matchingNewTables as $tableName) { // don't use getRows() to avoid memory overload $select = $tables[1][$tableName]->getTable()->select()->from($tableName); $pColumns = $tables[1][$tableName]->getPrimaryColumns(); $keycnt = count($pColumns); $tables[1][$tableName]->blankRows(); $stmt = $select->query(); while ($row = $stmt->fetch()) { $cRow = $tables[1][$tableName]->createRow($row, $tables[1][$tableName]->getRowsArray()); $this->rowsSetDiff($cRow, "new"); $upFile->createQuery($cRow, $pColumns, $keycnt, $tableName); if ($showChanges) { $tables[1][$tableName]->addRow($cRow); } } $upFile->writeData($keycnt, $tableName); unset($select, $stmt); $bar->increase(); } unset($bar, $tables, $tableNames, $matchingTables); }
function hae_rivit($tyyppi, $kukarow, $vva, $kka, $ppa, $vvl, $kkl, $ppl, $apaikka, $lpaikka, $varastot, $keraysvyohykkeet, $lisa_kentat, $kerayksettomat_tuotepaikat, $lisa) { global $yhtiorow; $ostoehdotukset = array('' => t("Ehdotetaan ostoehdotusohjelmissa tilattavaksi"), 'E' => "Ei ehdoteta ostoehdotusohjelmissa tilattavaksi"); if (strtotime("{$vva}-{$kka}-{$ppa}") < strtotime('now - 12 months')) { $_date = "AND tilausrivi.kerattyaika >= '{$vva}-{$kka}-{$ppa} 00:00:00'\n AND tilausrivi.kerattyaika <= '{$vvl}-{$kkl}-{$ppl} 23:59:59'"; } else { $_date = "AND tilausrivi.kerattyaika >= Date_sub(CURRENT_DATE, INTERVAL 12 month)"; } $tuotepaikka_where = ""; $a = array_filter($apaikka); $l = array_filter($lpaikka); if (!empty($a) or !empty($l)) { $ahyllyalue = $apaikka['ahyllyalue']; $ahyllynro = $apaikka['ahyllynro']; $ahyllyvali = $apaikka['ahyllyvali']; $ahyllytaso = $apaikka['ahyllytaso']; $lhyllyalue = $lpaikka['lhyllyalue']; $lhyllynro = $lpaikka['lhyllynro']; $lhyllyvali = $lpaikka['lhyllyvali']; $lhyllytaso = $lpaikka['lhyllytaso']; $tuotepaikka_where = "and concat(rpad(upper(tilausrivi.hyllyalue) ,5,'0'),lpad(upper(tilausrivi.hyllynro) ,5,'0'),lpad(upper(tilausrivi.hyllyvali) ,5,'0'),lpad(upper(tilausrivi.hyllytaso) ,5,'0')) >=\n concat(rpad(upper('{$ahyllyalue}'), 5, '0'),lpad(upper('{$ahyllynro}'), 5, '0'),lpad(upper('{$ahyllyvali}'), 5, '0'),lpad(upper('{$ahyllytaso}'),5, '0'))\n and concat(rpad(upper(tilausrivi.hyllyalue) ,5,'0'),lpad(upper(tilausrivi.hyllynro) ,5,'0'),lpad(upper(tilausrivi.hyllyvali) ,5,'0'),lpad(upper(tilausrivi.hyllytaso) ,5,'0')) <=\n concat(rpad(upper('{$lhyllyalue}'), 5, '0'),lpad(upper('{$lhyllynro}'), 5, '0'),lpad(upper('{$lhyllyvali}'), 5, '0'),lpad(upper('{$lhyllytaso}'),5, '0'))"; } $varasto_lisa1 = ""; $varasto_lisa2 = ""; if (!empty($varastot)) { $varasto_lisa1 = " AND tuotepaikat.varasto IN (" . implode(",", $varastot) . ") "; $varasto_lisa2 = " AND tilausrivi.varasto IN (" . implode(",", $varastot) . ") "; } $tuote_select = ""; $keraysvyohyke_select = ""; $keraysvyohyke_join = ""; $varaston_hyllypaikat_join = ""; $group = ","; if ($yhtiorow['kerayserat'] == "K") { $keraysvyohyke_select = "keraysvyohyke.nimitys as keraysvyohykkeen_nimitys,"; $keraysvyohyke_join = " JOIN keraysvyohyke ON (keraysvyohyke.yhtio = vh.yhtio AND keraysvyohyke.tunnus = vh.keraysvyohyke)"; $varaston_hyllypaikat_join = " JOIN varaston_hyllypaikat AS vh\n ON (\n vh.yhtio = tilausrivi.yhtio\n AND vh.hyllyalue = tilausrivi.hyllyalue\n AND vh.hyllynro = tilausrivi.hyllynro\n AND vh.hyllytaso = tilausrivi.hyllytaso\n AND vh.hyllyvali = tilausrivi.hyllyvali"; if (!empty($keraysvyohykkeet)) { $varaston_hyllypaikat_join .= " AND vh.keraysvyohyke IN (" . implode(",", $keraysvyohykkeet) . ")"; } $varaston_hyllypaikat_join .= ")"; $group .= "keraysvyohykkeen_nimitys,"; } if ($tyyppi == "TUOTE") { $vresult = t_avainsana("S"); $tuote_statukset = array(); while ($status = mysql_fetch_assoc($vresult)) { $tuote_statukset[$status['selite']] = $status['selitetark']; } $checked_count = 0; if (!empty($lisa_kentat)) { foreach ($lisa_kentat as $lisa_kentta) { if (!empty($lisa_kentta['checked'])) { $tuote_select .= $lisa_kentta['kolumni'] . ', '; $group .= $lisa_kentta['kolumni'] . ', '; $checked_count++; } } // Ruksattiin jotain lisävalintoita (tuotekohtaisia), voidaan näyttää saldo if ($checked_count > 0) { $tuote_select .= "tuotepaikat.saldo,"; $group .= "tuotepaikat.saldo,"; } } $tuote_select .= "tilausrivi.hyllyalue, tilausrivi.hyllynro, tilausrivi.hyllyvali, tilausrivi.hyllytaso, "; $tuote_select .= "CONCAT_WS(' ', tilausrivi.hyllyalue, tilausrivi.hyllynro, tilausrivi.hyllyvali, tilausrivi.hyllytaso) as hylly, "; $tuote_select .= "group_concat(distinct tuotepaikat.tunnus) paikkatun, "; $group .= "tilausrivi.hyllyalue, tilausrivi.hyllynro, tilausrivi.hyllyvali, tilausrivi.hyllytaso, hylly,"; if (empty($kerayksettomat_tuotepaikat)) { $tuote_select .= "if (tuotepaikat.tunnus IS NULL , 1, 0) poistettu, "; $group .= "poistettu,"; } } $group = rtrim($group, " ,"); if (!empty($kerayksettomat_tuotepaikat)) { $kerayksettomat_tuotepaikat_varaston_hyllypaikat_join = str_replace('tilausrivi', 'tuotepaikat', $varaston_hyllypaikat_join); $kerayksettomat_tuotepaikat_group = str_replace('tilausrivi', 'tuotepaikat', $group); $kerayksettomat_tuotepaikka_where = str_replace('tilausrivi', 'tuotepaikat', $tuotepaikka_where); $kerayksettomat_tuote_select = str_replace('tilausrivi', 'tuotepaikat', $tuote_select); $query = "SELECT varastopaikat.nimitys as varaston_nimitys,\n {$keraysvyohyke_select}\n {$kerayksettomat_tuote_select}\n sum(if (tilausrivi.kerattyaika >= '{$vva}-{$kka}-{$ppa} 00:00:00' AND tilausrivi.kerattyaika <= '{$vvl}-{$kkl}-{$ppl} 23:59:59', 1, 0)) kpl_valittu_aika,\n sum(if (tilausrivi.kerattyaika >= '{$vva}-{$kka}-{$ppa} 00:00:00' AND tilausrivi.kerattyaika <= '{$vvl}-{$kkl}-{$ppl} 23:59:59', tilausrivi.kpl+tilausrivi.varattu, 0)) tuokpl_valittu_aika,\n sum(if (tilausrivi.kerattyaika >= Date_sub(CURRENT_DATE, INTERVAL 6 month), 1, 0)) kpl_6,\n sum(if (tilausrivi.kerattyaika >= Date_sub(CURRENT_DATE, INTERVAL 6 month), tilausrivi.kpl+tilausrivi.varattu, 0)) tuo_kpl_6,\n sum(if (tilausrivi.kerattyaika >= Date_sub(CURRENT_DATE, INTERVAL 12 month), 1, 0)) kpl_12,\n sum(if (tilausrivi.kerattyaika >= Date_sub(CURRENT_DATE, INTERVAL 12 month), tilausrivi.kpl+tilausrivi.varattu, 0)) tuo_kpl_12\n FROM tuotepaikat\n JOIN tuote USE INDEX (tuoteno_index) ON (tuotepaikat.yhtio = tuote.yhtio\n AND tuotepaikat.tuoteno = tuote.tuoteno\n AND tuote.ei_saldoa = '')\n JOIN varastopaikat ON (varastopaikat.yhtio = tuotepaikat.yhtio\n AND varastopaikat.tunnus = tuotepaikat.varasto)\n {$kerayksettomat_tuotepaikat_varaston_hyllypaikat_join}\n {$keraysvyohyke_join}\n LEFT JOIN tilausrivi ON ( tilausrivi.tyyppi = 'L'\n AND tilausrivi.yhtio = tuotepaikat.yhtio\n AND tilausrivi.hyllyalue = tuotepaikat.hyllyalue\n AND tilausrivi.hyllynro = tuotepaikat.hyllynro\n AND tilausrivi.hyllyvali = tuotepaikat.hyllyvali\n AND tilausrivi.hyllytaso = tuotepaikat.hyllytaso\n AND tilausrivi.tuoteno = tuotepaikat.tuoteno\n {$_date})\n WHERE tuotepaikat.yhtio = '{$kukarow['yhtio']}'\n {$kerayksettomat_tuotepaikka_where}\n {$varasto_lisa1}\n GROUP BY 1\n {$kerayksettomat_tuotepaikat_group}\n ORDER BY kpl_valittu_aika DESC\n {$lisa}"; } else { $query = "SELECT varastopaikat.nimitys as varaston_nimitys,\n {$keraysvyohyke_select}\n {$tuote_select}\n sum(if (tilausrivi.kerattyaika >= '{$vva}-{$kka}-{$ppa} 00:00:00' AND tilausrivi.kerattyaika <= '{$vvl}-{$kkl}-{$ppl} 23:59:59', 1, 0)) kpl_valittu_aika,\n sum(if (tilausrivi.kerattyaika >= '{$vva}-{$kka}-{$ppa} 00:00:00' AND tilausrivi.kerattyaika <= '{$vvl}-{$kkl}-{$ppl} 23:59:59', tilausrivi.kpl+tilausrivi.varattu, 0)) tuokpl_valittu_aika,\n sum(if (tilausrivi.kerattyaika >= Date_sub(CURRENT_DATE, INTERVAL 6 month), 1, 0)) kpl_6,\n sum(if (tilausrivi.kerattyaika >= Date_sub(CURRENT_DATE, INTERVAL 6 month), tilausrivi.kpl+tilausrivi.varattu, 0)) tuo_kpl_6,\n sum(if (tilausrivi.kerattyaika >= Date_sub(CURRENT_DATE, INTERVAL 12 month), 1, 0)) kpl_12,\n sum(if (tilausrivi.kerattyaika >= Date_sub(CURRENT_DATE, INTERVAL 12 month), tilausrivi.kpl+tilausrivi.varattu, 0)) tuo_kpl_12\n FROM tilausrivi\n JOIN tuote USE INDEX (tuoteno_index) ON (tilausrivi.yhtio = tuote.yhtio\n AND tilausrivi.tuoteno = tuote.tuoteno\n AND tuote.ei_saldoa = '')\n JOIN varastopaikat ON (varastopaikat.yhtio = tilausrivi.yhtio\n AND varastopaikat.tunnus = tilausrivi.varasto)\n {$varaston_hyllypaikat_join}\n {$keraysvyohyke_join}\n LEFT JOIN tuotepaikat USE INDEX (yhtio_tuoteno_paikka) ON ( tilausrivi.yhtio = tuotepaikat.yhtio\n AND tilausrivi.hyllyalue = tuotepaikat.hyllyalue\n AND tilausrivi.hyllynro = tuotepaikat.hyllynro\n AND tilausrivi.hyllyvali = tuotepaikat.hyllyvali\n AND tilausrivi.hyllytaso = tuotepaikat.hyllytaso\n AND tilausrivi.tuoteno = tuotepaikat.tuoteno )\n WHERE tilausrivi.yhtio = '{$kukarow['yhtio']}'\n AND tilausrivi.tyyppi = 'L'\n {$tuotepaikka_where}\n {$_date}\n {$varasto_lisa2}\n GROUP BY 1\n {$group}\n ORDER BY kpl_valittu_aika DESC\n {$lisa}"; } $result = pupe_query($query); //päiviä aikajaksossa $epa1 = (int) date('U', mktime(0, 0, 0, $kka, $ppa, $vva)); $epa2 = (int) date('U', mktime(0, 0, 0, $kkl, $ppl, $vvl)); //Diff in workdays (5 day week) $pva = abs($epa2 - $epa1) / 60 / 60 / 24 / 7 * 5; $poistettu = t('Poistettu'); $rows = array(); $saldolliset = array(); if (mysql_num_rows($result) > 0) { $progress_bar = new ProgressBar(t("Haetaan tiedot")); $progress_bar->initialize(mysql_num_rows($result)); } while ($row = mysql_fetch_assoc($result)) { if (isset($progress_bar)) { $progress_bar->increase(); } if ($tyyppi == 'TUOTE') { if (!empty($lisa_kentat['nimitys']['checked'])) { $row['nimitys'] = t_tuotteen_avainsanat($row, 'nimitys'); } if (isset($row['status']) and array_key_exists($row['status'], $tuote_statukset)) { $row['status'] = $tuote_statukset[$row['status']]; } if (isset($row['ostoehdotus']) and array_key_exists($row['ostoehdotus'], $ostoehdotukset)) { $row['ostoehdotus'] = $ostoehdotukset[$row['ostoehdotus']]; } elseif (isset($row['ostoehdotus']) and !array_key_exists($row['ostoehdotus'], $ostoehdotukset)) { $row['ostoehdotus'] = t("Tuntematon"); } } $row['kpl_kerays'] = number_format($row["kpl_valittu_aika"] > 0 ? round($row["tuokpl_valittu_aika"] / $row["kpl_valittu_aika"]) : 0, 0); $row['kpl_valittu_aika_pvm'] = number_format($row["kpl_valittu_aika"] / $pva, 0); if (is_numeric($row['poistettu'])) { if ($row['poistettu'] == 1) { $row['poistettu'] = $poistettu; } elseif ($row['poistettu'] == 0) { $saldolliset[] = $row["paikkatun"]; $row['poistettu'] = ''; } } unset($row['tuokpl_valittu_aika']); unset($row['tuo_kpl_6']); unset($row['tuo_kpl_12']); unset($row['paikkatun']); $rows[] = $row; } echo "<br/>"; return array($rows, $saldolliset); }
function generoi_excel_tiedostot(&$data_array, $params, $kieli) { global $yhtiorow; echo '<br/>' . t('Tehdään excel tiedostot') . '<br/>'; $bar2 = new ProgressBar(); $bar2->initialize(count($data_array) - 1); $excel_tiedostot = array(); $i = 0; foreach ($data_array as &$data) { $bar2->increase(); $temp_data = array('osastoittain' => $data['tilaukset_ilman_try'], 'tuoteryhmittain' => $data['tilaukset_try']); $excel = new vuosisopimus_asiakkaat_excel(); $excel->set_kieli($kieli); $excel->set_asiakas($data['asiakasrow']); $excel->set_yhtiorow($yhtiorow); $alkumiinusyks = $params['alkuvv'] - 1; $loppumiinusyks = $params['loppuvv'] - 1; $excel->set_rajaus_paivat(array('alkupaiva' => $params['alkupp'] . '.' . $params['alkukk'] . '.' . $params['alkuvv'], 'loppupaiva' => $params['loppupp'] . '.' . $params['loppukk'] . '.' . $params['loppuvv'], 'edalkupaiva' => $params['alkupp'] . '.' . $params['alkukk'] . '.' . $alkumiinusyks, 'edloppupaiva' => $params['loppupp'] . '.' . $params['loppukk'] . '.' . $loppumiinusyks)); $excel->set_tilausrivit($temp_data); $excel->set_summat_osastoittain($data['summat_ilman_try']); $excel->set_summat_tuoteryhmittain($data['summat_try']); $excel_tiedostot[] = $excel->generoi(); $data['tiedosto'] = $excel_tiedostot[$i]; unset($excel); $i++; } return $excel_tiedostot; }
$rivilaskuri = 1; $puun_alkio_index_plus = 0; // REST-api ei salli etenemispalkkia if ((!$cli or $lue_data_output_file != "") and !isset($api_kentat)) { $bar = new ProgressBar(); $bar->initialize($rivimaara); } $lisatyt_indeksit = array(); for ($eriviindex = 0; $eriviindex < $rivimaara + $puun_alkio_index_plus; $eriviindex++) { // Komentorivillä piirretään progressbar, ellei ole output loggaus päällä // REST-api skippaa if (!isset($api_kentat)) { if ($cli and $lue_data_output_file == "") { progress_bar($eriviindex, $max_rivit); } elseif (!$cli or $lue_data_output_file != "") { $bar->increase(); } } $hylkaa = 0; $tila = ""; $tee = ""; $epakurpvm = ""; $eilisataeikamuuteta = ""; $rivilaskuri++; //asiakashinta/asiakasalennus/toimittajahinta/toimittajaalennus spessuja $chasiakas_ryhma = ''; $chytunnus = ''; $chryhma = ''; $chtuoteno = ''; $chasiakas = 0; $chsegmentti = 0;
function xls_rivit(pupeExcel &$xls, &$rivit, &$rivi, &$sarake, $force_to_string) { echo "<br/>"; echo "<font class='message'>" . t("Generoidaan excel-tiedosto") . "</font>"; echo "<br/>"; echo "<font class='message'>" . t("Löytyi") . ' ' . count($rivit) . ' ' . t('kpl') . "</font>"; echo "<br/>"; if (count($rivit) > 1) { $xls_progress_bar = new ProgressBar(); $xls_progress_bar->initialize(count($rivit)); } foreach ($rivit as $matkalasku_rivi) { foreach ($matkalasku_rivi as $header => $solu) { if (!stristr($header, 'tunnus')) { kirjoita_solu($xls, $header, $solu, $rivi, $sarake, $force_to_string); } } $rivi++; $sarake = 0; if (isset($xls_progress_bar)) { $xls_progress_bar->increase(); } } echo "<br/>"; }
function checkFiles($task) { global $jlistConfig, $lang; $limits = remove_server_limits(); if (!$limits) { echo '<p>'; echo '*******************************************************'; echo '<br />Note: The time limit on the server could not be changed/increased!<br />'; echo '*******************************************************'; echo '</p>'; } ignore_user_abort(true); // ob_flush(); flush(); $model_category = JModelLegacy::getInstance('Category', 'jdownloadsModel'); $model_download = JModelLegacy::getInstance('Download', 'jdownloadsModel'); jimport('joomla.filesystem.folder'); jimport('joomla.filesystem.file'); $db = JFactory::getDBO(); $lang = JFactory::getLanguage(); $lang->load('com_jdownloads', JPATH_SITE . DS); //check if all files and dirs in the uploaddir directory are listed if ($jlistConfig['files.autodetect'] || $task == 'restore.run' || $task == 'scan.files') { if (file_exists($jlistConfig['files.uploaddir']) && $jlistConfig['files.uploaddir'] != '') { $startdir = $jlistConfig['files.uploaddir'] . '/'; $dir_len = strlen($startdir); // define the params for scan_dir() results $dir = $startdir; $only = FALSE; $type = array(); if ($jlistConfig['all.files.autodetect']) { $allFiles = true; } else { $allFiles = FALSE; $type = explode(',', $jlistConfig['file.types.autodetect']); } $recursive = TRUE; $onlyDir = TRUE; $files = array(); $file = array(); $dirlist = array(); $new_files = 0; $new_dirs_found = 0; $new_dirs_create = 0; $new_dirs_errors = 0; $new_dirs_exists = 0; $new_cats_create = 0; $log_message = ''; $success = FALSE; $log_array = array(); // ******************************************** // first search new categories // ******************************************** clearstatcache(); $jd_root = $jlistConfig['files.uploaddir'] . '/'; $temp_dir = $jd_root . $jlistConfig['tempzipfiles.folder.name'] . '/'; $uncat_dir = $jd_root . $jlistConfig['uncategorised.files.folder.name'] . '/'; $preview_dir = $jd_root . $jlistConfig['preview.files.folder.name'] . '/'; $private_dir = $jd_root . $jlistConfig['private.area.folder.name'] . '/'; $except_folders = array($temp_dir, $uncat_dir, $preview_dir, $private_dir); $searchdirs = array(); $dirlist = JDownloadsHelper::searchdir($jd_root, -1, 'DIRS', 0, $except_folders); $no_writable = 0; for ($i = 0; $i < count($dirlist); $i++) { // no tempzifiles directory if (strpos($dirlist[$i], $jlistConfig['private.area.folder.name'] . '/') === FALSE) { if (!is_writable($dirlist[$i])) { $no_writable++; } $dirlist[$i] = str_replace($jd_root, '', $dirlist[$i]); // delete last slash / if ($pos = strrpos($dirlist[$i], '/')) { $searchdirs[] = substr($dirlist[$i], 0, $pos); } } } unset($dirlist); $count_cats = count($searchdirs); // first progressbar for cats $title1 = JText::_('COM_JDOWNLOADS_RUN_MONITORING_INFO3'); $bar = new ProgressBar(); $bar->setMessage($title1); $bar->setAutohide(false); $bar->setSleepOnFinish(0); $bar->setPrecision(100); $bar->setForegroundColor('#990000'); $bar->setBackgroundColor('#CCCCCC'); $bar->setBarLength(300); $bar->initialize($count_cats - 1); // print the empty bar for ($i = 0; $i < count($searchdirs); $i++) { $dirs = explode('/', $searchdirs[$i]); $sum = count($dirs); // check that folder exist if ($sum == 1) { $db->setQuery("SELECT COUNT(*) FROM #__jdownloads_categories WHERE cat_dir = '{$searchdirs[$i]}'"); $cat_dir_parent_value = ''; $cat_dir_value = $dirs[0]; } else { $pos = strrpos($searchdirs[$i], '/'); $cat_dir_parent_value = substr($searchdirs[$i], 0, $pos); $cat_dir_value = substr($searchdirs[$i], $pos + 1); $db->setQuery("SELECT COUNT(*) FROM #__jdownloads_categories WHERE cat_dir = '{$cat_dir_value}' AND cat_dir_parent = '{$cat_dir_parent_value}'"); } $cat_exist = $db->loadResult(); // when not exist - add it if (!$cat_exist) { $new_dirs_found++; $parent_cat = ''; // get the right parent_id value if ($sum == 1) { // we have a new root cat $parent_id = 1; } else { // find the parent category and get the cat ID $pos = strrpos($cat_dir_parent_value, '/'); if ($pos) { // we have NOT a first level sub category $cat_dir_parent_value2 = substr($cat_dir_parent_value, 0, $pos); $cat_dir_value2 = substr($cat_dir_parent_value, $pos + 1); $db->setQuery("SELECT * FROM #__jdownloads_categories WHERE cat_dir = '{$cat_dir_value2}' AND cat_dir_parent = '{$cat_dir_parent_value2}'"); } else { // we have a first level sub category $cat_dir_parent_value2 = $cat_dir_parent_value; $cat_dir_value2 = $cat_dir_value; $db->setQuery("SELECT * FROM #__jdownloads_categories WHERE cat_dir = '{$cat_dir_parent_value2}' AND cat_dir_parent = ''"); } $parent_cat = $db->loadObject(); if ($parent_cat) { $parent_id = $parent_cat->id; } else { // can not found the parents category for the new child $log_array[] = JText::_('Abort. Can not find parents category for the new folder: ') . ' <b>' . $searchdirs[$i] . '</b><br />'; break; } } $cat_dir_value = utf8_encode($cat_dir_value); // we need the original folder title as category title $original_folder_name = $cat_dir_value; // check the founded folder name $checked_cat_dir = JDownloadsHelper::getCleanFolderFileName($cat_dir_value, true); // check the folder name result if ($cat_dir_value != $checked_cat_dir) { // build path if ($parent_cat) { if ($parent_cat->cat_dir_parent) { $cat_dir_path = $jd_root . $parent_cat->cat_dir_parent . '/' . $parent_cat->cat_dir . '/' . $checked_cat_dir; $new_cat_dir_name = $parent_cat->cat_dir_parent . '/' . $parent_cat->cat_dir . '/' . $checked_cat_dir; } else { $cat_dir_path = $jd_root . $parent_cat->cat_dir . '/' . $checked_cat_dir; $new_cat_dir_name = $parent_cat->cat_dir . '/' . $checked_cat_dir; } } else { $cat_dir_path = $jd_root . $checked_cat_dir; $new_cat_dir_name = $checked_cat_dir; } // rename the folder - when he already exist: make it unique! $num = 1; while (JFolder::exists($cat_dir_path)) { $cat_dir_path = $cat_dir_path . $num; $checked_cat_dir = $checked_cat_dir . $num; $num++; } if (!JFolder::exists($cat_dir_path)) { $copied = JFolder::move($jd_root . $searchdirs[$i], $cat_dir_path); if ($copied !== true) { $log_array[] = JText::_('Error! Can not change folder name: ') . ' <b>' . $searchdirs[$i] . '</b><br />'; } } else { $log_array[] = JText::_('Error! A folder with the same (cleaned) name exist already: ') . ' <b>' . $searchdirs[$i] . '</b><br />'; } $cat_dir_value = $checked_cat_dir; // update the name in the folder list $searchdirs[$i] = $new_cat_dir_name; } // set access if ($parent_cat) { $access = $parent_cat->access; } else { $access = 1; } // set alias $alias = JApplication::stringURLSafe($cat_dir_value); // set note hint $note = JText::_('COM_JDOWNLOADS_RUN_MONITORING_NOTE_TEXT'); // build table array $data = array('id' => 0, 'parent_id' => $parent_id, 'title' => $original_folder_name, 'alias' => $alias, 'notes' => $note, 'description' => '', 'cat_dir' => $cat_dir_value, 'cat_dir_parent' => $cat_dir_parent_value, 'pic' => $jlistConfig['cat.pic.default.filename'], 'published' => (int) $jlistConfig['autopublish.founded.files'], 'access' => $access, 'metadesc' => '', 'metakey' => '', 'created_user_id' => '0', 'language' => '*', 'rules' => array('core.create' => array(), 'core.delete' => array(), 'core.edit' => array(), 'core.edit.state' => array(), 'core.edit.own' => array(), 'download' => array()), 'params' => array()); // create new cat in table $create_result = $model_category->createAutoCategory($data); if (!$create_result) { // error message $log_array[] = JText::_('Error! Can not create new category for: ') . ' <b>' . $searchdirs[$i] . '</b><br />'; } $new_cats_create++; // copy index.html to the new folder $index_copied = JFile::copy(JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_jdownloads' . DS . 'index.html', $jlistConfig['files.uploaddir'] . DS . $searchdirs[$i] . DS . 'index.html'); $log_array[] = JText::_('COM_JDOWNLOADS_AUTO_CAT_CHECK_ADDED') . ' <b>' . $searchdirs[$i] . '</b><br />'; } $bar->increase(); // calls the bar with every processed element } echo '<small><br />' . JText::_('COM_JDOWNLOADS_BACKEND_AUTOCHECK_SUM_FOLDERS') . ' ' . count($searchdirs) . '<br /><br /></small>'; ob_flush(); flush(); unset($dirs); unset($searchdirs); // ******************************************** // Exists all published category folders? // ******************************************** $mis_cats = 0; // get all published categories but not the root $db->setQuery("SELECT * FROM #__jdownloads_categories WHERE published = 1 AND id > 1"); $cats = $db->loadObjectList(); $count_cats = count($cats); // first progressbar for cats $bar = new ProgressBar(); $title2 = JText::_('COM_JDOWNLOADS_RUN_MONITORING_INFO4'); $bar->setMessage($title2); $bar->setAutohide(false); $bar->setSleepOnFinish(0); $bar->setPrecision(100); $bar->setForegroundColor('#990000'); $bar->setBarLength(300); $bar->initialize($count_cats); // print the empty bar foreach ($cats as $cat) { if ($cat->cat_dir_parent != '') { $cat_dir = $jd_root . $cat->cat_dir_parent . '/' . $cat->cat_dir; } else { $cat_dir = $jd_root . $cat->cat_dir; } // when it not exist, we must unpublish the category if (!JFolder::exists($cat_dir)) { $db->setQuery("UPDATE #__jdownloads_categories SET published = 0 WHERE id = '{$cat->id}'"); $db->execute(); $mis_cats++; $log_array[] = '<font color="red">' . JText::_('COM_JDOWNLOADS_AUTO_CAT_CHECK_DISABLED') . ' <b>' . $cat->cat_dir . '</b></font><br />'; } $bar->increase(); // calls the bar with every processed element } echo '<br /><br />'; unset($cats); // ********************************************************* // Check all files and create for new founded new Downloads // ********************************************************* unset($except_folders[1]); $all_dirs = JDownloadsHelper::scan_dir($dir, $type, $only, $allFiles, $recursive, $onlyDir, $except_folders, $jd_root, $files); if ($all_dirs != FALSE) { $count_files = count($files); // first progressbar for cats $bar = new ProgressBar(); $title3 = JText::_('COM_JDOWNLOADS_RUN_MONITORING_INFO5'); $bar->setMessage($title3); $bar->setAutohide(false); $bar->setSleepOnFinish(0); $bar->setPrecision(100); $bar->setForegroundColor('#990000'); $bar->setBarLength(300); $bar->initialize($count_files); // print the empty bar reset($files); $new_files = 0; foreach ($files as $key3 => $array2) { $filename = $files[$key3]['file']; if ($filename != '') { $dir_path_total = $files[$key3]['path']; $restpath = substr($files[$key3]['path'], $dir_len); $only_dirs = substr($restpath, 0, strlen($restpath) - 1); $upload_dir = $jlistConfig['files.uploaddir'] . '/' . $only_dirs . '/'; $pos = strrpos($only_dirs, '/'); if ($pos) { $cat_dir_parent_value = substr($only_dirs, 0, $pos); $cat_dir_value = substr($only_dirs, $pos + 1); } else { $cat_dir_parent_value = ''; $cat_dir_value = $only_dirs; } // exist still a Download with this filename? $exist_file = false; $db->setQuery("SELECT cat_id FROM #__jdownloads_files WHERE url_download = '" . $filename . "'"); $row_file_exists = $db->loadObjectList(); // when exist, get the category from the Download, when we have really assigned a category (ID > 1) if ($row_file_exists && $row_file_exists[0]->cat_id > 1) { foreach ($row_file_exists as $row_file_exist) { if (!$exist_file) { $db->setQuery("SELECT COUNT(*) FROM #__jdownloads_categories WHERE id = '{$row_file_exist->cat_id}' AND cat_dir = '{$cat_dir_value}' AND cat_dir_parent = '{$cat_dir_parent_value}'"); $row_cat_find = $db->loadResult(); if ($row_cat_find) { $exist_file = true; } } } } else { // it can be an 'uncategorised' if ($row_file_exists && $row_file_exists[0]->cat_id == 1) { $exist_file = true; } else { $exist_file = false; } } // Add the file here in a new Download if (!$exist_file) { // not check the filename when restore backup file if ($task != 'restore.run') { // reset images var $images = ''; $only_name = utf8_encode(JFile::stripExt($filename)); $file_extension = JFile::getExt($filename); // $title = JFilterInput::clean($only_name); $title = JFilterInput::getInstance(null, null, 1, 1)->clean($only_name, 'STRING'); // check filename $filename_new = JDownloadsHelper::getCleanFolderFileName($only_name, true) . '.' . $file_extension; if ($only_name == '') { echo "<script> alert('Error: Filename empty after cleaning: " . $dir_path_total . "'); </script>\n"; continue; // go to next foreach item } if ($filename_new != $filename) { $source = $startdir . $only_dirs . '/' . $filename; $target = $startdir . $only_dirs . '/' . $filename_new; $success = @rename($source, $target); if ($success === true) { $filename = $filename_new; } else { // could not rename filename echo "<script> alert('Error: Could not rename {$filename}'); </script>\n"; continue; // go to next foreach item } } } $target_path = $upload_dir . $filename; // find the category for the new founded file in this folder $db->setQuery("SELECT * FROM #__jdownloads_categories WHERE cat_dir = '{$cat_dir_value}' AND cat_dir_parent = '{$cat_dir_parent_value}'"); $cat = $db->loadObject(); if ($cat) { $id = $cat->id; $access = $cat->access; } else { // it seems that we have a new file in 'uncategorised' folder found $id = 1; $access = 1; } $date = JFactory::getDate(); $tz = JFactory::getConfig()->get('offset'); $date->setTimezone(new DateTimeZone($tz)); $file_extension = JFile::getExt($filename); // set file size $file_size = $files[$key3]['size']; // set note hint $note = JText::_('COM_JDOWNLOADS_RUN_MONITORING_NOTE_TEXT'); // set creation date $creation_date = JFactory::getDate()->toSql(); // set file mime pic $picpath = strtolower(JPATH_SITE . '/images/jdownloads/fileimages/' . $file_extension . '.png'); if (file_exists($picpath)) { $file_pic = $file_extension . '.png'; } else { $file_pic = $jlistConfig['file.pic.default.filename']; } // create thumbs form pdf if ($jlistConfig['create.pdf.thumbs'] && $jlistConfig['create.pdf.thumbs.by.scan'] && $file_extension == 'pdf') { $thumb_path = JPATH_SITE . '/images/jdownloads/screenshots/thumbnails/'; $screenshot_path = JPATH_SITE . '/images/jdownloads/screenshots/'; $pdf_thumb_name = jdownloadsHelper::create_new_pdf_thumb($target_path, $only_name, $thumb_path, $screenshot_path); if ($pdf_thumb_name) { $images = $pdf_thumb_name; } } // create auto thumb when founded file is an image if ($jlistConfig['create.auto.thumbs.from.pics'] && $jlistConfig['create.auto.thumbs.from.pics.by.scan']) { if ($file_is_image = JDownloadsHelper::fileIsPicture($filename)) { $thumb_created = jdownloadsHelper::create_new_thumb($target_path); if ($thumb_created) { $images = $filename; // create new big image for full view $image_created = jdownloadsHelper::create_new_image($target_path); } } } $sha1_value = sha1_file($target_path); $md5_value = md5_file($target_path); // build data array $data = array('file_id' => 0, 'cat_id' => $id, 'file_title' => $title, 'file_alias' => '', 'notes' => $note, 'url_download' => $filename, 'size' => $file_size, 'description' => JDownloadsHelper::getOnlyLanguageSubstring($jlistConfig['autopublish.default.description']), 'file_pic' => $file_pic, 'images' => $images, 'date_added' => $creation_date, 'sha1_value' => $sha1_value, 'md5_value' => $md5_value, 'published' => (int) $jlistConfig['autopublish.founded.files'], 'access' => $access, 'metadesc' => '', 'metakey' => '', 'created_user_id' => '0', 'language' => '*', 'rules' => array('core.create' => array(), 'core.delete' => array(), 'core.edit' => array(), 'core.edit.state' => array(), 'core.edit.own' => array(), 'download' => array()), 'params' => array()); // create new download in table $create_result = $model_download->createAutoDownload($data); if (!$create_result) { // error message echo "<script> alert('Error: Could not add download for: {$filename}'); window.history.go(-1); </script>\n"; exit; } $new_files++; $log_array[] = JText::_('COM_JDOWNLOADS_AUTO_FILE_CHECK_ADDED') . ' <b>' . $only_dirs . '/' . $filename . '</b><br />'; } } $bar->increase(); // calls the bar with every processed element } } echo '<small><br />' . JText::_('COM_JDOWNLOADS_BACKEND_AUTOCHECK_SUM_FILES') . ' ' . count($files) . '<br /><br /></small>'; unset($files); flush(); // **************************************************** // Check whether the assigned files from all published downloads exists // - otherwise unpublish this downloads // **************************************************** $mis_files = 0; $db->setQuery("SELECT * FROM #__jdownloads_files WHERE published = 1"); $files = $db->loadObjectList(); $count_files = count($files); // first progressbar for cats $bar = new ProgressBar(); $title4 = JText::_('COM_JDOWNLOADS_RUN_MONITORING_INFO6'); $bar->setMessage($title4); $bar->setAutohide(false); $bar->setSleepOnFinish(0); $bar->setPrecision(100); $bar->setForegroundColor('#990000'); $bar->setBarLength(300); $bar->initialize($count_files); // print the empty bar foreach ($files as $file) { // we checked only intern stored files if ($file->url_download != '') { // get the category path only, when we have not an 'uncategorised' Download if ($file->cat_id > 1) { $db->setQuery("SELECT cat_dir, cat_dir_parent FROM #__jdownloads_categories WHERE id = '{$file->cat_id}'"); $cat = $db->loadObject(); if ($cat->cat_dir_parent != '') { $cat_dir_path = $cat->cat_dir_parent . '/' . $cat->cat_dir; } else { $cat_dir_path = $cat->cat_dir; } $file_path = $jd_root . $cat_dir_path . '/' . $file->url_download; $cat_dir = $cat->cat_dir . '/' . $file->url_download; } else { // file in 'uncategorised' folder $file_path = $uncat_dir . $file->url_download; $cat_dir = $file_path; } if (!file_exists($file_path)) { $db->setQuery("UPDATE #__jdownloads_files SET published = 0 WHERE file_id = '{$file->file_id}'"); $db->execute(); $mis_files++; $log_array[] = '<font color="red">' . JText::_('COM_JDOWNLOADS_AUTO_FILE_CHECK_DISABLED') . ' <b>' . $cat_dir . '</b></font><br />'; } } $bar->increase(); // calls the bar with every processed element } echo '<br /><br />'; echo '<div style="font-family:Verdana; font-size:10"><b>' . JText::_('COM_JDOWNLOADS_RUN_MONITORING_INFO7') . '</b><br /><br /></div>'; flush(); // build log message if (count($log_array) > 0) { array_unshift($log_array, date(JText::_('DATE_FORMAT_LC2')) . ':<br />'); } foreach ($log_array as $log) { $log_message .= $log; } // when we have changed anything, we store it in the config if ($log_message != '') { $db->setQuery("UPDATE #__jdownloads_config SET setting_value = '{$log_message}' WHERE setting_name = 'last.log.message'"); $db->execute(); } if ($task == 'scan.files') { echo '<table width="100%"><tr><td><font size="1" face="Verdana">' . JText::_('COM_JDOWNLOADS_BACKEND_AUTOCHECK_TITLE') . '</font><br />'; if ($new_cats_create > 0) { echo '<font color="#FF6600" size="1" face="Verdana"><b>' . $new_cats_create . ' ' . JText::_('COM_JDOWNLOADS_BACKEND_AUTOCHECK_NEW_CATS') . '</b></font><br />'; } else { echo '<font color="green" size="1" face="Verdana"><b>' . JText::_('COM_JDOWNLOADS_BACKEND_AUTOCHECK_NO_NEW_CATS') . '</b></font><br />'; } if ($new_files > 0) { echo '<font color="#FF6600" size="1" face="Verdana"><b>' . $new_files . ' ' . JText::_('COM_JDOWNLOADS_BACKEND_AUTOCHECK_NEW_FILES') . '</b></font><br />'; } else { echo '<font color="green" size="1" face="Verdana"><b>' . JText::_('COM_JDOWNLOADS_BACKEND_AUTOCHECK_NO_NEW_FILES') . '</b></font><br />'; } if ($mis_cats > 0) { echo '<font color="#990000" size="1" face="Verdana"><b>' . $mis_cats . ' ' . JText::_('COM_JDOWNLOADS_BACKEND_AUTOCHECK_MISSING_CATS') . '</b></font><br />'; } else { echo '<font color="green" size="1" face="Verdana"><b>' . JText::_('COM_JDOWNLOADS_BACKEND_AUTOCHECK_NO_MISSING_CATS') . '</b></font><br />'; } if ($mis_files > 0) { echo '<font color="#990000" size="1" face="Verdana"><b>' . $mis_files . ' ' . JText::_('COM_JDOWNLOADS_BACKEND_AUTOCHECK_MISSING_FILES') . '</b><br /></td></tr></table>'; } else { echo '<font color="green" size="1" face="Verdana"><b>' . JText::_('COM_JDOWNLOADS_BACKEND_AUTOCHECK_NO_MISSING_FILES') . '</b><br /></td></tr></table>'; } if ($log_message) { echo '<table width="100%"><tr><td><font size="1" face="Verdana">' . JText::_('COM_JDOWNLOADS_BACKEND_AUTOCHECK_LOG_TITLE') . '<br />' . $log_message . '</font></td></tr></table>'; } } } else { // error upload dir not exists echo '<font color="red"><b>' . JText::sprintf('COM_JDOWNLOADS_AUTOCHECK_DIR_NOT_EXIST', $jlistConfig['files.uploaddir']) . '<br /><br />' . JText::_('COM_JDOWNLOADS_AUTOCHECK_DIR_NOT_EXIST_2') . '</b></font>'; } } }
function generoi_custom_excel($tuotteet) { global $kukarow, $yhtiorow; if (count($tuotteet) == 0) { return false; } $xls_progress_bar = new ProgressBar(t("Tallennetaan exceliin")); $xls_progress_bar->initialize(count($tuotteet)); $xls = new pupeExcel(); $rivi = 0; $sarake = 0; $edellinen_ryhma = null; $headerit = array('tuoteno' => t('Tuoteno'), 'tuote_nimi' => t('Tuotteen nimi'), 'kappalemaara' => t('Kappalemaara'), 'yksikko' => t('Yksikkö'), 'paivitys_pvm' => t('Päivitys päivämäärä'), 'ostohinta' => t('Ostohinta'), 'kehahin' => t('Keskihankintahinta'), 'ovh_hinta' => t('Ovh') . '-' . t('Hinta'), 'ryhman_ale' => t('Ryhmän ale'), 'hinnasto_hinta' => t('Hinnasto hinta'), 'status' => t('Status'), 'ale_prosentti' => t('Ale prosentti'), 'tarjous_hinta' => t('Alennettu hinta'), 'alennus_prosentti' => t('Alennus prosentti'), 'kate_prosentti' => t('Kate prosentti')); foreach ($headerit as $header) { $xls->write($rivi, $sarake, $header, array('bold' => true)); $sarake++; } $sarake = 0; $rivi++; foreach ($tuotteet as $tuote) { if ($tuote['aleryhma']['ryhma'] != $edellinen_ryhma) { $xls->write($rivi, $sarake, t('Ryhmä'), array('bold' => true)); $sarake++; $xls->write($rivi, $sarake, $tuote['aleryhma']['selite'], array('bold' => true)); $rivi++; $sarake = 0; } $xls->write($rivi, $sarake, $tuote['tuoteno']); $sarake++; $xls->write($rivi, $sarake, $tuote['tuote_nimi']); $sarake++; $xls->write($rivi, $sarake, $tuote['kappalemaara']); $sarake++; $xls->write($rivi, $sarake, $tuote['yksikko']); $sarake++; $xls->write($rivi, $sarake, date('d.m.Y', strtotime($tuote['paivitys_pvm']))); $sarake++; $xls->write($rivi, $sarake, $tuote['ostohinta']); $sarake++; $xls->write($rivi, $sarake, $tuote['kehahin']); $sarake++; $xls->write($rivi, $sarake, $tuote['ovh_hinta']); $sarake++; $xls->write($rivi, $sarake, $tuote['ryhman_ale']); $sarake++; $xls->write($rivi, $sarake, $tuote['hinnasto_hinta']); $sarake++; $xls->write($rivi, $sarake, $tuote['status']); $sarake++; $xls->write($rivi, $sarake, $tuote['ale_prosentti']); $sarake++; $xls->write($rivi, $sarake, $tuote['tarjous_hinta']); $sarake++; $xls->write($rivi, $sarake, $tuote['alennus_prosentti']); $sarake++; $xls->write($rivi, $sarake, $tuote['kate_prosentti']); $sarake++; $xls_progress_bar->increase(); $edellinen_ryhma = $tuote['aleryhma']['ryhma']; $sarake = 0; $rivi++; } echo "<br/>"; $xls_tiedosto = $xls->close(); return $xls_tiedosto; }
} ?> <p> ProgressBar.class.php is an easy to use solution for time consuming operations and loops in PHP. </p> <p> The class increases the timelimit for script-execution (if safe-mode is turned off), prevents a browser-timeout by sending pieces auf the progressbar to the browser and gives the user live-feedback on the progress of the running operation. </p> <p> As of version 1.2 you can use setter-methods to change the appeareance of the bar at runtime. Have a look at the source of this demo to see how it works! </p> <?php $bar1 = new ProgressBar('End of simulation: 0%'); $bar1->setForegroundColor('#FFA200'); $elements1 = 3; //total number of elements to process $bar1->initialize($elements1); //print the empty bar for ($i = 0; $i < $elements1; $i++) { sleep(1); // simulate a time consuming process $bar1->increase(); //calls the bar with every processed element $bar1->setMessage('End of simulation: ' . ($i + 1) * 33 . '%'); } $bar1->setMessage('End of simulation: 100%'); ?> </body> </html>
function generoi_custom_excel($valmistukset, $valmistuslinjat, $esitysmuoto) { global $kukarow, $yhtiorow; if (count($valmistukset) == 0) { return false; } $xls_progress_bar = new ProgressBar(t("Tallennetaan exceliin")); $xls_progress_bar->initialize(count($valmistukset)); $xls = new pupeExcel(); $rivi = 0; $sarake = 0; $valmistus_headerit = array('tuoteno' => t('Valmisteen tuoteno'), 'nimitys' => t('Valmisteen nimitys'), 'lasku_tunnus' => t('Valmistusnumero'), 'yksikko' => t('Valmistuslinja'), 'valmistettava_kpl' => t('Valmistetaan kpl'), 'ostohinta' => t('Valmistuksen tila'), 'kerayspvm' => t('Keräyspäivä'), 'toimaika' => t('Valmistuspäivä')); $raaka_aine_headerit = array('tuoteno' => t('Raaka-Aineen Tuoteno'), 'nimitys' => t('Raaka-Aineen Nimitys'), 'kappalemaara' => t('Valmistusnumero'), 'yksikko' => t('Saldo'), 'paivitys_pvm' => t('Hyllyssä'), 'ostohinta' => t('Myytävissä'), 'kehahin' => t('Tilattu'), 'ryhman_ale' => t('Toimittaja')); $tulostettu = false; foreach ($valmistukset as $valmistus) { foreach ($valmistus['tilausrivit'] as $tilausrivi) { if ($esitysmuoto == 'A') { foreach ($valmistus_headerit as $valmistus_header) { $xls->write($rivi, $sarake, $valmistus_header, array('bold' => true)); $sarake++; } $sarake = 0; $rivi++; $xls->write($rivi, $sarake, $tilausrivi['tuoteno']); $sarake++; $xls->write($rivi, $sarake, $tilausrivi['nimitys']); $sarake++; $xls->write($rivi, $sarake, $tilausrivi['lasku_tunnus']); $sarake++; $valmistuslinja = search_array_key_for_value_recursive($valmistuslinjat, 'selite', $tilausrivi['valmistuslinja']); $valmistuslinja = isset($valmistuslinja[0]['selitetark']) ? $valmistuslinja[0]['selitetark'] : ''; if (empty($valmistuslinja)) { $xls->write($rivi, $sarake, t('Ei valmistuslinjaa')); $sarake++; } else { $xls->write($rivi, $sarake, $valmistuslinja['selitetark']); $sarake++; } $xls->writeNumber($rivi, $sarake, $tilausrivi['valmistettava_kpl']); $sarake++; $laskutyyppi = $tilausrivi['tila']; $alatila = $tilausrivi['alatila']; require 'inc/laskutyyppi.inc'; $xls->write($rivi, $sarake, $laskutyyppi . ' ' . $alatila); $sarake++; $xls->write($rivi, $sarake, date('d.m.Y', strtotime($tilausrivi['kerayspvm']))); $sarake++; $xls->write($rivi, $sarake, date('d.m.Y', strtotime($tilausrivi['toimaika']))); $sarake++; $rivi = $rivi + 2; $sarake = 0; } if (!$tulostettu and $esitysmuoto == 'B') { foreach ($raaka_aine_headerit as $raaka_aine_header) { $xls->write($rivi, $sarake, $raaka_aine_header, array('bold' => true)); $sarake++; } $sarake = 0; $rivi++; $tulostettu = true; } foreach ($tilausrivi['raaka_aineet'] as $raaka_aine) { $xls->write($rivi, $sarake, $raaka_aine['tuoteno']); $sarake++; $xls->write($rivi, $sarake, $raaka_aine['nimitys']); $sarake++; $xls->write($rivi, $sarake, $raaka_aine['lasku_tunnus']); $sarake++; $xls->writeNumber($rivi, $sarake, $raaka_aine['saldo']); $sarake++; $xls->writeNumber($rivi, $sarake, $raaka_aine['hyllyssa']); $sarake++; $xls->writeNumber($rivi, $sarake, $raaka_aine['myytavissa']); $sarake++; $xls->writeNumber($rivi, $sarake, $raaka_aine['tilattu']); $sarake++; $xls->write($rivi, $sarake, $raaka_aine['toimittaja']); $sarake++; $rivi++; $sarake = 0; } $xls_progress_bar->increase(); if ($esitysmuoto == 'A') { $rivi = $rivi + 2; } $sarake = 0; } } echo "<br/>"; $xls_tiedosto = $xls->close(); return $xls_tiedosto; }