HEX
Server: Apache/2.4.6 (CentOS) mpm-itk/2.4.7-04 mod_fcgid/2.3.9 PHP/5.4.16
System: Linux dvm.vladweb.ru 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: region-gk.ru (1016)
PHP: 7.3.33
Disabled: NONE
Upload Files
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;