<commit_before><?php slot('title', __('Loan Overview'));  ?>
<?php include_stylesheets_for_form($form) ?>
<?php include_javascripts_for_form($form) ?>
<?php use_javascript('button_ref.js') ?>

<div class="page">
    <h1 class="edit_mode"><?php echo __('Overview');?></h1>

    <?php include_partial('tabs', array('loan'=> $loan, 'items'=>array())); ?>
    <div class="tab_content">

      <?php echo form_tag('loan/overview?id='.$loan->getId(), array('class'=>'edition loan_overview_form'));?>

      <?php echo $form->renderGlobalErrors();?>
        <table>
        <thead>
          <tr>
            <th></th>
            <th><?php echo __('Darwin Part') ;?></th>
            <th><?php echo __('I.g. Num');?></th>
            <th><?php echo __('Details') ;?></th>
            <th><?php echo __('Expedition') ;?></th>
            <th><?php echo __('Return') ;?></th>
            <th></th>
            <th></th>
          </tr>
        </thead>
        <tbody>
          <?php foreach($form['LoanItems'] as $name => $sf):?>
            <?php include_partial('loanLine', array('loan'=> $loan, 'form'=>$sf, 'lineObj' => $form->getEmbeddedForm('LoanItems')->getEmbeddedForm($name)->getObject())); ?>
          <?php endforeach;?>

          <?php foreach($form['newLoanItems'] as $name => $sf):?>
            <?php include_partial('loanLine', array('loan'=> $loan, 'form'=>$sf, 'lineObj' => $form->getEmbeddedForm('LoanItems')->getEmbeddedForm($name)->getObject())); ?>
          <?php endforeach;?>
        </tbody>
       </table>
       <?php if(! count($form['LoanItems']) && ! count($form['newLoanItems'])):?>
        <div class="warn_message"><?php echo __('There is currently no items in your loan. Do not forget to add them.');?></div>
       <?php endif;?>
  
        <div class="form_buttons">
          <input type="button" id="add_maint_items" value="<?php echo __('Add Maintenance for checked');?>" />
          <a href="<?php echo url_for('loan/addLoanItem?id='.$loan->getId()) ?>" id="add_item"><?php echo __('Add item');?></a>
          &nbsp;

          <?php echo link_to(__('Back to Loan'), 'loan/edit?id='.$loan->getId()) ?>
          <a href="<?php echo url_for('loan/index') ?>"><?php echo __('Cancel');?></a>

          <input id="submit" type="submit" value="<?php echo __('Save');?>" />
        </div>
        
      </form>


<script  type="text/javascript">
$(document).ready(function () {
    $('#add_item').click( function(event)
    {
        event.preventDefault();
        hideForRefresh('.loan_overview_form');
        parent_el = $('.loan_overview_form table tbody');
        $.ajax(
        {
          type: "GET",
          url: $(this).attr('href')+ '/num/' + ( parent_el.find('tr').length),
          success: function(html)
          {                    
            //console.log(parent_el);
            parent_el.append(html);
            $('.warn_message').hide();
            showAfterRefresh('.loan_overview_form');
            $('.loan_overview_form').css({position: 'absolute'});
            
 
          }
        });
        return false;
    }); 

    $('#add_maint_items').click(function (event) {
      event.preventDefault();
      var ids = [];
      $('.select_chk_box:checked').each(function (i) {
        ids.push($(this).val());<commit_msg>Select the right table to add item in overview<commit_after><?php slot('title', __('Loan Overview'));  ?>
<?php include_stylesheets_for_form($form) ?>
<?php include_javascripts_for_form($form) ?>
<?php use_javascript('button_ref.js') ?>

<div class="page">
    <h1 class="edit_mode"><?php echo __('Overview');?></h1>

    <?php include_partial('tabs', array('loan'=> $loan, 'items'=>array())); ?>
    <div class="tab_content">

      <?php echo form_tag('loan/overview?id='.$loan->getId(), array('class'=>'edition loan_overview_form'));?>

      <?php echo $form->renderGlobalErrors();?>
        <table>
        <thead>
          <tr>
            <th></th>
            <th><?php echo __('Darwin Part') ;?></th>
            <th><?php echo __('I.g. Num');?></th>
            <th><?php echo __('Details') ;?></th>
            <th><?php echo __('Expedition') ;?></th>
            <th><?php echo __('Return') ;?></th>
            <th></th>
            <th></th>
          </tr>
        </thead>
        <tbody>
          <?php foreach($form['LoanItems'] as $name => $sf):?>
            <?php include_partial('loanLine', array('loan'=> $loan, 'form'=>$sf, 'lineObj' => $form->getEmbeddedForm('LoanItems')->getEmbeddedForm($name)->getObject())); ?>
          <?php endforeach;?>

          <?php foreach($form['newLoanItems'] as $name => $sf):?>
            <?php include_partial('loanLine', array('loan'=> $loan, 'form'=>$sf, 'lineObj' => $form->getEmbeddedForm('LoanItems')->getEmbeddedForm($name)->getObject())); ?>
          <?php endforeach;?>
        </tbody>
       </table>
       <?php if(! count($form['LoanItems']) && ! count($form['newLoanItems'])):?>
        <div class="warn_message"><?php echo __('There is currently no items in your loan. Do not forget to add them.');?></div>
       <?php endif;?>
  
        <div class="form_buttons">
          <input type="button" id="add_maint_items" value="<?php echo __('Add Maintenance for checked');?>" />
          <a href="<?php echo url_for('loan/addLoanItem?id='.$loan->getId()) ?>" id="add_item"><?php echo __('Add item');?></a>
          &nbsp;

          <?php echo link_to(__('Back to Loan'), 'loan/edit?id='.$loan->getId()) ?>
          <a href="<?php echo url_for('loan/index') ?>"><?php echo __('Cancel');?></a>

          <input id="submit" type="submit" value="<?php echo __('Save');?>" />
        </div>
        
      </form>


<script  type="text/javascript">
$(document).ready(function () {
    $('#add_item').click( function(event)
    {
        event.preventDefault();
        hideForRefresh('.loan_overview_form');
        parent_el = $('.loan_overview_form > table > tbody');
        $.ajax(
        {
          type: "GET",
          url: $(this).attr('href')+ '/num/' + ( parent_el.find('tr').length),
          success: function(html)
          {                    
            //console.log(parent_el);
            parent_el.append(html);
            $('.warn_message').hide();
            showAfterRefresh('.loan_overview_form');
            $('.loan_overview_form').css({position: 'absolute'});
            
 
          }
        });
        return false;
    }); 

    $('#add_maint_items').click(function (event) {
      event.preventDefault();
      var ids = [];
      $('.select_chk_box:checked').each(function (i) {
        ids.push($(this).val());
{'fraction_non_alphanumeric': 0.218434152964248, 'fraction_numerical': 0.0006034092623321768, 'mean_word_length': 2.605220228384992, 'pattern_counts': {'":': 0, '<': 141, '<?xml version=': 0, '>': 185, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3398048', 'n_tokens_mistral': 2101, 'n_tokens_neox': 2042, 'n_words': 389}