Ir para conteúdo
Fórum Script Brasil

Pesquisar na Comunidade

Mostrando resultados para as tags ''sistema pdv''.

  • Pesquisar por Tags

    Digite tags separadas por vírgulas
  • Pesquisar por Autor

Tipo de Conteúdo


Fóruns

  • Programação & Desenvolvimento
    • ASP
    • PHP
    • .NET
    • Java
    • C, C++
    • Delphi, Kylix
    • Lógica de Programação
    • Mobile
    • Visual Basic
    • Outras Linguagens de Programação
  • WEB
    • HTML, XHTML, CSS
    • Ajax, JavaScript, XML, DOM
    • Editores
  • Arte & Design
    • Corel Draw
    • Fireworks
    • Flash & ActionScript
    • Photoshop
    • Outros Programas de Arte e Design
  • Sistemas Operacionais
    • Microsoft Windows
    • GNU/Linux
    • Outros Sistemas Operacionais
  • Softwares, Hardwares e Redes
    • Microsoft Office
    • Softwares Livres
    • Outros Softwares
    • Hardware
    • Redes
  • Banco de Dados
    • Access
    • MySQL
    • PostgreSQL
    • SQL Server
    • Demais Bancos
  • Segurança e Malwares
    • Segurança
    • Remoção De Malwares
  • Empregos
    • Vagas Efetivas
    • Vagas para Estágios
    • Oportunidades para Freelances
  • Negócios & Oportunidades
    • Classificados & Serviços
    • Eventos
  • Geral
    • Avaliações de Trabalhos
    • Links
    • Outros Assuntos
    • Entretenimento
  • Script Brasil
    • Novidades e Anúncios Script Brasil
    • Mercado Livre / Mercado Sócios
    • Sugestões e Críticas
    • Apresentações

Encontrar resultados em...

Encontrar resultados que...


Data de Criação

  • Início

    FIM


Data de Atualização

  • Início

    FIM


Filtrar pelo número de...

Data de Registro

  • Início

    FIM


Grupo


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests

Encontrado 1 registro

  1. Boa tarde pessoal, estou com um sistema que comprei online. Trata-se de um sistema online de gestão empresarial com pdv. Eu estou com uma dificuldade para alterar um dado que eu quero. Vou tentar explicar caso ainda haja dúvidas podem me perguntar. É o seguinte: Nome do sistema: Stock Manager PDV 1. Eu abro uma venda e nela tenho que selecionar o comprador, produto, quantidade e o valor ele puxa do estoque. 2.Porém quando eu tento alterar o valor unitário da venda, ele puxa do estoque, mas eu preciso alterar no pedido o valor do produto. ------------ CONTROLADORA DO PDV ------------ <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Pos extends MX_Controller { /* | ----------------------------------------------------- | PRODUCT NAME: SIMPLE POS | ----------------------------------------------------- | AUTHER: MIAN SALEEM | ----------------------------------------------------- | EMAIL: saleem@tecdiary.com | ----------------------------------------------------- | COPYRIGHTS: RESERVED BY TECDIARY IT SOLUTIONS | ----------------------------------------------------- | WEBSITE: http://tecdiary.net | ----------------------------------------------------- | | MODULE: POS | ----------------------------------------------------- | This is sales module controller file. | ----------------------------------------------------- */ function __construct() { parent::__construct(); // check if user logged in if (!$this->ion_auth->logged_in()) { redirect('module=auth&view=login'); } $this->load->library('form_validation'); $this->load->model('pos_model'); $pos_setting = $this->pos_model->getSetting(); define("CLIMIT", $pos_setting->cat_limit); define("PLIMIT", $pos_setting->pro_limit); define("DCAT", $pos_setting->default_category); define("DCUS", $pos_setting->default_customer); define("DBILLER", $pos_setting->default_biller); define("DTIME", $pos_setting->display_time); $this->lang->load('pos', LANGUAGE); } /* -------------------------------------------------------------------------------------------------------------------------------- */ //Add new pos sale function index() { if( $this->input->get('suspend_id') ) { $data['sid'] = $this->input->get('suspend_id'); } else { $data['sid'] = NULL; } if( $this->input->post('delete_id') ) { $did = $this->input->post('delete_id'); } else { $did = NULL; } if( $this->input->post('suspend') ) { $suspend = TRUE; } else { $suspend = FALSE; } if( $this->input->post('count') ) { $count = $this->input->post('count'); $count = $count - 1; } $groups = array('purchaser', 'viewer'); if ($this->ion_auth->in_group($groups)) { $this->session->set_flashdata('message', $this->lang->line("access_denied")); redirect('module=home', 'refresh'); } //validate form input $this->form_validation->set_rules('customer', $this->lang->line("customer"), 'trim|required|xss_clean'); $this->form_validation->set_rules('warehouse', $this->lang->line("warehouse"), 'required|xss_clean'); $this->form_validation->set_rules('biller', $this->lang->line("biller"), 'required|xss_clean'); $quantity = "quantity"; $product = "product"; $unit_price = "price"; $tax_rate = "tax_rate"; $sl = "serial"; $dis = "discount"; if ($this->form_validation->run() == true) { $date = date('Y-m-d'); $reference_no = $this->pos_model->getNextAI(); $paid_by = $this->input->post('rpaidby'); $count = $this->input->post('count'); $count = $count - 1; $warehouse_id = $this->input->post('warehouse'); $biller_id = $this->input->post('biller'); if($biller_details = $this->pos_model->getBillerByID($biller_id)) { $biller_name = $biller_details->name; } else { $this->session->set_flashdata('message', $this->lang->line("biller_x_found")); redirect("module=pos", 'refresh'); } if($customer_details = $this->pos_model->getCustomerByName($this->input->post('customer'))) { $customer_id = $customer_details->id; $customer_name = $customer_details->name; } else { $customer_details = $this->pos_model->getCustomerByName(DCUS); $customer_id = $customer_details->id; $customer_name = $customer_details->name; } if(DISCOUNT_OPTION == 1) { $inv_discount = DEFAULT_DISCOUNT; } if(TAX2) { $tax_rate2 = DEFAULT_TAX2; } $inv_total_no_tax = 0; for($i=1; $i<=500; $i++){ if( $this->input->post($quantity.$i) && $this->input->post($product.$i) && $this->input->post($unit_price.$i) ) { $product_details = $this->pos_model->getProductByCode($this->input->post($product.$i)); if(RESTRICT_SALE) { if($pr_ck = $this->pos_model->getWarehouseProductQuantity($warehouse_id, $product_details->id)) { if($pr_ck->quantity < $this->input->post($quantity.$i) && $product_details->track_quantity == 1) { $this->session->set_flashdata('message', $this->lang->line("wh_qty_less_then_sale")." (".$product_details->name.")"); redirect("module=pos", 'refresh'); } } else { $this->session->set_flashdata('message', $this->lang->line("wh_qty_less_then_sale")." (".$product_details->name.")"); redirect("module=pos", 'refresh'); } } if(TAX1) { $tax_id = $this->input->post($tax_rate.$i); $tax_details = $this->pos_model->getTaxRateByID($tax_id); $taxRate = $tax_details->rate; $taxType = $tax_details->type; $tax_rate_id[] = $tax_id; if($taxType == 1 && $taxRate != 0) { $item_tax = (($this->input->post($quantity.$i)) * ($this->input->post($unit_price.$i)) * $taxRate / 100); $val_tax[] = $item_tax; } else { $item_tax = $taxRate; $val_tax[] = $item_tax; } if($taxType == 1) { $tax[] = $taxRate."%"; } else { $tax[] = $taxRate; } } else { $item_tax = 0; $tax_rate_id[] = 0; $val_tax[] = 0; $tax[] = ""; } if(DISCOUNT_METHOD == 1 && DISCOUNT_OPTION == 2) { $discount_id = $this->input->post($dis.$i); $ds_details = $this->pos_model->getDiscountByID($discount_id); $ds = $ds_details->discount; $dsType = $ds_details->type; $dsID[] = $discount_id; if($dsType == 1 && $ds != 0) { $val_ds[] = (($this->input->post($quantity.$i)) * ($this->input->post($unit_price.$i)) * $ds / 100); } else { $val_ds[] = $ds * ($this->input->post($quantity.$i)); } if($dsType == 1) { $discount[] = $ds."%"; } else { $discount[] = $ds; } } elseif(DISCOUNT_METHOD == 2 && DISCOUNT_OPTION == 2) { $discount_id = $this->input->post($dis.$i); $ds_details = $this->pos_model->getDiscountByID($discount_id); $ds = $ds_details->discount; $dsType = $ds_details->type; $dsID[] = $discount_id; if($dsType == 1 && $ds != 0) { $val_ds[] = (((($this->input->post($quantity.$i)) * ($this->input->post($unit_price.$i)) + $item_tax) * $ds) / 100); } else { $val_ds[] = $ds * ($this->input->post($quantity.$i)); } if($dsType == 1) { $discount[] = $ds."%"; } else { $discount[] = $ds; } } else { $val_ds[] = 0; $dsID[] = 0; $discount[] = ""; } if(PRODUCT_SERIAL) { $serial[] = $this->input->post($sl.$i); } else { $serial[] = ""; } $inv_quantity[] = $this->input->post($quantity.$i); //$inv_product_code[] = $this->input->post($product.$i); $inv_unit_price[] = $this->input->post($unit_price.$i); $inv_gross_total[] = (($this->input->post($quantity.$i)) * ($this->input->post($unit_price.$i))); $product_id[] = $product_details->id; $product_name[] = $product_details->name; $product_code[] = $product_details->code; $product_unit[] = $product_details->unit; $inv_total_no_tax += (($this->input->post($quantity.$i)) * ($this->input->post($unit_price.$i))); } } if(DISCOUNT_OPTION == 2) { $total_ds = array_sum($val_ds); } else { $total_ds = 0; } if(TAX1) { $total_tax = array_sum($val_tax); } else { $total_tax = 0; } /*if(!empty($inv_product_code)) { foreach($inv_product_code as $pr_code){ $product_details = $this->pos_model->getProductByCode($pr_code); $product_id[] = $product_details->id; $product_name[] = $product_details->name; $product_code[] = $product_details->code; $product_unit[] = $product_details->unit; } }*/ $keys = array("product_id","product_code","product_name","product_unit", "tax_rate_id", "tax","quantity","unit_price", "gross_total", "val_tax", "serial_no", "discount_val", "discount", "discount_id"); $items = array(); foreach ( array_map(null, $product_id, $product_code, $product_name, $product_unit, $tax_rate_id, $tax, $inv_quantity, $inv_unit_price, $inv_gross_total, $val_tax, $serial, $val_ds, $discount, $dsID) as $key => $value ) { $items[] = array_combine($keys, $value); } if(TAX2) { $tax_dts = $this->pos_model->getTaxRateByID($tax_rate2); $taxRt = $tax_dts->rate; $taxTp = $tax_dts->type; if($taxTp == 1 && $taxRt != 0) { $val_tax2 = ($inv_total_no_tax * $taxRt / 100); } else { $val_tax2 = $taxRt; } } else { $val_tax2 = 0; $tax_rate2 = 0; } if(DISCOUNT_METHOD == 1 && DISCOUNT_OPTION == 1) { $ds_dts = $this->pos_model->getDiscountByID($inv_discount); $ds = $ds_dts->discount; $dsTp = $ds_dts->type; if($dsTp == 1 && $ds != 0) { $val_discount = ($inv_total_no_tax * $ds / 100); } else { $val_discount = $ds; } } elseif(DISCOUNT_METHOD == 2 && DISCOUNT_OPTION == 1) { $ds_dts = $this->pos_model->getDiscountByID($inv_discount); $ds = $ds_dts->discount; $dsTp = $ds_dts->type; if($dsTp == 1 && $ds != 0) { $val_discount = ((($inv_total_no_tax + $total_tax + $val_tax2) * $ds) / 100); } else { $val_discount = $ds; } } else { $val_discount = $total_ds; $inv_discount = 0; } $gTotal = $inv_total_no_tax + $total_tax + $val_tax2 - $val_discount; $saleDetails = array('reference_no' => $reference_no, 'date' => $date, 'biller_id' => $biller_id, 'biller_name' => $biller_name, 'customer_id' => $customer_id, 'customer_name' => $customer_name, 'inv_total' => $inv_total_no_tax, 'total_tax' => $total_tax, 'total' => $gTotal, 'total_tax2' => $val_tax2, 'tax_rate2_id' => $tax_rate2, 'inv_discount' => $val_discount, 'discount_id' => $inv_discount, 'user' => USER_NAME, 'paid_by' => $paid_by, 'count' => $count, 'paid_val' => $this->input->post('paid_val'), 'cc_no_val' => $this->input->post('cc_no_val'), 'cc_holder_val' => $this->input->post('cc_holder_val'), 'cheque_no_val' => $this->input->post('cheque_no_val'), ); } if ( $this->form_validation->run() == true && !empty($items) ) { if($suspend) { if($this->pos_model->suspendSale($saleDetails, $items, $count, $did)) { $this->session->set_flashdata('success_message', $this->lang->line("sale_suspended")); redirect("module=pos", 'refresh'); } } else { if($saleID = $this->pos_model->addSale($saleDetails, $items, $warehouse_id, $did)) { $this->session->set_flashdata('success_message', $this->lang->line("sale_added")); redirect("module=pos&view=view_invoice&id=".$saleID, 'refresh'); } } } else { $data['message'] = (validation_errors() ? validation_errors() : $this->session->flashdata('message')); $data['success_message'] = $this->session->flashdata('success_message'); if($this->input->get('suspend_id')) { $suspende_sd = $this->pos_model->getSaleByID($this->input->get('suspend_id')); $data['customer'] = $this->pos_model->getCustomerById($suspende_sd->customer_id); } else { $data['customer'] = $this->pos_model->getCustomerById(DCUS); } $data['biller'] = $this->pos_model->getBillerByID(DBILLER); $data['discounts'] = $this->pos_model->getAllDiscounts(); $data['billers'] = $this->pos_model->getAllBillers(); $data['warehouses'] = $this->pos_model->getAllWarehouses(); $data['tax_rates'] = $this->pos_model->getAllTaxRates(); $data["total_cats"] = $this->pos_model->categories_count(); $data["total_cp"] = $this->pos_model->products_count(DCAT); if(DISCOUNT_OPTION == 1) { $discount_details = $this->pos_model->getDiscountByID(DEFAULT_DISCOUNT); $data['discount_rate'] = $discount_details->discount; $data['discount_type'] = $discount_details->type; $data['discount_name'] = $discount_details->name; } if(DISCOUNT_OPTION == 2) { $discount2_details = $this->pos_model->getDiscountByID(DEFAULT_DISCOUNT); $data['discount_rate2'] = $discount2_details->discount; $data['discount_type2'] = $discount2_details->type; } if(TAX1) { $tax_rate_details = $this->pos_model->getTaxRateByID(DEFAULT_TAX); $data['tax_rate'] = $tax_rate_details->rate; $data['tax_type'] = $tax_rate_details->type; $data['tax_name'] = $tax_rate_details->name; } if(TAX2) { $tax_rate2_details = $this->pos_model->getTaxRateByID(DEFAULT_TAX2); $data['tax_rate2'] = $tax_rate2_details->rate; $data['tax_name2'] = $tax_rate2_details->name; $data['tax_type2'] = $tax_rate2_details->type; } $data['products'] = $this->ajaxproducts(DCAT); $data['categories'] = $this->poscategories(); $data['page_title'] = $this->lang->line("pos_module"); $this->load->view('add', $data); } } function tax_rates() { if($this->input->get('id')) { $id = $this->input->get('id'); } if($this->input->get('old_id')) { $old_id = $this->input->get('old_id'); } else { $old_id = NULL; } $new_tax_rate_details = $this->pos_model->getTaxRateByID($id); if($old_id) { $old_tax_rate_details = $this->pos_model->getTaxRateByID($old_id); $tax = array('old_tax_rate' => $old_tax_rate_details->rate, 'old_tax_type' => $old_tax_rate_details->type, 'new_tax_rate' => $new_tax_rate_details->rate, 'new_tax_type' => $new_tax_rate_details->type); } else { $tax = array('new_tax_rate' => $new_tax_rate_details->rate, 'new_tax_type' => $new_tax_rate_details->type); } echo json_encode($tax); } function discounts() { if($this->input->get('id')) { $id = $this->input->get('id'); } if($this->input->get('old_id')) { $old_id = $this->input->get('old_id'); } else { $old_id = NULL; } $new_discount_details = $this->pos_model->getDiscountByID($id); if($old_id) { $old_discount_details = $this->pos_model->getDiscountByID($old_id); $ds = array('old_discount' => $old_discount_details->discount, 'old_discount_type' => $old_discount_details->type, 'new_discount' => $new_discount_details->discount, 'new_discount_type' => $new_discount_details->type); } else { $ds = array('new_discount' => $new_discount_details->discount, 'new_discount_type' => $new_discount_details->type); } echo json_encode($ds); } function scan_product() { if($this->input->get('code')) { $code = $this->input->get('code'); } if($prodd = $this->pos_model->getProductByCode($code)) { $product_name = $prodd->name; $product_code = $prodd->code; $product_price = $prodd->price; $product_id = $prodd->id; $category_id = $prodd->category_id; if($product_id < 10) { $product_id = "0".(($product_id*100)/100); } if($category_id < 10) { $category_id = "0".(($category_id*100)/100); } $last = $category_id.$product_id; $tax_rate = $this->pos_model->getTaxRateByID($prodd->tax_rate); $product = array('product_name' => $product_name, 'product_code' => $product_code, 'item_price' => $product_price, 'last' => $last, 'tax_rate' => $tax_rate ); } echo json_encode($product); } function add_row($category_id = NULL, $code = NULL) { if($this->input->get('code')) { $code = $this->input->get('code'); } if($this->input->get('category_id')) { $category_id = $this->input->get('category_id'); } else { $category_id = 1; } $products = $this->pos_model->getProductByCode($code); $row = '<td width="29px" style="text-align:center;"> x </td><td width="144px">'.$products->name.'</td><td width="44px" style="text-align:center;">1</td><td width="86px style="text-align:right;"> '.$products->price.' </td>'; echo $row; } function price($code = NULL) { if($this->input->get('code')) { $code = $this->input->get('code'); } $products = $this->pos_model->getProductByCode($code); $price = $products->price; $name = $products->name; $code = $products->code; $product_tax = $products->tax_rate; $tax_rate = $this->pos_model->getTaxRateByID($product_tax); $data = array('price'=> $price, 'name' => $name, 'code' => $code, 'tax_rate' => $tax_rate); echo json_encode($data); } function poscategories($category_id = NULL) { if($this->input->get('category_id')) { $category_id = $this->input->get('category_id'); } else { $category_id = DCAT; } if($this->input->get('per_page') == 'n' ) { $page = 0; } else { $page = $this->input->get('per_page'); } $categories = $this->pos_model->getAllCategories(); $count = 1; $cats = ""; foreach($categories as $category) { $cats .= "<li><button id=\"category\" type=\"button\" value='".$category->id."' class=\"gray\"> ".$category->name."</button></li>"; $count++; } if($this->input->get('per_page')) { echo $cats ; } else { return $cats; } } function ajaxproducts( $category_id = NULL) { if($this->input->get('category_id')) { $category_id = $this->input->get('category_id'); } else { $category_id = DCAT; } if($this->input->get('per_page') == 'n' ) { $page = 0; } else { $page = $this->input->get('per_page'); } $this->load->library("pagination"); $config = array(); $config["base_url"] = base_url() . "index.php?module=pos&view=ajaxproducts"; $config["total_rows"] = $this->pos_model->products_count($category_id); $config["per_page"] = PLIMIT; $config['prev_link'] = FALSE; $config['next_link'] = FALSE; $config['display_pages'] = FALSE; $config['first_link'] = FALSE; $config['last_link'] = FALSE; $this->pagination->initialize($config); $products = $this->pos_model->fetch_products($category_id, $config["per_page"], $page); $pro = 1; $prods = "<div>"; foreach($products as $product) { $count = $product->id; if($count < 10) { $count = "0".($count /100) *100; } if($category_id < 10) { $category_id = "0".($category_id /100) *100; } if($product->image == 'no_image.jpg') { $prods .= " <button id=\"product-".$category_id.$count."\" type=\"button\" value='".$product->code."' class=\"green\" ><i><img src=\"assets/uploads/thumbs/default.png\"></i><span><span>".$product->name."</span></span></button>"; } else { $prods .= " <button id=\"product-".$category_id.$count."\" type=\"button\" value='".$product->code."' class=\"green\" ><i><img src=\"assets/uploads/thumbs/".$product->image."\"></i><span><span>".$product->name."</span></span></button>"; } $pro++; } if($pro <= PLIMIT) { for($i = $pro; $i <= PLIMIT; $i++) { $prods .= "<button type=\"button\" value='0' class=\"tr\" style=\"cursor: default !important;\"><i></i><span></span></button>"; } } $prods .= "</div>"; if($this->input->get('per_page')) { echo $prods ; } else { return $prods; } } /* -------------------------------------------------------------------------------------------------------------------------------- */ function total_cp() { $category_id = $this->input->get('category_id'); if($result = $this->pos_model->products_count($category_id)) { } else { $result = 0; } echo $result; exit; } function products() { $term = $this->input->get('q', TRUE); $output = $this->input->get('output', TRUE); if(!$term) { redirect("home"); } $cq = $term; if (!$cq) return; $prs = $this->pos_model->getProductsByCode($cq); foreach($prs as $pr) { $items[$pr->code] = $pr->price; } $results = array(); foreach ($items as $key=>$value) { if (strpos(strtolower($key), $cq) !== false) { array_push($results, array(strip_tags($key))); } if (count($results) > 11) { break; } } echo $this->array_to_json($results); exit; } //view inventory as html page function view_invoice() { if($this->input->get('id')){ $sale_id = $this->input->get('id'); } else { $sale_id = NULL; } $data['message'] = (validation_errors() ? validation_errors() : $this->session->flashdata('message')); $data['rows'] = $this->pos_model->getAllInvoiceItems($sale_id); $inv = $this->pos_model->getInvoiceBySaleID($sale_id); $biller_id = $inv->biller_id; $customer_id = $inv->customer_id; $invoice_type_id = $inv->invoice_type; $data['biller'] = $this->pos_model->getBillerByID($biller_id); $data['customer'] = $this->pos_model->getCustomerByID($customer_id); $data['invoice_types_details'] = $this->pos_model->getInvoiceTypeByID($invoice_type_id); $data['pos'] = $this->pos_model->getSetting(); $data['inv'] = $inv; $data['sid'] = $sale_id; $data['page_title'] = $this->lang->line("invoice"); $this->load->view('view', $data); } function today_sale() { $data['message'] = (validation_errors() ? validation_errors() : $this->session->flashdata('message')); if($cc_sale = $this->pos_model->getTodayCCSales()) { $data['ccsales'] = $cc_sale->total; } else { $data['ccsales'] = "0.00"; } if($cash_sale = $this->pos_model->getTodayCashSales()) { $data['cashsales'] = $cash_sale->total; } else { $data['cashsales'] = "0.00"; } if($ch_sale = $this->pos_model->getTodayChSales()) { $data['chsales'] = $ch_sale->total; } else { $data['chsales'] = "0.00"; } $data['totalsales'] = $this->pos_model->getTodaySales(); $meta['page_title'] = $this->lang->line('today_sale'); echo $this->load->view('sales', $data, TRUE); } function settings() { //validate form input $this->form_validation->set_message('is_natural_no_zero', $this->lang->line('no_zero_required')); $this->form_validation->set_rules('pro_limit', $this->lang->line('pro_limit'), 'required|is_natural_no_zero|xss_clean'); $this->form_validation->set_rules('category', $this->lang->line('default_category'), 'required|is_natural_no_zero|xss_clean'); $this->form_validation->set_rules('customer', $this->lang->line('default_customer'), 'required|is_natural_no_zero|xss_clean'); $this->form_validation->set_rules('biller', $this->lang->line('default_biller'), 'required|is_natural_no_zero|xss_clean'); $this->form_validation->set_rules('cf_title1', $this->lang->line('cf_title1'), 'xss_clean'); $this->form_validation->set_rules('cf_title2', $this->lang->line('cf_title2'), 'xss_clean'); $this->form_validation->set_rules('cf_value1', $this->lang->line('cf_value1'), 'xss_clean'); $this->form_validation->set_rules('cf_value2', $this->lang->line('cf_value2'), 'xss_clean'); if ($this->form_validation->run() == true) { $data = array( 'pro_limit' => $this->input->post('pro_limit'), 'category' => $this->input->post('category'), 'customer' => $this->input->post('customer'), 'biller' => $this->input->post('biller'), 'display_time' => $this->input->post('display_time'), 'cf_title1' => $this->input->post('cf_title1'), 'cf_title2' => $this->input->post('cf_title2'), 'cf_value1' => $this->input->post('cf_value1'), 'cf_value2' => $this->input->post('cf_value2') ); } if ( $this->form_validation->run() == true && $this->pos_model->updateSetting($data)) { $this->session->set_flashdata('success_message', $this->lang->line('pos_setting_updated')); redirect("module=pos&view=settings", 'refresh'); } else { $data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message'); $data['success_message'] = $this->session->flashdata('success_message'); $data['pos'] = $this->pos_model->getSetting(); $data['categories'] = $this->pos_model->getAllCategories(); $data['customers'] = $this->pos_model->getAllCustomers(); $data['billers'] = $this->pos_model->getAllBillers(); $meta['page_title'] = $this->lang->line('pos_settings'); $data['page_title'] = $this->lang->line('pos_settings'); $this->load->view('commons/header', $meta); $this->load->view('setting', $data); $this->load->view('commons/footer'); } } function suspend_bill() { $csutomer_id = $this->input->post('id'); $saleData = base64_encode($this->input->post('saleData')); $count = $this->input->post('count'); $tax1 = $this->input->post('tax1'); $tax2 = $this->input->post('tax2'); $total = $this->input->post('total'); if($this->pos_model->suspendBill($csutomer_id, $saleData, $count, $tax1, $tax2, $total)) { return true; } else { return false; } } function load_suspended_bill() { $id = $this->input->post('id'); if($newData = $this->pos_model->getSaleByID($id)) { $items = $this->pos_model->getAllSaleItems($id); $tax_rates = $this->pos_model->getAllTaxRates(); $r=1; $sdata = ""; foreach($items as $item){ $sdata .= '<tr id="row_'.$r.'"><td id="satu" style="text-align:center; width: 27px;"><button type="button" class="del_row" id="del-'.$r.'" value="'.$r.'"><i class="icon-trash"></i></button></td><td><input type="hidden" name="product'.$r.'" value="'.$item->product_code.'" id="product-'.$r.'"><input type="hidden" name="serial'.$r.'" value="" id="serial-'.$r.'"><input type="hidden" name="tax_rate'.$r.'" value="'.$item->tax_rate_id.'" id="tax_rate-'.$r.'"><input type="hidden" name="discount'.$r.'" value="'.$item->discount_id.'" id="discount-'.$r.'"><a href="#" id="model-'.$r.'" class="code">'.$item->product_name.'</a><input type="hidden" name="price'.$r.'" value="'.$item->unit_price.'" id="oprice-'.$r.'"></td><td style="text-align:center;"><input class="keyboard" onClick="this.select();" name="quantity'.$r.'" type="text" value="'.$item->quantity.'" autocomplete="off" id="quantity-'.$r.'"></td><td style="padding-right: 10px; text-align:right;"><input type="text" class="price" name="unit_price'.$r.'" value="'.$item->gross_total.'" id="price-'.$r.'"></td></tr>'; $r++; } $item_count = $newData->count + 1; $customer_id = $newData->customer_id; $tax1 = $newData->tax1; $tax2 = $newData->tax2; $discount = $newData->discount; $sale_total = $newData->inv_total; $grand_total = $newData->total; $data = array( 'customer_id' => $customer_id, 'sale_data' => $sdata, 'count' => $item_count, 'tax1' => $tax1, 'tax2' => $tax2, 'discount' => $discount, 'inv_total' => $sale_total, 'g_total' => $grand_total ); } else { $data = NULL; } echo json_encode($data); } function suspended_sales() { if ($this->ion_auth->in_group(array('purchaser', 'viewer'))) { $this->session->set_flashdata('message', $this->lang->line("access_denied")); $data['message'] = (validation_errors() ? validation_errors() : $this->session->flashdata('message')); redirect('module=home', 'refresh'); } $data['message'] = (validation_errors() ? validation_errors() : $this->session->flashdata('message')); $data['success_message'] = $this->session->flashdata('success_message'); $meta['page_title'] = $this->lang->line("suspended_sales"); $data['page_title'] = $this->lang->line("suspended_sales"); $this->load->view('commons/header', $meta); $this->load->view('content', $data); $this->load->view('commons/footer'); } function getSuspendedSales() { $this->load->library('datatables'); $this->datatables ->select("suspended_bills.id as id, date, customers.name, count, tax1, tax2, discount, total") ->from('suspended_bills') ->join('customers', 'customers.id=suspended_bills.customer_id', 'left') ->group_by('suspended_bills.id'); $this->datatables->add_column("Actions", "<center><a class=\"tip\" title='".$this->lang->line("add_to_pos")."' href='index.php?module=pos&amp;suspend_id=$1'><i class=\"icon-plus-sign\"></i></a> <a class=\"tip\" title='".$this->lang->line("delete_suspended_sale")."' href='index.php?module=pos&amp;view=delete&amp;id=$1' onClick=\"return confirm('". $this->lang->line('alert_x_sale') ."')\"><i class=\"icon-trash\"></i></a></center>", "id") ->unset_column('id'); echo $this->datatables->generate(); } function delete($id = NULL) { $groups = array('admin', 'purchaser', 'salesman', 'viewer'); if ($this->ion_auth->in_group($groups)) { $this->session->set_flashdata('message', $this->lang->line("access_denied")); $data['message'] = (validation_errors() ? validation_errors() : $this->session->flashdata('message')); redirect('module=sales', 'refresh'); } if($this->input->get('id')){ $id = $this->input->get('id'); } else { $id = NULL; } if ( $this->pos_model->deleteSale($id) ) { $this->session->set_flashdata('success_message', $this->lang->line("suspended_sale_deleted")); redirect('module=pos&view=suspended_sales', 'refresh'); } } function add_customer() { $cusData = $this->input->post('data'); $this->load->helper('email'); $error = NULL; if (!empty($cusData[0]) && !empty($cusData[1]) && valid_email($cusData[3]) && !empty($cusData[4]) && !empty($cusData[5]) && !empty($cusData[6]) && !empty($cusData[7]) && !empty($cusData[8]) && !empty($cusData[2])) { $data = array('name' => $cusData[1], 'email' => $cusData[3], 'company' => $cusData[0], 'address' => $cusData[4], 'city' => $cusData[5], 'state' => $cusData[6], 'postal_code' => $cusData[7], 'country' => $cusData[8], 'phone' => $cusData[2] ); } else { $error = $this->lang->line("email")." ".$this->lang->line("is_required"); } if (empty($cusData[8])) {$error = $this->lang->line("country")." ".$this->lang->line("is_required"); } if (empty($cusData[7]) || !is_numeric($cusData[7])) {$error = $this->lang->line("postal_code")." ".$this->lang->line("is_required"); } if (empty($cusData[6])) {$error = $this->lang->line("state")." ".$this->lang->line("is_required"); } if (empty($cusData[5])) {$error = $this->lang->line("city")." ".$this->lang->line("is_required"); } if (empty($cusData[4])) {$error = $this->lang->line("address")." ".$this->lang->line("is_required"); } if (empty($cusData[2]) || !is_numeric($cusData[2])) {$error = $this->lang->line("phone")." ".$this->lang->line("is_required"); } if (empty($cusData[1])) {$error = $this->lang->line("name")." ".$this->lang->line("is_required"); } if (empty($cusData[0])) {$error = $this->lang->line("company")." ".$this->lang->line("is_required"); } if(!$error) { if ( $this->pos_model->addCustomer($data)) { echo $this->lang->line("customer_added"); } } else { echo $error; } } function email_receipt($sale_id = NULL) { if($this->input->post('id')){ $sale_id = $this->input->post('id'); } else { die(); } if($this->input->post('email')){ $to = $this->input->post('email'); } else { die(); } $data['message'] = (validation_errors() ? validation_errors() : $this->session->flashdata('message')); $data['rows'] = $this->pos_model->getAllInvoiceItems($sale_id); $inv = $this->pos_model->getInvoiceBySaleID($sale_id); $biller_id = $inv->biller_id; $customer_id = $inv->customer_id; $invoice_type_id = $inv->invoice_type; $data['biller'] = $this->pos_model->getBillerByID($biller_id); $data['customer'] = $this->pos_model->getCustomerByID($customer_id); $data['invoice_types_details'] = $this->pos_model->getInvoiceTypeByID($invoice_type_id); $data['pos'] = $this->pos_model->getSetting(); $data['inv'] = $inv; $data['sid'] = $sale_id; $data['page_title'] = $this->lang->line("invoice"); $receipt = $this->load->view('view', $data, TRUE); $user = $this->ion_auth->user()->row(); $this->load->library('email'); $config['mailtype'] = 'html'; $config['wordwrap'] = TRUE; $this->email->initialize($config); $this->email->from($user->email, $user->first_name." ".$user->last_name); $this->email->to($to); $this->email->subject('Receipt from '.SITE_NAME); $this->email->message($receipt); if($this->email->send()) { echo json_encode(array('msg' => $this->lang->line("email_sent"))); } else { echo json_encode(array('msg' => $this->lang->line("email_failed"))); } } } ------------ MODELS DO PDV ------------ <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); /* | ----------------------------------------------------- | PRODUCT NAME: SIMPLE POS | ----------------------------------------------------- | AUTHER: MIAN SALEEM | ----------------------------------------------------- | EMAIL: saleem@tecdiary.com | ----------------------------------------------------- | COPYRIGHTS: RESERVED BY TECDIARY IT SOLUTIONS | ----------------------------------------------------- | WEBSITE: http://tecdiary.net | ----------------------------------------------------- | | MODULE: POS | ----------------------------------------------------- | This is inventories module's model file. | ----------------------------------------------------- */ class Pos_model extends CI_Model { public function __construct() { parent::__construct(); } function getSetting() { $q = $this->db->get('pos_settings'); if( $q->num_rows() > 0 ) { return $q->row(); } return FALSE; } public function getAllCategories() { $q = $this->db->get('categories'); if($q->num_rows() > 0) { foreach (($q->result()) as $row) { $data[] = $row; } return $data; } } public function getNextAI() { $this->db->select_max('id'); $q = $this->db->get('sales'); if( $q->num_rows() > 0 ) { $row = $q->row(); //return SALES_REF."-".date('Y')."-".sprintf("%03s", $row->id+1); return SALES_REF."-".sprintf("%04s", $row->id+1); } return FALSE; } public function updateSetting($data) { $settingData = array( 'pro_limit' => $data['pro_limit'], 'default_category' => $data['category'], 'default_customer' => $data['customer'], 'default_biller' => $data['biller'], 'display_time' => $data['display_time'], 'cf_title1' => $data['cf_title1'], 'cf_title2' => $data['cf_title2'], 'cf_value1' => $data['cf_value1'], 'cf_value2' => $data['cf_value2'] ); $this->db->where('pos_id', '1'); if($this->db->update('pos_settings', $settingData)) { return true; } else { return false; } } public function products_count($category_id) { $this->db->where('category_id', $category_id)->from('products'); return $this->db->count_all_results(); } public function fetch_products($category_id, $limit, $start) { $this->db->limit($limit, $start); $this->db->where('category_id', $category_id); $this->db->order_by("name", "asc"); $query = $this->db->get("products"); if ($query->num_rows() > 0) { foreach ($query->result() as $row) { $data[] = $row; } return $data; } return false; } public function categories_count() { return $this->db->count_all("categories"); } public function fetch_categories($limit, $start) { $this->db->limit($limit, $start); $this->db->order_by("id", "asc"); $query = $this->db->get("categories"); if ($query->num_rows() > 0) { foreach ($query->result() as $row) { $data[] = $row; } return $data; } return false; } public function getProductsByCode($code) { $q = $this->db->query("SELECT * FROM products WHERE code LIKE '%{$code}%' ORDER BY code"); if($q->num_rows() > 0) { foreach (($q->result()) as $row) { $data[] = $row; } return $data; } } public function getProductByCode($code) { $q = $this->db->get_where('products', array('code' => $code), 1); if( $q->num_rows() > 0 ) { return $q->row(); } return FALSE; } public function getProductByName($name) { $q = $this->db->get_where('products', array('name' => $name), 1); if( $q->num_rows() > 0 ) { return $q->row(); } return FALSE; } public function getCustomerByName($name) { $q = $this->db->get_where('customers', array('name' => $name), 1); if( $q->num_rows() > 0 ) { return $q->row(); } return FALSE; } public function getAllBillers() { $q = $this->db->get('billers'); if($q->num_rows() > 0) { foreach (($q->result()) as $row) { $data[] = $row; } return $data; } } public function getBillerByID($id) { $q = $this->db->get_where('billers', array('id' => $id), 1); if( $q->num_rows() > 0 ) { return $q->row(); } return FALSE; } public function getAllCustomers() { $q = $this->db->get('customers'); if($q->num_rows() > 0) { foreach (($q->result()) as $row) { $data[] = $row; } return $data; } } public function getAllDiscounts() { $q = $this->db->get('discounts'); if($q->num_rows() > 0) { foreach (($q->result()) as $row) { $data[] = $row; } return $data; } } public function getDiscountByID($id) { $q = $this->db->get_where('discounts', array('id' => $id), 1); if( $q->num_rows() > 0 ) { return $q->row(); } return FALSE; } public function getCustomerByID($id) { $q = $this->db->get_where('customers', array('id' => $id), 1); if( $q->num_rows() > 0 ) { return $q->row(); } return FALSE; } public function getAllProducts() { $q = $this->db->query('SELECT * FROM products ORDER BY id'); if($q->num_rows() > 0) { foreach (($q->result()) as $row) { $data[] = $row; } return $data; } } public function getProductByID($id) { $q = $this->db->get_where('products', array('id' => $id), 1); if( $q->num_rows() > 0 ) { return $q->row(); } return FALSE; } public function getAllTaxRates() { $q = $this->db->get('tax_rates'); if($q->num_rows() > 0) { foreach (($q->result()) as $row) { $data[] = $row; } return $data; } } public function getTaxRateByID($id) { $q = $this->db->get_where('tax_rates', array('id' => $id), 1); if( $q->num_rows() > 0 ) { return $q->row(); } return FALSE; } public function getAllInvoiceTypes() { $q = $this->db->get('invoice_types'); if($q->num_rows() > 0) { foreach (($q->result()) as $row) { $data[] = $row; } return $data; } } public function getAllInvoiceTypesFor() { $q = $this->db->get_where('invoice_types', array('type' => 'real')); if($q->num_rows() > 0) { foreach (($q->result()) as $row) { $data[] = $row; } return $data; } } public function getInvoiceTypeByID($id) { $q = $this->db->get_where('invoice_types', array('id' => $id), 1); if( $q->num_rows() > 0 ) { return $q->row(); } return FALSE; } public function updateProductQuantity($product_id, $warehouse_id, $quantity) { // update the product with new details if($this->addQuantity($product_id, $warehouse_id, $quantity)) { return true; } return false; } public function calculateAndUpdateQuantity($item_id, $product_id, $quantity, $warehouse_id) { //check if entry exist then update else inster if($this->getProductQuantity($product_id, $warehouse_id)) { //get product details to calculate quantity $warehouse_quantity = $this->getProductQuantity($product_id, $warehouse_id); $warehouse_quantity = $warehouse_quantity['quantity']; $item_details = $this->getItemByID($item_id); $item_quantity = $item_details->quantity; $after_quantity = $warehouse_quantity + $item_quantity; $new_quantity = $after_quantity - $quantity; if($this->updateQuantity($product_id, $warehouse_id, $new_quantity)){ return TRUE; } } else { if($this->insertQuantity($product_id, $warehouse_id, -$quantity)){ return TRUE; } } return FALSE; } public function CalculateOldQuantity($item_id, $product_id, $quantity, $warehouse_id) { //get product details to calculate quantity $warehouse_quantity = $this->getProductQuantity($product_id, $warehouse_id); $warehouse_quantity = $warehouse_quantity['quantity']; $item_details = $this->getItemByID($item_id); $item_quantity = $item_details->quantity; $after_quantity = $warehouse_quantity + $item_quantity; if($this->updateQuantity($product_id, $warehouse_id, $after_quantity)){ return TRUE; } return FALSE; } public function addQuantity($product_id, $warehouse_id, $quantity) { //check if entry exist then update else inster if($this->getProductQuantity($product_id, $warehouse_id)) { $warehouse_quantity = $this->getProductQuantity($product_id, $warehouse_id); $old_quantity = $warehouse_quantity['quantity']; $new_quantity = $old_quantity - $quantity; if($this->updateQuantity($product_id, $warehouse_id, $new_quantity)){ return TRUE; } } else { if($this->insertQuantity($product_id, $warehouse_id, -$quantity)){ return TRUE; } } return FALSE; } public function insertQuantity($product_id, $warehouse_id, $quantity) { // Product data $productData = array( 'product_id' => $product_id, 'warehouse_id' => $warehouse_id, 'quantity' => $quantity ); if($this->db->insert('warehouses_products', $productData)) { return true; } else { return false; } } public function updateQuantity($product_id, $warehouse_id, $quantity) { $productData = array( 'quantity' => $quantity ); //$this->db->where('product_id', $id); if($this->db->update('warehouses_products', $productData, array('product_id' => $product_id, 'warehouse_id' => $warehouse_id))) { return true; } else { return false; } } public function getProductQuantity($product_id, $warehouse) { $q = $this->db->get_where('warehouses_products', array('product_id' => $product_id, 'warehouse_id' => $warehouse), 1); if( $q->num_rows() > 0 ) { return $q->row_array(); //$q->row(); } return FALSE; } public function getItemByID($id) { $q = $this->db->get_where('sale_items', array('id' => $id), 1); if( $q->num_rows() > 0 ) { return $q->row(); } return FALSE; } public function getAllSales() { $q = $this->db->get('sales'); if($q->num_rows() > 0) { foreach (($q->result()) as $row) { $data[] = $row; } return $data; } } public function sales_count() { return $this->db->count_all("sales"); } public function fetch_sales($limit, $start) { $this->db->limit($limit, $start); $this->db->order_by("id", "desc"); $query = $this->db->get("sales"); if ($query->num_rows() > 0) { foreach ($query->result() as $row) { $data[] = $row; } return $data; } return false; } public function getAllInvoiceItems($sale_id) { $q = $this->db->get_where('sale_items', array('sale_id' => $sale_id)); if($q->num_rows() > 0) { foreach (($q->result()) as $row) { $data[] = $row; } return $data; } } public function getAllSaleItems($id) { $q = $this->db->get_where('suspended_items', array('suspend_id' => $id)); if($q->num_rows() > 0) { foreach (($q->result()) as $row) { $data[] = $row; } return $data; } } public function getSaleByID($id) { $q = $this->db->get_where('suspended_bills', array('id' => $id), 1); if( $q->num_rows() > 0 ) { return $q->row(); } return FALSE; } public function getInvoiceByID($id) { $q = $this->db->get_where('sales', array('id' => $id), 1); if( $q->num_rows() > 0 ) { return $q->row(); } return FALSE; } public function getInvoiceBySaleID($sale_id) { $q = $this->db->get_where('sales', array('id' => $sale_id), 1); if( $q->num_rows() > 0 ) { return $q->row(); } return FALSE; } public function getQuoteByID($id) { $q = $this->db->get_where('quotes', array('id' => $id), 1); if( $q->num_rows() > 0 ) { return $q->row(); } return FALSE; } public function getQuoteByQID($id) { $this->db->select("reference_no, warehouse_id, biller_id, biller_name, customer_id, customer_name, date, note, inv_total, total_tax, total"); $this->db->from('quotes'); $this->db->where('id', $id); $this->db->limit(1); $q = $this->db->get(); if( $q->num_rows() > 0 ) { return $q->row_array(); } return FALSE; } public function getAllQuoteItems($quote_id) { $q = $this->db->get_where('quote_items', array('quote_id' => $quote_id)); if($q->num_rows() > 0) { foreach (($q->result()) as $row) { $data[] = $row; } return $data; } } public function addSale($saleDetails = array(), $items = array(), $warehouse_id, $sid = NULL) { // sale data $saleData = array( 'reference_no' => $saleDetails['reference_no'], 'warehouse_id' => $warehouse_id, 'biller_id' => $saleDetails['biller_id'], 'biller_name' => $saleDetails['biller_name'], 'customer_id' => $saleDetails['customer_id'], 'customer_name' => $saleDetails['customer_name'], 'date' => $saleDetails['date'], 'inv_total' => $saleDetails['inv_total'], 'total_tax' => $saleDetails['total_tax'], 'total' => $saleDetails['total'], 'total_tax2' => $saleDetails['total_tax2'], 'tax_rate2_id' => $saleDetails['tax_rate2_id'], 'inv_discount' => $saleDetails['inv_discount'], 'discount_id' => $saleDetails['discount_id'], 'user' => $saleDetails['user'], 'paid_by' => $saleDetails['paid_by'], 'count' => $saleDetails['count'], 'pos' => '1', 'paid' => $saleDetails['paid_val'], 'cc_no' => $saleDetails['cc_no_val'], 'cc_holder' => $saleDetails['cc_holder_val'], 'cheque_no' => $saleDetails['cheque_no_val'], ); if($this->db->insert('sales', $saleData)) { $sale_id = $this->db->insert_id(); foreach($items as $idata){ $this->nsQTY($idata['product_id'], $idata['quantity']); $this->updateProductQuantity($idata['product_id'], $warehouse_id, $idata['quantity']); } $addOn = array('sale_id' => $sale_id); end($addOn); foreach ( $items as &$var ) { $var = array_merge($addOn, $var); } if($this->db->insert_batch('sale_items', $items)) { if($sid) { $this->deleteSale($sid); } return $sale_id; } } return false; } public function nsQTY($product_id, $quantity) { $prD = $this->getProductByID($product_id); $nQTY = $prD->quantity - $quantity; $this->db->update('products', array('quantity' => $nQTY), array('id' => $product_id)); } /* public function addSale($invoice_type, $saleDetails = array(), $items = array(), $warehouse_id, $sid = NULL) { if($invoice_type == "real") { foreach($items as $data){ $product_id = $data['product_id']; $product_quantity = $data['quantity']; $this->updateProductQuantity($product_id, $warehouse_id, $product_quantity); } // sale data $saleData = array( 'reference_no' => $saleDetails['reference_no'], 'warehouse_id' => $warehouse_id, 'biller_id' => $saleDetails['biller_id'], 'biller_name' => $saleDetails['biller_name'], 'customer_id' => $saleDetails['customer_id'], 'customer_name' => $saleDetails['customer_name'], 'date' => $saleDetails['date'], 'inv_total' => $saleDetails['inv_total'], 'total_tax' => $saleDetails['total_tax'], 'total' => $saleDetails['total'], 'invoice_type' => $saleDetails['invoice_type'], 'in_type' => $saleDetails['in_type'], 'total_tax2' => $saleDetails['total_tax2'], 'tax_rate2_id' => $saleDetails['tax_rate2_id'], 'paid_by' => $saleDetails['paid_by'] ); if($this->db->insert('sales', $saleData)) { $sale_id = $this->db->insert_id(); $addOn = array('sale_id' => $sale_id); end($addOn); foreach ( $items as &$var ) { $var = array_merge($addOn, $var); } if($this->db->insert_batch('sale_items', $items)) { if($sid !== NULL) { $this->deleteSale($sid); } return $sale_id; } } } else { // sale data $saleData = array( 'reference_no' => $saleDetails['reference_no'], 'warehouse_id' => $warehouse_id, 'biller_id' => $saleDetails['biller_id'], 'biller_name' => $saleDetails['biller_name'], 'customer_id' => $saleDetails['customer_id'], 'customer_name' => $saleDetails['customer_name'], 'date' => $saleDetails['date'], 'inv_total' => $saleDetails['inv_total'], 'total_tax' => $saleDetails['total_tax'], 'total' => $saleDetails['total'], 'invoice_type' => $saleDetails['invoice_type'], 'in_type' => $saleDetails['in_type'], 'total_tax2' => $saleDetails['total_tax2'], 'tax_rate2_id' => $saleDetails['tax_rate2_id'] ); if($this->db->insert('quotes', $saleData)) { $sale_id = $this->db->insert_id(); $addOn = array('quote_id' => $sale_id); end($addOn); foreach ( $items as &$var ) { $var = array_merge($addOn, $var); } if($this->db->insert_batch('quote_items', $items)) { return $sale_id; } } else { return false; } } } */ public function getAllWarehouses() { $q = $this->db->get('warehouses'); if($q->num_rows() > 0) { foreach (($q->result()) as $row) { $data[] = $row; } return $data; } } public function getTodaySales() { $date = date('Y-m-d'); $myQuery = "SELECT DATE_FORMAT( date, '%W, %D %M %Y' ) AS date, SUM( COALESCE( total, 0 ) ) AS total FROM sales WHERE DATE(date) LIKE '{$date}'"; $q = $this->db->query($myQuery, false); if( $q->num_rows() > 0 ) { return $q->row(); } } public function getTodayCCSales() { $date = date('Y-m-d'); $myQuery = "SELECT SUM( COALESCE( total, 0 ) ) AS total FROM sales WHERE DATE(date) = '{$date}' AND paid_by = 'CC' GROUP BY date"; $q = $this->db->query($myQuery, false); if( $q->num_rows() > 0 ) { return $q->row(); } } public function getTodayCashSales() { $date = date('Y-m-d'); $myQuery = "SELECT SUM( COALESCE( total, 0 ) ) AS total FROM sales WHERE DATE(date) = '{$date}' AND paid_by = 'cash' GROUP BY date"; $q = $this->db->query($myQuery, false); if( $q->num_rows() > 0 ) { return $q->row(); } } public function getTodayChSales() { $date = date('Y-m-d'); $myQuery = "SELECT SUM( COALESCE( total, 0 ) ) AS total FROM sales WHERE DATE(date) = '{$date}' AND paid_by = 'Cheque' GROUP BY date"; $q = $this->db->query($myQuery, false); if( $q->num_rows() > 0 ) { return $q->row(); } } public function getDailySales($year, $month) { $myQuery = "SELECT DATE_FORMAT( date, '%e' ) AS date, SUM( COALESCE( total, 0 ) ) AS total FROM sales WHERE DATE_FORMAT( date, '%Y-%m' ) = '{$year}-{$month}' GROUP BY DATE_FORMAT( date, '%e' )"; $q = $this->db->query($myQuery, false); if($q->num_rows() > 0) { foreach (($q->result()) as $row) { $data[] = $row; } return $data; } } public function getMonthlySales($year) { $myQuery = "SELECT DATE_FORMAT( date, '%c' ) AS date, SUM( COALESCE( total, 0 ) ) AS total FROM sales WHERE DATE_FORMAT( date, '%Y' ) = '{$year}' GROUP BY date_format( date, '%c' ) ORDER BY date_format( date, '%c' ) ASC"; $q = $this->db->query($myQuery, false); if($q->num_rows() > 0) { foreach (($q->result()) as $row) { $data[] = $row; } return $data; } } public function getSuspendedBillByID($id) { $q = $this->db->get_where('suspended_bills', array('id' => $id)); if( $q->num_rows() > 0 ) { return $q->row(); } return FALSE; } public function suspendBill($customer_id, $saleData, $count, $tax1, $tax2, $total) { // bill data $billData = array( 'customer_id' => $customer_id, 'sale_data' => $saleData, 'count' => $count, 'tax1' => $tax1, 'tax2' => $tax2, 'total' => $total ); if( $this->db->insert('suspended_bills', $billData) ) { return true; } return FALSE; } public function suspendSale($saleDetails = array(), $items = array(), $count, $did = NULL) { if($did) { // sale data $saleData = array( 'count' => $count, 'customer_id' => $saleDetails['customer_id'], 'date' => $saleDetails['date'], 'total' => $saleDetails['inv_total'], 'tax1' => $saleDetails['total_tax'], 'total' => $saleDetails['total'], 'inv_total' => $saleDetails['inv_total'], 'tax2' => $saleDetails['total_tax2'], 'discount' => $saleDetails['inv_discount'] ); if($this->db->update('suspended_bills', $saleData, array('id' => $did)) && $this->db->delete('suspended_items', array('suspend_id' => $did))) { $addOn = array('suspend_id' => $did); end($addOn); foreach ( $items as &$var ) { $var = array_merge($addOn, $var); } if($this->db->insert_batch('suspended_items', $items)) { return TRUE; } } } else { // sale data $saleData = array( 'count' => $count, 'customer_id' => $saleDetails['customer_id'], 'date' => $saleDetails['date'], 'total' => $saleDetails['inv_total'], 'tax1' => $saleDetails['total_tax'], 'total' => $saleDetails['total'], 'inv_total' => $saleDetails['inv_total'], 'tax2' => $saleDetails['total_tax2'], 'discount' => $saleDetails['inv_discount'] ); if($this->db->insert('suspended_bills', $saleData)) { $suspend_id = $this->db->insert_id(); $addOn = array('suspend_id' => $suspend_id); end($addOn); foreach ( $items as &$var ) { $var = array_merge($addOn, $var); } if($this->db->insert_batch('suspended_items', $items)) { return TRUE; } } } return FALSE; } public function deleteSale($id) { if($this->db->delete('suspended_items', array('suspend_id' => $id)) && $this->db->delete('suspended_bills', array('id' => $id))) { return true; } return FALSE; } public function addCustomer($data) { if($this->db->insert('customers', $data)) { return true; } return false; } public function getWarehouseProductQuantity($warehouse_id, $product_id) { $q = $this->db->get_where('warehouses_products', array('warehouse_id' => $warehouse_id, 'product_id' => $product_id), 1); if( $q->num_rows() > 0 ) { return $q->row(); } return FALSE; } } ------------ VIEW DO PDV ------------ <!doctype html> <html> <head> <meta charset="utf-8"> <title><?php echo $page_title." ".$this->lang->line("no")." ".$inv->id; ?></title> <style type="text/css" media="all"> body { text-align:center; color:#000; font-family: Arial, Helvetica, sans-serif; font-size:12px; } #wrapper { width: 280px; margin: 0 auto; } #wrapper img { max-width: 250px; width: auto; } h3 { margin: 5px 0; } .left { width:60%; float:left; text-align:left; margin-bottom: 3px; } .right { width:40%; float:right; text-align:right; margin-bottom: 3px; } .table, .totals { width: 100%; margin:10px 0; } .table th { border-bottom: 1px solid #000; } .table td { padding:0; } .totals td { width: 24%; padding:0; } .table td:nth-child(2) { overflow:hidden; } @media print { #buttons { display: none; } #wrapper { max-width: 300px; width: 100%; margin: 0 auto; font-size:8px; } #wrapper img { max-width:250px; width: 80%; } } </style> </head> <body> <div id="wrapper"> <img src="<?php echo $this->config->base_url(); ?>assets/uploads/logos/<?php echo $biller->logo; ?>" alt="Biller Logo"> <h3 style="text-transform:uppercase;"><?php echo $biller->company; ?></h3> <?php echo "<p style=\"text-transform:capitalize;\">".$biller->address.", ".$biller->city.", ".$biller->postal_code.", ".$biller->state.", ".$biller->country."</p>"; echo "<span class=\"left\">".$this->lang->line("reference_no").": ".$inv->reference_no."</span> <span class=\"right\">".$this->lang->line("tel").": ".$biller->phone."</span>"; if($pos->cf_title1 != "" && $pos->cf_value1 != "") { echo "<span class=\"left\">".$pos->cf_title1.": ".$pos->cf_value1."</span>"; } if($pos->cf_title2 != "" && $pos->cf_value2 != "") { echo "<span class=\"right\">".$pos->cf_title2.": ".$pos->cf_value2."</span>"; } echo '<div style="clear:both;"></div>'; echo "<span class=\"left\">".$this->lang->line("customer").": ". $inv->customer_name."</span> <span class=\"right\">".$this->lang->line("date").": ".date(PHP_DATE, strtotime($inv->date))."</span>"; ?> <div style="clear:both;"></div> <table class="table" cellspacing="0" border="0"> <thead> <tr> <th><?php echo $this->lang->line("#"); ?></th> <th><?php echo $this->lang->line("description"); ?></th> <th><?php echo $this->lang->line("qty"); ?></th> <th><?php echo $this->lang->line("price"); ?></th> <th><?php echo $this->lang->line("total"); ?></th> </tr> </thead> <tbody> <?php $r = 1; foreach ($rows as $row):?> <tr> <td style="text-align:center; width:30px;"><?php echo $r; ?></td> <td style="text-align:left; width:180px;"><?php echo $row->product_name; ?></td> <td style="text-align:center; width:50px;"><?php echo $row->quantity; ?></td> <td style="text-align:right; width:55px; "><?php echo $this->ion_auth->formatMoney($row->unit_price); ?></td> <td style="text-align:right; width:65px;"><?php echo $this->ion_auth->formatMoney($row->gross_total); ?></td> </tr> <?php $r++; endforeach; ?> </tbody> </table> <table class="totals" cellspacing="0" border="0"> <tbody> <tr> <td style="text-align:left;"><?php echo $this->lang->line("total_items"); ?></td><td style="text-align:right; padding-right:1.5%; border-right: 1px solid #999;font-weight:bold;"><?php echo $inv->count; ?></td> <td style="text-align:left; padding-left:1.5%;">Total</td><td style="text-align:right;font-weight:bold;"><?php echo $this->ion_auth->formatMoney($inv->inv_total); ?></td> </tr> <tr> <?php if($inv->total_tax != 0 && TAX1) { ?> <td style="text-align:left;"><?php echo $this->lang->line("product_tax"); ?></td><td style="text-align:right; padding-right:1.5%; border-right: 1px solid #999;font-weight:bold;"><?php echo $this->ion_auth->formatMoney($inv->total_tax); ?></td> <?php } else { echo '<td></td>'; } ?> <?php if($inv->total_tax2 != 0 && TAX2) { ?> <td style="text-align:left; padding-left:1.5%;"><?php echo $this->lang->line("invoice_tax"); ?></td><td style="text-align:right;font-weight:bold;"><?php echo $this->ion_auth->formatMoney($inv->total_tax2); ?></td> <?php } else { echo '<td></td>'; } ?> </tr> <?php if($inv->inv_discount != 0 && DISCOUNT_OPTION) { ?><tr> <td colspan="2" style="text-align:left;"><?php echo $this->lang->line("discount"); ?></td><td colspan="2" style="text-align:right;font-weight:bold;"><?php echo $this->ion_auth->formatMoney($inv->inv_discount); ?></td> </tr><?php } ?> <tr> <td colspan="2" style="text-align:left; font-weight:bold; border-top:1px solid #000; padding-top:10px;"><?php echo $this->lang->line("total_payable"); ?></td><td colspan="2" style="border-top:1px solid #000; padding-top:10px; text-align:right; font-weight:bold;"><?php echo $this->ion_auth->formatMoney($inv->total); ?></td> </tr> <?php if($inv->paid_by == 'cash' && $inv->paid) { ?> <tr> <td colspan="2" style="text-align:left; font-weight:bold; padding-top:5px;"><?php echo $this->lang->line("paid"); ?></td><td colspan="2" style="padding-top:5px; text-align:right; font-weight:bold;"><?php echo $inv->paid; ?></td> </tr> <td colspan="2" style="text-align:left; font-weight:bold; padding-top:5px;"><?php echo $this->lang->line("change"); ?></td><td colspan="2" style="padding-top:5px; text-align:right; font-weight:bold;"><?php echo number_format(($inv->paid - $inv->total), 2, '.', ''); ?></td> </tr> <?php } if($inv->paid_by == 'CC' && $inv->cc_no) { ?> <tr> <td colspan="2" style="text-align:left; font-weight:bold; padding-top:5px;"><?php echo $this->lang->line("cc_no"); ?></td><td colspan="2" style="text-align:right; font-weight:bold;"><?php echo 'xxxx xxxx xxxx '.substr($inv->cc_no, -4); ?></td> </tr> <tr> <td colspan="2" style="text-align:left; font-weight:bold; padding-top:5px;"><?php echo $this->lang->line("cc_holder"); ?></td><td colspan="2" style="padding-top:5px; text-align:right; font-weight:bold;"><?php echo $inv->cc_holder; ?></td> </tr> <?php } if($inv->paid_by == 'Cheque' && $inv->cheque_no) { ?> <tr> <td colspan="2" style="text-align:left; font-weight:bold; padding-top:5px;"><?php echo $this->lang->line("cheque_no"); ?></td><td colspan="2" style="padding-top:5px; text-align:right; font-weight:bold;"><?php echo $inv->cheque_no; ?></td> </tr> <?php } ?> </tbody> </table> <div style="border-top:1px solid #000; padding-top:10px;"> <?php echo html_entity_decode($biller->invoice_footer); ?> </div> <div id="buttons" style="padding-top:10px; text-transform:uppercase;"> <span class="left"><a href="#" style="width:90%; display:block; font-size:12px; text-decoration: none; text-align:center; color:#000; background-color:#4FA950; border:2px solid #4FA950; padding: 10px 1px; font-weight:bold;" id="email"><?php echo $this->lang->line("email"); ?></a></span> <span class="right"><button type="button" onClick="window.print();return false;" style="width:100%; cursor:pointer; font-size:12px; background-color:#FFA93C; color:#000; text-align: center; border:1px solid #FFA93C; padding: 10px 1px; font-weight:bold;"><?php echo $this->lang->line("print"); ?></button></span> <div style="clear:both;"></div> <a href="<?php echo base_url(); ?>index.php?module=pos" style="width:98%; display:block; font-size:12px; text-decoration: none; text-align:center; color:#FFF; background-color:#007FFF; border:2px solid #007FFF; padding: 10px 1px; margin: 5px auto 10px auto; font-weight:bold;"><?php echo $this->lang->line("back_to_pos"); ?></a> <div style="clear:both;"></div> <div style="background:#F5F5F5; padding:10px;"> <p style="font-weight:bold;">Please don't forget to disble the header and footer in browser print settings.</p> <p style="text-transform: capitalize;"><strong>FF:</strong> File > Print Setup > Margin & Header/Footer Make all --blank--</p> <p style="text-transform: capitalize;"><strong>chrome:</strong> Menu > Print > Disable Header/Footer in Option & Set Margins to None</p> </div> <div style="clear:both;"></div> </div> </div> <script type="text/javascript" src="<?php echo base_url(); ?>assets/js/jquery.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('#email').click( function(){ var email = prompt("<?php echo $this->lang->line("email_address"); ?>","<?php echo $customer->email; ?>"); if (email!=null){ $.ajax({ type: "post", url: "index.php?module=pos&view=email_receipt", data: { <?php echo $this->security->get_csrf_token_name(); ?>: "<?php echo $this->security->get_csrf_hash(); ?>", email: email, id: <?php echo $inv->id; ?> }, dataType: "json", success: function(data) { alert(data.msg); }, error: function(){ alert('<?php echo $this->lang->line('ajax_request_failed'); ?>'); return false; } }); } return false; }); }); $(window).load(function() { window.print(); }); </script> </body> </html> Será que alguém pode me ajudar? Eu não sei aonde eu vou para que quando eu inicie a venda, eu possa editar o valor unitário do produto.
×
×
  • Criar Novo...