<?php
Doo::loadClass('auth');
Doo::loadClass('attfile');
Doo::loadClass('profile');
Doo::loadClass('project');
Doo::loadClass('contractact');
Doo::loadClass('actmeasure');
Doo::loadClass('numofperact');
Doo::loadClass('measureauditact');
Doo::loadClass('itemmeasurenum');
Doo::loadClass('itemfile');
Doo::loadClass('attachment');
Doo::loadHelper('DooPager');
Doo::loadClass('sign');
Doo::loadModelAt('aconfig', 'admin');

/* * proDetail
 * MainController
 * Feel free to delete the methods and replace them with your own code.
 *
 * @author darkredz
 */

class ProjectController extends DooController
{

    private $data, $sign, $auth, $attfile, $profile, $project, $contractact, $actmeasure, $measureauditact, $numofperact, $statusArray = array('uncheck' => '<span class = "colGray">未审批</span>', 'checking' => '<span class = "colOrange">审批中</span>', 'checked' => '<span class = "colGreen">审批通过</span>', 'checkno' => '<span class = "colRed">审批不通过</span>'), $aconfig, $itemmeasurenum, $itemfle, $att;

    public function beforeRun($resource, $action)
    {
        if ($this->auth->getUid()) {
            $uGroups = $this->profile->getProWithUid($this->auth->getUid());
            $falg = Doo::acl()->isAllowed($uGroups['groups'], $resource, $action);
            if (!$falg)
                return Doo::acl()->defaultFailedRoute;
        } else {
            return Doo::acl()->defaultFailedRoute;
        }
    }

    public function __construct()
    {
        $this->auth = new Auth();
        $this->attfile = new attFile();
        $this->profile = new Profile();
        $this->project = new Project();
        $this->contractact = new Contractact();
        $this->actmeasure = new actMeasure();
        $this->numofperact = new NumofperAct();
        $this->measureauditact = new MeasureauditAct();
        $this->itemmeasurenum = new ItemMeasureNumpofper();
        $this->aconfig = new AConfig();
        $this->itemfle = new ItemFile();
        $this->att = new attachment();
        $this->sign = new Signn();
        $this->data['rootUrl'] = Doo::conf()->APP_URL;
        $this->data['currChannle'] = 'p';
        $this->data['user'] = $this->profile->getProWithUid($this->auth->getUid());
        $mpidArray = $this->measureauditact->getAuditProject2($this->auth->getUid());
        if (isset($mpidArray[0]['pid'])) {
            $this->data['numofchecking'] = 0;
            foreach ($mpidArray as $key => $value) {
                // 审批操作按照时间排序多标段
                $this->data['numofchecking'] += $this->measureauditact->getCountMyChecking($value['pid'], $this->auth->getUid());
            }
        }
        if (!isset($this->data['numofchecking']) || $this->data['numofchecking'] == 0) {
            $this->data['numofchecking'] = null;
        }

        $this->data['signSwitch'] = $this->aconfig->getOne(array('select' => 'signswitch', 'asArray' => TRUE))['signswitch'];

        //获取需要您签署的数目
        if($this->data['signSwitch'] > 0)
            $this->data['needSignNum'] = $this->sign->getNeedSignNumbyUid($this->auth->getUid()) != 0 ? $this->sign->getNeedSignNumbyUid($this->auth->getUid()) : '';

        //获取桌面版本
        $this->getsoftware();

        //草图入口
        $this->data['imediateSwitch'] = $this->aconfig->getOne(array('select' => 'imediateswitch', 'asArray' => TRUE))['imediateswitch'];
    }

    function getsoftware(){
        $StrJson = ($this->aconfig->getOne(array('select' => 'upgradeinfo', 'asArray' => TRUE))['upgradeinfo']);
        $upgradeinfo = json_decode($StrJson, true);
        if ($upgradeinfo) {
            $this->data['version'] = $upgradeinfo['version'];
            $this->data['download'] = $upgradeinfo['download'];
        }
    }

    /**
     *
     * @return type
     */
    public function index()
    {
        if (isset($_POST['pname']) && $_POST['pname']) {
            $this->project->insertProject($this->auth->getUid(), $_POST['pname']);
            return Doo::conf()->APP_URL . 'project/index';
        }
        if (isset($_POST['target_pname']) && $_POST['target_pname'] && isset($_POST['ppid']) && $_POST['ppid']) {
            $this->project->updateProName($_POST['ppid'], $_POST['target_pname']);
            return Doo::conf()->APP_URL . 'project/index';
        }
        $this->data['pros'] = $this->project->getAll($this->auth->getUid());
        if (isset($this->data['pros'][0]['pid'])) {
            foreach ($this->data['pros'] as $key => $value) {
                $this->data['pros'][$key]['index'] = $key%8+1;
                $this->data['pros'][$key]['numMeasure'] = $this->actmeasure->getMearsureCount($value['pid']);
                $this->data['pros'][$key]['contracttotal'] = $this->actmeasure->getTotalWithPid($value['pid']);
                $this->data['pros'][$key]['changTotal'] = $this->numofperact->getChangTotal($value['pid']);
//		$this->data['pros'][$key]['contracttotal'] += $this->data['pros'][$key]['changTotal'];
                $this->data['pros'][$key]['currdone'] = $this->numofperact->getCurrDoneNow($value['pid']);
                if ($this->data['pros'][$key]['contracttotal']) {
                    $this->data['pros'][$key]['pcurrdone'] = round(($this->data['pros'][$key]['currdone'] / $this->data['pros'][$key]['contracttotal']) * 100) . '%';
                } else {
                    $this->data['pros'][$key]['pcurrdone'] = '0%';
                }
                $this->data['pros'][$key]['bcontracttotal'] = number_format($this->data['pros'][$key]['contracttotal'], 2, '.', ',');
                $this->data['pros'][$key]['bchangTotal'] = number_format($this->data['pros'][$key]['changTotal'], 2, '.', ',');
            }
        } else {
            $this->data['pros'] = [];
        }
        $this->render('w-project', $this->data, TRUE);
    }

    public function proOverview()
    {
        $conArray = $this->contractact->getRowByPid($this->params['pid']);
        $this->data['projectDate'] = '';
        $this->data['conArray'][] = array();
        $this->getFav();
//	$this->data['measureArray'] = $this->actmeasure->getRowByPids($this->params['pid']);
//	foreach ($this->data['measureArray'] as $key => $value) {
//	    $this->data['measureArray'][$key]['stopNow'] = $this->numofperact->getStopNow($value['pmid'])['sntotal'];
//	    $this->data['measureArray'][$key]['pstopnow'] = round(($this->data['measureArray'][$key]['stopNow'] / $value['contracttotal']) * 100);
//	}
        $this->data['pid'] = $this->params['pid'];
        $this->data['conArray'] = $conArray;

        $contracttotal = 0;
        // 不同标段和值
//	$list = $this->numofperact->getStopNowStMonth($v['stid']); //print_r($list);
//	if (empty($list))
//	    $startMonth = date("Y-m");
//	else
//	    $startMonth = $list[0]['month'];
//	//$list=Array ( 0 => Array ( 'sntotal' => 20000 ,'month' => '2014-09' ),1 => Array ( 'sntotal' => 40000, 'month' => '2016-10' ) );
//	$d = 0;
//	$mDList = $mList = array();
//	$toMD = date("Y-m");
//	foreach ($list as $value) {
//	    $flag = true;
//	    do {
//		$MD = date("Y-m", strtotime($startMonth . " " . $d . " month")); //echo $MD."/".$value['month']."<br/>";
//		array_push($mDList, "'" . $MD . "'");
//		array_push($mList, $MD);
//
//		if ($MD == $toMD)//if(strtotime($MD)>=strtotime($toMD))
//		    $flag = false;
//		if ($d > 0 && ($MD == $value['month'] || $toMD == $value['month']))
//		    $flag = false;
//		$d++;
////		  		if ($d==10)
////		  			$flag=false;
//	    } while ($flag);
//	}
//	$this->data['projectDate'] = implode(',', $mDList);
//
//	$dataList = array();
//	$sntotalTA = 0;
//	foreach ($mList as $va) {
//	    $falg = true;
//	    foreach ($list as $value) {
//		if ($va == $value['month']) {
//		    $sntotalTA+=$value['sntotal'];
//		    $PER = round($sntotalTA / $contracttotal, 3) * 100;
//		    array_push($dataList, $PER);
//		    $falg = false;
//		    break;
//		}
//	    }
//	    if ($falg)
//		array_push($dataList, 0);
//	}
//	$this->data['conArray'][$k]['monthStopnow'] = $dataList;
//
//	$list = $this->numofperact->getCurrDoneSMontht($v['stid']);
//	$dataList = array();
//	$currdoneTA = 0;
//	foreach ($mList as $va) {
//	    $falg = true;
//	    foreach ($list as $value) {
//		if ($va == $value['month']) {
//		    $currdoneTA+=$value['currdone'];
//		    $PER = round($currdoneTA / $contracttotal, 3) * 100;
//		    array_push($dataList, $PER);
//		    $falg = false;
//		    break;
//		}
//	    }
//	    if ($falg)
//		array_push($dataList, 0);
//	}
//	$this->data['conArray'][$k]['monthCurrdone'] = $dataList;
//
        $totalstid = 0;
        $monthArray = [];
        foreach ($this->data['conArray'] as $k => $v) {
            $this->data['conArray'][$k]['pstopnow'] = $this->data['conArray'][$k]['pscurrdone'] = 0;
            $retval = $this->actmeasure->getAllbyStidSum($v['stid']);
            $contracttotal += $retval[0]['contracttotal'];
            $totalstid += $this->actmeasure->getTotal($v['stid'])['total'];
            $total = $this->actmeasure->getTotal($v['stid'])['total'];
            if ($total) {
                $this->data['conArray'][$k]['total'] = round($total, 2);
            } else {
                $this->data['conArray'][$k]['total'] = 0;
            }
            $sntotal = $this->numofperact->getCountTotalSTID2($v['stid'])['totalplus'];
            if ($sntotal) {
                $this->data['conArray'][$k]['stopnow'] = round($sntotal, 2);
            } else {
                $this->data['conArray'][$k]['stopnow'] = 0;
            }
            $this->data['conArray'][$k]['currdone'] = $this->numofperact->getCurrDoneSt($v['stid'])['currdone'];
            if ($this->data['conArray'][$k]['total'] > 0) {
                $this->data['conArray'][$k]['pstopnow'] = round(($this->data['conArray'][$k]['stopnow'] / $this->data['conArray'][$k]['total']) * 100);
                $this->data['conArray'][$k]['pscurrdone'] = round(($this->data['conArray'][$k]['currdone'] / $this->data['conArray'][$k]['total']) * 100);
            }
            // 分组出年月 每个月份的独立相加  累计完成总量
            $month = $this->numofperact->getCurrTotalStMonthNoCheckno($v['stid']);
            foreach ($month as $key => $value) {
                $allmonth[] = $value;
                if (!in_array($value['month'], $monthArray))
                    $monthArray[] = $value['month'];
            }

            // 分组出年月 每个月份的独立相加   本月完成总量
            $month1 = $this->numofperact->getCurrDoneStMonthNoCheckno($v['stid']);
            foreach ($month1 as $key => $value) {
                $allmonth1[] = $value;
            }
        }
        // 中文表述年月
        $total = $total1 = array();
        $startyear = $cnymArray = array();
        foreach ($monthArray as $kk => $vv) {
            $ymarray = explode('-', $vv);
            if (!in_array($ymarray[0], $startyear))
                $startyear[] = $ymarray[0];
//            $cnym = '\'' . $ymarray[1] . '月' . '\'';
//            if ($kk == 0)
//                $cnym = '\'' . $ymarray[0] . '年' . $ymarray[1] . '月' . '\'';
//            $cnymArray[] = $cnym;
        }
        $thismonth = 0;
        foreach($startyear as $sk => $sv){
            for($i = 1; $i <= 12; $i++){
                $j = $i < 10 ? '0'.$i : $i;
                $month = $sv.'-'.$j;
                $thismonth1 = 0;
                foreach ($allmonth1 as $k1 => $v1) {
                    if ($v1['month'] == $month)
                        $thismonth1 += $v1['currdone'];
                }
                $total1[] = $thismonth1 != 0 ? $thismonth1 : 0;
                foreach ($allmonth as $keyk => $valuev) {
                    if ($valuev['month'] == $month)
                        $thismonth += $valuev['currtotal'];
                }
                $total[] = ($thismonth != 0 && $thismonth1 != 0) ? $thismonth : 0;
                $cnymArray[] = $i == 1 ? '\'' .$sv.'年'.$i.'月'. '\'' : '\'' .$i.'月'. '\'';
            }
        }
        foreach ($total as $value2) {
            $total3[] = round(($value2 / $totalstid) * 100);
        }
        foreach ($total1 as $value11) {
            $total4[] = round(($value11 / $totalstid) * 100);
        }
        $this->data['projectDate'] = implode(',', $cnymArray);
        $this->data['t1'] = implode(',', $total3);
        $this->data['t2'] = implode(',', $total4);
        $this->render('w-project-detail', $this->data, TRUE);
    }

    public function proSection()
    {
        if (isset($_POST['stid']) && isset($_POST['proname'])) {
            $this->contractact->updateStName($_POST['stid'], $_POST['proname']);
            return Doo::conf()->APP_URL . 'project/' . $this->params['pid'] . '/section';
        }
        $this->getFav();
        $contractArray = $this->contractact->getRowByPid($this->params['pid']); // 获取合同段
        $htmlstr = NULL;
        foreach ($contractArray as $k => $v) {// 获取所有合同段
            $retval = $this->actmeasure->getAllbyStid($v['stid']); // 获取标段
            $bdhtmlstr = NULL;
            $bdhtmlstr = '<thead>
				    <tr><th class="taC taCble header"  width="225">标段名</th><th class="taC" width="140">计量期数</th><th width="115" class="taC">总价</th><th class="taC" width="">截止上期完成/本期完成/未完成</th></tr></thead>
				<tbody>';
            $biaoduantotalmoney = 0;
            $currTotal = 0;
            $progress = $otherprogress = '0%';
            $currTotal = $this->numofperact->getCountTotalSTID2($v['stid']);
            foreach ($retval as $key => $value) {
                $displayPercentSnTotalProgress = '0%';
                $displayPercentCurrTotalProgress = '0%';
                $displayPercentLessTotalProgress = '0%';
                $snTotalProgress = $currTotalProgress = $lessTotalProgress = '0%';
                $nTotalProgress = $ncurrTotalProgress = $nlessTotalProgress = number_format(0, 2, '.', ',');
                $numCount = $this->numofperact->getCountTotalnum2($value['pmid']); // 获取标段已有期数
                if (isset($numCount['numpname'])) {
                    $lastStatusArray = $this->numofperact->getMaxStatusTimes($value['pmid'], $numCount['numpname']);
                } else {
                    $lastStatusArray['currstatus'] = 'uncheck';
                    $numCount['numpname'] = 0;
                }
                $totalplus = $this->numofperact->getCountTotalplus($value['pmid']);
                $snTotal = $this->numofperact->getStopNowTotal($value['pmid']); //根据标段ID获取最新一期（包括不通过）
                $currcomTotal = $this->numofperact->getCurrdoneNew($value['pmid']); //截止目前
                $numStatusArray = $this->numofperact->getLastStatus2($this->params['pid'], $value['pmid']);
                if ($numCount > 0) {
                    $nTotalProgress = number_format($snTotal['sntotal'], 2, '.', ',');
                    $ncurrTotalProgress = number_format($currcomTotal['currtotal'], 2, '.', ',');
                    $nlessTotalProgress = number_format($value['contracttotal'] - $snTotal['sntotal'] - $currcomTotal['currtotal'], 2, '.', ',');
                    if (isset($value['contracttotal']) && ($value['contracttotal'] > 0)) {
                        $snTotalProgress = round(($snTotal['sntotal'] / $value['contracttotal']) * 100);
                        $currTotalProgress = round(($currcomTotal['currtotal'] / $value['contracttotal']) * 100);
//			$lessTotalProgress = round((($value['contracttotal'] - ($currcomTotal['currtotal'] + $snTotal['sntotal'])) / $value['contracttotal']) * 100);
                        $lessTotalProgress = 100 - $snTotalProgress - $currTotalProgress;
                        $displayPercentSnTotalProgress = $snTotalProgress . '%';
                        $displayPercentCurrTotalProgress = $currTotalProgress . '%';
                        $displayPercentLessTotalProgress = $lessTotalProgress . '%';
                    }
                }
                $biaoduantotalmoney += $value['contracttotal'];
                $totalmoney = number_format($value['contracttotal'], 2, '.', ',');
                if (isset($numStatusArray['currstatus'])) {
                    $statusStr = '（' . $this->statusArray[$lastStatusArray['currstatus']] . '）';
                } else {
                    $statusStr = '';
                }
                $bdhtmlstr .= '
				<tr>
					<td><a href="/project/' . $this->params['pid'] . '/section/' . $value['pmid'] . '/detail">' . $value['pmname'] . '</a></td>
					<td class="">第 ' . $numCount['numpname'] . ' 期' . $statusStr . '</td>
					<td class="taR">￥' . $totalmoney . '</td>
					<td>
					    <div class="progress">
						<div class="progress-bar progress-bar-success" style="width: ' . $displayPercentSnTotalProgress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="截止上期完成：￥' . $nTotalProgress . '">' . $displayPercentSnTotalProgress . '</div>
						<div class="progress-bar" style="width:' . $displayPercentCurrTotalProgress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="本期完成：￥' . $ncurrTotalProgress . '">' . $displayPercentCurrTotalProgress . '</div>
						<div class="progress-bar progress-bar-gary" style="width:' . $displayPercentLessTotalProgress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="未完成：￥' . $nlessTotalProgress . '">' . $displayPercentLessTotalProgress . '</div>
					    </div>
					</td>
				    </tr>';
            }
            $nprogress = $notherprogress = NULL;
//	    $currTotal = $this->numofperact->getCurrdoneSTID($v['stid']);
            if ($biaoduantotalmoney > 0) {
                $nprogress = number_format($currTotal['totalplus'], 2, '.', ',');
                $notherprogress = number_format($biaoduantotalmoney - $currTotal['totalplus'], 2, '.', ',');
                $progress = round(($currTotal['totalplus'] / $biaoduantotalmoney) * 100) . '%'; // 累计完成计量 所有标段合计
                $otherprogress = round((($biaoduantotalmoney - $currTotal['totalplus']) / $biaoduantotalmoney) * 100) . '%';
                $biaoduantotalmoney = number_format($biaoduantotalmoney, 2, '.', ',');
            }
            $htmlstr .= '<div class="project">
			<div class="proSection">
			    <table class="table">
				<thead>
				    <tr>
					<td width="150"><span aria-hidden="true" data-icon="u"></span> ' . $v['stname'] . '<a id="idt_' . $v['stid'] . '" href="#secoption" data-toggle="modal" title="编辑/查看KEY" stid="' . $v['stid'] . '" proname="' . $v['stname'] . '" key="' . $v['stkey'] . '"><span data-icon="S" aria-hidden="true" class="closePanel" data-placement="bottom" data-toggle="tooltip" data-original-title="查看KEY" style="font-size:18px"></span></a></td>
					<td width="90">总价：</td><td width="165">￥<b style="font-size:16px">' . $biaoduantotalmoney . '</b></td>
					<td width="60">完成进度：</td><td><div class="progress">
						<div class="progress-bar progress-bar-success" style="width:' . $progress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="累计完成：￥' . $nprogress . '">' . $progress . '</div>
						<div class="progress-bar progress-bar-danger" style="width:' . $otherprogress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="未完成：￥' . $notherprogress . '">' . $otherprogress . '</div>
					    </div></td>
				    </tr>
				</thead>
			    </table>
			    <table class="table table-striped table-hover tablelist">
				' . $bdhtmlstr . '
				</tbody>
			    </table>
			</div>
		    </div>';
        }
        $this->data['htmlstr'] = $htmlstr;
        if (isset($_POST['secname']) && $_POST['secname']) {
            $this->contractact->insertContract($this->params['pid'], $this->auth->getUid(), $_POST['secname']);
            return Doo::conf()->APP_URL . 'project/' . $this->params['pid'] . '/section';
        }
        $this->data['pid'] = $this->params['pid'];
        $this->render('w-project-section', $this->data, TRUE);
    }

    function proSectionFiles()
    {
        if (isset($_POST['optype']) && ($_POST['optype'] == 'replace') && ($_POST['imnid'])) {
            $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
            if ($imnidArray['iaid'] > 0) {
                $fileArray = $this->upItemFile('file')[0];
                if (isset($fileArray['filepath'])) {
                    $itemArray = $this->itemfle->getItemFile($imnidArray['iaid']);
                    if (isset($itemArray)) {
                        if ($itemArray['oldiaid'] > 0) {
                            $oldiaid = $itemArray['oldiaid'];
                        } else {
                            $oldiaid = $imnidArray['iaid'];
                        }
                        $postArray = array('ownerid' => $this->auth->getUid(), 'pid' => $itemArray['pid'], 'pmid' => $itemArray['pmid'], 'filename' => $fileArray['filename'], 'filesize' => $fileArray['filesize'], 'fileext' => $fileArray['fileext'], 'filepath' => $fileArray['filepath'], 'oldiaid' => $oldiaid);
                        $iaid = $this->itemfle->insertItemFileRecord($postArray);
                        if ($iaid > 1) {
                            $this->itemmeasurenum->updateIAID($imnidArray['iaid'], $iaid);
                            echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
                            die();
                        }
                    }
                }
            }
        }
        if (isset($_POST['optype']) && ($_POST['optype'] == 'del') && isset($_POST['imnid'])) {
            $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
            if ($imnidArray['iaid'] > 0) {
                $this->itemmeasurenum->updateDeltag($_POST['imnid'], $this->auth->getUid());
                echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
                die();
            }
        }
        if (isset($_POST['filename']) && isset($_POST['filedesc']) && isset($_POST['upimnid'])) {
            $filename = $_POST['filename'];
            $filedesc = $_POST['filedesc'];
            $imnidArray = $this->itemmeasurenum->getRowData($_POST['upimnid']);
            if ($imnidArray['iaid'] > 0) {
                if (isset($filedesc))
                    $this->itemmeasurenum->updateItemFields($_POST['upimnid'], $filedesc, 0);
                if (isset($filename))
                    $this->itemfle->updateItemFields($imnidArray['iaid'], $filename, 0);
                echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
                die();
            }
        }

        // 面包屑导航项目
//        $this->data['currproArray'] = $this->data['allproArray'] = NULL;
//        $this->data['pmid'] = $this->params['pmid'];
//        $allproArray = $this->project->getAll();
//        foreach ($allproArray as $kk => $vv) {
//            if ($vv['pid'] == $this->params['pid']) {
//                $this->data['currproArray'] = $vv;
//            } else {
//                $this->data['allproArray'][] = $vv;
//            }
//        }
        $this->getFav();
// 面包屑导航合同
        $conArray = $this->contractact->getAll();
        $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
        if (isset($measureArray['stid'])) {
            foreach ($conArray as $kkk => $vvv) {
                if ($vvv['stid'] == $measureArray['stid']) {
                    $this->data['currconArray'] = $vvv;
                } else {
                    if ($vvv['pid'] == $this->params['pid'])
                        $this->data['allconArray'][] = $vvv;
                }
            }
        } else {
            $this->data['currconArray'] = $this->data['allconArray'] = NULL;
        }
// 面包屑导航标段
        $this->data['curractmeasureArray'] = NULL;
        $this->data['allactmeasureArray'] = [];
        $actmeasureArray = $this->actmeasure->getAll();
        foreach ($actmeasureArray as $kkkk => $vvvv) {
            if ($vvvv['stid'] == $measureArray['stid']) {
                if (($vvvv['pmid'] == $this->params['pmid'])) {
                    $this->data['curractmeasureArray'] = $vvvv;
                } else {
                    $this->data['allactmeasureArray'][] = $vvvv;
                }
            }
        }
        // 选取查询
        $groupArray = $this->numofperact->getGroupByLastOne2($this->params['pmid']);
        $this->data['groupArray'] = $groupArray;
        $owneridArray = $this->itemfle->getGroupOwnerid($this->params['pmid']);
        foreach ($owneridArray as $k => $v) {
            $this->data['owneridArray'][$k]['name'] = $this->profile->getProWithUid($v['ownerid'])['name'];
            $this->data['owneridArray'][$k]['iaid'] = $v['iaid'];
            $this->data['owneridArray'][$k]['ownerid'] = $v['ownerid'];
        }

// 分页
        $totalArchive = $this->itemmeasurenum->getCount($this->params['pmid'], 0, $this->params['numpname'], $this->params['userid']);
        if ($totalArchive) {
            if ($this->params['numpname'] && $this->params['userid']) {
                $pager = new DooPager(Doo::conf()->APP_URL . 'project/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/num/' . $this->params['numpname'] . '/user/' . $this->params['userid'] . '/page', $totalArchive, 20, 100);
            } elseif ($this->params['numpname']) {
                $pager = new DooPager(Doo::conf()->APP_URL . 'project/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/num/' . $this->params['numpname'] . '/page', $totalArchive, 20, 100);
            } elseif ($this->params['userid']) {
                $pager = new DooPager(Doo::conf()->APP_URL . 'project/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/user/' . $this->params['userid'] . '/page', $totalArchive, 20, 100);
            } else {
                $pager = new DooPager(Doo::conf()->APP_URL . 'project/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/page', $totalArchive, 20, 100);
            }
            $pager->setCss('', 'disabled', 'active');
            if (isset($this->params['pindex']))
                $pager->paginate(intval($this->params['pindex']));
            else
                $pager->paginate(1);
            $this->data['itemMeasureArray'] = $this->itemmeasurenum->getItemMeasureNum($this->params['pmid'], $pager->limit, $this->params['numpname'], $this->params['userid']);
        }

        foreach ($this->data['itemMeasureArray'] as $k => $v) {
            $fileArray = $this->itemfle->getItemFile($v['iaid']);
            $this->data['itemMeasureArray'][$k]['realname'] = $this->profile->getProWithUid($v['ownerid'])['name'];
            $this->data['itemMeasureArray'][$k]['pmname'] = $this->actmeasure->getRowByPmid($v['pmid'])['pmname'];
            $this->data['itemMeasureArray'][$k]['filename'] = $fileArray['filename'];
            $this->data['itemMeasureArray'][$k]['fileext'] = $fileArray['fileext'];
            $this->data['itemMeasureArray'][$k]['tips'] = $v['tips'];
        }
        $this->data['pid'] = $this->params['pid'];
        $this->data['pmid'] = $this->params['pmid'];
        $this->data['mpid'] = $this->params['mpid'];
        $this->data['userid'] = $this->params['userid'];
        $this->data['num'] = $this->params['numpname'];
        $this->data['pager'] = $pager->output;
        $this->render('w-project-section-files', $this->data, TRUE);
    }

    function proSectionFilesRecover()
    {
        if (isset($_POST['optype']) && ($_POST['optype'] == 'reconvery') && isset($_POST['imnid'])) {
            $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
            if ($imnidArray['iaid'] > 0) {
                $this->itemmeasurenum->recoveryDel($_POST['imnid']);
                echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
                die();
            }
        }

        if (isset($_POST['optype']) && ($_POST['optype'] == 'del') && isset($_POST['imnid'])) {
            $imnidArray = $this->itemmeasurenum->getRowData($_POST['imnid']);
            if ($imnidArray['iaid'] > 0) {
                $iaidArray = $this->itemfle->getItemFile($imnidArray['iaid']);
                if ($iaidArray['ownerid'] == $this->auth->getUid()) {
                    $this->itemfle->delItem($imnidArray['iaid']);
                    $this->itemmeasurenum->delItemIAID($imnidArray['iaid']);
                    echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
                    die();
                } else {
                    echo json_encode(array('status' => 2), JSON_UNESCAPED_UNICODE);
                    die();
                }
            }
        }

        // 面包屑导航项目
//        $this->data['currproArray'] = $this->data['allproArray'] = NULL;
//        $this->data['pmid'] = $this->params['pmid'];
//        $allproArray = $this->project->getAll();
//        foreach ($allproArray as $kk => $vv) {
//            if ($vv['pid'] == $this->params['pid']) {
//                $this->data['currproArray'] = $vv;
//            } else {
//                $this->data['allproArray'][] = $vv;
//            }
//        }
        $this->getFav();
// 面包屑导航合同
        $conArray = $this->contractact->getAll();
        $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
        if (isset($measureArray['stid'])) {
            foreach ($conArray as $kkk => $vvv) {
                if ($vvv['stid'] == $measureArray['stid']) {
                    $this->data['currconArray'] = $vvv;
                } else {
                    if ($vvv['pid'] == $this->params['pid'])
                        $this->data['allconArray'][] = $vvv;
                }
            }
        } else {
            $this->data['currconArray'] = $this->data['allconArray'] = NULL;
        }
// 面包屑导航标段
        $this->data['curractmeasureArray'] = NULL;
        $this->data['allactmeasureArray'] = [];
        $actmeasureArray = $this->actmeasure->getAll();
        foreach ($actmeasureArray as $kkkk => $vvvv) {
            if ($vvvv['stid'] == $measureArray['stid']) {
                if (($vvvv['pmid'] == $this->params['pmid'])) {
                    $this->data['curractmeasureArray'] = $vvvv;
                } else {
                    $this->data['allactmeasureArray'][] = $vvvv;
                }
            }
        }

        $totalArchive = $this->itemmeasurenum->getCount($this->params['pmid']);
        if ($totalArchive) {
            $pager = new DooPager(Doo::conf()->APP_URL . 'project/' . $this->params['pmid'] . '/section/' . $this->params['pmid'] . '/files/recover/page', $totalArchive, 20, 100);
            $pager->setCss('', 'disabled', 'active');
            if (isset($this->params['pindex']))
                $pager->paginate(intval($this->params['pindex']));
            else
                $pager->paginate(1);
            $this->data['itemMeasureArray'] = $this->itemmeasurenum->getItemMeasureNumDel($pager->limit, $this->params['pmid']);
        }


        foreach ($this->data['itemMeasureArray'] as $k => $v) {
            $fileArray = $this->itemfle->getItemFile($v['iaid']);
            $this->data['itemMeasureArray'][$k]['realname'] = $this->profile->getProWithUid($v['ownerid'])['name'];
            $this->data['itemMeasureArray'][$k]['delname'] = $this->profile->getProWithUid($v['deluid'])['name'];
            $this->data['itemMeasureArray'][$k]['pmname'] = $this->actmeasure->getRowByPmid($v['pmid'])['pmname'];
            $this->data['itemMeasureArray'][$k]['filename'] = $fileArray['filename'];
            $this->data['itemMeasureArray'][$k]['fileext'] = $fileArray['fileext'];
            $this->data['itemMeasureArray'][$k]['tips'] = $v['tips'];
            $this->data['itemMeasureArray'][$k]['filepath'] = $fileArray['filepath'];
        }
        $this->data['pid'] = $this->params['pid'];
        $this->data['pmid'] = $this->params['pmid'];
        $this->data['mpid'] = $this->params['mpid'];
        $this->data['pager'] = $pager->output;
        $this->render('w-project-section-files-recover', $this->data, TRUE);
    }

    /**
     * @return actMeasure
     */
    public function proSectionGetFiles()
    {
        $attaArray = $this->itemfle->getItemFile($this->params['iaid']);
        $this->file_down($attaArray['filepath'], $attaArray['filesize'], $attaArray['filename'] . '.' . $attaArray['fileext']);
        return;
    }

    function getItemFileHistory()
    {
        if ($this->params['iaid']) {
            $iaidArray = $this->itemfle->getItemFile($this->params['iaid']);
            if ($iaidArray['oldiaid'] > 0) {
                $oldiaidArray = $this->itemfle->getFileHistory($iaidArray['oldiaid']);
                $htmlstr = '';
                foreach ($oldiaidArray as $k => $v) {
                    $countInt = $k + 1;
                    $formatDate = date('Y-m-d H:i:s', $v['intime']);
                    $profileArray = $this->profile->getProWithUid($v['ownerid']);
                    $htmlstr .= '<div class="media"><div class="pull-left"><h4>#' . $countInt . '</h4></div><div class="media-body"><h5>' . $profileArray['name'] . '&nbsp;上传于 ' . $formatDate . '</h5><a href="/' . $v['filepath'] . '" target="_blank">' . $v['filename'] . '</a></div></div>';
                }
                echo json_encode(array('html' => $htmlstr), JSON_UNESCAPED_UNICODE);
                die();
            }
        }
    }

    Function fNumber($number)
    {
        if ($number == '')
            Return "-";
        $nlen = strlen($number);
        while ($nlen > 3) {
            $fNumber = "," . substr($number, $nlen - 3, 3);
            $number = substr($number, 0, -3);
            $nlen = strlen($number);
        }

        if ($nlen <= 3) {
            $fNumber = $number . $fNumber;
        }
        Return $fNumber;
    }

    private function getFav()
    {
        $proArray = $this->project->getAll($this->auth->getUid());
        $this->data['othrPro'] = [];
        foreach ($proArray as $key => $value) {
            if ($value['pid'] == $this->params['pid']) {
                $this->data['currProName'] = $value['pname'];
                $this->data['currProID'] = $value['pid'];
            } else {
                $this->data['othrPro'][] = $proArray[$key];
            }
        }
    }

    public function proSectionMeasure()
    {
//此处未做更改，JSON文件已经固定名称
        $jsonpath = pathinfo($this->attfile->getMaxRow()['filepath']);
        if (isset($jsonpath['dirname'])) {
            $extPathdir = Doo::conf()->SITE_PATH . $jsonpath['dirname'] . '/' . $jsonpath['filename'];
            if ($handle = opendir($extPathdir)) {
                while (false !== ($file = readdir($handle))) {
                    $filename = NULL;
                    $filename = pathinfo($file);
                    if ($filename['extension'] == 'json')
                        $proArray = json_decode(file_get_contents($extPathdir . '/' . $file), TRUE, JSON_UNESCAPED_UNICODE);
                }
                closedir($handle);
            }
            $this->data['proArray'] = $proArray['Bills'];
        } else {
            $this->data['proArray'] = [];
        }
        $this->data['mpid'] = $this->params['mpid'];
        $this->data['pid'] = $this->params['pid'];
        $this->render('w-project-section-measure', $this->data, TRUE);
    }

    public function substr_replace_cn($string, $repalce = '*', $start = 0, $len = 0)
    {
        $count = mb_strlen($string, 'UTF-8'); //此处传入编码，建议使用utf-8。此处编码要与下面mb_substr()所使用的一致
        if (!$count) {
            return $string;
        }
        if ($len == 0) {
            $end = $count;  //传入0则替换到最后
        } else {
            $end = $start + $len;       //传入指定长度则为开始长度+指定长度
        }
        $i = 0;
        $returnString = '';
        while ($i < $count) { //循环该字符串
            $tmpString = mb_substr($string, $i, 1, 'UTF-8'); // 与mb_strlen编码一致
            if ($start <= $i && $i < $end) {
                $returnString .= $repalce;
            } else {
                $returnString .= $tmpString;
            }
            $i++;
        }
        return $returnString;
    }

    function unicode_encode($name)
    {//to Unicode
        $name = iconv('UTF-8', 'UCS-2', $name);
        $len = strlen($name);
        $str = '';
        for ($i = 0; $i < $len - 1; $i = $i + 2) {
            $c = $name[$i];
            $c2 = $name[$i + 1];
            if (ord($c) > 0) {// 两个字节的字
                $str .= '\\' . base_convert(ord($c), 10, 16) . base_convert(ord($c2), 10, 16);
            } else {
                $str .= $c2;
            }
        }
        $str = strtoupper($str);
        return $str;
    }

    function unicode_decode($name)
    {//Unicode to
        $pattern = '/([\w]+)|(\\\u([\w]{4}))/i';
        preg_match_all($pattern, $name, $matches);
        if (!empty($matches)) {
            $name = '';
            for ($j = 0; $j < count($matches[0]); $j++) {
                $str = $matches[0][$j];
                if (strpos($str, '\\u') === 0) {
                    $code = base_convert(substr($str, 2, 2), 16, 10);
                    $code2 = base_convert(substr($str, 4), 16, 10);
                    $c = chr($code) . chr($code2);
                    $c = iconv('UCS-2', 'UTF-8', $c);
                    $name .= $c;
                } else {
                    $name .= $str;
                }
            }
        }
        return $name;
    }

    public function proDetail()
    {
        // 面包屑导航项目
//        $this->data['currproArray'] = $this->data['allproArray'] = NULL;
//        $this->data['pmid'] = $this->params['pmid'];
//        $allproArray = $this->project->getAll();
//        foreach ($allproArray as $kk => $vv) {
//            if ($vv['pid'] == $this->params['pid']) {
//                $this->data['currproArray'] = $vv;
//            } else {
//                $this->data['allproArray'][] = $vv;
//            }
//        }
        $this->getFav();
        // 面包屑导航合同
        $conArray = $this->contractact->getAll();
        $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
        if (isset($measureArray['stid'])) {
            foreach ($conArray as $kkk => $vvv) {
                if ($vvv['stid'] == $measureArray['stid']) {
                    $this->data['currconArray'] = $vvv;
                } else {
                    if ($vvv['pid'] == $this->params['pid'])
                        $this->data['allconArray'][] = $vvv;
                }
            }
        } else {
            $this->data['currconArray'] = $this->data['allconArray'] = NULL;
        }
        // 面包屑导航标段
        $this->data['curractmeasureArray'] = NULL;
        $this->data['allactmeasureArray'] = [];
        $actmeasureArray = $this->actmeasure->getAll();
        foreach ($actmeasureArray as $kkkk => $vvvv) {
            if ($vvvv['stid'] == $measureArray['stid']) {
                if (($vvvv['pmid'] == $this->params['pmid'])) {
                    $this->data['curractmeasureArray'] = $vvvv;
                } else {
                    $this->data['allactmeasureArray'][] = $vvvv;
                }
            }
        }
// 图表
        $this->data['MeasureArray'] = $this->numofperact->getGroupByLastOne($this->params['pmid']);
        $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
        foreach ($this->data['MeasureArray'] as $key => $value) {
            if ($measureArray['contracttotal'] > $value['currdone'] && $value['currdone'] > 0) {
                $this->data['MeasureArray'][$key]['lessTotal'] = round(($value['currdone'] / $measureArray['contracttotal']) * 100);
            } else {
                $this->data['MeasureArray'][$key]['lessTotal'] = 0;
            }
        }
        $this->data['pmid'] = $this->params['pmid'];
        $this->data['pid'] = $this->params['pid'];
        $this->render('w-project-section-detail', $this->data, TRUE);
    }

    public function welcome()
    {
//	if (!$this->auth->isLoggedIn())
//	    return Doo::conf()->APP_URL;
        if ($this->profile->getProWithUid($this->auth->getUid())['userid'])
            return Doo::conf()->APP_URL . 'project/list';
        if (isset($_POST['welform'])) {
            $profileUserArray = $_POST;
            $profileUserArray['userid'] = $this->auth->getUid();
            $this->profile->insertProfile($profileUserArray); // 无自增字段返回0
            return Doo::conf()->APP_URL . 'project/list';
        }
        $this->render('welcome', $this->data);
    }

// ajax提取密码名称
    public function getAjaxSection()
    {
        if (!$this->isAjax())
            return;
        echo json_encode($_POST);
    }

    function upItemFile($fildname, $param = 'doc, docx, xls, xlsx, png, zip')
    {
        $this->att->setUploadDir();
        return $this->att->uploadMut($fildname, $param);
    }

    /**
     * 文件下载
     * @param $filepath 文件路径
     * @param $filename 文件名称
     */
    function file_down($filepath, $filesize, $filename = '')
    {
        if (!$filename)
            $filename = basename($filepath);
        if ($this->is_ie())
            $filename = rawurlencode($filename);
        $filetype = $this->fileext($filename);
//        $filesize = sprintf("%u", filesize($filepath));
        if (ob_get_length() !== false)
            @ob_end_clean();
        header('Pragma: public');
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
        header('Cache-Control: no-store, no-cache, must-revalidate');
        header('Cache-Control: pre-check=0, post-check=0, max-age=0');
        header('Content-Transfer-Encoding: binary');
        header('Content-Encoding: none');
        header('Content-type: ' . $filetype);
        header('Content-Disposition: attachment; filename="' . $filename . '"');
        header('Content-length: ' . $filesize);
        @readfile($filepath);
        exit;
    }

    /**
     * IE浏览器判断
     */
    function is_ie()
    {
        $useragent = strtolower($_SERVER['HTTP_USER_AGENT']);
        if ((strpos($useragent, 'opera') !== false) || (strpos($useragent, 'konqueror') !== false))
            return false;
        if (strpos($useragent, 'msie ') !== false)
            return true;
        return false;
    }

    /**
     * 取得文件扩展
     *
     * @param $filename 文件名
     * @return 扩展名
     */
    function fileext($filename)
    {
        return strtolower(trim(substr(strrchr($filename, '.'), 1, 10)));
    }


    /*
     *
     * 中间计量表草图列表
     */
    public function proSectionInterMediate(){

        //草图功能开关控制
        if($this->data['imediateSwitch'] == 0){
            exit('中间计量表草图添加功能未启用...');
        }

        // 面包屑导航项目
        $this->getFav();
        // 面包屑导航合同
        $conArray = $this->contractact->getAll();
        $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
        if (isset($measureArray['stid'])) {
            foreach ($conArray as $kkk => $vvv) {
                if ($vvv['stid'] == $measureArray['stid']) {
                    $this->data['currconArray'] = $vvv;
                } else {
                    if ($vvv['pid'] == $this->params['pid'])
                        $this->data['allconArray'][] = $vvv;
                }
            }
        } else {
            $this->data['currconArray'] = $this->data['allconArray'] = NULL;
        }
        // 面包屑导航标段
        // 面包屑导航标段
        $this->data['curractmeasureArray'] = NULL;
        $this->data['allactmeasureArray'] = [];
        $actmeasureArray = $this->actmeasure->getAll();
        foreach ($actmeasureArray as $kkkk => $vvvv) {
            if ($vvvv['stid'] == $measureArray['stid']) {
                if (($vvvv['pmid'] == $this->params['pmid'])) {
                    $this->data['curractmeasureArray'] = $vvvv;
                } else {
                    $this->data['allactmeasureArray'][] = $vvvv;
                }
            }
        }

        Doo::loadHelper('DooPager');
        $pagestr = '';
        $sqlstr = ' 1';
//        $this->data['project'] = '';
//        $this->data['tender'] = '';
        $this->data['phaseno'] = '';
        $this->data['nosign'] = '';

        //获取项目信息
        $searchsql = 'isinter=3';
//        $itemlist = $this->sign->getSignGroupByProject($searchsql);
//        if(!empty($itemlist)){
//            foreach($itemlist as $ik => $iv){
//                $itemmsg = $this->project->getRowByPid($iv['project']);
//                $itemlist[$ik]['pname'] = $itemmsg['pname'];
//            }
//        }

        if(isset($this->params['pid']) && is_numeric($this->params['pid'])){
            $pagestr .= '/'.$this->params['pid'];
            $sqlstr .= ' and project='.$this->params['pid'];
            //获取标段信息
//            $tenderlist = $this->sign->getSignGroupByTender($this->params['pid'],$searchsql);
//            if(!empty($tenderlist)){
//                foreach($tenderlist as $tk => $tv){
//                    $tendermsg = $this->actmeasure->getRowByPmid($tv['tender']);
//                    $tenderlist[$tk]['pmname'] = $tendermsg['pmname'];
//                }
//            }

            if(isset($this->params['pmid']) && is_numeric($this->params['pmid'])){
                $pagestr .= '/section/'.$this->params['pmid'];
                $sqlstr .= ' and tender='.$this->params['pmid'];
                //获取期数信息
                $phasenolist = $this->sign->getSignGroupByPhaseno($this->params['pmid'],$searchsql);
                if(!empty($phasenolist)){
                    foreach($phasenolist as $pk => $pv){
                        $phasenolist[$pk]['numpname'] = $pv['phaseno'];
                    }
                }

                if(isset($this->params['mpid']) && is_numeric($this->params['mpid'])){
                    $this->data['phaseno'] = $this->params['mpid'];
                    $pagestr .= '/phaseno/'.$this->params['mpid'];
                    $sqlstr .= ' and phaseno='.$this->params['mpid'];
                }
            }
        }

        $totalArchive = $this->sign->getSignNum($sqlstr.' and '.$searchsql);
        $pager = new DooPager(Doo::conf()->APP_URL . 'project'.$pagestr.'/intermediate/page', $totalArchive, 10, 100);
        $pager->setCss('', 'disabled', 'active');
        if (isset($this->params['pindex']))
            $pager->paginate(intval($this->params['pindex']));
        else
            $pager->paginate(1);
        if ($pager->limit != ' -10,10')
            $list = $this->sign->getSignList($sqlstr.' and '.$searchsql,$pager->limit);
        if(isset($list) && !empty($list)){
            foreach($list as $k => $v){
                //获取项目名，标段名，标段期数
                $project = $this->project->getRowByPid($v['project']);
                $tender = $this->actmeasure->getRowByPmid($v['tender']);
//                $phaseno = $this->numofperact->getCurrStatus($v['phaseno']);

                $list[$k]['project'] = $project['pname'];
                $list[$k]['tender'] = $tender['pmname'];
//                $list[$k]['phaseno'] = $phaseno['numpname'];
                $list[$k]['ownname'] = $this->auth->getName($v['ownuid']);
                $list[$k]['auditname'] = $this->auth->getName($v['audituid']);
            }
        }

        $this->data['list'] = isset($list) ? $list : '';
//        $this->data['itemlist'] = $itemlist;
//        $this->data['tenderlist'] = isset($tenderlist) ? $tenderlist : '';
        $this->data['phasenolist'] = isset($phasenolist) ? $phasenolist : '';
        $this->data['pager'] = $pager->output;


        $this->data['pid'] = $this->params['pid'];
        $this->data['pmid'] = $this->params['pmid'];
        $this->render('w-project-section-intermediate', $this->data, TRUE);
    }


    /**
     *
     * 中间计量表视图
     */
    public function signView()
    {
        //草图功能开关控制
        if($this->data['imediateSwitch'] == 0){
            exit('中间计量表草图添加功能未启用...');die;
        }

        if(!isset($this->params['sid']) || !is_numeric($this->params['sid'])){
            exit('没有报表参数');
        }
        //获取报表信息
        $signmsg = $this->sign->getOneSignbysid($this->params['sid']);
        if(empty($signmsg) || $signmsg['isinter'] != 3){
            exit('不存在此中间计量表');
        }

        $backurl = '/project/'.$signmsg['project'].'/section/'.$signmsg['tender'].'/intermediate';
        //获取项目名，标段名，标段期数
        $project = $this->project->getRowByPid($signmsg['project']);
        $tender = $this->actmeasure->getRowByPmid($signmsg['tender']);
//        $phaseno = $this->numofperact->getCurrStatus($signmsg['phaseno']);

        $signmsg['project'] = $project['pname'];
        $signmsg['tender'] = $tender['pmname'];
//        $signmsg['phaseno'] = $phaseno['numpname'];

        //获取签署人列表
        $signauditlist = $this->sign->getSignAuditList($this->params['sid']);
        if(!empty($signauditlist)){
            foreach($signauditlist as $k => $v){
                //获取签署人头像
                $signauditlist[$k]['index'] = $k+1;
                $signauditlist[$k]['avatar'] = $this->auth->getAvatar($v['audituid']);
            }
        }

        //获取报表图片
        $maxwidth = 794; //默认图片最大宽度   a4
        $maxheight = 1123; //默认图片最大高度  a4
        if(!empty($signmsg['widhei'])){
            $widhei = explode('_', $signmsg['widhei']);
            $style = $widhei[0].'mm '.$widhei[1].'mm';
        }else{
            $style = '210mm 297mm';
        }
        $signattlist = $this->sign->getSignAttList($this->params['sid']);
        if(!empty($signattlist)){
            foreach($signattlist as $sak => $sav){
                $signattlist[$sak]['auditatt'] = $this->sign->getSignAuditAttList($sav['said']);
                if($sak == 0){
                    $imgmsg = getimagesize(Doo::conf()->APP_URL.$sav['filepath']);
                    $maxwidth = $imgmsg[0];
                    $maxheight = $imgmsg[1];
                }
            }
        }

        $this->data['signmsg'] = $signmsg;
        $this->data['auditlist'] = $signauditlist;
        $this->data['attlist'] = $signattlist;
        $this->data['backurl'] = $backurl;
        $this->data['maxwidth'] = $maxwidth;
        $this->data['maxheight'] = $maxheight;
        $this->data['style'] = $style;

        $this->render('sign-view-page', $this->data, TRUE);
    }


}

?>