BBnepal-Accounts/account/application/controllers/Ajax.php

906 lines
35 KiB
PHP
Raw Normal View History

2024-07-10 12:43:19 +00:00
<?php
class Ajax extends CI_Controller
{
function __construct()
{
parent::__construct();
$this->load->model('MUsers');
$this->load->helper("accounts");
checkLogin();
}
function deleteVoucher($voucher_id)
{
$this->myaccounts->deleteVoucher($voucher_id);
}
function getVoucherDetailsTable($voucher_id)
{
$VD = $this->db->where("voucher_id", $voucher_id)->get("tbl_voucherdetails")->result();
$html = "<table class='table table-bordered'>";
$html .= "<tr><th>Account</th><th>Narration</th><th>Dr</th><th>Cr</th></tr>";
foreach ($VD as $T) {
$html .= "<tr>";
$html .= "<td class='col-3'>" . getFieldfromValue("tbl_accounts", "account_name", "account_id", $T->account_id) . "</td>";
$html .= "<td>" . $T->narration . "</td>";
$html .= "<td class='col-2'>" . myCurrency($T->dr) . "</td>";
$html .= "<td class='col-2'>" . myCurrency($T->cr) . "</td>";
$html .= "</tr>";
}
$html .= "</table>";
echo $html;
}
function getAccountsTableByCategory($accategory_id)
{
$this->myaccounts->getAccountsTableByCategory($accategory_id);
}
function getAllAccountsTable()
{
$this->myaccounts->getAllAccountsTable();
}
function dragDrop()
{
}
function updatePrivilege($id)
{
$user = $this->MUsers->getUsers($id);
$privileges = (array) json_decode($user->user_privilege); ?>
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">Edit Privileges For <?php echo $user->user_name; ?> (<?php echo $user->user_email; ?>)</h4>
<button type="button" class="close" data-dismiss="modal">&times;</button>
</div>
<form action="<?php echo base_url('users/update/' . $user->user_id); ?>" method="post">
<!-- Modal body -->
<div class="modal-body">
<table class="table">
<?php
$controllers = $this->config->item('checkControllers');
foreach ($controllers as $controller) :
$val = 0;
if (!empty($privileges[$controller])) {
$val = $privileges[$controller];
}
changePrivilege($controller, $val);
endforeach;
?>
</table>
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button class="btn btn-danger" type="submit">Update</button>
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</form>
</div>
</div>
<?php
}
function changePassword($id)
{
$inputArray = array(
'user_password' => $_POST['password'],
);
$this->MUsers->UpdateUser($inputArray, $id);
}
function changePrivilege($name, $value)
{
?>
<tr>
<td style="text-transform: capitalize"><?php echo $name; ?></td>
<td><label><input type="checkbox" value="1" <?php if ($value >= 1) echo 'checked'; ?> name="<?php echo $name; ?>"> view</label></td>
<td><label><input type="checkbox" value="2" <?php if ($value >= 2) echo 'checked'; ?> name="<?php echo $name; ?>"> add/update</label></td>
<td><label><input type="checkbox" value="3" <?php if ($value >= 3) echo 'checked'; ?> name="<?php echo $name; ?>"> delete</label></td>
</tr>
<?php
}
function showpodetails($po_id)
{
$t = "select * from tbl_podetails where po_id=$po_id";
$PoDetails = $this->db->query($t)->result();
foreach ($PoDetails as $details) {
$details->item_name = $this->db->query("select * from tbl_items where item_id=$details->item_id")->row();
}
$t = "select * from tbl_po where po_id=$po_id";
$Po = $this->db->query($t)->row();
$vendor_name = $this->db->query("select * from tbl_vendors where vendor_id=$Po->vendor_id")->row();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>YR tyres invoice</title>
<link rel="stylesheet" href="<?php echo base_url(); ?>uploads/style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body>
<header class="tp-hdr-sec">
<div class="container">
<div class="row">
<div class="col-md-3 col-lg-3 algn-cntr">
<div class="logo-sec">
<img src="<?php echo base_url(); ?>uploads/logo.png" alt="Yr tyres">
</div>
</div>
<div class="col-md-5 col-lg-5">
<div class="yr-tpdetas">
<h1 class="yr0tryoe">Y.R TYRE</h1>
<h3>INDUSTRIES PVT. LTD.</h3>
<h4>Strength | Speed | Grip</h4>
</div>
</div>
<div class="col-md-4 col-lg-4">
<div class="rgt-sec_prt">
<ul>
<li><i class="fa fa-globe"></i> YR Estate bld, Thir Bam Sadak-5, Baluwatar, Kathmandu, Nepal</li>
<li><i class="fa fa-globe"></i> +977 1 4421615, 4421587</li>
<li><i class="fa fa-globe"></i> mail@yrtyres.com</li>
<li><i class="fa fa-globe"></i> www.yrtyres.com</li>
</ul>
</div>
</div>
</div>
</div>
</header>
<section class="purchs-ord">
<div class="container">
<div class="row">
<div class="col-12 purc-bgprt">
<span>Purchase Order</span>
</div>
<div class="col-lg-12 col-md-12 rgt-pt-20">
<label for="date">Date</label>
<input type="text" name="date" class="mb-10 inpt-wdt" value=" <?php echo $Po->po_date ?>"><br>
<label for="po">PO#</label>
<input type="text" name="po" class="inpt-wdt"><br>
</div>
</div>
</div>
</section>
<section class="vedr-sph">
<div class="container">
<div class="row">
<div class="col-lg-6 col-md-6">
<div class="wst-100-bg">
<span>VENDOR</span>
</div>
<ul class="ul_sec-prst">
<li>Qingdao Yonghe International Trade Co. Ltd. </li>
<li>NO.1275, WANGSHA ROAD, CHENGYANG DISTRICT, QINGDAO CITY, CHINA</li>
<li>yh@qdyhltd.com</li>
<li>+86-532- 86468187-0</li>
</ul>
</div>
<div class="col-lg-6 col-md-6">
<div class="wst-100-bg">
<span>SHIP TO</span>
</div>
<ul class="ul_sec-prst">
<li>Y. R. Tye Industries Pvt. Ltd. </li>
<li>YR Estate Building, Thirbam Sadak, Baluwatar-4, Kathmandu, Nepa</li>
<li>mail@yrtyres.com</li>
<li>+977-1-4421615, 4421587 </li>
</ul>
</div>
<div class="col-lg-12 col-md-12 txt-rgt-prt">
<p>VAT: 606532363</p>
<p>EXIM: 6065323630128NP</p>
</div>
</div>
</div>
</section>
<section class="upr_tbl-secprt">
<div class="container">
<div class="row">
<table class="tg">
<thead>
<tr>
<th class="tg-0pky">EQUISITIONER</th>
<th class="tg-0pky">SHIP VIA</th>
<th class="tg-0pky">Delivery To</th>
<th class="tg-0pky">SHIPPING TERMS</th>
<th class="tg-0pky">CUSTOM ENTRY POINT</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tg-0pky"> </td>
<td class="tg-0pky"></td>
<td class="tg-0pky">Chitwan, Nepal</td>
<td class="tg-0pky"></td>
<td class="tg-0pky">Tatopani-Nepal</td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
<section class="lwr_tbl-secprt">
<div class="container">
<div class="row">
<table class="tg">
<thead>
<tr>
<th class="tg-0pky">ITEMS #</th>
<th class="tg-0pky">DESCRIPTION</th>
<th class="tg-0pky">QTY</th>
<th class="tg-0pky">UNIT PRICE</th>
<th class="tg-0pky">TOTAL</th>
</tr>
</thead>
<tbody>
<?php $a = 0;
foreach ($PoDetails as $details) : $a++; ?>
<tr>
<td><?php echo $a; ?></td>
<td><?php echo $details->item_name->item_name; ?></td>
<td><?php echo $details->item_qty; ?></td>
<td>USD <?php echo $details->est_price; ?></td>
<?php $total[$a] = $details->item_qty * $details->est_price; ?>
<td>USD <?php echo $total[$a]; ?></td>
</tr>
<?php endforeach; ?>
<?php for ($x = $a; $x <= 9; $x++) { ?>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</section>
<section class="trms-cnd-ttl">
<div class="container">
<div class="row">
<div class="col-lg-6 col-md-6">
<div class="wst-100-bg">
<span>Terms: </span>
</div>
<div class="trsm-cnd_prt ttms-trs-1">
<ul>
<li>1. Payment Terms: 100% TT before dispatch. </li>
<li>2. Desired Dispatch period: 35 days from the date of PO
issued. </li>
</ul>
</div>
</div>
<div class="col-lg-6 col-md-6">
<div class="trsm-cnd_prt">
<ul>
<li><span>Subtotal:</span>
<p>USD <?php echo array_sum($total) ?></p>
</li>
<li><span>Discount:</span>
<p>USD 10.00</p>
</li>
<li><span>After dis:</span>
<p>USD 2,400.00</p>
</li>
<li><span>Tax:</span> </li>
<li><span> Net:</span>
<p>USD 2,400.00</p>
</li>
<li><span>In Words:</span>
<p>Two Thousand four hundred only.</p>
</li>
</ul>
</div>
</div>
</div>
</div>
</section>
<section class="end_secprt">
<div class="container">
<div class="sdr_cenr-tr">
<h5>For:</h5>
<ul>
<li>Y. R. Tyre Industries Pvt. Ltd.</li>
<li>Yugma Malla</li>
</ul>
</div>
<div class="lwr-rd-prt">
<div class="container">
<div class="row">
<div class="col-md-6 col-lg-6">
<p class="pb-0-p-prt">Factory Address: KALIKA MUNICIPALITY-8,
NEURENI CHITWAN, NEPAL</p>
</div>
<div class="col-md-6 col-lg-6">
<p class="pb-0-p-prt">Dedicated for Vehicle Tyre Manufacturing</p>
</div>
</div>
</div>
</div>
</div>
</section>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>
<?php
}
function showsodetails($so_id)
{
$t = "select * from tbl_salesorderdetails where salesorder_id=$so_id";
$SoDetails = $this->db->query($t)->result();
$t = "select * from tbl_salesorders where salesorder_id=$so_id";
$So = $this->db->query($t)->row();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Form</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<style type="text/css">
.tg {
border-collapse: collapse;
border-spacing: 0;
}
.tg td {
border-color: black;
border-style: solid;
border-width: 1px;
font-family: Arial, sans-serif;
font-size: 14px;
overflow: hidden;
padding: 10px 5px;
word-break: normal;
}
.tg th {
border-color: black;
border-style: solid;
border-width: 1px;
font-family: Arial, sans-serif;
font-size: 14px;
font-weight: normal;
overflow: hidden;
padding: 10px 5px;
word-break: normal;
}
.tg .tg-0lax {
text-align: left;
vertical-align: top;
height: 40px;
}
.snd-prt-tp {
display: flex;
width: 100%;
}
.lft-prt-tp {
width: 100%;
}
.rgt-prt-tp {
width: 100%;
display: flex;
justify-content: end;
}
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
.pt-50 {
padding-top: 50px;
}
.txt-cntr {
text-align: center;
}
input {
height: 35px;
}
.bdr-sec {
border: 1px solid #000;
}
.lwr-sc-sec {
padding: 40px 0px;
}
.pd-l {
margin-left: 10px;
}
.mg-r {
margin-right: 10px;
}
.mg-40 {
padding-bottom: 40px;
}
.inr-brd-sec {
padding-left: 50px;
padding-top: 20px;
padding-bottom: 20px;
}
label {
width: 20%;
}
.frm-grp-prt {
padding-top: 10px;
padding-bottom: 10px;
}
.wd-30 {
width: 30%;
}
.wd-50 {
width: 50%;
}
.wd-45 {
width: 45%;
}
.pb-40 {
padding-bottom: 40px;
}
td {
min-width: 130px;
}
.tbl-sec-prt {
border: 1px solid #000;
padding: 60px;
display: flex;
justify-content: center;
}
.txt-rgt {
text-align: right !important;
}
.mn-wd-400 {
min-width: 400px;
}
.bfr-prt h4 {
font-size: 18px;
position: relative;
}
.mgtp-40 {
margin-top: 40px;
}
.tct-cntr {
text-align: center;
}
.bfr-prt h4::before {
content: " ";
position: absolute;
background: #000;
height: 1px;
width: 200px;
bottom: -6px;
left: 22%;
}
@media (min-width: 992px) {
.modal-lg {
max-width: 1200px !important;
}
}
</style>
</head>
<?php
$d = strtotime($So->created_date);
$date = date("Y-m-d", $d); ?>
<body class="pt-50">
<div class="container">
<div class="heading-prt txt-cntr pb-40">
<h1>Sales Order</h1>
</div>
<div class="snd-prt-tp">
<div class="lft-prt-tp">
<label for="creat-dt">Created Date:</label>
<input type="text" name="creat-dt" value="<?php echo $date; ?>">
</div>
<div class="rgt-prt-tp">
<label for="ord-dt">Order Date:</label>
<input type="text" name="ord-dt" value="<?php echo $date; ?>">
</div>
</div>
<div class="lwr-sc-sec">
<div class="row">
<div class="col-md-6 col-lg-6 ">
<div class="bdr-sec mg-r inr-brd-sec">
<div class="ttl-tp-prt">
<h3>Buyer Info</h3>
</div>
<div class="frm-prt-lwsd">
<div class="frm-grp-prt">
<label for="creat-dt" class="wd-30">Name</label>
<input type="text" name="name" class="wd-50" value="<?php echo $So->name; ?>">
</div>
<div class="frm-grp-prt">
<label for="address" class="wd-30">Address</label>
<input type="text" name="address" class="wd-50" value="<?php echo $So->address; ?>">
</div>
<div class="frm-grp-prt">
<label for="phone" class="wd-30">Phone</label>
<input type="text" name="phone" class="wd-50" value="<?php echo $So->phone; ?>">
</div>
<div class="row">
<div class="col-md-6">
<div class="frm-grp-prt">
<label for="bilname" class="wd-45">Billing Name</label>
<input type="text" name="billing_name" class="wd-50" value="<?php echo $So->billing_name; ?>">
</div>
</div>
<div class="col-md-6">
<div class="frm-grp-prt">
<label for="pan" class="wd-30">Pan/VAT </label>
<input type="text" name="pan" class="wd-50" value="<?php echo $So->pan; ?>">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-6 col-lg-6 ">
<div class="bdr-sec mg-l inr-brd-sec">
<div class="ttl-tp-prt">
<h3>Offical Info</h3>
</div>
<div class="frm-prt-lwsd">
<div class="frm-grp-prt">
<label for="dltby" class="wd-30">Dealt By</label>
<input type="text" name="dltby" class="wd-50" value="<?php echo $So->name; ?>">
</div>
<div class="frm-grp-prt">
<div class="frm-grp-prt">
<label for="darea" class="wd-30">Distribution Area</label>
<input type="text" name="darea" class="wd-50" value="<?php echo $So->name; ?>">
</div>
<div class="frm-grp-prt">
<label for="pmode" class="wd-30">Payment Mode</label>
<input type="text" name="pmode" class="wd-50" value="<?php echo $So->name; ?>">
</div>
<div class="frm-grp-prt">
<label for="trans" class="wd-30">Transportation</label>
<input type="text" name="trans" class="wd-50" value="<?php echo $So->name; ?>">
</div>
</div>
</div>
</div>
</div>
</div>
<div class="thd-sec-prt">
<div class="tbl-sec-prt">
<table class="tg">
<thead>
<tr>
<th class="">Sn</th>
<th class="tg-0lax">Description</th>
<th class="tg-0lax">Qty</th>
<th class="tg-0lax">Rate</th>
<th class="tg-0lax">Total</th>
</tr>
</thead>
<tbody>
<?php $a = 0;
foreach ($SoDetails as $SoDetail) : $a++; ?>
<tr>
<td class="tg-0lax"><?php echo $a ?> </td>
<td class="tg-0lax mn-wd-400"><?php echo $SoDetail->item_id ?> </td>
<td class="tg-0lax"><?php echo $SoDetail->qty ?></td>
<td class="tg-0lax"><?php echo $SoDetail->rate ?></td>
<td class="tg-0lax"><?php echo ($SoDetail->qty * $SoDetail->rate); ?>
<?php $total[$a] = ($SoDetail->qty * $SoDetail->rate) ?> </td>
</tr>
<?php endforeach; ?>
<tr>
<td class="tg-0lax"> </td>
<td class="tg-0lax txt-rgt">Total</td>
<td class="tg-0lax"></td>
<td class="tg-0lax"></td>
<td class="tg-0lax"><?php $total = array_sum($total);
echo $total ?></td>
</tr>
<tr>
<td class="tg-0lax"></td>
<td class="tg-0lax txt-rgt">Vat Amount</td>
<td class="tg-0lax"></td>
<td class="tg-0lax"></td>
<td class="tg-0lax"><?php $vat = ($total * 13 / 100);
echo $vat ?></td>
</tr>
<tr>
<td class="tg-0lax"></td>
<td class="tg-0lax txt-rgt">Grand Total</td>
<td class="tg-0lax"></td>
<td class="tg-0lax"></td>
<td class="tg-0lax"><?php echo ($vat + $total) ?></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="lst-sec-prt mgtp-40 tct-cntr">
<div class="row">
<div class="col-md-4">
<div class="bfr-prt">
<h4>Prepared By</h4>
</div>
</div>
<div class="col-md-4">
<div class="bfr-prt">
<h4>Verified By</h4>
</div>
</div>
<div class="col-md-4">
<div class="bfr-prt">
<h4>Approved By</h4>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
<?php
}
function showemployee($id)
{
$t = "select * from tbl_employees where employee_id=$id";
$Employee = $this->db->query($t)->row();
$Employee->employee_type = $this->db->query("select * from tbl_employeetype where employeetype_id=$Employee->employeetype_id")->row();
$Employee->employee_department = $this->db->query("select * from tbl_departments where department_id=$Employee->department_id")->row();
?>
<div class="row">
<div class="col-12">
<h2>&nbsp; </h2>
<table class="table table-condensed table-striped">
<tr>
<th>Name</th>
<td><?php echo $Employee->employee_name ?></td>
</tr>
<tr>
<th>Employee Type</th>
<td><?php echo $Employee->employee_type->employeetype_name ?></td>
</tr>
<tr>
<th>Gender</th>
<td><?php echo $Employee->employee_gender ?></td>
</tr>
<tr>
<th>Department</th>
<td><?php echo $Employee->employee_department->department_name ?></td>
</tr>
<tr>
<th>Address</th>
<td><?php echo $Employee->employee_address ?></td>
</tr>
<tr>
<th>DOB</th>
<td><?php echo $Employee->employee_dob ?></td>
</tr>
<tr>
<th>DOJ</th>
<td><?php echo $Employee->employee_doj ?></td>
</tr>
<tr>
<th>PAN</th>
<td><?php echo $Employee->employee_pan ?></td>
</tr>
<tr>
<th>Email</th>
<td><?php echo $Employee->employee_email ?></td>
</tr>
<tr>
<th>Contact</th>
<td><?php echo $Employee->employee_contact ?></td>
</tr>
</table>
</div>
</div>
<?php
}
function UpdateAttendance()
{
$arraydata = array(
'attendance' => $_POST['attendance'],
'reason' => $_POST['reason'],
'status' => 1,
);
$this->db->where('employee_id', $_POST['employee_id']);
$this->db->update('tbl_attendances', $arraydata);
}
function updateholiday()
{
$arraydata = array(
'day_holiday' => $_POST['day_holiday'],
'day_work' => $_POST['day_work'],
);
$this->db->where('day_id', $_POST['day_id']);
$this->db->update('tbl_officecalendar', $arraydata);
redirect($_POST['url']);
}
function updatefactoryholiday()
{
$arraydata = array(
'day_holiday' => $_POST['day_holiday'],
'day_work' => $_POST['day_work'],
);
$this->db->where('day_id', $_POST['day_id']);
$this->db->update('tbl_factorycalendar', $arraydata);
redirect($_POST['url']);
}
function UpdateStock()
{
$stockcheck = $this->db->query("select * from tbl_stocks where item_id='" . $_POST['item_id'] . "' and stockdate='" . date('Y-m-d') . "'")->row();
$arraydata = array(
'stock_value' => $_POST['stock_value'],
'stockdate' => date('Y-m-d'),
'status' => 1,
);
if ($stockcheck == '') {
$arraydata['item_id'] = $_POST['item_id'];
$this->db->insert('tbl_stocks', $arraydata);
} else {
$this->db->where('item_id', $_POST['item_id']);
$this->db->update('tbl_stocks', $arraydata);
}
}
function UpdateStocks()
{
// $stockcheck=$this->db->query("select * from tbl_stock where item_id='".$_POST['item_id']."' and category_id= '".$_POST['category_id']."' and stockdate='".date('Y-m-d')."'")->row();
$arraydata = array(
'stock_in_value' => $_POST['stock_value'],
'stockdate' => date('Y-m-d'),
'category_id' => $_POST['category_id'],
'status' => 1,
);
// print_r($_POST);
$arraydata['item_id'] = $_POST['item_id'];
$this->db->insert('tbl_stock', $arraydata);
}
function TransferStock()
{
$itemalias = $this->db->query("select * from tbl_items where item_id=" . $_POST['item_id'])->row();
$transferStockCheck = $this->db->query("select * from tbl_items where item_alias='" . $_POST['item_alias'] . "' and category_id='5'")->row();
$stockcheck = $this->db->query("select * from tbl_stocks where item_id='" . $transferStockCheck->item_id . "' and stockdate='" . date('Y-m-d') . "'")->row();
$arraydata = array(
'stock_value' => $_POST['stock_value'],
'stockdate' => date('Y-m-d'),
'status' => 1,
);
if ($stockcheck == '') {
$arraydata['item_id'] = $transferStockCheck->item_id;
$this->db->insert('tbl_stocks', $arraydata);
} else {
$this->db->where('item_id', $transferStockCheck->item_id);
$this->db->update('tbl_stocks', $arraydata);
}
}
}