<?php echo $this->partial('Layout/nav'); ?>

<div class="container">
	<div class="container-page-wrapper">
		<div class="container-page-container shodowed bordered">
			
			<?php //debug($this->user->getUser()); ?>
			
			<h1><?php echo $this->actionTitle; ?></h1>
			<hr>
			<h4 class="text-center"><?php echo _('Personal information'); ?></h4>
			<?php echo $this->partial('User/profile-summary', ['showBottomLink'=>false]); ?>
			<form id="profile-form-edit">
				<div class="form-row">
					
					<div class="form-group col-lg-6">
						<label for="profile_passwd1" class="label-main"><?php echo _('Password'); ?></label>
						<input type="password" class="form-control field-passwd1" value="" id="profile_passwd1" name="data[profile_passwd1][value]">
						<small class="form-text text-muted"><?php echo _('Provide a new password to change the current one.'); ?></small>
						
						<input type="hidden" name="data[profile_passwd1][required]" value="0">
						<input type="hidden" name="data[profile_passwd1][type]" value="password1">
						<input type="hidden" name="data[profile_passwd1][class]" value="field-passwd1">
						<input type="hidden" name="data[profile_passwd1][label]" value="<?php echo _('Password'); ?>">
					</div>
					
					<div class="form-group col-lg-6">
						<label for="profile_passwd2" class="label-main"><?php echo _('Confirm password'); ?></label>
						<input type="password" class="form-control field-passwd2" value="" id="profile_passwd2" name="data[profile_passwd2][value]">
						
						<input type="hidden" name="data[profile_passwd2][required]" value="0">
						<input type="hidden" name="data[profile_passwd2][type]" value="password2">
						<input type="hidden" name="data[profile_passwd2][class]" value="field-passwd2">
						<input type="hidden" name="data[profile_passwd2][label]" value="<?php echo _('Confirm password'); ?>">
					</div>
					
					<div class="form-group col-lg-12">
						<hr>
					</div>
					
					<div class="form-group col-lg-6">
						<label for="profile_default_lang" class="label-main"><?php echo _('First language'); ?></label>
						<select class="form-control" id="profile_default_lang" name="data[default_lang][value]">
							<?php foreach($this->view->languageList as $language): ?>
								<option value="<?php echo $language['lang_code']; ?>" <?php echo $language['selected'] ? 'selected': ''; ?>><?php echo $language['name_string']; ?></option>
							<?php endforeach; ?>
						</select>
					</div>
					
					<div class="form-group col-lg-6">
						<label for="profile_default_lang" class="label-main"><?php echo _('Alternative languages'); ?></label>
						<div>
							<?php foreach($this->view->alternativeLanguages as $index => $language): ?>
									<div class="form-check form-check-inline">
										<input class="form-check-input" type="checkbox" id="alt-lang-<?php echo $index; ?>" value="<?php echo $language['lang_code']; ?>" <?php echo $language['checked'] ? 'checked' : ''; ?> name="data[alt_langs][value][<?php echo $language['id']; ?>]">
										<label class="form-check-label" for="alt-lang-<?php echo $index; ?>"><?php echo $language['name_string']; ?></label>
									</div>
							<?php endforeach; ?>
						</div>
					</div>
					
					<div class="form-group col-md-12">
						<label class="label-main" for="user_country"><?php echo _('Country'); ?></label>
						
						<select class="form-control field-country chosen-select" name="data[country][value]" id="user_country">
							<option value="">...</option>
							<?php if(is_array($this->view->countries)): ?>
								<?php foreach($this->view->countries as $country): ?>
									<option value="<?php echo $country['country_iso2_code']; ?>" <?php echo $country['selected'] ? 'selected' : ''; ?>><?php echo $country['country_name']; ?></option>
								<?php endforeach; ?>
							<?php endif; ?>
						</select>
						
						<input type="hidden" name="data[country][required]" value="1">
						<input type="hidden" name="data[country][type]" value="text">
						<input type="hidden" name="data[country][class]" value="field-country">
						<input type="hidden" name="data[country][label]" value="<?php echo _('Country'); ?>">
					</div>
					
					<div class="form-group col-lg-12">
						<hr>
					</div>
					
					<div class="row col-lg-12">
						<div class="col-md-2 text-center">

							
							<?php echo $this->helper->setAvatarView($this->view->userAvatar, ['timestamp'=>md5($this->view->userUpdatedAt), 'class'=>'edit-avatar']); ?>
						</div>
						
						<div class="col-md-10">
							<?php echo $this->partial('User/avatar'); ?>
						</div>
					</div>
					
					<div class="form-group col-lg-12">
						<hr>
					</div>
					
					<div class="form-group col-lg-12">
						<label for="profile_passwd1"><?php echo _('Remarks'); ?></label>
						<textarea rows="4" class="form-control field-remarks" id="profile_remarks" name="data[public_remarks][value]"><?php echo $this->view->userRemarks; ?></textarea>
						
						<input type="hidden" name="data[public_remarks][required]" value="0">
						<input type="hidden" name="data[public_remarks][type]" value="text">
						<input type="hidden" name="data[public_remarks][class]" value="field-remarks">
						<input type="hidden" name="data[public_remarks][label]" value="<?php echo _('Remarks'); ?>">
					</div>
					
					<div class="form-group col-lg-12">
						<hr>
						<h4 class="text-center"><?php echo _('Contact preferences'); ?></h4>
						<hr>
					</div>
					
					<div class="form-group col-lg-12">
						<label for="profile_email" class="label-main"><?php echo _('E-mail'); ?></label>
						<input type="email" class="form-control field-email" value="<?php echo $this->view->userEmail; ?>" id="profile_email" name="data[email][value]">
						
						<input type="hidden" name="data[email][required]" value="1">
						<input type="hidden" name="data[email][type]" value="email">
						<input type="hidden" name="data[email][class]" value="field-email">
						<input type="hidden" name="data[email][label]" value="<?php echo _('E-mail'); ?>">
					</div>
					
					<?php /*
					<div class="form-group col-lg-6">
						<label for="profile_alt_email" class="label-main"><?php echo _('Alternative e-mail'); ?></label>
						<input type="email" class="form-control field-alt-email" value="<?php echo $this->view->userAltEmail; ?>" id="profile_alt_email" name="data[alt_email][value]">
						
						<input type="hidden" name="data[alt_email][required]" value="0">
						<input type="hidden" name="data[alt_email][type]" value="email">
						<input type="hidden" name="data[alt_email][class]" value="field-alt-email">
						<input type="hidden" name="data[alt_email][label]" value="<?php echo _('Alternative e-mail'); ?>">
					</div>
					*/ ?>
					
					<div class="form-group col-lg-6">
						<label for="profile_default_mobile" class="label-main"><?php echo _('Mobile (All communications)'); ?></label>
						<input type="tel" class="form-control field-mobile-default" value="<?php echo $this->view->userMobNumber; ?>" id="profile_default_mobile" name="data[default_mobile][value]">
						<small class="text-muted"><?php echo _('With international code without + or 00.'); ?></small>
						
						<input type="hidden" name="data[default_mobile][required]" value="1">
						<input type="hidden" name="data[default_mobile][type]" value="text">
						<input type="hidden" name="data[default_mobile][class]" value="field-mobile-default">
						<input type="hidden" name="data[default_mobile][label]" value="<?php echo _('Mobile (All communications)'); ?>">
					</div>
					
					<div class="form-group col-lg-6">
						<label for="profile_mobile_chat" class="label-main"><?php echo _('Mobile (Preferred for WhatsApp)'); ?></label>
						<input type="tel" class="form-control field-mobile-chat" value="<?php echo $this->view->userMobWA; ?>" id="profile_mobile_chat" name="data[mobile_chat][value]">
						<small class="text-muted"><?php echo _('With international code without + or 00.'); ?></small>
						
						<input type="hidden" name="data[mobile_chat][required]" value="0">
						<input type="hidden" name="data[mobile_chat][type]" value="text">
						<input type="hidden" name="data[mobile_chat][class]" value="field-mobile-chat">
						<input type="hidden" name="data[mobile_chat][label]" value="<?php echo _('Mobile (Preferred for WhatsApp)'); ?>">
					</div>
					
					<div class="form-group col-lg-6">
						<label for="profile_default_lang" class="label-main"><?php echo _('Communication preferences'); ?></label>
						<div>
							<div class="form-check form-check-inline">
								<input type="hidden" name="data[phone_pref][value]" value="1">
								<input class="form-check-input" type="checkbox" id="phone_pref" name="data[phone_pref][value]" value="0" <?php echo (int)$this->view->userPhoneText == 0 ? 'checked' : ''; ?>>
								<label class="form-check-label" for="phone_pref"><?php echo _('Do not send SMS/Text by phone'); ?></label>
							</div>
							
							<div class="form-check form-check-inline">
								<input type="hidden" name="data[wa_pref][value]" value="1">
								<input class="form-check-input" type="checkbox" id="wa_pref" name="data[wa_pref][value]" value="0" <?php echo (int)$this->view->userPhoneChat == 0 ? 'checked' : ''; ?>>
								<label class="form-check-label" for="wa_pref"><?php echo _('Do not send messages by WhatsApp'); ?></label>
							</div>
							
							<div class="form-check form-check-inline">
								<input type="hidden" name="data[wa_email][value]" value="1">
								<input class="form-check-input" type="checkbox" id="wa_email" name="data[wa_email][value]" value="0" <?php echo (int)$this->view->userEmailMsgs == 0 ? 'checked' : ''; ?>>
								<label class="form-check-label" for="wa_email"><?php echo _('Do not send messages by e-mail'); ?></label>
							</div>
						</div>
					</div>
					
					<div class="form-group col-lg-12">
						<hr>
					</div>
					
					<div class="clearfix col-lg-12">
						<button type="button" class="btn btn-primary btn-edit-profile float-right"><?php echo _('Save'); ?></button>
					</div>
				
				</div>
			</form>
			<?php 
				//debug($this->view->roles, true);
			?>
		</div>
	</div>
</div>