<?php
class main extends spController
{
	function index(){
	   $confignum=array('id'=>1);
       $mxszpt_confing=spClass("confing");
        $confignr=$this->confignr=$mxszpt_confing->find($confignum);
		$this->display("index.html");
	}
    
    function login(){
        $mxszpt_admin=spClass("admin");
        $new=array(
        $us_name=$this->spArgs('username'),
        $us_password=$this->spArgs('userpassword'),
        );
            $mxszpt_admin->verifier=$mxszpt_admin->verifier_login;
    $new=$mxszpt_admin->spVerifier($this->spArgs());
    if(false==$new){
        if(false==$mxszpt_admin->userlogin($us_name,$us_password)){
            $this->error("用户名或密码错误，请重新输入！");
        }else{
            spClass('spAcl')->set("admin"); 
           $this->success("登陆成功，欢迎您尊敬的管理员！",spUrl("main","adminindex")); 
            }
                }else{
            foreach($new as $item){
                    foreach($item as $msg){
                        $this->error($msg,spUrl("main","index"));
        }
        }
        }
    }
    
    function adminindex(){
                $this->display("adminlogin.html"); 
    }
    
    function guaji(){
        $danny=array('id'=>1);
        $mxszpt_mxszpta=spClass("timea");
        $mxszpt_mxszpt=spClass("time");
        $zzb=array('num'=>0);
        $zza=$this->zza=$mxszpt_mxszpt->findCount($zzb);
        $zzc=$this->zzc=$mxszpt_mxszpta->find($danny);
        $zzd=$zzc['num'];
        if($zza !=$zzd){
                $zzc=array('id'=>1);
                $zzd=array('num'=>$zza);
                $mxszpt_mxszpta->update($zzc,$zzd);
                         echo '<embed src="images/1.mp3" width=0 height=0 type=audio/mpeg loop="1"   autostart="true">';
                $this->display("guaji.html"); 

        }else{
                $this->display("guaji.html"); 
        }
 
    }
    
        function moren(){
       $this->display("moren.html");  
    }
    
    function header(){
         $this->display("header.html");
    }
    
        function menuzero(){
        $this->display("menuzero.html"); 
    }
    
        function adminedit(){
        $mxszpt_admin=spClass("admin");
        $row=array('id'=>$this->spArgs("id"));
        $new=$this->new=$mxszpt_admin->find($row);
        $this->display("adminedit.html");
    }
    
        function admineditzz(){
      $mxszpt_admin=spClass("admin");
      $new=array(
      'userpassword'=>$this->spArgs('userpassword'),
      );
      $row=array('id'=>$this->spArgs("id")); 
       if($new[userpassword]==""){
        $this->success("密码不能为空！");
       }else{   
      $mxszpt_admin->update($row,$new);
      $this->success("密码修改成功！");
    }
    }
    
       function logout(){
	   	$_SESSION = array();
	  	if (isset($_COOKIE[session_name()])) {setcookie(session_name(), '', time()-42000, '/');}
	   	session_destroy();
	   	$this->success("成功退出！", spUrl("main","index"));
	}
    
      function shopadd(){
        $this->display("shopadd.html");
      }
    
        function shopaddzz(){
            $row=array(
            'num'=>$this->spArgs('num'),
            'type'=>$this->spArgs('type'),
            'pay'=>$this->spArgs('pay'),
            'goodnum'=>$this->spArgs('goodnum'),
            'badnum'=>$this->spArgs('badnum'),
            'shopname'=>$this->spArgs('shopname'),
            'images'=>$this->spArgs('images'),
            'fbtime'=>date("Y-m-d H:i:s"),
            );
            $mxszpt_shop=spClass("shop");
            $mxszpt_shop->create($row);
            $this->success("添加产品成功！",spUrl("main","shopadd"));
        }
    
    function shoplist(){
        $mxszpt_shop=spClass("shop");
        $b=$mxszpt_shop->findAll();
        $b=$this->b=$mxszpt_shop->spPager($this->spArgs('page', 1), 15)->findAll(null, " fbtime DESC ");
        $this->pager = $mxszpt_shop->spPager()->getPager();
        $fenye=$this->fenye=$this->spArgs('name');
        $this->display("shoplist.html");
    }
    
    
        function shopdel(){
         $mxszpt_shop=spClass("shop");
        $row=array('id'=>$this->spArgs("id"));
        $mxszpt_shop->delete($row);
        $this->success("刪除成功！");
    }
    
    function book(){
         $mxszpt_ly=spClass("book");
       $row=array(
            'who'=>$this->spArgs('who'),
            'contents'=>$this->spArgs('contents'),
            'time'=>date("Y-m-d H:i:s"),
            ); 
           $mxszpt_ly->create($row); 
           spclass('splog')->warn("有新留言信息！");
                     $newtime=filemtime("temp/.access.warn.log");
             $mxszpt_mxszpt=spClass("time");
            $rowtime=array('time'=>$newtime);
             $mxszpt_mxszpt->create($rowtime);
           $this->success("留言成功！等待管理员查看",spUrl("main","index"));
    }
    
    function bookshow(){
              $mxszpt_ly=spClass("book");
        $b=$mxszpt_ly->findAll();
        $b=$this->b=$mxszpt_ly->spPager($this->spArgs('page', 1), 15)->findAll(null, " time DESC ");
        $this->pager = $mxszpt_ly->spPager()->getPager();
        $fenye=$this->fenye=$this->spArgs('name');
        $this->display("bookshow.html");  
    }
    
    function bookdel(){
         $mxszpt_ly=spClass("book");
        $row=array('id'=>$this->spArgs("id"));
        $mxszpt_ly->delete($row);
        $this->success("刪除成功！");
    }
    
    
    function two(){
        $mxszpt_shop=spClass("shop");
        $b=$mxszpt_shop->findAll();
        $b=$this->b=$mxszpt_shop->spPager($this->spArgs('page', 1), 15)->findAll(null, " fbtime DESC ");
        $this->pager = $mxszpt_shop->spPager()->getPager();
        $fenye=$this->fenye=$this->spArgs('name');
        	   $confignum=array('id'=>1);
       $mxszpt_confing=spClass("confing");
        $confignr=$this->confignr=$mxszpt_confing->find($confignum);
        spclass('splog')->warn("有新的员工登陆！");
                     $newtime=filemtime("temp/.access.warn.log");
             $mxszpt_mxszpt=spClass("time");
            $rowtime=array('time'=>$newtime);
             $mxszpt_mxszpt->create($rowtime);
        $this->display("two.html");
    }
    
    function three(){
        $mxszpt_shop=spClass("shop");
        $id=$this->spArgs('id');
        $a=array('id'=>$this->spArgs('id'));
        $name=$this->spArgs('name');
        $this->name=$name;
        $num=$this->spArgs('num');
        $this->num=$num;
        $this->id=$id;
        $row=$this->row=$mxszpt_shop->find($a);
        	   $confignum=array('id'=>1);
       $mxszpt_confing=spClass("confing");
        $confignr=$this->confignr=$mxszpt_confing->find($confignum);
        $this->display("three.html");
    }
    

    
    function threea(){
        $row=array(
            'pay'=>$this->spArgs('pay'),
            'goodnum'=>$this->spArgs('goodnum'),
            'badnum'=>$this->spArgs('badnum'),
            'shopname'=>$this->spArgs('shopname'),
            'num'=>$this->spArgs('num'),
            'cid'=>$this->spArgs('id'),
            'gxtime'=>date("Y-m-d H:i:s"),
            );
            $this->row=$row;
                   $mxszpt_shopls=spClass("linshi");
                $danny=array('id'=>$this->spArgs('id'));
                $mxszpt_shopls->create($row);
        $confignum=array('id'=>1);
       $mxszpt_confing=spClass("confing");
        $confignr=$this->confignr=$mxszpt_confing->find($confignum);
        spclass('splog')->warn("有新的入库申请！");
        $newtime=filemtime("temp/.access.warn.log");
                     $mxszpt_mxszpt=spClass("time");
            $rowtime=array('time'=>$newtime);
             $mxszpt_mxszpt->create($rowtime);
            $this->display("four.html");
    }
    
    function threeb(){
          $rows = spAccess('r' , 'zhangzhen');
         $this->rows=$rows;
                 $confignum=array('id'=>1);
       $mxszpt_confing=spClass("confing");
        $confignr=$this->confignr=$mxszpt_confing->find($confignum);
        $this->display("foura.html");
    }
    
    function linshi(){
         $row=array(
            'gxtime'=>date("Y-m-d H:i:s"),
            'shopname'=>$this->spArgs('shopname'),
            'num'=>$this->spArgs('num'),
            'cid'=>$this->spArgs('id'),
            'gdpay'=>$this->spArgs('gdpay'),
            'bz'=>$this->spArgs('bz'),
            ); 
             spAccess('w',  'zhangzhen', $row, 3600);
            $mxszpt_shopls=spClass("linshi");
 $mxszpt_shopls->verifier=$mxszpt_shopls->verifier_linshia;
    $new=$mxszpt_shopls->spVerifier($this->spArgs());
    if(false==$new){
             $mxszpt_shopls->create($row);
            spclass('splog')->warn("有新的入库申请！");
                     $newtime=filemtime("temp/.access.warn.log");
             $mxszpt_mxszpt=spClass("time");
            $rowtime=array('time'=>$newtime);
             $mxszpt_mxszpt->create($rowtime);
            $this->success("请用心填写并提交，谢谢！",spUrl("main","threeb"));
                }else{
            foreach($new as $item){
                    foreach($item as $msg){
                        $this->error($msg,spUrl("main","two"));
        }
        }
        }
    }
    
        function linshia(){
         $row=array(
            'shopname'=>$this->spArgs('shopname'),
            'gxtime'=>date("Y-m-d H:i:s"),
            'num'=>$this->spArgs('num'),
            'cid'=>$this->spArgs('id'),
            'bdpay'=>$this->spArgs('bdpay'),
            'bza'=>$this->spArgs('bza'),
            );   
            $mxszpt_shopls=spClass("linshi");
 $mxszpt_shopls->verifier=$mxszpt_shopls->verifier_linshib;
    $new=$mxszpt_shopls->spVerifier($this->spArgs());
    if(false==$new){
             $mxszpt_shopls->create($row);
            spclass('splog')->warn("有新的入库申请！");
                     $newtime=filemtime("temp/.access.warn.log");
             $mxszpt_mxszpt=spClass("time");
            $rowtime=array('time'=>$newtime);
             $mxszpt_mxszpt->create($rowtime);
            $this->success("请用心填写并提交，谢谢！",spUrl("main","two"));
                }else{
            foreach($new as $item){
                    foreach($item as $msg){
                        $this->error($msg,spUrl("main","two"));
        }
        }
        }
    }
    
    
    function linshishow(){
        $mxszpt_shopls=spClass("linshi");
        $b=$mxszpt_shopls->findAll();
        $b=$this->b=$mxszpt_shopls->spPager($this->spArgs('page', 1), 15)->findAll(null, " gxtime DESC ");
        $this->pager = $mxszpt_shopls->spPager()->getPager();
        $fenye=$this->fenye=$this->spArgs('name');
        $this->display("linshishow.html");
    }
    
    function linshidel(){
        $mxszpt_shopls=spClass("linshi");
        $row=array('id'=>$this->spArgs("id"));
        $mxszpt_shopls->delete($row);
        $this->success("刪除成功！"); 
    }
    
    function linshiok(){
        $a=array('id'=>$this->spArgs('id'));
          $mxszpt_shopls=spClass("linshi");
                    $mxszpt_shop=spClass("shop");
          $row=$this->row=$mxszpt_shopls->find($a);
          $num=array('id'=>$row['cid']);
            $zz=$this->zz=$mxszpt_shop->find($num);
            dump ($zz);
                $b=$zz['goodnum'];
                $c=$zz['badnum'];
          $new=array(
          'num'=>$row['num'],
          'pay'=>$row['pay'],
          'goodnum'=>$row['goodnum']+$b,
          'badnum'=>$row['badnum']+$c,
          'gxtime'=>$row['gxtime'],
   //       'gdpay'=>$row['gdpay'],
  //        'bdpay'=>$row['bdpay'],
  //        'bz'=>$row['bz'],
  //        'bza'=>$row['bza'],
          ); 
          dump ($new);
          $mxszpt_shop->update($num, $new);
         $newrow=array('yesno'=>1);
          $mxszpt_shopls->update($a, $newrow);
          $this->success("审批成功！您幸苦了！");
    }
    
        function linshioka(){
        $a=array('id'=>$this->spArgs('id'));
          $mxszpt_shopls=spClass("linshi");
                    $mxszpt_shop=spClass("shop");
          $row=$this->row=$mxszpt_shopls->find($a);
          $num=array('id'=>$row['cid']);
            $zz=$this->zz=$mxszpt_shop->find($num);
            dump ($zz);
                $b=$zz['goodnum'];
                $c=$zz['badnum'];
          $new=array(
    //      'num'=>$row['num'],
    //      'pay'=>$row['pay'],
  //        'goodnum'=>$row['goodnum']+$b,
   //       'badnum'=>$row['badnum']+$c,
          'gxtime'=>$row['gxtime'],
         'gdpay'=>$row['gdpay'],
  //        'bdpay'=>$row['bdpay'],
          'bz'=>$row['bz'],
  //        'bza'=>$row['bza'],
          ); 
          dump ($new);
          $mxszpt_shop->update($num, $new);
          $newrow=array('yesno'=>1);
          $mxszpt_shopls->update($a, $newrow);
          $this->success("审批成功！您幸苦了！");
    }
    
    
        function linshiokb(){
        $a=array('id'=>$this->spArgs('id'));
          $mxszpt_shopls=spClass("linshi");
                    $mxszpt_shop=spClass("shop");
          $row=$this->row=$mxszpt_shopls->find($a);
          $num=array('id'=>$row['cid']);
            $zz=$this->zz=$mxszpt_shop->find($num);
            dump ($zz);
                $b=$zz['goodnum'];
                $c=$zz['badnum'];
          $new=array(
  //        'num'=>$row['num'],
  //        'pay'=>$row['pay'],
  //        'goodnum'=>$row['goodnum']+$b,
  //        'badnum'=>$row['badnum']+$c,
          'gxtime'=>$row['gxtime'],
   //       'gdpay'=>$row['gdpay'],
          'bdpay'=>$row['bdpay'],
  //        'bz'=>$row['bz'],
          'bza'=>$row['bza'],
          ); 
          dump ($new);
          $mxszpt_shop->update($num, $new);
          $newrow=array('yesno'=>1);
          $mxszpt_shopls->update($a, $newrow);
          $this->success("审批成功！您幸苦了！");
    }
    
    
    function confing(){
        $a=array('id'=>1);
        $mxszpt_confing=spClass("confing");
        $row=$this->row=$mxszpt_confing->find($a);
        $this->display('confing.html');
    }
    
    function confingedit(){
        $num=array('id'=>1);
        $row=array(
        'onename'=>$this->spArgs('onename'),
        'twoname'=>$this->spArgs('twoname'),
        'threename'=>$this->spArgs('threename'),
        'fourname'=>$this->spArgs('fourname'),
        'fivename'=>$this->spArgs('fivename'),
        'titel_color'=>$this->spArgs('titel_color'),
        'title_font'=>$this->spArgs('title_font'),
                        'titel_colora'=>$this->spArgs('titel_colora'),
        'title_fonta'=>$this->spArgs('title_fonta'),
                'titel_colorb'=>$this->spArgs('titel_colorb'),
        'title_fontb'=>$this->spArgs('title_fontb'),
                          'titel_colorc'=>$this->spArgs('titel_colorc'),
        'title_fontc'=>$this->spArgs('title_fontc'),  
         'titel_colord'=>$this->spArgs('titel_colord'),
        'title_fontd'=>$this->spArgs('title_fontd'),     
        );
            $mxszpt_confing=spClass("confing");
            $mxszpt_confing->update($num,$row); 
            $this->success("修改标语成功！您幸苦了！");  
    }
    
    function goout(){
        $new=array(
         'brivername'=>$this->spArgs('brivername'),
         'brivernum'=>$this->spArgs('brivernum'),
         'sale'=>$this->spArgs('sale'),
         'tel'=>$this->spArgs('tel'),
         'qq'=>$this->spArgs('qq'),
         'city'=>$this->spArgs('city'),
         'dont'=>$this->spArgs('dont'),
         'dontmodel'=>$this->spArgs('dontmodel'),
         'dontnum'=>$this->spArgs('dontnum'),
         'overdue'=>$this->spArgs('overdue'),
         'time'=>date("Y-m-d H:i:s"),
          ); 
         $mxszpt_goout=spClass("goout"); 
         $mxszpt_goout->create($new); 
                    spclass('splog')->warn("有新的出入库表单！");
                     $newtime=filemtime("temp/.access.warn.log");
             $mxszpt_mxszpt=spClass("time");
            $rowtime=array('time'=>$newtime);
             $mxszpt_mxszpt->create($rowtime);
         $this->success("您好，已经提交成功！",spUrl("main","two"));
    }
    
    function gooutlist(){
               $mxszpt_goout=spClass("goout");
        $b=$mxszpt_goout->findAll();
        $b=$this->b=$mxszpt_goout->spPager($this->spArgs('page', 1), 15)->findAll(null, " time DESC ");
        $this->pager = $mxszpt_goout->spPager()->getPager();
        $fenye=$this->fenye=$this->spArgs('name');
        $this->display("gooutlist.html"); 
    }
    
            function gooutdel(){
         $mxszpt_goout=spClass("goout");
        $row=array('id'=>$this->spArgs("id"));
        $mxszpt_goout->delete($row);
        $this->success("刪除成功！");
    }
    
}