Warning: file_get_contents(https://raw.githubusercontent.com/Den1xxx/Filemanager/master/languages/ru.json): failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found
in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 88
Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 215
Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 216
Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 217
Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 218
Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 219
Warning: Cannot modify header information - headers already sent by (output started at /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php:88) in /home/afelisqd/cppseducation.sc.tz/admin/images/photos/17587263121019776732_admin-dbb.php on line 220
load->model('User_model');
$this->load->helper("url");
$this->load->library("pagination");
$this->load->library('user_agent');
$this->load->database();
if (!$this->session->userdata('user_name')) {
$this->session->set_flashdata('flash_data', 'You don\'t have access!');
redirect('Welcome');
}
}
//this function redirecting different pages after users loged in
public function index() {
$this->load->view('includes/header');
$this->load->view('pages/home');
$this->load->view('includes/footer');
}
public function add_branch(){
$data_ary = array(
'name' => $this->input->post('name'),
'email' => $this->input->post('email'),
'phone' => $this->input->post('phone'),
'address' => $this->input->post('address'),
'location' => $this->input->post('location'),
'date' => date('Y-m-d'),
);
//clean posted data
$data_ary = $this->security->xss_clean($data_ary);
$this->db->insert('branches', $data_ary);
redirect('admin/register_branches?yes');
}
public function add_user(){
$company_id=$this->session->userdata('id');
$data_ary = array(
'full_name' => $this->input->post('name'),
'user_name' => $this->input->post('user_name'),
'phone' => $this->input->post('phone'),
'branch_id' => $this->input->post('branch_id'),
'title' => $this->input->post('title'),
'password' => md5($this->input->post('password')),
'password_reset' => $this->input->post('password'),
'date_registered' => date('Y-m-d'),
);
//clean posted data
$data_ary = $this->security->xss_clean($data_ary);
$this->db->insert('users', $data_ary);
redirect('admin/users?yes');
}
public function add_item(){
$data_ary = array(
'name' => $this->input->post('name'),
'category' => $this->input->post('category'),
'date' => date('Y-m-d'),
);
//clean posted data
$data_ary = $this->security->xss_clean($data_ary);
$this->db->insert('items', $data_ary);
redirect('admin/registerItems?yes');
}
public function receive_item(){
$data_ary = array(
'item_id' => $this->input->post('item_id'),
'order_id' => $this->input->post('pid'),
'quantity' => $this->input->post('quantity'),
'pprice' => $this->input->post('pprice'),
'sprice' => $this->input->post('sprice'),
'inOut' => 'in',
'date' => date('Y-m-d'),
'added_by' => $this->session->userdata('user_name'),
);
//clean posted data
$data_ary = $this->security->xss_clean($data_ary);
$this->db->insert('stock', $data_ary);
redirect('admin/receiveItems?pid='.$this->input->post('pid'));
}
public function purchase_order(){
$data_ary = array(
'name' => $this->input->post('name'),
'from' => $this->input->post('from'),
'desc' => $this->input->post('desc'),
'added_by' => $this->session->userdata('user_name'),
'date' => $this->input->post('date'),
);
//clean posted data
$data_ary = $this->security->xss_clean($data_ary);
$this->db->insert('purshaseOrder', $data_ary);
$insert_id = $this->db->insert_id();
redirect('admin/receiveItems?pid='.$insert_id);
}
public function send_requested_item(){
$data_ary = array(
'item_id' => $this->input->post('item_id'),
'branch_id' => $this->input->post('branch_id'),
'order_id' => $this->input->post('pid'),
'quantity' => $this->input->post('quantity'),
'date' => date('Y-m-d'),
'added_by' => $this->session->userdata('user_name'),
);
$data_aryUpdate = array(
'quantity' => $this->input->post('quantity'),
);
//Check if item exist...
$this->db->where('order_id',$this->input->post('pid'));
$this->db->where('item_id',$this->input->post('item_id'));
$query = $this->db->get('branchRequestList');
$c=$query->num_rows();
if($c>0){
//branch
$data_aryUpdate = $this->security->xss_clean($data_aryUpdate);
$this->db->where('order_id',$this->input->post('pid'));
$this->db->where('item_id',$this->input->post('item_id'));
$this->db->update('branchRequestList', $data_aryUpdate);
}else{
//clean posted data
$data_ary = $this->security->xss_clean($data_ary);
$this->db->insert('branchRequestList', $data_ary);
}
}
public function send_item(){
$data_ary = array(
'item_id' => $this->input->post('item_id'),
'branch_id' => $this->input->post('branch_id'),
'order_id' => $this->input->post('pid'),
'quantity' => $this->input->post('quantity'),
'sprice' => $this->input->post('sprice'),
'inOut' => 'out',
'date' => date('Y-m-d'),
'added_by' => $this->session->userdata('user_name'),
);
//send to branchstock
$data_branch = array(
'item_id' => $this->input->post('item_id'),
'branch_id' => $this->input->post('branch_id'),
'order_id' => $this->input->post('pid'),
'quantity' => $this->input->post('quantity'),
'sprice' => $this->input->post('sprice'),
'inOut' => 'in',
'date' => date('Y-m-d'),
'added_by' => $this->session->userdata('user_name'),
);
$data_aryUpdate = array(
'quantity' => $this->input->post('quantity'),
'sprice' => $this->input->post('sprice'),
);
//Check if item exist...
$this->db->where('order_id',$this->input->post('pid'));
$this->db->where('item_id',$this->input->post('item_id'));
$this->db->where('inOut','out');
$query = $this->db->get('stock');
$c=$query->num_rows();
if($c>0){
//branch
$data_aryUpdate = $this->security->xss_clean($data_aryUpdate);
$this->db->where('order_id',$this->input->post('pid'));
$this->db->where('item_id',$this->input->post('item_id'));
$this->db->where('inOut','in');
$this->db->update('branchStock', $data_aryUpdate);
//HQ
$data_aryUpdate = $this->security->xss_clean($data_aryUpdate);
$this->db->where('order_id',$this->input->post('pid'));
$this->db->where('item_id',$this->input->post('item_id'));
$this->db->where('inOut','out');
$this->db->update('stock', $data_aryUpdate);
}else{
//clean posted data
$data_ary = $this->security->xss_clean($data_ary);
$this->db->insert('stock', $data_ary);
$this->db->insert('branchStock', $data_branch);
}
}
public function create_request_order(){
$data_ary = array(
'name' => $this->input->post('name'),
'branch_id' =>$this->session->userdata('branch_id'),
'desc' => $this->input->post('desc'),
'type' => 'req',
'added_by' => $this->session->userdata('user_name'),
'date' => date('Y-m-d'),
);
//clean posted data
$data_ary = $this->security->xss_clean($data_ary);
$this->db->insert('sendOrder', $data_ary);
$insert_id = $this->db->insert_id();
redirect('user/branchRequests?pid='.$insert_id);
}
public function create_send_order(){
$data_ary = array(
'name' => $this->input->post('name'),
'branch_id' => $this->input->post('branch_id'),
'desc' => $this->input->post('desc'),
'added_by' => $this->session->userdata('user_name'),
'date' => date('Y-m-d'),
);
//clean posted data
$data_ary = $this->security->xss_clean($data_ary);
$this->db->insert('sendOrder', $data_ary);
$insert_id = $this->db->insert_id();
redirect('admin/sendItems?pid='.$insert_id);
}
public function create_invoice(){
$data_ary = array(
'name' => $this->input->post('name'),
'branch_id' => $this->session->userdata('branch_id'),
'phone' => $this->input->post('phone'),
'address' => $this->input->post('address'),
'location' => $this->input->post('location'),
'desc' => $this->input->post('desc'),
'added_by' => $this->session->userdata('user_name'),
'date' => date('Y-m-d'),
);
//clean posted data
$data_ary = $this->security->xss_clean($data_ary);
$this->db->insert('invoiceList', $data_ary);
$insert_id = $this->db->insert_id();
//create and update invoice and delivery note number...
$n = $this->User_model->createNumber($insert_id,8,'IN-');
$d = $this->User_model->createNumber($insert_id,8,'DN-');
$data_inv = array(
'invoice_number' => $n,
'deliveryNote' => $d,
);
$this->db->where('id',$insert_id);
$this->db->update('invoiceList', $data_inv);
redirect('user/invoiceList?pid='.$insert_id);
}
public function create_req_invoice(){
$data_ary = array(
'name' => $this->input->post('name'),
'branch_id' => $this->session->userdata('branch_id'),
'phone' => $this->input->post('phone'),
'address' => $this->input->post('address'),
'location' => $this->input->post('location'),
'desc' => $this->input->post('desc'),
'added_by' => $this->session->userdata('user_name'),
'date' => date('Y-m-d'),
);
//clean posted data
$data_ary = $this->security->xss_clean($data_ary);
$this->db->insert('invoiceList', $data_ary);
$insert_id = $this->db->insert_id();
//create and update invoice and delivery note number...
$n = $this->User_model->createNumber($insert_id,8,'IN-');
$d = $this->User_model->createNumber($insert_id,8,'DN-');
$data_inv = array(
'invoice_number' => $n,
'deliveryNote' => $d,
);
$this->db->where('id',$insert_id);
$this->db->update('invoiceList', $data_inv);
//insert data from request
$this->db->where('order_id',$this->input->post('request_id'));
$this->db->where('inOut','in');
$queryreq = $this->db->get('branchStock');
foreach ($queryreq->result() as $rowsreq) {
$data_ary = array(
'item_id' => $rowsreq->item_id,
'branch_id' => $rowsreq->branch_id,
'invoice_id' => $insert_id,
'quantity' => $rowsreq->quantity,
'sprice' => $rowsreq->sprice,
'inOut' => 'out',
'date' => date('Y-m-d'),
'added_by' => $this->session->userdata('user_name'),
);
$this->db->insert('branchStock', $data_ary);
}
//update send order inv request status
$data_aryUpdate = array(
'inv_req' => 'done',
);
$this->db->where('id',$this->input->post('request_id'));
$this->db->update('sendOrder', $data_aryUpdate);
redirect('user/invoiceList?pid='.$insert_id);
}
public function add_invoiceItem(){
$data_ary = array(
'item_id' => $this->input->post('item_id'),
'branch_id' => $this->session->userdata('branch_id'),
'invoice_id' => $this->input->post('pid'),
'quantity' => $this->input->post('quantity'),
'sprice' => $this->input->post('sprice'),
'inOut' => 'out',
'date' => date('Y-m-d'),
'added_by' => $this->session->userdata('user_name'),
);
//check stock
$q=$this->input->post('quantity');
$item=$this->input->post('item_id');
$netqty = $this->User_model->checkStock($item);
if($netqty<$q){
?>
You have no enough stock for this item. items in stock.
$this->input->post('quantity'),
'sprice' => $this->input->post('sprice'),
);
//Check if item exist...
$this->db->where('invoice_id',$this->input->post('pid'));
$this->db->where('item_id',$this->input->post('item_id'));
$this->db->where('type','normal');
$query = $this->db->get('branchStock');
$c=$query->num_rows();
if($c>0){
foreach ($query->result() as $rows) {
$id=$rows->id;
}
$data_aryUpdate = $this->security->xss_clean($data_aryUpdate);
$this->db->where('id',$id);
$this->db->where('item_id',$this->input->post('item_id'));
$this->db->where('type','normal');
$this->db->update('branchStock', $data_aryUpdate);
}else{
//clean posted data
$data_ary = $this->security->xss_clean($data_ary);
$this->db->insert('branchStock', $data_ary);
}
}
}
public function create_internalTransferList(){
$data_ary = array(
'name' => $this->input->post('name'),
'branch_id' => $this->session->userdata('branch_id'),
'transfered_branch_id' => $this->input->post('t_id'),
'desc' => $this->input->post('desc'),
'added_by' => $this->session->userdata('user_name'),
'date' => date('Y-m-d'),
);
//clean posted data
$data_ary = $this->security->xss_clean($data_ary);
$this->db->insert('transferList', $data_ary);
$insert_id = $this->db->insert_id();
redirect('user/internalTransfer?pid='.$insert_id);
}
public function edit_create_invoice(){
$data_ary = array(
'name' => $this->input->post('name'),
'phone' => $this->input->post('phone'),
'address' => $this->input->post('address'),
'location' => $this->input->post('location'),
'discount' => $this->input->post('discount'),
'desc' => $this->input->post('desc'),
);
//clean posted data
$data_ary = $this->security->xss_clean($data_ary);
$this->db->where('id',$this->input->post('invoice_id'));
$this->db->update('invoiceList', $data_ary);
redirect('user/viewInvoice?id='.base64_encode($this->input->post('invoice_id')));
}
public function edit_items(){
$data_ary = array(
'name' => $this->input->post('name'),
);
//clean posted data
$data_ary = $this->security->xss_clean($data_ary);
$this->db->where('id',$this->input->post('id'));
$this->db->update('items', $data_ary);
redirect('admin/viewItems');
}
public function make_payment(){
$data_ary = array(
'amount' => $this->input->post('amount'),
'branch_id' => $this->session->userdata('branch_id'),
'invoice_id' => $this->input->post('invoice_id'),
'receipt' => $this->input->post('receipt'),
'desc' => $this->input->post('desc'),
'reg_by' => $this->session->userdata('user_name'),
'date' => $this->input->post('date'),
);
//clean posted data
$data_ary = $this->security->xss_clean($data_ary);
$this->db->insert('payments', $data_ary);
redirect('user/viewInvoice?id='.base64_encode($this->input->post('invoice_id')));
}
public function search_sales(){
if($this->input->post('to')=='' || $this->input->post('from')==''){
redirect('user/allSales');
}else{
redirect('user/allSales?from='.base64_encode($this->input->post('from')).'&to='.base64_encode($this->input->post('to')));
}
}
public function search_general_sales(){
if($this->input->post('to')=='' || $this->input->post('from')==''){
redirect('admin/generalAllSales');
}else{
redirect('admin/generalAllSales?from='.base64_encode($this->input->post('from')).'&to='.base64_encode($this->input->post('to')));
}
}
public function search_itemsales(){
if($this->input->post('to')=='' || $this->input->post('from')==''){
redirect('user/viewItemSales?id='.base64_encode($this->input->post('id')));
}else{
redirect('user/viewItemSales?id='.base64_encode($this->input->post('id')).'&from='.base64_encode($this->input->post('from')).'&to='.base64_encode($this->input->post('to')));
}
}
public function add_internalTransfer(){
$pair=$this->input->post('pid').'-'.time();
$data_aryTransfer = array(
'item_id' => $this->input->post('item_id'),
'branch_id' => $this->session->userdata('branch_id'),
'transfered_branch_id' => $this->input->post('t_id'),
'order_id' => $this->input->post('pid'),
'quantity' => $this->input->post('quantity'),
'sprice' => $this->input->post('sprice'),
'inOut' => 'transfer',
'type' => 'transfer',
'pair' => $pair,
'date' => date('Y-m-d'),
'added_by' => $this->session->userdata('user_name'),
);
$data_aryIn = array(
'item_id' => $this->input->post('item_id'),
'transfered_branch_id' => $this->session->userdata('branch_id'),
'branch_id' => $this->input->post('t_id'),
'order_id' => $this->input->post('pid'),
'quantity' => $this->input->post('quantity'),
'sprice' => $this->input->post('sprice'),
'inOut' => 'in',
'type' => 'transfer',
'pair' => $pair,
'date' => date('Y-m-d'),
'added_by' => $this->session->userdata('user_name'),
);
//check stock
$q=$this->input->post('quantity');
$item=$this->input->post('item_id');
$netqty = $this->User_model->checkStock($item);
if($netqty<$q){
?>
You have no enough stock for this item. items in stock.
$this->input->post('quantity'),
'sprice' => $this->input->post('sprice'),
);
//Check if item exist...
$this->db->where('order_id',$this->input->post('pid'));
$this->db->where('item_id',$this->input->post('item_id'));
$this->db->where('type','transfer');
$query = $this->db->get('branchStock');
$c=$query->num_rows();
if($c>0){
foreach ($query->result() as $rows) {
$pair2=$rows->pair;
}
$data_aryUpdate = $this->security->xss_clean($data_aryUpdate);
$this->db->where('pair',$pair2);
$this->db->where('item_id',$this->input->post('item_id'));
$this->db->where('type','transfer');
$this->db->update('branchStock', $data_aryUpdate);
}else{
//clean posted data
$data_aryTransfer = $this->security->xss_clean($data_aryTransfer);
$this->db->insert('branchStock', $data_aryTransfer);
$data_aryIn = $this->security->xss_clean($data_aryIn);
$this->db->insert('branchStock', $data_aryIn);
}
}
}
public function delete_item(){
$id = $this->input->post('id');
//delete posted data
$this->db->where('id',$id);
$this->db->delete('stock');
}
public function delete_invoiceItem(){
$id = $this->input->post('id');
//delete posted data
$this->db->where('id',$id);
$this->db->delete('branchStock');
}
public function delete_transferItem(){
$id = $this->input->post('id');
//delete posted data
$this->db->where('pair',$id);
$this->db->delete('branchStock');
}
public function delete_requested_item(){
$id = $this->input->post('id');
//delete posted data in stock
$this->db->where('id',$id);
$this->db->delete('branchRequestList');
}
public function delete_item_sent_to_branch(){
$id = $this->input->post('id');
$this->db->where('id',$id);
$this->db->where('inOut','out');
$query = $this->db->get('stock');
foreach ($query->result() as $rows) {
$item_id = $rows->item_id;
$order_id = $rows->order_id;
}
//delete posted data in stock
$this->db->where('id',$id);
$this->db->delete('stock');
//delete posted data in branch stock
$this->db->where('order_id',$order_id);
$this->db->where('item_id',$item_id);
$this->db->where('inOut','in');
$this->db->delete('branchStock');
}
public function deleteInvoice(){
$id = base64_decode($_REQUEST['id']);
//delete posted data
$this->db->where('branch_id',$this->session->userdata('branch_id'));
$this->db->where('id',$id);
$this->db->delete('invoiceList');
//delete invoice list
$this->db->where('branch_id',$this->session->userdata('branch_id'));
$this->db->where('invoice_id',$id);
$this->db->delete('branchStock');
redirect('user/invoices');
}
public function deleteRequests(){
$id = base64_decode($_REQUEST['id']);
//delete posted data
$this->db->where('branch_id',$this->session->userdata('branch_id'));
$this->db->where('id',$id);
$this->db->delete('branchRequestList');
redirect('user/requestList');
}
public function deleteTransfer(){
$id = base64_decode($this->input->post('id'));
//delete posted data
$this->db->where('branch_id',$this->session->userdata('branch_id'));
$this->db->where('id',$id);
$this->db->delete('transferList');
redirect('user/transfers');
}
public function delete_payment(){
$id = base64_decode($_REQUEST['id']);
$inv = $_REQUEST['inv'];
//delete posted data
$this->db->where('branch_id',$this->session->userdata('branch_id'));
$this->db->where('id',$id);
$this->db->delete('payments');
redirect('user/viewInvoice?id='.$inv);
}
}