$(".tab-home" ).on('tab:show', function(e) {

  e.preventDefault();  

  console.log('app tab_home ready')

  let js = JSON.parse(localStorage.getItem('t01_fcode'));

  if(js){

    let dt = js.data;

    //console.log(dt)

    strHtml =``;

    for(let i in dt) {

      strHtml +=`

      <div class="section-title">`+dt[i].name+`</div>`;

      strHtml +=`<div class="data-table">

        <table>

          <thead>

            <tr>

              <th class="label-cell"></th>

              <th class="label-cell">Name</th>

              <th class="numeric-cell"></th>

              <th class="numeric-cell">Amount</th>

            </tr>

          </thead>

          <tbody>`;

      for(let b in dt[i].items) {

      strHtml +=`

      <tr>

       <td class="label-cell">`+dt[i].items[b].code+`</td>

       <td class="label-cell">`+dt[i].items[b].name+`</td>

       <td class="numeric-cell"></td>

       <td class="numeric-cell">`+dt[i].items[b].rp+`</td>

      </tr>`;  

      for (let c in dt[i].items[b].items) {

        strHtml +=`

        <tr>

         <td class="label-cell">`+dt[i].items[b].items[c].code+`</td>

         <td class="label-cell">`+dt[i].items[b].items[c].name+`</td>

         <td class="numeric-cell">`+dt[i].items[b].items[c].rp+`</td>

         <td class="numeric-cell"></td>

        </tr>`;      

          for (let d in dt[i].items[b].items[c].items) {

            if(dt[i].items[b].items[c].items[d].trx==1) {

            strHtml +=`

            

              <tr>

               <td class="label-cell"></td>

               <td class="label-cell"><i><a class="link" href="/journal/`+dt[i].items[b].items[c].items[d].cd+`">`+dt[i].items[b].items[c].items[d].name+`</a></i></td>

               <td class="numeric-cell"><i>`+dt[i].items[b].items[c].items[d].rp+`</i></td>

               <td class="numeric-cell"></td>

              </tr>

            

            `; 

            } else {

            strHtml +=`

            <tr>

             <td class="label-cell"></td>

             <td class="label-cell"><i>`+dt[i].items[b].items[c].items[d].name+`</i></td>

             <td class="numeric-cell"><i>`+dt[i].items[b].items[c].items[d].rp+`</i></td>

             <td class="numeric-cell"></td>

            </tr>`; 



            }             

          }

        }  

      }      

      strHtml +=`</tbody></table></div>`;    

    }

      strHtml +=``;

    $$("#home_tab_content").html(strHtml);

  } else {

    fcode();

  }

})