$toimipaikkalisa = ""; } if ($onkolaajattoimipaikat and isset($toimipaikka) and $toimipaikka == 'kaikki') { $joinlisa .= " LEFT JOIN yhtion_toimipaikat ON (yhtion_toimipaikat.yhtio = lasku.yhtio AND yhtion_toimipaikat.tunnus = lasku.yhtio_toimipaikka)"; $selectlisa .= ", IF(yhtion_toimipaikat.tunnus IS NULL, '" . t('Ei toimipaikkaa') . "', yhtion_toimipaikat.nimi) as toimipaikka_nimi"; } // etsitään vanhoja keikkoja, vanhatunnus pitää olla tyhjää niin ei listata liitettyjä laskuja $query = "SELECT lasku.tunnus,\n lasku.laskunro,\n lasku.comments,\n lasku.nimi,\n lasku.ytunnus,\n lasku.luontiaika,\n lasku.laatija,\n lasku.rahti_etu,\n lasku.kohdistettu,\n lasku.yhtio_toimipaikka\n {$selectlisa}\n FROM lasku\n {$joinlisa}\n where lasku.yhtio = '{$kukarow['yhtio']}'\n and lasku.liitostunnus = '{$toimittajaid}'\n and lasku.tila = 'K'\n and lasku.alatila = ''\n and lasku.vanhatunnus = 0\n and lasku.mapvm = '0000-00-00'\n {$toimipaikkalisa}\n {$groupbylisa}\n {$havinglisa}\n ORDER BY lasku.laskunro DESC"; $result = pupe_query($query); echo "<font class='head'>" . t("Toimittajan keskeneräiset saapumiset") . "</font><hr>"; if (mysql_num_rows($result) > 0) { $maara = 9; if ($onkolaajattoimipaikat and isset($toimipaikka) and $toimipaikka == 'kaikki') { $maara = 10; } pupe_DataTables(array(array($pupe_DataTables, $maara, $maara, false))); echo "<table class='display dataTable' id='{$pupe_DataTables}'>"; echo "<thead>"; echo "<tr>"; if ($onkolaajattoimipaikat and isset($toimipaikka) and $toimipaikka == 'kaikki') { echo "<th valign='top'>" . t("toimipaikka") . "</th>"; } echo "<th valign='top'>" . t("saapuminen") . "</th>"; echo "<th valign='top'> </th>"; echo "<th valign='top'>" . t("laadittu") . " /<br>" . t("viety varastoon") . "</th>"; echo "<th valign='top'>" . t("kohdistus") . " /<br>" . t("lisätiedot") . "</th>"; echo "<th valign='top'>" . t("paikat") . " /<br>" . t("sarjanrot") . "</th>"; echo "<th valign='top'>" . t("kohdistettu") . " /<br>" . t("varastossa") . "</th>"; echo "<th valign='top'>" . t("tilaukset") . "</th>"; echo "<th valign='top'>" . t("ostolaskuja") . " /<br>" . t("kululaskuja") . "</th>"; echo "<th valign='top'>" . t("toiminto") . "</th>";
$lataa_tiedosto = 1; } if ($_REQUEST["kaunisnimi"] != '') { $_REQUEST["kaunisnimi"] = str_replace("/", "", $_REQUEST["kaunisnimi"]); } } //* Tämä skripti käyttää slave-tietokantapalvelinta *// $useslave = 1; require "../inc/parametrit.inc"; require 'valmistuslinjat.inc'; if (isset($tee) and $tee == "lataa_tiedosto") { readfile("/tmp/" . $tmpfilenimi); exit; } // Pupe datatables koodi pupe_DataTables(array(array($pupe_DataTables[0], 12, 12))); // Piirretään taulu aluksi display:none, ettei selain piirrä sitä ruudulle. Toglataan display päälle kun dokumentti on ready ja datatables tehny rivityksen. echo '<script language="javascript"> $(document).ready(function() { $("#raportti_valmistuksista").toggle(); }); </script>'; // Tarvittavat muuttujat $tee = isset($tee) ? trim($tee) : ""; echo "<font class='head'>" . t("Raportti avoimista ja tehdyistä valmistuksista") . "</font><hr>"; echo "<br>"; // Ehdotetaan oletuksena edellistä kuukautta if (!isset($pp1)) { $pp1 = date("d", mktime(0, 0, 0, date("m") - 1, 1, date("Y"))); } if (!isset($kk1)) {
$excelsarake++; $worksheet->write($excelrivi, $excelsarake, t("Luottoraja"), $format_bold); $excelsarake = 0; $excelrivi++; } echo "<font class='head'>" . t("Saatavat") . " - {$yhtiorow['nimi']} - {$sappl}.{$sakkl}.{$savvl}</font><hr>"; if ($eiliittymaa != 'ON') { if ($grouppaus == "kustannuspaikka") { $sarakemaara = count($saatavat_array) + 8; } else { $sarakemaara = count($saatavat_array) + 9; if ($tiliointilisa != "") { $sarakemaara++; } } pupe_DataTables(array(array($pupe_DataTables, $sarakemaara, $sarakemaara))); } // Linkki asiakasrappariin if ($grouppaus == 'asiakas') { $asirappari_linkki_alatila = "T"; } else { $asirappari_linkki_alatila = "Y"; } echo "<table class='display dataTable' id='{$pupe_DataTables}'>"; echo "<thead>"; echo "<tr>"; if ($grouppaus != "kustannuspaikka") { echo "<th>" . t("Ytunnus") . "</th>"; echo "<th>" . t("Nimi") . "</th>"; } if ($grouppaus == "kustannuspaikka" or $tiliointilisa != "") {
} else { echo "<td colspan='4' class='back'>"; } echo "<td class='back'>"; echo "<input id='etsinappi' type='submit' value='" . t("Hae") . "'>"; echo "</td></tr>"; echo "</table>"; echo "</form>"; if (mysql_num_rows($result) > 50 and $limittrikkeri == "A") { echo "<p><font class='error'>" . t("HUOM") . "! " . t("Näytetään vain 50 uusinta tilausta") . "</font></p>"; } if (mysql_num_rows($result) > 0) { if (substr($toim, 0, 8) == "KONSERNI" and $yhtiorow['konsernivarasto'] != '' and $konsernivarasto_yhtiot != '') { pupe_DataTables(array(array($pupe_DataTables, 11, 12))); } else { pupe_DataTables(array(array($pupe_DataTables, 10, 11))); } echo "<br>"; echo "<table class='display dataTable' id='{$pupe_DataTables}'>"; echo "<thead>"; echo "<tr>"; for ($i = 0; $i < mysql_num_fields($result) - 8; $i++) { echo "<th>" . t(mysql_field_name($result, $i)) . "</th>"; } echo "<th>" . t("Tyyppi") . "</th>\n <th style='visibility:hidden;'></th>"; echo "</tr>"; echo "<tr>"; for ($i = 0; $i < mysql_num_fields($result) - 8; $i++) { echo "<td><input type='text' class='search_field' name='search_" . t(mysql_field_name($result, $i)) . "'></td>"; } echo "<td><input type='text' class='search_field' name='search_tyyppi'></td>\n <td class='back'></td>";
if (mysql_num_rows($result) == 0) { echo "<b>" . t("Sinulla ei ole hyväksymättömiä laskuja") . "</b><br>"; require "inc/footer.inc"; exit; } //tablen sarakkeiden määrä riippuu $kukarow['taso'] $sarakkeet_base = 12; if ($kukarow['taso'] == 1 or $kukarow['taso'] == 2 or $kukarow['taso'] == 3) { $sarakkeet_base = 14; } $sarakkeet_vis = 11; if ($liitetaanko_editilaus_laskulle_hakemisto != '') { $sarakkeet_vis++; $sarakkeet_base++; } pupe_DataTables(array(array('mur', $sarakkeet_vis, $sarakkeet_base))); echo "<table class='display dataTable' id='mur'>"; echo "<thead>"; echo "<tr>"; echo "<th>" . t("Tapvm") . "</th>"; echo "<th>" . t("Eräpvm/Kapvm") . "</th>"; echo "<th>" . t("Ytunnus") . "</th>"; echo "<th>" . t("Nimi") . "</th>"; echo "<th>" . t("Postitp") . "</th>"; echo "<th>" . t("Yhtiön valuutassa") . "</th>"; echo "<th>" . t("Laskun valuutassa") . "</th>"; echo "<th>" . t("Laskunro") . "</th>"; echo "<th>" . t("Liitetty") . "</th>"; echo "<th>" . t("Tyyppi") . "</th>"; if ($liitetaanko_editilaus_laskulle_hakemisto != '') { echo "<th>", t("Vertailu"), "</th>";
<?php //* Tämä skripti käyttää slave-tietokantapalvelinta *// $useslave = 1; // DataTables päälle $pupe_DataTables = "selaasoppareita"; require '../inc/parametrit.inc'; pupe_DataTables(array(array($pupe_DataTables, 14, 14, true, true))); $query_ale_lisa = generoi_alekentta('M'); echo "<font class='head'>" . t("Selaa Sopimuksia") . "</font><hr>"; // Tehdään taulukko echo "<table class='display dataTable' id='{$pupe_DataTables}'>"; echo "<thead>"; echo "<tr>"; echo "<th>" . t("Sopimus") . "<br>" . t("Myyjä") . "</th>"; echo "<th>" . t("Asiakkaan") . "<br>" . t("Tilausnumero") . "</th>"; echo "<th>" . t("Asiakas") . "</th>"; echo "<th>" . t("Tuoteno") . "</th>"; echo "<th>" . t("Nimitys") . "</th>"; echo "<th>" . t("Kommentti") . "</th>"; echo "<th>" . t("Sisäinen") . "<br>" . t("Kommentti") . "</th>"; echo "<th>" . t("Alku pvm") . "</th>"; echo "<th>" . t("Loppu pvm") . "</th>"; echo "<th>" . t("Kpl") . "</th>"; echo "<th>" . t("Hinta") . "</th>"; echo "<th>" . t("Rivihinta") . "</th>"; echo "<th>" . t("Sarjanumero") . "</th>"; echo "<th>" . t("Vasteaika") . "</th>"; echo "</tr>"; // Hakukentät echo "<tr>";
} } echo "<tr>"; echo "<td nowrap><a href='" . $palvelin2 . "crm/kuittaamattomat.php?tee=A&kaletunnus={$prow['tunnus']}&kuka={$prow['kuka']}'>" . tv1dateconv($prow["Muistutukset"]) . "</a></td>"; echo "<td>{$prow['Asiakas']}<br>{$prow['Yhteyshenkilo']}</td>"; echo "<td>{$prow['Kommentit']}</td>"; echo "<td nowrap>{$prow['Tapa']}</td>"; echo "</tr>"; } echo "</table><br>"; } // Näytetään käyttäjäkohtaiset työmääräykset $tyojonosql = "SELECT lasku.tunnus,\n lasku.nimi,\n lasku.toimaika,\n a2.selitetark tyostatus,\n a2.selitetark_2 tyostatusvari,\n a5.selitetark tyom_prioriteetti\n FROM lasku\n JOIN tyomaarays ON (tyomaarays.yhtio = lasku.yhtio AND tyomaarays.otunnus = lasku.tunnus AND tyomaarays.tyojono != '' AND tyomaarays.suorittaja = '{$kukarow["kuka"]}')\n LEFT JOIN avainsana a2 ON (a2.yhtio=tyomaarays.yhtio and a2.laji='TYOM_TYOSTATUS' and a2.selite=tyomaarays.tyostatus)\n LEFT JOIN avainsana a5 ON (a5.yhtio=tyomaarays.yhtio and a5.laji='TYOM_PRIORIT' and a5.selite=tyomaarays.prioriteetti)\n WHERE lasku.yhtio = '{$kukarow["yhtio"]}'\n AND lasku.tila in ('A','L','N','S','C')\n AND lasku.alatila != 'X'\n ORDER BY ifnull(a5.jarjestys, 9999), ifnull(a2.jarjestys, 9999), lasku.toimaika asc, a2.selitetark"; $tyoresult = pupe_query($tyojonosql); if (mysql_num_rows($tyoresult) > 0) { pupe_DataTables(array(array($pupe_DataTables[0], 5, 5))); $padding_muuttuja = " style='padding-right:15px;'"; echo "<table class='display dataTable' id='{$pupe_DataTables['0']}'>"; echo "<thead>"; echo "<tr>"; echo "<td colspan='5' class='back'><font class='head'>" . t("Omat Työmääräykset") . "</font><hr></td>"; echo "</tr>"; echo "<tr>"; echo "<th {$padding_muuttuja}>" . t("Työnumero") . "</th>"; echo "<th {$padding_muuttuja}>" . t("Prioriteetti") . "</th>"; echo "<th {$padding_muuttuja}>" . t("Status") . "</th>"; echo "<th {$padding_muuttuja}>" . t("Asiakas") . "</th>"; echo "<th {$padding_muuttuja}>" . t("Päivämäärä") . "</th>"; echo "</tr>"; echo "</thead>"; echo "<tbody>";
echo "</td>"; echo "<tr>"; echo "<tr>"; echo "<th>" . t('Loppupäivämäärä') . "</th>"; echo "<td>"; echo "<input type='text' id='ppl' name='ppl' value='{$ppl}' size='3' />"; echo "<input type='text' id='kkl' name='kkl' value='{$kkl}' size='3' />"; echo "<input type='text' id='vvl' name='vvl' value='{$vvl}' size='6' />"; echo "</td>"; echo "<td class='back'><input type='submit' value='" . t('Hae') . "' /></td>"; echo "</tr>"; echo "</table>"; echo "</form><br>"; if (mysql_num_rows($result) > 0) { echo "<form method = 'post'>\n <input type='hidden' name = 'tila' value='{$tila}'>\n <input type='hidden' name = 'ytunnus' value = '{$ytunnus}'>\n <input type='hidden' name = 'asiakasid' value = '{$asiakasid}'>\n <input type='hidden' name = 'valintra' value = '{$valintra}'>\n <input type='hidden' name = 'savalkoodi' value = '{$savalkoodi}'>\n <input type='hidden' name = 'alatila' value = '{$alatila}'>\n <input type='hidden' name = 'lopetus' value = '{$lopetus}'>"; pupe_DataTables(array(array($pupe_DataTables, 12, 12, false, false))); echo "<table class='display dataTable' id='{$pupe_DataTables}'><thead>"; echo "<tr>"; echo "<th valign='top'>" . t("Laskunro") . "</th>"; echo "<th valign='top'>" . t("Pvm") . "</th>"; echo "<th valign='top'>" . t("Eräpäivä") . "</th>"; echo "<th valign='top'>" . t("Summa") . "</th>"; echo "<th valign='top'>" . t("Avoinsaldo") . "</th>"; echo "<th valign='top'>" . t("Kassa-ale") . "<br>" . t("pvm") . "</th>"; echo "<th valign='top'>" . t("Kassa-ale") . "<br>" . t("summa") . "</th>"; echo "<th valign='top'>" . t("Maksu") . "<br>" . t("pvm") . "</th>"; echo "<th valign='top'>" . t("Ikä") . "</th>"; echo "<th valign='top'>" . t("Korko") . "</th>"; echo "<th valign='top'>" . t("Korkolasku") . "<br>" . t("pvm") . "</th>"; echo "<th valign='top'>" . t("Maksusuoritukset") . "</th>"; echo "</tr>";
} echo "<table>"; echo "<tr>"; echo "<th colspan='2'>" . t("Kirjaa luottotappioksi") . "</th>"; echo "</tr><tr>"; echo "<td>" . t("Päivämäärä") . " " . t("pp-kk-vvvv") . "</td>"; echo "<td>\n <input type='text' name='tpp' maxlength='2' size='2' value='{$tpp}'>\n <input type='text' name='tpk' maxlength='2' size='2' value='{$tpk}'>\n <input type='text' name='tpv' maxlength='4' size='5' value='{$tpv}'></td>"; echo "<td class='back'><input type='submit' value='" . t("Luottotappio") . "'></td>"; echo "</tr>"; echo "</table>"; echo "</form>"; $formi = 'pvm'; $kentta = 'tpp'; } if ($tila == "") { pupe_DataTables(array(array($pupe_DataTables, 5, 6))); $lisa = ""; $erachk = ""; if ($eraantyneet != "") { $lisa = " and erpcm < curdate() "; $erachk = "SELECTED"; } $query = "SELECT *, concat_ws(' ', nimi, nimitark, '<br>', osoite, '<br>', postino, postitp) asiakas, sum(summa-saldo_maksettu) summa, count(*) kpl, group_concat(distinct laskunro SEPARATOR '<br>') laskut\n FROM lasku USE INDEX (yhtio_tila_mapvm)\n WHERE mapvm = '0000-00-00'\n AND tila = 'U'\n AND alatila = 'X'\n AND yhtio = '{$kukarow['yhtio']}'\n AND liitostunnus != 0\n {$lisa}\n GROUP BY liitostunnus\n ORDER BY ytunnus"; $result = pupe_query($query); echo "<form method = 'post'>"; echo "<table>"; echo "<tr><th>" . t("Rajaus") . "</th>"; echo "<td><select name='eraantyneet'>\n <option value=''>" . t("Näytä kaikki laskut") . "</option>\n <option value='E' {$erachk}>" . t("Näytä vain erääntyneet laskut") . "</option>\n </select></td>\n <td class='back'><input type='submit' value='" . t("Aja") . "'></td>"; echo "</table>"; echo "</form><br>"; echo "<table class='display dataTable' id='{$pupe_DataTables}'>";
function piirra_tilaus_table($tilaukset, $rajaus, $pupe_DataTables) { global $yhtiorow, $palvelin2; pupe_DataTables(array(array($pupe_DataTables, 9, 12))); echo "<table class='display dataTable' id='{$pupe_DataTables}'>"; echo "<thead>"; echo "<tr>"; echo "<th>" . t("Kuitti") . "</th>"; echo "<th>" . t("Tilaus") . "</th>"; echo "<th>" . t("Asiakas") . "</th>"; echo "<th>" . t("As.nro") . "</th>"; echo "<th>" . t("Aika") . "</th>"; echo "<th>" . t("Myyjä") . "</th>"; echo "<th>" . t("Summa") . "</th>"; echo "<th>" . t("Astilno") . "</th>"; echo "<th>" . t("Tilausviite") . "</th>"; echo "<th class='back'></th>"; echo "<th class='back'></th>"; echo "<th class='back'></th>"; echo "</tr>"; echo "<tr>"; echo "<td><input type='text' class='search_field' name='search_kuitti'></td>"; echo "<td><input type='text' class='search_field' name='search_tilaus'></td>"; echo "<td><input type='text' class='search_field' name='search_asiakas'></td>"; echo "<td><input type='text' class='search_field' name='search_asnro'></td>"; echo "<td><input type='text' class='search_field' name='search_aika'></td>"; echo "<td><input type='text' class='search_field' name='search_myyja'></td>"; echo "<td><input type='text' class='search_field' name='search_summa'></td>"; echo "<td><input type='text' class='search_field' name='search_astilno'></td>"; echo "<td><input type='text' class='search_field' name='search_tilausviite'></td>"; echo "<td class='back'>"; echo "<td class='back'>"; echo "<td class='back'>"; echo "</tr>"; echo "</thead>"; echo "<tbody>"; while ($tilaus = mysql_fetch_assoc($tilaukset)) { $tilaus["summa"] = number_format($tilaus["summa"], $yhtiorow["hintapyoristys"], ",", " "); $lopetus = "{$palvelin2}tilauskasittely/maksutapahtumaselaus.php////" . "rajaus[alku][paiva]={$rajaus["alku"]["paiva"]}//" . "rajaus[alku][kuukausi]={$rajaus["alku"]["kuukausi"]}//" . "rajaus[alku][vuosi]={$rajaus["alku"]["vuosi"]}//" . "rajaus[loppu][paiva]={$rajaus["loppu"]["paiva"]}//" . "rajaus[loppu][kuukausi]={$rajaus["loppu"]["kuukausi"]}//" . "rajaus[loppu][vuosi]={$rajaus["loppu"]["vuosi"]}//" . "rajaus[limit]={$rajaus["limit"]}"; echo "<tr>"; echo "<td class='text-right'>{$tilaus["laskunro"]}</td>"; echo "<td class='text-right'>{$tilaus["tunnus"]}</td>"; echo "<td>{$tilaus["asiakas"]}</td>"; echo "<td class='text-right'>{$tilaus["asiakasnro"]}</td>"; echo "<td>{$tilaus["laskutettu"]}</td>"; echo "<td>{$tilaus["myyja"]}</td>"; echo "<td class='text-right'>{$tilaus["summa"]}</td>"; echo "<td class='text-right'>{$tilaus["asiakkaan_tilausnumero"]}</td>"; echo "<td class='text-right'>{$tilaus["viite"]}</td>"; echo "<td class='back'>"; echo "<form>"; echo "<input type='hidden' name='rajaus[alku][vuosi]' value='{$rajaus["alku"]["vuosi"]}'>"; echo "<input type='hidden' name='rajaus[alku][kuukausi]' value='{$rajaus["alku"]["kuukausi"]}'>"; echo "<input type='hidden' name='rajaus[alku][paiva]' value='{$rajaus["alku"]["paiva"]}'>"; echo "<input type='hidden' name='rajaus[loppu][vuosi]' value='{$rajaus["loppu"]["vuosi"]}'>"; echo "<input type='hidden' name='rajaus[loppu][kuukausi]' value='{$rajaus["loppu"]["kuukausi"]}'>"; echo "<input type='hidden' name='rajaus[loppu][paiva]' value='{$rajaus["loppu"]["paiva"]}'>"; echo "<input type='hidden' name='rajaus[limit]' value='{$rajaus["limit"]}'>"; echo "<input type='hidden' name='tilaus[laskunro]' value='{$tilaus["laskunro"]}'>"; echo "<input type='hidden' name='tilaus[toiminto]' value='kuittikopio'>"; echo "<input type='submit' value='" . t("Kuittikopio") . "'>"; echo "</form>"; echo "</td>"; echo "<td class='back'>"; echo "<form action='../raportit/asiakkaantilaukset.php'>"; echo "<input type='hidden' name='tee' value='NAYTATILAUS'>"; echo "<input type='hidden' name='toim' value='MYYNTI'>"; echo "<input type='hidden' name='asiakasid' value='{$tilaus["asiakkaan_tunnus"]}'>"; echo "<input type='hidden' name='laskunro' value='{$tilaus["laskunro"]}'>"; echo "<input type='hidden' name='lasku_yhtio' value='{$tilaus["yhtio"]}'>"; echo "<input type='hidden' name='tunnus' value='{$tilaus["tunnus"]}'>"; echo "<input type='hidden' name='ytunnus' value='{$tilaus["asiakasnro"]}'>"; echo "<input type='hidden' name='ppa' value='{$rajaus["alku"]["paiva"]}'>"; echo "<input type='hidden' name='kka' value='{$rajaus["alku"]["kuukausi"]}'>"; echo "<input type='hidden' name='vva' value='{$rajaus["alku"]["vuosi"]}'>"; echo "<input type='hidden' name='ppl' value='{$rajaus["loppu"]["paiva"]}'>"; echo "<input type='hidden' name='kkl' value='{$rajaus["loppu"]["kuukausi"]}'>"; echo "<input type='hidden' name='vvl' value='{$rajaus["loppu"]["vuosi"]}'>"; echo "<input type='hidden' name='lopetus' value='{$lopetus}'>"; echo "<input type='submit' value='" . t("Näytä tilaus") . "'>"; echo "</form>"; echo "</td>"; echo "<td class='back'>"; echo "<form action='../monistalasku.php'>"; echo "<input type='hidden' name='tee' value='MONISTA'>"; echo "<input type='hidden' name='monistettavat[{$tilaus["myyntilaskun_tunnus"]}]' value='HYVITA'>"; echo "<input type='hidden' name='mistatultiin' value='maksutapahtumaselaus'>"; echo "<input type='hidden' name='lopetus' value='{$lopetus}'>"; echo "<input type='submit' value='" . t("Korjaa kuitti") . "'>"; echo "</form>"; echo "</td>"; echo "</tr>"; } echo "</tbody>"; echo "</table>"; }
echo "<br>"; $excelnimi = $worksheet->close(); echo "<table>"; echo "<tr><th>" . t("Tallenna excel") . ":</th>"; echo "<form method='post' class='multisubmit'>"; echo "<input type='hidden' name='tee' value='lataa_tiedosto'>"; echo "<input type='hidden' name='kaunisnimi' value='" . t("Varastotilasto") . ".xlsx'>"; echo "<input type='hidden' name='tmpfilenimi' value='{$excelnimi}'>"; echo "<td class='back'><input type='submit' value='" . t("Tallenna") . "'></td></tr></form>"; echo "</table><br>"; if ($total_rows > 1000) { echo "<font class='error'>", t("Hakutulos oli liian suuri"), ". ", t("Tulos vain excelissä"), ".</font><br><br>"; } else { if ($listaustyyppi == "kappaleet2" and $nayta_vapaa_saldo == "on") { $sarakkeet = 20; } elseif ($listaustyyppi == "kappaleet2") { $sarakkeet = 19; } elseif ($nayta_vapaa_saldo == "on") { $sarakkeet = 16; } else { $sarakkeet = 15; } pupe_DataTables(array(array($pupe_DataTables, $sarakkeet, $sarakkeet, false, false))); echo "<br>", $varastotilasto_table; } } if ($total_rows == 0) { echo "<font class='message'>", t("Yhtään soveltuvaa tuotetta ei löytynyt"), ".</font>"; } } require "inc/footer.inc";
$jarj = "nimi, summa"; } // L = laskunumerolla if ($tee == 'L') { $index = " use index (yhtio_tila_laskunro) "; $ehto = "tila = 'U' and (laskunro = '" . abs($summa1) . "' or laskunro = '-" . abs($summa1) . "')"; $jarj = "nimi, summa"; } if ($tee != '') { $query = "SELECT tapvm, erpcm, laskunro, concat_ws(' ', nimi, nimitark) nimi,\n summa, valkoodi, ebid, tila, alatila, tunnus,\n mapvm, saldo_maksettu, ytunnus, liitostunnus, laatija\n FROM lasku {$index}\n WHERE {$ehto} and yhtio = '{$kukarow['yhtio']}'\n ORDER BY {$jarj}"; $result = pupe_query($query); if (mysql_num_rows($result) == 0) { echo "<b>", t("Haulla ei löytynyt yhtään laskua"), "</b>"; $tee = ''; } else { pupe_DataTables(array(array($pupe_DataTables, 9, 9))); echo "<table class='display dataTable' id='{$pupe_DataTables}'>"; echo "<thead>\n <tr>\n <th>", t("Pvm"), "</th>\n <th>", t("Eräpäivä"), "</th>\n <th>", t("Laskunro"), "</th>\n <th>", t("Nimi"), "</th>\n <th>", t("Summa"), "</th>\n <th>", t("Valuutta"), "</th>\n <th>", t("Ebid"), "</th>\n <th>", t("Tila"), "</th>\n <th>", t("Laatija"), "</th>\n </tr>\n <tr>\n <td><input type='text' class='search_field' name='search_pvm'></td>\n <td><input type='text' class='search_field' name='search_erpvm'></td>\n <td><input type='text' class='search_field' name='search_laskunro'></td>\n <td><input type='text' class='search_field' name='search_nimi'></td>\n <td><input type='text' class='search_field' name='search_summa'></td>\n <td><input type='text' class='search_field' name='search_valuutta'></td>\n <td><input type='text' class='search_field' name='search_ebid'></td>\n <td><input type='text' class='search_field' name='search_tila'></td>\n <td><input type='text' class='search_field' name='search_laatija'></td>\n </tr>\n </thead>"; echo "<tbody>"; while ($trow = mysql_fetch_assoc($result)) { echo "<tr class='aktiivi'>"; if ($kukarow['taso'] < 2) { echo "<td valign='top'>{$trow["tapvm"]}</td>"; } else { echo "<td valign='top'><a href = '../muutosite.php?tee=E&tunnus={$trow['tunnus']}&lopetus={$lopetus}'>{$trow["tapvm"]}</td>"; } echo "<td valign='top'>{$trow["erpcm"]}</td>"; echo "<td valign='top'><a href = '../tilauskasittely/tulostakopio.php?toim=LASKU&tee=ETSILASKU&laskunro={$trow['laskunro']}&lopetus={$lopetus}'>{$trow['laskunro']}</td>"; echo "<td valign='top'><a name='{$trow['tunnus']}' href='" . $palvelin2 . "myyntires/myyntilaskut_asiakasraportti.php?ytunnus={$trow['ytunnus']}&asiakasid={$trow['liitostunnus']}&alatila=Y&tila=tee_raportti&lopetus={$lopetus}'>{$trow['nimi']}</a></td>"; echo "<td valign='top' align='right'>{$trow['summa']}</td>"; echo "<td valign='top'>{$trow['valkoodi']}</td>";
if ($osasto != '' or $try != '') { $tuotelisa .= " JOIN tuote on lasku.yhtio = tuote.yhtio and tilausrivi.tuoteno = tuote.tuoteno "; } if (trim($tuotealku) != '' and trim($tuoteloppu) != '') { $tuotelisa .= " and tilausrivi.tuoteno >= '{$tuotealku}' and tilausrivi.tuoteno <= '{$tuoteloppu}' "; } if ($osasto != '') { $tuotelisa .= " and tuote.osasto = '{$osasto}' "; } if ($try != '') { $tuotelisa .= " and tuote.try = '{$try}' "; } } $query = "(SELECT lasku.toimaika as 'Toimitusaika',\n concat(concat(nimi,'<br>'),if(nimitark!='',concat(nimitark,'<br>'),''),if(toim_nimi!='',if(toim_nimi!=nimi,concat(toim_nimi,'<br>'),''),''),if(toim_nimitark!='',if(toim_nimitark!=nimitark,concat(toim_nimitark,'<br>'),''),'')) as 'Nimi/Toim. nimi',\n lasku.tunnus as 'Tilausnro', lasku.tila, lasku.alatila, lasku.tilaustyyppi, lasku.viesti as viesti\n from lasku use index (tila_index)\n {$tuotelisa}\n where lasku.yhtio = '{$kukarow['yhtio']}'\n and lasku.tila in ('L','N','V')\n and lasku.alatila not in ('X','V')\n and lasku.toimaika >= '{$alkupvm}' and lasku.toimaika <= '{$loppupvm}')\n\n UNION\n\n (SELECT lasku.toimaika as 'Toimitusaika',\n concat(concat(nimi,'<br>'),if(nimitark!='',concat(nimitark,'<br>'),''),if(toim_nimi!='',if(toim_nimi!=nimi,concat(toim_nimi,'<br>'),''),''),if(toim_nimitark!='',if(toim_nimitark!=nimitark,concat(toim_nimitark,'<br>'),''),'')) as 'Nimi/Toim. nimi',\n lasku.tunnus as 'Tilausnro', lasku.tila, lasku.alatila, lasku.tilaustyyppi, lasku.viesti as viesti\n from lasku use index (yhtio_tila_tapvm)\n {$tuotelisa}\n where lasku.yhtio = '{$kukarow['yhtio']}'\n and lasku.tila = 'N'\n and tapvm = '0000-00-00'\n and lasku.toimaika >= '{$alkupvm}' and lasku.toimaika <= '{$loppupvm}')\n\n UNION\n\n (SELECT lasku.toimaika as 'Toimitusaika',\n concat(concat(nimi,'<br>'),if(nimitark!='',concat(nimitark,'<br>'),''),if(toim_nimi!='',if(toim_nimi!=nimi,concat(toim_nimi,'<br>'),''),''),if(toim_nimitark!='',if(toim_nimitark!=nimitark,concat(toim_nimitark,'<br>'),''),'')) as 'Nimi/Toim. nimi',\n lasku.tunnus as 'Tilausnro', lasku.tila, lasku.alatila, lasku.tilaustyyppi, lasku.viesti as viesti\n from lasku use index (yhtio_tila_tapvm)\n {$tuotelisa}\n where lasku.yhtio = '{$kukarow['yhtio']}'\n and lasku.tila = 'E'\n and tapvm = '0000-00-00'\n and lasku.toimaika >= '{$alkupvm}' and lasku.toimaika <= '{$loppupvm}')\n\n ORDER BY 1, 3 "; $result = pupe_query($query); pupe_DataTables(array(array($pupe_DataTables, 7, 7, false, false))); echo "<table class='display dataTable' id='{$pupe_DataTables}'><thead><tr>"; for ($i = 0; $i < mysql_num_fields($result) - 3; $i++) { echo "<th align='left'>" . t(mysql_field_name($result, $i)) . "</th>"; } echo "<th align='left'>" . t("Tyyppi") . "</th>"; echo "<th align='left'>" . t("Viesti") . "</th>"; echo "<th align='left'>" . t("Summa") . "</th>"; echo "</tr></thead>"; $summat = 0; $arvot = 0; echo "<tbody>"; while ($prow = mysql_fetch_array($result)) { $ero = "td"; if ($tunnus == $prow['Tilausnro']) { $ero = "th";
if ($tee == "vapauta_tilaus_keraykseen") { $vapauta_tilaus_keraykseen = true; $query = "UPDATE lasku SET\n alatila = ''\n WHERE yhtio = '{$kukarow['yhtio']}'\n AND tunnus = '{$tunnus}'\n AND tila = 'N'\n AND alatila = 'B'"; $upd_res = pupe_query($query); $kukarow['kesken'] = $tunnus; $query = "SELECT *\n FROM lasku\n WHERE yhtio = '{$kukarow['yhtio']}'\n AND tunnus = '{$tunnus}'"; $laskures = pupe_query($query); $laskurow = mysql_fetch_assoc($laskures); require 'tilauskasittely/tilaus-valmis.inc'; $tee = ""; } if ($tee == "") { echo " <SCRIPT LANGUAGE=JAVASCRIPT>\n function verify(msg){\n if (confirm(msg)) {\n return true;\n }\n else {\n skippaa_tama_submitti = true;\n return false;\n }\n }\n </SCRIPT>"; $query = "SELECT\n lasku.jaksotettu jaksotettu,\n concat_ws(' ',lasku.nimi, lasku.nimitark) nimi,\n lasku.tila,\n sum(if (maksupositio.uusiotunnus > 0 and uusiolasku.tila='L' and uusiolasku.alatila='X', 1, 0)) AS laskutettu_kpl,\n sum(if (maksupositio.uusiotunnus = 0, 1, 0)) tekematta_kpl,\n count(*) AS yhteensa_kpl,\n sum(if (maksupositio.uusiotunnus = 0 or (maksupositio.uusiotunnus > 0 and uusiolasku.alatila!='X'), maksupositio.summa,0)) laskuttamatta,\n sum(if (maksupositio.uusiotunnus > 0 and uusiolasku.tila='L' and uusiolasku.alatila='X', maksupositio.summa, 0)) laskutettu,\n sum(maksupositio.summa) yhteensa\n FROM lasku\n JOIN maksupositio ON maksupositio.yhtio = lasku.yhtio and maksupositio.otunnus = lasku.tunnus\n JOIN maksuehto ON maksuehto.yhtio = lasku.yhtio and maksuehto.tunnus = lasku.maksuehto and maksuehto.jaksotettu != ''\n LEFT JOIN lasku uusiolasku ON maksupositio.yhtio = uusiolasku.yhtio and maksupositio.uusiotunnus = uusiolasku.tunnus\n WHERE lasku.yhtio = '{$kukarow['yhtio']}'\n and lasku.jaksotettu > 0\n and lasku.tila in ('L','N','R','A','D')\n and lasku.alatila != 'X'\n GROUP BY jaksotettu, nimi, tila\n HAVING count(*) > sum(if (maksupositio.uusiotunnus > 0 and uusiolasku.tila='L' and uusiolasku.alatila='X', 1, 0))\n ORDER BY jaksotettu desc"; $result = pupe_query($query); pupe_DataTables(array(array($pupe_DataTables, 7, 8))); echo "<table class='display dataTable' id='{$pupe_DataTables}'>"; echo "<thead>"; echo "<tr>\n <th>" . t("Tilaus") . "</th>\n <th>" . t("Asiakas") . "</th>\n <th>" . t("Erä") . "</th>\n <th>" . t("Laskuttamatta") . "</th>\n <th>" . t("Laskutettu") . "</th>\n <th>" . t("Yhteensä") . "</th>\n <th>" . t("Seuraava positio") . "</th>\n <th style='visibility:hidden;'></th>\n </tr>"; echo "<tr>\n <td><input type='text' class='search_field' name='search_tilaus'></td>\n <td><input type='text' class='search_field' name='search_asiakas'></td>\n <td><input type='text' class='search_field' name='search_era'></td>\n <td><input type='text' class='search_field' name='search_laskuttamatta'></td>\n <td><input type='text' class='search_field' name='search_laskutettu'></td>\n <td><input type='text' class='search_field' name='search_yhteensa'></td>\n <td><input type='text' class='search_field' name='search_seuraava'></td>\n <td style='visibility:hidden;'></td>\n </tr>"; echo "</thead>"; echo "<tbody>"; while ($row = mysql_fetch_assoc($result)) { //onko poistetun tilauksen takana loppulaskutusta odottava tilaus? if ($row["tila"] == 'D') { $query = "SELECT tunnus\n FROM lasku\n WHERE yhtio = '{$kukarow['yhtio']}'\n AND vanhatunnus = '{$row['jaksotettu']}'\n AND tila IN ('L','N','R','A')\n AND alatila != 'X'"; $deleteds = pupe_query($query); if (mysql_num_rows($deleteds) == 0) { continue; } }
if ($_rajaa_chk) { $query = "SELECT lasku.ytunnus\n FROM lasku\n JOIN tiliointi ON (\n tiliointi.yhtio = lasku.yhtio AND\n tiliointi.ltunnus = lasku.tunnus AND\n tiliointi.korjattu = '' AND\n tiliointi.tapvm >= '{$alkupvm}' AND\n tiliointi.tapvm <= '{$loppupvm}' AND\n tiliointi.tilino in ({$tilirow['tilitMUU']})\n {$verolisa}\n )\n WHERE lasku.yhtio = '{$kukarow['yhtio']}'\n {$tilat}\n {$tilaustyyppi}\n GROUP BY 1\n HAVING abs(sum(if(\n tiliointi.summa > 0,\n tiliointi.summa,\n 0\n ))) < {$rajaa}\n AND abs(sum(if(\n tiliointi.summa < 0,\n tiliointi.summa,\n 0\n ))) < {$rajaa}"; $result = pupe_query($query); $_exclude_asiakkaat = array(); while ($row = mysql_fetch_assoc($result)) { $_exclude_asiakkaat[$row['ytunnus']] = $row['ytunnus']; } if (!empty($_exclude_asiakkaat)) { $rajaalisa = "and lasku.ytunnus NOT IN ('" . implode("','", $_exclude_asiakkaat) . "')"; } } $query = "SELECT tiliointi.ltunnus,\n max(tiliointi.vero) veropros,\n sum(round(tiliointi.summa * vero / 100, 2)) veronmaara,\n sum(tiliointi.summa) summa\n FROM tiliointi\n WHERE tiliointi.yhtio = '{$kukarow['yhtio']}'\n AND tiliointi.korjattu = ''\n AND tiliointi.tapvm >= '{$alkupvm}'\n AND tiliointi.tapvm <= '{$loppupvm}'\n AND tiliointi.tilino in ({$tilirow['tilitMUU']})\n {$verolisa}\n GROUP BY 1"; $result = pupe_query($query); $verot_yht = 0; $verot_csv_yht = 0; pupe_DataTables(array(array($pupe_DataTables, 10, 10, true))); $style = "width: 15px; height: 15px; display: inline-table; border-radius: 50%; -webkit-border-radius: 50%; -moz-border-radius: 50%;"; $_green = "<span style='{$style} background-color: #5D2; margin-right: 5px;'></span>"; $_red = "<span style='{$style} background-color: #E66; margin-right: 5px;'></span>"; echo "<table class='display dataTable' id='{$pupe_DataTables}'>"; echo "<thead>"; echo "<tr>"; echo "<th>", t("CSV"), "</th>"; echo "<th>#</th>"; echo "<th>", t("ytunnus"), "</th>"; echo "<th>", t("nimi"), "</th>"; echo "<th>", t("laskunro"), "</th>"; echo "<th>", t("pvm"), "</th>"; echo "<th>", t("laskun summa"), "</th>"; echo "<th>", t("alv"), "</th>"; echo "<th>", t("verot"), "</th>";
echo "<tbody>"; $total_yht = 0; foreach ($tyomaarays_kuitti_yhteensa as $tyom_id => $tyom_array) { $yht = 0; $yhtk = 0; echo "<tr><td>{$tyom_id}</td>"; echo "<td style='vertical-align:bottom;'>"; echo "<table width='100%'>"; if (is_array($tyomaarays_kuitti_yhteensa[$tyom_id])) { ksort($tyomaarays_kuitti_yhteensa[$tyom_id]); foreach ($tyomaarays_kuitti_yhteensa[$tyom_id] as $tyom_asentaja => $tyom_sekunnit) { echo "<tr><td>{$tyom_asentaja}</td><td class='ok' align='right'><strong>" . tunnit_minuutit($tyom_sekunnit) . "</strong></td></tr>"; $yhtk += $tyom_sekunnit; } } echo "<tr><td class='tumma'>", t("Yhteensä"), "</td><td class='tumma' align='right'><span class='yhteensa'>" . tunnit_minuutit($yhtk) . "</span></td></tr>"; echo "</table>"; echo "</td>"; echo "</tr>"; $total_yht += $yht; $total_yhtk += $yhtk; } echo "</tbody>"; echo "<tfoot>"; echo "<tr><td class='tumma'>", t("Kaikki yhteensä"), "</td><td class='tumma' align='right' id='tyom_yhteensa1'>" . tunnit_minuutit($total_yhtk) . " </td></tr>"; echo "</tfoot>"; echo "</table>"; } pupe_DataTables($datatables_conf); echo "<br><br>"; require "inc/footer.inc";
function echo_saldovahvistukset($request) { global $kukarow, $yhtiorow, $pupe_DataTables, $palvelin2; // echo "<table class='display'>"; pupe_DataTables(array(array($pupe_DataTables, 6, 9, false, false, true))); echo "<table class='display dataTable' id='{$pupe_DataTables}'>"; echo "<thead>"; echo "<tr>"; echo "<th>" . t('Päivämäärä') . "</th>"; echo "<th>" . t('Ytunnus') . "</th>"; echo "<th>" . t('Asiakasnumero') . "</th>"; echo "<th>" . t('Nimi') . "</th>"; echo "<th>" . t('Saldo') . "</th>"; echo "<th>" . t('Viesti') . "</th>"; echo "<th>", t("Muistissa"), "</th>"; echo "<th>", t("Lähetä"), "</th>"; echo "<th class='hidden'></th>"; echo "</tr>"; echo "<tr>"; echo "<td><input type='text' class='search_field' name='search_paivamaara'></td>"; echo "<td><input type='text' class='search_field' name='search_ytunnus'></td>"; echo "<td><input type='text' class='search_field' name='search_asiakasnumero'></td>"; echo "<td><input type='text' class='search_field' name='search_nimi'></td>"; echo "<td><input type='text' class='search_field' name='search_saldo'></td>"; echo "<td><input type='text' class='search_field' name='search_viesti'></td>"; echo "<td><input type='checkbox' id='valitse_kaikki' CHECKED /></td>"; echo "<td><input type='checkbox' id='valitse_kaikki_lahetettavaksi' /></td>"; echo "<td class='hidden'></td>"; echo "</tr>"; echo "</thead>"; echo "<tbody>"; $kpl = count($request['laskut']); $i = 1; $viimeinen = false; foreach ($request['laskut'] as $lasku) { if ($i == $kpl) { $viimeinen = true; } if (!empty($request['avoin_saldo_rajaus'])) { $_rajaus = (double) $request['avoin_saldo_rajaus']; $_avoin_summa = $lasku['avoin_saldo_summa']; $_pos = ($_rajaus > 0 and $_avoin_summa < $_rajaus); $_neg = ($_rajaus < 0 and $_avoin_summa > $_rajaus); if ($_pos or $_neg) { continue; } } echo_saldovahvistus_rivi($lasku, $request, false, $viimeinen); $i++; } foreach ($request['valitut_laskut'] as $lasku) { echo_saldovahvistus_rivi($lasku, $request, true); } echo "</tbody>"; echo "</table>"; echo "<form id='lahetysformi' method='POST' action = ''>"; echo "<input type='hidden' name='tee' value='laheta_sahkopostit' />"; echo "<input type='hidden' name='ryhmittely_tyyppi' value='{$request['ryhmittely_tyyppi']}' />"; echo "<input type='hidden' name='pp' value='{$request['pp']}' />"; echo "<input type='hidden' name='kk' value='{$request['kk']}' />"; echo "<input type='hidden' name='vv' value='{$request['vv']}' />"; echo "<input type='submit' value='" . t('Lähetä saldovahvistukset asiakkaille') . "' />"; echo "</form><br><br>"; echo "<form method='POST' action=''>"; echo "<input type='hidden' name='tee' value='poista_valinnat' />"; echo "<input type='hidden' name='pp' value='{$request['pp']}' />"; echo "<input type='hidden' name='kk' value='{$request['kk']}' />"; echo "<input type='hidden' name='vv' value='{$request['vv']}' />"; echo "<input type='submit' value='" . t('Poista kaikki kerätyt saldovahvistusrivit') . "' onclick='return tarkista(\"" . t('Oletko varma että haluat poistaa kaikki valitut') . "\");' />"; echo "</form>"; }