add account on product move
This commit is contained in:
parent
41215c1bfb
commit
b2bd7975db
@ -271,6 +271,12 @@ class Products extends BaseController {
|
||||
$results = $query->getResultArray();
|
||||
$data['sites'] = $results;
|
||||
|
||||
|
||||
$sql = "select * from accounts";
|
||||
$query = $db->query($sql);
|
||||
$results = $query->getResultArray();
|
||||
$data['accounts'] = $results;
|
||||
|
||||
$data['productowners'] = $this->data['productowners'];
|
||||
|
||||
if ($this->request->getMethod() === 'POST') {
|
||||
@ -289,7 +295,8 @@ class Products extends BaseController {
|
||||
'siteid' => $this->request->getVar('siteid'),
|
||||
'oldlocationenddate' => $this->request->getVar('oldlocationenddate'),
|
||||
'newlocationstartdate' => $this->request->getVar('newlocationstartdate'),
|
||||
'productowner' => $this->request->getVar('productowner')
|
||||
'productowner' => $this->request->getVar('productowner'),
|
||||
'accountid_productowner' => $this->request->getVar('accountid_productowner'),
|
||||
];
|
||||
|
||||
if($this->validate($rules)){
|
||||
@ -299,16 +306,16 @@ class Products extends BaseController {
|
||||
$oldlocationenddate = $data['new_value']['oldlocationenddate'];
|
||||
$newlocationstartdate = $data['new_value']['newlocationstartdate'];
|
||||
$productowner = $data['new_value']['productowner'];
|
||||
|
||||
$accountid_productowner = $data['new_value']['accountid_productowner'];
|
||||
// products_log
|
||||
$sql = "INSERT INTO products_log
|
||||
(productid, siteid, catalogid, locationstartdate, locationenddate, installationdate, warrantystartdate, warrantyenddate, productowner, productserviceid, statuspart, logdate )
|
||||
SELECT productid, siteid,catalogid, locationstartdate, '$oldlocationenddate', installationdate, warrantystartdate, warrantyenddate, productowner, productserviceid, statuspart, NOW()
|
||||
(productid, siteid, catalogid, locationstartdate, locationenddate, installationdate, warrantystartdate, warrantyenddate, productowner, productserviceid, statuspart, accountid_productowner, logdate )
|
||||
SELECT productid, siteid,catalogid, locationstartdate, '$oldlocationenddate', installationdate, warrantystartdate, warrantyenddate, productowner, productserviceid, statuspart, accountid_productowner, NOW()
|
||||
FROM products WHERE productid='$productid'";
|
||||
$query = $db->query($sql);
|
||||
|
||||
// products
|
||||
$sql = "update products set siteid='$siteid', locationstartdate='$newlocationstartdate', productowner='$productowner' where productid='$productid'";
|
||||
$sql = "update products set siteid='$siteid', locationstartdate='$newlocationstartdate', productowner='$productowner', accountid_productowner='$accountid_productowner' where productid='$productid'";
|
||||
$query = $db->query($sql);
|
||||
return view('form_success');
|
||||
} else {
|
||||
|
||||
@ -8,6 +8,7 @@ $siteid = '';
|
||||
$newlocationstartdate = '';
|
||||
$oldlocationenddate = '';
|
||||
// $installationdate = '';
|
||||
$accountid_productowner = '';
|
||||
$productowner = '';
|
||||
if(isset($products)) { $data = $products[0]; }
|
||||
if(isset($new_value)) { $data = $new_value; }
|
||||
@ -16,6 +17,7 @@ if(isset($data)) {
|
||||
$siteid = $data['siteid'];
|
||||
if(isset($data['newlocationstartdate'])) { $newlocationstartdate = $data['newlocationstartdate']; }
|
||||
if(isset($data['oldlocationenddate'])) { $oldlocationenddate = $data['oldlocationenddate']; }
|
||||
if(isset($data['accountid_productowner'])) { $accountid_productowner = $data['accountid_productowner']; }
|
||||
|
||||
// if (isset($data['installationdate'])) {
|
||||
// $installationdate = $data['installationdate'];
|
||||
@ -114,6 +116,23 @@ if(isset($data)) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-3 col-form-label">Account Product Owner</label>
|
||||
<div class="col-9">
|
||||
<select class="form-control select2" name='accountid_productowner' >
|
||||
<option value=''>-</option>
|
||||
<?php
|
||||
foreach ($accounts as $data) {
|
||||
$qaccountid = $data['accountid'];
|
||||
$qaccountname = $data['accountname'];
|
||||
if ($qaccountid == $accountid_productowner) { echo "<option value='$qaccountid' selected>$qaccountname</option>"; }
|
||||
else { echo "<option value='$qaccountid'>$qaccountname</option>"; }
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="button" class="btn btn-dark float-start" onclick="window.close()">Cancel</button>
|
||||
<button type="submit" class="btn btn-success text-white float-end"> <i class="fa fa-check"></i> Submit</button>
|
||||
</form>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user