Advertisement
Guest User

Untitled

a guest
Jul 11th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     $products = array();
  2.     $sections = array();
  3.     $pagetype = array();
  4.     $names = array();
  5.    
  6.     $query = $this->db->query('select id,in_stock from product_stock');
  7.     foreach($query->result() as $row) {
  8.       $products[$row->id] = FALSE;
  9.       if($row->in_stock == 'out') $products[$row->id] = TRUE;
  10.     }
  11.    
  12.     $disallowed = array('product-detail','%detail');
  13.    
  14.     $query = $this->db->query("select id,contents,pagetype,name from product_info
  15.                               where id not like 'deleted%'
  16.                               and pagetype not like '" . implode("' and pagetype not like '", $disallowed) . "'");
  17.     foreach($query->result() as $row) {
  18.       $out = 0;
  19.       $count = count($row->contents);
  20.      
  21.       foreach(explode(' ', $row->contents) as $content) {
  22.         if(isset($products[$content])) {
  23.           ($products[$content]?$out++:null);
  24.         }
  25.       }
  26.       $cooking .= $row->id ."\t" .$row->pagetype ."\t" .$row->name ."\t" .$count ."\t" .$out ."\t" .($out/$count)*100 ."\n";
  27.     }
  28.  
  29.     $cooking = "id\tpagetype\tname\tnumber in section\tnumber out of stock\t% out of stock\n" . $cooking;
  30.    
  31.     force_download('oosreport_section.txt',$cooking);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement