| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303 | <?phpini_set('display_errors', 1);session_start(); // starts new or resumes existing sessionDoo::loadModelAt('auser', 'admin');Doo::loadModelAt('ausers', 'admin');Doo::loadModelAt('ameasure', 'admin');Doo::loadModelAt('fileup', 'admin');Doo::loadModelAt('measureaudit', 'admin');Doo::loadModelAt('numofper', 'admin');Doo::loadModel('users');Doo::loadClass('profile');Doo::loadClass('contractact');Doo::loadClass('PasswordHash');Doo::loadClass('mailer');Doo::loadClass('project');Doo::loadClass('attfile');/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */// 列表停用 编辑 重置密码// 管理员权限管理// 管理员修改密码class ProController extends DooController{    private $data, $users, $user, $profile, $ph, $userz, $mailer, $project, $am, $cc, $an, $attfile, $ama, $statusArray = array('uncheck' => '<span class = "colGray">未上报</span>', 'checking' => '<span class = "colOrange">审核中</span>', 'checked' => '<span class = "colGreen">完成</span>', 'checkno' => '<span class = "colRed">不通过</span>'), $statusArray2 = array('uncheck' => '', 'checking' => '<span class = "colOrange">审批中</span>', 'checked' => '<span class = "colGreen">审批通过</span>', 'checkno' => '<span class = "colRed">审批不通过</span>');    public function beforeRun($resource, $action)    {        if (!isset($_SESSION['auid'])) {            return Doo::conf()->APP_URL . 'manage';        }    }    public function __construct()    {        $this->users = new AUsers();        $this->user = new AUser();        $this->userz = new Users();        $this->profile = new Profile();        $this->mailer = new Mailer();        $this->ph = new PasswordHash(8, FALSE);        $this->am = new Ameasure();        $this->ama = new AmeasureAudit();        $this->af = new Afileup();        $this->an = new Anumofper();        $this->project = new Project();        $this->cc = new Contractact();        $this->attfile = new attFile();        $this->data['rootUrl'] = Doo::conf()->APP_URL;    }    public function index()    {        if(isset($_POST['type']) && isset($_POST['pid'])){            if($_POST['type'] == 'del'){                $num = $this->cc->getNumRow($_POST['pid']);                if($num > 0){                    die(json_encode(array('status' => 1)));                }else{                    die(json_encode(array('status' => 2)));                }            }            if($_POST['type'] == "delpro"){                $this->project->del($_POST['pid']);                die(json_encode(array('status' => 'ok')));            }        }        $pArray = $this->project->getAll();        if(!empty($pArray)){            foreach($pArray as $k => $v){                $pArray[$k]['mnum'] = $this->cc->getNumRow($v['pid']);                $userfile = $this->profile->getProWithUid($v['uid']);                $company = !empty($userfile['company']) ? '-'.$userfile['company'] : '';                $pArray[$k]['uname'] = $userfile['name'].$company;            }        }        $this->data['pArray'] = $pArray;        $this->data['menu'] = 5;        $this->render('admin-project', $this->data, TRUE);    }    public function section()    {        if(isset($_POST['type'])){            if($_POST['type'] == 'del' && isset($_POST['stid'])){                $num = $this->am->getRowNum($_POST['stid']);                if($num > 0){                    die(json_encode(array('status' => 1)));                }else{                    die(json_encode(array('status' => 2)));                }            }            if($_POST['type'] == 'delpro' && isset($_POST['stid'])){                $this->cc->del($_POST['stid']);                die(json_encode(array('status' => 'ok')));            }            if($_POST['type'] == 'delmcheck' && isset($_POST['pmid'])){                $num = $this->an->getLastNew2($_POST['pmid']);                if(isset($num['numpname']) && !empty($num['numpname']) && $num['numpname'] != 1 && $num['times'] != 1){                    die(json_encode(array('status' => 1)));                }else{                    die(json_encode(array('status' => 2)));                }            }            if($_POST['type'] == 'delmpro' && isset($_POST['pmid'])){                $this->am->del($_POST['pmid']);                //删除该标段下第1期#1所有审批人列表                $anmsg = $this->an->getLastNew2($_POST['pmid']);                if(!empty($anmsg)){                    $muaudits = $this->ama->getAuditsByMpid($anmsg['mpid']);                    if(!empty($muaudits)){                        foreach($muaudits as $k => $v){                            $this->ama->del($v['maid']);                        }                    }                    $this->an->del($anmsg['mpid']);                    //文件列也要删除,不然软件报错                    $this->attfile->delAllTimesFile2($anmsg['mpid']);                }                die(json_encode(array('status' => 'ok')));            }        }        $typeArray = $this->cc->getRowByPid($this->params['pid']);        if(!empty($typeArray)){            foreach($typeArray as $k => $v){                $datarows = $this->am->getRowswith($v['stid']);                if(!empty($datarows)){                    foreach($datarows as $dk => $dv){                        $userfile = $this->profile->getProWithUid($dv['uid']);                        $datarows[$dk]['name'] = $userfile['name'];                        $company = !empty($userfile['company']) ? '-'.$userfile['company'] : '';                        $datarows[$dk]['company'] = $company;                        //获取第几期和审核状态                        $countNum = $this->an->getLastNew2($dv['pmid'])['numpname'];                        if (!isset($countNum)) {                            $countNum = 0;                        }                        $lastStatusArray = $this->an->getMaxStatusTimes($dv['pmid'], $countNum);                        $datarows[$dk]['num'] = $countNum;                        $datarows[$dk]['status'] =  $countNum != 0 ? $this->statusArray[$lastStatusArray['currstatus']] : '';                    }                }                $typeArray[$k]['datarows'] = $datarows;            }        }        $this->data['pid'] = $this->params['pid'];        $this->data['typeArray'] = $typeArray;        $this->data['menu'] = 5;        $this->render('admin-section', $this->data, TRUE);    }    public function period(){        if(isset($_POST['op'])){            if($_POST['op'] == 'pass' && isset($_POST['maid'])){                $mamsg = $this->ama->getRowData($_POST['maid']);                if(!empty($mamsg)){                    $mumsg = $this->an->getRowByMpid($mamsg['mpid']);                    //修改期数状态                    if(!empty($mumsg)){                        $nextmumsg = $this->ama->getAuditByMpidStatus($mamsg['mpid'],'uncheck');                        if(!empty($nextmumsg)){                            $this->ama->updateStatus($nextmumsg['maid'],'checking');                        }else{                            $this->an->updateAuditStatus($mamsg['mpid'],'checked');                        }                    }                    //修改状态为checked                    $this->ama->updateStatus($_POST['maid'],'checked');                    $this->attfile->updateHash($mumsg['pmid'], $mumsg['numpname'], $mumsg['times']);                }                die(json_encode(array('status' => 'ok')));            }            if($_POST['op'] == 'unpass' && isset($_POST['maid'])){                $mamsg = $this->ama->getRowData($_POST['maid']);                if(!empty($mamsg)){                    $mumsg = $this->an->getRowByMpid($mamsg['mpid']);                    //修改期数状态                    if(!empty($mumsg)){                        $this->an->updateAuditStatus($mamsg['mpid'],'checkno');                    }                    //修改状态为checkno                    $this->ama->updateStatus($_POST['maid'],'checkno');                    $this->attfile->updateHash($mumsg['pmid'], $mumsg['numpname'], $mumsg['times']);                }                die(json_encode(array('status' => 'ok')));            }            if($_POST['op'] == 'checking' && isset($_POST['maid'])){                $mamsg = $this->ama->getRowData($_POST['maid']);                if(!empty($mamsg)){                    $mumsg = $this->an->getRowByMpid($mamsg['mpid']);                    //修改期数状态                    if(!empty($mumsg) && $mumsg['currstatus'] != 'checking'){                        $this->an->updateAuditStatus($mamsg['mpid'],'checking');                    }                    //修改上一审状态为uncheck,下一审状态为checking                    $lastmamsg = $this->ama->getAuditByMpidStatus($mamsg['mpid'],'checking');                    $this->ama->updateStatus($lastmamsg['maid'],'uncheck',2);                    $this->ama->updateStatus($_POST['maid'],'checking',2);                    $this->attfile->updateHash($mumsg['pmid'], $mumsg['numpname'], $mumsg['times']);                }                die(json_encode(array('status' => 'ok')));            }            if($_POST['op'] == 'delete' && isset($_POST['numpname']) && isset($_POST['times'])){                //删除该期审批人列表                $muaudits = $this->ama->getAuditsByPmidNumTimes($this->params['pmid'],$_POST['numpname'],$_POST['times']);                if(!empty($muaudits)){                    foreach($muaudits as $k => $v){                        $this->ama->del($v['maid']);                    }                }                $mumsg = $this->an->getMsgByPmidNumTimes($this->params['pmid'],$_POST['numpname'],$_POST['times']);                if(!empty($mumsg)){                    $this->an->del($mumsg['mpid']);                    //文件列也要删除,不然软件报错                    $this->attfile->delAllTimesFile2($mumsg['mpid']);                }                die(json_encode(array('status' => 'ok')));            }        }        $pmArray = $this->an->getGroupByLastOne2($this->params['pmid']);        //判断是否有获取未上报的数据,如果有则置顶;        $nopm = $this->ama->getLastAuditMsgByPmid($this->params['pmid']);        $this->data['pmid'] = $this->params['pmid'];        if(!empty($pmArray)){            $this->data['pid'] = $pmArray[0]['pid'];            $this->data['keymax'] = $pmArray[0]['numpname'];            if($nopm['numpname'] == $pmArray[0]['numpname'] && $nopm['times'] != $pmArray[0]['times']){                $nopmArray = array();                $nopmArray['mpid'] = $nopm['mpid'];                $nopmArray['numpname'] = $nopm['numpname'];                $nopmArray['times'] = $nopm['times']+1;                $audits2 = $this->ama->getAuditsByPmidNumTimes($nopm['pmid'],$nopm['numpname'],$nopm['times']);                $numaudits2 = $this->ama->getNumAuditsByPmidNumTimes($nopm['pmid'],$nopm['numpname'],$nopm['times']);                if(!empty($audits2)){                    foreach($audits2 as $ak => $av){                        $audits2[$ak]['numaudit'] = $numaudits2-$ak;                        $audits2[$ak]['status'] = $this->statusArray2[$av['mastatus']];                        $audits2[$ak]['auditcontent'] = !empty($av['auditcontent']) ? $av['auditcontent'] : '';                        $userfile = $this->profile->getProWithUid($av['auditoruid']);                        $company = !empty($userfile['company']) ? '-'.$userfile['company'] : '';                        $audits2[$ak]['name'] = $userfile['name'];                        $audits2[$ak]['company'] = $company;                        $audits2[$ak]['enable'] = 3;                    }                }                $nopmArray['audits'] = $audits2;                $this->data['nopmArray'] = $nopmArray;            }            foreach($pmArray as $k => $v){                $pmArray[$k]['times'] = $v['times']+1;                $audits = $this->ama->getAuditsByPmidNumTimes($v['pmid'],$v['numpname'],$v['times']);                $numaudits = $this->ama->getNumAuditsByPmidNumTimes($v['pmid'],$v['numpname'],$v['times']);                if(!empty($audits)){                    foreach($audits as $ak => $av){                        $audits[$ak]['numaudit'] = $numaudits-$ak;                        $audits[$ak]['status'] = $this->statusArray2[$av['mastatus']];                        $audits[$ak]['auditcontent'] = !empty($av['auditcontent']) ? $av['auditcontent'] : '';                        $userfile = $this->profile->getProWithUid($av['auditoruid']);                        $company = !empty($userfile['company']) ? '-'.$userfile['company'] : '';                        $audits[$ak]['name'] = $userfile['name'];                        $audits[$ak]['company'] = $company;                        $audits[$ak]['enable'] = 3;                        if($audits[0]['mastatus'] == 'checked'){                            $audits[0]['enable'] = 2;                        }else{                            if($av['mastatus'] == "checking"){                                $audits[$ak]['enable'] = 1;                            }                            if(($ak > 0 && $audits[$ak-1]['mastatus'] == "checking") || $av['mastatus'] == "checkno"){                                $audits[$ak]['enable'] = 2;                            }                        }                    }                }                $pmArray[$k]['audits'] = $audits;            }        }        $this->data['isnopm'] = isset($nopmArray) && !empty($nopmArray) ? 1 : 0;        $this->data['pmArray'] = $pmArray;        $this->data['menu'] = 5;        $this->render('admin-period', $this->data, TRUE);    }}
 |