BBnepal-Accounts/account/application/views/accounts/accountheads/edit.php
2024-08-08 12:16:46 +05:45

251 lines
14 KiB
PHP

<div class="content-wrapper">
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col">
<div class="card card-primary card-outline">
<div class="card-header">
<h5 class="m-0">Edit <?php echo $pageTitle; ?> <a href="<?php echo site_url("accounts/accountheads/list"); ?>" class="btn btn-sm btn-primary float-right">List <?php echo $pageTitle; ?></a></h5>
</div>
<div class="card-body">
<?php $TableData = $Account ?>
<form method=POST action="" enctype="multipart/form-data" name="tbl_accounts">
<div class="row">
<!--COL START-->
<div class="col-10">
<div class="form-group">
<label for="account_name">Account Name</label><input type="text" class="form-control" id="account_name" value="<?php echo $TableData->account_name; ?>" name="account_name">
</div>
</div>
<div class="col-2">
<div class="form-group">
<label for="exampleInputFile">Upload Image</label>
<div class="input-group">
<div class="custom-file">
<input type="file" class="custom-file-input" id="exampleInputFile" name="account_image" value="<?php echo $TableData->account_image; ?>" onchange="previewImage(event)">
<label class="custom-file-label" for="exampleInputFile">Choose file</label>
</div>
</div>
</div>
</div>
<div class="col-7">
<div class="form-group">
<?php fillComboWithValue("accategory_id", "Under", "accategory_id", "tbl_accategories", "accategory_name", "accategory_id", $TableData->accategory_id, "", false, "status=1"); ?>
</div>
</div>
<!--COL END-->
<!--COL START-->
<!-- <div class="col-2">
<div class="form-group">
<label for="account_code">Account Code</label><input type="text" readonly class="form-control" id="account_code" value="<?php //echo $TableData->account_code;
?>" name="account_code">
</div>
</div> -->
<!--COL END-->
<!--COL START-->
<div class="col-2">
<div class="form-group"> <label for="opening_balance">Opening Balance</label><input type="text" class="form-control" id="opening_balance" value="<?php echo ($TableData->OpeningEntry) ? ((($TableData->OpeningEntry->dr) > 0) ? $TableData->OpeningEntry->dr : $TableData->OpeningEntry->cr) : ""; ?>" name="opening_balance"> </div>
</div>
<div class="col-1">
<div class="form-group"> <label for="opening_balance_drcr">Dr/Cr</label>
<select class="form-control" id="opening_balance_drcr" name="opening_balance_drcr" required>
<option value="DR" <?php echo ($TableData->OpeningEntry) ? ((($TableData->OpeningEntry->dr) != 0) ? "SELECTED" : "") : ""; ?>>Dr</option>
<option value="CR" <?php echo ($TableData->OpeningEntry) ? ((($TableData->OpeningEntry->cr) != 0) ? "SELECTED" : "") : ""; ?>>Cr</option>
</select>
</div>
</div>
<!--image display-->
<div class="col-2">
<img id="imagePreview" class="profile-user-img img-fluid " src="<?php echo isset($TableData->account_image) && $TableData->account_image ? base_url('uploads/' . $TableData->account_image) : base_url('/dist/img/user4-128x128.jpg'); ?>" alt="Account Image">
</div>
<!--image display end-->
<!--COL END-->
</div>
<?php
// Get the account category name
$category_name = getFieldfromValue("tbl_accategories", "accategory_name", "accategory_id", $TableData->accategory_id);
?>
<div id="creditorFields" style="display: none;">
<!-- <?php //if ($category_name == "Sundry Creditors" || $category_name == "Sundry Debtors") : ?> -->
<div class="row">
<!--COL START-->
<div class="col">
<div class="form-group">
<label for="account_partyname">Party Name</label><input type="text" class="form-control" id="account_partyname" value="<?php echo $TableData->account_partyname; ?>" name="account_partyname">
</div>
</div>
<!--COL END-->
<!--COL START-->
<div class="col">
<div class="form-group">
<label for="account_partyaddress">Party Address</label><input type="text" class="form-control" id="account_partyaddress" value="<?php echo $TableData->account_partyaddress; ?>" name="account_partyaddress">
</div>
</div>
<div class="col">
<div class="form-group">
<label for="account_partypan">PAN</label><input type="text" class="form-control" id="account_partypan" value="<?php echo $TableData->account_partypan; ?>" name="account_partypan">
</div>
</div>
<!--COL END-->
<!--COL START-->
<div class="col">
<div class="form-group">
<label for="account_partyemail">Party Email</label><input type="email" class="form-control" id="account_partyemail" value="<?php echo $TableData->account_partyemail; ?>" name="account_partyemail">
</div>
</div>
<!--COL END-->
</div>
<div class="row">
<!--COL START-->
<div class="col">
<div class="form-group">
<label for="account_partycontact">Party Contact</label><input type="text" class="form-control" id="account_partycontact" value="<?php echo $TableData->account_partycontact; ?>" name="account_partycontact">
</div>
</div>
<!--COL END-->
<!--COL START-->
<div class="col">
<div class="form-group">
<label for="account_partycontactperson">Contact Person</label><input type="text" class="form-control" id="account_partycontactperson" value="<?php echo $TableData->account_partycontactperson; ?>" name="account_partycontactperson">
</div>
</div>
<!--COL END-->
<!--COL START-->
<div class="col">
<div class="form-group">
<label for="account_partycontactpersoncontact">Contact Person Phone</label><input type="text" class="form-control" id="account_partycontactpersoncontact" value="<?php echo $TableData->account_partycontactpersoncontact; ?>" name="account_partycontactpersoncontact">
</div>
</div>
<!--COL END-->
</div>
<!-- <?php //endif; ?> -->
</div>
<div class="row" id="bankFields" >
<!-- <?php //if ($category_name == "Bank Account") : ?> -->
<!--COL START-->
<div class="col">
<div class="form-group">
<label for="account_bank">Account Bank</label><input type="text" class="form-control" id="account_bank" value="<?php echo $TableData->account_bank; ?>" name="account_bank">
</div>
</div>
<!--COL END-->
<!--COL START-->
<div class="col">
<div class="form-group">
<label for="account_number">Account Number</label><input type="text" class="form-control" id="account_number" value="<?php echo $TableData->account_number; ?>" name="account_number">
</div>
</div>
<!--COL END-->
<!--COL START-->
<div class="col">
<div class="form-group">
<label for="account_branch">Account Branch</label><input type="text" class="form-control" id="account_branch" value="<?php echo $TableData->account_branch; ?>" name="account_branch">
</div>
</div>
<!--COL END-->
<!-- <?php //endif; ?> -->
</div>
<div class="row">
<!--COL START-->
<div class="col">
<div class="form-group">
<label for="remarks">Remarks</label>
<textarea class="form-control" id="remarks" name="remarks"><?php echo $TableData->remarks; ?></textarea>
</div>
</div>
<!--COL END-->
</div>
<p align="right">
<button style="padding: 6px 24px; border-radius: 2px; border: 1px solid DodgerBlue" class="btn btn-default btn-sm">Reset</button> <button style="padding: 6px 24px; border-radius: 2px;" class="btn btn-primary btn-sm" type="submit" name="submit">Save</button>
</p>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
function previewImage(event) {
var reader = new FileReader();
reader.onload = function() {
var output = document.getElementById('imagePreview');
output.src = reader.result;
}
reader.readAsDataURL(event.target.files[0]);
}
</script>
<script>
$(document).ready(function() {
function updateFields() {
var category = $('#accategory_id').val(); // Assuming the category select field has this ID
if (category == 2) {
$('#bankFields').show();
$('#creditorFields').hide();
} else if (category == 4 || category == 30) {
$('#bankFields').hide();
$('#creditorFields').show();
} else {
$('#bankFields').hide();
$('#creditorFields').hide();
}
}
// On page load
updateFields();
// On category change
$('#accategory_id').change(function() {
updateFields();
});
});
</script>