<?php
/**
 * This is a core PHP file. For customization, create a file in the folder /custom/.
 * Files with the same filename in this folder will automatically be loaded instead of the current file
 */

if(isset($service) && in_array(Settings_Model::get('CLIENTAREA_SERVICE_TERMINATE'), array('yes', 'approve'), TRUE))
{
	// show terminate button
	if(!isset($service->Termination))
	{
		?>

		<a href="#" class="h1-small pull-xs-right hidden-xs-down" data-toggle="modal" data-target="#terminate-subscription" data-backdrop="static">
			<?php echo __('terminate subscription'); ?>
		</a>

		<!-- Modal -->
		<div class="modal fade" id="terminate-subscription" tabindex="-1" role="dialog" aria-labelledby="terminate-subscription" aria-hidden="true">
			<div class="modal-dialog" role="form">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-label="Close">
							<span aria-hidden="true">&times;</span>
						</button>
						<h4 class="modal-title">
							<?php echo __('terminate subscription?'); ?>
						</h4>
					</div>

					<?php
					if (isset($message))
					{
						echo $message;
						unset($message);
					}
					?>

					<form id="form-terminate-subscription" class="" method="post" action="<?php echo __SITE_URL . '/' . $ServiceUrlString . '/'. __('terminate', 'url'); ?>">

						<input type="hidden" name="ServiceID" value="<?php echo $service->id; ?>" />
						<input type="hidden" name="ServiceType" value="<?php echo $servicetype; ?>" />

						<div class="modal-body">
							<?php echo sprintf(__('terminate subscription are you sure'), rewrite_date_db2site($service->Subscription['ContractTerminationDate'])); ?>
							<br /><br />

							<div class="form-group row">
								<label class="col-sm-4 form-control-label"><?php echo __('terminate reason'); ?></label>
								<div class="col-sm-7">
									<textarea class="form-control autogrow" name="Reason"><?php if(isset($service->Reason)){ echo normalize($service->Reason); } ?></textarea>
								</div>
							</div>

							<div class="form-group row">
								<label class="col-sm-4 form-control-label"><?php echo __('password'); ?></label>
								<div class="col-sm-7">
									<input class="form-control" type="password" name="Password" value="" autocomplete="off">
								</div>
							</div>


						</div>
						<div class="modal-footer">
							<button type="button" class="btn btn-secondary pull-left" data-dismiss="modal"><?php echo __('cancel'); ?></button>
							<button type="submit" class="btn btn-danger"><?php echo __('terminate'); ?></button>
						</div>

					</form>

					<?php validate_input($service->ErrorFields); ?>

				</div>
			</div>
		</div>
		<?php
	}
}