class form_order_material{ public $id; public $config; public $validation; public $reasons; public $sign_counter; public $department; public $status_table; public $status_id; public function __construct($context){ $this->id = $context['id']; $this->matid = $context['matid']; $this->status_table = $context['status_table']; $this->status_id = $context['status']; $this->department_id = $context['dept_id']; $this->sign_counter = 0; } public function set(){ global $database; $id = $this->id; $db_name = $this->db_name; $order = common_stock::get_details_raw($_GET['id']); if($order){ $delivery_date_arr = explode(' ', $order['delivery_date']); $order_date_arr = explode(' ', $order['order_date']); $this->delivery_date = dates::change_to_nice($delivery_date_arr[0]); $this->order_date = dates::change_to_nice($order_date_arr[0]); $this->order_number = $order['order_no']; } if(!empty($this->matid)){ $material_detail = common_stock::get_material_detail_raw($this->matid); $this->order_no = $material_detail['order_no']; $this->cost = $material_detail['cost']; $this->material = $material_detail['item_no']; $this->supplier = $material_detail['supplier_no']; $this->quantity = $material_detail['order_quantity']; $this->received = $material_detail['num_received']; $delivery_date_arr = explode(' ', $material_detail['delivery_date']); $order_date_arr = explode(' ', $material_detail['order_date']); $this->delivery_date = dates::change_to_nice($delivery_date_arr[0]); $this->order_date = dates::change_to_nice($order_date_arr[0]); } if($_POST['Submit'] == "Create") { $this->order_no = $_POST['order_no']; $this->cost = $_POST['cost']; $this->material = $_POST['material']; $this->supplier = $_POST['supplier']; $this->quantity = $_POST['quantity']; $this->delivery_date = $_POST['delivery_date']; $this->order_date = $_POST['order_date']; } $this->config['order_no'] = array("id"=> $id,"value"=> $_GET['id'], "input_name" => "order_no", "name" => "Order No.","rule" => "required|alpha_numeric"); $this->config['cost'] = array("id"=> $id,"value"=> $this->cost, "input_name" => "cost", "name" => "Cost","rule" => "required|numeric"); $this->config['material'] = array("id"=> $id,"value"=> $this->material, "input_name" => "material", "name" => "Material","rule" => "required"); $this->config['supplier'] = array("id"=> $id,"value"=> $this->supplier, "input_name" => "supplier", "name" => "Supplier","rule" => "required"); $this->config['quantity'] = array("id"=> $id,"value"=> $this->quantity, "input_name" => "quantity", "name" => "Quantity","rule" => "required|numeric"); $this->config['delivery_date'] = array("id"=> $id,"value"=> $this->delivery_date, "input_name" => "delivery_date", "name" => "Delivery Date","rule" => "required"); $this->config['order_date'] = array("id"=> $id,"value"=> $this->order_date, "input_name" => "order_date", "name" => "Order Date","rule" => ""); $this->config['received'] = array("id"=> $id,"value"=> $this->received, "input_name" => "received", "name" => "Received","rule" => "numeric"); self::run_validation(); } public function run_validation(){ $static_function = (($_POST['Submit'] == "")) ? "initial" : "validate"; $this->validation['order_no'] = validation::$static_function($this->config['order_no']); $this->validation['cost'] = validation::$static_function($this->config['cost']); $this->validation['material'] = validation::$static_function($this->config['material']); $this->validation['supplier'] = validation::$static_function($this->config['supplier']); $this->validation['quantity'] = validation::$static_function($this->config['quantity']); $this->validation['delivery_date'] = validation::$static_function($this->config['delivery_date']); $this->validation['order_date'] = validation::$static_function($this->config['order_date']); if(!empty($this->matid)){$this->validation['received'] = validation::$static_function($this->config['received']);} $this->reasons = validation::formalise($this->validation); } public function form(){ global $database; $id = $this->id; $form_type = $this->form_type; $config = $this->config; $validation = $this->validation; $text_options = array("class" => "medium"); $text_options_small = array("class" => "small"); $text_area_options = array("class" => "medium"); $select_options = array("class" => "medium form"); $text_options_small_readonly['class'] = "small"; $text_options_small_readonly['attr'] = "readonly"; $options_select_medium = array("class"=>"medium"); ?>
Order Number: |