Master - Detail

Master - Detail

programozasprogramozas Posts: 4Questions: 1Answers: 0

Not working ! Whats wrong ? :(

bizonylat.html

        <div class="container">

            <h1>
                Számlák <span>bizonylat</span>
            </h1>
            
            <table cellpadding="0" cellspacing="0" border="0" class="display" id="bizonylatszamla" width="100%">
                <thead>
                    <tr>
                        <th>Számlaszám</th>
                        <th>Számlakelt.</th>
                    </tr>
                </thead>
            </table>
            
            <table cellpadding="0" cellspacing="0" border="0" class="display" id="tetelekszamla" width="100%">
                <thead>
                    <tr>
                        <th>Számlaszám</th>
                        <th>Mennyiség</th>
                    </tr>
                </thead>
            </table>            

        </div>  

bizonylatszamla.php

<?php

/*
 * Editor server script for DB table torzsbank
 * Created by http://editor.datatables.net/generator
 */

// DataTables PHP library and database connection
include( "lib/DataTables.php" );

// Alias Editor classes so they are easy to use
use
    DataTables\Editor,
    DataTables\Editor\Field,
    DataTables\Editor\Format,
    DataTables\Editor\Mjoin,
    DataTables\Editor\Options,
    DataTables\Editor\Upload,
    DataTables\Editor\Validate,
    DataTables\Editor\ValidateOptions;

// The following statement can be removed after the first run (i.e. the database
// table has been created). It is a good idea to do this to help improve
// performance.
$db->sql( "CREATE TABLE IF NOT EXISTS `bizonylatszamla` (
    `szlaid` int(10) NOT NULL auto_increment,
    `szamlaszam` varchar(30),
    `szamlakelt` date,
    PRIMARY KEY( `szlaid` )
);" );

// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'bizonylatszamla', 'szlaid' )
    ->fields(
        Field::inst( 'szlaid' )->set( false ),
        Field::inst( 'szamlaszam' )->validator( 'Validate::notEmpty' ),
        Field::inst( 'szamlakelt' )
    )
    ->join(
        Mjoin::inst( 'tetelekszamla' )
            ->link( 'bizonylatszamla.szlaid', 'tetelekszamla.szlaid' )
            ->fields(
                Field::inst( 'szlaid' )
            )
    )   
    ->process( $_POST )
    ->json();

bizonylatszamla.js


/* * Editor client script for DB table torzsbank * Created by http://editor.datatables.net/generator */ (function($){ $(document).ready(function() { var bizonylatszamlaeditor = new $.fn.dataTable.Editor( { ajax: 'php/table.bizonylatszamla.php', table: '#bizonylatszamla', fields: [ { "label": "Számlaszám:", "name": "szamlaszam" }, { "label": "Számlakelt:", "name": "szamlakelt" } ], i18n: { create: { button: "Új", title: "Új bejegyzés létrehozása", submit: "Rögzít" }, edit: { button: "Módosít", title: "Bejegyzés szerkesztése", submit: "Rögzít" }, remove: { button: "Töröl", title: "Eltávolítás", submit: "Eltávolít", confirm: { _: "Biztosan törölni szeretné a(z)%d sort?", 1: "Biztosan törölni szeretne 1 sort?" } }, error: { system: "Hiba történt, forduljon a rendszergazdához" }, datetime: { previous: 'Előző', next: 'Következő', months: [ 'Január', 'Február', 'Március', 'Április', 'Május', 'Június', 'Július', 'Augusztus', 'Szeptember', 'Október', 'November', 'December' ], weekdays: [ 'Hétfő', 'Kedd', 'Szerda', 'Csütörtök', 'Péntek', 'Szombat', 'Vasárnap' ] } } } ); var bizonylatszamlatable = $('#bizonylatszamla').DataTable( { dom: 'Bfrtip', ajax: 'php/table.bizonylatszamla.php', columns: [ { "data": "szamlaszam" }, { "data": "szamlakelt" } ], select: true, lengthChange: false, buttons: [ { extend: 'create', editor: bizonylatszamlaeditor }, { extend: 'edit', editor: bizonylatszamlaeditor }, { extend: 'remove', editor: bizonylatszamlaeditor } ], language: { processing: "Feldolgozás folyamatban...", search: "Keresés:", lengthMenu: "Elemek _MENU_ megjelenítése", info: "Megjelenítve _START_ től _END_ , _TOTAL_ összesen", infoEmpty: "Megejelenítve 0 től 0 től , 0 összesen", infoFiltered: "(Szűrés _MAX_ összesen elem)", infoPostFix: "", loadingRecords: "Betöltés...", zeroRecords: "Nincs találat", emptyTable: "Nincs adat a táblázatban", paginate: { first: "Első", previous: "Előző", next: "Következő", last: "Utolsó" }, aria: { sortAscending: ": aktiválja, hogy az oszlopot növekvő sorrendben rendezze", sortDescending: ": aktiválja az oszlop rendezéséhez csökkenő sorrendben" } } } ); } ); }(jQuery));

Answers

  • programozasprogramozas Posts: 4Questions: 1Answers: 0

    tetelekszamla.php

    <?php
    
    /*
     * Editor server script for DB table torzsbank
     * Created by http://editor.datatables.net/generator
     */
    
    // DataTables PHP library and database connection
    include( "lib/DataTables.php" );
    
    // Alias Editor classes so they are easy to use
    use
        DataTables\Editor,
        DataTables\Editor\Field,
        DataTables\Editor\Format,
        DataTables\Editor\Mjoin,
        DataTables\Editor\Options,
        DataTables\Editor\Upload,
        DataTables\Editor\Validate,
        DataTables\Editor\ValidateOptions;
    
    // The following statement can be removed after the first run (i.e. the database
    // table has been created). It is a good idea to do this to help improve
    // performance.
    $db->sql( "CREATE TABLE IF NOT EXISTS `tetelekszamla` (
        `szlaid` int(10) NOT NULL auto_increment,
        `szamlaszam` varchar(30),
        `mennyiseg` double,
        PRIMARY KEY( `szlaid` )
    );" );
    
    // Build our Editor instance and process the data coming from _POST
    ///*
    Editor::inst( $db, 'tetelekszamla', 'szlaid' )
        ->fields(
            Field::inst( 'szamlaszam' ),
            Field::inst( 'mennyiseg' )
        )
        ->process( $_POST )
        ->json();
    */
    ///*
    if ( ! isset($_POST['tetelekszamla']) || ! is_numeric($_POST['tetelekszamla']) ) {
        echo json_encode( [ "data" => [] ] );
    }
    else {
        Editor::inst( $db, 'tetelekszamla' )
            ->field(
                Field::inst( 'szamlaszam' ),
                Field::inst( 'mennyiseg' )
            )
            ->leftJoin( 'bizonylatszamla', 'bizonylatszamla.szamlaszam', '=', 'tetelekszamla.szamlaszam' ))     
            ->where( 'bizonylatszamla', $_POST['bizonylatszamla'] )
            ->process($_POST)
            ->json();
    }
    */
    

    tetelekszamla.js


    /* * Editor client script for DB table torzsbank * Created by http://editor.datatables.net/generator */ (function($){ $(document).ready(function() { var tetelekszamlaeditor = new $.fn.dataTable.Editor( { // ajax: 'php/table.tetelekszamla.php', ajax: { url: 'php/table.tetelekszamla.php', type: 'post', data: function ( d ) { var selected = bizonylatszamlaTable.row( { selected: true } ); if ( selected.any() ) { d.site = selected.data().szlaid; } } }, table: '#tetelekszamla', fields: [ { "label": "Számlaszám:", "name": "szamlaszam" }, { "label": "Mennyiség:", "name": "mennyiseg" } ], i18n: { create: { button: "Új", title: "Új bejegyzés létrehozása", submit: "Rögzít" }, edit: { button: "Módosít", title: "Bejegyzés szerkesztése", submit: "Rögzít" }, remove: { button: "Töröl", title: "Eltávolítás", submit: "Eltávolít", confirm: { _: "Biztosan törölni szeretné a(z)%d sort?", 1: "Biztosan törölni szeretne 1 sort?" } }, error: { system: "Hiba történt, forduljon a rendszergazdához" }, datetime: { previous: 'Előző', next: 'Következő', months: [ 'Január', 'Február', 'Március', 'Április', 'Május', 'Június', 'Július', 'Augusztus', 'Szeptember', 'Október', 'November', 'December' ], weekdays: [ 'Hétfő', 'Kedd', 'Szerda', 'Csütörtök', 'Péntek', 'Szombat', 'Vasárnap' ] } } } ); var tetelekszamlatable = $('#tetelekszamla').DataTable( { dom: 'Bfrtip', //ajax: 'php/table.tetelekszamla.php', ajax: { url: 'php/table.tetelekszamla.php', type: 'post', data: function ( d ) { var selected = siteTable.row( { selected: true } ); if ( selected.any() ) { d.site = selected.data().szlaid; } } }, columns: [ { "data": "tetelekszamla.szamlaszam" }, { "data": "tetelekszamla.mennyiseg" } ], select: true, lengthChange: false, buttons: [ { extend: 'create', editor: tetelekszamlaeditor }, { extend: 'edit', editor: tetelekszamlaeditor }, { extend: 'remove', editor: tetelekszamlaeditor } ], language: { processing: "Feldolgozás folyamatban...", search: "Keresés:", lengthMenu: "Elemek _MENU_ megjelenítése", info: "Megjelenítve _START_ től _END_ , _TOTAL_ összesen", infoEmpty: "Megejelenítve 0 től 0 től , 0 összesen", infoFiltered: "(Szűrés _MAX_ összesen elem)", infoPostFix: "", loadingRecords: "Betöltés...", zeroRecords: "Nincs találat", emptyTable: "Nincs adat a táblázatban", paginate: { first: "Első", previous: "Előző", next: "Következő", last: "Utolsó" }, aria: { sortAscending: ": aktiválja, hogy az oszlopot növekvő sorrendben rendezze", sortDescending: ": aktiválja az oszlop rendezéséhez csökkenő sorrendben" } } } ); } ); //---------------- bizonylatszamlaTable.on( 'select', function () { tetelekszamlaTable.ajax.reload(); tetelekszamlaEditor .field( 'tetelekszamla.szamlaszam' ) .def( bizonylatszamlaTable.row( { selected: true } ).data().szlaid ); } ); bizonylatszamlaTable.on( 'deselect', function () { tetelekszamlaTable.ajax.reload(); } ); //----------------- bizonylatszamlaEditor.on( 'submitSuccess', function () { tetelekszamlaTable.ajax.reload(); } ); tetelekszamlaEditor.on( 'submitSuccess', function () { bizonylatszamlaTable.ajax.reload(); } ); //------------------ }(jQuery));
  • kthorngrenkthorngren Posts: 20,292Questions: 26Answers: 4,768

    Thats a lot of code to look through without know what the problem is. Maybe you can start by providing details of what is not working and if you are getting any alert or console log errors. Better yet please provide a link to your page or a test case replicating the issue along with steps to see the problem.

    Kevin

  • programozasprogramozas Posts: 4Questions: 1Answers: 0
    edited June 2019

    programozas.org/zeusz/production/bizonylat-szamla.html

    The detail not working in this link...

  • colincolin Posts: 15,143Questions: 1Answers: 2,586

    Can you help us to help you, please. What isn't working? How can we reproduce the issue?

  • programozasprogramozas Posts: 4Questions: 1Answers: 0

    You press the bottom new button, enter the account number for example: 2019/1 enter the quantity for example: 1 press the capture button and then the event indicator will spin in the upper right corner but the surface will not disappear, the item will not be recorded.

  • colincolin Posts: 15,143Questions: 1Answers: 2,586

    If you check your console you'll see you're getting an error upon pressing submit:

    Uncaught ReferenceError: bizonylatszamlaTable is not defined
    

    You're trying to access bizonylatszamlaTable inside ajax.data, which is why the submission is just hanging and doesn't complete.

This discussion has been closed.