<?php
if (isset($tpl['status']))
{
	$status = __('status', true);
	switch ($tpl['status'])
	{
		case 2:
			pjUtil::printNotice(NULL, $status[2]);
			break;
	}
} else {
	$week_start = isset($tpl['option_arr']['o_week_start']) && in_array((int) $tpl['option_arr']['o_week_start'], range(0,6)) ? (int) $tpl['option_arr']['o_week_start'] : 0;
	$jqDateFormat = pjUtil::jqDateFormat($tpl['option_arr']['o_date_format']);
	pjUtil::printNotice(__('infoUpdateClientTitle', true, false), __('infoUpdateClientDesc', true, false));
	?>
	
	<form action="<?php echo $_SERVER['PHP_SELF']; ?>?controller=pjAdminClients&amp;action=pjActionUpdate" method="post" id="frmUpdateClient" class="form pj-form">
		<input type="hidden" name="client_update" value="1" />
		<input type="hidden" name="csrf_token" value="<?php echo pjAppController::getCsrfToken(); ?>" />
		<input type="hidden" name="id" value="<?php echo $tpl['arr']['id']; ?>" />
		<input type="hidden" name="old_status" value="<?php echo $tpl['arr']['status']; ?>" />
		<?php $locale = isset($_GET['locale']) && (int) $_GET['locale'] > 0 ? (int) $_GET['locale'] : @$tpl['lp_arr'][0]['id']; ?>
		<div class="clear_both">
			<?php
			if(!empty($tpl['arr']['last_reply']))
			{ 
				?>
				<p>
					<label class="title"><?php __('menuTickets'); ?></label>
					<span class="inline_block">
						<label class="block t5"><a href="<?php echo $_SERVER['PHP_SELF']?>?controller=pjAdminTickets&action=pjActionIndex&client_id=<?php echo $tpl['arr']['id']; ?>"><?php echo $tpl['cnt_tickets']; ?></a>&nbsp;&nbsp;/&nbsp;&nbsp;<?php echo mb_strtolower(__('lblLastReply', true), 'UTF-8')?>&nbsp;&nbsp;<?php echo date($tpl['option_arr']['o_date_format'], strtotime($tpl['arr']['last_reply'])) . ', ' . date($tpl['option_arr']['o_time_format'], strtotime($tpl['arr']['last_reply']))?>&nbsp;&nbsp;<?php echo mb_strtolower(__('lblTicket', true), 'UTF-8')?>&nbsp;&nbsp;<a href="<?php echo $_SERVER['PHP_SELF']; ?>?controller=pjAdminTickets&amp;action=pjActionUpdate&amp;id=<?php echo $tpl['arr']['tkid'];?>"><?php echo $tpl['arr']['ticket_id'];?></a></label>
					</span>
				</p>
				<?php
			}else{
				?>
				<p>
					<label class="title"><?php __('menuTickets'); ?></label>
					<span class="inline_block">
						<label class="block t5"><a href="<?php echo $_SERVER['PHP_SELF']?>?controller=pjAdminTickets&action=pjActionIndex&client_id=<?php echo $tpl['arr']['id']; ?>"><?php echo $tpl['cnt_tickets']; ?></a></label>
					</span>
				</p>
				<?php
			} 
			?>
			<p>
				<label class="title"><?php __('lblLastLogin'); ?></label>
				<span class="inline_block">
					<?php
					if(!empty($tpl['arr']['last_login']))
					{ 
						?>
						<label class="block t5"><?php echo date($tpl['option_arr']['o_date_format'], strtotime($tpl['arr']['last_login'])) . ', ' . date($tpl['option_arr']['o_time_format'], strtotime($tpl['arr']['last_login'])); ?></label>
						<?php
					}else{
						?>
						<label class="block t5"><?php __('lblNA');?></label>
						<?php
					} 
					?>
				</span>
			</p>
			<p>
				<label class="title"><?php __('lblName'); ?></label>
				<span class="inline_block">
					<input type="text" name="name" id="name" class="pj-form-field w250 required" value="<?php echo pjSanitize::html($tpl['arr']['name']); ?>" />
				</span>
			</p>
			<p>
				<label class="title"><?php __('lblEmail'); ?></label>
				<span class="pj-form-field-custom pj-form-field-custom-before">
					<span class="pj-form-field-before"><abbr class="pj-form-field-icon-email"></abbr></span>
					<input type="text" name="email" id="email" class="pj-form-field required email w200" value="<?php echo pjSanitize::html($tpl['arr']['email']); ?>"  />
				</span>
			</p>
			<p>
				<label class="title"><?php __('lblPass'); ?></label>
				<span class="pj-form-field-custom pj-form-field-custom-before">
					<span class="pj-form-field-before"><abbr class="pj-form-field-icon-password"></abbr></span>
					<input type="password" name="password" id="password" class="pj-form-field required w200" value="<?php echo pjSanitize::html($tpl['arr']['password']); ?>"/>
				</span>
			</p>
			<p>
				<label class="title"><?php __('lblClientWebsite'); ?></label>
				<span class="pj-form-field-custom pj-form-field-custom-before">
					<span class="pj-form-field-before"><abbr class="pj-form-field-icon-url"></abbr></span>
					<input type="text" name="website" id="website" class="pj-form-field w200" placeholder="www.domain.com" value="<?php echo pjSanitize::html($tpl['arr']['website']); ?>"  />
				</span>
			</p>
			<p>
				<label class="title"><?php __('lblClientSince'); ?></label>
				<span class="pj-form-field-custom pj-form-field-custom-after">
					<input type="text" name="client_since" id="client_since" class="pj-form-field pointer w80 datepick" value="<?php echo pjUtil::formatDate($tpl['arr']['client_since'], "Y-m-d", $tpl['option_arr']['o_date_format']); ?>"  readonly="readonly" rel="<?php echo $week_start; ?>" rev="<?php echo $jqDateFormat; ?>" />
					<span class="pj-form-field-after"><abbr class="pj-form-field-icon-date"></abbr></span>
				</span>
			</p>
			<p style="overflow: visible">
				<label class="title"><?php __('lblClientCountry'); ?></label>
				<span class="inline_block" id="boxCountry">
					<select name="country_id" id="country_id" class="pj-form-field w400">
						<option value="">-- <?php __('lblChoose'); ?> --</option>
						<?php
						foreach ($tpl['country_arr'] as $v)
						{
							if($v['id'] == $tpl['arr']['country_id'])
							{
							    ?><option value="<?php echo $v['id']; ?>" selected="selected"><?php echo pjSanitize::html($v['name']); ?></option><?php
							}else{
							    ?><option value="<?php echo $v['id']; ?>"><?php echo pjSanitize::html($v['name']); ?></option><?php
							}
						}
						?>
					</select>
				</span>
			</p>
			<p>
				<label class="title"><?php __('lblClientState'); ?></label>
				<span class="inline_block">
					<input type="text" name="state" id="state" class="pj-form-field w250" value="<?php echo pjSanitize::html($tpl['arr']['state']); ?>" />
				</span>
			</p>
			<p>
				<label class="title"><?php __('lblClientCity'); ?></label>
				<span class="inline_block">
					<input type="text" name="city" id="city" class="pj-form-field w250" value="<?php echo pjSanitize::html($tpl['arr']['city']); ?>" />
				</span>
			</p>
			<p>
				<label class="title"><?php __('lblClientAddress'); ?></label>
				<span class="inline_block">
					<input type="text" name="address" id="address" class="pj-form-field w400" value="<?php echo pjSanitize::html($tpl['arr']['address']); ?>" />
				</span>
			</p>
			<p>
				<label class="title"><?php __('lblClientPhone'); ?></label>
				<span class="pj-form-field-custom pj-form-field-custom-before">
					<span class="pj-form-field-before"><abbr class="pj-form-field-icon-phone"></abbr></span>
					<input type="text" name="phone" id="phone" class="pj-form-field w150" placeholder="(123) 456-7890" value="<?php echo pjSanitize::html($tpl['arr']['phone']); ?>" />
				</span>
			</p>
			<p>
				<label class="title"><?php __('lblClientMobile'); ?></label>
				<span class="pj-form-field-custom pj-form-field-custom-before">
					<span class="pj-form-field-before"><abbr class="pj-form-field-icon-phone"></abbr></span>
					<input type="text" name="cell_phone" id="cell_phone" class="pj-form-field w150" placeholder="(123) 456-7890" value="<?php echo pjSanitize::html($tpl['arr']['cell_phone']); ?>" />
				</span>
			</p>
			<p>
				<label class="title"><?php __('lblClientFax'); ?></label>
				<span class="pj-form-field-custom pj-form-field-custom-before">
					<span class="pj-form-field-before"><abbr class="pj-form-field-icon-phone"></abbr></span>
					<input type="text" name="fax" id="fax" class="pj-form-field w150" placeholder="(123) 456-7890" value="<?php echo pjSanitize::html($tpl['arr']['fax']); ?>" />
				</span>
			</p>
			<p>
				<label class="title"><?php __('lblClientNotes'); ?></label>
				<span class="inline_block">
					<textarea name="notes" class="pj-form-field w500 h80"><?php echo pjSanitize::html($tpl['arr']['notes']); ?></textarea>
				</span>
			</p>
			<p>
				<label class="title"><?php __('lblStatus'); ?></label>
				<span class="inline_block">
					<select name="status" id="status" class="pj-form-field required">
						<option value="">-- <?php __('lblChoose'); ?>--</option>
						<?php
						foreach (__('u_statarr', true) as $k => $v)
						{
							?><option value="<?php echo $k; ?>"<?php echo $k == $tpl['arr']['status'] ? ' selected="selected"' : NULL; ?>><?php echo $v; ?></option><?php
						}
						?>
					</select>
				</span>
			</p>
			
			
			<p>
				<label class="title">&nbsp;</label>
				<input type="submit" value="<?php __('btnSave'); ?>" class="pj-button" />
				<input type="button" value="<?php __('btnCancel'); ?>" class="pj-button" onclick="window.location.href='<?php echo PJ_INSTALL_URL; ?>index.php?controller=pjAdminClients&action=pjActionIndex';" />
			</p>
		</div>
	</form>
	
	<div id="dialogMessage" title="<?php __('changeStatusTitle'); ?>" style="display: none"></div>
	
	<script type="text/javascript">
	var myLabel = myLabel || {};
	myLabel.email_taken = "<?php __('ts_email_taken'); ?>";
	myLabel.field_required = "<?php __('ts_field_required'); ?>";
	myLabel.email_invalid = "<?php __('ts_email_invalid'); ?>";
	myLabel.btn_send = "<?php __('btnSend'); ?>";
	myLabel.btn_cancel = "<?php __('btnCancel'); ?>";
	</script>
	<?php
}
?>