Add minimum ROAS functionality to product management; implement saving and display in product listing
This commit is contained in:
22
.vscode/ftp-kr.sync.cache.json
vendored
22
.vscode/ftp-kr.sync.cache.json
vendored
@@ -15,6 +15,12 @@
|
||||
},
|
||||
"autoload": {
|
||||
"controls": {
|
||||
"class.Allegro.php": {
|
||||
"type": "-",
|
||||
"size": 6456,
|
||||
"lmtime": 0,
|
||||
"modified": false
|
||||
},
|
||||
"class.Api.php": {
|
||||
"type": "-",
|
||||
"size": 11018,
|
||||
@@ -29,14 +35,14 @@
|
||||
},
|
||||
"class.Cron.php": {
|
||||
"type": "-",
|
||||
"size": 18166,
|
||||
"size": 18168,
|
||||
"lmtime": 1734812301104,
|
||||
"modified": false
|
||||
"modified": true
|
||||
},
|
||||
"class.Products.php": {
|
||||
"type": "-",
|
||||
"size": 6779,
|
||||
"lmtime": 1734386753537,
|
||||
"size": 6777,
|
||||
"lmtime": 1736159781898,
|
||||
"modified": false
|
||||
},
|
||||
"class.Site.php": {
|
||||
@@ -67,8 +73,8 @@
|
||||
},
|
||||
"class.Products.php": {
|
||||
"type": "-",
|
||||
"size": 3708,
|
||||
"lmtime": 1734812409871,
|
||||
"size": 4108,
|
||||
"lmtime": 1736159665616,
|
||||
"modified": false
|
||||
},
|
||||
"class.Users.php": {
|
||||
@@ -2712,8 +2718,8 @@
|
||||
"products": {
|
||||
"main_view.php": {
|
||||
"type": "-",
|
||||
"size": 6819,
|
||||
"lmtime": 1734385931827,
|
||||
"size": 6808,
|
||||
"lmtime": 1736161322024,
|
||||
"modified": false
|
||||
},
|
||||
"product_history.php": {
|
||||
|
||||
@@ -58,7 +58,8 @@ class Products
|
||||
\S::number_display( $row['cpc'] ),
|
||||
round( $row['conversions'], 2 ),
|
||||
\S::number_display( $row['conversions_value'] ),
|
||||
$row['roas'],
|
||||
$row['roas'] <= $row['min_roas'] ? '<span class="text-danger">' . $row['roas'] . '</span>' : $row['roas'],
|
||||
'<input type="text" class="form-control min_roas" product_id="' . $row['product_id'] . '" value="' . $row['min_roas'] . '" style="width: 100px;">',
|
||||
'',
|
||||
'<input type="text" class="form-control custom_label_4" product_id="' . $row['product_id'] . '" value="' . $custom_label_4 . '">'
|
||||
];
|
||||
@@ -68,6 +69,20 @@ class Products
|
||||
exit;
|
||||
}
|
||||
|
||||
static public function save_min_roas()
|
||||
{
|
||||
$product_id = \S::get( 'product_id' );
|
||||
$min_roas = \S::get( 'min_roas' );
|
||||
|
||||
if ( \factory\Products::save_min_roas( $product_id, $min_roas ) )
|
||||
{
|
||||
echo json_encode( [ 'status' => 'ok' ] );
|
||||
}
|
||||
else
|
||||
echo json_encode( [ 'status' => 'error' ] );
|
||||
exit;
|
||||
}
|
||||
|
||||
static public function save_custom_label_4()
|
||||
{
|
||||
$product_id = \S::get( 'product_id' );
|
||||
|
||||
@@ -2,16 +2,20 @@
|
||||
namespace factory;
|
||||
class Products
|
||||
{
|
||||
static public function save_min_roas( $product_id, $min_roas )
|
||||
{
|
||||
global $mdb;
|
||||
return $mdb -> update( 'products', [ 'min_roas' => $min_roas ], [ 'id' => $product_id ] );
|
||||
}
|
||||
|
||||
static public function get_products( $client_id, $search, $limit, $start, $order_name, $order_dir )
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( $search )
|
||||
return $mdb -> query( 'SELECT pt.*, p.offer_id FROM products_temp AS pt INNER JOIN products AS p ON p.id = pt.product_id WHERE client_id = \'' . $client_id . '\' AND pt.name LIKE \'%' . $search . '%\' ORDER BY ' . $order_name . ' ' . $order_dir . ' LIMIT ' . $start . ', ' . $limit ) -> fetchAll();
|
||||
else {
|
||||
// echo 'SELECT pt.*, p.offer_id FROM products_temp AS pt INNER JOIN products AS p ON p.id = pt.product_id WHERE client_id = \'' . $client_id . '\' ORDER BY ' . $order_name . ' ' . $order_dir . ' LIMIT ' . $start . ', ' . $limit;
|
||||
return $mdb -> query( 'SELECT pt.*, p.offer_id FROM products_temp AS pt INNER JOIN products AS p ON p.id = pt.product_id WHERE client_id = \'' . $client_id . '\' ORDER BY ' . $order_name . ' ' . $order_dir . ' LIMIT ' . $start . ', ' . $limit ) -> fetchAll();
|
||||
}
|
||||
return $mdb -> query( 'SELECT pt.*, p.offer_id, p.min_roas FROM products_temp AS pt INNER JOIN products AS p ON p.id = pt.product_id WHERE client_id = \'' . $client_id . '\' AND ( pt.name LIKE \'%' . $search . '%\' OR offer_id = ' . (int)$search . ' ) ORDER BY ' . $order_name . ' ' . $order_dir . ' LIMIT ' . $start . ', ' . $limit ) -> fetchAll();
|
||||
else
|
||||
return $mdb -> query( 'SELECT pt.*, p.offer_id, p.min_roas FROM products_temp AS pt INNER JOIN products AS p ON p.id = pt.product_id WHERE client_id = \'' . $client_id . '\' ORDER BY ' . $order_name . ' ' . $order_dir . ' LIMIT ' . $start . ', ' . $limit ) -> fetchAll();
|
||||
}
|
||||
|
||||
static public function get_records_total_products( $client_id, $search )
|
||||
@@ -19,7 +23,7 @@ class Products
|
||||
global $mdb;
|
||||
|
||||
if ( $search )
|
||||
return $mdb -> query( 'SELECT COUNT(0) FROM products_temp AS pt INNER JOIN products AS p ON p.id = pt.product_id WHERE client_id = \'' . $client_id . '\' AND pt.name LIKE \'%' . $search . '%\'' ) -> fetchColumn();
|
||||
return $mdb -> query( 'SELECT COUNT(0) FROM products_temp AS pt INNER JOIN products AS p ON p.id = pt.product_id WHERE client_id = \'' . $client_id . '\' AND ( pt.name LIKE \'%' . $search . '%\' OR offer_id = ' . (int)$search . ' )' ) -> fetchColumn();
|
||||
else
|
||||
return $mdb -> query( 'SELECT COUNT(0) FROM products_temp AS pt INNER JOIN products AS p ON p.id = pt.product_id WHERE client_id = \'' . $client_id . '\'' ) -> fetchColumn();
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
<th scope="col">Konw.</th>
|
||||
<th scope="col">Wartość konw.</th>
|
||||
<th scope="col">ROAS</th>
|
||||
<th scope="col">Min. ROAS</th>
|
||||
<th scope="col">CL3</th>
|
||||
<th scope="col">CL4</th>
|
||||
</tr>
|
||||
@@ -79,12 +80,34 @@
|
||||
{ width: 'auto', name: 'conversions' },
|
||||
{ width: 'auto', name: 'conversions_value', className: "dt-type-numeric" },
|
||||
{ width: 'auto', name: 'roas' },
|
||||
{ width: '100px', name: 'min_roas' },
|
||||
{ width: 'auto', name: 'cl3', orderable: false },
|
||||
{ width: '200px', orderable: false }],
|
||||
order: [ [ 5, 'desc' ] ]
|
||||
});
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'change', '.min_roas', function()
|
||||
{
|
||||
var input = $( this );
|
||||
var product_id = $( this ).attr( 'product_id' );
|
||||
var min_roas = $( this ).val();
|
||||
|
||||
input.addClass('saving');
|
||||
$.ajax({
|
||||
url: '/products/save_min_roas/',
|
||||
type: 'POST',
|
||||
data: {
|
||||
product_id: product_id,
|
||||
min_roas: min_roas
|
||||
},
|
||||
success: function( response ) {
|
||||
},
|
||||
complete: function() {
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
$( 'body' ).on( 'change', '.custom_label_4', function()
|
||||
{
|
||||
var input = $( this );
|
||||
|
||||
Reference in New Issue
Block a user