BBnepal-Accounts/account/application/views/setup/Po.php

71 lines
2.7 KiB
PHP
Raw Normal View History

2024-07-10 12:43:19 +00:00
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Po extends CI_Controller {
function __construct()
{
parent::__construct();
checkLogin();
}
public function _remap($alias="",$params=array())
{
$data['dataValue']=$this->session;
$data['pageTitle']="Purchase Order";
switch($alias)
{
case 'add':
if(isset($_POST['submit'])){
$TableData=array(
'po_date'=>filter_var($_POST['po_date'],FILTER_SANITIZE_STRING),
'po_by'=>filter_var($_POST['po_by'],FILTER_SANITIZE_STRING),
'po_duedate'=>filter_var($_POST['po_duedate'],FILTER_SANITIZE_STRING),
'po_urgency'=>filter_var($_POST['po_urgency'],FILTER_SANITIZE_STRING),
'vendor_id'=>filter_var($_POST['vendor_id'],FILTER_SANITIZE_STRING),
'approved_by'=>filter_var($_POST['approved_by'],FILTER_SANITIZE_STRING),
'approved_on'=>filter_var($_POST['approved_on'],FILTER_SANITIZE_STRING),
'created_by'=>'admin',
'created_on'=>date('Y-m-d H:i:s'),
'remarks'=>filter_var($_POST['remarks'],FILTER_SANITIZE_STRING),
'status'=>1,
);
$this->db->insert('tbl_po',$TableData);
redirect("po");
} loadView("po/addpo",$data);
break;
case 'edit':
if(isset($_POST['submit'])){
$id=$this->uri->segment(4);
$TableData=array(
'po_date'=>filter_var($_POST['po_date'],FILTER_SANITIZE_STRING),
'po_by'=>filter_var($_POST['po_by'],FILTER_SANITIZE_STRING),
'po_duedate'=>filter_var($_POST['po_duedate'],FILTER_SANITIZE_STRING),
'po_urgency'=>filter_var($_POST['po_urgency'],FILTER_SANITIZE_STRING),
'vendor_id'=>filter_var($_POST['vendor_id'],FILTER_SANITIZE_STRING),
'approved_by'=>filter_var($_POST['approved_by'],FILTER_SANITIZE_STRING),
'approved_on'=>filter_var($_POST['approved_on'],FILTER_SANITIZE_STRING),
'created_by'=>'admin',
'created_on'=>date('Y-m-d H:i:s'),
'remarks'=>filter_var($_POST['remarks'],FILTER_SANITIZE_STRING),
'status'=>1,
);
$this->db->where('po_id',$id);
$this->db->update('tbl_po',$TableData);
redirect("po");
} loadView("po/editpo",$data);
break;
case 'delete':
$id=$this->uri->segment(4);
$this->db->where('po_id',$id);
$this->db->delete('tbl_po');
redirect("po");
break;
default:
loadView("po/listpo",$data);
}
}
}