diff --git a/app/Controllers/Activities.php b/app/Controllers/Activities.php index 86e3370..7713eb6 100644 --- a/app/Controllers/Activities.php +++ b/app/Controllers/Activities.php @@ -581,7 +581,7 @@ class Activities extends Controller { FROM products p LEFT JOIN productcatalog pc ON pc.`catalogid`=p.`catalogid` LEFT JOIN producttype pt ON pt.`producttypeid`= pc.`producttypeid` - WHERE p.siteid=$siteid and productaliasid<>0 + WHERE p.siteid=$siteid and productaliasid<>0 and COALESCE(active, 1) = 1 ORDER BY FIELD(pt.producttypeid, 20, 19, 21, 12, 10, 14, 11, 13, 4, 3) DESC, pc.productname"; $query = $db->query($sql); $results = $query->getResultArray(); diff --git a/app/Controllers/Products.php b/app/Controllers/Products.php index 8848af2..757220c 100644 --- a/app/Controllers/Products.php +++ b/app/Controllers/Products.php @@ -12,6 +12,7 @@ class Products extends BaseController { function __construct() { $this->data['productowners'] = array('S'=>'Summit', 'C'=> 'Customer', 'O' => 'Other'); + $this->data['productactives'] = array('1'=> 'Yes', '2'=>'No'); } // Get Data Dari CLQMS untuk MEAN Jumlah Test Selama 6 Bulan @@ -80,7 +81,7 @@ class Products extends BaseController { $where = 0; - $sql = "SELECT p.productid, p.installationdate ,pc.productname, pc.productaliasid, p.productnumber, s.sitename, pt.producttypeid, pt.texts, + $sql = "SELECT p.productid, p.installationdate, p.active, pc.productname, pc.productaliasid, p.productnumber, s.sitename, pt.producttypeid, pt.texts, z.zonename as city, z2.zonename as prov FROM products p left join productcatalog pc on pc.catalogid=p.catalogid @@ -160,7 +161,6 @@ class Products extends BaseController { $query = $db->query($sql); $results = $query->getResultArray(); $data['products_log'] = $results; - return view('products_view', $data); } @@ -191,6 +191,7 @@ class Products extends BaseController { $data['productservice'] = $results; $data['productowners'] = $this->data['productowners']; + $data['productactives'] = $this->data['productactives']; if ($this->request->getMethod() === 'POST') { @@ -211,17 +212,19 @@ class Products extends BaseController { 'warrantystartdate' => ($this->request->getVar('warrantystartdate') == '') ? NULL : $this->request->getVar('warrantystartdate'), 'warrantyenddate' => ($this->request->getVar('warrantyenddate') == '') ? NULL : $this->request->getVar('warrantyenddate'), 'productowner' => $this->request->getVar('productowner'), + 'active' => ($this->request->getVar('productactive') == '') ? NULL : $this->request->getVar('productactive'), 'productserviceid' => $this->request->getVar('productserviceid'), 'statuspart' => $this->request->getVar('statuspart'), 'remotetool' => $this->request->getVar('remotetool'), 'remoteid' => $this->request->getVar('remoteid'), 'remotepwd' => $this->request->getVar('remotepwd'), ]; - + foreach($data['new_value'] as $qkey => $qvalue) { if(empty( $qvalue ) ) { $data['new_value'][$qkey] = null; } else { $data['new_value'][$qkey] = $db->escapeString($qvalue); } } + if($productid != 0) { if($this->validate($rules)){ $productsModel = new ProductsModel(); @@ -432,8 +435,6 @@ class Products extends BaseController { 'statuspart' => $this->request->getVar('statuspart') ]; - // var_dump($data['new_value']);die(); - $productsLogModel = new ProductsLogModel(); $productsLogModel->update($productlogid, $data['new_value']); return view('form_success'); @@ -446,7 +447,6 @@ class Products extends BaseController { $productlogid = $this->request->getVar('logid'); $sql = "delete from products_log where productlogid='$productlogid'"; $query = $db->query($sql); - //echo "$sql"; } public function exportdata() { diff --git a/app/Models/ProductsModel.php b/app/Models/ProductsModel.php index d044a57..2a3605f 100644 --- a/app/Models/ProductsModel.php +++ b/app/Models/ProductsModel.php @@ -7,6 +7,6 @@ class ProductsModel extends Model { protected $primaryKey = 'productid'; protected $allowedFields = [ 'siteid', 'productnumber', 'productname', 'catalogid', 'installationdate', 'locationstartdate', 'locationenddate', 'warrantystartdate', 'warrantyenddate', - 'productowner', 'productserviceid', 'statuspart', + 'productowner', 'productserviceid', 'statuspart', 'active', 'remotetool', 'remoteid', 'remotepwd', 'createdate', 'enddate' ]; } \ No newline at end of file diff --git a/app/Views/products_edit.php b/app/Views/products_edit.php index db164c6..36c4cca 100644 --- a/app/Views/products_edit.php +++ b/app/Views/products_edit.php @@ -11,6 +11,7 @@ $installationdate = ''; $warrantystartdate = ''; $warrantyenddate = ''; $productowner = ''; +$productactive = ''; $statusservice = ''; $statuspart = ''; $remotetool = ''; @@ -29,10 +30,12 @@ if(isset($data)) { $warrantystartdate = $data['warrantystartdate']; $warrantyenddate = $data['warrantyenddate']; $productowner = $data['productowner']; + $productactive = ($data['active'] == NULL) ? '1' : $data['active']; $remotetool = $data['remotetool']; $remoteid = $data['remoteid']; $remotepwd = $data['remotepwd']; $productserviceid = $data['productserviceid']; + // var_dump($productactive);die(); } ?> @@ -43,12 +46,10 @@ if(isset($data)) { -
listErrors(); ?>
- @@ -140,6 +141,20 @@ if(isset($data)) { +
+ +
+ +
+
diff --git a/app/Views/products_index.php b/app/Views/products_index.php index da75130..f98f191 100644 --- a/app/Views/products_index.php +++ b/app/Views/products_index.php @@ -120,12 +120,18 @@ if(!isset($sitename)) { $sitename=''; } $date = new DateTime($installationdate); $installationdate = $date->format('M d, Y'); } else { $installationdate = ''; } + + if ($data['active'] == '2') { + $bg='bg-danger'; + } else { + $bg=''; + } /* if( $data['createdate'] != '' ) { $createdate = date('d-m-Y', strtotime($data['createdate'])); } else { $createdate = ''; } */ ?> - +