<?php

namespace Dashboard\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Dashboard\Form\ManageDocumentationForm;

class ManageDocumentationController extends AbstractActionController {

    /**
     * Index
     * @return ViewModel
     */
    public function indexAction() {

        $form = new ManageDocumentationForm();
        //Call API...
        $tourInclusionListing = [
            '0' => [
                'country' => 'India',
                'type_of_booking' => 'Domestic Fit',
                'title' => 'Domestic',
                'payment_structure' => 'We have a variety of Products suiting the requirements of everyone. You can select the tour as per your preference.',
                'created_by' => 'Admin',
                'Status' => '1'
            ],
            '1' => [
                'country' => 'Usa',
                'type_of_booking' => 'Domestic Fit',
                'title' => 'Domestic',
                'payment_structure' => 'We have a variety of Products suiting the requirements of everyone. You can select the tour as per your preference.',
                'created_by' => 'Admin',
                'Status' => '1'
            ],
            '2' => [
                'country' => 'China',
                'type_of_booking' => 'Domestic Fit',
                'title' => 'Domestic',
                'payment_structure' => 'We have a variety of Products suiting the requirements of everyone. You can select the tour as per your preference.',
                'created_by' => 'Admin',
                'Status' => '1'
            ]
        ];


    
        $request = $this->getRequest();

        if ($request->isPost()) {

            $form->setData($request->getPost());

            $post = $request->getPost()->toArray();
            if ($form->isValid()) {
                $post = $request->getPost()->toArray();
              
                return $this->redirect()->toRoute('manage-documentation', ['action' => 'index']);
            } else {
                
                //$form->getMessages()
            }
        }

        $viewModel = new ViewModel(['form' => $form,'tourInclusionListing'=>$tourInclusionListing]);
        return $viewModel;
    }

    public function EditDocumentationAction() {



        $form = new ManageDocumentationForm();


        $request = $this->getRequest();
        //if request will be post                
        if ($request->isPost()) {
            $form->setData($request->getPost());
            if ($form->isValid()) {
                $post = $request->getPost()->toArray();
               
                return $this->redirect()->toRoute('manage-documentation', ['action' => 'index']);
            }
        }
        $viewModel = new ViewModel(['form' => $form]);
        return $viewModel;
    }

}
