123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177 |
- <?php
- /*
- * WigsStockUp Class
- * by lijg 20191017
- */
- require_once 'library/mdb.php';
- require_once 'library/common.php';
- class WigsMemoCtrl{
- public function __construct(){
- $this->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 .= "<div class=\"list_block\" id=\"{$item['id']}\">";
- $line .= "<span class=\"id\">{$item['id']}</span>";
- $line .= "<span class=\"goods_info\" title=\"{$goods_info}\">{$goods_info}</span>";
- $line .= "<span class=\"print_num\" title=\"{$item['print_num']}\">{$item['print_num']}</span>";
- $line .= "<span class=\"print_status {$print_clazz}\" title=\"{$print_status}\">{$print_status}</span>";
- $line .= "<span class=\"create_time\" title=\"{$item['create_time']}\">{$item['create_time']}</span>";
- $line .= '<span class="options">';
- $line .= "<input type=\"button\" class=\"print_bc\" data-id=\"{$item['id']}\" value=\"打印\">";
- $line .= '</span></div>';
- }
- 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 = '<span class="total_page" data-ttpg="'.$num.'">共 '.$num.' 页</span>';
- if($num > 1){
- $pagination .= ($num>10)?"<span class=\"gtlt head\" data-wh=\"h{$whh}\"><<</span>":'';
- $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 .= "<span class=\"{$clazz}\" onclick=\"getOFP('{$i}')\">".$i."</span>";
- }
- }
- $pagination .= ($num>10)?"<span class=\"gtlt tail\" data-wh=\"t{$wht}\">>></span>":'';
- }
- $pagination .= "<span>展示 <select class=\"pnsn\">";
- $pns = array('15', '50', '100', '250', '500');
- for($i=0; $i<5; $i++){
- if($pnsn == $pns[$i]){
- $s = 'selected="selected"';
- }else{
- $s = '';
- }
- $pagination .= "<option value=\"{$pns[$i]}\" {$s}>{$pns[$i]}条</option>";
- }
- $pagination .= "</select> 记录</span>";
- 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 .= '<div>';
- $str.=$val['content'];
- $str .= '</div>';
- }
- }
- return $str;
- }
- }
-
- public function __destruct(){
- //TODO
- }
- }
|