Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php defined("\102\101\x53\105\120\x41\124\x48") or die("\116\157\x20\x64\151\162\145\x..
Decoded Output download
<?php
defined("BASEPATH") or die("No direct script access allowed"); class Quotes extends MY_Controller { public function __construct() { parent::__construct(); if (!$this->loggedIn) { $this->session->set_userdata("requested_page", $this->uri->uri_string()); $this->sma->md("login"); } if ($this->Supplier) { $this->session->set_flashdata("warning", lang("access_denied")); redirect($_SERVER["HTTP_REFERER"]); } $this->lang->admin_load("quotations", $this->Settings->user_language); $this->load->library("form_validation"); $this->load->admin_model("quotes_model"); $this->digital_upload_path = "files/"; $this->digital_file_types = "zip|psd|ai|rar|pdf|doc|docx|xls|xlsx|ppt|pptx|gif|jpg|jpeg|png|tif|txt"; $this->allowed_file_size = "1024"; $this->data["logo"] = true; } public function add() { $this->sma->checkPermissions(); $this->form_validation->set_message("is_natural_no_zero", $this->lang->line("no_zero_required")); $this->form_validation->set_rules("customer", $this->lang->line("customer"), "required"); if ($this->form_validation->run() == true) { $reference = $this->input->post("reference_no") ? $this->input->post("reference_no") : $this->site->getReference("qu"); if ($this->Owner || $this->Admin) { $date = $this->sma->fld(trim($this->input->post("date"))); } else { $date = date("Y-m-d H:i:s"); } $warehouse_id = $this->input->post("warehouse"); $customer_id = $this->input->post("customer"); $biller_id = $this->input->post("biller"); $supplier_id = $this->input->post("supplier"); $status = $this->input->post("status"); $shipping = $this->input->post("shipping") ? $this->input->post("shipping") : 0; $customer_details = $this->site->getCompanyByID($customer_id); $customer = $customer_details->company && $customer_details->company != "-" ? $customer_details->company : $customer_details->name; $biller_details = $this->site->getCompanyByID($biller_id); $biller = $biller_details->company && $biller_details->company != "-" ? $biller_details->company : $biller_details->name; if ($supplier_id) { $supplier_details = $this->site->getCompanyByID($supplier_id); $supplier = $supplier_details->company && $supplier_details->company != "-" ? $supplier_details->company : $supplier_details->name; } else { $supplier = null; } $note = $this->sma->clear_tags($this->input->post("note")); $total = 0; $product_tax = 0; $product_discount = 0; $gst_data = array(); $total_cgst = $total_sgst = $total_igst = 0; $i = isset($_POST["product_code"]) ? sizeof($_POST["product_code"]) : 0; for ($r = 0; $r < $i; $r++) { $item_id = $_POST["product_id"][$r]; $item_type = $_POST["product_type"][$r]; $item_code = $_POST["product_code"][$r]; $item_name = $_POST["product_name"][$r]; $item_option = isset($_POST["product_option"][$r]) && $_POST["product_option"][$r] != "false" ? $_POST["product_option"][$r] : null; $real_unit_price = $this->sma->formatDecimal($_POST["real_unit_price"][$r]); $unit_price = $this->sma->formatDecimal($_POST["unit_price"][$r]); $item_unit_quantity = $_POST["quantity"][$r]; $item_tax_rate = $_POST["product_tax"][$r] ?? null; $item_discount = $_POST["product_discount"][$r] ?? null; $item_unit = $_POST["product_unit"][$r]; $item_quantity = $_POST["product_base_quantity"][$r]; if (isset($item_code) && isset($real_unit_price) && isset($unit_price) && isset($item_quantity)) { $product_details = $item_type != "manual" ? $this->quotes_model->getProductByCode($item_code) : null; $pr_discount = $this->site->calculateDiscount($item_discount, $unit_price); $unit_price = $this->sma->formatDecimal($unit_price - $pr_discount); $item_net_price = $unit_price; $pr_item_discount = $this->sma->formatDecimal($pr_discount * $item_unit_quantity); $product_discount += $pr_item_discount; $pr_item_tax = $item_tax = 0; $tax = ''; if (isset($item_tax_rate) && $item_tax_rate != 0) { $tax_details = $this->site->getTaxRateByID($item_tax_rate); $ctax = $this->site->calculateTax($product_details, $tax_details, $unit_price); $item_tax = $this->sma->formatDecimal($ctax["amount"]); $tax = $ctax["tax"]; if (!$product_details || !empty($product_details) && $product_details->tax_method != 1) { $item_net_price = $unit_price - $item_tax; } $pr_item_tax = $this->sma->formatDecimal($item_tax * $item_unit_quantity, 4); if ($this->Settings->indian_gst && ($gst_data = $this->gst->calculateIndianGST($pr_item_tax, $biller_details->state == $customer_details->state, $tax_details))) { $total_cgst += $gst_data["cgst"]; $total_sgst += $gst_data["sgst"]; $total_igst += $gst_data["igst"]; } } $product_tax += $pr_item_tax; $subtotal = $item_net_price * $item_unit_quantity + $pr_item_tax; $unit = $this->site->getUnitByID($item_unit); $product = array("product_id" => $item_id, "product_code" => $item_code, "product_name" => $item_name, "product_type" => $item_type, "option_id" => $item_option, "net_unit_price" => $item_net_price, "unit_price" => $this->sma->formatDecimal($item_net_price + $item_tax), "quantity" => $item_quantity, "product_unit_id" => $item_unit, "product_unit_code" => $unit->code, "unit_quantity" => $item_unit_quantity, "warehouse_id" => $warehouse_id, "item_tax" => $pr_item_tax, "tax_rate_id" => $item_tax_rate, "tax" => $tax, "discount" => $item_discount, "item_discount" => $pr_item_discount, "subtotal" => $this->sma->formatDecimal($subtotal), "real_unit_price" => $real_unit_price); $products[] = $product + $gst_data; $total += $this->sma->formatDecimal($item_net_price * $item_unit_quantity, 4); } } if (empty($products)) { $this->form_validation->set_rules("product", lang("order_items"), "required"); } else { krsort($products); } $order_discount = $this->site->calculateDiscount($this->input->post("discount"), $total + $product_tax, true); $total_discount = $this->sma->formatDecimal($order_discount + $product_discount, 4); $order_tax = $this->site->calculateOrderTax($this->input->post("order_tax"), $total + $product_tax - $order_discount); $total_tax = $this->sma->formatDecimal($product_tax + $order_tax, 4); $grand_total = $this->sma->formatDecimal($total + $total_tax + $this->sma->formatDecimal($shipping) - $order_discount, 4); $data = array("date" => $date, "reference_no" => $reference, "customer_id" => $customer_id, "customer" => $customer, "biller_id" => $biller_id, "biller" => $biller, "supplier_id" => $supplier_id, "supplier" => $supplier, "warehouse_id" => $warehouse_id, "note" => $note, "total" => $total, "product_discount" => $product_discount, "order_discount_id" => $this->input->post("discount"), "order_discount" => $order_discount, "total_discount" => $total_discount, "product_tax" => $product_tax, "order_tax_id" => $this->input->post("order_tax"), "order_tax" => $order_tax, "total_tax" => $total_tax, "shipping" => $this->sma->formatDecimal($shipping), "grand_total" => $grand_total, "status" => $status, "created_by" => $this->session->userdata("user_id"), "hash" => hash("sha256", microtime() . mt_rand())); if ($this->Settings->indian_gst) { $data["cgst"] = $total_cgst; $data["sgst"] = $total_sgst; $data["igst"] = $total_igst; } if ($_FILES["document"]["size"] > 0) { $this->load->library("upload"); $config["upload_path"] = $this->digital_upload_path; $config["allowed_types"] = $this->digital_file_types; $config["max_size"] = $this->allowed_file_size; $config["overwrite"] = false; $config["encrypt_name"] = true; $this->upload->initialize($config); if (!$this->upload->do_upload("document")) { $error = $this->upload->display_errors(); $this->session->set_flashdata("error", $error); redirect($_SERVER["HTTP_REFERER"]); } $photo = $this->upload->file_name; $data["attachment"] = $photo; } } if ($this->form_validation->run() == true && $this->quotes_model->addQuote($data, $products)) { $this->session->set_userdata("remove_quls", 1); $this->session->set_flashdata("message", $this->lang->line("quote_added")); admin_redirect("quotes"); } else { $this->data["error"] = validation_errors() ? validation_errors() : $this->session->flashdata("error"); $this->data["billers"] = $this->Owner || $this->Admin || !$this->session->userdata("biller_id") ? $this->site->getAllCompanies("biller") : null; $this->data["units"] = $this->site->getAllBaseUnits(); $this->data["tax_rates"] = $this->site->getAllTaxRates(); $this->data["warehouses"] = $this->Owner || $this->Admin || !$this->session->userdata("warehouse_id") ? $this->site->getAllWarehouses() : null; $this->data["qunumber"] = ''; $bc = array(array("link" => base_url(), "page" => lang("home")), array("link" => admin_url("quotes"), "page" => lang("quotes")), array("link" => "#", "page" => lang("add_quote"))); $meta = array("page_title" => lang("add_quote"), "bc" => $bc); $this->page_construct("quotes/add", $meta, $this->data); } } public function combine_pdf($quotes_id) { $this->sma->checkPermissions("pdf"); foreach ($quotes_id as $quote_id) { $this->data["error"] = validation_errors() ? validation_errors() : $this->session->flashdata("error"); $inv = $this->quotes_model->getQuoteByID($quote_id); if (!$this->session->userdata("view_right")) { $this->sma->view_rights($inv->created_by); } $this->data["rows"] = $this->quotes_model->getAllQuoteItems($quote_id); $this->data["customer"] = $this->site->getCompanyByID($inv->customer_id); $this->data["biller"] = $this->site->getCompanyByID($inv->biller_id); $this->data["user"] = $this->site->getUser($inv->created_by); $this->data["warehouse"] = $this->site->getWarehouseByID($inv->warehouse_id); $this->data["inv"] = $inv; $html[] = array("content" => $this->load->view($this->theme . "quotes/pdf", $this->data, true), "footer" => ''); } $name = lang("quotes") . ".pdf"; $this->sma->generate_pdf($html, $name); } public function delete($id = null) { $this->sma->checkPermissions(null, true); if ($this->input->get("id")) { $id = $this->input->get("id"); } if (!$id) { $this->sma->send_json(array("error" => 1, "msg" => lang("id_not_found"))); } if ($this->quotes_model->deleteQuote($id)) { if ($this->input->is_ajax_request()) { $this->sma->send_json(array("error" => 0, "msg" => lang("quote_deleted"))); } $this->session->set_flashdata("message", lang("quote_deleted")); admin_redirect("welcome"); } } public function edit($id = null) { $this->sma->checkPermissions(); if ($this->input->get("id")) { $id = $this->input->get("id"); } $inv = $this->quotes_model->getQuoteByID($id); if (!$this->session->userdata("edit_right")) { $this->sma->view_rights($inv->created_by); } $this->form_validation->set_message("is_natural_no_zero", $this->lang->line("no_zero_required")); $this->form_validation->set_rules("reference_no", $this->lang->line("reference_no"), "required"); $this->form_validation->set_rules("customer", $this->lang->line("customer"), "required"); if ($this->form_validation->run() == true) { $reference = $this->input->post("reference_no"); if ($this->Owner || $this->Admin) { $date = $this->sma->fld(trim($this->input->post("date"))); } else { $date = date("Y-m-d H:i:s"); } $warehouse_id = $this->input->post("warehouse"); $customer_id = $this->input->post("customer"); $biller_id = $this->input->post("biller"); $supplier_id = $this->input->post("supplier"); $status = $this->input->post("status"); $shipping = $this->input->post("shipping") ? $this->input->post("shipping") : 0; $customer_details = $this->site->getCompanyByID($customer_id); $customer = $customer_details->company && $customer_details->company != "-" ? $customer_details->company : $customer_details->name; $biller_details = $this->site->getCompanyByID($biller_id); $biller = $biller_details->company && $biller_details->company != "-" ? $biller_details->company : $biller_details->name; if ($supplier_id) { $supplier_details = $this->site->getCompanyByID($supplier_id); $supplier = $supplier_details->company && $supplier_details->company != "-" ? $supplier_details->company : $supplier_details->name; } else { $supplier = null; } $note = $this->sma->clear_tags($this->input->post("note")); $total = 0; $product_tax = 0; $product_discount = 0; $gst_data = array(); $total_cgst = $total_sgst = $total_igst = 0; $i = isset($_POST["product_code"]) ? sizeof($_POST["product_code"]) : 0; for ($r = 0; $r < $i; $r++) { $item_id = $_POST["product_id"][$r]; $item_type = $_POST["product_type"][$r]; $item_code = $_POST["product_code"][$r]; $item_name = $_POST["product_name"][$r]; $item_option = isset($_POST["product_option"][$r]) && $_POST["product_option"][$r] != "false" ? $_POST["product_option"][$r] : null; $real_unit_price = $this->sma->formatDecimal($_POST["real_unit_price"][$r]); $unit_price = $this->sma->formatDecimal($_POST["unit_price"][$r]); $item_unit_quantity = $_POST["quantity"][$r]; $item_tax_rate = $_POST["product_tax"][$r] ?? null; $item_discount = $_POST["product_discount"][$r] ?? null; $item_unit = $_POST["product_unit"][$r]; $item_quantity = $_POST["product_base_quantity"][$r]; if (isset($item_code) && isset($real_unit_price) && isset($unit_price) && isset($item_quantity)) { $product_details = $item_type != "manual" ? $this->quotes_model->getProductByCode($item_code) : null; $pr_discount = $this->site->calculateDiscount($item_discount, $unit_price); $unit_price = $this->sma->formatDecimal($unit_price - $pr_discount); $item_net_price = $unit_price; $pr_item_discount = $this->sma->formatDecimal($pr_discount * $item_unit_quantity); $product_discount += $pr_item_discount; $pr_item_tax = $item_tax = 0; $tax = ''; if (isset($item_tax_rate) && $item_tax_rate != 0) { $tax_details = $this->site->getTaxRateByID($item_tax_rate); $ctax = $this->site->calculateTax($product_details, $tax_details, $unit_price); $item_tax = $this->sma->formatDecimal($ctax["amount"]); $tax = $ctax["tax"]; if (!$product_details || !empty($product_details) && $product_details->tax_method != 1) { $item_net_price = $unit_price - $item_tax; } $pr_item_tax = $this->sma->formatDecimal($item_tax * $item_unit_quantity, 4); if ($this->Settings->indian_gst && ($gst_data = $this->gst->calculateIndianGST($pr_item_tax, $biller_details->state == $customer_details->state, $tax_details))) { $total_cgst += $gst_data["cgst"]; $total_sgst += $gst_data["sgst"]; $total_igst += $gst_data["igst"]; } } $product_tax += $pr_item_tax; $subtotal = $item_net_price * $item_unit_quantity + $pr_item_tax; $unit = $this->site->getUnitByID($item_unit); $product = array("product_id" => $item_id, "product_code" => $item_code, "product_name" => $item_name, "product_type" => $item_type, "option_id" => $item_option, "net_unit_price" => $item_net_price, "unit_price" => $this->sma->formatDecimal($item_net_price + $item_tax), "quantity" => $item_quantity, "product_unit_id" => $item_unit, "product_unit_code" => $unit->code, "unit_quantity" => $item_unit_quantity, "warehouse_id" => $warehouse_id, "item_tax" => $pr_item_tax, "tax_rate_id" => $item_tax_rate, "tax" => $tax, "discount" => $item_discount, "item_discount" => $pr_item_discount, "subtotal" => $this->sma->formatDecimal($subtotal), "real_unit_price" => $real_unit_price); $products[] = $product + $gst_data; $total += $this->sma->formatDecimal($item_net_price * $item_unit_quantity, 4); } } if (empty($products)) { $this->form_validation->set_rules("product", lang("order_items"), "required"); } else { krsort($products); } $order_discount = $this->site->calculateDiscount($this->input->post("discount"), $total + $product_tax, true); $total_discount = $this->sma->formatDecimal($order_discount + $product_discount, 4); $order_tax = $this->site->calculateOrderTax($this->input->post("order_tax"), $total + $product_tax - $order_discount); $total_tax = $this->sma->formatDecimal($product_tax + $order_tax, 4); $grand_total = $this->sma->formatDecimal($total + $total_tax + $this->sma->formatDecimal($shipping) - $order_discount, 4); $data = array("date" => $date, "reference_no" => $reference, "customer_id" => $customer_id, "customer" => $customer, "biller_id" => $biller_id, "biller" => $biller, "supplier_id" => $supplier_id, "supplier" => $supplier, "warehouse_id" => $warehouse_id, "note" => $note, "total" => $total, "product_discount" => $product_discount, "order_discount_id" => $this->input->post("discount"), "order_discount" => $order_discount, "total_discount" => $total_discount, "product_tax" => $product_tax, "order_tax_id" => $this->input->post("order_tax"), "order_tax" => $order_tax, "total_tax" => $total_tax, "shipping" => $shipping, "grand_total" => $grand_total, "status" => $status, "updated_by" => $this->session->userdata("user_id"), "updated_at" => date("Y-m-d H:i:s")); if ($this->Settings->indian_gst) { $data["cgst"] = $total_cgst; $data["sgst"] = $total_sgst; $data["igst"] = $total_igst; } if ($_FILES["document"]["size"] > 0) { $this->load->library("upload"); $config["upload_path"] = $this->digital_upload_path; $config["allowed_types"] = $this->digital_file_types; $config["max_size"] = $this->allowed_file_size; $config["overwrite"] = false; $config["encrypt_name"] = true; $this->upload->initialize($config); if (!$this->upload->do_upload("document")) { $error = $this->upload->display_errors(); $this->session->set_flashdata("error", $error); redirect($_SERVER["HTTP_REFERER"]); } $photo = $this->upload->file_name; $data["attachment"] = $photo; } } if ($this->form_validation->run() == true && $this->quotes_model->updateQuote($id, $data, $products)) { $this->session->set_userdata("remove_quls", 1); $this->session->set_flashdata("message", $this->lang->line("quote_added")); admin_redirect("quotes"); } else { $this->data["error"] = validation_errors() ? validation_errors() : $this->session->flashdata("error"); $this->data["inv"] = $this->quotes_model->getQuoteByID($id); $inv_items = $this->quotes_model->getAllQuoteItems($id); $c = rand(100000, 9999999); foreach ($inv_items as $item) { $row = $this->site->getProductByID($item->product_id); if (!$row) { $row = json_decode("{}"); $row->tax_method = 0; } else { unset($row->details, $row->product_details, $row->cost, $row->supplier1price, $row->supplier2price, $row->supplier3price, $row->supplier4price, $row->supplier5price); } $row->quantity = 0; $pis = $this->site->getPurchasedItems($item->product_id, $item->warehouse_id, $item->option_id); if ($pis) { foreach ($pis as $pi) { $row->quantity += $pi->quantity_balance; } } $row->id = $item->product_id; $row->code = $item->product_code; $row->name = $item->product_name; $row->type = $item->product_type; $row->base_quantity = $item->quantity; $row->base_unit = $row->unit ?? $item->product_unit_id; $row->base_unit_price = $row->price ?? $item->unit_price; $row->unit = $item->product_unit_id; $row->qty = $item->unit_quantity; $row->discount = $item->discount ? $item->discount : "0"; $row->item_tax = $item->item_tax > 0 ? $item->item_tax / $item->quantity : 0; $row->item_discount = $item->item_discount > 0 ? $item->item_discount / $item->quantity : 0; $row->unit_price = $row->tax_method ? $item->unit_price + $this->sma->formatDecimal($row->item_discount) + $this->sma->formatDecimal($row->item_tax) : $item->unit_price + $row->item_discount; $row->real_unit_price = $item->real_unit_price; $row->tax_rate = $item->tax_rate_id; $row->option = $item->option_id; $options = $this->quotes_model->getProductOptions($row->id, $item->warehouse_id, true); if ($options) { foreach ($options as $option) { $pis = $this->site->getPurchasedItems($row->id, $item->warehouse_id, $item->option_id); if ($pis) { $option->quantity = 0; foreach ($pis as $pi) { $option->quantity += $pi->quantity_balance; } } if ($row->option == $option->id) { $option->quantity += $item->quantity; } } } $combo_items = false; if ($row->type == "combo") { $combo_items = $this->quotes_model->getProductComboItems($row->id, $item->warehouse_id); foreach ($combo_items as $combo_item) { $combo_item->quantity = $combo_item->qty * $item->quantity; } } $units = $this->site->getUnitsByBUID($row->base_unit); $tax_rate = $this->site->getTaxRateByID($row->tax_rate); $ri = $this->Settings->item_addition ? $row->id : $c; $pr[$ri] = array("id" => $c, "item_id" => $row->id, "label" => $row->name . " (" . $row->code . ")", "row" => $row, "combo_items" => $combo_items, "tax_rate" => $tax_rate, "units" => $units, "options" => $options); $c++; } $this->data["inv_items"] = json_encode($pr); $this->data["id"] = $id; $this->data["billers"] = $this->Owner || $this->Admin || !$this->session->userdata("biller_id") ? $this->site->getAllCompanies("biller") : null; $this->data["units"] = $this->site->getAllBaseUnits(); $this->data["tax_rates"] = $this->site->getAllTaxRates(); $this->data["warehouses"] = $this->Owner || $this->Admin || !$this->session->userdata("warehouse_id") ? $this->site->getAllWarehouses() : null; $bc = array(array("link" => base_url(), "page" => lang("home")), array("link" => admin_url("quotes"), "page" => lang("quotes")), array("link" => "#", "page" => lang("edit_quote"))); $meta = array("page_title" => lang("edit_quote"), "bc" => $bc); $this->page_construct("quotes/edit", $meta, $this->data); } } public function email($quote_id = null) { $this->sma->checkPermissions(false, true); if ($this->input->get("id")) { $quote_id = $this->input->get("id"); } $inv = $this->quotes_model->getQuoteByID($quote_id); $this->form_validation->set_rules("to", $this->lang->line("to") . " " . $this->lang->line("email"), "trim|required|valid_email"); $this->form_validation->set_rules("subject", $this->lang->line("subject"), "trim|required"); $this->form_validation->set_rules("cc", $this->lang->line("cc"), "trim|valid_emails"); $this->form_validation->set_rules("bcc", $this->lang->line("bcc"), "trim|valid_emails"); $this->form_validation->set_rules("note", $this->lang->line("message"), "trim"); if ($this->form_validation->run() == true) { if (!$this->session->userdata("view_right")) { $this->sma->view_rights($inv->created_by); } $to = $this->input->post("to"); $subject = $this->input->post("subject"); if ($this->input->post("cc")) { $cc = $this->input->post("cc"); } else { $cc = null; } if ($this->input->post("bcc")) { $bcc = $this->input->post("bcc"); } else { $bcc = null; } $customer = $this->site->getCompanyByID($inv->customer_id); $biller = $this->site->getCompanyByID($inv->biller_id); $this->load->library("parser"); $parse_data = array("reference_number" => $inv->reference_no, "contact_person" => $customer->name, "company" => $customer->company, "site_link" => base_url(), "site_name" => $this->Settings->site_name, "logo" => "<img src="" . base_url() . "assets/uploads/logos/" . $biller->logo . "" alt="" . ($biller->company && $biller->company != "-" ? $biller->company : $biller->name) . ""/>"); $msg = $this->input->post("note"); $message = $this->parser->parse_string($msg, $parse_data); $attachment = $this->pdf($quote_id, null, "S"); try { if ($this->sma->send_email($to, $subject, $message, null, null, $attachment, $cc, $bcc)) { delete_files($attachment); $this->db->update("quotes", array("status" => "sent"), array("id" => $quote_id)); $this->session->set_flashdata("message", $this->lang->line("email_sent")); admin_redirect("quotes"); } } catch (Exception $e) { $this->session->set_flashdata("error", $e->getMessage()); redirect($_SERVER["HTTP_REFERER"]); } } elseif ($this->input->post("send_email")) { $this->data["error"] = validation_errors() ? validation_errors() : $this->session->flashdata("error"); $this->session->set_flashdata("error", $this->data["error"]); redirect($_SERVER["HTTP_REFERER"]); } else { $this->data["error"] = validation_errors() ? validation_errors() : $this->session->flashdata("error"); if (file_exists("./themes/" . $this->Settings->theme . "/admin/views/email_templates/quote.html")) { $quote_temp = file_get_contents("themes/" . $this->Settings->theme . "/admin/views/email_templates/quote.html"); } else { $quote_temp = file_get_contents("./themes/default/admin/views/email_templates/quote.html"); } $this->data["subject"] = array("name" => "subject", "id" => "subject", "type" => "text", "value" => $this->form_validation->set_value("subject", lang("quote") . " (" . $inv->reference_no . ") " . lang("from") . " " . $this->Settings->site_name)); $this->data["note"] = array("name" => "note", "id" => "note", "type" => "text", "value" => $this->form_validation->set_value("note", $quote_temp)); $this->data["customer"] = $this->site->getCompanyByID($inv->customer_id); $this->data["id"] = $quote_id; $this->data["modal_js"] = $this->site->modal_js(); $this->load->view($this->theme . "quotes/email", $this->data); } } public function getQuotes($warehouse_id = null) { $this->sma->checkPermissions("index"); if ((!$this->Owner || !$this->Admin) && !$warehouse_id) { $user = $this->site->getUser(); $warehouse_id = $user->warehouse_id; } $detail_link = anchor("admin/quotes/view/$1", "<i class="fa fa-file-text-o"></i> " . lang("quote_details")); $email_link = anchor("admin/quotes/email/$1", "<i class="fa fa-envelope"></i> " . lang("email_quote"), "data-toggle="modal" data-target="#myModal""); $edit_link = anchor("admin/quotes/edit/$1", "<i class="fa fa-edit"></i> " . lang("edit_quote")); $convert_link = anchor("admin/sales/add/$1", "<i class="fa fa-heart"></i> " . lang("create_sale")); $pc_link = anchor("admin/purchases/add/$1", "<i class="fa fa-star"></i> " . lang("create_purchase")); $pdf_link = anchor("admin/quotes/pdf/$1", "<i class="fa fa-file-pdf-o"></i> " . lang("download_pdf")); $delete_link = "<a href='#' class='po' title='<b>" . $this->lang->line("delete_quote") . "</b>' data-content="<p>" . lang("r_u_sure") . "</p><a class='btn btn-danger po-delete' href='" . admin_url("quotes/delete/$1") . "'>" . lang("i_m_sure") . "</a> <button class='btn po-close'>" . lang("no") . "</button>" rel='popover'><i class="fa fa-trash-o"></i> " . lang("delete_quote") . "</a>"; $action = "<div class="text-center"><div class="btn-group text-left">" . "<button type="button" class="btn btn-default btn-xs btn-primary dropdown-toggle" data-toggle="dropdown">" . lang("actions") . " <span class="caret"></span></button>\xa <ul class="dropdown-menu pull-right" role="menu">
<li>" . $detail_link . "</li>
<li>" . $edit_link . "</li>\xa <li>" . $convert_link . "</li>\xa <li>" . $pc_link . "</li>\xa <li>" . $pdf_link . "</li>
<li>" . $email_link . "</li>
<li>" . $delete_link . "</li>
</ul>
</div></div>"; $this->load->library("datatables"); if ($warehouse_id) { $this->datatables->select("id, date, reference_no, biller, customer, supplier, grand_total, status, attachment")->from("quotes")->where("warehouse_id", $warehouse_id); } else { $this->datatables->select("id, date, reference_no, biller, customer, supplier, grand_total, status, attachment")->from("quotes"); } if (!$this->Customer && !$this->Supplier && !$this->Owner && !$this->Admin && !$this->session->userdata("view_right")) { $this->datatables->where("created_by", $this->session->userdata("user_id")); } elseif ($this->Customer) { $this->datatables->where("customer_id", $this->session->userdata("user_id")); } $this->datatables->add_column("Actions", $action, "id"); echo $this->datatables->generate(); } public function index($warehouse_id = null) { $this->sma->checkPermissions(); $this->data["error"] = validation_errors() ? validation_errors() : $this->session->flashdata("error"); if ($this->Owner || $this->Admin || !$this->session->userdata("warehouse_id")) { $this->data["warehouses"] = $this->site->getAllWarehouses(); $this->data["warehouse_id"] = $warehouse_id; $this->data["warehouse"] = $warehouse_id ? $this->site->getWarehouseByID($warehouse_id) : null; } else { $this->data["warehouses"] = null; $this->data["warehouse_id"] = $this->session->userdata("warehouse_id"); $this->data["warehouse"] = $this->session->userdata("warehouse_id") ? $this->site->getWarehouseByID($this->session->userdata("warehouse_id")) : null; } $bc = array(array("link" => base_url(), "page" => lang("home")), array("link" => "#", "page" => lang("quotes"))); $meta = array("page_title" => lang("quotes"), "bc" => $bc); $this->page_construct("quotes/index", $meta, $this->data); } public function modal_view($quote_id = null) { $this->sma->checkPermissions("index", true); if ($this->input->get("id")) { $quote_id = $this->input->get("id"); } $this->data["error"] = validation_errors() ? validation_errors() : $this->session->flashdata("error"); $inv = $this->quotes_model->getQuoteByID($quote_id); if (!$this->session->userdata("view_right")) { $this->sma->view_rights($inv->created_by, true); } $this->data["rows"] = $this->quotes_model->getAllQuoteItems($quote_id); $this->data["customer"] = $this->site->getCompanyByID($inv->customer_id); $this->data["biller"] = $this->site->getCompanyByID($inv->biller_id); $this->data["created_by"] = $this->site->getUser($inv->created_by); $this->data["updated_by"] = $inv->updated_by ? $this->site->getUser($inv->updated_by) : null; $this->data["warehouse"] = $this->site->getWarehouseByID($inv->warehouse_id); $this->data["inv"] = $inv; $this->load->view($this->theme . "quotes/modal_view", $this->data); } public function pdf($quote_id = null, $view = null, $save_bufffer = null) { $this->sma->checkPermissions(); if ($this->input->get("id")) { $quote_id = $this->input->get("id"); } $this->data["error"] = validation_errors() ? validation_errors() : $this->session->flashdata("error"); $inv = $this->quotes_model->getQuoteByID($quote_id); if (!$this->session->userdata("view_right")) { $this->sma->view_rights($inv->created_by); } $this->data["rows"] = $this->quotes_model->getAllQuoteItems($quote_id); $this->data["customer"] = $this->site->getCompanyByID($inv->customer_id); $this->data["biller"] = $this->site->getCompanyByID($inv->biller_id); $this->data["created_by"] = $this->site->getUser($inv->created_by); $this->data["warehouse"] = $this->site->getWarehouseByID($inv->warehouse_id); $this->data["inv"] = $inv; $name = $this->lang->line("quote") . "_" . str_replace("/", "_", $inv->reference_no) . ".pdf"; $html = $this->load->view($this->theme . "quotes/pdf", $this->data, true); if (!$this->Settings->barcode_img) { $html = preg_replace("'\<\?xml(.*)\?\>'", '', $html); } if ($view) { $this->load->view($this->theme . "quotes/pdf", $this->data); } elseif ($save_bufffer) { return $this->sma->generate_pdf($html, $name, $save_bufffer); } else { $this->sma->generate_pdf($html, $name); } } public function quote_actions() { if (!$this->Owner && !$this->GP["bulk_actions"]) { $this->session->set_flashdata("warning", lang("access_denied")); redirect($_SERVER["HTTP_REFERER"]); } $this->form_validation->set_rules("form_action", lang("form_action"), "required"); if ($this->form_validation->run() == true) { if (!empty($_POST["val"])) { if ($this->input->post("form_action") == "delete") { $this->sma->checkPermissions("delete"); foreach ($_POST["val"] as $id) { $this->quotes_model->deleteQuote($id); } $this->session->set_flashdata("message", $this->lang->line("quotes_deleted")); redirect($_SERVER["HTTP_REFERER"]); } elseif ($this->input->post("form_action") == "combine") { $html = $this->combine_pdf($_POST["val"]); } elseif ($this->input->post("form_action") == "export_excel") { $this->load->library("excel"); $this->excel->setActiveSheetIndex(0); $this->excel->getActiveSheet()->setTitle(lang("quotes")); $this->excel->getActiveSheet()->SetCellValue("A1", lang("date")); $this->excel->getActiveSheet()->SetCellValue("B1", lang("reference_no")); $this->excel->getActiveSheet()->SetCellValue("C1", lang("biller")); $this->excel->getActiveSheet()->SetCellValue("D1", lang("customer")); $this->excel->getActiveSheet()->SetCellValue("E1", lang("total")); $this->excel->getActiveSheet()->SetCellValue("F1", lang("status")); $row = 2; foreach ($_POST["val"] as $id) { $qu = $this->quotes_model->getQuoteByID($id); $this->excel->getActiveSheet()->SetCellValue("A" . $row, $this->sma->hrld($qu->date)); $this->excel->getActiveSheet()->SetCellValue("B" . $row, $qu->reference_no); $this->excel->getActiveSheet()->SetCellValue("C" . $row, $qu->biller); $this->excel->getActiveSheet()->SetCellValue("D" . $row, $qu->customer); $this->excel->getActiveSheet()->SetCellValue("E" . $row, $qu->total); $this->excel->getActiveSheet()->SetCellValue("F" . $row, $qu->status); $row++; } $this->excel->getActiveSheet()->getColumnDimension("A")->setWidth(20); $this->excel->getActiveSheet()->getColumnDimension("B")->setWidth(20); $this->excel->getDefaultStyle()->getAlignment()->setVertical("center"); $filename = "quotations_" . date("Y_m_d_H_i_s"); $this->load->helper("excel"); create_excel($this->excel, $filename); } } else { $this->session->set_flashdata("error", $this->lang->line("no_quote_selected")); redirect($_SERVER["HTTP_REFERER"]); } } else { $this->session->set_flashdata("error", validation_errors()); redirect($_SERVER["HTTP_REFERER"]); } } public function suggestions() { $term = $this->input->get("term", true); $warehouse_id = $this->input->get("warehouse_id", true); $customer_id = $this->input->get("customer_id", true); if (strlen($term) < 1 || !$term) { die("<script type='text/javascript'>setTimeout(function(){ window.top.location.href = '" . admin_url("welcome") . "'; }, 10);</script>"); } $analyzed = $this->sma->analyze_term($term); $sr = $analyzed["term"]; $sr = addslashes($sr); $strict = $analyzed["strict"] ?? false; $qty = $strict ? null : $analyzed["quantity"] ?? null; $bprice = $strict ? null : $analyzed["price"] ?? null; $option_id = $analyzed["option_id"]; $warehouse = $this->site->getWarehouseByID($warehouse_id); $customer = $this->site->getCompanyByID($customer_id); $customer_group = $this->site->getCustomerGroupByID($customer->customer_group_id); $rows = $this->quotes_model->getProductNames($sr, $warehouse_id); if ($rows) { $r = 0; foreach ($rows as $row) { $c = uniqid(mt_rand(), true); unset($row->cost, $row->details, $row->product_details, $row->image, $row->barcode_symbology, $row->cf1, $row->cf2, $row->cf3, $row->cf4, $row->cf5, $row->cf6, $row->supplier1price, $row->supplier2price, $row->cfsupplier3price, $row->supplier4price, $row->supplier5price, $row->supplier1, $row->supplier2, $row->supplier3, $row->supplier4, $row->supplier5, $row->supplier1_part_no, $row->supplier2_part_no, $row->supplier3_part_no, $row->supplier4_part_no, $row->supplier5_part_no); $option = false; $row->quantity = 0; $row->item_tax_method = $row->tax_method; $row->qty = 1; $row->discount = "0"; $options = $this->quotes_model->getProductOptions($row->id, $warehouse_id); if ($options) { $opt = $option_id && $r == 0 ? $this->quotes_model->getProductOptionByID($option_id) : $options[0]; if (!$option_id || $r > 0) { $option_id = $opt->id; } } else { $opt = json_decode("{}"); $opt->price = 0; $option_id = false; } $row->option = $option_id; $pis = $this->site->getPurchasedItems($row->id, $warehouse_id, $row->option); if ($pis) { foreach ($pis as $pi) { $row->quantity += $pi->quantity_balance; } } if ($options) { $option_quantity = 0; foreach ($options as $option) { $pis = $this->site->getPurchasedItems($row->id, $warehouse_id, $row->option); if ($pis) { foreach ($pis as $pi) { $option_quantity += $pi->quantity_balance; } } if ($option->quantity > $option_quantity) { $option->quantity = $option_quantity; } } } if ($row->promotion) { $row->price = $row->promo_price; } elseif ($customer->price_group_id) { if ($pr_group_price = $this->site->getProductGroupPrice($row->id, $customer->price_group_id)) { $row->price = $pr_group_price->price; } } elseif ($warehouse->price_group_id) { if ($pr_group_price = $this->site->getProductGroupPrice($row->id, $warehouse->price_group_id)) { $row->price = $pr_group_price->price; } } if ($customer_group->discount && $customer_group->percent < 0) { $row->discount = 0 - $customer_group->percent . "%"; } else { $row->price = $row->price + $row->price * $customer_group->percent / 100; } $row->real_unit_price = $row->price; $row->base_quantity = 1; $row->base_unit = $row->unit; $row->base_unit_price = $row->price; $row->unit = $row->sale_unit ? $row->sale_unit : $row->unit; $combo_items = false; if ($row->type == "combo") { $combo_items = $this->quotes_model->getProductComboItems($row->id, $warehouse_id); } if ($qty) { $row->qty = $qty; $row->base_quantity = $qty; } else { $row->qty = $bprice ? $bprice / $row->price : 1; } $units = $this->site->getUnitsByBUID($row->base_unit); $tax_rate = $this->site->getTaxRateByID($row->tax_rate); $pr[] = array("id" => sha1($c . $r), "item_id" => $row->id, "label" => $row->name . " (" . $row->code . ")", "category" => $row->category_id, "row" => $row, "combo_items" => $combo_items, "tax_rate" => $tax_rate, "units" => $units, "options" => $options); $r++; } $this->sma->send_json($pr); } else { $this->sma->send_json(array(array("id" => 0, "label" => lang("no_match_found"), "value" => $term))); } } public function update_status($id) { $this->form_validation->set_rules("status", lang("status"), "required"); if ($this->form_validation->run() == true) { $status = $this->input->post("status"); $note = $this->sma->clear_tags($this->input->post("note")); } elseif ($this->input->post("update")) { $this->session->set_flashdata("error", validation_errors()); admin_redirect($_SERVER["HTTP_REFERER"] ?? "sales"); } if ($this->form_validation->run() == true && $this->quotes_model->updateStatus($id, $status, $note)) { $this->session->set_flashdata("message", lang("status_updated")); admin_redirect($_SERVER["HTTP_REFERER"] ?? "sales"); } else { $this->data["inv"] = $this->quotes_model->getQuoteByID($id); $this->data["modal_js"] = $this->site->modal_js(); $this->load->view($this->theme . "quotes/update_status", $this->data); } } public function view($quote_id = null) { $this->sma->checkPermissions("index"); if ($this->input->get("id")) { $quote_id = $this->input->get("id"); } $this->data["error"] = validation_errors() ? validation_errors() : $this->session->flashdata("error"); $inv = $this->quotes_model->getQuoteByID($quote_id); if (!$this->session->userdata("view_right")) { $this->sma->view_rights($inv->created_by); } $this->data["rows"] = $this->quotes_model->getAllQuoteItems($quote_id); $this->data["customer"] = $this->site->getCompanyByID($inv->customer_id); $this->data["biller"] = $this->site->getCompanyByID($inv->biller_id); $this->data["created_by"] = $this->site->getUser($inv->created_by); $this->data["updated_by"] = $inv->updated_by ? $this->site->getUser($inv->updated_by) : null; $this->data["warehouse"] = $this->site->getWarehouseByID($inv->warehouse_id); $this->data["inv"] = $inv; $bc = array(array("link" => base_url(), "page" => lang("home")), array("link" => admin_url("quotes"), "page" => lang("quotes")), array("link" => "#", "page" => lang("view"))); $meta = array("page_title" => lang("view_quote_details"), "bc" => $bc); $this->page_construct("quotes/view", $meta, $this->data); } } ?>
Did this file decode correctly?
Original Code
<?php
defined("\102\101\x53\105\120\x41\124\x48") or die("\116\157\x20\x64\151\162\145\x63\164\40\x73\x63\x72\151\x70\x74\x20\x61\x63\143\x65\163\x73\40\141\154\154\157\x77\145\x64"); class Quotes extends MY_Controller { public function __construct() { parent::__construct(); if (!$this->loggedIn) { $this->session->set_userdata("\x72\x65\x71\165\145\x73\x74\145\144\x5f\160\141\x67\x65", $this->uri->uri_string()); $this->sma->md("\154\x6f\147\x69\x6e"); } if ($this->Supplier) { $this->session->set_flashdata("\167\x61\x72\x6e\151\x6e\147", lang("\141\143\143\x65\x73\x73\137\x64\145\x6e\x69\145\144")); redirect($_SERVER["\x48\124\x54\120\x5f\x52\x45\106\x45\x52\x45\122"]); } $this->lang->admin_load("\161\x75\157\164\x61\164\151\x6f\156\x73", $this->Settings->user_language); $this->load->library("\x66\157\x72\155\x5f\x76\141\x6c\x69\x64\141\x74\151\157\156"); $this->load->admin_model("\161\x75\157\164\145\x73\x5f\155\157\144\x65\x6c"); $this->digital_upload_path = "\x66\151\x6c\145\163\x2f"; $this->digital_file_types = "\172\151\160\x7c\x70\x73\x64\x7c\x61\x69\x7c\162\141\x72\x7c\x70\144\146\x7c\x64\x6f\x63\174\144\x6f\143\170\174\170\x6c\x73\174\x78\x6c\x73\x78\x7c\160\160\164\174\x70\160\x74\x78\174\x67\151\146\174\152\160\x67\174\152\160\x65\147\174\x70\x6e\x67\x7c\x74\151\x66\x7c\164\x78\x74"; $this->allowed_file_size = "\61\x30\62\x34"; $this->data["\x6c\x6f\x67\157"] = true; } public function add() { $this->sma->checkPermissions(); $this->form_validation->set_message("\151\163\x5f\156\141\x74\165\x72\x61\x6c\137\156\157\x5f\x7a\145\162\157", $this->lang->line("\156\157\x5f\172\145\x72\x6f\x5f\x72\145\161\x75\151\x72\x65\144")); $this->form_validation->set_rules("\x63\x75\x73\164\157\x6d\145\162", $this->lang->line("\143\165\163\164\x6f\155\145\162"), "\x72\x65\161\165\x69\x72\145\x64"); if ($this->form_validation->run() == true) { $reference = $this->input->post("\x72\x65\x66\x65\x72\145\156\x63\x65\x5f\156\x6f") ? $this->input->post("\x72\145\146\x65\x72\x65\x6e\143\145\x5f\156\x6f") : $this->site->getReference("\x71\165"); if ($this->Owner || $this->Admin) { $date = $this->sma->fld(trim($this->input->post("\x64\141\x74\145"))); } else { $date = date("\x59\x2d\x6d\55\x64\x20\110\x3a\151\x3a\163"); } $warehouse_id = $this->input->post("\x77\141\162\x65\x68\x6f\165\163\x65"); $customer_id = $this->input->post("\143\165\163\164\157\155\145\162"); $biller_id = $this->input->post("\x62\151\154\154\x65\x72"); $supplier_id = $this->input->post("\x73\x75\x70\x70\154\151\145\162"); $status = $this->input->post("\163\164\141\x74\x75\163"); $shipping = $this->input->post("\x73\150\151\x70\x70\151\156\x67") ? $this->input->post("\x73\150\x69\160\x70\151\156\x67") : 0; $customer_details = $this->site->getCompanyByID($customer_id); $customer = $customer_details->company && $customer_details->company != "\55" ? $customer_details->company : $customer_details->name; $biller_details = $this->site->getCompanyByID($biller_id); $biller = $biller_details->company && $biller_details->company != "\55" ? $biller_details->company : $biller_details->name; if ($supplier_id) { $supplier_details = $this->site->getCompanyByID($supplier_id); $supplier = $supplier_details->company && $supplier_details->company != "\x2d" ? $supplier_details->company : $supplier_details->name; } else { $supplier = null; } $note = $this->sma->clear_tags($this->input->post("\x6e\x6f\x74\x65")); $total = 0; $product_tax = 0; $product_discount = 0; $gst_data = array(); $total_cgst = $total_sgst = $total_igst = 0; $i = isset($_POST["\x70\162\x6f\144\x75\143\164\137\143\157\144\145"]) ? sizeof($_POST["\x70\x72\x6f\x64\165\143\x74\137\x63\x6f\144\x65"]) : 0; for ($r = 0; $r < $i; $r++) { $item_id = $_POST["\x70\x72\157\144\x75\x63\x74\137\x69\144"][$r]; $item_type = $_POST["\160\x72\x6f\144\x75\x63\164\x5f\164\171\160\145"][$r]; $item_code = $_POST["\x70\x72\x6f\x64\x75\143\164\137\x63\157\144\145"][$r]; $item_name = $_POST["\x70\162\x6f\x64\165\x63\x74\x5f\x6e\141\x6d\145"][$r]; $item_option = isset($_POST["\160\162\x6f\144\165\143\x74\x5f\157\x70\164\x69\x6f\156"][$r]) && $_POST["\160\162\x6f\x64\x75\143\164\137\157\x70\x74\151\157\x6e"][$r] != "\146\141\x6c\163\145" ? $_POST["\160\162\x6f\144\165\143\x74\x5f\157\x70\164\x69\x6f\156"][$r] : null; $real_unit_price = $this->sma->formatDecimal($_POST["\x72\x65\x61\154\x5f\165\156\151\x74\x5f\x70\162\151\x63\145"][$r]); $unit_price = $this->sma->formatDecimal($_POST["\x75\156\x69\164\137\160\162\x69\x63\x65"][$r]); $item_unit_quantity = $_POST["\161\x75\x61\156\164\151\164\x79"][$r]; $item_tax_rate = $_POST["\160\162\x6f\144\x75\x63\164\x5f\164\x61\170"][$r] ?? null; $item_discount = $_POST["\160\x72\x6f\144\165\x63\164\x5f\144\151\x73\x63\157\x75\x6e\164"][$r] ?? null; $item_unit = $_POST["\160\162\x6f\144\165\143\164\137\165\x6e\151\x74"][$r]; $item_quantity = $_POST["\160\x72\157\144\x75\x63\164\137\142\x61\163\x65\x5f\161\165\x61\x6e\x74\151\x74\171"][$r]; if (isset($item_code) && isset($real_unit_price) && isset($unit_price) && isset($item_quantity)) { $product_details = $item_type != "\155\141\156\x75\x61\x6c" ? $this->quotes_model->getProductByCode($item_code) : null; $pr_discount = $this->site->calculateDiscount($item_discount, $unit_price); $unit_price = $this->sma->formatDecimal($unit_price - $pr_discount); $item_net_price = $unit_price; $pr_item_discount = $this->sma->formatDecimal($pr_discount * $item_unit_quantity); $product_discount += $pr_item_discount; $pr_item_tax = $item_tax = 0; $tax = ''; if (isset($item_tax_rate) && $item_tax_rate != 0) { $tax_details = $this->site->getTaxRateByID($item_tax_rate); $ctax = $this->site->calculateTax($product_details, $tax_details, $unit_price); $item_tax = $this->sma->formatDecimal($ctax["\141\x6d\157\165\x6e\164"]); $tax = $ctax["\x74\141\x78"]; if (!$product_details || !empty($product_details) && $product_details->tax_method != 1) { $item_net_price = $unit_price - $item_tax; } $pr_item_tax = $this->sma->formatDecimal($item_tax * $item_unit_quantity, 4); if ($this->Settings->indian_gst && ($gst_data = $this->gst->calculateIndianGST($pr_item_tax, $biller_details->state == $customer_details->state, $tax_details))) { $total_cgst += $gst_data["\143\147\x73\x74"]; $total_sgst += $gst_data["\x73\x67\x73\164"]; $total_igst += $gst_data["\x69\x67\163\164"]; } } $product_tax += $pr_item_tax; $subtotal = $item_net_price * $item_unit_quantity + $pr_item_tax; $unit = $this->site->getUnitByID($item_unit); $product = array("\x70\162\157\144\x75\143\x74\x5f\151\x64" => $item_id, "\x70\x72\x6f\144\x75\143\164\137\143\x6f\144\x65" => $item_code, "\x70\162\157\x64\x75\143\164\x5f\x6e\141\155\x65" => $item_name, "\160\x72\157\144\x75\x63\164\x5f\164\x79\x70\x65" => $item_type, "\x6f\160\x74\151\157\x6e\137\151\144" => $item_option, "\x6e\145\164\x5f\x75\156\151\164\137\160\162\151\143\145" => $item_net_price, "\165\156\x69\164\x5f\160\x72\151\143\145" => $this->sma->formatDecimal($item_net_price + $item_tax), "\x71\165\x61\156\x74\151\164\171" => $item_quantity, "\x70\162\157\144\165\x63\x74\x5f\165\156\151\x74\137\151\144" => $item_unit, "\160\x72\x6f\144\x75\143\x74\137\165\x6e\x69\x74\x5f\x63\157\x64\x65" => $unit->code, "\x75\x6e\151\x74\137\161\x75\141\156\164\151\x74\171" => $item_unit_quantity, "\167\141\162\x65\150\x6f\x75\163\145\x5f\x69\x64" => $warehouse_id, "\x69\164\145\x6d\137\164\x61\x78" => $pr_item_tax, "\164\141\170\137\x72\x61\x74\145\137\x69\x64" => $item_tax_rate, "\x74\x61\x78" => $tax, "\x64\x69\x73\143\x6f\x75\156\164" => $item_discount, "\151\x74\145\x6d\137\144\151\163\x63\x6f\x75\x6e\x74" => $pr_item_discount, "\x73\165\142\x74\157\164\141\x6c" => $this->sma->formatDecimal($subtotal), "\x72\x65\141\x6c\x5f\165\156\x69\x74\x5f\160\162\x69\x63\x65" => $real_unit_price); $products[] = $product + $gst_data; $total += $this->sma->formatDecimal($item_net_price * $item_unit_quantity, 4); } } if (empty($products)) { $this->form_validation->set_rules("\x70\x72\x6f\x64\x75\x63\164", lang("\157\162\144\x65\x72\x5f\151\164\x65\x6d\x73"), "\x72\x65\x71\x75\151\x72\145\x64"); } else { krsort($products); } $order_discount = $this->site->calculateDiscount($this->input->post("\144\151\x73\143\x6f\165\x6e\164"), $total + $product_tax, true); $total_discount = $this->sma->formatDecimal($order_discount + $product_discount, 4); $order_tax = $this->site->calculateOrderTax($this->input->post("\x6f\x72\x64\145\162\x5f\x74\x61\x78"), $total + $product_tax - $order_discount); $total_tax = $this->sma->formatDecimal($product_tax + $order_tax, 4); $grand_total = $this->sma->formatDecimal($total + $total_tax + $this->sma->formatDecimal($shipping) - $order_discount, 4); $data = array("\x64\x61\164\x65" => $date, "\162\145\146\145\162\x65\156\143\x65\137\156\157" => $reference, "\143\165\163\164\x6f\155\x65\x72\137\x69\x64" => $customer_id, "\143\x75\163\164\157\x6d\145\x72" => $customer, "\x62\151\154\154\145\162\137\151\x64" => $biller_id, "\x62\151\x6c\x6c\145\x72" => $biller, "\x73\x75\160\x70\x6c\151\x65\162\137\151\144" => $supplier_id, "\x73\x75\x70\160\154\x69\145\162" => $supplier, "\167\141\162\x65\x68\157\x75\x73\145\x5f\151\144" => $warehouse_id, "\x6e\x6f\164\x65" => $note, "\x74\157\164\x61\x6c" => $total, "\x70\x72\x6f\x64\x75\x63\164\x5f\144\x69\163\x63\x6f\x75\x6e\164" => $product_discount, "\x6f\x72\144\x65\162\x5f\144\x69\x73\x63\157\165\x6e\x74\x5f\x69\144" => $this->input->post("\144\151\163\x63\157\165\x6e\164"), "\x6f\162\x64\x65\162\x5f\144\151\x73\143\157\165\156\x74" => $order_discount, "\x74\157\x74\141\x6c\x5f\144\151\x73\x63\157\x75\x6e\x74" => $total_discount, "\160\162\157\x64\x75\x63\x74\137\164\141\x78" => $product_tax, "\157\162\144\x65\x72\x5f\164\141\170\137\x69\144" => $this->input->post("\x6f\x72\x64\145\x72\137\164\141\x78"), "\x6f\162\144\145\162\137\164\x61\x78" => $order_tax, "\164\157\x74\x61\x6c\137\x74\x61\x78" => $total_tax, "\x73\x68\x69\x70\160\x69\x6e\147" => $this->sma->formatDecimal($shipping), "\147\x72\x61\x6e\x64\137\164\x6f\164\141\154" => $grand_total, "\163\164\141\x74\165\x73" => $status, "\143\x72\145\x61\164\145\x64\x5f\142\x79" => $this->session->userdata("\x75\163\145\162\137\x69\144"), "\x68\141\x73\x68" => hash("\163\x68\141\x32\x35\66", microtime() . mt_rand())); if ($this->Settings->indian_gst) { $data["\x63\147\163\x74"] = $total_cgst; $data["\x73\147\163\164"] = $total_sgst; $data["\151\147\x73\x74"] = $total_igst; } if ($_FILES["\144\157\143\x75\x6d\145\156\164"]["\x73\x69\x7a\145"] > 0) { $this->load->library("\x75\x70\154\157\x61\x64"); $config["\165\x70\x6c\157\x61\x64\x5f\160\x61\x74\x68"] = $this->digital_upload_path; $config["\x61\154\x6c\x6f\x77\145\x64\137\x74\x79\160\145\x73"] = $this->digital_file_types; $config["\x6d\141\x78\137\x73\x69\172\x65"] = $this->allowed_file_size; $config["\x6f\x76\x65\x72\167\162\151\x74\x65"] = false; $config["\x65\x6e\143\162\171\x70\164\137\x6e\141\x6d\145"] = true; $this->upload->initialize($config); if (!$this->upload->do_upload("\144\x6f\x63\x75\x6d\145\156\164")) { $error = $this->upload->display_errors(); $this->session->set_flashdata("\x65\x72\x72\x6f\x72", $error); redirect($_SERVER["\x48\124\x54\120\x5f\x52\x45\106\x45\x52\x45\x52"]); } $photo = $this->upload->file_name; $data["\141\164\x74\x61\143\150\x6d\x65\x6e\x74"] = $photo; } } if ($this->form_validation->run() == true && $this->quotes_model->addQuote($data, $products)) { $this->session->set_userdata("\162\145\x6d\157\x76\x65\137\161\x75\x6c\x73", 1); $this->session->set_flashdata("\x6d\145\x73\163\x61\147\x65", $this->lang->line("\161\165\157\x74\145\x5f\x61\144\144\x65\x64")); admin_redirect("\x71\x75\157\164\145\x73"); } else { $this->data["\145\162\162\x6f\162"] = validation_errors() ? validation_errors() : $this->session->flashdata("\145\162\162\x6f\162"); $this->data["\x62\151\154\154\x65\x72\x73"] = $this->Owner || $this->Admin || !$this->session->userdata("\x62\151\x6c\x6c\x65\162\137\151\144") ? $this->site->getAllCompanies("\142\x69\x6c\x6c\145\162") : null; $this->data["\165\156\151\164\x73"] = $this->site->getAllBaseUnits(); $this->data["\x74\x61\170\137\162\x61\164\145\x73"] = $this->site->getAllTaxRates(); $this->data["\167\141\x72\x65\x68\x6f\165\163\145\163"] = $this->Owner || $this->Admin || !$this->session->userdata("\x77\x61\x72\145\x68\157\165\163\x65\137\151\x64") ? $this->site->getAllWarehouses() : null; $this->data["\x71\165\156\x75\x6d\x62\145\x72"] = ''; $bc = array(array("\154\x69\156\153" => base_url(), "\x70\x61\x67\x65" => lang("\x68\157\155\145")), array("\154\151\x6e\x6b" => admin_url("\x71\165\157\x74\x65\x73"), "\x70\x61\x67\x65" => lang("\x71\165\x6f\x74\x65\x73")), array("\x6c\x69\156\x6b" => "\x23", "\x70\x61\147\145" => lang("\x61\x64\144\137\x71\x75\157\x74\x65"))); $meta = array("\160\141\x67\145\x5f\164\151\164\154\x65" => lang("\x61\x64\144\137\161\165\x6f\x74\145"), "\x62\x63" => $bc); $this->page_construct("\x71\165\x6f\164\x65\163\x2f\x61\x64\x64", $meta, $this->data); } } public function combine_pdf($quotes_id) { $this->sma->checkPermissions("\160\144\146"); foreach ($quotes_id as $quote_id) { $this->data["\145\162\162\157\x72"] = validation_errors() ? validation_errors() : $this->session->flashdata("\x65\162\162\157\162"); $inv = $this->quotes_model->getQuoteByID($quote_id); if (!$this->session->userdata("\166\x69\145\x77\x5f\x72\151\x67\x68\x74")) { $this->sma->view_rights($inv->created_by); } $this->data["\x72\x6f\167\x73"] = $this->quotes_model->getAllQuoteItems($quote_id); $this->data["\143\165\x73\164\157\155\x65\x72"] = $this->site->getCompanyByID($inv->customer_id); $this->data["\x62\x69\154\154\x65\162"] = $this->site->getCompanyByID($inv->biller_id); $this->data["\x75\163\145\162"] = $this->site->getUser($inv->created_by); $this->data["\x77\141\x72\145\x68\157\x75\x73\x65"] = $this->site->getWarehouseByID($inv->warehouse_id); $this->data["\x69\156\166"] = $inv; $html[] = array("\x63\157\156\x74\x65\156\164" => $this->load->view($this->theme . "\161\x75\x6f\x74\x65\x73\x2f\160\144\x66", $this->data, true), "\x66\157\x6f\164\x65\162" => ''); } $name = lang("\x71\165\157\164\145\x73") . "\56\160\x64\x66"; $this->sma->generate_pdf($html, $name); } public function delete($id = null) { $this->sma->checkPermissions(null, true); if ($this->input->get("\151\x64")) { $id = $this->input->get("\x69\x64"); } if (!$id) { $this->sma->send_json(array("\145\162\162\157\162" => 1, "\155\x73\x67" => lang("\x69\144\x5f\156\157\x74\x5f\x66\x6f\165\x6e\x64"))); } if ($this->quotes_model->deleteQuote($id)) { if ($this->input->is_ajax_request()) { $this->sma->send_json(array("\x65\162\162\x6f\162" => 0, "\155\x73\147" => lang("\x71\x75\157\164\145\137\x64\x65\154\x65\164\x65\x64"))); } $this->session->set_flashdata("\155\x65\163\163\141\147\145", lang("\x71\x75\x6f\x74\145\x5f\144\145\154\145\x74\145\144")); admin_redirect("\167\x65\154\143\157\x6d\145"); } } public function edit($id = null) { $this->sma->checkPermissions(); if ($this->input->get("\151\x64")) { $id = $this->input->get("\151\144"); } $inv = $this->quotes_model->getQuoteByID($id); if (!$this->session->userdata("\145\x64\x69\x74\137\x72\151\147\x68\x74")) { $this->sma->view_rights($inv->created_by); } $this->form_validation->set_message("\x69\163\x5f\156\x61\164\x75\x72\x61\x6c\x5f\156\x6f\137\172\x65\162\157", $this->lang->line("\156\x6f\x5f\x7a\x65\x72\x6f\x5f\x72\145\161\165\x69\162\145\144")); $this->form_validation->set_rules("\x72\145\146\145\162\x65\x6e\143\x65\137\156\157", $this->lang->line("\x72\145\x66\145\162\145\x6e\143\145\x5f\x6e\x6f"), "\162\x65\161\x75\x69\162\x65\x64"); $this->form_validation->set_rules("\x63\x75\163\x74\157\x6d\x65\162", $this->lang->line("\x63\165\163\x74\x6f\x6d\x65\x72"), "\x72\x65\161\x75\x69\x72\x65\x64"); if ($this->form_validation->run() == true) { $reference = $this->input->post("\x72\x65\x66\145\x72\x65\156\143\145\x5f\156\x6f"); if ($this->Owner || $this->Admin) { $date = $this->sma->fld(trim($this->input->post("\x64\x61\x74\145"))); } else { $date = date("\x59\55\155\55\144\x20\x48\x3a\151\72\163"); } $warehouse_id = $this->input->post("\167\x61\x72\145\x68\x6f\x75\163\x65"); $customer_id = $this->input->post("\x63\165\163\164\x6f\x6d\x65\162"); $biller_id = $this->input->post("\x62\151\154\x6c\x65\162"); $supplier_id = $this->input->post("\x73\165\x70\160\x6c\151\x65\162"); $status = $this->input->post("\x73\x74\x61\x74\x75\163"); $shipping = $this->input->post("\x73\x68\151\160\160\x69\x6e\x67") ? $this->input->post("\163\x68\151\x70\x70\151\x6e\147") : 0; $customer_details = $this->site->getCompanyByID($customer_id); $customer = $customer_details->company && $customer_details->company != "\x2d" ? $customer_details->company : $customer_details->name; $biller_details = $this->site->getCompanyByID($biller_id); $biller = $biller_details->company && $biller_details->company != "\x2d" ? $biller_details->company : $biller_details->name; if ($supplier_id) { $supplier_details = $this->site->getCompanyByID($supplier_id); $supplier = $supplier_details->company && $supplier_details->company != "\55" ? $supplier_details->company : $supplier_details->name; } else { $supplier = null; } $note = $this->sma->clear_tags($this->input->post("\x6e\x6f\x74\x65")); $total = 0; $product_tax = 0; $product_discount = 0; $gst_data = array(); $total_cgst = $total_sgst = $total_igst = 0; $i = isset($_POST["\x70\162\x6f\144\x75\x63\164\137\143\157\x64\x65"]) ? sizeof($_POST["\160\162\x6f\144\165\x63\164\x5f\x63\x6f\x64\x65"]) : 0; for ($r = 0; $r < $i; $r++) { $item_id = $_POST["\160\x72\x6f\144\165\143\164\x5f\151\144"][$r]; $item_type = $_POST["\x70\x72\157\x64\x75\143\164\137\164\171\x70\145"][$r]; $item_code = $_POST["\160\x72\x6f\x64\165\x63\164\x5f\x63\x6f\x64\x65"][$r]; $item_name = $_POST["\160\162\157\144\165\143\x74\x5f\156\x61\x6d\x65"][$r]; $item_option = isset($_POST["\x70\162\157\144\165\143\x74\137\x6f\x70\164\151\157\156"][$r]) && $_POST["\160\x72\x6f\x64\165\143\164\137\157\160\x74\151\x6f\x6e"][$r] != "\x66\x61\154\163\145" ? $_POST["\160\x72\157\x64\x75\x63\x74\137\x6f\x70\164\151\x6f\x6e"][$r] : null; $real_unit_price = $this->sma->formatDecimal($_POST["\x72\x65\x61\154\x5f\x75\156\151\164\137\160\x72\151\143\145"][$r]); $unit_price = $this->sma->formatDecimal($_POST["\165\x6e\151\164\137\x70\162\x69\143\x65"][$r]); $item_unit_quantity = $_POST["\161\x75\x61\x6e\164\x69\x74\171"][$r]; $item_tax_rate = $_POST["\x70\x72\x6f\144\165\143\x74\137\164\x61\x78"][$r] ?? null; $item_discount = $_POST["\160\162\157\144\x75\x63\x74\x5f\x64\x69\163\143\157\x75\x6e\164"][$r] ?? null; $item_unit = $_POST["\x70\162\157\x64\x75\x63\164\137\165\156\151\164"][$r]; $item_quantity = $_POST["\x70\162\x6f\x64\x75\143\x74\137\142\141\x73\x65\x5f\161\165\x61\x6e\x74\151\164\171"][$r]; if (isset($item_code) && isset($real_unit_price) && isset($unit_price) && isset($item_quantity)) { $product_details = $item_type != "\155\x61\x6e\x75\x61\x6c" ? $this->quotes_model->getProductByCode($item_code) : null; $pr_discount = $this->site->calculateDiscount($item_discount, $unit_price); $unit_price = $this->sma->formatDecimal($unit_price - $pr_discount); $item_net_price = $unit_price; $pr_item_discount = $this->sma->formatDecimal($pr_discount * $item_unit_quantity); $product_discount += $pr_item_discount; $pr_item_tax = $item_tax = 0; $tax = ''; if (isset($item_tax_rate) && $item_tax_rate != 0) { $tax_details = $this->site->getTaxRateByID($item_tax_rate); $ctax = $this->site->calculateTax($product_details, $tax_details, $unit_price); $item_tax = $this->sma->formatDecimal($ctax["\141\155\157\x75\156\164"]); $tax = $ctax["\164\141\170"]; if (!$product_details || !empty($product_details) && $product_details->tax_method != 1) { $item_net_price = $unit_price - $item_tax; } $pr_item_tax = $this->sma->formatDecimal($item_tax * $item_unit_quantity, 4); if ($this->Settings->indian_gst && ($gst_data = $this->gst->calculateIndianGST($pr_item_tax, $biller_details->state == $customer_details->state, $tax_details))) { $total_cgst += $gst_data["\x63\x67\x73\x74"]; $total_sgst += $gst_data["\x73\147\163\x74"]; $total_igst += $gst_data["\151\x67\163\x74"]; } } $product_tax += $pr_item_tax; $subtotal = $item_net_price * $item_unit_quantity + $pr_item_tax; $unit = $this->site->getUnitByID($item_unit); $product = array("\x70\x72\157\x64\165\143\164\x5f\x69\144" => $item_id, "\x70\162\x6f\144\165\x63\x74\137\x63\157\x64\x65" => $item_code, "\x70\x72\157\x64\165\x63\x74\137\156\x61\155\145" => $item_name, "\160\162\157\x64\165\143\164\137\164\171\160\x65" => $item_type, "\x6f\x70\x74\151\x6f\x6e\x5f\x69\144" => $item_option, "\156\145\164\x5f\x75\156\x69\164\x5f\x70\162\x69\x63\x65" => $item_net_price, "\x75\156\151\x74\137\160\162\x69\x63\x65" => $this->sma->formatDecimal($item_net_price + $item_tax), "\x71\x75\x61\156\164\151\164\x79" => $item_quantity, "\160\162\x6f\144\x75\x63\164\x5f\165\x6e\x69\164\137\x69\144" => $item_unit, "\x70\162\157\144\x75\x63\164\x5f\165\156\x69\164\137\143\157\x64\145" => $unit->code, "\x75\x6e\x69\x74\x5f\161\165\141\156\164\151\164\171" => $item_unit_quantity, "\x77\141\x72\x65\150\x6f\165\163\x65\x5f\151\144" => $warehouse_id, "\151\164\x65\x6d\x5f\164\x61\x78" => $pr_item_tax, "\x74\141\x78\x5f\162\141\164\x65\137\151\144" => $item_tax_rate, "\164\141\170" => $tax, "\x64\x69\x73\x63\157\x75\156\x74" => $item_discount, "\x69\x74\145\x6d\x5f\x64\x69\163\x63\157\x75\156\164" => $pr_item_discount, "\x73\x75\x62\x74\x6f\x74\x61\x6c" => $this->sma->formatDecimal($subtotal), "\x72\x65\x61\x6c\137\165\156\151\x74\x5f\160\x72\x69\143\145" => $real_unit_price); $products[] = $product + $gst_data; $total += $this->sma->formatDecimal($item_net_price * $item_unit_quantity, 4); } } if (empty($products)) { $this->form_validation->set_rules("\x70\162\x6f\x64\165\x63\x74", lang("\x6f\x72\144\x65\x72\x5f\x69\x74\145\155\x73"), "\x72\x65\161\165\151\x72\x65\x64"); } else { krsort($products); } $order_discount = $this->site->calculateDiscount($this->input->post("\144\151\163\x63\x6f\165\156\x74"), $total + $product_tax, true); $total_discount = $this->sma->formatDecimal($order_discount + $product_discount, 4); $order_tax = $this->site->calculateOrderTax($this->input->post("\157\x72\144\145\162\x5f\164\x61\x78"), $total + $product_tax - $order_discount); $total_tax = $this->sma->formatDecimal($product_tax + $order_tax, 4); $grand_total = $this->sma->formatDecimal($total + $total_tax + $this->sma->formatDecimal($shipping) - $order_discount, 4); $data = array("\x64\x61\x74\145" => $date, "\x72\145\x66\145\x72\x65\x6e\x63\145\137\156\157" => $reference, "\x63\x75\163\164\157\155\145\x72\137\x69\x64" => $customer_id, "\143\x75\163\x74\x6f\155\145\162" => $customer, "\142\x69\154\154\145\x72\137\151\x64" => $biller_id, "\142\151\154\x6c\x65\x72" => $biller, "\x73\165\x70\160\x6c\151\145\x72\x5f\x69\x64" => $supplier_id, "\x73\x75\160\x70\154\151\145\x72" => $supplier, "\167\141\162\x65\150\x6f\x75\163\145\x5f\x69\x64" => $warehouse_id, "\156\x6f\164\145" => $note, "\164\157\164\141\154" => $total, "\x70\x72\x6f\x64\165\143\164\x5f\x64\151\163\x63\x6f\165\x6e\x74" => $product_discount, "\157\x72\x64\145\x72\x5f\144\x69\x73\x63\x6f\x75\156\164\137\x69\144" => $this->input->post("\144\151\163\143\157\165\156\x74"), "\x6f\x72\x64\145\162\x5f\144\x69\163\143\x6f\165\156\164" => $order_discount, "\x74\157\164\141\154\x5f\x64\x69\163\143\x6f\165\x6e\164" => $total_discount, "\x70\x72\x6f\144\x75\x63\x74\137\164\141\x78" => $product_tax, "\157\x72\x64\x65\162\137\164\141\x78\x5f\151\x64" => $this->input->post("\157\x72\x64\145\162\137\x74\141\170"), "\157\162\144\145\162\137\x74\141\x78" => $order_tax, "\x74\157\x74\x61\x6c\x5f\164\x61\170" => $total_tax, "\163\x68\151\x70\x70\151\156\147" => $shipping, "\x67\x72\141\156\144\137\x74\x6f\x74\141\x6c" => $grand_total, "\x73\x74\x61\x74\165\163" => $status, "\165\160\144\141\164\x65\144\x5f\142\x79" => $this->session->userdata("\x75\x73\145\x72\x5f\x69\144"), "\165\160\x64\141\x74\145\x64\x5f\141\x74" => date("\x59\55\155\55\x64\x20\110\72\151\x3a\163")); if ($this->Settings->indian_gst) { $data["\143\x67\x73\164"] = $total_cgst; $data["\x73\x67\163\x74"] = $total_sgst; $data["\x69\147\163\164"] = $total_igst; } if ($_FILES["\144\157\143\x75\x6d\x65\156\x74"]["\163\x69\x7a\x65"] > 0) { $this->load->library("\x75\160\154\157\141\144"); $config["\x75\x70\x6c\x6f\x61\144\137\x70\x61\x74\x68"] = $this->digital_upload_path; $config["\x61\x6c\154\x6f\167\x65\144\x5f\164\x79\x70\145\163"] = $this->digital_file_types; $config["\155\141\170\x5f\163\x69\172\145"] = $this->allowed_file_size; $config["\157\x76\145\x72\167\x72\x69\x74\145"] = false; $config["\145\156\x63\162\171\x70\164\137\156\x61\155\x65"] = true; $this->upload->initialize($config); if (!$this->upload->do_upload("\x64\157\x63\x75\155\145\156\x74")) { $error = $this->upload->display_errors(); $this->session->set_flashdata("\145\x72\162\157\x72", $error); redirect($_SERVER["\x48\124\124\120\137\122\x45\x46\105\x52\x45\122"]); } $photo = $this->upload->file_name; $data["\141\164\164\x61\x63\150\155\x65\x6e\164"] = $photo; } } if ($this->form_validation->run() == true && $this->quotes_model->updateQuote($id, $data, $products)) { $this->session->set_userdata("\162\145\155\x6f\166\x65\137\161\x75\154\163", 1); $this->session->set_flashdata("\155\x65\x73\163\x61\x67\x65", $this->lang->line("\161\x75\157\x74\145\x5f\141\144\144\145\144")); admin_redirect("\x71\165\157\x74\x65\x73"); } else { $this->data["\145\162\x72\157\162"] = validation_errors() ? validation_errors() : $this->session->flashdata("\145\162\x72\x6f\162"); $this->data["\x69\156\x76"] = $this->quotes_model->getQuoteByID($id); $inv_items = $this->quotes_model->getAllQuoteItems($id); $c = rand(100000, 9999999); foreach ($inv_items as $item) { $row = $this->site->getProductByID($item->product_id); if (!$row) { $row = json_decode("\173\x7d"); $row->tax_method = 0; } else { unset($row->details, $row->product_details, $row->cost, $row->supplier1price, $row->supplier2price, $row->supplier3price, $row->supplier4price, $row->supplier5price); } $row->quantity = 0; $pis = $this->site->getPurchasedItems($item->product_id, $item->warehouse_id, $item->option_id); if ($pis) { foreach ($pis as $pi) { $row->quantity += $pi->quantity_balance; } } $row->id = $item->product_id; $row->code = $item->product_code; $row->name = $item->product_name; $row->type = $item->product_type; $row->base_quantity = $item->quantity; $row->base_unit = $row->unit ?? $item->product_unit_id; $row->base_unit_price = $row->price ?? $item->unit_price; $row->unit = $item->product_unit_id; $row->qty = $item->unit_quantity; $row->discount = $item->discount ? $item->discount : "\60"; $row->item_tax = $item->item_tax > 0 ? $item->item_tax / $item->quantity : 0; $row->item_discount = $item->item_discount > 0 ? $item->item_discount / $item->quantity : 0; $row->unit_price = $row->tax_method ? $item->unit_price + $this->sma->formatDecimal($row->item_discount) + $this->sma->formatDecimal($row->item_tax) : $item->unit_price + $row->item_discount; $row->real_unit_price = $item->real_unit_price; $row->tax_rate = $item->tax_rate_id; $row->option = $item->option_id; $options = $this->quotes_model->getProductOptions($row->id, $item->warehouse_id, true); if ($options) { foreach ($options as $option) { $pis = $this->site->getPurchasedItems($row->id, $item->warehouse_id, $item->option_id); if ($pis) { $option->quantity = 0; foreach ($pis as $pi) { $option->quantity += $pi->quantity_balance; } } if ($row->option == $option->id) { $option->quantity += $item->quantity; } } } $combo_items = false; if ($row->type == "\143\157\x6d\x62\x6f") { $combo_items = $this->quotes_model->getProductComboItems($row->id, $item->warehouse_id); foreach ($combo_items as $combo_item) { $combo_item->quantity = $combo_item->qty * $item->quantity; } } $units = $this->site->getUnitsByBUID($row->base_unit); $tax_rate = $this->site->getTaxRateByID($row->tax_rate); $ri = $this->Settings->item_addition ? $row->id : $c; $pr[$ri] = array("\x69\x64" => $c, "\151\164\145\155\x5f\151\x64" => $row->id, "\154\x61\142\x65\154" => $row->name . "\40\50" . $row->code . "\51", "\162\157\167" => $row, "\143\x6f\155\x62\x6f\137\151\164\x65\155\x73" => $combo_items, "\164\141\170\x5f\162\141\x74\145" => $tax_rate, "\x75\156\x69\x74\163" => $units, "\x6f\160\164\x69\157\x6e\163" => $options); $c++; } $this->data["\151\x6e\x76\137\151\x74\145\x6d\x73"] = json_encode($pr); $this->data["\151\144"] = $id; $this->data["\142\x69\154\x6c\145\x72\163"] = $this->Owner || $this->Admin || !$this->session->userdata("\x62\x69\x6c\x6c\145\162\137\x69\144") ? $this->site->getAllCompanies("\x62\151\154\x6c\145\x72") : null; $this->data["\165\156\151\x74\x73"] = $this->site->getAllBaseUnits(); $this->data["\x74\x61\170\137\162\141\164\145\163"] = $this->site->getAllTaxRates(); $this->data["\167\141\162\145\x68\157\165\x73\145\163"] = $this->Owner || $this->Admin || !$this->session->userdata("\167\141\x72\x65\x68\x6f\x75\163\145\137\151\x64") ? $this->site->getAllWarehouses() : null; $bc = array(array("\x6c\151\x6e\x6b" => base_url(), "\160\141\147\x65" => lang("\150\157\155\x65")), array("\154\151\156\x6b" => admin_url("\161\165\x6f\x74\x65\x73"), "\x70\141\147\x65" => lang("\161\x75\x6f\x74\x65\x73")), array("\x6c\x69\156\153" => "\x23", "\160\141\x67\x65" => lang("\145\x64\151\164\137\161\x75\157\164\145"))); $meta = array("\x70\x61\x67\x65\137\164\151\164\x6c\145" => lang("\145\x64\151\164\137\x71\x75\x6f\x74\145"), "\x62\x63" => $bc); $this->page_construct("\161\165\157\164\145\163\x2f\x65\x64\151\x74", $meta, $this->data); } } public function email($quote_id = null) { $this->sma->checkPermissions(false, true); if ($this->input->get("\151\144")) { $quote_id = $this->input->get("\151\x64"); } $inv = $this->quotes_model->getQuoteByID($quote_id); $this->form_validation->set_rules("\164\x6f", $this->lang->line("\x74\157") . "\x20" . $this->lang->line("\x65\155\x61\x69\x6c"), "\164\162\151\x6d\174\x72\145\161\x75\x69\x72\x65\x64\x7c\166\141\154\151\144\x5f\145\x6d\141\151\x6c"); $this->form_validation->set_rules("\x73\165\x62\x6a\x65\x63\x74", $this->lang->line("\x73\165\142\152\145\x63\x74"), "\164\x72\x69\x6d\x7c\x72\145\x71\x75\151\162\x65\x64"); $this->form_validation->set_rules("\143\143", $this->lang->line("\143\x63"), "\x74\162\x69\x6d\174\x76\x61\x6c\151\x64\137\x65\155\x61\151\154\163"); $this->form_validation->set_rules("\142\143\143", $this->lang->line("\142\x63\x63"), "\164\162\151\x6d\174\166\x61\154\x69\x64\137\145\x6d\x61\151\x6c\163"); $this->form_validation->set_rules("\156\x6f\x74\x65", $this->lang->line("\x6d\145\x73\163\141\x67\145"), "\x74\162\151\x6d"); if ($this->form_validation->run() == true) { if (!$this->session->userdata("\166\151\x65\x77\137\x72\x69\x67\150\164")) { $this->sma->view_rights($inv->created_by); } $to = $this->input->post("\x74\157"); $subject = $this->input->post("\163\x75\142\152\145\143\164"); if ($this->input->post("\143\x63")) { $cc = $this->input->post("\x63\143"); } else { $cc = null; } if ($this->input->post("\x62\x63\x63")) { $bcc = $this->input->post("\x62\x63\143"); } else { $bcc = null; } $customer = $this->site->getCompanyByID($inv->customer_id); $biller = $this->site->getCompanyByID($inv->biller_id); $this->load->library("\160\x61\162\163\145\162"); $parse_data = array("\162\145\146\x65\x72\145\156\143\x65\x5f\156\165\x6d\142\145\x72" => $inv->reference_no, "\x63\x6f\x6e\x74\141\143\x74\137\160\145\x72\163\x6f\x6e" => $customer->name, "\143\x6f\x6d\x70\141\x6e\171" => $customer->company, "\163\x69\x74\x65\x5f\x6c\151\156\x6b" => base_url(), "\x73\151\x74\145\137\156\141\x6d\145" => $this->Settings->site_name, "\154\157\147\x6f" => "\74\x69\x6d\147\x20\x73\162\x63\x3d\42" . base_url() . "\141\163\163\145\x74\x73\x2f\165\x70\x6c\157\x61\144\163\x2f\x6c\157\147\x6f\163\57" . $biller->logo . "\42\40\141\154\164\75\x22" . ($biller->company && $biller->company != "\55" ? $biller->company : $biller->name) . "\42\x2f\76"); $msg = $this->input->post("\x6e\x6f\x74\145"); $message = $this->parser->parse_string($msg, $parse_data); $attachment = $this->pdf($quote_id, null, "\123"); try { if ($this->sma->send_email($to, $subject, $message, null, null, $attachment, $cc, $bcc)) { delete_files($attachment); $this->db->update("\161\165\157\x74\145\x73", array("\163\x74\x61\x74\165\163" => "\x73\145\156\x74"), array("\x69\144" => $quote_id)); $this->session->set_flashdata("\x6d\x65\x73\x73\141\x67\145", $this->lang->line("\145\x6d\x61\x69\x6c\x5f\x73\x65\156\x74")); admin_redirect("\x71\165\x6f\x74\x65\x73"); } } catch (Exception $e) { $this->session->set_flashdata("\x65\162\162\x6f\x72", $e->getMessage()); redirect($_SERVER["\x48\x54\x54\120\x5f\122\105\106\x45\x52\x45\x52"]); } } elseif ($this->input->post("\163\145\x6e\144\x5f\x65\x6d\x61\151\x6c")) { $this->data["\x65\x72\162\x6f\162"] = validation_errors() ? validation_errors() : $this->session->flashdata("\145\162\162\x6f\162"); $this->session->set_flashdata("\145\162\x72\x6f\162", $this->data["\145\x72\162\157\162"]); redirect($_SERVER["\110\x54\124\120\x5f\x52\105\x46\105\x52\105\x52"]); } else { $this->data["\x65\162\x72\x6f\162"] = validation_errors() ? validation_errors() : $this->session->flashdata("\145\162\162\x6f\162"); if (file_exists("\56\x2f\164\x68\145\155\145\x73\57" . $this->Settings->theme . "\57\x61\144\155\x69\x6e\57\x76\x69\145\x77\163\x2f\x65\155\x61\151\154\137\x74\x65\155\x70\154\x61\164\145\163\x2f\x71\x75\157\164\x65\56\x68\164\155\x6c")) { $quote_temp = file_get_contents("\164\x68\x65\155\145\163\57" . $this->Settings->theme . "\x2f\141\144\x6d\151\156\57\x76\x69\145\167\x73\57\x65\x6d\x61\151\154\137\x74\x65\x6d\160\154\x61\164\x65\x73\57\x71\165\x6f\x74\x65\x2e\x68\164\x6d\154"); } else { $quote_temp = file_get_contents("\x2e\57\x74\x68\145\x6d\x65\x73\x2f\x64\145\x66\x61\x75\154\x74\57\x61\144\x6d\x69\156\x2f\166\x69\145\167\x73\x2f\145\x6d\x61\151\x6c\137\x74\145\x6d\160\x6c\x61\x74\145\x73\x2f\161\165\157\x74\145\56\150\x74\x6d\x6c"); } $this->data["\163\165\142\x6a\145\x63\164"] = array("\x6e\141\x6d\x65" => "\163\165\142\x6a\x65\143\x74", "\151\x64" => "\x73\165\x62\152\x65\143\x74", "\164\x79\x70\x65" => "\164\x65\170\x74", "\x76\x61\154\x75\x65" => $this->form_validation->set_value("\163\165\x62\152\x65\x63\x74", lang("\161\165\x6f\x74\145") . "\40\50" . $inv->reference_no . "\51\x20" . lang("\x66\162\157\155") . "\40" . $this->Settings->site_name)); $this->data["\156\x6f\164\145"] = array("\156\141\x6d\145" => "\x6e\157\164\x65", "\x69\x64" => "\x6e\x6f\164\x65", "\164\171\160\x65" => "\164\x65\170\x74", "\x76\x61\154\165\x65" => $this->form_validation->set_value("\x6e\x6f\x74\x65", $quote_temp)); $this->data["\x63\165\163\164\157\155\x65\x72"] = $this->site->getCompanyByID($inv->customer_id); $this->data["\x69\x64"] = $quote_id; $this->data["\x6d\157\144\x61\x6c\137\x6a\x73"] = $this->site->modal_js(); $this->load->view($this->theme . "\x71\x75\x6f\x74\x65\163\x2f\x65\155\141\151\154", $this->data); } } public function getQuotes($warehouse_id = null) { $this->sma->checkPermissions("\151\156\144\145\x78"); if ((!$this->Owner || !$this->Admin) && !$warehouse_id) { $user = $this->site->getUser(); $warehouse_id = $user->warehouse_id; } $detail_link = anchor("\x61\144\155\151\x6e\57\x71\165\157\x74\145\x73\57\x76\151\x65\x77\57\x24\61", "\74\151\x20\x63\154\141\x73\x73\75\x22\x66\141\40\x66\141\x2d\x66\x69\154\145\55\164\x65\x78\164\x2d\157\x22\76\74\x2f\151\x3e\x20" . lang("\x71\165\x6f\164\x65\x5f\x64\x65\164\x61\x69\154\163")); $email_link = anchor("\x61\144\x6d\x69\x6e\57\x71\165\x6f\x74\145\163\x2f\x65\155\x61\151\154\x2f\44\61", "\x3c\x69\x20\143\154\141\163\x73\75\42\146\x61\x20\146\141\55\145\156\x76\x65\x6c\157\x70\145\42\x3e\x3c\x2f\151\76\40" . lang("\145\155\141\x69\x6c\x5f\x71\165\157\x74\145"), "\x64\141\164\141\55\x74\x6f\147\x67\x6c\145\x3d\42\155\x6f\144\x61\154\42\40\x64\x61\164\141\x2d\x74\141\162\x67\145\164\75\42\x23\155\171\115\157\144\141\154\x22"); $edit_link = anchor("\141\x64\x6d\151\x6e\57\x71\165\157\164\x65\163\x2f\x65\144\151\x74\x2f\x24\x31", "\x3c\x69\x20\x63\154\141\163\163\75\x22\146\141\x20\146\141\x2d\x65\144\151\164\x22\76\x3c\57\x69\76\x20" . lang("\x65\144\x69\x74\x5f\x71\x75\x6f\x74\145")); $convert_link = anchor("\141\x64\x6d\151\x6e\57\x73\141\154\x65\x73\x2f\x61\x64\144\x2f\x24\61", "\x3c\151\x20\x63\154\141\163\163\75\x22\x66\x61\40\146\141\x2d\150\x65\141\x72\164\42\x3e\x3c\57\151\76\x20" . lang("\x63\x72\x65\x61\164\145\137\163\x61\x6c\145")); $pc_link = anchor("\x61\144\155\x69\x6e\x2f\160\x75\x72\143\150\x61\163\x65\163\x2f\x61\144\x64\57\x24\x31", "\74\151\x20\x63\154\x61\x73\x73\x3d\42\146\x61\x20\x66\x61\55\163\x74\x61\x72\x22\76\74\x2f\x69\76\40" . lang("\x63\x72\x65\x61\164\x65\x5f\160\x75\162\x63\x68\x61\163\145")); $pdf_link = anchor("\141\x64\155\x69\156\57\161\165\157\x74\x65\x73\x2f\x70\x64\x66\57\x24\61", "\74\x69\40\143\x6c\x61\163\163\x3d\x22\x66\141\x20\146\x61\55\146\x69\x6c\145\x2d\160\x64\146\55\x6f\42\x3e\x3c\57\151\76\40" . lang("\x64\x6f\x77\x6e\x6c\x6f\x61\144\137\160\144\146")); $delete_link = "\x3c\x61\x20\x68\x72\x65\146\x3d\47\x23\47\40\143\154\x61\163\163\x3d\47\160\157\47\40\164\151\164\x6c\x65\75\47\x3c\x62\76" . $this->lang->line("\x64\x65\154\145\x74\x65\x5f\x71\x75\x6f\164\145") . "\x3c\57\x62\x3e\47\40\x64\141\164\x61\x2d\x63\157\x6e\164\x65\x6e\x74\75\x22\74\x70\76" . lang("\162\x5f\165\x5f\163\165\x72\x65") . "\74\57\160\76\74\x61\40\143\x6c\x61\x73\x73\75\x27\x62\164\x6e\40\x62\x74\x6e\55\x64\x61\x6e\x67\145\x72\x20\x70\157\55\x64\x65\x6c\145\164\145\47\x20\150\x72\x65\146\x3d\x27" . admin_url("\x71\x75\157\164\145\x73\57\x64\145\x6c\145\x74\145\57\44\x31") . "\47\x3e" . lang("\151\x5f\155\137\x73\165\x72\x65") . "\74\57\141\76\x20\x3c\x62\165\164\x74\x6f\x6e\x20\x63\154\x61\163\163\75\x27\142\164\x6e\40\x70\x6f\55\143\154\157\x73\145\47\x3e" . lang("\x6e\157") . "\74\x2f\142\x75\164\164\157\156\x3e\42\x20\x20\162\x65\x6c\75\47\x70\157\160\x6f\x76\x65\162\47\76\74\151\x20\143\x6c\141\163\163\75\42\x66\141\40\146\141\x2d\x74\162\x61\x73\x68\55\x6f\x22\76\x3c\x2f\151\x3e\x20" . lang("\x64\x65\x6c\x65\164\x65\137\x71\x75\157\x74\x65") . "\x3c\x2f\141\76"; $action = "\x3c\x64\151\166\x20\x63\154\141\x73\x73\75\42\x74\x65\170\x74\x2d\x63\x65\156\x74\x65\x72\42\x3e\x3c\144\151\x76\40\x63\x6c\x61\163\x73\x3d\x22\x62\x74\156\x2d\x67\162\x6f\x75\160\x20\x74\x65\x78\164\x2d\154\x65\x66\x74\42\x3e" . "\x3c\x62\165\164\164\x6f\x6e\40\x74\x79\x70\145\75\42\x62\165\164\164\x6f\156\42\x20\x63\x6c\x61\163\163\75\42\142\164\x6e\x20\142\x74\156\x2d\144\145\x66\141\165\x6c\x74\40\x62\164\156\x2d\170\x73\x20\x62\x74\x6e\55\160\x72\x69\x6d\141\x72\171\40\144\162\x6f\160\144\157\167\x6e\55\164\x6f\147\x67\154\x65\42\40\144\141\164\x61\x2d\x74\x6f\x67\x67\154\x65\x3d\42\x64\162\157\x70\144\x6f\167\156\x22\x3e" . lang("\x61\143\x74\x69\157\x6e\x73") . "\40\x3c\x73\160\x61\156\x20\x63\x6c\x61\163\163\x3d\42\x63\x61\x72\145\164\42\x3e\74\57\x73\160\x61\156\x3e\74\x2f\142\165\164\164\157\x6e\76\xa\x20\40\x20\40\x20\x20\40\x20\x20\40\40\40\40\40\x20\40\40\x20\40\40\74\x75\154\x20\x63\154\x61\x73\x73\75\42\144\x72\157\160\144\157\x77\x6e\55\x6d\145\156\x75\x20\160\x75\154\x6c\x2d\x72\151\x67\x68\x74\x22\x20\162\157\x6c\x65\x3d\x22\x6d\x65\x6e\x75\x22\76\12\x20\40\40\x20\40\40\40\x20\x20\x20\x20\x20\40\x20\x20\40\40\x20\x20\x20\40\40\40\40\x3c\154\151\x3e" . $detail_link . "\74\x2f\154\151\76\12\x20\x20\x20\x20\x20\x20\40\40\x20\x20\x20\40\40\40\x20\40\40\40\40\x20\40\40\x20\x20\x3c\x6c\x69\x3e" . $edit_link . "\74\57\154\x69\76\xa\40\40\x20\40\x20\x20\40\x20\x20\x20\40\x20\40\40\40\40\x20\x20\40\40\x20\x20\40\x20\74\x6c\151\76" . $convert_link . "\x3c\57\x6c\x69\x3e\xa\x20\x20\x20\40\x20\40\40\40\x20\x20\x20\40\40\x20\40\40\x20\x20\x20\40\x20\x20\x20\40\74\154\x69\76" . $pc_link . "\74\57\154\x69\76\xa\40\x20\x20\40\40\40\40\x20\40\x20\40\40\40\40\x20\x20\40\40\x20\40\x20\40\x20\40\x3c\x6c\151\x3e" . $pdf_link . "\x3c\x2f\x6c\151\x3e\12\x20\40\40\40\x20\x20\40\40\40\x20\x20\x20\40\x20\x20\x20\40\40\x20\x20\40\40\x20\x20\x3c\154\x69\x3e" . $email_link . "\x3c\x2f\x6c\151\76\12\x20\x20\x20\x20\40\x20\40\40\x20\x20\x20\40\x20\x20\40\40\40\x20\40\x20\40\40\x20\40\x3c\154\x69\76" . $delete_link . "\x3c\x2f\x6c\151\x3e\12\x20\40\40\x20\40\x20\x20\40\x20\x20\40\40\x20\40\x20\x20\x20\40\x20\40\x3c\57\165\x6c\x3e\12\x20\40\40\40\x20\40\x20\40\40\x20\x20\40\x20\x20\x20\40\x3c\x2f\144\151\x76\76\74\57\x64\x69\166\x3e"; $this->load->library("\x64\x61\164\x61\x74\x61\x62\x6c\145\x73"); if ($warehouse_id) { $this->datatables->select("\x69\x64\x2c\40\144\x61\x74\145\x2c\40\162\x65\x66\145\x72\145\x6e\143\x65\137\156\x6f\54\x20\142\151\154\154\145\162\x2c\x20\143\165\x73\x74\x6f\155\145\x72\x2c\x20\x73\165\x70\160\154\x69\145\x72\54\40\x67\x72\x61\156\x64\137\164\x6f\164\141\154\x2c\40\163\164\141\164\165\x73\x2c\40\141\x74\x74\141\x63\150\x6d\x65\156\x74")->from("\161\165\x6f\x74\x65\x73")->where("\x77\x61\x72\145\150\157\165\x73\x65\137\x69\x64", $warehouse_id); } else { $this->datatables->select("\151\x64\54\40\144\141\164\145\54\x20\x72\x65\x66\x65\x72\x65\x6e\x63\x65\137\x6e\x6f\54\x20\142\151\x6c\154\x65\x72\54\40\x63\165\x73\x74\157\155\x65\x72\54\40\x73\x75\160\x70\154\151\x65\x72\x2c\40\x67\162\x61\156\144\x5f\x74\157\x74\x61\154\x2c\40\163\164\141\x74\x75\163\x2c\x20\141\x74\x74\141\x63\x68\155\x65\x6e\164")->from("\161\x75\x6f\164\x65\163"); } if (!$this->Customer && !$this->Supplier && !$this->Owner && !$this->Admin && !$this->session->userdata("\x76\151\145\x77\x5f\162\x69\147\x68\x74")) { $this->datatables->where("\x63\162\145\141\164\x65\144\137\142\171", $this->session->userdata("\165\x73\x65\x72\137\151\144")); } elseif ($this->Customer) { $this->datatables->where("\x63\x75\163\x74\x6f\155\x65\x72\137\151\144", $this->session->userdata("\165\x73\x65\162\x5f\x69\x64")); } $this->datatables->add_column("\101\143\x74\x69\157\156\163", $action, "\x69\x64"); echo $this->datatables->generate(); } public function index($warehouse_id = null) { $this->sma->checkPermissions(); $this->data["\x65\162\x72\x6f\162"] = validation_errors() ? validation_errors() : $this->session->flashdata("\x65\x72\x72\157\x72"); if ($this->Owner || $this->Admin || !$this->session->userdata("\x77\x61\x72\145\x68\x6f\x75\x73\x65\137\151\x64")) { $this->data["\x77\x61\162\x65\x68\x6f\x75\x73\x65\163"] = $this->site->getAllWarehouses(); $this->data["\167\x61\162\145\150\x6f\x75\163\x65\137\x69\144"] = $warehouse_id; $this->data["\167\x61\x72\x65\x68\x6f\x75\163\x65"] = $warehouse_id ? $this->site->getWarehouseByID($warehouse_id) : null; } else { $this->data["\167\x61\x72\x65\150\157\x75\x73\x65\163"] = null; $this->data["\167\x61\162\x65\x68\x6f\165\x73\145\137\151\x64"] = $this->session->userdata("\167\141\162\145\x68\x6f\x75\163\x65\137\x69\x64"); $this->data["\x77\141\x72\145\150\x6f\x75\x73\x65"] = $this->session->userdata("\x77\141\162\x65\x68\157\x75\x73\x65\137\x69\x64") ? $this->site->getWarehouseByID($this->session->userdata("\x77\141\x72\145\x68\x6f\165\163\145\137\x69\144")) : null; } $bc = array(array("\x6c\x69\156\x6b" => base_url(), "\160\x61\x67\145" => lang("\x68\x6f\x6d\x65")), array("\x6c\x69\x6e\x6b" => "\x23", "\160\141\147\x65" => lang("\x71\x75\x6f\x74\145\163"))); $meta = array("\x70\141\147\x65\137\x74\151\164\154\x65" => lang("\x71\x75\157\x74\x65\x73"), "\142\x63" => $bc); $this->page_construct("\161\165\x6f\x74\145\163\57\x69\156\x64\145\170", $meta, $this->data); } public function modal_view($quote_id = null) { $this->sma->checkPermissions("\x69\x6e\x64\x65\170", true); if ($this->input->get("\x69\x64")) { $quote_id = $this->input->get("\151\x64"); } $this->data["\145\162\x72\157\x72"] = validation_errors() ? validation_errors() : $this->session->flashdata("\145\x72\162\157\x72"); $inv = $this->quotes_model->getQuoteByID($quote_id); if (!$this->session->userdata("\x76\151\x65\167\137\x72\x69\x67\150\x74")) { $this->sma->view_rights($inv->created_by, true); } $this->data["\x72\157\x77\163"] = $this->quotes_model->getAllQuoteItems($quote_id); $this->data["\x63\165\x73\164\x6f\155\x65\162"] = $this->site->getCompanyByID($inv->customer_id); $this->data["\142\x69\x6c\154\x65\162"] = $this->site->getCompanyByID($inv->biller_id); $this->data["\x63\162\x65\x61\x74\x65\144\137\x62\171"] = $this->site->getUser($inv->created_by); $this->data["\165\x70\x64\141\x74\x65\x64\x5f\142\x79"] = $inv->updated_by ? $this->site->getUser($inv->updated_by) : null; $this->data["\167\141\162\x65\150\x6f\165\x73\145"] = $this->site->getWarehouseByID($inv->warehouse_id); $this->data["\151\x6e\x76"] = $inv; $this->load->view($this->theme . "\161\165\157\164\x65\163\57\x6d\x6f\144\141\x6c\x5f\166\151\145\x77", $this->data); } public function pdf($quote_id = null, $view = null, $save_bufffer = null) { $this->sma->checkPermissions(); if ($this->input->get("\151\144")) { $quote_id = $this->input->get("\151\144"); } $this->data["\145\x72\162\x6f\x72"] = validation_errors() ? validation_errors() : $this->session->flashdata("\145\x72\x72\157\162"); $inv = $this->quotes_model->getQuoteByID($quote_id); if (!$this->session->userdata("\x76\151\x65\167\137\x72\151\x67\150\164")) { $this->sma->view_rights($inv->created_by); } $this->data["\162\x6f\167\163"] = $this->quotes_model->getAllQuoteItems($quote_id); $this->data["\143\165\163\x74\157\155\x65\x72"] = $this->site->getCompanyByID($inv->customer_id); $this->data["\142\151\x6c\154\x65\x72"] = $this->site->getCompanyByID($inv->biller_id); $this->data["\143\x72\145\x61\164\x65\144\x5f\142\171"] = $this->site->getUser($inv->created_by); $this->data["\x77\141\x72\x65\150\157\x75\163\x65"] = $this->site->getWarehouseByID($inv->warehouse_id); $this->data["\x69\156\166"] = $inv; $name = $this->lang->line("\161\x75\157\x74\145") . "\137" . str_replace("\57", "\x5f", $inv->reference_no) . "\x2e\160\144\x66"; $html = $this->load->view($this->theme . "\x71\165\x6f\x74\x65\x73\x2f\160\144\x66", $this->data, true); if (!$this->Settings->barcode_img) { $html = preg_replace("\x27\x5c\74\x5c\x3f\x78\x6d\154\x28\x2e\x2a\x29\x5c\x3f\134\76\x27", '', $html); } if ($view) { $this->load->view($this->theme . "\x71\x75\157\164\x65\x73\57\x70\144\x66", $this->data); } elseif ($save_bufffer) { return $this->sma->generate_pdf($html, $name, $save_bufffer); } else { $this->sma->generate_pdf($html, $name); } } public function quote_actions() { if (!$this->Owner && !$this->GP["\142\x75\154\x6b\x5f\x61\143\164\151\157\156\163"]) { $this->session->set_flashdata("\167\141\162\x6e\x69\x6e\147", lang("\x61\143\x63\145\163\x73\x5f\144\x65\x6e\151\145\x64")); redirect($_SERVER["\110\124\x54\120\137\x52\105\x46\x45\122\105\122"]); } $this->form_validation->set_rules("\x66\157\162\155\x5f\141\143\164\x69\157\156", lang("\146\x6f\162\x6d\x5f\x61\143\x74\x69\x6f\156"), "\x72\x65\x71\165\x69\162\145\x64"); if ($this->form_validation->run() == true) { if (!empty($_POST["\x76\141\x6c"])) { if ($this->input->post("\x66\157\162\x6d\x5f\141\x63\164\x69\157\x6e") == "\x64\145\154\x65\x74\x65") { $this->sma->checkPermissions("\x64\x65\154\x65\x74\145"); foreach ($_POST["\166\141\x6c"] as $id) { $this->quotes_model->deleteQuote($id); } $this->session->set_flashdata("\155\x65\163\163\141\147\x65", $this->lang->line("\x71\x75\157\x74\x65\x73\137\144\x65\x6c\x65\164\x65\144")); redirect($_SERVER["\x48\124\x54\x50\137\x52\105\x46\x45\122\x45\x52"]); } elseif ($this->input->post("\146\157\x72\155\137\141\143\x74\x69\x6f\156") == "\x63\x6f\x6d\x62\x69\156\x65") { $html = $this->combine_pdf($_POST["\x76\x61\x6c"]); } elseif ($this->input->post("\146\157\162\155\x5f\x61\x63\164\151\x6f\156") == "\145\x78\160\157\x72\x74\x5f\145\x78\143\x65\x6c") { $this->load->library("\x65\x78\143\145\154"); $this->excel->setActiveSheetIndex(0); $this->excel->getActiveSheet()->setTitle(lang("\x71\165\157\164\x65\x73")); $this->excel->getActiveSheet()->SetCellValue("\x41\61", lang("\x64\141\x74\145")); $this->excel->getActiveSheet()->SetCellValue("\x42\x31", lang("\162\145\146\145\162\x65\156\x63\x65\x5f\x6e\157")); $this->excel->getActiveSheet()->SetCellValue("\103\61", lang("\142\x69\x6c\154\x65\162")); $this->excel->getActiveSheet()->SetCellValue("\104\x31", lang("\143\165\x73\x74\157\155\x65\162")); $this->excel->getActiveSheet()->SetCellValue("\105\61", lang("\x74\157\164\x61\x6c")); $this->excel->getActiveSheet()->SetCellValue("\x46\61", lang("\163\164\x61\164\x75\x73")); $row = 2; foreach ($_POST["\x76\x61\x6c"] as $id) { $qu = $this->quotes_model->getQuoteByID($id); $this->excel->getActiveSheet()->SetCellValue("\x41" . $row, $this->sma->hrld($qu->date)); $this->excel->getActiveSheet()->SetCellValue("\102" . $row, $qu->reference_no); $this->excel->getActiveSheet()->SetCellValue("\103" . $row, $qu->biller); $this->excel->getActiveSheet()->SetCellValue("\x44" . $row, $qu->customer); $this->excel->getActiveSheet()->SetCellValue("\x45" . $row, $qu->total); $this->excel->getActiveSheet()->SetCellValue("\106" . $row, $qu->status); $row++; } $this->excel->getActiveSheet()->getColumnDimension("\101")->setWidth(20); $this->excel->getActiveSheet()->getColumnDimension("\x42")->setWidth(20); $this->excel->getDefaultStyle()->getAlignment()->setVertical("\143\x65\x6e\x74\x65\x72"); $filename = "\161\x75\x6f\164\x61\164\151\x6f\x6e\163\137" . date("\131\137\x6d\x5f\x64\x5f\110\137\151\x5f\x73"); $this->load->helper("\x65\x78\143\x65\154"); create_excel($this->excel, $filename); } } else { $this->session->set_flashdata("\145\162\162\x6f\162", $this->lang->line("\x6e\x6f\x5f\x71\x75\157\x74\x65\x5f\163\145\x6c\145\x63\164\145\x64")); redirect($_SERVER["\x48\124\124\x50\x5f\x52\105\106\105\122\105\122"]); } } else { $this->session->set_flashdata("\145\162\162\157\162", validation_errors()); redirect($_SERVER["\x48\x54\124\x50\137\122\x45\x46\x45\122\105\x52"]); } } public function suggestions() { $term = $this->input->get("\x74\145\162\x6d", true); $warehouse_id = $this->input->get("\x77\x61\162\145\x68\x6f\x75\163\x65\x5f\151\144", true); $customer_id = $this->input->get("\143\x75\x73\164\x6f\x6d\x65\162\137\151\144", true); if (strlen($term) < 1 || !$term) { die("\x3c\x73\x63\x72\x69\160\164\x20\x74\x79\x70\145\75\x27\x74\145\x78\x74\57\152\141\x76\x61\x73\x63\x72\x69\x70\x74\x27\x3e\163\145\x74\124\x69\x6d\x65\157\x75\x74\x28\x66\x75\156\143\x74\151\157\156\x28\51\x7b\40\167\x69\x6e\x64\x6f\x77\56\164\157\160\56\x6c\x6f\143\x61\x74\x69\157\156\56\x68\x72\145\x66\x20\75\40\x27" . admin_url("\x77\145\154\x63\157\x6d\145") . "\47\73\x20\x7d\54\x20\x31\60\51\73\x3c\57\163\x63\162\151\160\164\76"); } $analyzed = $this->sma->analyze_term($term); $sr = $analyzed["\164\145\162\155"]; $sr = addslashes($sr); $strict = $analyzed["\x73\164\162\x69\x63\164"] ?? false; $qty = $strict ? null : $analyzed["\x71\x75\141\156\164\x69\x74\x79"] ?? null; $bprice = $strict ? null : $analyzed["\x70\162\x69\143\145"] ?? null; $option_id = $analyzed["\157\160\x74\151\x6f\x6e\137\151\x64"]; $warehouse = $this->site->getWarehouseByID($warehouse_id); $customer = $this->site->getCompanyByID($customer_id); $customer_group = $this->site->getCustomerGroupByID($customer->customer_group_id); $rows = $this->quotes_model->getProductNames($sr, $warehouse_id); if ($rows) { $r = 0; foreach ($rows as $row) { $c = uniqid(mt_rand(), true); unset($row->cost, $row->details, $row->product_details, $row->image, $row->barcode_symbology, $row->cf1, $row->cf2, $row->cf3, $row->cf4, $row->cf5, $row->cf6, $row->supplier1price, $row->supplier2price, $row->cfsupplier3price, $row->supplier4price, $row->supplier5price, $row->supplier1, $row->supplier2, $row->supplier3, $row->supplier4, $row->supplier5, $row->supplier1_part_no, $row->supplier2_part_no, $row->supplier3_part_no, $row->supplier4_part_no, $row->supplier5_part_no); $option = false; $row->quantity = 0; $row->item_tax_method = $row->tax_method; $row->qty = 1; $row->discount = "\x30"; $options = $this->quotes_model->getProductOptions($row->id, $warehouse_id); if ($options) { $opt = $option_id && $r == 0 ? $this->quotes_model->getProductOptionByID($option_id) : $options[0]; if (!$option_id || $r > 0) { $option_id = $opt->id; } } else { $opt = json_decode("\173\x7d"); $opt->price = 0; $option_id = false; } $row->option = $option_id; $pis = $this->site->getPurchasedItems($row->id, $warehouse_id, $row->option); if ($pis) { foreach ($pis as $pi) { $row->quantity += $pi->quantity_balance; } } if ($options) { $option_quantity = 0; foreach ($options as $option) { $pis = $this->site->getPurchasedItems($row->id, $warehouse_id, $row->option); if ($pis) { foreach ($pis as $pi) { $option_quantity += $pi->quantity_balance; } } if ($option->quantity > $option_quantity) { $option->quantity = $option_quantity; } } } if ($row->promotion) { $row->price = $row->promo_price; } elseif ($customer->price_group_id) { if ($pr_group_price = $this->site->getProductGroupPrice($row->id, $customer->price_group_id)) { $row->price = $pr_group_price->price; } } elseif ($warehouse->price_group_id) { if ($pr_group_price = $this->site->getProductGroupPrice($row->id, $warehouse->price_group_id)) { $row->price = $pr_group_price->price; } } if ($customer_group->discount && $customer_group->percent < 0) { $row->discount = 0 - $customer_group->percent . "\x25"; } else { $row->price = $row->price + $row->price * $customer_group->percent / 100; } $row->real_unit_price = $row->price; $row->base_quantity = 1; $row->base_unit = $row->unit; $row->base_unit_price = $row->price; $row->unit = $row->sale_unit ? $row->sale_unit : $row->unit; $combo_items = false; if ($row->type == "\143\x6f\x6d\x62\x6f") { $combo_items = $this->quotes_model->getProductComboItems($row->id, $warehouse_id); } if ($qty) { $row->qty = $qty; $row->base_quantity = $qty; } else { $row->qty = $bprice ? $bprice / $row->price : 1; } $units = $this->site->getUnitsByBUID($row->base_unit); $tax_rate = $this->site->getTaxRateByID($row->tax_rate); $pr[] = array("\x69\144" => sha1($c . $r), "\151\164\x65\155\137\151\144" => $row->id, "\x6c\141\142\x65\154" => $row->name . "\x20\x28" . $row->code . "\x29", "\x63\141\x74\x65\147\157\x72\x79" => $row->category_id, "\x72\x6f\x77" => $row, "\x63\x6f\155\142\157\x5f\151\x74\145\x6d\x73" => $combo_items, "\x74\x61\170\137\x72\x61\x74\145" => $tax_rate, "\x75\x6e\151\164\x73" => $units, "\157\x70\164\151\157\156\163" => $options); $r++; } $this->sma->send_json($pr); } else { $this->sma->send_json(array(array("\151\144" => 0, "\154\141\142\x65\154" => lang("\x6e\157\137\155\x61\164\143\x68\x5f\x66\157\x75\x6e\144"), "\x76\x61\154\x75\145" => $term))); } } public function update_status($id) { $this->form_validation->set_rules("\x73\164\x61\x74\165\163", lang("\x73\164\141\x74\x75\x73"), "\x72\145\161\165\x69\162\145\144"); if ($this->form_validation->run() == true) { $status = $this->input->post("\163\x74\x61\x74\165\x73"); $note = $this->sma->clear_tags($this->input->post("\156\x6f\164\145")); } elseif ($this->input->post("\x75\x70\144\141\x74\145")) { $this->session->set_flashdata("\x65\162\162\x6f\x72", validation_errors()); admin_redirect($_SERVER["\110\x54\124\x50\x5f\122\x45\106\105\122\105\x52"] ?? "\x73\141\x6c\x65\x73"); } if ($this->form_validation->run() == true && $this->quotes_model->updateStatus($id, $status, $note)) { $this->session->set_flashdata("\155\145\x73\x73\141\147\x65", lang("\163\164\141\x74\x75\x73\137\x75\x70\144\x61\164\145\144")); admin_redirect($_SERVER["\110\x54\x54\x50\x5f\x52\105\106\105\x52\x45\122"] ?? "\x73\141\x6c\145\x73"); } else { $this->data["\151\156\166"] = $this->quotes_model->getQuoteByID($id); $this->data["\x6d\x6f\144\141\154\x5f\x6a\x73"] = $this->site->modal_js(); $this->load->view($this->theme . "\x71\165\x6f\x74\x65\x73\57\165\160\x64\141\x74\145\x5f\163\164\141\x74\165\163", $this->data); } } public function view($quote_id = null) { $this->sma->checkPermissions("\x69\156\144\x65\x78"); if ($this->input->get("\x69\x64")) { $quote_id = $this->input->get("\151\x64"); } $this->data["\x65\x72\162\x6f\x72"] = validation_errors() ? validation_errors() : $this->session->flashdata("\145\162\x72\157\x72"); $inv = $this->quotes_model->getQuoteByID($quote_id); if (!$this->session->userdata("\x76\151\145\x77\137\x72\151\147\x68\164")) { $this->sma->view_rights($inv->created_by); } $this->data["\162\x6f\167\x73"] = $this->quotes_model->getAllQuoteItems($quote_id); $this->data["\x63\x75\163\x74\157\x6d\145\x72"] = $this->site->getCompanyByID($inv->customer_id); $this->data["\x62\151\x6c\154\x65\x72"] = $this->site->getCompanyByID($inv->biller_id); $this->data["\x63\x72\x65\x61\164\145\144\x5f\142\x79"] = $this->site->getUser($inv->created_by); $this->data["\x75\x70\x64\141\164\145\144\137\x62\x79"] = $inv->updated_by ? $this->site->getUser($inv->updated_by) : null; $this->data["\167\x61\x72\145\x68\x6f\x75\163\145"] = $this->site->getWarehouseByID($inv->warehouse_id); $this->data["\151\x6e\166"] = $inv; $bc = array(array("\x6c\151\x6e\x6b" => base_url(), "\x70\x61\147\x65" => lang("\150\x6f\x6d\145")), array("\x6c\151\156\153" => admin_url("\x71\x75\x6f\164\145\163"), "\x70\141\x67\x65" => lang("\161\165\x6f\164\x65\x73")), array("\x6c\x69\156\153" => "\43", "\x70\x61\x67\x65" => lang("\x76\151\x65\x77"))); $meta = array("\x70\x61\x67\145\x5f\x74\151\164\154\x65" => lang("\x76\151\145\x77\137\x71\165\157\164\145\137\x64\x65\x74\x61\x69\154\x73"), "\142\143" => $bc); $this->page_construct("\161\165\x6f\x74\145\x73\x2f\x76\x69\x65\167", $meta, $this->data); } }
Function Calls
None |
Stats
MD5 | 9387328b5842b076c8905029cd353fba |
Eval Count | 0 |
Decode Time | 88 ms |