<!-- Content Header (Page header) -->
<section class="content-header">
	<div class="container-fluid">
		<div class="row mb-2">
			<div class="col-sm-6">
				<h1 class="m-0">Chart of Accounts</h1>
			</div>

			<div class="col-sm-6">
				<ol class="breadcrumb float-sm-right">
					<li class="breadcrumb-item"><a href="dashboard">Dashboard</a></li>
					<li class="breadcrumb-item"><a href="accounts">Accounts</a></li>
					<li class="breadcrumb-item active"><?php if ( count( $chart ) > 0 ): ?>Edit<?php else: ?>Add New<?php endif;?> Chart of Account</li>
				</ol>
			</div>
		</div>
	</div>
</section>

<!-- Main content -->
<section class="content">
	<div class="container-fluid">
		<!-- Small boxes (Stat box) -->
		<div class="row">
			<div class="col-md-12">
				<form id="frmChartSave" action="accounts/chart-save" method="post">
					<div class="card card-primary">
						<div class="card-header">
							<h3 class="card-title"><?php if ( count( $chart ) > 0 ): ?>Edit<?php else: ?>Add New<?php endif;?> Chart of Account</h3>
						</div>

						<div class="card-body">
							<div class="row">
								<div class="col-md-6">
									<div class="form-group">
										<label for="parent_id">Under Account of</label>
										<select name="parent_id" id="parent_id" class="form-control select2">
											<option value="">Root</option>
											<?php echo $ac_chart_tree; ?>
										</select>
									</div>
									<div class="form-group">
										<label for="code">Account Code</label>
										<input type="text" name="code" id="code" class="form-control" placeholder="Enter Account Code ..." value="<?php if ( count( $chart ) > 0 ): echo $chart['code'];endif;?>">
									</div>
									<div class="form-group">
										<label for="name">Account Name</label>
										<input type="text" name="name" id="name" class="form-control" placeholder="Enter Account Name ..."  value="<?php if ( count( $chart ) > 0 ): echo $chart['name'];endif;?>">
									</div>
								</div>

								<div class="col-md-6">
									<div class="form-group">
										<label for="opening">Opening Balance</label>
										<input type="text" name="opening" id="opening" class="form-control" placeholder="Enter Opening Balance ..." value="<?php if ( count( $chart ) > 0 ): echo $chart['opening'];endif;?>">
									</div>
									<div class="form-group">
										<label for="memo">Memo</label>
										<textarea name="memo" id="memo" class="form-control" placeholder="Enter Memo..." ><?php if ( count( $chart ) > 0 ): echo $chart['memo'];endif;?></textarea>
									</div>
								</div>
							</div>
						</div>

						<input type="hidden" name="<?php echo $this->security->get_csrf_token_name(); ?>" value="<?php echo $this->security->get_csrf_hash(); ?>">
						<?php if ( count( $chart ) > 0 ): ?>
							<input type="hidden" name="id" value="<?php echo $chart['id']; ?>">
						<?php endif;?>

						<div class="card-footer">
							<input type="submit" class="btn bg-gradient-primary" value="Save Changes">
							<input type="reset" class="btn bg-gradient-danger" value="Cancel">
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</section>