<?php
$session = new \Zend\Session\Container('userlogin');
$user_id = isset($session->userData['user_id'])?$session->userData['user_id']:'';
?>
<div class="tab-pane fade in active" id="pointtopoint_form">
    <?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']));
    $form->setAttribute('method', 'post');
    $form->setAttribute('id', 'vehicle-search-form');
    echo $this->form()->openTag($form);
    ?>
<div id="fieldset">
    <?php
    $i = 0;
    //https://framework.zend.com/manual/2.4/en/modules/zend.form.view.helpers.html
    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 if($i==0){ ?>
                        <?php echo $this->formElement($var->get('pickup_city')->setValue(isset($cityValue)?$cityValue:'')); ?>
                        <?php } else { ?>
                        <?php echo $this->formElement($var->get('pickup_city')); ?>
                        <?php }?>
                        <?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 if($i==1){ ?>
                        <?php echo $this->formElement($var->get('drop_city')->setValue(isset($cityValue)?$cityValue:'')); ?>
                        <?php } else { ?>
                        <?php echo $this->formElement($var->get('drop_city')); ?>
                        <?php }?>

                        <?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')->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')); ?>
                        <?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')); ?>
                        <?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 > 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('<section class="row multi-city" %4$s>%2$s%1$s%3$s</section>');

//https://github.com/zendframework/zend-form/blob/master/src/View/Helper/FormCollection.php
// Set the default input helper as our custom formInputTd instead of formInput
$this->formCollection()->setDefaultElementHelper('formRowTd');

echo $this->formCollection()->renderTemplate($collection);
?>
<div class="col-sm-10 marginbot20 margintop10 no-padding">
    <a class="btn btn-danger white " id="add" href="javascript:void();" role="button"><span class="glyphicon glyphicon-plus"></span>&nbsp;Add City</a>
</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 padding0 margintop10 marginbot20">
        <div class="row">
            <div class="col-md-6">
                <div class="form-group-lg form-group-select-plus spanclass">
                    <label class="booking-check">
                        <?php echo $this->translate('Accept the Terms and Conditions'); ?>
                        <?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>
    </div>

<div class="col-sm-6 no-padding pull-left margin-bot10px margintop10" align="left">
    <?php echo $this->formElement($form->get('source_name')); ?>
    <?php echo $this->formElement($form->get('destination_name')); ?>
    <?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 if (!empty($user_id)) { ?>
        <?php echo $this->FormElement($form->get('submit')); ?>
    <?php } else { ?>
        <a href="<?php echo $this->url('login'); ?>" data-target="#ajax-modal" data-toggle="modal" data-remote="true" data-keyboard="false" data-backdrop="static" class="btn btn-red defaultbtnsearch btn-warning">
            <i class="fa fa-search iconsearch" id="search-me" ></i>Search
        </a>
    <?php } ?>
</div>
</div>

<?php echo $this->form()->closeTag(); ?>

