<?php
$product = $form->get('new-product');
$collection = $product->get('items');
$form = $this->form;
$form->prepare();
$form->setAttribute('action', $this->url('outstation', ['action' => 'multi-city-vehicle-listing']));
$form->setAttribute('method', 'post');
$form->setAttribute('id', 'vehicle-search-form');
echo $this->form()->openTag($form);
?>
<!--<section class="row">
    <div class="col-md-2"><strong>From</strong><span style="color: red"> *</span></div>
    <div class="col-md-2"><strong>To</strong><span style="color: red"> *</span></div>
    <div class="col-md-2"><strong>Departure</strong><span style="color: red"> *</span></div>
    <div class="col-md-2"><strong>Time</strong><span style="color: red"> *</span></div>
    <div class="col-md-2"><strong>No of Days</strong><span style="color: red"> *</span></div>
</section>-->

<div id="fieldset">
    <?php
    if ($data['items'] != "") {
        $i = 0;
        //foreach ($data['items'] as $val){
        foreach ($collection as $var) {
            ?>
            <section class="row multi-city modify-city">

                <div class="col-md-2">
                    <div class="form-group-lg form-group-icon-left form-group-filled">
                        <div class="group">
                            <?php echo $this->formElement($var->get('pickup_city')->setValue($data['items'][$i]['pickup_city'])); ?>
        <?php echo $this->formElementErrors($var->get('pickup_city'), array('class' => "error")); ?>
                            <span class="highlight"></span>
                            <span class="bar"></span>
                             <label>From<span style="color: red"> *</span></label>
                        </div>
                    </div>
                </div>

                <div class="col-md-2">
                    <div class="form-group-lg form-group-icon-left">
                        <div class="group">
                            <?php echo $this->formElement($var->get('drop_city')->setValue($data['items'][$i]['drop_city'])); ?>
        <?php echo $this->formElementErrors($var->get('drop_city'), array('class' => "error")); ?>
                            <span class="highlight"></span>
                            <span class="bar"></span>
                            <label>To<span style="color: red"> *</span></label>
                        </div>
                    </div>
                </div>

                <div class="col-md-2">
                    <div class="form-group-lg form-group-icon-left">
                        <div class="group">
                            <?php echo $this->formElement($var->get('pickup_date')->setValue(date('d-m-Y',strtotime($data['items'][$i]['pickup_date'])))->setAttribute('id', 'pickup-date'.$i)); ?>
        <?php echo $this->formElementErrors($var->get('pickup_date'), array('class' => "error")); ?>
                            <span class="highlight"></span>
                            <span class="bar"></span>
                            <label>Date<span style="color: red"> *</span></label>
                        </div>
                    </div>
                </div>

                <div class="col-md-2">
                    <div class="form-group-lg form-group-icon-left">

                        <div class="group">
                            <?php echo $this->formElement($var->get('pickup_time')->setValue($data['items'][$i]['pickup_time'])); ?>
        <?php echo $this->formElementErrors($var->get('pickup_time'), array('class' => "error")); ?>
                             <span class="highlight"></span>
                            <span class="bar"></span>
                            <label>Time<span style="color: red"> *</span></label>
                        </div>
                    </div>
                </div>




                <div class="col-md-2">
                    <div class="form-group-lg form-group-icon-left">
                        <div class="group">
                            <?php echo $this->formElement($var->get('days')->setValue($data['items'][$i]['days'])); ?>
        <?php echo $this->formElementErrors($var->get('days'), array('class' => "error")); ?>
                            <span class="highlight"></span>
                            <span class="bar"></span>
                             <label>No of Nights<span style="color: red"> *</span></label>
                        </div>
                    </div>


                </div>
                <?php if ($i > 1) { ?>
                    <?php
                    echo '<div class="Xbtn col-md-2" onclick="mcClose($(this).parent())">X</div>';
                }
                ?>
            </section>
            <?php
            $i++;
        }
    } else {
        $i = 1;
        foreach ($collection as $var) {
            ?>
            <section class="row multi-city">

                <div class="col-md-2">
                    <div class="form-group-lg form-group-icon-left form-group-filled">
                        <div class="group">
                            <?php echo $this->formElement($var->get('pickup_city')); ?>
        <?php echo $this->formElementErrors($var->get('pickup_city'), array('class' => "error")); ?>
                            <span class="highlight"></span>
                            <span class="bar"></span>
                        </div>
                    </div>
                </div>

                <div class="col-md-2">
                    <div class="form-group-lg form-group-icon-left">
                        <div class="group">
                            <?php echo $this->formElement($var->get('drop_city')); ?>
        <?php echo $this->formElementErrors($var->get('drop_city'), array('class' => "error")); ?>
                            <span class="highlight"></span>
                            <span class="bar"></span>
                        </div>
                    </div>
                </div>

                <div class="col-md-2">
                    <div class="form-group-lg form-group-icon-left">
                        <div class="group">
                            <?php echo $this->formElement($var->get('pickup_date')); ?>
        <?php echo $this->formElementErrors($var->get('pickup_date'), array('class' => "error")); ?>
                            <span class="highlight"></span>
                            <span class="bar"></span>
                        </div>
                    </div>
                </div>

                <div class="col-md-2">
                    <div class="form-group-lg form-group-icon-left">

                        <div class="group">
                            <?php echo $this->formElement($var->get('pickup_time')); ?>
        <?php echo $this->formElementErrors($var->get('pickup_time'), array('class' => "error")); ?>
                        </div>
                    </div>
                </div>




                <div class="col-md-2">
                    <div class="form-group-lg form-group-icon-left">
                        <div class="group">
                            <?php echo $this->formElement($var->get('days')); ?>
        <?php echo $this->formElementErrors($var->get('days'), array('class' => "error")); ?>
                            <span class="highlight"></span>
                            <span class="bar"></span>
                        </div>
                    </div>


                </div>
                <?php if ($i > 2) { ?>
                    <?php
                    echo '<div class="Xbtn col-md-2" onclick="mcClose($(this).parent())">X</div>';
                }
                ?>
            </section>
            <?php
            $i++;
        }
    }
    ?>
</div>
<!--<table class="table table-responsive">
    <thead>
        <tr>
            <th>From<span style="color: red"> *</span></th>
            <th>To<span style="color: red"> *</span></th>
            <th>Departure<span style="color: red"> *</span></th>
            <th>Time<span style="color: red"> *</span></th>
            <th>Days<span style="color: red"> *</span></th>
            <th></th>
        </tr>
    </thead>
    <tbody id="fieldset">
<?php
if ($data['items'] != "") {
    $i = 0;
    //foreach ($data['items'] as $val){
    foreach ($collection as $var) {
        echo '<tr>';
        echo '<td>' . $this->formElement($var->get('pickup_city')->setValue($data['items'][$i]['pickup_city'])) . $this->formElementErrors($var->get('pickup_city')) . '</td>';
        echo '<td>' . $this->formElement($var->get('drop_city')->setValue($data['items'][$i]['drop_city'])) . $this->formElementErrors($var->get('drop_city'), array('class' => "error")) . '</td>';
        echo '<td>' . $this->formElement($var->get('pickup_date')->setValue($data['items'][$i]['pickup_date'])) . $this->formElementErrors($var->get('pickup_date'), array('class' => "error")) . '</td>';
        echo '<td>' . $this->formElement($var->get('pickup_time')->setValue($data['items'][$i]['pickup_time'])) . $this->formElementErrors($var->get('pickup_time'), array('class' => "error")) . '</td>';
        echo '<td>' . $this->formElement($var->get('days')->setValue($data['items'][$i]['days'])) . $this->formElementErrors($var->get('days'), array('class' => "error")) . '</td>';
        ?>
        <?php if ($i > 1) { ?>
            <?php
            echo '<td><div class="Xbtn col-md-2" onclick="mcClose($(this).parent())">X</div></td></tr>';
        }
        $i++;
    }
    //}
} else {
    $i = 1;
    foreach ($collection as $var) {
        echo '<tr>';
        echo '<td>' . $this->formElement($var->get('pickup_city')) . $this->formElementErrors($var->get('pickup_city'), array('class' => "error")) . '</td>';
        echo '<td>' . $this->formElement($var->get('drop_city')) . $this->formElementErrors($var->get('drop_city'), array('class' => "error")) . '</td>';
        echo '<td>' . $this->formElement($var->get('pickup_date')) . $this->formElementErrors($var->get('pickup_date'), array('class' => "error")) . '</td>';
        echo '<td>' . $this->formElement($var->get('pickup_time')) . $this->formElementErrors($var->get('pickup_time'), array('class' => "error")) . '</td>';
        echo '<td>' . $this->formElement($var->get('days')) . $this->formElementErrors($var->get('days'), array('class' => "error")) . '</td>';
        ?>
        <?php if ($i > 2) { ?>
            <?php
            echo '<td><div class="Xbtn col-md-2" onclick="mcClose($(this).parent())">X</div></td></tr>';
        }
        ?>
        <?php
        $i++;
    }
}
?>
    </tbody>
</table>-->

<?php
// Render the collection template
$this->formCollection()->setTemplateWrapper('<span data-template="%s"></span>');
//$this->formCollection()->setShouldWrap(false);
// Change fieldset wrapper to tr rows
//$this->formCollection()->setWrapper('<tr%4$s>%2$s%1$s%3$s</tr>');
$this->formCollection()->setWrapper('<section class="row multi-city modify-city" %4$s>%2$s%1$s%3$s</section>');
// Set the default input helper as our custom formInputTd instead of formInput
$this->formCollection()->setDefaultElementHelper('formRowTd');
echo $this->formCollection()->renderTemplate($collection);
?>
<p>
    <a class="btn btn-default btn-danger white" id="add" href="javascript:void();" role="button"><span class="glyphicon glyphicon-plus"></span>&nbsp;Add City</a>
</p>

<div class="row modify-flight-time">
 <div class="col-sm-10 margintop10 modify-city margin-bot40px">
        <div class="group">
            <?php echo $this->formElement($form->get('pickup_address')); ?>
<?php echo $this->formElementErrors($form->get('pickup_address'), ['class' => 'error']); ?>
            <span class="highlight"></span>
            <span class="bar"></span>
            <?php echo $this->translate($this->formLabel($form->get('pickup_address'))); ?>
        </div>
    </div>

    <div class="col-sm-10 margintop10 modify-city margin-bot40px">
        <div class="group">
            <?php echo $this->formElement($form->get('nationality')); ?>
<?php echo $this->formElementErrors($form->get('nationality'), ['class' => 'error']); ?>
            <span class="highlight"></span>
            <span class="bar"></span>
            <?php echo $this->translate($this->formLabel($form->get('nationality'))); ?>
        </div>
    </div>


<div class="col-sm-12 pull-left margin-bot40px">


    <div class="col-sm-4 margintop10 no-padding">
        <label class="booking-check"><?php echo $this->translate('Coming Mode is Flight'); ?>
            <?php echo $this->formElement($form->get('flight_mode')); ?>
            <span class="checkmark"></span>
<?php echo $this->formElement($form->get('flight_mode_selected')); ?>
        </label>
    </div>

    <div class="disable_none"  id="flight-mode-div">

        <div class="col-sm-2 padding-right0">
            <div class="group">
                <?php echo $this->formElement($form->get('flight_number')); ?>
<?php echo $this->formElementErrors($form->get('flight_number'), ['class' => 'error']); ?>
                <span class="highlight"></span>
                <span class="bar"></span>
                <label>Flight No<span style="color: red"> *</span></label>
            </div>
        </div>

        <div class="col-sm-2 padding-left0">
             <div class="group form-group-lg form-group-select-plus">
                        <div class="input-group clockpicker" data-placement="bottom" data-align="left" data-donetext="Done">
                           <?php echo $this->formElement($form->get('flight_time')); ?>
<?php echo $this->formElementErrors($form->get('flight_time'), ['class' => 'error']); ?>
                            <span class="input-group-addon">
                                <span class="glyphicon glyphicon-time"></span>
                            </span>
                           <?php echo $this->translate($this->formLabel($form->get('flight_time'))); ?>
                        </div>
                    </div>

        </div>
    </div>
</div>


<div class="multi-city col-sm-12 no-padding modify-city margin-bot20px">

    <div class="col-sm-2 margintop10">
        <div class="group quantity">
            <?php echo $this->formElement($form->get('adults')); ?>
<?php echo $this->formElementErrors($form->get('adults'), ['class' => 'error']); ?>
            <span class="highlight"></span>
            <span class="bar"></span>
             <?php echo $this->translate($this->formLabel($form->get('adults'))); ?>
        </div>
    </div>


    <div class="col-sm-2 margintop10">
        <div class="group quantity">
            <?php echo $this->formElement($form->get('childs')); ?>
<?php echo $this->formElementErrors($form->get('childs'), ['class' => 'error']); ?>
            <span class="highlight"></span>
            <span class="bar"></span>
            <?php echo $this->translate($this->formLabel($form->get('childs'))); ?>
        </div>
    </div>


    <div class="col-sm-2 margintop10">
        <div class="group quantity">
            <?php echo $this->formElement($form->get('luggages')); ?>
<?php echo $this->formElementErrors($form->get('luggages'), ['class' => 'error']); ?>
            <span class="highlight"></span>
            <span class="bar"></span>
            <?php echo $this->translate($this->formLabel($form->get('luggages'))); ?>
        </div>
    </div>


    <div class="col-sm-2 margintop10">
        <div class="group quantity">
            <?php echo $this->formElement($form->get('no_of_vehicles')); ?>
<?php echo $this->formElementErrors($form->get('no_of_vehicles'), ['class' => 'error']); ?>
            <span class="highlight"></span>
            <span class="bar"></span>
            <?php echo $this->translate($this->formLabel($form->get('no_of_vehicles'))); ?>
        </div>
    </div>
</div>

<div class="col-sm-12 no-padding">


    <div class="col-sm-12 margintop10">
        
    </div>
    <?php echo $this->formElement($form->get('source_name')); ?>
<?php echo $this->formElement($form->get('destination_name')); ?>

    <div class="col-sm-12">
                <div class="col-md-12 no-padding" style="width:auto !important;">
                    <h6><strong>Note – Booking will be Accepted After 1 Hour from Current Time</strong></h6>
                </div>
                </div><br/>

    <div class="col-sm-3 margintop10">
<?php echo $this->FormElement($form->get('search_a_car')); ?>

    </div>
</div>

 </div>
<?php echo $this->formElement($form->get('module_type')); ?>
<?php echo $this->FormElement($form->get('master_package_type')); ?>
<?php echo $this->FormElement($form->get('pickcity_id')); ?>
<?php echo $this->FormElement($form->get('city_latitude')); ?>
<?php echo $this->FormElement($form->get('city_longitude')); ?>
<?php echo $this->FormElement($form->get('city_northeast_latitude')); ?>
<?php echo $this->FormElement($form->get('city_northeast_longitude')); ?>
<?php echo $this->FormElement($form->get('city_southwest_latitude')); ?>
<?php echo $this->FormElement($form->get('city_southwest_longitude')); ?>
<?php echo $this->form()->closeTag(); ?>