File: /home/temp/yarusvl.ru/adminx/ajax/change_sup_cats.php
<?php
class ChangeSupAjax extends Mgc {
/*Отображеие статистики заказов*/
public function fetch() {
if(!$this->managers->access('suppliers')) {
return false;
}
$query = $this->db->placehold('SELECT * FROM __categories_suppliers WHERE id=? ',$this->request->post("id"));
$this->db->query($query);
$data = $this->db->result();
$sql = "SELECT product_id FROM __products_sup_id WHERE sup_id=? ";
$sql = $this->db->placehold($sql,$data->sup_id);
$this->db->query($sql);
$prods = $this->db->results();
if($prods)
foreach ($prods as $prod){
$this->categories->delete_product_category($prod->product_id,19);
$this->categories->add_product_category($prod->product_id, $data->cat_id);
$query = $this->db->placehold("update __categories_suppliers SET updated=? WHERE id=?",time(),$this->request->post("id"));
$this->db->query($query);
}
return array("ok"=>$data);
}
}
$ajax = new ChangeSupAjax();
header("Content-type: application/json; charset=utf-8");
header("Cache-Control: must-revalidate");
header("Pragma: no-cache");
header("Expires: -1");
$json = json_encode($ajax->fetch());
print $json;