<!-- 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">Default Chart of Account Settings</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="settings">Settings</a></li>
					<li class="breadcrumb-item"><a href="settings/chart-list">Default Chart of Account</a></li>
					<li class="breadcrumb-item active"><?php if ( count( $chart ) > 0 ): ?>Edit<?php else: ?>Add New<?php endif;?> Default 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 action="settings/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;?> Default 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="type">Account Class</label>
										<select name="type" id="type" class="form-control select2">
											<option value="">Default</option>
											<option value="Receivable" <?php if ( count( $chart ) > 0 && $chart['type'] == 'Receivable' ) {echo 'selected';}?>>Receivable</option>
											<option value="Payable" <?php if ( count( $chart ) > 0 && $chart['type'] == 'Payable' ) {echo 'selected';}?>>Payable</option>
											<option value="Cash" <?php if ( count( $chart ) > 0 && $chart['type'] == 'Cash' ) {echo 'selected';}?>>Cash</option>
											<option value="Bank" <?php if ( count( $chart ) > 0 && $chart['type'] == 'Bank' ) {echo 'selected';}?>>Bank</option>
											<option value="Sales" <?php if ( count( $chart ) > 0 && $chart['type'] == 'Sales' ) {echo 'selected';}?>>Sales</option>
											<option value="Purchase" <?php if ( count( $chart ) > 0 && $chart['type'] == 'Purchase' ) {echo 'selected';}?>>Purchase</option>
											<option value="Inventory" <?php if ( count( $chart ) > 0 && $chart['type'] == 'Inventory' ) {echo 'selected';}?>>Inventory</option>
											<option value="COGS" <?php if ( count( $chart ) > 0 && $chart['type'] == 'COGS' ) {echo 'selected';}?>>Cost of Goods Sold</option>
										</select>
									</div>
								</div>

								<div class="col-md-6">
									<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'];}?>">
									</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'];}?>">
									</div>
									<div class="form-group">
										<label for="memo">Memo</label>
										<textarea name="memo" id="notes" class="form-control" placeholder="Enter Memo..."><?php if ( count( $chart ) > 0 ) {echo $chart['memo'];}?></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>