Update Untuk Kolom Active pada Tabel Product

This commit is contained in:
mikael-zakaria 2025-09-01 22:42:12 +07:00
parent 1cbf604e8b
commit 6820de87e2
5 changed files with 32 additions and 11 deletions

View File

@ -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();

View File

@ -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() {

View File

@ -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' ];
}

View File

@ -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)) {
<?php
if(isset($validation)) {
?>
<div class='alert alert-danger alert-dismissible'>
<?= $validation->listErrors(); ?>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"> <span aria-hidden="true"></span> </button>
</div>
<?php
}
?>
@ -140,6 +141,20 @@ if(isset($data)) {
</select>
</div>
</div>
<div class="form-group row">
<label class="col-3 col-form-label">Active Status</label>
<div class="col-9">
<select class='form-control' name='productactive'>
<option value=''></option>
<?php
foreach($productactives as $qactive => $qname) {
if($qactive == $productactive) { echo "<option value='$qactive' selected>$qname</option>"; }
else { echo "<option value='$qactive'>$qname</option>"; }
}
?>
</select>
</div>
</div>
<div class="form-group row">
<label class="col-3 col-form-label">Status Part</label>
<div class="col-9"><input class="form-control" type="text" name='statuspart' value="<?=$statuspart;?>"></div>

View File

@ -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 = ''; } */
?>
<tr>
<tr class='<?php echo($bg); ?>'>
<td><?=$productid;?></td>
<td><?=$sitename;?></td>
<td><?=$prov;?></td>