<?php
$product = $form->get('new-product');
$collection = $product->get('items');
$form = $this->form;
$form->prepare();
$form->setAttribute('action', $this->url('guide-booking', ['action' => 'multi-city-guide-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>

<?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('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 no-padding guide-booking">
        <div class="row">
            <div class="col-sm-12 no-padding marginbot20 guide-ohterdetail">
                    <div class="col-md-2">
                        <div class="form-group-lg form-group-icon-left form-group-filled">

                            <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>

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

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


                <div class="col-md-2 col-md-3-mobile">
                    <div class="form-group-lg form-group-select-plus">
                        <div class="group adult quantity">
                            <?php echo $this->formElement($form->get('adults')); ?>
                            <div class="quantity-nav">
                                <div class="quantity-button quantity-up"></div>
                                <div class="quantity-button quantity-down"></div></div>
                            <span class="highlight"></span>
                            <span class="bar"></span>
                              <?php echo $this->translate($this->formLabel($form->get('adults'))); ?>
                        </div>
                    </div>
                </div>

                <div class="col-md-2 col-md-3-mobile">
                    <div class="form-group-lg form-group-select-plus">
                        <div class="group chield quantity">
                            <?php echo $this->formElement($form->get('childs')); ?>
                            <div class="quantity-nav"><div class="quantity-button quantity-up"></div>
                                <div class="quantity-button quantity-down"></div></div>
                            <span class="highlight"></span>
                            <span class="bar"></span>
                            <?php echo $this->translate($this->formLabel($form->get('childs'))); ?>
                        </div>


                    </div>
                </div>

                 <div class="col-md-2 col-md-3-mobile">
            <div class="form-group form-group-lg form-group-select-plus">

                <div class="group">

                    <div class="group guide quantity">
                        <?php echo $this->formElement($form->get('guides')); ?>

                        <div class="quantity-nav">
                            <div class="quantity-button quantity-up"></div>
                            <div class="quantity-button quantity-down"></div></div>
                        <span class="highlight"></span>
                        <span class="bar"></span>
                        <?php echo $this->translate($this->formLabel($form->get('guides'))); ?>
                    </div>

                </div>

            </div>
        </div>


            </div>




        </div>

<div class="row package-pickup">
       <div class="col-md-2">
                    <div class="form-group-lg form-group-select-plus">
                        <div class="group">
                            <?php echo $this->formElement($form->get('guide_package')); ?>
                            <?php echo $this->formElementErrors($form->get('guide_package'), ['class' => 'error']); ?>
                            <span class="highlight"></span>
                            <span class="bar"></span>
                            <?php echo $this->translate($this->formLabel($form->get('guide_package'))); ?>
                        </div>
                    </div>
                </div>
        <div class="col-md-10 margin-top18">
            <div class="form-group form-group-lg form-group-select-plus">
                <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>

</div>
    </div>

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


    <div class="col-sm-12 margintop10">
        <div class="col-md-6 no-padding">
            <div class="form-group-lg form-group-select-plus spanclass">
                <label class="booking-check"><a href="javascript: void(0);" class="terms-color" onclick="termsCondition()"><?php echo $this->translate('Accept the Terms and Conditions'); ?></a>
                    <?php echo $this->FormElement($form->get('agree_terms')); ?>
<?php echo $this->formElementErrors($form->get('agree_terms'), ['class' => 'error']); ?>
                    <span class="checkmark"></span>
                </label>
            </div>
        </div>
    </div>
    <?php echo $this->formElement($form->get('source_name')); ?>
<?php echo $this->formElement($form->get('destination_name')); ?>

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

    </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(); ?>