Hejka!
Widziałem w pracy jak szef się męczy przy pisaniu w wordzie każdego PDF'a z wyceną prac osobno i chciałem mu trochę pomóc.
Amatorsko lubiłem kodować, edytować style czy skrypty ale niestety okazało się, że to zadanie mnie przerasta lekko. Utknąłem.
Mianowicie zamysł jest taki ->
Interaktywny formularz z 5-cioma polami ( Liczba kolejna, Nr. Artykułu, Typ, Opis oraz Ilość ). Szef wpisuje w kola tekstowe dane, dodatkowo posiada przyciski "dodaj wers", "usuń wers", "generuj PDF".
O tyle o ile poradziłem sobie ładnie ze stroną główną interaktywnej tabelki o tyle kompletnie nie wiem jak się zabrać za generowanie PDF'a z danych które mam.
Stwierdziłem, że chcę to zrobić w PHPie (Udostępnię szefowi linka do strony gdzie to wrzucę), wiem, że pewnie jakiś python albo builder programu byłby łatwiejszy.
Czy jest ktoś w stanie mi pomóc? Podpowiedzieć, rozpocząć dalszy etap za mnie?
Chciałbym aby po kliknięciu "Generuj" nowy skrypt w php pobierał ilość wersów tabeli i tworzył odpowiadającą tabelę w nowym pliku PDF, to znaczy, żeby dane się przepisały do PDF'a.
Jak zrobię 4 wersy i wypełnię danymi żeby pobrało i zrobiło tak samo w PDF'ie.
Nie wiem którego rozszerzenia do tworzenia PDF'a użyć ani jak się za to zabrać. Dalej myślę, że jestem w stanie sam ogarnąć całego PDF,a do porządku.
Dziękuję za każdą pomoc i pozdrawiam.
Skrypt głównej strony który już mam:
> <form action="wynik.php" method="get">
> <p>
> <input style="height:50px;width:100px;font-size:20px;" type="button" value="Dodaj" onclick="addRowToTable();" />
> <input style="height:50px;width:100px;font-size:20px;" type="button" value="Usuń" onclick="removeRowFromTable();" />
> <input style="height:50px;width:100px;font-size:20px;" type="button" value="Generuj" onclick="validateRow(this.form);" />
> </p>
> <p>
> <input type="checkbox" id="chkValidate" /> Sprawdzanie
> <input type="checkbox" id="chkValidateOnKeyPress" checked="checked" /> Gdzie wpisuje
> <span id="spanOutput" style="margin-left:3px;border:1px solid #000;padding:3px;"> </span>
> </p>
> <table border="1" id="tabela" style="font-size:30px">
> <tr>
> <td>
> Np.
> </td>
> <td>
> Artykuł
> </td>
> <td>
> Typ
> </td>
> <td>
> Opis
> </td>
> <td>
> Ilość
> </td>
> </tr>
> <tr>
> <td>
> 1
> </td>
> <td>
> <input type="text" name="txt1Row1" id="txt1Row1" size="15" onkeypress="keyPressTest(event, this);" />
> </td>
> <td>
> <input type="text" name="txt2Row1" id="txt2Row1" size="40" onkeypress="keyPressTest(event, this);" />
> </td>
> <td>
> <input type="text" name="txt3Row1" id="txt3Row1" size="70" onkeypress="keyPressTest(event, this);" />
> </td>
> <td>
> <input type="number" name="txt4Row1" id="txt4Row1" size="15" onkeypress="keyPressTest(event, this);" />
> </td>
> </tr>
> </table>
> </form>
>
> <script>
> function addRowToTable()
> {
> var tbl = document.getElementById('tabela');
> var lastRow = tbl.rows.length;
> var iteration = lastRow;
> var row = tbl.insertRow(lastRow);
>
> // Pierwsza
> var cellLeft = row.insertCell(0);
> var textNode = document.createTextNode(iteration);
> cellLeft.appendChild(textNode);
> cellLeft.id = 'liczba' + iteration;
>
> // Druga
> var cellRight = row.insertCell(1);
> var el = document.createElement('input');
> el.type = 'text';
> el.name = 'txt1Row' + iteration;
> el.id = 'txt1Row' + iteration;
> el.size = 15;
>
> // Trzecia
> var cellRight1 = row.insertCell(1);
> var el1 = document.createElement('input');
> el1.type = 'text';
> el1.name = 'txt2Row' + iteration;
> el1.id = 'txt2Row' + iteration;
> el1.size = 40;
>
> // Czwarta
> var cellRight2 = row.insertCell(1);
> var el2 = document.createElement('input');
> el2.type = 'text';
> el2.name = 'txt3Row' + iteration;
> el2.id = 'txt3Row' + iteration;
> el2.size = 70;
>
> // Piata
> var cellRight3 = row.insertCell(1);
> var el3 = document.createElement('input');
> el3.type = 'number';
> el3.name = 'txt4Row' + iteration;
> el3.id = 'txt4Row' + iteration;
> el3.size = 15;
>
> el.onkeypress = keyPressTest;
> cellRight3.appendChild(el);
> cellRight2.appendChild(el1);
> cellRight1.appendChild(el2);
> cellRight.appendChild(el3);
> }
> function keyPressTest(e, obj)
> {
> var validateChkb = document.getElementById('chkValidateOnKeyPress');
> if (validateChkb.checked) {
> var displayObj = document.getElementById('spanOutput');
> var key;
> if(window.event) {
> key = window.event.keyCode;
> }
> else if(e.which) {
> key = e.which;
> }
> var objId;
> if (obj != null) {
> objId = obj.id;
> } else {
> objId = this.id;
> }
> displayObj.innerHTML = objId + ' : ' + String.fromCharCode(key);
> }
> }
> function removeRowFromTable()
> {
> var tbl = document.getElementById('tabela');
> var lastRow = tbl.rows.length;
> if (lastRow > 2) tbl.deleteRow(lastRow - 1);
> }
> function openInNewWindow(frm)
> {
> var aWindow = window.open('', 'TableAddRowNewWindow',
> 'scrollbars=yes,menubar=yes,resizable=yes,toolbar=no,width=400,height=400');
> frm.target = 'TableAddRowNewWindow';
> frm.submit();
> }
> function validateRow(frm)
> {
> var chkb = document.getElementById('chkValidate');
> if (chkb.checked) {
> var tbl = document.getElementById('tabela');
> var lastRow = tbl.rows.length - 1;
> var i;
> for (i=1; i<=lastRow; i++) {
> var aRow = document.getElementById('txtRow' + i);
> if (aRow.value.length <= 0) {
> alert('Row ' + i + ' is empty');
> return;
> }
> }
> }
> openInNewWindow(frm);
> }
> </script>