| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169 | <?phpDoo::loadCore('auth/DooAuth');Doo::loadClass('PasswordHash');Doo::loadClass('client');Doo::loadClass('auth');Doo::loadClass('attachment');Doo::loadClass('attfile');Doo::loadClass('actmeasure');Doo::loadClass('contractact');Doo::loadClass('project');Doo::loadClass('profile');Doo::loadClass('numofperact');Doo::loadClass('measureauditact');Doo::loadClass('itemfile');Doo::loadModel('users');Doo::loadClass('itemmeasurenum');Doo::loadModelAt('aconfig', 'admin');Doo::loadClass('sms');Doo::loadClass('sign');Doo::loadClass('measureconcerner');Doo::loadClass('change');////                       _oo0oo_//                      o8888888o//                      88" . "88//                      (| -_- |)//                      0\  =  /0//                    ___/`---'\___//                  .' \|     |// './/                 / \|||  :  |||// \//                / _||||| -:- |||||- \//               |   | \  -  /// |     |//               | \_|  ''\---/''  |_/ |//               \  .-\__  '-'  ___/-. ///             ___'. .'  /--.--\  `. .'___//          ."" '<  `.___\_<|>_/___.' >' "".//         | | :  `- \`.;`\ _ /`;.`/ - ` : | |//         \  \ `_.   \_ __\ /__ _/   .-` /  ///     =====`-.____`.___ \_____/___.-`___.-'=====//                       `=---='//////     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~////               佛祖保佑         永无BUG///** * MainController * Feel free to delete the methods and replace them with your own code. * * @author NoNZero */class ClientController extends DooController{    private $data, $sign, $change, $concern, $client, $auth, $att, $file, $zip, $actmeasure, $contractact, $project, $profile, $numofperact, $measureauditact, $attfile, $users, $itemfile, $modelconfig, $aconfig, $sms, $itemMeasureNum;    private $changeType = array('1' => 'A.位置', '2' => 'B.数量', '3' => 'C.结构', '4' => 'D.新增', '5' => 'E.取消', '6' => 'F.纠错');    private $changeCategory = array('1' => 'A类变更(设计变更)', '2' => 'B类变更(施工措施变更)', '3' => 'C类变更(计划变更)', '4' => 'D类变更(条件变更)', '5' => 'E类变更(新增工程)');    private $changeNature = array('1' => '一般设计变更', '2' => '较大设计变更', '3' => '重大设计变更');    private $statusArray = array('uncheck' => '1', 'checking' => '2', 'checked' => '3', 'checkno' => '4');    private $fileTypeArray = array('台帐附件');    public function __construct()    {        $this->data['rootUrl'] = Doo::conf()->APP_URL;        $this->client = new client();        $this->auth = new Auth();        $this->att = new attachment();        $this->attfile = new attFile();        $this->zip = new ZipArchive();        $this->actmeasure = new actMeasure();        $this->contractact = new Contractact();        $this->project = new Project();        $this->profile = new Profile();        $this->numofperact = new NumofperAct();        $this->measureauditact = new MeasureauditAct();        $this->users = new Users();        $this->itemfile = new ItemFile();        $this->modelconfig = new AConfig();        $this->itemMeasureNum = new ItemMeasureNumpofper();        $this->aconfig = new AConfig();        $this->sign = new signn();        $this->concern = new MeasureConcerner();        $this->change = new Changes();        $this->sms = new Sms(Doo::conf()->SMS_URL, Doo::conf()->SMS_AUTHKEY);    }    public function ClientSignin()    {        if (isset($_POST['zhname']) && isset($_POST['zhpass'])) {            echo json_encode(array('status' => FALSE, 'msg' => '登录失败,请更新软件。'), JSON_UNESCAPED_UNICODE);            die;        }        if (isset($_POST['uname']) && isset($_POST['upass'])) {            echo json_encode(array('status' => FALSE, 'msg' => '登录失败,请更新软件。'), JSON_UNESCAPED_UNICODE);            die;        }        if (isset($_POST['v3name']) && isset($_POST['v3name'])) {            echo json_encode(array('status' => FALSE, 'msg' => '登录失败,请更新软件。'), JSON_UNESCAPED_UNICODE);            die;        }                if (!empty($_POST['version'])) {            try {                if ($this->modelconfig->getOne(array('select' => 'onoff', 'asArray' => TRUE))['onoff'] != 1) {                                        $versionTotal = implode("",explode('.', $_POST['version']));                    $StrJson = ($this->modelconfig->getOne(array('select' => 'upgradeinfo', 'asArray' => TRUE))['upgradeinfo']);                    $jsonObj = json_decode($StrJson, true);                    if ($jsonObj) {                        $versionTotalUp = implode("",explode('.', $jsonObj['version']));                        $strJson = json_encode(array('status' => 'upgrade', 'msg' => '您的客户端需要升级,请点击确定按钮,下载新版本,并且覆盖安装。', 'url' => $jsonObj['download']), JSON_UNESCAPED_UNICODE);                        if ($jsonObj['condition'] == 1) {                            if ($versionTotalUp != $versionTotal) {                                echo $strJson;                                die;                            }                        }                        if ($jsonObj['condition'] == 2) {                            if ($versionTotalUp > $versionTotal) {                                echo $strJson;                                die;                            }                        }                    }                    if (isset($_POST['logintype']) && $_POST['logintype'] == 2) {                        if ($this->auth->loginWithUserName($_POST['v4name'])) {                            $uinfo = $this->auth->getUinfo();                            if (isset($uinfo['isstop']) && $uinfo['isstop'] > 0) {                                echo json_encode(array('status' => FALSE, 'msg' => '帐号不存在或者密码错误'), JSON_UNESCAPED_UNICODE);                                die;                            }                            if (isset($uinfo['uid'])) {                                $userArray = $this->profile->getProWithUid($uinfo['uid']);                                $avatarStr = $userArray['avatar'];                                if (isset($userArray['userid'])) {                                    $msgArray = array('uid' => $uinfo['uid'], 'name' => $userArray['name'], 'email' => $uinfo['uemail'], 'ucompany' => $userArray['company'], 'jobtitle' => $userArray['jobs'], 'avatar' => Doo::conf()->APP_URL . $avatarStr);                                    echo json_encode(array('status' => TRUE, 'msg' => '', 'userinfo' => $msgArray), JSON_UNESCAPED_UNICODE);                                    die;                                }                            }                        } else {                            echo json_encode(array('status' => FALSE, 'msg' => '帐号不存在或者密码错误'), JSON_UNESCAPED_UNICODE);                            die;                        }                    } else {                        if(isset($_POST['v4name']) && isset($_POST['v4pass'])) {                            if ($this->auth->login($_POST['v4name'], $_POST['v4pass'])) {                                $uinfo = $this->auth->getUinfo();                                if (isset($uinfo['isstop']) && $uinfo['isstop'] > 0) {                                    echo json_encode(array('status' => 'false', 'msg' => '帐号不存在或者密码错误'), JSON_UNESCAPED_UNICODE);                                    die;                                }                                if (isset($uinfo['uid'])) {                                    $userArray = $this->profile->getProWithUid($uinfo['uid']);                                    $avatarStr = $userArray['avatar'];                                    if (isset($userArray['userid'])) {                                        $msgArray = array('uid' => $uinfo['uid'], 'name' => $userArray['name'], 'email' => $uinfo['uemail'], 'ucompany' => $userArray['company'], 'jobtitle' => $userArray['jobs'], 'avatar' => Doo::conf()->APP_URL . $avatarStr);                                        echo json_encode(array('status' => 'true', 'msg' => '', 'userinfo' => $msgArray), JSON_UNESCAPED_UNICODE);                                        die;                                    }                                }                            } else {                                echo json_encode(array('status' => 'false', 'msg' => '帐号不存在或者密码错误'), JSON_UNESCAPED_UNICODE);                                die;                            }                        }else{                            echo json_encode(array('status' => 'false', 'msg' => '参数错误'), JSON_UNESCAPED_UNICODE);                            die;                        }                    }                } else {                    echo json_encode(array('status' => 'false', 'msg' => '该计量支付已关闭,请联系相关管理人员。'), JSON_UNESCAPED_UNICODE);                    die;                }            } catch (Exception $exc) {            }        } else {            echo json_encode(array('status' => 'false', 'msg' => '参数错误'), JSON_UNESCAPED_UNICODE);            die;        }    }    // 创建标段    // 参数:用户ID,创建名称,KEY    function ClientCreatmeasure()    {        if (isset($this->params['uid']) && $this->params['uid'] && isset($this->params['bname']) && $this->params['bname'] && $this->params['ckey'] && isset($this->params['ckey'])) {            $retval = $this->contractact->getPidWithKey($this->params['ckey']);            if (isset($retval['pid'])) {                $pArray = $this->project->getRowByPid($retval['pid']);                if (isset($this->params['uid']) && ($this->params['uid'] == $pArray['uid'])) {                    $status = array('status' => FALSE, 'msg' => '业主不能作为编制人新建标段!');                    echo json_encode($status, JSON_UNESCAPED_UNICODE);                    die();                }                $id = $this->actmeasure->insertMeasure(intval($this->params['uid']), $retval['pid'], $retval['stid'], iconv('GBK', 'UTF-8', $this->params['bname']));                $this->measureauditact->insertMeasureAudit($pArray['pid'], 0, $pArray['uid'], 0, $id, $retval['stid'], 1, 'uncheck', 1); //加入业主                $uArray = $this->profile->getProWithUid($retval['uid']);                $strAvatar = $this->auth->getAvatar($uArray['userid']);                $createArray = array('catid' => $id, 'name' => $uArray['name'], 'avatar' => $strAvatar, 'jobs' => $uArray['jobs'], 'company' => $uArray['company'], 'coninfo' => array('phone' => $uArray['phone'], 'mobile' => $uArray['mobile'], 'qq' => $uArray['qq']), 'pname' => $pArray['pname'], 'ptype' => $retval['stname'], 'ownuid' => $pArray['uid'], 'pnameid' => $pArray['pid'], 'ptypeid' => $retval['stid']);                $status = array('status' => TRUE, 'msg' => '', 'createinfo' => $createArray);                echo json_encode($status, JSON_UNESCAPED_UNICODE);                die();            } else {                $status = array('status' => FALSE, 'msg' => 'The key is error');                echo json_encode($status, JSON_UNESCAPED_UNICODE);                die();            }        } else {            $status = array('status' => FALSE, 'msg' => 'error_create');            echo json_encode($status, JSON_UNESCAPED_UNICODE);            die();        }    }// 编制人审批第一期时 开始审批第一期时候调用ll    public function ClientPeriod()    {        // TODO:上报数据        // TODO:每期更新数据时候和上传时候要查询当前进行期数的第几次一并写入数据库        if (isset($this->params['userid']) && isset($this->params['tenderid']) && isset($this->params['phaseno']) && isset($_POST['MD5_JL']) && isset($_POST['MD5_Zip'])) {            $fp = $this->upfile('upfile');            if (isset($fp[0]['filepath'])) {                /**                 * 增加上传压缩包md5检测机制                 */                $localmd5HashString = hash_file("md5", Doo::conf()->SITE_PATH . $fp[0]['filepath']);                if ($localmd5HashString != trim($_POST['MD5_Zip'])) {                    $status = array('status' => 'FALSE', 'msg' => '期数数据上传失败,请重新上传');                    echo json_encode($status, JSON_UNESCAPED_UNICODE);                    die();                }                $res = $this->zip->open(Doo::conf()->SITE_PATH . $fp[0]['filepath']);                $extPath = pathinfo($fp[0]['filepath']);                $extPathdir = Doo::conf()->SITE_PATH . $extPath['dirname'] . '/' . $extPath['filename'];                if ($res === TRUE) {                    if (!$this->dir_create($extPathdir)) {                        $status = array('status' => 'FALSE', 'msg' => '期数数据上传失败');                        echo json_encode($status, JSON_UNESCAPED_UNICODE);                        die();                    }                    $this->zip->extractTo($extPathdir);                    $this->zip->close();                }                $countArray = json_decode(file_get_contents($extPathdir . '/' . 'JsonFile_Common.json'), TRUE, JSON_UNESCAPED_UNICODE);                if (!isset($countArray)) {                    $status = array('status' => 'FALSE', 'msg' => '期数汇总数据上传失败');                    echo json_encode($status, JSON_UNESCAPED_UNICODE);                    die();                }                $this->actmeasure->updateCon($this->params['tenderid'], $countArray['TotalPrice']);                $pmArray = $this->actmeasure->getRowByPmid($this->params['tenderid']);                if (isset($pmArray['pmid'])) {                    // 由于不通过功能数据表记录重复写入时要考虑当前是第几次审批                    $intMaxTimes = $this->numofperact->getMaxTimes($this->params['tenderid'], $this->params['phaseno']);                    if (isset($intMaxTimes['times']) && ($intMaxTimes['times'] >= 0)) {                        $iniTimes = $intMaxTimes['times'] + 1;                    } else {                        $iniTimes = 0;                    }                    // 写入第一期                    $mpid = $this->numofperact->insert($pmArray['pid'], $this->params['userid'], $this->params['tenderid'], $pmArray['stid'], $this->params['phaseno'], $countArray['BQHTJL'], $countArray['BQSLBGJL'], $countArray['JZSQLJWC'], $countArray['BQWCJL'], $countArray['LJWCJL'], $iniTimes);                    // 更新审批人MPID                    $this->measureauditact->updateAuditorMPID($mpid, $this->params['tenderid'], $this->params['phaseno'], $iniTimes);                    // 设置审批人状态                    $firstAuditor = $this->measureauditact->getFirstAuditor($this->params['tenderid'], $this->params['phaseno'], $iniTimes);                    if (isset($firstAuditor)) {                        if ($firstAuditor['mastatus'] == 'uncheck') {                            $retVal = $this->measureauditact->updateMastatus($firstAuditor['maid']);                            if ($retVal > 0) {                                // SMS Start                                $verifyUserArray = $this->profile->getVerifiedMobile($firstAuditor['auditoruid']);                                $pmnameArray = $this->actmeasure->getRowByPmid($this->params['tenderid']);                                if (isset($verifyUserArray) && ($verifyUserArray['mobile'])) {// // XXXX(标段名),陈特,已审批通过。请您继续审批。                                    $this->__auditNotice($verifyUserArray['mobile'], Doo::conf()->SMS_TIPS_PRE . '您好,' . $pmnameArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR2"]);                                }                                // SMS End                            }                        }                    }                }                if ($mpid > 0) {                    if ($this->attfile->insertFile($pmArray['pid'], $pmArray['stid'], $mpid, $this->params['tenderid'], $this->params['phaseno'], $this->params['userid'], $fp[0]['filepath'], 0, $_POST['MD5_JL'], $iniTimes, 2)) {                        $infostatus = 0;                        $pmArray = $this->numofperact->getRowTender($this->params['tenderid']);                        if ($pmArray) {                            $countTotal = count($pmArray);                            $ownerStatusArray = $this->measureauditact->getStatusTender($pmArray[0]['pmid'], $pmArray[0]['numpname']);                            if ($ownerStatusArray) {                                $infostatus = $this->statusArray[$ownerStatusArray['mastatus']];                            }                            echo json_encode(array('status' => 'TRUE', 'msg' => '', 'info' => array('curr' => $pmArray[0]['numpname'], 'infostatus' => $infostatus, 'total' => $countTotal)), JSON_UNESCAPED_UNICODE);                            die();                        } else {                            echo json_encode(array('status' => 'TRUE', 'msg' => '', 'info' => array('curr' => 1, 'infostatus' => 1, 'total' => 1)), JSON_UNESCAPED_UNICODE);                            die();                        }                    } else {                        $status = array('status' => 'FALSE', 'msg' => '期数上传失败');                        echo json_encode($status, JSON_UNESCAPED_UNICODE);                        die();                    }                } else {                    $status = array('status' => 'FALSE', 'msg' => '期数上传失败');                    echo json_encode($status, JSON_UNESCAPED_UNICODE);                    die();                }            } else {                $status = array('status' => 'FALSE', 'msg' => '文件上传失败,请重试');                echo json_encode($status, JSON_UNESCAPED_UNICODE);                die();            }        } else {            $status = array('status' => 'FALSE', 'msg' => '上传参数错误');            echo json_encode($status, JSON_UNESCAPED_UNICODE);            die();        }    }    /**     * 获取标段状态信息(由于加入了)     * 每个标段只有一期在进行中 group by?     *     * 查询标段的审批状态可以根据业主的审批依据来查询     * 如果除业主意外的人审批状态为未通过怎么处理     */    public function getMAStatus()    {        // curr:当前期数,status:当前状态,total:总期数        // 参数catid        if (isset($this->params['tenderid'])) {            $pmArray = $this->numofperact->getRowTenderCurr($this->params['tenderid']);            $countTotal = count($pmArray);            $ownerStatus = NULL;            $isUnCheck = TRUE;            $ownerStatusArray = $this->measureauditact->getStatusTen($pmArray[0]['pmid'], $pmArray[0]['numpname']);//	    if (isset($ownerStatusArray))//		if (($ownerStatusArray[0]['last'] == 1) && ($ownerStatusArray[0]['mastatus'] == 'checked')) {//		    $ownerStatus = 'checked';//		} else {//		    $ownerStatus = 'checking';//		}            $statusArray = $this->numofperact->getMaxRowStatus($pmArray[0]['pmid'], $pmArray[0]['numpname']);            $ownerStatus = $statusArray['currstatus'];//		foreach ($ownerStatusArray as $kk => $vv) {//		    if (($vv['last'] == 1) && ($vv['mastatus'] == 'checked')) {//			$ownerStatus = 'checked';//		    } else {//			$ownerStatus = 'checking';//		    }//		}            $projectArray = $this->project->getRowByPid($ownerStatusArray[0]['pid']);            $stArray = $this->contractact->getRowByStid($ownerStatusArray[0]['stid']);            $profileArray = $this->profile->getProWithUid($projectArray['uid']);            $auditArray = $this->measureauditact->getAuditUserRedo($pmArray[0]['pmid'], $pmArray[0]['numpname']);            if (isset($auditArray[0]['auditoruid'])) {                foreach ($auditArray as $key => $value) {                    $userArray = $this->profile->getProWithUid($value['auditoruid']);                    $auditcontent = !empty($value['auditcontent']) ? $value['auditcontent'] : '';//		    $finalStatus = $value['mastatus'];                    if ($value['mastatus'] != 'uncheck') {                        $isUnCheck = FALSE;                    }                    if ($value['audittime'] > 0) {                        $value['audittime'] = date('Y-m-d', $value['audittime']);                    }                    $auditInfo[] = array('uid' => $userArray['userid'], 'name' => $userArray['name'], 'company' => $userArray['company'], 'jobs' => $userArray['jobs'], 'avatar' => $this->auth->getAvatar($value['auditoruid']), 'mastatus' => $this->statusArray[$value['mastatus']], 'CheckerMemo' => $auditcontent, 'onlineaudit' => $value['onlineaudit'], 'audittime' => $value['audittime']);                }            }            if ($ownerStatusArray) {                if ($isUnCheck) {                    echo json_encode(array('status' => 'TRUE', 'msg' => '', 'info' => array('curr' => $pmArray[0]['numpname'], 'infostatus' => $this->statusArray['uncheck'], 'total' => "$countTotal", 'proName' => $projectArray['pname'], 'stName' => $stArray['stname'], 'name' => $profileArray['name'], 'company' => $profileArray['company'], 'jobs' => $profileArray['jobs']), 'auditinfo' => $auditInfo), JSON_UNESCAPED_UNICODE);                } else {                    echo json_encode(array('status' => 'TRUE', 'msg' => '', 'info' => array('curr' => $pmArray[0]['numpname'], 'infostatus' => $this->statusArray[$ownerStatus], 'total' => "$countTotal", 'proName' => $projectArray['pname'], 'stName' => $stArray['stname'], 'name' => $profileArray['name'], 'company' => $profileArray['company'], 'jobs' => $profileArray['jobs']), 'auditinfo' => $auditInfo), JSON_UNESCAPED_UNICODE);                }                die();            } else {                echo json_encode(array('status' => 'FALSE', 'msg' => '标段状态查询不存在'), JSON_UNESCAPED_UNICODE);                die();            }        } else {            echo json_encode(array('status' => 'FALSE', 'msg' => '标段状态查询参数错误'), JSON_UNESCAPED_UNICODE);            die();        }    }    public function getUserSearch()    {        if (isset($_POST['uemail'])) {            $retval = $this->users->getOne(array('where' => 'uemail=?', 'param' => array($_POST['uemail']), 'asArray' => TRUE));            if (isset($retval['uid'])) {                $proArray = $this->profile->getProWithUid($retval['uid']);                if (isset($proArray['userid'])) {                    $strAvatar = $this->auth->getAvatar($proArray['userid']);                    echo json_encode(array('status' => 'TRUE', 'msg' => '', 'info' => array('uid' => $proArray['userid'], 'avatar' => $strAvatar, 'name' => $proArray['name'], 'jobs' => $proArray['jobs'], 'company' => $proArray['company'])), JSON_UNESCAPED_UNICODE);                    die();                } else {                    echo json_encode(array('status' => 'FALSE', 'msg' => ''), JSON_UNESCAPED_UNICODE);                    die();                }            } else {                echo json_encode(array('status' => 'FALSE', 'msg' => ''), JSON_UNESCAPED_UNICODE);                die();            }        } else {            echo json_encode(array('status' => 'FALSE', 'msg' => ''), JSON_UNESCAPED_UNICODE);            die();        }    }    /**     * 获取指定标段指定期数{默认提取重做后最新一期的}     * 单击获取项目相关审批人员和状态     * sectionid:标段ID periodid:期数     * TODO:如果审批人的期数或者次数与标段期数或者次数存在不对应情况的处理     */    public function getAlluserMeasure()    {        if (isset($this->params['tenderid']) && isset($this->params['phaseno'])) {//            error_log(var_export($this->params, TRUE), 3, '/opt/html/jlzftest/data/' . time());            // 先判断是否存在期数问题            // 然后再判断是否存在次数不匹配//            $intNum = $this->numofperact->getCountNumpname($this->params['tenderid'], $this->params['phaseno']);//            // 如果期数是第一期期数必须大于一,否则减一为无效数据 ,为0表示这期为做上报没有产生记录//            if (( $this->params['phaseno'] > 1) && ($intNum == 0)) {// 提取上一期的数据//                // 提取期数减一//                $intLastTimes = $this->numofperact->getMaxTimes($this->params['tenderid'], $this->params['phaseno'] - 1)['times'];//                $uinfoTmpArray = $this->measureauditact->getAllAudit($this->params['tenderid'], $this->params['phaseno'] - 1, $intLastTimes);//            } else {//                $IntMaxRedoTimes = $this->measureauditact->getMaxTimes($this->params['tenderid'], $this->params['phaseno'])['maxtimes'];//                $intTimes = $this->numofperact->getCountTimes($this->params['tenderid'], $this->params['phaseno'], $IntMaxRedoTimes);//                if (($intTimes == 0) && ($IntMaxRedoTimes > 0)) {//                    $lastTimes = $IntMaxRedoTimes - 1;//                    $uinfoTmpArray = $this->measureauditact->getAllAudit($this->params['tenderid'], $this->params['phaseno'], $lastTimes);//                } else {//                    $uinfoTmpArray = $this->measureauditact->getAllAudit($this->params['tenderid'], $this->params['phaseno'], $IntMaxRedoTimes);//                }//            }            $uinfoTmpArray = $this->measureauditact->getAlluserMeasureAudit($this->params['tenderid'], $this->params['phaseno']);            if ($uinfoTmpArray) {                foreach ($uinfoTmpArray as $key => $value) {                    $uArray = $this->profile->getProWithUid($value['auditoruid']);                    $uinfoArray[$key]['name'] = $uArray['name'];                    $uinfoArray[$key]['company'] = $uArray['company'];                    $uinfoArray[$key]['jobs'] = $uArray['jobs'];                    $uinfoArray[$key]['mastatus'] = $this->statusArray[$value['mastatus']];                    $uinfoArray[$key]['uid'] = $value['auditoruid'];                    $uinfoArray[$key]['avatar'] = $this->auth->getAvatar($value['auditoruid']);                    $uinfoArray[$key]['CheckerMemo'] = !empty($value['auditcontent']) ? $value['auditcontent'] : '';                    $uinfoArray[$key]['onlineaudit'] = $value['onlineaudit'];                    if ($value['audittime'] > 0) {                        $uinfoArray[$key]['audittime'] = date('Y-m-d', $value['audittime']);                    } else {                        $uinfoArray[$key]['audittime'] = '0';                    }                }            } else {                echo json_encode(array('status' => FALSE, 'msg' => '用户列表不存在'), JSON_UNESCAPED_UNICODE);                die();            }            echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $uinfoArray), JSON_UNESCAPED_UNICODE);            die();        } else {            echo json_encode(array('status' => FALSE, 'msg' => '错误'), JSON_UNESCAPED_UNICODE);            die();        }    }//    //    // 配置审批人时候还没有创建标段所以没有MPID存在    function addAuditMeasure()    {        //  必须检查期数是否存在        //  标段ID 当前登录 审批人ID        //  检测是否重复写入 && ($_POST['creatoruid'] > 0)        // TODO: 增加多次审批人变更需求,调整审批人增加、删除接口        // 当前操作的是否为最新一期还是最新一期加一(项目进行中时,不能编辑审批人,所以直接加一)        // 大于一次重做的时候,自动复制编制人和所有审批人次数加一        if (isset($_POST['pmid']) && isset($_POST['creatoruid']) && isset($_POST['auditoruid']) && isset($_POST['numpname'])) {            $IntMaxTimes = $this->measureauditact->getMaxTimesInt($_POST['pmid'], $_POST['numpname']); // 根据标段PMID,期数numpname,获取目前重做次数            if ($IntMaxTimes > 0) {                $inTimes = $IntMaxTimes;            } else {                $inTimes = 0;            }            $pmArray = $this->actmeasure->getRowByPmid($_POST['pmid']);            try {                if ($this->measureauditact->insertMeasureAudit($pmArray['pid'], $_POST['creatoruid'], $_POST['auditoruid'], 0, $_POST['pmid'], $pmArray['stid'], $_POST['numpname'], 'uncheck', 2, $inTimes) > 0) {                    echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => ''), JSON_UNESCAPED_UNICODE);                    die();                }            } catch (PDOException $e) {// 判断异常类型,提示不同错误信息                echo json_encode(array('status' => FALSE, 'msg' => '配置审批人错误'), JSON_UNESCAPED_UNICODE);            }        } else {            echo json_encode(array('status' => FALSE, 'msg' => '配置审批人参数错误'), JSON_UNESCAPED_UNICODE);            die();        }    }    /**     * 删除审批用户     */    function delAuditMeasure()    {        if (isset($this->params['userid']) && isset($this->params['tenderid']) && isset($this->params['phaseno'])) {            // 判断当前标段期数审批状态,决定是否继续执行            $IntMaxTimes = $this->measureauditact->getMaxTimesInt($this->params['tenderid'], $this->params['phaseno']); // 根据标段PMID,期数numpname,获取目前重做次数            if ($IntMaxTimes > 0) {                $inTimes = $IntMaxTimes;                $intHasCount = $this->numofperact->hasTheTimesRow($this->params['tenderid'], $this->params['phaseno'], $inTimes);                if (isset($intHasCount) && ($intHasCount > 0)) {                    echo json_encode(array('status' => FALSE, 'msg' => '此标段状态,禁止删除审批人员'), JSON_UNESCAPED_UNICODE);                    die();                }            } else {                $inTimes = 0;            }            try {                $this->measureauditact->delAuditUserTimes($this->params['tenderid'], $this->params['phaseno'], $this->params['userid'], $inTimes);                echo json_encode(array('status' => TRUE, 'msg' => ''), JSON_UNESCAPED_UNICODE);                die();            } catch (PDOException $e) {// 判断异常类型,提示不同错误信息                echo json_encode(array('status' => FALSE, 'msg' => '删除审批人错误'), JSON_UNESCAPED_UNICODE);            }        } else {            echo json_encode(array('status' => FALSE, 'msg' => '删除审批人员参数错误'), JSON_UNESCAPED_UNICODE);            die();        }    }// 查询状态变更为审批中,已审批中为查询依据    function checkMeasureStatus()    {        if (isset($_POST['sectionid']) && isset($_POST['periodid'])) {            $mpArray = $this->numofperact->getRow($_POST['sectionid'], $_POST['periodid']);            $maArray = $this->measureauditact->getAlluserMeasureAudit($_POST['sectionid'], $_POST['periodid']);            foreach ($maArray as $key => $value) {                if ($value['mastatus'] == 'uncheck') {                    $mastatus = $this->statusArray[$value['mastatus']];                }            }            if (isset($mpArray['mpid'])) {                echo json_encode(array('status' => TRUE, 'msg' => '', 'isexist' => TRUE, 'checkstatus' => $mastatus), JSON_UNESCAPED_UNICODE);                die();            } else {                echo json_encode(array('status' => TRUE, 'msg' => '', 'isexist' => FALSE), JSON_UNESCAPED_UNICODE);                die();            }        } else {            echo json_encode(array('status' => FALSE, 'msg' => '标段信息不正确'), JSON_UNESCAPED_UNICODE);            die();        }    }    // 根据用户查询参与的标段信息    //  参数为1时,当提交的附件中有重做记录时,提取记录未经过排重处理,出现重复结果。    //  api/client/user/get/15/allproject 此接口也有同样问题    function getAuditProject()    {        // TODO:可以通过SQL直接查询出来        if (isset($_POST['audituid']) && isset($_POST['RequestType'])) {            $downfileurl = NULL;            /**             * 只查询审批中状态的记录             * 然后根据每天记录所在的标段、期数、创建人查询所有此次所有审批人记录、为了判断             * 判断此用户是第几个审批的人             * 直接提取状态为未审批、审批中的             * 未审批(没有到该审批人)             * 审批中(出现在第一个)             * 上传审批时候先遍历所有审批提交文件的状态并设置为旧文件状态             * 然后写入新审批的文件路径等信息             * 审批同时上传审批文件并设置审批表的状态做更改             *             */            if ($_POST['RequestType'] == 1) {                /**                 *  功能描述:                 *  参数1功能为,取得与当前用户相关的待审批状态的所有进行中的标段期数、最新一次的记录                 *  根据用户ID查询编制人和审批人参与的正在进行中的项目,进行中的项目状态为uncheck,checking                 *  由于·uncheck状态不能准确反映出其他用户操作对所属标段操作产生的的状态{比如:其他用户操作标段状态为(未通过【打回重做】)}、要排除这种情况                 *  还有一种情况为编制人编制项目时,审批人列表已经添加审批人,但是项目没有提交,没有项目文件,此时应根据有没有项目文件进行过滤。                 *                 *  ??此ID为编制人或者为审批人时                 */                // 第一步:根据用户ID,查询此用户参与的所有标段{根据最大期数【由于期数是递进关系只获取最大值】、最大次数【由于次数是递进关系只获取最大值】作为条件参数进行查询记录}                $mpArray = $this->measureauditact->getCheckedRowbyUID2($_POST['audituid']); // 通过pmid,numpname分组获取参与的记录                if (isset($mpArray)) {                    $statusArray = array('uncheck', 'checking');                    foreach ($mpArray as $key => $value) {                        /**                         * 根据审批ID查询所在标段期数                         * 然后去附件表根据标段ID 期数 是否新标志字段去查询最新的文件                         * 项目名称 项目类型                         *                         *                         * 此处现在是以创建者ID和审批人ID做关联来做判断                         * 判断上一个人的审批状态来提取记录                         *                         * 变更为一个用户添加所有人                         *                         *///			$maxtimes = $this->attfile->getMaxTimes2($value['pmid'], $value['numpname']);                        $numStatusArray = $this->numofperact->getRow($value['pmid'], $value['numpname'], $value['times']);                        if (in_array($numStatusArray['currstatus'], $statusArray)) {                            $newfileArray = $this->attfile->getNewLast($value['pmid'], $value['numpname'], $value['times']);                            if (isset($newfileArray['filepath'])) {                                $projectArray = $this->project->getRowByPid($newfileArray['pid']);                                $pmidArray = $this->actmeasure->getRowByPmid($value['pmid']);                                $stArray = $this->contractact->getRowByStid($newfileArray['stid']);//			    $auditArray = $this->measureauditact->getLastNewRowInfo($value['pmid'], $value['numpname'], $_POST['audituid']);                                $pathinfo = pathinfo($newfileArray['filepath']);                                $downfileurl[] = array('downurl' => Doo::conf()->APP_URL . $pathinfo ['dirname'] . '/' . $pathinfo ['filename'] . '/ProjectFile.rmf', 'proName' => $projectArray['pname'], 'stName' => $stArray['stname'], 'MD5_Jl' => $newfileArray['filehashcode'], 'tenderstatus' => $this->statusArray[$value['mastatus']], 'tenderid' => $value['pmid'], 'pnameid' => $projectArray['pid'], 'ptypeid' => $stArray['stid'], 'audituidstatus' => $this->statusArray[$value['mastatus']], 'bianzhirenuid' => $pmidArray['uid'], 'tenderName' => $pmidArray['pmname']);                            }                        }                    }                    echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $downfileurl), JSON_UNESCAPED_UNICODE);                    die();                } else {                    echo json_encode(array('status' => FALSE, 'msg' => '暂时无审批信息'), JSON_UNESCAPED_UNICODE);                    die();                }            }            if ($_POST['RequestType'] == 2) {                /**                 * {                 * "downurl": "http://d.jl.smartcost.com.cn/data/2015/0608/20150608043245691/ProjectFile.rmf", 最新一期最新一次的文件                 * "proName": "巫溪县前进桥",                        项目名称                 * "stName": "巫溪县 前进桥(终)",                        合同段名称                 * "MD5_Jl": "7cf05dccc6ad45b2d78f476a3388c3b2",                最新一期最新一次的文件hash code                 * "tenderstatus": "2",                            标段状态                 * "tenderid": "234",                            标段ID                 * "pnameid": "79",                            项目ID                 * "ptypeid": "96",                            合同段ID                 * "audituidstatus": "2",                            当前用户审批状态                 * "bianzhirenuid": "59",                            编制人UID                 * "tenderName": "巫溪县 前进桥 终"                        标段名称                 * }                 */                // TODO::不同角色提取条件不同是否使用audituid 作为当前用户提取条件,容易产生冲突                if (!isset($_POST['audituid']) || !($_POST['audituid'] > 0)) {                    echo json_encode(array('status' => FALSE, 'msg' => '返回指定用户参与的所有项目参数错误'), JSON_UNESCAPED_UNICODE);                    die();                }// 三个角色数据合并返回// 返回最新一期的项目文件// 业主                //  业主查询参与的项目时                //  TODO::业主是否参与审批?如果参与提取哪个参与者的审批状态?                $userproArray = $this->project->getRowUid($_POST['audituid']);                $newattArray = $retArray = $hashArray = NULL;                foreach ($userproArray as $upk => $upv) {                    $attArray = $this->attfile->getPmidGroup($upv['pid']);                    $attaArray = NULL;                    foreach ($attArray as $akey => $avalue) {                        $attaArray[] = $this->attfile->getLastNumTimes($avalue['pmid']);                    }                    foreach ($attaArray as $attk => $attv) {                        $attfileArray = $this->contractact->getRowByStid($attv['stid']);                        $pmidArray = $this->actmeasure->getRowByPmid($attv['pmid']);                        $numArray = $this->numofperact->getRow($attv['pmid'], $attv['numpname'], $attv['times']);                        $auditArray = $this->measureauditact->getLastNewRowInfo($attv['pmid'], $attv['numpname'], $_POST['audituid']);                        $pathinfo = pathinfo($attv['filepath']);                        if (isset($pathinfo['dirname'])) {                            $retArray[] = array('downurl' => Doo::conf()->APP_URL . $pathinfo ['dirname'] . '/' . $pathinfo ['filename'] . '/ProjectFile.rmf', 'proName' => $upv['pname'], 'stName' => $attfileArray['stname'], 'MD5_Jl' => $attv['filehashcode'], 'tenderstatus' => $this->statusArray[$numArray['currstatus']], 'tenderid' => $attv['pmid'], 'pnameid' => $upv['pid'], 'ptypeid' => $attfileArray['stid'], 'audituidstatus' => $this->statusArray[$auditArray['mastatus']], 'bianzhirenuid' => $pmidArray['uid'], 'tenderName' => $pmidArray['pmname']);                            $hashArray[] = md5(Doo::conf()->APP_URL . $pathinfo ['dirname'] . '/' . $pathinfo ['filename'] . '/ProjectFile.rmf' . $upv['pname'] . $attfileArray['stname'] . $attv['filehashcode'] . $this->statusArray[$numArray['currstatus']] . $attv['pmid'] . $upv['pid'] . $attfileArray['stid'] . $this->statusArray[$auditArray['mastatus']] . $pmidArray['uid'] . $pmidArray['pmname']);                        }                    }                }// 施工                $measureArray = $this->actmeasure->getPmidRow($_POST['audituid']);                if (isset($measureArray) && $measureArray) {                    $attfileArray = $stidArray = NULL;                    foreach ($measureArray as $key => $value) {                        $proArray = $this->project->getRowByPid($value['pid']);                        $conArray = $this->contractact->getRowByStid($value['stid']);                        $attfileArray = $this->attfile->getLastNewProfile2($value['pmid']);                        $pmidArray = $this->actmeasure->getRowByPmid($value['pmid']);                        $statusArray = $this->numofperact->getMaxRowStatus($attfileArray['pmid'], $attfileArray['numpname']);                        $auditArray = $this->measureauditact->getLastNewRowInfo($attfileArray['pmid'], $attfileArray['numpname'], $_POST['audituid']);                        $pathinfo = pathinfo($attfileArray['filepath']);                        if (!$auditArray['mastatus'])                            $auditStr = 'uncheck';                        else                            $auditStr = $auditArray['mastatus'];                        if (isset($pathinfo['dirname'])) {                            $hashstr = md5(Doo::conf()->APP_URL . $pathinfo ['dirname'] . '/' . $pathinfo ['filename'] . '/ProjectFile.rmf' . $proArray['pname'] . $conArray['stname'] . $attfileArray['filehashcode'] . $this->statusArray[$statusArray['currstatus']] . $value['pmid'] . $proArray['pid'] . $conArray['stid'] . $this->statusArray[$auditStr] . $pmidArray['uid'] . $pmidArray['pmname']);                            if (!in_array($hashstr, $hashArray)) {                                $retArray[] = array('downurl' => Doo::conf()->APP_URL . $pathinfo ['dirname'] . '/' . $pathinfo ['filename'] . '/ProjectFile.rmf', 'proName' => $proArray['pname'], 'stName' => $conArray['stname'], 'MD5_Jl' => $attfileArray['filehashcode'], 'tenderstatus' => $this->statusArray[$statusArray['currstatus']], 'tenderid' => $value['pmid'], 'pnameid' => $proArray['pid'], 'ptypeid' => $conArray['stid'], 'audituidstatus' => $this->statusArray[$auditStr], 'bianzhirenuid' => $pmidArray['uid'], 'tenderName' => $pmidArray['pmname']);                                $hashArray[] = $hashstr;                            }                        }                    }                }// 审批 是否只提取最新一期?                $pmidGroupArray = $this->measureauditact->getPmidGroup($_POST['audituid']);                /**                 * 从审批人列表中提取记录时,如果项目进行到新开一次或者一期数据,但是上报人并未上报数据,(犹豫逻辑上机制导致,先创建审批人再通过上报人上报数据才能产生新一期)                 * 这时,上报人查询到的数据就为空。                 * 如果没有最新一次上报数据(可否提取2期上报数据?即便是能下载也不能打开,因为上一期数据的审批人数或者状态,可能与最新一期的审批人状态不同,然后软件报错)                 */                $retval = null;                foreach ($pmidGroupArray as $gkey => $gvalue) {                    $retval[] = $this->measureauditact->getLastNumTimes($gvalue['pmid'], $_POST['audituid']);                }                foreach ($retval as $spkey => $spvalue) {                    $pathinfo = null;                    $proArray = $this->project->getRowByPid($spvalue['pid']);                    $conArray = $this->contractact->getRowByStid($spvalue['stid']);                    $pmidArray = $this->actmeasure->getRowByPmid($spvalue['pmid']);                    /**                     * 两种情况 一种情况是 新建一期 还有一种是审批未通过重做 这两种未提交                     */                    $intNum = $this->numofperact->getCountNumpname($spvalue['pmid'], $spvalue['numpname']);                    // 如果期数是第一期期数必须大于一,否则减一为无效数据 ,为0表示这期为做上报没有产生记录                    if (($spvalue['numpname'] > 1) && ($intNum == 0)) {// 提取上一期的数据                        // 提取期数减一                        $intLastTimes = $this->numofperact->getMaxTimes($spvalue['pmid'], $spvalue['numpname'] - 1)['times'];                        $numstatusArray = $this->numofperact->getRow($spvalue['pmid'], $spvalue['numpname'] - 1, $intLastTimes); //获取上一期最新一次的状态                    } else {                        $intTimes = $this->numofperact->getCountTimes($spvalue['pmid'], $spvalue['numpname'], $spvalue['times']);                        if (($intTimes == '0') && $spvalue['times'] > 0) {                            $numstatusArray = $this->numofperact->getRow($spvalue['pmid'], $spvalue['numpname'], $spvalue['times'] - 1);                        } else {// 当创建第一次的时候也会为空,所以下方加了判断                            $numstatusArray = $this->numofperact->getRow($spvalue['pmid'], $spvalue['numpname'], $spvalue['times']);                        }                    }                    $afArray = $this->attfile->getLastNewProfile2($spvalue['pmid']); // 由于始终提取最新一期所以不用放入判断情况中                    $auditArray = $this->measureauditact->getLastNewRowInfo($spvalue['pmid'], $spvalue['numpname'], $_POST['audituid']);                    $pathinfo = pathinfo($afArray['filepath']);                    if ($numstatusArray && $auditArray) { // 如果重做审批人有变更,根据审批状态判断是否存在该审批人,不存在则不显示此条记录                        $hashstr = md5(Doo::conf()->APP_URL . $pathinfo ['dirname'] . '/' . $pathinfo ['filename'] . '/ProjectFile.rmf' . $proArray['pname'] . $conArray['stname'] . $afArray['filehashcode'] . $this->statusArray[$numstatusArray['currstatus']] . $spvalue['pmid'] . $proArray['pid'] . $conArray['stid'] . $this->statusArray[$auditArray['mastatus']] . $pmidArray['uid'] . $pmidArray['pmname']);                        if (!in_array($hashstr, $hashArray)) {                            $retArray[] = array('downurl' => Doo::conf()->APP_URL . $pathinfo ['dirname'] . '/' . $pathinfo ['filename'] . '/ProjectFile.rmf', 'proName' => $proArray['pname'], 'stName' => $conArray['stname'], 'MD5_Jl' => $afArray['filehashcode'], 'tenderstatus' => $this->statusArray[$numstatusArray['currstatus']], 'tenderid' => $spvalue['pmid'], 'pnameid' => $proArray['pid'], 'ptypeid' => $conArray['stid'], 'audituidstatus' => $this->statusArray[$auditArray['mastatus']], 'bianzhirenuid' => $pmidArray['uid'], 'tenderName' => $pmidArray['pmname']);                            $hashArray[] = $hashstr;                        }                    }                }                //标段关注人                $concernArray = $this->concern->getRowbyUid($_POST['audituid']);                if (isset($concernArray) && !empty($concernArray)) {                    $attfileArray = $stidArray = NULL;                    foreach ($concernArray as $key => $value) {                        $proArray = $this->project->getRowByPid($value['pid']);                        $conArray = $this->contractact->getRowByStid($value['stid']);                        $attfileArray = $this->attfile->getLastNewProfile2($value['pmid']);                        $pmidArray = $this->actmeasure->getRowByPmid($value['pmid']);                        $statusArray = $this->numofperact->getMaxRowStatus($attfileArray['pmid'], $attfileArray['numpname']);                        $auditArray = $this->measureauditact->getLastNewRowInfo($attfileArray['pmid'], $attfileArray['numpname'], $_POST['audituid']);                        $pathinfo = pathinfo($attfileArray['filepath']);                        if (!$auditArray['mastatus'])                            $auditStr = 'uncheck';                        else                            $auditStr = $auditArray['mastatus'];                        if (isset($pathinfo['dirname'])) {                            $hashstr = md5(Doo::conf()->APP_URL . $pathinfo ['dirname'] . '/' . $pathinfo ['filename'] . '/ProjectFile.rmf' . $proArray['pname'] . $conArray['stname'] . $attfileArray['filehashcode'] . $this->statusArray[$statusArray['currstatus']] . $value['pmid'] . $proArray['pid'] . $conArray['stid'] . $this->statusArray[$auditStr] . $pmidArray['uid'] . $pmidArray['pmname']);                            if (!in_array($hashstr, $hashArray)) {                                $retArray[] = array('downurl' => Doo::conf()->APP_URL . $pathinfo ['dirname'] . '/' . $pathinfo ['filename'] . '/ProjectFile.rmf', 'proName' => $proArray['pname'], 'stName' => $conArray['stname'], 'MD5_Jl' => $attfileArray['filehashcode'], 'tenderstatus' => $this->statusArray[$statusArray['currstatus']], 'tenderid' => $value['pmid'], 'pnameid' => $proArray['pid'], 'ptypeid' => $conArray['stid'], 'audituidstatus' => $this->statusArray[$auditStr], 'bianzhirenuid' => $pmidArray['uid'], 'tenderName' => $pmidArray['pmname']);                                $hashArray[] = $hashstr;                            }                        }                    }                }//		$dd = NULL;//		if (isset($retArray))//		    $dd = $this->array_unique_fb($retArray);                echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $retArray), JSON_UNESCAPED_UNICODE);            }        }    }//二维数组去掉重复值 并保留键值    function array_unique_fb($array2D)    {        $key = array();        foreach ($array2D as $k => $v) {            if (empty($key))                $key = array_keys($v); //记录数组的KEY            $v = join(",", $v); //降维,也可以用implode,将一维数组转换为用逗号连接的字符串            $temp[$k] = $v;        }        $temp = array_unique($temp); //去掉重复的字符串,也就是重复的一维数组        foreach ($temp as $k => $v) {            $array = explode(",", $v); //再将拆开的数组重新组装            foreach ($array as $i => $t) {                $temp2[$k] = !empty($temp2[$k]) ? array_merge($temp2[$k], array("{        $key[$i]}" => $t)) : array("{        $key[$i]}" => $t); //依次添加到新的数组中去            }        }        return $temp2;    }    function unique_arr($array2D, $stkeep = false, $ndformat = true)    {        // 判断是否保留一级数组键 (一级数组键可以为非数字)        if ($stkeep)            $stArr = array_keys($array2D);        // 判断是否保留二级数组键 (所有二级数组键必须相同)        if ($ndformat)            $ndArr = array_keys(end($array2D));        //降维,也可以用implode,将一维数组转换为用逗号连接的字符串        foreach ($array2D as $v) {            $v = join(",", $v);            $temp[] = $v;        }        //去掉重复的字符串,也就是重复的一维数组        $temp = array_unique($temp);        //再将拆开的数组重新组装        foreach ($temp as $k => $v) {            if ($stkeep)                $k = $stArr[$k];            if ($ndformat) {                $tempArr = explode(",", $v);                foreach ($tempArr as $ndkey => $ndval) {                    $output[$k][$ndArr[$ndkey]] = $ndval;                }            } else {                $output[$k] = explode(",", $v);            }        }        return $output;    }// 标段期审批接口    function auditMeasure()    {        if (isset($_POST['userid']) && isset($_POST['tenderid']) && isset($_POST['phaseno']) && isset($_POST['MD5_JL']) && isset($_POST['MD5_Zip'])) {            $auditcontent = iconv('GBK', 'UTF-8', $_POST['CheckerMemo']);            $auditArray = $this->measureauditact->getLastNewRowInfo($_POST['tenderid'], $_POST['phaseno'], $_POST['userid']);            if (isset($auditArray ['mastatus']) && (($auditArray ['mastatus'] == 'checked') || ($auditArray ['mastatus'] == 'checkno'))) {                echo json_encode(array('status' => FALSE, 'msg' => '该标段已审批完毕。'), JSON_UNESCAPED_UNICODE);                die();            }            $auditUserArray = $this->measureauditact->getUserAuditLast($_POST['tenderid'], $_POST['phaseno']);            $fp = $this->upfile('upfile');            if (isset($fp[0]['filepath'])) {                $localmd5HashString = hash_file("md5", Doo::conf()->SITE_PATH . $fp[0]['filepath']);                if ($localmd5HashString != trim($_POST['MD5_Zip'])) {                    $status = array('status' => 'FALSE', 'msg' => '审批期数数据上传失败,请重新上传');                    echo json_encode($status, JSON_UNESCAPED_UNICODE);                    die();                }                $res = $this->zip->open(Doo::conf()->SITE_PATH . $fp[0]['filepath']);                $extPath = pathinfo($fp[0]['filepath']);                $extPathdir = Doo::conf()->SITE_PATH . $extPath ['dirname'] . '/' . $extPath['filename'];                if ($res === TRUE) {                    if (!$this->dir_create($extPathdir)) {                        return FALSE;                    }                    $this->zip->extractTo($extPathdir);                    $this->zip->close();                }                // 更新五项最新数据                $countArray = json_decode(file_get_contents($extPathdir . '/' . 'JsonFile_Common.json'), TRUE, JSON_UNESCAPED_UNICODE);                if (!isset($countArray)) {                    $status = array('status' => FALSE, 'msg' => '期数汇总数据上传失败');                    echo json_encode($status, JSON_UNESCAPED_UNICODE);                    die();                }                $iniTimes = 0;                $intMaxTimes = $this->numofperact->getMaxTimes($_POST['tenderid'], $_POST['phaseno']);                if (isset($intMaxTimes['times']) && ($intMaxTimes['times'] > 0)) {                    $iniTimes = $intMaxTimes['times'];                }                $this->actmeasure->updateCon($_POST['tenderid'], $countArray['TotalPrice']);                $this->numofperact->updateNumofper($_POST['tenderid'], $_POST['phaseno'], $countArray, $iniTimes);                $numArray = $this->numofperact->getRow($_POST['tenderid'], $_POST['phaseno'], $iniTimes);                if (isset($auditArray['pid'])) {                    // 插入附件表之前要更新所有次标段期数的提交的数据状态为旧标志                    $this->attfile->setOldfileFlag($_POST['tenderid'], $_POST['phaseno'], $iniTimes);                    // 插入此次提交的文件路径数据并设置为新状态                    // 写入此时是第几次重做                    $this->attfile->insertFile($auditArray['pid'], $auditArray['stid'], $numArray['mpid'], $_POST['tenderid'], $_POST['phaseno'], $_POST['userid'], $fp[0]['filepath'], 0, $_POST['MD5_JL'], $iniTimes);                    // 更新审批表审批人的标段期数审批状态                    if ($this->measureauditact->setStatusTo($auditArray['maid'], 3, $auditcontent)) {                        // 更新下一个人的状态                        $countAudit = count($auditUserArray);                        if ($auditArray['last'] == '1') {// 根据标志位判断是否为最后一个审核人{ 判断当前审核人是什么角色 } 利用post发送的UID 与 当前期数参与的所有人比较                            $this->measureauditact->setStatusTo($auditUserArray[0]['maid'], 3);                            $this->numofperact->updateAuditStatus($_POST['tenderid'], $_POST['phaseno'], 'checked', $iniTimes);                            // SMS Start                            $TenderArray = $this->actmeasure->getRowByPmid($_POST['tenderid']);                            $userProArray = $this->profile->getProWithUid($TenderArray['uid']);                            if (isset($userProArray) && ($userProArray['mobile'])) {                                $retval = $this->__auditNotice($userProArray['mobile'], Doo::conf()->SMS_TIPS_PRE . '您好,' . $TenderArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR3"]);                            }                            // SMS End                            echo json_encode(array('status' => TRUE, 'msg' => ''), JSON_UNESCAPED_UNICODE);                            die();                        } else {// 不是最后一个审核人根据不同审核人数量变更状态 {当前用户不是最后一个审核人}                            if (($countAudit == 2) && ($auditUserArray[0]['last'] == 1) && ($auditUserArray[1]['maid'] == $auditArray['maid'])) {// 如果审核人为两个,第一个是最后审核人角色,第二个为当前审核人,设置审核中状态 {就是当前用户POST UID}                                $this->measureauditact->updateMastatus($auditUserArray[0]['maid']);                                $this->numofperact->updateAuditStatus($_POST['tenderid'], $_POST['phaseno'], 'checking', $iniTimes);                                // SMS Start                                $verifyUserArray = $this->profile->getVerifiedMobile($auditUserArray[0]['auditoruid']);                                $pmnameArray = $this->actmeasure->getRowByPmid($_POST['tenderid']);                                if (isset($verifyUserArray) && ($verifyUserArray['mobile'])) {// XXXX(标段名),陈特,已审批通过。请您继续审批。                                    $this->__auditNotice($verifyUserArray['mobile'], Doo::conf()->SMS_TIPS_PRE . '您好,' . $pmnameArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR2"]);                                }                                // SMS End                                echo json_encode(array('status' => TRUE, 'msg' => ''), JSON_UNESCAPED_UNICODE);                                die();                            }                            if (($countAudit > 2)) {// 审核人总数大于2时,                                foreach ($auditUserArray as $k => $v) {                                    if ($v['maid'] == $auditArray['maid']) {// 找到当前用户                                        if ($k == ($countAudit - 1)) {//如果是最后一个                                            $this->measureauditact->updateMastatus($auditUserArray[0]['maid']);                                            $verifyUserArray = $this->profile->getVerifiedMobile($auditUserArray[0]['auditoruid']);                                            $pmnameArray = $this->actmeasure->getRowByPmid($auditUserArray[0]['pmid']);                                        } else {                                            $this->measureauditact->updateMastatus($auditUserArray[$k + 1]['maid']);//变更下一个状态                                            $verifyUserArray = $this->profile->getVerifiedMobile($auditUserArray[$k + 1]['auditoruid']);                                            $pmnameArray = $this->actmeasure->getRowByPmid($auditUserArray[$k]['pmid']);                                        }                                        // SMS Start                                        if (isset($verifyUserArray) && ($verifyUserArray['mobile'])) {// // XXXX(标段名),陈特,已审批通过。请您继续审批。                                            $this->__auditNotice($verifyUserArray['mobile'], Doo::conf()->SMS_TIPS_PRE . '您好,' . $pmnameArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR2"]);                                        }                                        // SMS End                                        $this->numofperact->updateAuditStatus($_POST['tenderid'], $_POST['phaseno'], 'checking', $iniTimes);                                        echo json_encode(array('status' => TRUE, 'msg' => ''), JSON_UNESCAPED_UNICODE);                                        die();                                    }                                }                                // 我是第几个审批的                                // 如果是最后一个就把业主审批状态更改为审批中                                // 如果是第一个就把后一个设置为审批中                            }                        }                    } else {                        echo json_encode(array('status' => FALSE, 'msg' => '审批文件提交失败1'), JSON_UNESCAPED_UNICODE);                        die();                    }                }            } else {                echo json_encode(array('status' => FALSE, 'msg' => '审批文件提交失败'), JSON_UNESCAPED_UNICODE);                die();            }        } else {            echo json_encode(array('status' => FALSE, 'msg' => '审批参数错误'), JSON_UNESCAPED_UNICODE);            die();        }    }    /**     * 根据标段ID查询是否需要更新     */    function checkTenderUpdate()    {        if (isset($this->params ['tenderid']) && $this->params['tenderid']) {            $updateArray = $this->attfile->getFileUpdate($this->params['tenderid']);            $projectArray = $this->project->getRowByPid($updateArray['pid']);            $stArray = $this->contractact->getRowByStid($updateArray['stid']);            $MeasureArray = $this->actmeasure->getRowByPmid($this->params['tenderid']);            if (isset($updateArray['filepath'])) {                $pathinfo = pathinfo($updateArray['filepath']);                $downfileurl[] = array('downurl' => Doo::conf()->APP_URL . $pathinfo ['dirname'] . '/' . $pathinfo ['filename'] . '/ProjectFile.rmf', 'MD5_Jl' => $updateArray['filehashcode'], 'proName' => $projectArray['pname'], 'stName' => $stArray['stname'], 'pnameid' => $projectArray['pid'], 'ptypeid' => $stArray['stid'], 'BidName' => $MeasureArray['pmname']);                echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $downfileurl), JSON_UNESCAPED_UNICODE);                die();            } else {                echo json_encode(array('status' => TRUE, 'msg' => '暂无更新数据'), JSON_UNESCAPED_UNICODE);                die();            }        } else {            echo json_encode(array('status' => FALSE, 'msg' => '更新查询参数错误'), JSON_UNESCAPED_UNICODE);            die();        }    }    /**     * 手动创建第二期的审批人     */    function creatTenderNumPnameUser()    {        if (isset($_POST['tenderid']) && isset($_POST['phaseno']) && ($_POST['phaseno'] > 1)) {            $allMeasureUser = $this->measureauditact->getUserAuditLast($_POST['tenderid'], $_POST['phaseno'] - 1);            if (isset($allMeasureUser)) {                foreach ($allMeasureUser as $key => $value) {//		    if ($key == 1) {//			$status = 'checking';//		    } else {                    $status = 'uncheck';//		    }                    try {                        $this->measureauditact->insertMeasureAudit($value['pid'], $value['creatoruid'], $value['auditoruid'], $value['mpid'], $value['pmid'], $value['stid'], $_POST['phaseno'], $status, $value['last']);                    } catch (Exception $exc) {                    }                }                echo json_encode(array('status' => TRUE, 'msg' => ''), JSON_UNESCAPED_UNICODE);                die();            } else {                echo json_encode(array('status' => FALSE, 'msg' => '审批人员列表不存在'), JSON_UNESCAPED_UNICODE);                die();            }        } else {            echo json_encode(array('status' => FALSE, 'msg' => '创建审批人员列表参数错误'), JSON_UNESCAPED_UNICODE);            die();        }    }    /**     * 返回指定用户参与的所有项目     */    function getUserALLProject()    {        if (!isset($this->params['userid']) || !($this->params['userid'] > 0)) {            echo json_encode(array('status' => FALSE, 'msg' => '返回指定用户参与的所有项目参数错误'), JSON_UNESCAPED_UNICODE);            die();        }        $conArray = $this->contractact->getUserRow($this->params['userid']);        if (isset($conArray) && $conArray) {            foreach ($conArray as $key => $value) {                $proArray = $this->project->getRowByPid($value['pid']);                $attfileArray = $this->attfile->getLastData($value['stid']);                foreach ($attfileArray as $k => $v) {                    $pathinfo = pathinfo($v['filepath']);                    $retArray[] = array('downurl' => Doo::conf()->APP_URL . $pathinfo ['dirname'] . '/' . $pathinfo ['filename'] . '/ProjectFile.rmf', 'proName' => $proArray['pname'], 'stName' => $value['stname'], 'MD5_Jl' => $v['filehashcode']);                }            }            echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $retArray), JSON_UNESCAPED_UNICODE);            die();        } else {            $userproArray = $this->measureauditact->getProject($this->params['userid']);            if (isset($userproArray) && $userproArray) {                foreach ($userproArray as $upk => $upv) {                    $attArray = $this->attfile->getMeasureLastNew($upv['pmid'], $upv['numpname']);                    $proArray = $this->project->getRowByPid($attArray['pid']);                    $attfileArray = $this->contractact->getRowByStid($attArray['stid']);                    $pathinfo = pathinfo($attArray['filepath']);                    if (isset($pathinfo['dirname']))                        $newattArray[] = array('downurl' => Doo::conf()->APP_URL . $pathinfo ['dirname'] . '/' . $pathinfo ['filename'] . '/ProjectFile.rmf', 'proName' => $proArray['pname'], 'stName' => $attfileArray['stname'], 'MD5_Jl' => $attArray['filehashcode']);                }                echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $newattArray), JSON_UNESCAPED_UNICODE);                die();            }        }    }    /**     * 设置审批未通过操作     * 第一步设置未通过操作,操作相关期数。 同步状态。     * 第二步设置项目查询接口未通过审批的查询返回未锁定的     * 第三步前台相关状态更新     *     * TODO: 更新附件标志位未加入次数标志做更新 ok     * TODO: 不通过两次未通过时候操作期数状态为错误位同步状态位 ok     * TODO: MPID未通过操作不争取 ok     */    function setCheckno()    {        if (isset($this->params['userid']) && isset($this->params['tenderid']) && isset($this->params['phaseno']) && isset($_POST['MD5_JL']) && isset($_POST['MD5_Zip'])) {            $auditcontent = iconv('GBK', 'UTF - 8', $_POST['CheckerMemo']);            $auditArrayStatus = $this->measureauditact->getLastNewRowInfo($this->params['tenderid'], $this->params['phaseno'], $this->params['userid']);            if (isset($auditArrayStatus ['mastatus']) && (($auditArrayStatus ['mastatus'] == 'checked') || ($auditArrayStatus ['mastatus'] == 'checkno'))) {                echo json_encode(array('status' => FALSE, 'msg' => '该标段已审批完毕。'), JSON_UNESCAPED_UNICODE);                die();            }            $auditArray = $this->measureauditact->getRowInfo($this->params['tenderid'], $this->params['phaseno'], $this->params['userid']);            if (isset($auditArray['maid'])) {                $intMaxTimes = $this->numofperact->getMaxTimes($this->params['tenderid'], $this->params['phaseno']);                if (isset($intMaxTimes['times'])) {                    $iniTimes = $intMaxTimes['times'];                }                $this->measureauditact->setCheckno($auditArray['maid'], $auditcontent);                $this->numofperact->updateAuditStatus($this->params['tenderid'], $this->params['phaseno'], 'checkno', $iniTimes);                $fp = $this->upfile('upfile');                if (isset($fp[0]['filepath'])) {                    // 解压缩文件等待以后直接使用                    // TODO:根据校验码校验包的完整性                    $localmd5HashString = hash_file("md5", Doo::conf()->SITE_PATH . $fp[0]['filepath']);                    if ($localmd5HashString != trim($_POST['MD5_Zip'])) {                        $status = array('status' => 'FALSE', 'msg' => '未通过期数数据上传失败,请重新上传');                        echo json_encode($status, JSON_UNESCAPED_UNICODE);                        die();                    }                    $res = $this->zip->open(Doo::conf()->SITE_PATH . $fp[0]['filepath']);                    $extPath = pathinfo($fp[0]['filepath']);                    $extPathdir = Doo::conf()->SITE_PATH . $extPath ['dirname'] . '/' . $extPath['filename'];                    if ($res === TRUE) {                        if (!$this->dir_create($extPathdir)) {                            return FALSE;                        }                        $this->zip->extractTo($extPathdir);                        $this->zip->close();                    }                    $numArray = $this->numofperact->getRow($this->params['tenderid'], $this->params['phaseno'], $iniTimes);                    // 插入附件表之前要更新所有次标段期数的提交的数据状态为旧标志                    $this->attfile->setOldfileFlag($this->params['tenderid'], $this->params['phaseno'], $iniTimes);                    // 插入此次提交的文件路径数据并设置为新状态                    $this->attfile->insertFile($auditArray['pid'], $auditArray['stid'], $auditArray['mpid'], $this->params['tenderid'], $this->params['phaseno'], $this->params['userid'], $fp[0]['filepath'], 0, $_POST['MD5_JL'], $iniTimes);                    // SMS Start                    $TenderArray = $this->actmeasure->getRowByPmid($this->params['tenderid']);                    $userProArray = $this->profile->getProWithUid($TenderArray['uid']);                    if (isset($userProArray) && ($userProArray['mobile'])) {                        $retval = $this->__auditNotice($userProArray['mobile'], Doo::conf()->SMS_TIPS_PRE . '您好,' . $TenderArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR4"]);                    }                    // SMS End                    echo json_encode(array('status' => TRUE, 'msg' => ''), JSON_UNESCAPED_UNICODE);                    die();                } else {                    echo json_encode(array('status' => FALSE, 'msg' => '文件上传故障'), JSON_UNESCAPED_UNICODE);                    die();                }            } else {                echo json_encode(array('status' => FALSE, 'msg' => '审批期数不存在'), JSON_UNESCAPED_UNICODE);                die();            }        } else {            echo json_encode(array('status' => FALSE, 'msg' => '审批未通过参数错误'), JSON_UNESCAPED_UNICODE);            die();        }    }    /**     * 创建未通过的新一期     *     */    function createNewAudit()    {        // 插入上次期数相关审批人员        // TODO://	error_log(var_export($this->params, TRUE), 3, ' / opt / html / jiliang_customedProduct / data / ' . time());//	die;        if (isset($this->params['tenderid']) && isset($this->params['phaseno'])) {            $auditArray = $this->numofperact->getChecknoRow($this->params['tenderid'], $this->params['phaseno']);            if (isset($auditArray['currstatus']) && ($auditArray['currstatus'] == 'checkno')) {                $isCreate = false;                $auditUserArray = $this->measureauditact->getUserAuditLast($this->params['tenderid'], $this->params['phaseno']);                foreach ($auditUserArray as $key => $value) {                    if ($value['mastatus'] != 'uncheck') {                        $isCreate = true;                    }                }                if ($auditUserArray && $isCreate) {                    foreach ($auditUserArray as $key => $value) {                        $this->measureauditact->insertMeasureAudit($value['pid'], $value['creatoruid'], $value['auditoruid'], $value['mpid'], $value['pmid'], $value['stid'], $value['numpname'], $status = 'uncheck', $value['last'], $auditArray['times'] + 1);                    }                } else {                    echo json_encode(array('status' => FALSE, 'msg' => '无效操作重复创建审批人'), JSON_UNESCAPED_UNICODE);                    die();                }////                $timesArray = $this->numofperact->getMaxTimes($this->params['tenderid'], $this->params['phaseno']);//                $urlinfoArray = $this->attfile->getLastNewProfileUnlock2($this->params['tenderid'], $this->params['phaseno']);//                $proArray = $this->project->getRowByPid($urlinfoArray['pid']);//                $stArray = $this->contractact->getRowByStid($urlinfoArray['stid']);//                $MeasureArray = $this->actmeasure->getRowByPmid($this->params['tenderid']);//                $downArray = NULL;//                $pathinfo = pathinfo($urlinfoArray['filepath']);//                if (isset($pathinfo['dirname']))//                    $downArray[] = array('downurl' => Doo::conf()->APP_URL . $pathinfo['dirname'] . ' / ' . $pathinfo['filename'] . ' / ProjectFile . rmf', 'MD5_Jl' => $urlinfoArray['filehashcode'], 'proName' => $proArray['pname'], 'stName' => $stArray['stname'], 'pnameid' => $proArray['pid'], 'ptypeid' => $stArray['stid'], 'BidName' => $MeasureArray['pmname']);//                echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $downArray), JSON_UNESCAPED_UNICODE);                echo json_encode(array('status' => 'TRUE', 'msg' => ''), JSON_UNESCAPED_UNICODE);                die();            } else {                echo json_encode(array('status' => FALSE, 'msg' => '审批状态无效'), JSON_UNESCAPED_UNICODE);                die();            }        } else {            echo json_encode(array('status' => FALSE, 'msg' => '创建未通过的新一期参数错误'), JSON_UNESCAPED_UNICODE);            die();        }    }    /**     * 重做新一期获取原报上报文件     *     */    function getReportFile()    {        if (isset($this->params['tenderid']) && isset($this->params['phaseno'])) {            $auditArray = $this->numofperact->getChecknoRow($this->params['tenderid'], $this->params['phaseno']);            if (isset($auditArray['currstatus']) && ($auditArray['currstatus'] == 'checkno')) {                $timesArray = $this->numofperact->getMaxTimes($this->params['tenderid'], $this->params['phaseno']);                $urlinfoArray = $this->attfile->getReportFile($this->params['tenderid'], $this->params['phaseno'], $timesArray['times']);                $proArray = $this->project->getRowByPid($urlinfoArray['pid']);                $stArray = $this->contractact->getRowByStid($urlinfoArray['stid']);                $MeasureArray = $this->actmeasure->getRowByPmid($this->params['tenderid']);                $downArray = NULL;                $pathinfo = pathinfo($urlinfoArray['filepath']);                if (isset($pathinfo['dirname'])) {                    $downArray[] = array('downurl' => Doo::conf()->APP_URL . $pathinfo['dirname'] . '/' . $pathinfo['filename'] . '/ProjectFile.rmf', 'MD5_Jl' => $urlinfoArray['filehashcode'], 'proName' => $proArray['pname'], 'stName' => $stArray['stname'], 'pnameid' => $proArray['pid'], 'ptypeid' => $stArray['stid'], 'BidName' => $MeasureArray['pmname']);                    echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $downArray), JSON_UNESCAPED_UNICODE);                    die();                } else {                    echo json_encode(array('status' => FALSE, 'msg' => '上报文件不存在'), JSON_UNESCAPED_UNICODE);                    die();                }            } else {                echo json_encode(array('status' => FALSE, 'msg' => '审批状态无效'), JSON_UNESCAPED_UNICODE);                die();            }        } else {            echo json_encode(array('status' => FALSE, 'msg' => '创建未通过的新一期参数错误'), JSON_UNESCAPED_UNICODE);            die();        }    }    public function getUserInfo()    {        if (isset($this->params['userid']) && ($this->params['userid'] > 0)) {            $proArray = $this->profile->getProWithUid($this->params['userid']);            if (isset($proArray['userid'])) {                $strAvatar = $this->auth->getAvatar($proArray['userid']);                echo json_encode(array('status' => 'TRUE', 'msg' => '', 'info' => array('avatar' => $strAvatar, 'name' => $proArray['name'], 'jobs' => $proArray['jobs'], 'company' => $proArray['company'])), JSON_UNESCAPED_UNICODE);                die();            } else {                echo json_encode(array('status' => 'FALSE', 'msg' => '此用户不存在'), JSON_UNESCAPED_UNICODE);                die();            }        } else {            echo json_encode(array('status' => 'FALSE', 'msg' => '用户查询参数无效'), JSON_UNESCAPED_UNICODE);            die();        }    }    public function updateTenderName()    {        if (isset($this->params['BidID']) && isset($this->params['BidNewName'])) {            if ($this->actmeasure->updateName($this->params['BidID'], iconv('GBK', 'UTF - 8', $this->params['BidNewName']))) {                echo json_encode(array('status' => 'TRUE', 'msg' => ''), JSON_UNESCAPED_UNICODE);                die();            } else {                echo json_encode(array('status' => 'FALSE', 'msg' => '标段名称更新错误'), JSON_UNESCAPED_UNICODE);                die();            }        } else {            echo json_encode(array('status' => 'FALSE', 'msg' => '标段名称更新参数无效'), JSON_UNESCAPED_UNICODE);            die();        }    }    /**     *  清单附件上传,单文件上传     * @param int $tenderid 标段ID     * @param int $uid 上传人ID     * @param int $itemid 本地清单ID     */    public function uploadItemFile()    {        if (isset($this->params['tenderid']) && isset($this->params['uid'])) {            if (!isset($_FILES['upitem']) && !isset($_POST['itemid']) && !isset($_POST['category']) && !isset($_POST['phase'])) {                $this->msg(0, '上传参数错误');            }            $fileArray = $this->upItemFile('upitem')[0];            if (isset($fileArray['filepath'])) {                $pidArray = $this->actmeasure->getRowByPmid($this->params['tenderid']);                $memoStr = iconv('GBK', 'UTF-8', $_POST['Memo']);                $pathinfo_dirname = pathinfo($fileArray['filepath'], PATHINFO_DIRNAME);                $filenameStr2 = iconv('GBK', 'UTF-8', $fileArray['filename']);//                $url = $pathinfo_dirname . '/' . $filenameStr2;//                setlocale(LC_ALL, 'zh_CN.UTF-8');//                $fname = pathinfo($url);//                $filenameStr = $fname['filename'];                $filenameStr = str_replace(strrchr($filenameStr2, "."),"",$filenameStr2);                $postArray = array('ownerid' => $this->params['uid'], 'pid' => $pidArray['pid'], 'pmid' => $this->params['tenderid'], 'filename' => $filenameStr, 'filesize' => $fileArray['filesize'], 'fileext' => $fileArray['fileext'], 'filepath' => $fileArray['filepath']);                $iaid = $this->itemfile->insertItemFileRecord($postArray);                if ($iaid > 1) {                    $itemMeasureNumArray = array('iaid' => $iaid, 'pid' => $pidArray['pid'], 'pmid' => $this->params['tenderid'], 'numpname' => $_POST['phase'], 'ownerid' => $this->params['uid'], 'itemid' => $_POST['itemid'], 'categoryid' => array_search($_POST['category'], $this->fileTypeArray), 'tips' => $memoStr);                    if (($imnid = $this->itemMeasureNum->insert($itemMeasureNumArray)) > 0) {                        $extPath = pathinfo($fileArray['filepath']);                        $itemArray = array('onlineFileName' => $extPath['filename'] . '.' . $extPath['extension'], 'imnid' => $imnid, 'fileurl' => Doo::conf()->APP_URL . $fileArray['filepath']);                        $status = array('status' => TRUE, 'msg' => '', 'iteminfo' => $itemArray);                        echo json_encode($status, JSON_UNESCAPED_UNICODE);                        die();                    } else {                        $this->msg(0, '附件上传失败,请重新上传.');                    }                }            } else {                $this->msg(0, '附件上传失败,请重新上传');            }        } else {            $this->msg(0, '上传参数错误');        }    }    /**     * 获得清单附件列表     */    public function getItemFileList()    {        if (isset($this->params['tenderid'])) {            $itemfileArray = $this->itemMeasureNum->getItemMeasureNum($this->params['tenderid']);            foreach ($itemfileArray as $value) {                $profileArray = $this->profile->getProWithUid($value['ownerid']);                $attFileArray = $this->itemfile->getItemFile($value['iaid']);                if (isset($attFileArray) && $attFileArray && isset($profileArray) && $profileArray)                    $downArray[] = array('downurl' => Doo::conf()->APP_URL . $attFileArray['filepath'], 'filename' => $attFileArray['filename'] . '.' . $attFileArray['fileext'], 'fileext' => $attFileArray['fileext'], 'ownerName' => $profileArray['name'], 'itemid' => $value['softwareitemid'], 'Category' => $value['categoryid'], 'Memo' => $value['tips'], 'ownerid' => $value['ownerid'], 'uptime' => date('Y-m-d H:i', $value['intime']), 'fileid' => $value['imnid'], 'phase' => $value['numpname']);            }            echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $downArray), JSON_UNESCAPED_UNICODE);            die();        } else {            $this->msg(0, '获取附件列表参数错误');        }    }    /**     * 编辑清单附件描述 文件名?     */    public function updateItemFileDesc()    {        if (isset($this->params['fileid']) && isset($_POST['FileName']) && isset($_POST['Memo'])) {            // $memoStr = iconv('GB18030', 'UTF-8', $_POST['Memo']);            $memoStr = $_POST['Memo'];            // $filenameStr = iconv('GB18030', 'UTF-8', $_POST['FileName']);            $filenameStr = $_POST['FileName'];            $imnidArray = $this->itemMeasureNum->getRowData($this->params['fileid']);            // if ($this->itemMeasureNum->updateItemFields($this->params['fileid'], $memoStr) > 0) {            $this->itemMeasureNum->updateItemFields($this->params['fileid'], $memoStr);            $this->itemfile->updateItemFields($imnidArray['iaid'], $filenameStr);            echo json_encode(array('status' => 'TRUE', 'msg' => ''), JSON_UNESCAPED_UNICODE);            die();            // } else {            //     echo json_encode(array('status' => 'FALSE', 'msg' => '附件更新接口参数错误'), JSON_UNESCAPED_UNICODE);            //     die();            // }        } else {            $this->msg(0, '附件更新接口参数错误');        }    }    /**     * 删除清单附件     */    public function delItemFile()    {        if (isset($this->params['fileid'])) {            $this->itemMeasureNum->delItemFields($this->params['fileid']);            echo json_encode(array('status' => 'TRUE', 'msg' => ''), JSON_UNESCAPED_UNICODE);            die();        } else {            $this->msg(0, '关联删除接口参数错误');        }    }    /**     * @return attachment     */    public function getAttaFilesAll()    {        if (isset($this->params['tenderid'])) {            $itemfileArray = $this->itemfile->getFilesAll($this->params['tenderid']);            foreach ($itemfileArray as $value) {//                $profileArray = $this->profile->getProWithUid($value['ownerid']);//                $attFileArray = $this->itemfile->getItemFile($value['iaid']);//                if (isset($attFileArray) && $attFileArray && isset($profileArray) && $profileArray)                $filesArray[] = array('downurl' => Doo::conf()->APP_URL . $value['filepath'], 'filename' => $value['filename'] . '.' . $value['fileext'], 'fileext' => $value['fileext'], 'fileid' => $value['iaid']);            }            echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $filesArray), JSON_UNESCAPED_UNICODE);            die();        } else {            $this->msg(0, '获取附件列表参数错误');        }    }    /**     * @return attachment     */    public function createAttWithTender()    {        if (isset($this->params['tenderid'])) {            $itemfileArray = $this->itemfile->getFilesAll($this->params['tenderid']);            foreach ($itemfileArray as $value) {//                $profileArray = $this->profile->getProWithUid($value['ownerid']);//                $attFileArray = $this->itemfile->getItemFile($value['iaid']);//                if (isset($attFileArray) && $attFileArray && isset($profileArray) && $profileArray)                $filesArray[] = array('downurl' => Doo::conf()->APP_URL . $value['filepath'], 'filename' => $value['filename'] . '.' . $value['fileext'], 'fileext' => $value['fileext'], 'fileid' => $value['iaid']);            }            echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $filesArray), JSON_UNESCAPED_UNICODE);            die();        } else {            $this->msg(0, '获取附件列表参数错误');        }    }    /**     *   查询指定项目的指定期的全部审批意见。     *   标段ID,期号     */    public function getAuditOpinion()    {        if (isset($this->params['tenderid']) && isset($this->params['phaseno'])) {            $retval = $this->measureauditact->getAuditOpinion($this->params['tenderid'], $this->params['phaseno']);            $iterator = new ArrayIterator($retval);            if (iterator_count($iterator) > 0) {                foreach ($retval as $value) {                    $proArray = $this->profile->getProWithUid($value['auditoruid']);                    $auditcontent = !empty($value['auditcontent']) ? $value['auditcontent'] : '';                    $uArray[] = array('realname' => $proArray['name'], 'jobs' => $proArray['jobs'], 'acontent' => $auditcontent);                }                echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $uArray), JSON_UNESCAPED_UNICODE);                die();            } else {                echo json_encode(array('status' => 'FALSE', 'msg' => '查询指定项目的指定期的全部审批意见参数错误'), JSON_UNESCAPED_UNICODE);                die();            }        } else {            $this->msg(0, '查询指定项目的指定期的全部审批意见接口参数错误');        }    }    /**     *   。     *   标段ID,期号     */    private function __auditNotice($mobile, $text)    {        $smsSwitch = $this->aconfig->getOne(array('select' => 'smsSwitch', 'asArray' => TRUE))['smsSwitch'];        if ($smsSwitch > 0)            return $this->sms->sendSms($mobile, $text);    }    function upfile($fildname, $param = 'doc, docx, xls, xlsx, png, zip')    {        return $this->att->uploadMut($fildname, $param);    }    function upItemFile($fildname, $param = 'doc, docx, xls, xlsx, png, zip')    {        $this->att->setUploadDir();        return $this->att->uploadMut($fildname, $param);    }    /**     *   根据标段ID获取标段是否已经被删除的提示     *   标段ID     */    public function getCountPmid()    {        if (isset($this->params['tenderid'])) {            $isexist = $this->actmeasure->getCountPmid($this->params['tenderid']);            if ($isexist > 0) {                echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => null), JSON_UNESCAPED_UNICODE);                die();            } else {                echo json_encode(array('status' => 'FALSE', 'msg' => '该项目[XXX]在云端已被删除,点击“确定”后,可手动删除该项目'), JSON_UNESCAPED_UNICODE);                die();            }        } else {            $this->msg(0, '获取标段是否存在参数错误');        }    }    function getFileupErrorNo()    {        return $this->att->error();    }    function Signout()    {        session_destroy();    }    function isLoggedIn()    {        return isset($_SESSION['user_id']);    }    function generateFormHash($salt)    {        $hash = md5(mt_rand(1, 1000000) . $salt);        $_SESSION['csrf_hash'] = $hash;        return $hash;    }    function isValidFormHash($hash)    {        return $_SESSION['csrf_hash'] === $hash;    }    /**     * 随机字符串函数     * @param $password 密码     * @param $random 随机数     */    function random($length, $chars = '0123456789')    {        $hash = '';        $max = strlen($chars) - 1;        for ($i = 0; $i < $length; $i++) {            $hash .= $chars[mt_rand(0, $max)];        }        return $hash;    }    /**     * 生成随机字符串     * @param string $lenth 长度     * @return string 字符串     */    function create_randomstr($lenth = 6)    {        return $this->random($lenth, '123456789abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ');    }    function dir_create($path, $mode = 0777)    {        if (is_dir($path))            return TRUE;        $path = $this->dir_path($path);        $parent = dirname($path);        if (!is_dir($parent))            @mkdir($parent, 0777, true);        @mkdir($path, 0777, true);        return is_dir($path);    }    function dir_create2($path, $mode = 0777)    {        if (is_dir($path))            return TRUE;        $path = $this->dir_path($path);        $parent = dirname($path);        if (!is_dir($parent)){            @mkdir($parent, 0777);            @chmod($parent, 0777);        }        @mkdir($path, 0777);        @chmod($path, 0777);        return is_dir($path);    }    function dir_path($path)    {        $path = str_replace('\\', '/', $path);        if (substr($path, -1) != '/')            $path = $path . '/';        return $path;    }    function msg($isTrue = 0, $msg = null, $retmsg = null)    {        if ($isTrue > 0) {            echo json_encode(array('status' => 'TRUE', 'msg' => ''), JSON_UNESCAPED_UNICODE);            die();        } else {            echo json_encode(array('status' => 'FALSE', 'msg' => $msg), JSON_UNESCAPED_UNICODE);            die();        }    }//    function checkVersion($version)//    {//        preg_match();//    }//在线签署的接口    public function getSignCreate(){        // TODO:上报数据        if (!empty($_FILES['upspdf']['name']) && !empty($_FILES['upfile']['name']) && isset($_POST['project']) && isset($_POST['tender']) && isset($_POST['phaseno']) && isset($_POST['name']) && isset($_POST['ownuid']) && isset($_POST['widhei'])) {            //解压压缩包并把图片存到文件夹中            @$_POST['name'] = iconv('GBK', 'UTF-8', $_POST['name']);            $upfilename = pathinfo($_FILES['upfile']['name']);            if($upfilename['extension'] != 'zip'){                $status = array('status' => 'FALSE', 'msg' => '上传的文件格式有误');                echo json_encode($status, JSON_UNESCAPED_UNICODE);                die();            }            $res = $this->zip->open($_FILES['upfile']['tmp_name']);            if ($res === TRUE) {                $samesignname = $this->sign->getSignbyName($_POST['name']);                if(!empty($samesignname)){                    $status = array('status' => 'FALSE', 'msg' => '存在同名报表');                    echo json_encode($status, JSON_UNESCAPED_UNICODE);                    die();                }                //添加到签署报表中                $intime = time();                $signid = $this->sign->insertSign($_POST['project'], $_POST['tender'], $_POST['phaseno'], $_POST['name'], $_POST['ownuid'],$intime,$_POST['widhei']);                $extPathdir = Doo::conf()->SITE_PATH . 'signs/' . $signid;                if ($res === TRUE) {                    if (!$this->dir_create2($extPathdir)) {                        $status = array('status' => 'FALSE', 'msg' => '期数数据上传失败');                        echo json_encode($status, JSON_UNESCAPED_UNICODE);                        die();                    }                    $this->zip->extractTo($extPathdir);                    $this->zip->close();                    $fileanddir = $this->deepScanDir($extPathdir);                    sort($fileanddir['file2']);                    $sum = 0;                    foreach($fileanddir['file2'] as $k =>$v){                        $sum++;                        $signatt = new signn();                        $path = 'signs/'.$signid.'/' . $v . '.jpg';                        @chmod(Doo::conf()->SITE_PATH.$path,0777);                        $signatt->insertSignAtt($signid,$v,$path);//                        $this->compressed_image(Doo::conf()->SITE_PATH.$path,Doo::conf()->SITE_PATH.$path);                    }                    $sign2 = new signn();                    $sign2->updateSignPageNum($signid,$sum);                    $upspdfname = pathinfo($_FILES['upspdf']['name']);                    if($upspdfname['extension'] != 'pdf'){                        $status = array('status' => 'FALSE', 'msg' => '上传的文件格式有误');                        echo json_encode($status, JSON_UNESCAPED_UNICODE);                        die();                    }                    //上传pdf文件                    if(!empty($_FILES["upspdf"]['name'])){                        $pdf_name = $intime.'.pdf';                        $upload_pdf = $extPathdir.'/'.$pdf_name;                        $k = move_uploaded_file($_FILES["upspdf"]["tmp_name"], $upload_pdf);                        if($k){                            $status = array('status' => 'TRUE');                            echo json_encode($status, JSON_UNESCAPED_UNICODE);                            die();                        }                    }                }            }            $status = array('status' => 'FALSE', 'msg' => '文件上传失败,请重试');            echo json_encode($status, JSON_UNESCAPED_UNICODE);            die();        } else {            $status = array('status' => 'FALSE', 'msg' => '上传参数错误');            echo json_encode($status, JSON_UNESCAPED_UNICODE);            die();        }    }    public function getSignList(){        $wheresql = ' 1';        if(isset($_POST['project']) && is_numeric($_POST['project'])){            $wheresql .= ' and project='.$_POST['project'];        }        if(isset($_POST['tender']) && is_numeric($_POST['tender'])) {            $wheresql .= ' and tender='.$_POST['tender'];        }        if(isset($_POST['phaseno']) && is_numeric($_POST['phaseno'])){            $wheresql .= ' and phaseno='.$_POST['phaseno'];        }        $signlist = $this->sign->getSignListbyClient($wheresql);        if(!empty($signlist)){            $interMediatelist = array();            foreach($signlist as $k => $v){                $interMediatelist[$k]['signid'] = $v['sid'];                $interMediatelist[$k]['md5_sign'] = md5(Doo::conf()->SITE_PATH . 'signs/' . $v['sid']);                $interMediatelist[$k]['project'] = $v['project'];                $interMediatelist[$k]['tender'] = $v['tender'];                $interMediatelist[$k]['phaseno'] = $v['phaseno'];                $interMediatelist[$k]['name'] = $v['name'];                $interMediatelist[$k]['ownuid'] = $v['ownuid'];                $interMediatelist[$k]['status'] = $v['isinter'];                $interMediatelist[$k]['currnum'] = $v['pagenum'];                $interMediatelist[$k]['totalnum'] = $v['internum'];            }            echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $interMediatelist), JSON_UNESCAPED_UNICODE);            die();        }else{            $status = array('status' => TRUE, 'msg' => '当前没有签署报表','info' => '');            echo json_encode($status, JSON_UNESCAPED_UNICODE);            die();        }    }    //中间计量表的接口    public function getInterMediateCreate(){        // TODO:上报数据        if (isset($_POST['project']) && isset($_POST['tender']) && isset($_POST['phaseno']) && isset($_POST['name']) && isset($_POST['ownuid']) && isset($_POST['widhei']) && isset($_POST['totalnum'])) {            //解压压缩包并把图片存到文件夹中            @$_POST['name'] = iconv('GBK', 'UTF-8', $_POST['name']);            $samesignname = $this->sign->getSignbyName($_POST['tender'], $_POST['phaseno'], $_POST['name']);            if(!empty($samesignname)){                $status = array('status' => 'FALSE', 'msg' => '存在同名中间计量表');                echo json_encode($status, JSON_UNESCAPED_UNICODE);                die();            }            //添加到签署报表中            $intime = time();            $signid = $this->sign->insertSign($_POST['project'], $_POST['tender'], $_POST['phaseno'], $_POST['name'], $_POST['ownuid'],$intime,$_POST['widhei'],1,$_POST['totalnum']);            $extPathdir = Doo::conf()->SITE_PATH . 'signs/' . $signid;            if (!$this->dir_create2($extPathdir)) {                $status = array('status' => 'FALSE', 'msg' => '文件夹创建失败');                echo json_encode($status, JSON_UNESCAPED_UNICODE);                die();            }            $status = array('status' => 'TRUE','msg' => '', 'info' => array('signid' => $signid, 'md5_sign' => md5($extPathdir)));            echo json_encode($status, JSON_UNESCAPED_UNICODE);            die();        } else {            $status = array('status' => 'FALSE', 'msg' => '上传参数错误');            echo json_encode($status, JSON_UNESCAPED_UNICODE);            die();        }    }    public function getInterMediateUpload(){        if(isset($_POST['signid']) && isset($_POST['md5_sign']) && !empty($_FILES['imediate']['name'])){            $extPathdir = Doo::conf()->SITE_PATH . 'signs/' . $_POST['signid'];            if($_POST['md5_sign'] != md5($extPathdir)){                $status = array('status' => 'FALSE', 'msg' => '上传的图表不对应');                echo json_encode($status, JSON_UNESCAPED_UNICODE);                die();            }            $path = $extPathdir .'/' . $_FILES['imediate']['name'];            @chmod(Doo::conf()->SITE_PATH.$path,0777);            $k = move_uploaded_file($_FILES['imediate']["tmp_name"], $path);            if($k){                $signatt = new signn();                $result = $signatt->insertSignAtt($_POST['signid'],basename($_FILES['imediate']['name'],".jpg"),'signs/' . $_POST['signid'].'/'.$_FILES['imediate']['name']);                if(!empty($result)){                    $sign2 = new signn();                    $signArray = $sign2->getOneSignbysid($_POST['signid']);                    $sign2->updateSignPageNum($_POST['signid'],$signArray['pagenum']+1);                    if($signArray['pagenum']+1 == $signArray['internum']){                        $sign2->updateInterMediateStatus($_POST['signid'],2);                    }                    $status = array('status' => 'TRUE');                    echo json_encode($status, JSON_UNESCAPED_UNICODE);                    die();                }else{                    $status = array('status' => 'FALSE', 'msg' => '图片保存出错');                    echo json_encode($status, JSON_UNESCAPED_UNICODE);                    die();                }            }else{                $status = array('status' => 'FALSE', 'msg' => '上传图片失败');                echo json_encode($status, JSON_UNESCAPED_UNICODE);                die();            }        }else{            $status = array('status' => 'FALSE', 'msg' => '上传参数错误');            echo json_encode($status, JSON_UNESCAPED_UNICODE);            die();        }    }    public function getInterMediateList(){        $wheresql = 'isinter!=0';        if(isset($_POST['project']) && is_numeric($_POST['project'])){            $wheresql .= ' and project='.$_POST['project'];        }        if(isset($_POST['tender']) && is_numeric($_POST['tender'])) {            $wheresql .= ' and tender='.$_POST['tender'];        }        if(isset($_POST['phaseno']) && is_numeric($_POST['phaseno'])){            $wheresql .= ' and phaseno='.$_POST['phaseno'];        }        $signlist = $this->sign->getSignListbyClient($wheresql);        if(!empty($signlist)){            $interMediatelist = array();            foreach($signlist as $k => $v){                $interMediatelist[$k]['signid'] = $v['sid'];                $interMediatelist[$k]['md5_sign'] = md5(Doo::conf()->SITE_PATH . 'signs/' . $v['sid']);                $interMediatelist[$k]['phaseno'] = $v['phaseno'];                $interMediatelist[$k]['name'] = $v['name'];                $interMediatelist[$k]['ownuid'] = $v['ownuid'];                $interMediatelist[$k]['status'] = $v['isinter'];                $interMediatelist[$k]['currnum'] = $v['pagenum'];                $interMediatelist[$k]['totalnum'] = $v['internum'];            }            echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $interMediatelist), JSON_UNESCAPED_UNICODE);            die();        }else{            $status = array('status' => TRUE, 'msg' => '当前没有中间计量表','info' => '');            echo json_encode($status, JSON_UNESCAPED_UNICODE);            die();        }    }    // public function testzip(){    //     $this->render('testzip', $this->data);    // }    function deepScanDir($dir) {        $fileArr = array ();        $fileArr2 = array ();        $dirArr = array ();        $dir = rtrim($dir, '//');        if (is_dir($dir)) {            $dirHandle = opendir($dir);            while (false !== ($fileName = readdir($dirHandle))) {                $subFile = $dir . DIRECTORY_SEPARATOR . $fileName;                if (is_file($subFile)) {                    $fileArr[] = $subFile;                    $fileArr2[] = basename($subFile,'.jpg');                }                elseif (is_dir($subFile) && str_replace('.', '', $fileName) != '') {                    $dirArr[] = $subFile;                    $arr = $this->deepScanDir($subFile);                    $dirArr = array_merge($dirArr, $arr['dir']);                    $fileArr = array_merge($fileArr, $arr['file']);                    $fileArr2 = array_merge($fileArr2, $arr['file2']);                }            }            closedir($dirHandle);        }        return array (            'dir' => $dirArr,            'file' => $fileArr,            'file2' => $fileArr2        );    }    /**     * desription 判断是否gif动画     * @param sting $image_file图片路径     * @return boolean t 是 f 否     */    function check_gifcartoon($image_file){        $fp = fopen($image_file,'rb');        $image_head = fread($fp,1024);        fclose($fp);        return preg_match("/".chr(0x21).chr(0xff).chr(0x0b).'NETSCAPE2.0'."/",$image_head)?false:true;    }    /**     * desription 压缩图片     * @param sting $imgsrc 图片路径     * @param string $imgdst 压缩后保存路径     */    function compressed_image($imgsrc,$imgdst){        list($width,$height,$type)=getimagesize($imgsrc);        $new_width = $width;        $new_height = $height;        switch($type){            case 1:                $giftype=$this->check_gifcartoon($imgsrc);                if($giftype){                    // header('Content-Type:image/gif');                    $image_wp=imagecreatetruecolor($new_width, $new_height);                    $image = imagecreatefromgif($imgsrc);                    imagecopyresampled($image_wp, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);                    //75代表的是质量、压缩图片容量大小                    imagejpeg($image_wp, $imgdst,100);                    imagedestroy($image_wp);                }                break;            case 2:                // header('Content-Type:image/jpeg');                $image_wp=imagecreatetruecolor($new_width, $new_height);                $image = imagecreatefromjpeg($imgsrc);                imagecopyresampled($image_wp, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);                //75代表的是质量、压缩图片容量大小                imagejpeg($image_wp, $imgdst,100);                imagedestroy($image_wp);                break;            case 3:                // header('Content-Type:image/png');                $image_wp=imagecreatetruecolor($new_width, $new_height);                $image = imagecreatefrompng($imgsrc);                imagecopyresampled($image_wp, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);                //75代表的是质量、压缩图片容量大小                imagejpeg($image_wp, $imgdst,100);                imagedestroy($image_wp);                break;            case 6://                header('Content-Type:image/x-ms-bmp');                $image_wp=imagecreatetruecolor($new_width, $new_height);                $image = $this->imagecreatefrombmp($imgsrc);                imagecopyresampled($image_wp, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);                //75代表的是质量、压缩图片容量大小                imagejpeg($image_wp, $imgdst,100);                imagedestroy($image_wp);                break;        }    }    //bmp 转jpg    function imagecreatefrombmp( $filename ){        if ( !$f1 = fopen( $filename, "rb" ) )            return FALSE;        $FILE = unpack( "vfile_type/Vfile_size/Vreserved/Vbitmap_offset", fread( $f1, 14 ) );        if ( $FILE['file_type'] != 19778 )            return FALSE;        $BMP = unpack( 'Vheader_size/Vwidth/Vheight/vplanes/vbits_per_pixel' . '/Vcompression/Vsize_bitmap/Vhoriz_resolution' . '/Vvert_resolution/Vcolors_used/Vcolors_important', fread( $f1, 40 ) );        $BMP['colors'] = pow( 2, $BMP['bits_per_pixel'] );        if ( $BMP['size_bitmap'] == 0 )            $BMP['size_bitmap'] = $FILE['file_size'] - $FILE['bitmap_offset'];        $BMP['bytes_per_pixel'] = $BMP['bits_per_pixel'] / 8;        $BMP['bytes_per_pixel2'] = ceil( $BMP['bytes_per_pixel'] );        $BMP['decal'] = ($BMP['width'] * $BMP['bytes_per_pixel'] / 4);        $BMP['decal'] -= floor( $BMP['width'] * $BMP['bytes_per_pixel'] / 4 );        $BMP['decal'] = 4 - (4 * $BMP['decal']);        if ( $BMP['decal'] == 4 )            $BMP['decal'] = 0;        $PALETTE = array();        if ( $BMP['colors'] < 16777216 ){            $PALETTE = unpack( 'V' . $BMP['colors'], fread( $f1, $BMP['colors'] * 4 ) );        }        $IMG = fread( $f1, $BMP['size_bitmap'] );        $VIDE = chr( 0 );        $res = imagecreatetruecolor( $BMP['width'], $BMP['height'] );        $P = 0;        $Y = $BMP['height'] - 1;        while( $Y >= 0 ){            $X = 0;            while( $X < $BMP['width'] ){                if ( $BMP['bits_per_pixel'] == 32 ){                    $COLOR = unpack( "V", substr( $IMG, $P, 4 ) );                    $B = ord(substr($IMG, $P,1));                    $G = ord(substr($IMG, $P+1,1));                    $R = ord(substr($IMG, $P+2,1));                    $color = imagecolorexact( $res, $R, $G, $B );                    if ( $color == -1 )                        $color = imagecolorallocate( $res, $R, $G, $B );                    $COLOR[0] = $R*256*256+$G*256+$B;                    $COLOR[1] = $color;                }elseif ( $BMP['bits_per_pixel'] == 24 )                    $COLOR = unpack( "V", substr( $IMG, $P, 3 ) . $VIDE );                elseif ( $BMP['bits_per_pixel'] == 16 ){                    $COLOR = unpack( "n", substr( $IMG, $P, 2 ) );                    $COLOR[1] = $PALETTE[$COLOR[1] + 1];                }elseif ( $BMP['bits_per_pixel'] == 8 ){                    $COLOR = unpack( "n", $VIDE . substr( $IMG, $P, 1 ) );                    $COLOR[1] = $PALETTE[$COLOR[1] + 1];                }elseif ( $BMP['bits_per_pixel'] == 4 ){                    $COLOR = unpack( "n", $VIDE . substr( $IMG, floor( $P ), 1 ) );                    if ( ($P * 2) % 2 == 0 )                        $COLOR[1] = ($COLOR[1] >> 4);                    else                        $COLOR[1] = ($COLOR[1] & 0x0F);                    $COLOR[1] = $PALETTE[$COLOR[1] + 1];                }elseif ( $BMP['bits_per_pixel'] == 1 ){                    $COLOR = unpack( "n", $VIDE . substr( $IMG, floor( $P ), 1 ) );                    if ( ($P * 8) % 8 == 0 )                        $COLOR[1] = $COLOR[1] >> 7;                    elseif ( ($P * 8) % 8 == 1 )                        $COLOR[1] = ($COLOR[1] & 0x40) >> 6;                    elseif ( ($P * 8) % 8 == 2 )                        $COLOR[1] = ($COLOR[1] & 0x20) >> 5;                    elseif ( ($P * 8) % 8 == 3 )                        $COLOR[1] = ($COLOR[1] & 0x10) >> 4;                    elseif ( ($P * 8) % 8 == 4 )                        $COLOR[1] = ($COLOR[1] & 0x8) >> 3;                    elseif ( ($P * 8) % 8 == 5 )                        $COLOR[1] = ($COLOR[1] & 0x4) >> 2;                    elseif ( ($P * 8) % 8 == 6 )                        $COLOR[1] = ($COLOR[1] & 0x2) >> 1;                    elseif ( ($P * 8) % 8 == 7 )                        $COLOR[1] = ($COLOR[1] & 0x1);                    $COLOR[1] = $PALETTE[$COLOR[1] + 1];                }else                    return FALSE;                imagesetpixel( $res, $X, $Y, $COLOR[1] );                $X++;                $P += $BMP['bytes_per_pixel'];            }            $Y--;            $P += $BMP['decal'];        }        fclose( $f1 );        return $res;    }    /**     * 查询标段关注人信息列表     */    public function getConcernAuditList(){        if(isset($this->params['tenderid']) && is_numeric($this->params['tenderid'])){            $concernArray = $this->concern->getMeasureConcernList($this->params['tenderid']);            if(!empty($concernArray)){                $userArray = array();                foreach($concernArray as $k => $v){                    $userArray[$k]['uid'] = $v['uid'];                    $userArray[$k]['name'] = $this->auth->getName($v['uid']);                    $userArray[$k]['uemail'] = $this->auth->getEmail($v['uid']);                }                echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $userArray), JSON_UNESCAPED_UNICODE);                die();            }else{                echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => null), JSON_UNESCAPED_UNICODE);                die();            }        } else {            echo json_encode(array('status' => 'FALSE', 'msg' => '标段参数无效'), JSON_UNESCAPED_UNICODE);            die();        }    }    /**     * 添加关注标段     */    public function addConcernAudit(){        if(isset($_POST['tenderid']) && is_numeric($_POST['tenderid']) && isset($_POST['uid']) && is_numeric($_POST['uid'])){            $tendermsg = $this->actmeasure->getRowByPmid($_POST['tenderid']);            if(!empty($tendermsg)){                $result = $this->concern->insertMeasureConcern($tendermsg['pid'], $tendermsg['stid'], $tendermsg['pmid'], $_POST['uid']);                if($result){                    echo json_encode(array('status' => TRUE, 'msg' => '成功添加关注'), JSON_UNESCAPED_UNICODE);                    die();                }else{                    echo json_encode(array('status' => 'FALSE', 'msg' => '添加标段关注人失败'), JSON_UNESCAPED_UNICODE);                    die();                }            }else{                echo json_encode(array('status' => 'FALSE', 'msg' => '标段不存在'), JSON_UNESCAPED_UNICODE);                die();            }        }else{            echo json_encode(array('status' => 'FALSE', 'msg' => '标段或关注人参数无效'), JSON_UNESCAPED_UNICODE);            die();        }    }    /**     * 取消关注标段     */    public function delConcernAudit(){        if(isset($_POST['tenderid']) && is_numeric($_POST['tenderid']) && isset($_POST['uid']) && is_numeric($_POST['uid'])){            $tendermsg = $this->actmeasure->getRowByPmid($_POST['tenderid']);            if(!empty($tendermsg)){                $result = $this->concern->delMeasureConcern($tendermsg['pmid'], $_POST['uid']);                echo json_encode(array('status' => TRUE, 'msg' => '成功取消关注'), JSON_UNESCAPED_UNICODE);                die();            }else{                echo json_encode(array('status' => 'FALSE', 'msg' => '标段不存在'), JSON_UNESCAPED_UNICODE);                die();            }        }else{            echo json_encode(array('status' => 'FALSE', 'msg' => '标段或关注人参数无效'), JSON_UNESCAPED_UNICODE);            die();        }    }    /**     * 软件生成报表开关     */    public function signSwitch(){        $reportSwitch = $this->aconfig->getOne(array('select' => 'reportswitch', 'asArray' => TRUE))['reportswitch'];        echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $reportSwitch), JSON_UNESCAPED_UNICODE);        die();    }    /**     * 中间计量表添加草图功能开关     */    public function interMediateSwitch(){        $imediateswitch = $this->aconfig->getOne(array('select' => 'imediateswitch', 'asArray' => TRUE))['imediateswitch'];        echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => $imediateswitch), JSON_UNESCAPED_UNICODE);        die();    }    /**     * 变更令签约清单列表添加     */    public function changeListAdd(){        if(isset($_POST['pmid']) && is_numeric($_POST['pmid']) && isset($_POST['listjson']) && !empty($_POST['listjson'])){            $pmArray = $this->actmeasure->getRowByPmid($_POST['pmid']);            if(!empty($pmArray)){                $listjson = json_decode($_POST['listjson'],true);                //先删除原有的清单列表再重新添加                $this->change->delChangeListbyPmid($_POST['pmid']);                Doo::loadModel('changelist');                foreach($listjson as $k => $v){                    $changelist = new ChangeList();                    $changelist->insertChangelist($pmArray,$v);                }                echo json_encode(array('status' => TRUE, 'info' => ''), JSON_UNESCAPED_UNICODE);                die();            }else{                echo json_encode(array('status' => 'FALSE', 'msg' => '不存在此标段'), JSON_UNESCAPED_UNICODE);                die();            }        }else{            echo json_encode(array('status' => 'FALSE', 'msg' => '参数有误'), JSON_UNESCAPED_UNICODE);            die();        }    }    /*     * 标段的变更令内容导出     */    public function changeList()    {        if(isset($this->params['pmid']) && is_numeric($this->params['pmid'])){            $pmArray = $this->actmeasure->getRowByPmid($this->params['pmid']);            if(!empty($pmArray)){                $idlist = array();                $list = array();                $newcidlist = array();                //获取所有通过的变更令内容                $cidlist = $this->change->getPassChangeListID($this->params['pmid']);                if(empty($cidlist)){                    echo json_encode(array('status' => 'TRUE', 'msg' => '当前标段不存在变更令内容', 'info' => ''), JSON_UNESCAPED_UNICODE);                    die();                }                foreach($cidlist as $ck => $cv){                    array_push($newcidlist,$cv['cid']);                }                //过滤掉已上传完的list                if(isset($_POST['filter']) && !empty($_POST['filter'])){                    $filter = explode(',',$_POST['filter']);                    $idlist = array_diff($newcidlist,$filter);                }else{                    $idlist = $newcidlist;                }                if(empty($idlist)){                    echo json_encode(array('status' => 'TRUE', 'msg' => '当前标段不存在需要更新的变更令', 'info' => ''), JSON_UNESCAPED_UNICODE);                    die();                }else{                    $index = 0;                    foreach($idlist as $k => $v){                        $changeArray = $this->change->getChangebyid($v);                        $list[$index] = $changeArray;                        $list[$index]['changeCategory'] = $this->changeCategory[$changeArray['category']];                        $list[$index]['changeNature'] = $this->changeNature[$changeArray['cnature']];                        $list[$index]['company'] = $this->change->getCompanybyid($changeArray['companyid'])['name'];                        $list[$index]['changeBills'] = $this->change->getChangeAuditListbycid($v);                        $index++;                    }                    echo json_encode(array('status' => 'TRUE', 'msg' => '', 'info' => $list), JSON_UNESCAPED_UNICODE);                    die();                }            }else{                echo json_encode(array('status' => 'FALSE', 'msg' => '不存在此标段'), JSON_UNESCAPED_UNICODE);                die();            }        }else{            echo json_encode(array('status' => 'FALSE', 'msg' => '参数有误'), JSON_UNESCAPED_UNICODE);            die();        }    }    /**     * 软件删除变更令后返回结果     */    public function changeDelete() {        if(isset($_POST['cid']) && is_numeric($_POST['cid'])) {            $cid = $_POST['cid'];            $changeArray = $this->change->getChangebyid($cid);            if(!empty($changeArray)){                $result = $this->change->updateChangeStatus($cid);                if($result){                    echo json_encode(array('status' => 'TRUE', 'msg' => '删除成功'), JSON_UNESCAPED_UNICODE);                    die();                }            }        }        echo json_encode(array('status' => 'FALSE', 'msg' => '参数有误'), JSON_UNESCAPED_UNICODE);        die();    }}?>
 |