<?php



use Website\Controller\Action;



class char {

}



class duration {

}



class guid {

}



class Language {

}



class EstateAvailability {

}



class EstateCategory {

}



class ContactEstateType {

}



class ContactType {

}



class CountryCode {

}



class GenderType {

}



class EstatePurpose {

}



class EstateState {

}



class EstateSubCategory {

}



class EstateDisplayStatus {

}



class BaseDocumentType {

}



class EstateProcessAction {

}



class EstatePurposeStatus {

}



class EstateStatus {

}



class PictureSize {

}



class ExportStatus {

}



class KeyValueOfLanguagestringU2dkwwYM {

    public $Key; // Language

    public $Value; // string

}



class KeyValueOfstringstring {

    public $Key; // string

    public $Value; // string

}



class RequestHeader {

    public $Login; // string

    public $Password; // string

}



class BaseDocumentTypeData {

    public $BaseDocumentTypeId; // int

    public $IsActive; // boolean

    public $Name; // ArrayOfKeyValueOfLanguagestringU2dkwwYM

}



class ContactOriginData {

    public $ContactOriginID; // int

    public $Origin; // ArrayOfKeyValueOfLanguagestringU2dkwwYM

}



class ContactTitleData {

    public $ContactTitleID; // int

    public $LongDescription; // ArrayOfKeyValueOfLanguagestringU2dkwwYM

    public $ShortDescription; // ArrayOfKeyValueOfLanguagestringU2dkwwYM

}



class ContactTypeData {

    public $ContactTypeID; // int

    public $Type; // ArrayOfKeyValueOfLanguagestringU2dkwwYM

}



class ExportData {

    public $Estates; // ArrayOfEstateData

    public $RecordCount; // int

}



class EstateData {

    public $Address1; // string

    public $Address2; // string

    public $Area; // double

    public $Availability; // EstateAvailability

    public $AvailabilityDateTime; // dateTime

    public $BathRooms; // int

    public $Box; // string

    public $CanHaveChildren; // boolean

    public $Category; // EstateCategory

    public $City; // string

    public $Contacts; // ArrayOfContactData

    public $Country; // CountryCode

    public $CreateDateTime; // dateTime

    public $Currency; // string

    public $Details; // ArrayOfSubDetailData

    public $DisplayAddress; // boolean

    public $DisplayPrice; // boolean

    public $DisplayStatus; // EstateDisplayStatus

    public $Documents; // ArrayOfDocumentData

    public $EstateID; // int

    public $EstateOrder; // int

    public $Evaluation; // int

    public $Floor; // string

    public $Fronts; // int

    public $Furnished; // int

    public $Garage; // int

    public $Garden; // int

    public $GardenArea; // double

    public $GroundArea; // double

    public $InvestmentEstate; // boolean

    public $IsTypeEstate; // boolean

    public $Link3DModel; // string

    public $LinkRouteDesc; // boolean

    public $LinkVirtualVisit; // string

    public $LongDescription; // ArrayOfKeyValueOfLanguagestringU2dkwwYM

    public $Name; // string

    public $Number; // string

    public $OfficeID; // int

    public $ParentID; // int

    public $Parking; // int

    public $Pictures; // ArrayOfPictureData

    public $Price; // decimal

    public $PriceChangeDateTime; // dateTime

    public $ProcessAction; // EstateProcessAction

    public $ProjectPathName; // string

    public $PublicationText; // ArrayOfKeyValueOfLanguagestringU2dkwwYM

    public $Purpose; // EstatePurpose

    public $PurposeStatus; // EstatePurposeStatus

    public $ReferenceNumber; // string

    public $Representative; // LoginData

    public $Rooms; // int

    public $ShortDescription; // ArrayOfKeyValueOfLanguagestringU2dkwwYM

    public $Sms; // ArrayOfKeyValueOfstringstring

    public $State; // EstateState

    public $Status; // EstateStatus

    public $SubCategory; // EstateSubCategory

    public $Terrace; // int

    public $UpdateDateTime; // dateTime

    public $Zip; // string

}



class ContactData {

    public $Address1; // string

    public $Address2; // string

    public $AgreementMail; // boolean

    public $AgreementSms; // boolean

    public $Box; // string

    public $City; // string

    public $Comments; // string

    public $ContactEstateType; // ContactEstateType

    public $ContactId; // int

    public $ContactOriginID; // int

    public $ContactTitleID; // int

    public $ContactType; // ContactType

    public $ContactTypeIDList; // ArrayOfint

    public $Country; // CountryCode

    public $EstateId; // int

    public $FirstName; // string

    public $Gender; // GenderType

    public $Language; // Language

    public $Message; // string

    public $Name; // string

    public $Number; // string

    public $OfficeID; // int

    public $PrivateEmail; // string

    public $PrivateMobile; // string

    public $PrivateTel; // string

    public $SearchCriteria; // ArrayOfContactSearchCriteria

    public $Zip; // string

}



class ContactSearchCriteria {

    public $AreaMax; // double

    public $AreaMin; // double

    public $Category; // EstateCategory

    public $Country; // CountryCode

    public $Fronts; // int

    public $Furnished; // boolean

    public $Garage; // boolean

    public $Garden; // boolean

    public $GardenAreaMax; // double

    public $GardenAreaMin; // double

    public $GroundAreaMax; // double

    public $GroundAreaMin; // double

    public $InvestmentEstate; // boolean

    public $MinRooms; // int

    public $Parking; // boolean

    public $PriceMax; // int

    public $PriceMin; // int

    public $Purpose; // EstatePurpose

    public $RegionIDList; // ArrayOfint

    public $State; // EstateState

    public $SubCategory; // EstateSubCategory

    public $Terrace; // boolean

    public $ZipList; // ArrayOfstring

}



class SubDetailData {

    public $DetailID; // int

    public $DetailName; // ArrayOfKeyValueOfLanguagestringU2dkwwYM

    public $EnumId; // int

    public $NumericValue; // double

    public $SubDetailId; // int

    public $SubDetailName; // ArrayOfKeyValueOfLanguagestringU2dkwwYM

    public $Type; // string

    public $Value; // ArrayOfKeyValueOfLanguagestringU2dkwwYM

}



class DocumentData {

    public $BaseDocumentTypeId; // BaseDocumentType

    public $DocumentId; // int

    public $Name; // string

}



class PictureData {

    public $Description; // ArrayOfKeyValueOfLanguagestringU2dkwwYM

    public $Detail; // ArrayOfKeyValueOfLanguagestringU2dkwwYM

    public $Order; // int

    public $PictureExtension; // string

    public $PictureID; // int

}



class LoginData {

    public $Email; // string

    public $FirstName; // string

    public $Initials; // string

    public $Language; // Language

    public $LoginID; // int

    public $Mobile; // string

    public $Name; // string

    public $OfficeID; // int

}



class OfficeData {

    public $Address1; // string

    public $Address2; // string

    public $Box; // string

    public $City; // string

    public $ClientId; // int

    public $ClientName; // string

    public $Contact; // OfficeContactData

    public $Country; // CountryCode

    public $Email; // string

    public $Fax; // string

    public $Mobile; // string

    public $Number; // string

    public $OfficeId; // int

    public $OfficeName; // string

    public $Telephone; // string

    public $Vat; // string

    public $Website; // string

    public $Zip; // string

}



class OfficeContactData {

    public $ContactEmail; // string

    public $ContactFirstName; // string

    public $ContactMobile; // string

    public $ContactName; // string

    public $ContactTel; // string

}



class OfficeList {

    public $Offices; // ArrayOfOfficeData

    public $RecordCount; // int

}



class PictureDetailData {

    public $Name; // ArrayOfKeyValueOfLanguagestringU2dkwwYM

    public $PictureDetailId; // int

}



class RegionData {

    public $Name; // ArrayOfKeyValueOfLanguagestringU2dkwwYM

    public $RegionID; // int

    public $Values; // ArrayOfstring

}



class UploadDocumentData {

    public $BaseDocumentTypeId; // int

    public $Description; // ArrayOfKeyValueOfstringstring

    public $DocumentExtension; // string

    public $DocumentFile; // string

    public $EstateId; // int

    public $IsPlan; // boolean

    public $IsPublic; // boolean

    public $Name; // string

    public $OfficeId; // int

}



class UploadResult {

    public $ErrorMessage; // string

    public $Id; // int

    public $Success; // boolean

}



class UploadPictureData {

    public $EstateId; // int

    public $IsPublic; // boolean

    public $OfficeId; // int

    public $PictureDetailId; // int

    public $PictureFile; // string

}



class StreamBody {

}



class GetBaseDocumentType {

    public $header; // RequestHeader

    public $officeId; // int

}



class GetBaseDocumentTypeResponse {

    public $GetBaseDocumentTypeResult; // ArrayOfBaseDocumentTypeData

}



class GetContactOrigin {

    public $header; // RequestHeader

    public $officeId; // int

}



class GetContactOriginResponse {

    public $GetContactOriginResult; // ArrayOfContactOriginData

}



class GetContactTitle {

    public $header; // RequestHeader

    public $officeId; // int

}



class GetContactTitleResponse {

    public $GetContactTitleResult; // ArrayOfContactTitleData

}



class GetContactType {

    public $header; // RequestHeader

    public $officeId; // int

}



class GetContactTypeResponse {

    public $GetContactTypeResult; // ArrayOfContactTypeData

}



class GetDocument {

    public $header; // RequestHeader

    public $documentId; // int

}



class GetDocumentResponse {

    public $GetDocumentResult; // StreamBody

}



class GetEstateToBeExportedToMedia {

    public $header; // RequestHeader

    public $officeID; // ArrayOfint

    public $reset; // boolean

    public $page; // int

}



class GetEstateToBeExportedToMediaResponse {

    public $GetEstateToBeExportedToMediaResult; // ExportData

}



class GetOffices {

    public $header; // RequestHeader

}



class GetOfficesResponse {

    public $GetOfficesResult; // ArrayOfOfficeData

}



class GetOfficesPaging {

    public $header; // RequestHeader

    public $page; // int

}



class GetOfficesPagingResponse {

    public $GetOfficesPagingResult; // OfficeList

}



class GetPicture {

    public $header; // RequestHeader

    public $pictureID; // int

    public $size; // PictureSize

}



class GetPictureResponse {

    public $GetPictureResult; // StreamBody

}



class GetPictureDetail {

    public $header; // RequestHeader

}



class GetPictureDetailResponse {

    public $GetPictureDetailResult; // ArrayOfPictureDetailData

}



class GetRegion {

    public $header; // RequestHeader

    public $officeId; // int

}



class GetRegionResponse {

    public $GetRegionResult; // ArrayOfRegionData

}



class UpdateContact {

    public $header; // RequestHeader

    public $contact; // ContactData

}



class UpdateContactResponse {

}



class UpdateEstateExportStatusByMedia {

    public $header; // RequestHeader

    public $estateID; // int

    public $exportStatus; // ExportStatus

    public $IdInMedia; // string

}



class UpdateEstateExportStatusByMediaResponse {

}



class UpdateEstateSubDetail {

    public $header; // RequestHeader

    public $estateId; // int

    public $subDetailData; // ArrayOfSubDetailData

}



class UpdateEstateSubDetailResponse {

}



class UploadDocument {

    public $header; // RequestHeader

    public $document; // UploadDocumentData

}



class UploadDocumentResponse {

    public $UploadDocumentResult; // UploadResult

}



class UploadPicture {

    public $header; // RequestHeader

    public $picture; // UploadPictureData

}



class UploadPictureResponse {

    public $UploadPictureResult; // UploadResult

}





/**

 * WhomanMediaService class

 *

 *

 *

 * @author    {author}

 * @copyright {copyright}

 * @package   {package}

 */

class WhomanMediaService extends SoapClient {



    private static $classmap = array(

        'char' => 'char',

        'duration' => 'duration',

        'guid' => 'guid',

        'Language' => 'Language',

        'EstateAvailability' => 'EstateAvailability',

        'EstateCategory' => 'EstateCategory',

        'ContactEstateType' => 'ContactEstateType',

        'ContactType' => 'ContactType',

        'CountryCode' => 'CountryCode',

        'GenderType' => 'GenderType',

        'EstatePurpose' => 'EstatePurpose',

        'EstateState' => 'EstateState',

        'EstateSubCategory' => 'EstateSubCategory',

        'EstateDisplayStatus' => 'EstateDisplayStatus',

        'BaseDocumentType' => 'BaseDocumentType',

        'EstateProcessAction' => 'EstateProcessAction',

        'EstatePurposeStatus' => 'EstatePurposeStatus',

        'EstateStatus' => 'EstateStatus',

        'PictureSize' => 'PictureSize',

        'ExportStatus' => 'ExportStatus',

        'KeyValueOfLanguagestringU2dkwwYM' => 'KeyValueOfLanguagestringU2dkwwYM',

        'KeyValueOfstringstring' => 'KeyValueOfstringstring',

        'RequestHeader' => 'RequestHeader',

        'BaseDocumentTypeData' => 'BaseDocumentTypeData',

        'ContactOriginData' => 'ContactOriginData',

        'ContactTitleData' => 'ContactTitleData',

        'ContactTypeData' => 'ContactTypeData',

        'ExportData' => 'ExportData',

        'EstateData' => 'EstateData',

        'ContactData' => 'ContactData',

        'ContactSearchCriteria' => 'ContactSearchCriteria',

        'SubDetailData' => 'SubDetailData',

        'DocumentData' => 'DocumentData',

        'PictureData' => 'PictureData',

        'LoginData' => 'LoginData',

        'OfficeData' => 'OfficeData',

        'OfficeContactData' => 'OfficeContactData',

        'OfficeList' => 'OfficeList',

        'PictureDetailData' => 'PictureDetailData',

        'RegionData' => 'RegionData',

        'UploadDocumentData' => 'UploadDocumentData',

        'UploadResult' => 'UploadResult',

        'UploadPictureData' => 'UploadPictureData',

        'StreamBody' => 'StreamBody',

        'GetBaseDocumentType' => 'GetBaseDocumentType',

        'GetBaseDocumentTypeResponse' => 'GetBaseDocumentTypeResponse',

        'GetContactOrigin' => 'GetContactOrigin',

        'GetContactOriginResponse' => 'GetContactOriginResponse',

        'GetContactTitle' => 'GetContactTitle',

        'GetContactTitleResponse' => 'GetContactTitleResponse',

        'GetContactType' => 'GetContactType',

        'GetContactTypeResponse' => 'GetContactTypeResponse',

        'GetDocument' => 'GetDocument',

        'GetDocumentResponse' => 'GetDocumentResponse',

        'GetEstateToBeExportedToMedia' => 'GetEstateToBeExportedToMedia',

        'GetEstateToBeExportedToMediaResponse' => 'GetEstateToBeExportedToMediaResponse',

        'GetOffices' => 'GetOffices',

        'GetOfficesResponse' => 'GetOfficesResponse',

        'GetOfficesPaging' => 'GetOfficesPaging',

        'GetOfficesPagingResponse' => 'GetOfficesPagingResponse',

        'GetPicture' => 'GetPicture',

        'GetPictureResponse' => 'GetPictureResponse',

        'GetPictureDetail' => 'GetPictureDetail',

        'GetPictureDetailResponse' => 'GetPictureDetailResponse',

        'GetRegion' => 'GetRegion',

        'GetRegionResponse' => 'GetRegionResponse',

        'UpdateContact' => 'UpdateContact',

        'UpdateContactResponse' => 'UpdateContactResponse',

        'UpdateEstateExportStatusByMedia' => 'UpdateEstateExportStatusByMedia',

        'UpdateEstateExportStatusByMediaResponse' => 'UpdateEstateExportStatusByMediaResponse',

        'UpdateEstateSubDetail' => 'UpdateEstateSubDetail',

        'UpdateEstateSubDetailResponse' => 'UpdateEstateSubDetailResponse',

        'UploadDocument' => 'UploadDocument',

        'UploadDocumentResponse' => 'UploadDocumentResponse',

        'UploadPicture' => 'UploadPicture',

        'UploadPictureResponse' => 'UploadPictureResponse',

    );



    public function WhomanMediaService($wsdl = "http://mediaservices.whoman2.be:9101/WMS?wsdl", $options = array()) {

        foreach(self::$classmap as $key => $value) {

            if(!isset($options['classmap'][$key])) {

                $options['classmap'][$key] = $value;

            }

        }

        parent::__construct($wsdl, $options);

    }



    /**

     *

     *

     * @param GetBaseDocumentType $parameters

     * @return GetBaseDocumentTypeResponse

     */

    public function GetBaseDocumentType(GetBaseDocumentType $parameters) {

        return $this->__soapCall('GetBaseDocumentType', array($parameters), array(

                'uri' => 'http://tempuri.org/',

                'soapaction' => ''

            )

        );

    }



    /**

     *

     *

     * @param GetContactOrigin $parameters

     * @return GetContactOriginResponse

     */

    public function GetContactOrigin(GetContactOrigin $parameters) {

        return $this->__soapCall('GetContactOrigin', array($parameters),       array(

                'uri' => 'http://tempuri.org/',

                'soapaction' => ''

            )

        );

    }



    /**

     *

     *

     * @param GetContactTitle $parameters

     * @return GetContactTitleResponse

     */

    public function GetContactTitle(GetContactTitle $parameters) {

        return $this->__soapCall('GetContactTitle', array($parameters),       array(

                'uri' => 'http://tempuri.org/',

                'soapaction' => ''

            )

        );

    }



    /**

     *

     *

     * @param GetContactType $parameters

     * @return GetContactTypeResponse

     */

    public function GetContactType(GetContactType $parameters) {

        return $this->__soapCall('GetContactType', array($parameters),       array(

                'uri' => 'http://tempuri.org/',

                'soapaction' => ''

            )

        );

    }



    /**

     *

     *

     * @param GetDocument $parameters

     * @return GetDocumentResponse

     */

    public function GetDocument(GetDocument $parameters) {

        return $this->__soapCall('GetDocument', array($parameters),       array(

                'uri' => 'http://tempuri.org/',

                'soapaction' => ''

            )

        );

    }



    /**

     *

     *

     * @param GetEstateToBeExportedToMedia $parameters

     * @return GetEstateToBeExportedToMediaResponse

     */

    public function GetEstateToBeExportedToMedia(GetEstateToBeExportedToMedia $parameters) {

        return $this->__soapCall('GetEstateToBeExportedToMedia', array($parameters),       array(

                'uri' => 'http://tempuri.org/',

                'soapaction' => ''

            )

        );

    }



    /**

     *

     *

     * @param GetOffices $parameters

     * @return GetOfficesResponse

     */

    public function GetOffices(GetOffices $parameters) {

        return $this->__soapCall('GetOffices', array($parameters),       array(

                'uri' => 'http://tempuri.org/',

                'soapaction' => ''

            )

        );

    }



    /**

     *

     *

     * @param GetOfficesPaging $parameters

     * @return GetOfficesPagingResponse

     */

    public function GetOfficesPaging(GetOfficesPaging $parameters) {

        return $this->__soapCall('GetOfficesPaging', array($parameters),       array(

                'uri' => 'http://tempuri.org/',

                'soapaction' => ''

            )

        );

    }



    /**

     *

     *

     * @param GetPicture $parameters

     * @return GetPictureResponse

     */

    public function GetPicture(GetPicture $parameters) {

        return $this->__soapCall('GetPicture', array($parameters),       array(

                'uri' => 'http://tempuri.org/',

                'soapaction' => ''

            )

        );

    }



    /**

     *

     *

     * @param GetPictureDetail $parameters

     * @return GetPictureDetailResponse

     */

    public function GetPictureDetail(GetPictureDetail $parameters) {

        return $this->__soapCall('GetPictureDetail', array($parameters),       array(

                'uri' => 'http://tempuri.org/',

                'soapaction' => ''

            )

        );

    }



    /**

     *

     *

     * @param GetRegion $parameters

     * @return GetRegionResponse

     */

    public function GetRegion(GetRegion $parameters) {

        return $this->__soapCall('GetRegion', array($parameters),       array(

                'uri' => 'http://tempuri.org/',

                'soapaction' => ''

            )

        );

    }



    /**

     *

     *

     * @param UpdateContact $parameters

     * @return UpdateContactResponse

     */

    public function UpdateContact(UpdateContact $parameters) {

        return $this->__soapCall('UpdateContact', array($parameters),       array(

                'uri' => 'http://tempuri.org/',

                'soapaction' => ''

            )

        );

    }



    /**

     *

     *

     * @param UpdateEstateExportStatusByMedia $parameters

     * @return UpdateEstateExportStatusByMediaResponse

     */

    public function UpdateEstateExportStatusByMedia(UpdateEstateExportStatusByMedia $parameters) {

        return $this->__soapCall('UpdateEstateExportStatusByMedia', array($parameters),       array(

                'uri' => 'http://tempuri.org/',

                'soapaction' => ''

            )

        );

    }



    /**

     *

     *

     * @param UpdateEstateSubDetail $parameters

     * @return UpdateEstateSubDetailResponse

     */

    public function UpdateEstateSubDetail(UpdateEstateSubDetail $parameters) {

        return $this->__soapCall('UpdateEstateSubDetail', array($parameters),       array(

                'uri' => 'http://tempuri.org/',

                'soapaction' => ''

            )

        );

    }



    /**

     *

     *

     * @param UploadDocument $parameters

     * @return UploadDocumentResponse

     */

    public function UploadDocument(UploadDocument $parameters) {

        return $this->__soapCall('UploadDocument', array($parameters),       array(

                'uri' => 'http://tempuri.org/',

                'soapaction' => ''

            )

        );

    }



    /**

     *

     *

     * @param UploadPicture $parameters

     * @return UploadPictureResponse

     */

    public function UploadPicture(UploadPicture $parameters) {

        return $this->__soapCall('UploadPicture', array($parameters),       array(

                'uri' => 'http://tempuri.org/',

                'soapaction' => ''

            )

        );

    }



}





class AdminController extends Action {



    public function oldInsertAction(){

        $this->enableLayout();

        $this->setLayout('empty');



        if(isset($_GET['uid']) && $_GET['uid'] != '')

            $this->view->mode = 'edit';

        elseif(isset($_POST['do_update'])){

            $this->view->mode = 'do_update';

        }else{

            $this->view->mode = 'new';

        }





        if($this->view->mode == 'edit'){

            // Affiche une agence pour l'�diter...



            $uid = $_GET['uid'];

            $agency = \Website\Model\Agency::getByUid($uid);

            $this->view->agency =$agency;



        }

        elseif($this->view->mode == 'do_update'){



            // L'agence � �t� �dit�e

            $agency = new Website\Model\Agency();



            $agency->setId($_POST['id']);

            $agency->setUid($_POST['uid']);



            $agency->setName($_POST['name']);

            $agency->setPhone($_POST['phone']);

            $agency->setEmail($_POST['email']);

            $agency->setAddress($_POST['address']);

            $agency->setCp($_POST['cp']);



            $agency->setShort_description($_POST['description']);

            $agency->setLong_description($_POST['long_description']);



            $agency->setWebsite($_POST['website']);

            $agency->setFacebook($_POST['facebook']);

            $agency->setTwitter($_POST['twitter']);

            $agency->setLinkedin($_POST['linkedin']);



            $agency->setSeerus_key($_POST['seerus_key']);



            var_dump($_POST);



            if ($_POST['lundi_is_open'] == 0){

                $lundiAmStart   = 0;

                $lundiAmEnd     = 0;

                $lundiPmStart   = 0;

                $lundiPmEnd     = 0;

            }else {

                if ($_POST['lundi_is_open'] == 2) {

                    $lundiAmStart = -1;

                    $lundiAmEnd = -1;

                    $lundiPmStart = -1;

                    $lundiPmEnd = -1;

                }else{

                    if ($_POST['lundi_has_lunch'] == 0) {

                        $lundiAmStart = $_POST['lundi_am_start_0'];

                        $lundiAmEnd = -3;

                        $lundiPmStart = -3;

                        $lundiPmEnd = $_POST['lundi_pm_end_0'];

                    }else{

                        if($_POST['lundi_am_on_rdv'] == 1){

                            $lundiAmStart = -1;

                            $lundiAmEnd = -1;

                        }else{

                            $lundiAmStart = $_POST['lundi_am_start_1'];

                            $lundiAmEnd = $_POST['lundi_am_end_1'];

                        }

                        if($_POST['lundi_pm_on_rdv'] == 1){

                            $lundiPmStart = -1;

                            $lundiPmEnd = -1;

                        }else{

                            $lundiPmStart = $_POST['lundi_pm_start_1'];

                            $lundiPmEnd = $_POST['lundi_pm_end_1'];

                        }

                    }

                }

            }



            if ($_POST['mardi_is_open'] == 0){

                $mardiAmStart   = 0;

                $mardiAmEnd     = 0;

                $mardiPmStart   = 0;

                $mardiPmEnd     = 0;

            }else {

                if ($_POST['mardi_is_open'] == 2) {

                    $mardiAmStart = -1;

                    $mardiAmEnd = -1;

                    $mardiPmStart = -1;

                    $mardiPmEnd = -1;

                }else{

                    if ($_POST['mardi_has_lunch'] == 0) {

                        $mardiAmStart = $_POST['mardi_am_start_0'];

                        $mardiAmEnd = -3;

                        $mardiPmStart = -3;

                        $mardiPmEnd = $_POST['mardi_pm_end_0'];

                    }else{

                        if($_POST['mardi_am_on_rdv'] == 1){

                            $mardiAmStart = -1;

                            $mardiAmEnd = -1;

                        }else{

                            $mardiAmStart = $_POST['mardi_am_start_1'];

                            $mardiAmEnd = $_POST['mardi_am_end_1'];

                        }

                        if($_POST['mardi_pm_on_rdv'] == 1){

                            $mardiPmStart = -1;

                            $mardiPmEnd = -1;

                        }else{

                            $mardiPmStart = $_POST['mardi_pm_start_1'];

                            $mardiPmEnd = $_POST['mardi_pm_end_1'];

                        }

                    }

                }

            }



            if ($_POST['mercredi_is_open'] == 0){

                $mercrediAmStart   = 0;

                $mercrediAmEnd     = 0;

                $mercrediPmStart   = 0;

                $mercrediPmEnd     = 0;

            }else {

                if ($_POST['mercredi_is_open'] == 2) {

                    $mercrediAmStart = -1;

                    $mercrediAmEnd = -1;

                    $mercrediPmStart = -1;

                    $mercrediPmEnd = -1;

                }else{

                    if ($_POST['mercredi_has_lunch'] == 0) {

                        $mercrediAmStart = $_POST['mercredi_am_start_0'];

                        $mercrediAmEnd = -3;

                        $mercrediPmStart = -3;

                        $mercrediPmEnd = $_POST['mercredi_pm_end_0'];

                    }else{

                        if($_POST['mercredi_am_on_rdv'] == 1){

                            $mercrediAmStart = -1;

                            $mercrediAmEnd = -1;

                        }else{

                            $mercrediAmStart = $_POST['mercredi_am_start_1'];

                            $mercrediAmEnd = $_POST['mercredi_am_end_1'];

                        }

                        if($_POST['mercredi_pm_on_rdv'] == 1){

                            $mercrediPmStart = -1;

                            $mercrediPmEnd = -1;

                        }else{

                            $mercrediPmStart = $_POST['mercredi_pm_start_1'];

                            $mercrediPmEnd = $_POST['mercredi_pm_end_1'];

                        }

                    }

                }

            }



            if ($_POST['jeudi_is_open'] == 0){

                $jeudiAmStart   = 0;

                $jeudiAmEnd     = 0;

                $jeudiPmStart   = 0;

                $jeudiPmEnd     = 0;

            }else {

                if ($_POST['jeudi_is_open'] == 2) {

                    $jeudiAmStart = -1;

                    $jeudiAmEnd = -1;

                    $jeudiPmStart = -1;

                    $jeudiPmEnd = -1;

                }else{

                    if ($_POST['jeudi_has_lunch'] == 0) {

                        $jeudiAmStart = $_POST['jeudi_am_start_0'];

                        $jeudiAmEnd = -3;

                        $jeudiPmStart = -3;

                        $jeudiPmEnd = $_POST['jeudi_pm_end_0'];

                    }else{

                        if($_POST['jeudi_am_on_rdv'] == 1){

                            $jeudiAmStart = -1;

                            $jeudiAmEnd = -1;

                        }else{

                            $jeudiAmStart = $_POST['jeudi_am_start_1'];

                            $jeudiAmEnd = $_POST['jeudi_am_end_1'];

                        }

                        if($_POST['jeudi_pm_on_rdv'] == 1){

                            $jeudiPmStart = -1;

                            $jeudiPmEnd = -1;

                        }else{

                            $jeudiPmStart = $_POST['jeudi_pm_start_1'];

                            $jeudiPmEnd = $_POST['jeudi_pm_end_1'];

                        }

                    }

                }

            }



            if ($_POST['vendredi_is_open'] == 0){

                $vendrediAmStart   = 0;

                $vendrediAmEnd     = 0;

                $vendrediPmStart   = 0;

                $vendrediPmEnd     = 0;

            }else {

                if ($_POST['vendredi_is_open'] == 2) {

                    $vendrediAmStart = -1;

                    $vendrediAmEnd = -1;

                    $vendrediPmStart = -1;

                    $vendrediPmEnd = -1;

                }else{

                    if ($_POST['vendredi_has_lunch'] == 0) {

                        $vendrediAmStart = $_POST['vendredi_am_start_0'];

                        $vendrediAmEnd = -3;

                        $vendrediPmStart = -3;

                        $vendrediPmEnd = $_POST['vendredi_pm_end_0'];

                    }else{

                        if($_POST['vendredi_am_on_rdv'] == 1){

                            $vendrediAmStart = -1;

                            $vendrediAmEnd = -1;

                        }else{

                            $vendrediAmStart = $_POST['vendredi_am_start_1'];

                            $vendrediAmEnd = $_POST['vendredi_am_end_1'];

                        }

                        if($_POST['vendredi_pm_on_rdv'] == 1){

                            $vendrediPmStart = -1;

                            $vendrediPmEnd = -1;

                        }else{

                            $vendrediPmStart = $_POST['vendredi_pm_start_1'];

                            $vendrediPmEnd = $_POST['vendredi_pm_end_1'];

                        }

                    }

                }

            }



            if ($_POST['samedi_is_open'] == 0){

                $samediAmStart   = 0;

                $samediAmEnd     = 0;

                $samediPmStart   = 0;

                $samediPmEnd     = 0;

            }else {

                if ($_POST['samedi_is_open'] == 2) {

                    $samediAmStart = -1;

                    $samediAmEnd = -1;

                    $samediPmStart = -1;

                    $samediPmEnd = -1;

                }else{

                    if ($_POST['samedi_has_lunch'] == 0) {

                        $samediAmStart = $_POST['samedi_am_start_0'];

                        $samediAmEnd = -3;

                        $samediPmStart = -3;

                        $samediPmEnd = $_POST['samedi_pm_end_0'];

                    }else{

                        if($_POST['samedi_am_on_rdv'] == 1){

                            $samediAmStart = -1;

                            $samediAmEnd = -1;

                        }else{

                            $samediAmStart = $_POST['samedi_am_start_1'];

                            $samediAmEnd = $_POST['samedi_am_end_1'];

                        }

                        if($_POST['samedi_pm_on_rdv'] == 1){

                            $samediPmStart = -1;

                            $samediPmEnd = -1;

                        }else{

                            $samediPmStart = $_POST['samedi_pm_start_1'];

                            $samediPmEnd = $_POST['samedi_pm_end_1'];

                        }

                    }

                }

            }



            if ($_POST['dimanche_is_open'] == 0){

                $dimancheAmStart   = 0;

                $dimancheAmEnd     = 0;

                $dimanchePmStart   = 0;

                $dimanchePmEnd     = 0;

            }else {

                if ($_POST['dimanche_is_open'] == 2) {

                    $dimancheAmStart = -1;

                    $dimancheAmEnd = -1;

                    $dimanchePmStart = -1;

                    $dimanchePmEnd = -1;

                }else{

                    if ($_POST['dimanche_has_lunch'] == 0) {

                        $dimancheAmStart = $_POST['dimanche_am_start_0'];

                        $dimancheAmEnd = -3;

                        $dimanchePmStart = -3;

                        $dimanchePmEnd = $_POST['dimanche_pm_end_0'];

                    }else{

                        if($_POST['dimanche_am_on_rdv'] == 1){

                            $dimancheAmStart = -1;

                            $dimancheAmEnd = -1;

                        }else{

                            $dimancheAmStart = $_POST['dimanche_am_start_1'];

                            $dimancheAmEnd = $_POST['dimanche_am_end_1'];

                        }

                        if($_POST['dimanche_pm_on_rdv'] == 1){

                            $dimanchePmStart = -1;

                            $dimanchePmEnd = -1;

                        }else{

                            $dimanchePmStart = $_POST['dimanche_pm_start_1'];

                            $dimanchePmEnd = $_POST['dimanche_pm_end_1'];

                        }

                    }

                }

            }



            $agency->setMonday_am_start($lundiAmStart);

            $agency->setMonday_am_end  ($lundiAmEnd);

            $agency->setMonday_pm_start($lundiPmStart);

            $agency->setMonday_pm_end  ($lundiPmEnd);



            $agency->setThuesday_am_start($mardiAmStart);

            $agency->setThuesday_am_end  ($mardiAmEnd);

            $agency->setThuesday_pm_start($mardiPmStart);

            $agency->setThuesday_pm_end  ($mardiPmEnd);



            $agency->setThursday_am_start($mercrediAmStart);

            $agency->setThursday_am_end  ($mercrediAmEnd);

            $agency->setThursday_pm_start($mercrediPmStart);

            $agency->setThursday_pm_end  ($mercrediPmEnd);



            $agency->setWednesday_am_start($jeudiAmStart);

            $agency->setWednesday_am_end  ($jeudiAmEnd);

            $agency->setWednesday_pm_start($jeudiPmStart);

            $agency->setWednesday_pm_end  ($jeudiPmEnd);



            $agency->setFriday_am_start($vendrediAmStart);

            $agency->setFriday_am_end  ($vendrediAmEnd);

            $agency->setFriday_pm_start($vendrediPmStart);

            $agency->setFriday_pm_end  ($vendrediPmEnd);



            $agency->setSaturday_am_start($samediAmStart);

            $agency->setSaturday_am_end  ($samediAmEnd);

            $agency->setSaturday_pm_start($samediPmStart);

            $agency->setSaturday_pm_end  ($samediPmEnd);



            $agency->setSunday_am_start($dimancheAmStart);

            $agency->setSunday_am_end  ($dimancheAmEnd);

            $agency->setSunday_pm_start($dimanchePmStart);

            $agency->setSunday_pm_end  ($dimanchePmEnd);



            var_dump($agency); return;



            try{



                $agency->save();

/*              var_dump($agency);

                var_dump(basename($_FILES['logo']['name']));*/

                $this->view->message = "success";

            }catch(\Exception $e){

                $this->view->message = $e->getMessage();

            }



        }

    }



    public function insertAction(){

        $this->enableLayout()->setLayout('empty');

        $uid = $this->getParam("uid");



        $this->view->headScript()->appendFile('/pimcore/static/js/lib/ckeditor/ckeditor.js');



        if (!empty($uid)) $this->view->agency = \Website\Model\Agency::getByUid($uid);

    }



    public function whiseAction(){





        $rh = new RequestHeader();

        $rh->Password = new \SoapVar('qpz45$e', XSD_STRING);

        $rh->Login = new \SoapVar('realadvice', XSD_STRING);



        $client = new WhomanMediaService();



        $paramters = new GetOfficesPaging();

        $paramters->header = $rh;



        $r = $client->GetOfficesPaging($paramters);



        //var_dump($r->GetOfficesPagingResult->Offices->OfficeData);

        $this->view->offices = $r->GetOfficesPagingResult->Offices->OfficeData;



    }



    public function insertFreemiumAction()

    {

        $this->enableLayout()->setLayout('empty');



        if(!$this->_request->isPost()) {

            $this->view->showForm = true;

            return;

        }



        $agency = new Website\Model\Agency();



        $uid=\Website\Tool\RealAdvice::generateUid();





        $agency->setId($this->getParam('id'));

        $agency->setUid($uid);



        $agency->setName($this->getParam('name'));

        $agency->setPhone($this->getParam('phone'));

        $agency->setEmail($this->getParam('email'));

        $agency->setAddress($this->getParam('address'));

        $agency->setCp($this->getParam('cp'));



        $agency->setShort_description_fr($this->getParam('short_description_fr'));



        $agency->setShort_description_nl($this->getParam('short_description_nl'));



        $agency->setWebsite($this->getParam('website'));



        $agency->setSeerus_key($this->getParam('seerus_key'));

        $agency->setSeerus_secret($this->getParam('seerus_secret'));

        $agency->setDashboard_token($this->getParam('seerus_token'));

        $agency->setSeerus_custom_url($this->getParam('custom_url'));



        try{

            $auth = \Website\Model\Auth::create(array(

                'name' => 'freemium',

                'surname' => 'freemium',

                'email' => $this->getParam('login'),

                'password' => $this->getParam('pwd')

            ));



            $auth->setAgency_uid($uid);

            $auth->save();



            $agency->save();



            $uploaddir = $_SERVER['DOCUMENT_ROOT'] . '/upload/' . $agency->getUid() . '/' ;



            if (!file_exists($uploaddir))

                mkdir($uploaddir, 0777, true);



            foreach($_FILES as $file)

                if(move_uploaded_file($file['tmp_name'], $uploaddir . 'logo.png'))

                    $files[] = $uploaddir .$file['name'];



            return $this->_helper->json(array("success" => true, "message" => ''));

        }catch(\Exception $e){

            return $this->_helper->json(array("success" => false, "message" => $e->getMessage()));

        }



    }



}