WigsStockUpYZCtrl.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <?php
  2. require_once 'library/mdb.php';
  3. require_once 'library/common.php';
  4. class WigsStockUpYZCtrl{
  5. public function __construct(){
  6. $this->db = new MdbLib();
  7. $this->common = new CommonLib();
  8. }
  9. public function getGoods(){
  10. $pnsnyz = isset($_POST['pnsnyz'])?$this->common->my_filter_input($_POST['pnsnyz']):15;
  11. $now = isset($_POST['now'])?$this->common->my_filter_input($_POST['now']):1;
  12. $offset = ($now-1)*$pnsnyz;
  13. $sql = "SELECT `id`,`use`,`color`,`model`,`length`,`curvature`,`density`,`print_num`,`print_times`,`delivery_date` FROM `app_wigsstockup_yz` ORDER BY `id` DESC LIMIT {$offset},{$pnsnyz};";
  14. $query = $this->db->querySql($sql);
  15. $line = "";
  16. while($item = $this->db->queryRs($query)) {
  17. if($item['print_times'] == 0){
  18. $print_status = "未打印";
  19. $print_clazz = 'no';
  20. }else{
  21. $print_status = "已打印";
  22. $print_clazz = 'ok2';
  23. }
  24. $goods_info = "{$item['use']} {$item['model']} {$item['length']} {$item['curvature']} {$item['color']} {$item['density']}";
  25. $line .= "<div class=\"list_block\" id=\"{$item['id']}\">";
  26. $line .= "<span class=\"id\">{$item['id']}</span>";
  27. $line .= "<span class=\"goods_info\" title=\"{$goods_info}\">{$goods_info}</span>";
  28. $line .= "<span class=\"print_num\" title=\"{$item['print_num']}\">{$item['print_num']}</span>";
  29. $line .= "<span class=\"create_time\" title=\"{$item['delivery_date']}\">{$item['delivery_date']}</span>";
  30. $line .= "<span class=\"print_status {$print_clazz}\" title=\"{$print_status}\">{$print_status}</span>";
  31. $line .= '<span class="options">';
  32. $line .= "<input type=\"button\" class=\"print_bc\" data-id=\"{$item['id']}\" value=\"打印\">";
  33. $line .= '</span></div>';
  34. }
  35. return $line;
  36. }
  37. public function pagination(){
  38. if(!isset($_POST['wh'])){
  39. return false;
  40. }else{
  41. $wh = $this->common->my_filter_input($_POST['wh']);
  42. $pnsnyz = isset($_POST['pnsnyz'])?$this->common->my_filter_input($_POST['pnsnyz']):15;
  43. }
  44. $sql = "SELECT `id` FROM `app_wigsstockup_yz`;";
  45. $query = $this->db->querySql($sql);
  46. $total = $this->db->queryNum($query);
  47. if($total == 0){
  48. $num = '0';
  49. }else{
  50. $num = ceil($total/$pnsnyz);
  51. $wh_max = ceil($num/10);
  52. }
  53. $direction = substr($wh, 0, 1);
  54. $wh = substr($wh, 1);
  55. if($direction == 'h'){
  56. $whh = ($wh==0)?'0':$wh-1;
  57. $wht = ($wh==0)?'1':$wh;
  58. }elseif($direction == 't'){
  59. $whh = ($wh==$wh_max)?($wh-1):$wh;
  60. $wht = ($wh==$wh_max)?$wh:($wh+1);
  61. }else{
  62. $whh = '0';
  63. $wht = '1';
  64. }
  65. $pagination = '<span class="total_page" data-ttpg="'.$num.'">共&nbsp;'.$num.'&nbsp;页</span>';
  66. if($num > 1){
  67. $pagination .= ($num>10)?"<span class=\"gtlt head\" data-wh=\"h{$whh}\">&lt;&lt;</span>":'';
  68. $clazz = '';
  69. for($i=1+$whh*10; $i<=10+$whh*10; $i++){
  70. if($i > $num){
  71. break;
  72. }else{
  73. if($i != 1+$whh*10){
  74. $clazz = 'page';
  75. }else{
  76. $clazz = 'page pn';
  77. }
  78. $pagination .= "<span class=\"{$clazz}\" onclick=\"getOFP('{$i}')\">".$i."</span>";
  79. }
  80. }
  81. $pagination .= ($num>10)?"<span class=\"gtlt tail\" data-wh=\"t{$wht}\">&gt;&gt;</span>":'';
  82. }
  83. $pagination .= "<span>展示 <select class=\"pnsnyz\">";
  84. $pns = array('15', '50', '100', '250', '500');
  85. for($i=0; $i<5; $i++){
  86. if($pnsnyz == $pns[$i]){
  87. $s = 'selected="selected"';
  88. }else{
  89. $s = '';
  90. }
  91. $pagination .= "<option value=\"{$pns[$i]}\" {$s}>{$pns[$i]}条</option>";
  92. }
  93. $pagination .= "</select> 记录</span>";
  94. return $pagination;
  95. }
  96. public function addStock(){
  97. if(isset($_POST['form']) && !empty($_POST['form'])){
  98. $insert = '(';
  99. foreach($_POST['form'] as $val){
  100. $insert .= "'{$this->common->my_filter_input($val)}',";
  101. }
  102. $insert .= '0)';
  103. }else{
  104. return false;
  105. }
  106. $sql = "INSERT INTO `app_wigsstockup_yz` (`use`,`curvature`,`model`,`length`,`color`,`density`,`print_num`,`delivery_date`,`print_times`) VALUES {$insert};";
  107. if($this->db->querySql($sql)){
  108. return 1;
  109. }else{
  110. return -1;
  111. }
  112. }
  113. public function updatePrint(){
  114. if(isset($_POST['id']) && !empty($_POST['id'])){
  115. $id = $this->common->my_filter_input($_POST['id']);
  116. }else{
  117. return false;
  118. }
  119. $sql = "UPDATE `app_wigsstockup_yz` SET `print_times`=`print_times`+1 WHERE `id`='{$id}';";
  120. if($this->db->querySql($sql)){
  121. return 1;
  122. }else{
  123. return -1;
  124. }
  125. }
  126. public function printAll(){
  127. $sql = 'SELECT `use`,`color`,`model`,`length`,`curvature`,`density`,`print_num` FROM `app_wigsstockup_yz` WHERE `print_times`=0;';
  128. $query = $this->db->querySql($sql);
  129. $rs = $this->db->queryRsAll($query);
  130. if(empty($rs)){
  131. return -1;
  132. }else{
  133. $sql_update = 'UPDATE `app_wigsstockup_yz` SET `print_times`=`print_times`+1 WHERE `print_times`=0;';
  134. $query_update = $this->db->querySql($sql_update);
  135. $str = '';
  136. foreach($rs as $val){
  137. for($i=0; $i<$val['print_num']; $i++){
  138. $str .= '<div>';
  139. $str .= $val['use'].' '.$val['model'].' '.$val['length'].' '.$val['curvature'].' '.$val['color'].' '.$val['density'].'</div>';
  140. }
  141. }
  142. return $str;
  143. }
  144. }
  145. public function __destruct(){
  146. //TODO
  147. }
  148. }