db = new MdbLib(); $this->common = new CommonLib(); } public function getGoods(){ $pnsn = isset($_POST['pnsn'])?$this->common->my_filter_input($_POST['pnsn']):15; $now = isset($_POST['now'])?$this->common->my_filter_input($_POST['now']):1; $offset = ($now-1)*$pnsn; $sql = "SELECT `id`,`content`,`print_num`,`print_times`,`create_time` FROM `app_wigsmemo` ORDER BY `id` DESC LIMIT {$offset},{$pnsn};"; $query = $this->db->querySql($sql); $line = ""; while($item = $this->db->queryRs($query)) { if($item['print_times'] == 0){ $print_status = "未打印"; $print_clazz = 'no'; }else{ $print_status = "已打印"; $print_clazz = 'ok2'; } $goods_info = $item['content']; // if(!empty($item['use'])){ // $goods_info .= $item['use'].' '; // } // if(!empty($item['color'])){ // $goods_info .= $item['color'].' '; // } // if($item['lace_color'] == 'n/a'){ // $item['lace_color'] = ''; // }else{ // $item['lace_color'] = ' '.$item['lace_color']; // } $goods_info .= "{$item['model']}{$item['lace_color']} {$item['length']} {$item['curvature']} {$item['density']} {$item['size']}"; $line .= "
"; $line .= "{$item['id']}"; $line .= "{$goods_info}"; $line .= "{$item['print_num']}"; $line .= "{$print_status}"; $line .= "{$item['create_time']}"; $line .= ''; $line .= ""; $line .= '
'; } return $line; } public function pagination(){ if(!isset($_POST['wh'])){ return false; }else{ $wh = $this->common->my_filter_input($_POST['wh']); $pnsn = isset($_POST['pnsn'])?$this->common->my_filter_input($_POST['pnsn']):15; } $sql = "SELECT `id` FROM `app_wigsmemo`;"; $query = $this->db->querySql($sql); $total = $this->db->queryNum($query); if($total == 0){ $num = '0'; }else{ $num = ceil($total/$pnsn); $wh_max = ceil($num/10); } $direction = substr($wh, 0, 1); $wh = substr($wh, 1); if($direction == 'h'){ $whh = ($wh==0)?'0':$wh-1; $wht = ($wh==0)?'1':$wh; }elseif($direction == 't'){ $whh = ($wh==$wh_max)?($wh-1):$wh; $wht = ($wh==$wh_max)?$wh:($wh+1); }else{ $whh = '0'; $wht = '1'; } $pagination = '共 '.$num.' 页'; if($num > 1){ $pagination .= ($num>10)?"<<":''; $clazz = ''; for($i=1+$whh*10; $i<=10+$whh*10; $i++){ if($i > $num){ break; }else{ if($i != 1+$whh*10){ $clazz = 'page'; }else{ $clazz = 'page pn'; } $pagination .= "".$i.""; } } $pagination .= ($num>10)?">>":''; } $pagination .= "展示 记录"; return $pagination; } public function addStock(){ if(isset($_POST['form']) && !empty($_POST['form'])){ $insert = '('; foreach($_POST['form'] as $val){ $insert .= "'{$this->common->my_filter_input($val)}',"; } $insert .= '0)'; }else{ return false; } $sql = "INSERT INTO `app_wigsmemo` (`content`,`print_num`,`print_times`) VALUES {$insert};"; if($this->db->querySql($sql)){ return 1; }else{ return -1; } } public function updatePrint(){ if(isset($_POST['id']) && !empty($_POST['id'])){ $id = $this->common->my_filter_input($_POST['id']); }else{ return false; } $sql = "UPDATE `app_wigsmemo` SET `print_times`=`print_times`+1 WHERE `id`='{$id}';"; if($this->db->querySql($sql)){ return 1; }else{ return -1; } } public function printAll(){ $sql = 'SELECT `content`,`print_num` FROM `app_wigsmemo` WHERE `print_times`=0;'; $query = $this->db->querySql($sql); $rs = $this->db->queryRsAll($query); if(empty($rs)){ return -1; }else{ $sql_update = 'UPDATE `app_wigsmemo` SET `print_times`=`print_times`+1 WHERE `print_times`=0;'; $query_update = $this->db->querySql($sql_update); $str = ''; foreach($rs as $val){ for($i=0; $i<$val['print_num']; $i++){ $str .= '
'; $str.=$val['content']; $str .= '
'; } } return $str; } } public function __destruct(){ //TODO } }