trochu modifikuju SMS klientovi na míru, požaduje hromadné mazání a (de)aktivace produktů. Přidal jsem tam checkboxy, v atributu name je pole (name="check[id]"), jenže teď nevím, jak smazat ty zaškrtnuté.
Moje myšlenka je sesbírat si IDčka (klíče z foreach $_POST['check']), seskládat si z nich string oddělený čárkami a udělat dotaz
Code: Select all
...WHERE product_id IN (1, 4, 89)
Vezmu-li například (DE)AKTIVACI (mazání bude obdobné), vyskytuje se zde:
- products.api.php, ř. cca 300
Code: Select all
<?php
function EnableProduct($product) {
$db =& $this->module->GetDb();
$dict = NewDataDictionary($db);
$sql = "UPDATE ".cms_db_prefix()."module_sms_products SET active = ?
WHERE product_id = ?";
$dbresult = $db->Execute( $sql, array($product['active'], $product['product_id']));
if( !$dbresult ) {
return false;
}
return true;
}
?>
Code: Select all
<?php
// Set the product id of which the status is to be changed
$enable_product = $this->products->Get($params['current_product_id']);
// Now prepare the new status
$enable_product['active'] = $enable_product['active'] == 0 ? 1 : 0;
// Set the product to the new status
$this->products->EnableProduct($enable_product);
// Status has been swapped, refresh the admin screen with the categories/products
$params = array('active_tab'=>'products', 'current_category_id'=>$params['current_category_id'], 'current_product_id'=>$enable_product['parent_id']);
$this->Redirect( $id, 'defaultadmin', $returnid, $params );
?>
Poradíte mi někdo, jak na to? Moc mi to pomůže
