class common_templates { public function get_all_templates_by_type($type = '', $client_id) { global $database; $get_inventory = " SELECT templates.* FROM templates WHERE templates.type = '$type' AND templates.client_id = $client_id AND templates.status = 1 ORDER BY templates.id ASC "; $results = $database->getAll($get_inventory); return $results; } public function get_all_templates_by_client($client_id = '') { global $database; $get_inventory = " SELECT templates.* FROM templates WHERE templates.client_id = $client_id AND templates.status = 1 ORDER BY templates.id ASC "; $results = $database->getAll($get_inventory); return $results; } public function get_all_templates_by_status($status) { global $database; $get_inventory = " SELECT templates.*, clients.company_name FROM templates LEFT JOIN clients ON templates.client_id = clients.id WHERE templates.status = '$status' AND clients.status = 1 ORDER BY templates.id ASC "; $results = $database->getAll($get_inventory); return $results; } public function get_all_inventory_with_stock_take($status) { global $database; $get_inventory = " SELECT m.*, s.prove_by, s.real_quantity, s.submitter as stock_submitter, s.date_submitted as stock_submit_date, s.id as take_id FROM templates m LEFT JOIN stock_take s ON m.id = s.item_no AND s.prove_by =0 WHERE m.status = '$status' ORDER BY m.item_number ASC "; $results = $database->getAll($get_inventory); return $results; } public function get_templates($id) { global $database; $get_material = " SELECT * FROM templates WHERE id = '$id' LIMIT 1 "; $results = $database->getRow($get_material); return $results; } public function get_item_number($id) { global $database; $get_item_number = " SELECT item_number FROM templates WHERE id = '$id' LIMIT 1 "; $results = $database->getOne($get_item_number); return $results; } public function get_status($id) { global $database; $sql = " SELECT status FROM templates WHERE id = '$id' "; return $database->getOne($sql); } public function get_material_template_assigned($quote_id) { global $database; $sql = " SELECT template_ids FROM template_assigned WHERE quote_id = $quote_id "; return $database->getRow($sql); /*AND saved_in_material_costing = 0*/ } public function get_material_templates($ids = 0) { global $database; $result = array(); $ids = explode(',',$ids); // echo '
'; // print_r($ids); // echo 'count ids:'.count($ids); if($ids){ foreach ($ids as $key => $value) { if($value != ''){ $sql = " SELECT t.template_name, t.id FROM templates t WHERE t.id = $value AND t.status = 1 "; $result[]=$database->getRow($sql); } } } return $result; } } ?>