UserController.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. <?php
  2. ini_set('display_errors', 1);
  3. Doo::loadClass('auth');
  4. Doo::loadClass('attfile');
  5. Doo::loadClass('profile');
  6. Doo::loadClass('project');
  7. Doo::loadClass('contractact');
  8. Doo::loadClass('actmeasure');
  9. Doo::loadClass('numofperact');
  10. Doo::loadClass('user');
  11. Doo::loadClass('PasswordHash');
  12. Doo::loadClass('sms');
  13. Doo::loadModelAt('aconfig', 'admin');
  14. Doo::loadClass('measureauditact');
  15. Doo::loadClass('sign');
  16. Doo::loadClass('phpqrcode');
  17. Doo::loadClass('Hashids/Hashids');
  18. Doo::loadClass('change');
  19. /* * proDetail
  20. * MainController
  21. * Feel free to delete the methods and replace them with your own code.
  22. *
  23. * @author darkredz
  24. */
  25. class UserController extends DooController
  26. {
  27. private $data, $sign, $auth, $attfile, $change, $profile, $project, $contractact, $actmeasure, $numofperact, $user, $ph, $sms, $aconfig, $__hashids;
  28. public function beforeRun($resource, $action)
  29. {
  30. // $uGroups = $this->profile->getProWithUid($this->auth->getUid());
  31. // $falg = Doo::acl()->isAllowed($uGroups['groups'], $resource, $action);
  32. // if (!$falg)
  33. // return Doo::acl()->defaultFailedRoute;
  34. if ($this->auth->getUid()) {
  35. $uGroups = $this->profile->getProWithUid($this->auth->getUid());
  36. $falg = Doo::acl()->isAllowed($uGroups['groups'], $resource, $action);
  37. if (!$falg)
  38. return Doo::acl()->defaultFailedRoute;
  39. } else {
  40. return Doo::acl()->defaultFailedRoute;
  41. }
  42. }
  43. public function __construct()
  44. {
  45. $this->data['numofchecking'] = null;
  46. $this->auth = new Auth();
  47. $this->attfile = new attFile();
  48. $this->profile = new Profile();
  49. $this->project = new Project();
  50. $this->contractact = new Contractact();
  51. $this->actmeasure = new actMeasure();
  52. $this->numofperact = new NumofperAct();
  53. $this->user = new User();
  54. $this->ph = new PasswordHash(8, FALSE);
  55. $this->sms = new Sms(Doo::conf()->SMS_URL, Doo::conf()->SMS_ACCOUNT, DOO::conf()->SMS_PASSWORD, DOO::conf()->SMS_EXTNO);
  56. $this->aconfig = new AConfig();
  57. $this->measureauditact = new MeasureauditAct();
  58. $this->sign = new signn();
  59. $this->change = new Changes();
  60. $this->__hashids = new Hashids\Hashids('jlzfuserid', 8);
  61. $this->data['rootUrl'] = Doo::conf()->APP_URL;
  62. $this->data['currChannle'] = '';
  63. $this->data['user'] = $this->profile->getProWithUid($this->auth->getUid());
  64. $mpidArray = $this->measureauditact->getAuditProject2($this->auth->getUid());
  65. if (isset($mpidArray[0]['pid'])) {
  66. foreach ($mpidArray as $key => $value) {
  67. // 审批操作按照时间排序多标段
  68. $this->data['numofchecking'] += $this->measureauditact->getCountMyChecking($value['pid'], $this->auth->getUid());
  69. }
  70. }
  71. if (!isset($this->data['numofchecking']) || $this->data['numofchecking'] == 0) {
  72. $this->data['numofchecking'] = null;
  73. }
  74. $this->data['signSwitch'] = $this->aconfig->getOne(array('select' => 'signswitch', 'asArray' => TRUE))['signswitch'];
  75. //获取需要您签署的数目
  76. if($this->data['signSwitch'] > 0)
  77. $this->data['needSignNum'] = $this->sign->getNeedSignNumbyUid($this->auth->getUid()) != 0 ? $this->sign->getNeedSignNumbyUid($this->auth->getUid()) : '';
  78. //获取需要你审批的变更令数目
  79. $this->data['needChangeNum'] = $this->change->getNeedChangeNumbyUid($this->auth->getUid()) != 0 ? $this->change->getNeedChangeNumbyUid($this->auth->getUid()) : '';
  80. //获取桌面版本
  81. $this->data['version'] = '';
  82. $this->getsoftware();
  83. }
  84. function getsoftware(){
  85. $StrJson = ($this->aconfig->getOne(array('select' => 'upgradeinfo', 'asArray' => TRUE))['upgradeinfo']);
  86. $upgradeinfo = json_decode($StrJson, true);
  87. if ($upgradeinfo) {
  88. $this->data['version'] = $upgradeinfo['version'];
  89. $this->data['download'] = $upgradeinfo['download'];
  90. }
  91. }
  92. /**
  93. *
  94. * @return type
  95. */
  96. public function index()
  97. {
  98. $this->data['uprofile'] = $this->profile->getProWithUid($this->auth->getUid());
  99. $this->data['uprofile']['email'] = $this->auth->getUemail();
  100. if (isset($_POST['name']) && isset($_POST['company']) && isset($_POST['jobs']) && isset($_POST['phone'])) {
  101. $this->profile->upProfile($this->auth->getUid(), $_POST);
  102. return DOO::conf()->APP_URL . 'user/profile';
  103. }
  104. $this->render('edit-profile', $this->data, TRUE);
  105. }
  106. public function avatar()
  107. {
  108. // TODO:加入目录可否写入判断
  109. if (count($_FILES) == 3) {
  110. $result = array();
  111. $result['success'] = false;
  112. $successNum = 0;
  113. $avatarNumber = 1;
  114. $i = 0;
  115. $msg = '';
  116. $dir = 'global/avatar';
  117. while (list($key, $val) = each($_FILES)) {
  118. if ($_FILES[$key]['error'] > 0) {
  119. $msg .= $_FILES[$key]['error'];
  120. } else {
  121. $fileName = date("YmdHis") . '_' . floor(microtime() * 1000) . '_' . self::createRandomCode(8);
  122. if ($key == '__source') {
  123. $initParams = $_POST["__initParams"];
  124. $virtualPath = "$dir/php_source_$fileName.jpg";
  125. $result['sourceUrl'] = '/' . $virtualPath . $initParams;
  126. move_uploaded_file($_FILES[$key]["tmp_name"], Doo::conf()->SITE_PATH . $virtualPath);
  127. $successNum++;
  128. } else if (strpos($key, '__avatar') === 0) {
  129. $virtualPath = "$dir/php_avatar" . $avatarNumber . "_$fileName.jpg";
  130. $result['avatarUrls'][$i] = $virtualPath;
  131. if ($i == 2) {
  132. $this->profile->setAvatar($this->auth->getUid(), $result['avatarUrls'][$i]);
  133. }
  134. move_uploaded_file($_FILES[$key]["tmp_name"], $virtualPath);
  135. $successNum++;
  136. $i++;
  137. }
  138. }
  139. }
  140. $result['msg'] = $msg;
  141. if ($successNum > 0) {
  142. $result['success'] = true;
  143. }
  144. print json_encode($result);
  145. die;
  146. }
  147. $this->render('edit-profile-avtra', $this->data, TRUE);
  148. }
  149. /* * ************************************************************
  150. * 生成指定长度的随机码。
  151. * @param int $length 随机码的长度。
  152. * @access public
  153. * ************************************************************ */
  154. function createRandomCode($length)
  155. {
  156. $randomCode = "";
  157. $randomChars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  158. for ($i = 0; $i < $length; $i++) {
  159. $randomCode .= $randomChars{mt_rand(0, 35)};
  160. }
  161. return $randomCode;
  162. }
  163. public function proSection()
  164. {
  165. /**
  166. * 计量期数
  167. * 完成进度
  168. *
  169. */
  170. $this->getFav();
  171. $contractArray = $this->contractact->getRowByPid($this->params['pid']); // 获取合同段
  172. $htmlstr = NULL;
  173. foreach ($contractArray as $k => $v) {
  174. $retval = $this->actmeasure->getAllbyStid($v['stid']); // 获取标段
  175. $bdhtmlstr = NULL;
  176. $biaoduantotalmoney = 0;
  177. $currTotal = 0;
  178. $progress = $otherprogress = '0%';
  179. $currTotal = $this->numofperact->getCountTotalSTID($v['stid']);
  180. //
  181. foreach ($retval as $key => $value) {
  182. $snTotalProgress = $currTotalProgress = $lessTotalProgress = '0%';
  183. $numCount = $this->numofperact->getCountTotalnum($value['pmid']);
  184. $totalplus = $this->numofperact->getCountTotalplus($value['pmid']);
  185. $snTotal = $this->numofperact->getStopNow($value['pmid']); //截止目前
  186. $currcomTotal = $this->numofperact->getCurrTotal($value['pmid']); //截止目前
  187. if ($numCount > 0) {
  188. $nTotalProgress = number_format($snTotal['sntotal'], 2, '.', ',');
  189. $ncurrTotalProgress = number_format($currcomTotal['currtotal'], 2, '.', ',');
  190. $nlessTotalProgress = number_format($totalplus['totalplus'] - $currcomTotal['currtotal'] - $snTotal['sntotal'], 2, '.', ',');
  191. $snTotalProgress = round(($snTotal['sntotal'] / $totalplus['totalplus']) * 100) . '%';
  192. $currTotalProgress = round(($currcomTotal['currtotal'] / $totalplus['totalplus']) * 100) . '%';
  193. $lessTotalProgress = round((($totalplus['totalplus'] - $currcomTotal['currtotal'] - $snTotal['sntotal']) / $totalplus['totalplus']) * 100) . '%';
  194. }
  195. $biaoduantotalmoney += $value['contracttotal'];
  196. $totalmoney = number_format($value['contracttotal'], 2, '.', ',');
  197. $bdhtmlstr .= '
  198. <thead>
  199. <tr><th class="taC" width="225">标段名</th><th class="taC" width="140">计量期数</th><th width="115" class="taC">总价</th><th class="taC" width="">截止本期累计完成/本期完成/未完成</th></tr></thead>
  200. <tbody>
  201. <tr>
  202. <td><a href="/project/1/section/' . $value['pmid'] . '/detail">' . $value['pmname'] . '</a></td>
  203. <td class="">共 ' . $numCount . ' 期(本期 <span class="colOrange">审批中</span>)</td>
  204. <td class="taR">¥' . $totalmoney . '</td>
  205. <td>
  206. <div class="progress">
  207. <div class="bar bar-success" style="width: ' . $snTotalProgress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="截止本期累计完成:¥' . $nTotalProgress . '">' . $snTotalProgress . '</div>
  208. <div class="bar" style="width:' . $currTotalProgress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="本期完成:¥' . $ncurrTotalProgress . '">' . $currTotalProgress . '</div>
  209. <div class="bar bar-gary" style="width:' . $lessTotalProgress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="未完成:¥' . $nlessTotalProgress . '">' . $lessTotalProgress . '</div>
  210. </div>
  211. </td>
  212. </tr>';
  213. }
  214. if ($biaoduantotalmoney > 0 && ($currTotal['totalplus'] > 0)) {
  215. $nprogress = number_format($currTotal['totalplus'], 2, '.', ',');
  216. $notherprogress = number_format($biaoduantotalmoney - $currTotal['totalplus'], 2, '.', ',');
  217. $progress = round(($currTotal['totalplus'] / $biaoduantotalmoney) * 100) . '%';
  218. $otherprogress = round((($biaoduantotalmoney - $currTotal['totalplus']) / $biaoduantotalmoney) * 100) . '%';
  219. $biaoduantotalmoney = number_format($biaoduantotalmoney, 2, '.', ',');
  220. }
  221. $htmlstr .= '<div class="project">
  222. <div class="proSection">
  223. <table class="table">
  224. <thead>
  225. <tr>
  226. <td width="150"><span aria-hidden="true" data-icon="u"></span> ' . $v['stname'] . '(' . $v['stkey'] . ') <a href="#secoption" data-toggle="modal" title="编辑/查看KEY"><span data-icon="S" aria-hidden="true" value="' . $v['stid'] . '" class="closePanel"></span></a></td>
  227. <td width="90">总价:</td><td width="165">¥<b style="font-size:16px">' . $biaoduantotalmoney . '</b></td>
  228. <td width="60">完成进度:</td><td><div class="progress">
  229. <div class="bar bar-success" style="width:' . $progress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="累计完成:¥' . $nprogress . '">' . $progress . '</div>
  230. <div class="bar bar-danger" style="width:' . $otherprogress . ';" data-placement="bottom" data-toggle="tooltip" data-original-title="未完成:¥' . $notherprogress . '">' . $otherprogress . '</div>
  231. </div></td>
  232. </tr>
  233. </thead>
  234. </table>
  235. <table class="table table-striped table-hover">
  236. ' . $bdhtmlstr . '
  237. </tbody>
  238. </table>
  239. </div>
  240. </div>';
  241. }
  242. $this->data['htmlstr'] = $htmlstr;
  243. if (isset($_POST['secname']) && $_POST['secname']) {
  244. $this->contractact->insertContract($this->params['pid'], $this->auth->getUid(), $_POST['secname']);
  245. return Doo::conf()->APP_URL . 'project/' . $this->params['pid'] . '/section';
  246. }
  247. $this->data['pid'] = $this->params['pid'];
  248. $this->render('w-project-section', $this->data, TRUE);
  249. }
  250. /**
  251. *
  252. * @return type
  253. */
  254. public function sms()
  255. {
  256. if (isset($_POST['mobile']) && isset($_POST['verifycode'])) {
  257. $vmArray = $this->auth->getVerifyMobile();
  258. if (isset($vmArray) && $vmArray) {
  259. if (md5($_POST['mobile'] . $_POST['verifycode']) == md5($vmArray['mobile'] . $vmArray['code'])) {
  260. $this->profile->updateMobile($this->auth->getUid(), $vmArray['mobile']);
  261. die(json_encode(array('status'=> true)));
  262. }
  263. }
  264. }
  265. $this->data['uprofile'] = $this->profile->getProWithUid($this->auth->getUid());
  266. $this->data['smsNoticeSwitch'] = $this->aconfig->getOne(array('select' => 'smsswitch', 'asArray' => TRUE))['smsswitch'];
  267. $this->render('edit-profile-sms', $this->data, TRUE);
  268. }
  269. /**
  270. *
  271. * @return type
  272. */
  273. public function smsEdit()
  274. {
  275. if (isset($_POST['mobile']) && isset($_POST['verifycode'])) {
  276. $vmArray = $this->auth->getVerifyMobile();
  277. if (isset($vmArray) && $vmArray) {
  278. if (md5($_POST['mobile'] . $_POST['verifycode']) == md5($vmArray['mobile'] . $vmArray['code'])) {
  279. $this->profile->updateMobile($this->auth->getUid(), $vmArray['mobile']);
  280. return Doo::conf()->APP_URL . 'user/profile/sms/edit';
  281. }
  282. }
  283. }
  284. $this->data['uprofile'] = $this->profile->getProWithUid($this->auth->getUid());
  285. $this->render('edit-profile-sms-edit', $this->data, TRUE);
  286. }
  287. /**
  288. *
  289. * @return type
  290. */
  291. public function checkMobile()
  292. {
  293. // $this->data['uprofile']['email'] = $this->auth->getUemail();
  294. // if (isset($_POST['name']) && isset($_POST['company']) && isset($_POST['jobs']) && isset($_POST['phone']) && isset($_POST['mobile'])) {
  295. // $this->profile->upProfile($this->auth->getUid(), $_POST);
  296. // return DOO::conf()->APP_URL . 'user/profile';
  297. // }
  298. die(json_encode(array('mobile' => (int)$this->profile->checkMobile($_POST['mobile']))));
  299. }
  300. /**
  301. *
  302. * @return type
  303. */
  304. public function mobileVerify()
  305. {
  306. // $this->data['uprofile']['email'] = $this->auth->getUemail();
  307. // if (isset($_POST['name']) && isset($_POST['company']) && isset($_POST['jobs']) && isset($_POST['phone']) && isset($_POST['mobile'])) {
  308. // $this->profile->upProfile($this->auth->getUid(), $_POST);
  309. // return DOO::conf()->APP_URL . 'user/profile';
  310. // }
  311. die(json_encode(array('mobile' => (int)$this->profile->checkMobile($_POST['mobile']))));
  312. }
  313. /**
  314. *
  315. * @return type
  316. */
  317. public function smsSend()
  318. {
  319. $randNum = rand(1000, 9999);
  320. $this->auth->setVerifyMobile(array('mobile' => $_POST['mobile'], 'code' => $randNum));
  321. $res = $this->sms->sendSms($_POST['mobile'], Doo::conf()->SMS_TIPS['AUDIT_NOTICE'] . $randNum . Doo::conf()->SMS_TIPS['END_MSG']);
  322. die(json_encode(array('verify' => $res)));
  323. }
  324. Function fNumber($number)
  325. {
  326. if ($number == '')
  327. Return "-";
  328. $nlen = strlen($number);
  329. while ($nlen > 3) {
  330. $fNumber = "," . substr($number, $nlen - 3, 3);
  331. $number = substr($number, 0, -3);
  332. $nlen = strlen($number);
  333. }
  334. if ($nlen <= 3) {
  335. $fNumber = $number . $fNumber;
  336. }
  337. Return $fNumber;
  338. }
  339. private function getFav()
  340. {
  341. $proArray = $this->project->getAll();
  342. $this->data['othrPro'] = [];
  343. foreach ($proArray as $key => $value) {
  344. if ($value['pid'] == $this->params['pid']) {
  345. $this->data['currProName'] = $value['pname'];
  346. $this->data['currProID'] = $value['pid'];
  347. } else {
  348. $this->data['othrPro'][] = $proArray[$key];
  349. }
  350. }
  351. }
  352. public function proSectionMeasure()
  353. {
  354. //此处未做更改,JSON文件已经固定名称
  355. $jsonpath = pathinfo($this->attfile->getMaxRow()['filepath']);
  356. if (isset($jsonpath['dirname'])) {
  357. $extPathdir = Doo::conf()->SITE_PATH . $jsonpath['dirname'] . '/' . $jsonpath['filename'];
  358. if ($handle = opendir($extPathdir)) {
  359. while (false !== ($file = readdir($handle))) {
  360. $filename = NULL;
  361. $filename = pathinfo($file);
  362. if ($filename['extension'] == 'json')
  363. $proArray = json_decode(file_get_contents($extPathdir . '/' . $file), TRUE, JSON_UNESCAPED_UNICODE);
  364. }
  365. closedir($handle);
  366. }
  367. $this->data['proArray'] = $proArray['Bills'];
  368. } else {
  369. $this->data['proArray'] = [];
  370. }
  371. $this->data['mpid'] = $this->params['mpid'];
  372. $this->data['pid'] = $this->params['pid'];
  373. $this->render('w-project-section-measure', $this->data, TRUE);
  374. }
  375. public function substr_replace_cn($string, $repalce = '*', $start = 0, $len = 0)
  376. {
  377. $count = mb_strlen($string, 'UTF-8'); //此处传入编码,建议使用utf-8。此处编码要与下面mb_substr()所使用的一致
  378. if (!$count) {
  379. return $string;
  380. }
  381. if ($len == 0) {
  382. $end = $count; //传入0则替换到最后
  383. } else {
  384. $end = $start + $len; //传入指定长度则为开始长度+指定长度
  385. }
  386. $i = 0;
  387. $returnString = '';
  388. while ($i < $count) { //循环该字符串
  389. $tmpString = mb_substr($string, $i, 1, 'UTF-8'); // 与mb_strlen编码一致
  390. if ($start <= $i && $i < $end) {
  391. $returnString .= $repalce;
  392. } else {
  393. $returnString .= $tmpString;
  394. }
  395. $i++;
  396. }
  397. return $returnString;
  398. }
  399. function unicode_encode($name)
  400. {//to Unicode
  401. $name = iconv('UTF-8', 'UCS-2', $name);
  402. $len = strlen($name);
  403. $str = '';
  404. for ($i = 0; $i < $len - 1; $i = $i + 2) {
  405. $c = $name[$i];
  406. $c2 = $name[$i + 1];
  407. if (ord($c) > 0) {// 两个字节的字
  408. $str .= '\\' . base_convert(ord($c), 10, 16) . base_convert(ord($c2), 10, 16);
  409. } else {
  410. $str .= $c2;
  411. }
  412. }
  413. $str = strtoupper($str);
  414. return $str;
  415. }
  416. function unicode_decode($name)
  417. {//Unicode to
  418. $pattern = '/([\w]+)|(\\\u([\w]{4}))/i';
  419. preg_match_all($pattern, $name, $matches);
  420. if (!empty($matches)) {
  421. $name = '';
  422. for ($j = 0; $j < count($matches[0]); $j++) {
  423. $str = $matches[0][$j];
  424. if (strpos($str, '\\u') === 0) {
  425. $code = base_convert(substr($str, 2, 2), 16, 10);
  426. $code2 = base_convert(substr($str, 4), 16, 10);
  427. $c = chr($code) . chr($code2);
  428. $c = iconv('UCS-2', 'UTF-8', $c);
  429. $name .= $c;
  430. } else {
  431. $name .= $str;
  432. }
  433. }
  434. }
  435. return $name;
  436. }
  437. public function proDetail()
  438. {
  439. // 面包屑导航项目
  440. $this->data['currproArray'] = $this->data['allproArray'] = NULL;
  441. $allproArray = $this->project->getAll();
  442. foreach ($allproArray as $kk => $vv) {
  443. if ($vv['pid'] == $this->params['pid']) {
  444. $this->data['currproArray'] = $vv;
  445. } else {
  446. $this->data['allproArray'][] = $vv;
  447. }
  448. }
  449. // 面包屑导航合同
  450. $conArray = $this->contractact->getAll();
  451. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  452. if (isset($measureArray['stid'])) {
  453. foreach ($conArray as $kkk => $vvv) {
  454. if ($vvv['stid'] == $measureArray['stid']) {
  455. $this->data['currconArray'] = $vvv;
  456. } else {
  457. $this->data['allconArray'][] = $vvv;
  458. }
  459. }
  460. } else {
  461. $this->data['currconArray'] = $this->data['allconArray'] = NULL;
  462. }
  463. // 面包屑导航标段
  464. $this->data['curractmeasureArray'] = NULL;
  465. $this->data['allactmeasureArray'] = [];
  466. $actmeasureArray = $this->actmeasure->getAll();
  467. foreach ($actmeasureArray as $kkkk => $vvvv) {
  468. if ($vvvv['stid'] == $measureArray['stid']) {
  469. if (($vvvv['pmid'] == $this->params['pmid'])) {
  470. $this->data['curractmeasureArray'] = $vvvv;
  471. } else {
  472. $this->data['allactmeasureArray'][] = $vvvv;
  473. }
  474. }
  475. }
  476. // 图标
  477. $this->data['MeasureArray'] = $this->numofperact->getRowByPmid($this->params['pmid']);
  478. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  479. foreach ($this->data['MeasureArray'] as $key => $value) {
  480. if ($measureArray['contracttotal'] > ($value['currdone'] > 0)) {
  481. $this->data['MeasureArray'][$key]['lessTotal'] = round(($value['currdone'] / $measureArray['contracttotal']) * 100);
  482. } else {
  483. $this->data['MeasureArray'][$key]['lessTotal'] = 0;
  484. }
  485. }
  486. $this->data['pmid'] = $this->params['pmid'];
  487. $this->data['pid'] = $this->params['pid'];
  488. $this->render('w-project-section-detail', $this->data, TRUE);
  489. }
  490. public function welcome()
  491. {
  492. // if (!$this->auth->isLoggedIn())
  493. // return Doo::conf()->APP_URL;
  494. if ($this->profile->getProWithUid($this->auth->getUid())['userid'])
  495. return Doo::conf()->APP_URL . 'project/list';
  496. if (isset($_POST['welform'])) {
  497. $profileUserArray = $_POST;
  498. $profileUserArray['userid'] = $this->auth->getUid();
  499. $this->profile->insertProfile($profileUserArray); // 无自增字段返回0
  500. return Doo::conf()->APP_URL . 'project/list';
  501. }
  502. $this->render('welcome', $this->data);
  503. }
  504. public function prolist()
  505. {
  506. // if (!$this->auth->isLoggedIn())
  507. // return Doo::conf()->APP_URL;
  508. // $proArray = new stdClass();
  509. // $jsonpath = pathinfo($this->attfile->getMaxRow()['filepath']);
  510. // $extPathdir = Doo::conf()->SITE_PATH . $jsonpath['dirname'] . '/' . $jsonpath['filename'];
  511. // if ($handle = opendir($extPathdir)) {
  512. // while (false !== ($file = readdir($handle))) {
  513. // $filename = pathinfo($file);
  514. // if ($filename['extension'] == 'json')
  515. // $proArray = json_decode(file_get_contents($extPathdir . '/' . $file));
  516. // }
  517. // closedir($handle);
  518. // }
  519. // $this->data['proArray'] = null;
  520. $this->render('s-project', $this->data);
  521. }
  522. // ajax提取密码名称
  523. public function getAjaxSection()
  524. {
  525. if (!$this->isAjax())
  526. return;
  527. echo json_encode($_POST);
  528. }
  529. public function repasswd()
  530. {
  531. if (isset($_POST['oldpasswd']) && isset($_POST['newpasswd']) && isset($_POST['renewpasswd']) && ($_POST['newpasswd'] == $_POST['renewpasswd'])) {
  532. $userArray = $this->user->getRowUser($this->auth->getUid());
  533. if ($this->ph->CheckPassword($_POST['oldpasswd'], $userArray['upass'])) {
  534. if ($this->user->updatePassWd($this->auth->getUid(), $_POST['newpasswd']))
  535. return Doo::conf()->APP_URL . 'signout';
  536. }
  537. }
  538. $this->render('edit-profile-pw', $this->data, TRUE);
  539. }
  540. public function appdownload(){
  541. $token = $this->auth->getWebToken($this->auth->getUid());
  542. if($token == ''){
  543. exit('token不存在或已过期,请重新登录 '.DOO::conf()->APP_URL);
  544. }
  545. //加密uid
  546. $uid = $this->__hashids->encode($this->auth->getUid());
  547. $content = Doo::conf()->APP_URL.'api/app/scan/validate?user='.$uid.'&token='.$token;
  548. $qrcodeurl = 'global/qrcode/';
  549. $filepath = $qrcodeurl.'qrcode_'.$uid.'.png';
  550. $this->codemake($content,$filepath);
  551. $this->data['qrcode'] = $filepath;
  552. $this->render('edit-app', $this->data, TRUE);
  553. }
  554. function codemake($content,$filepath){
  555. $value = $content;//二维码内容
  556. $errorCorrectionLevel = 'H';//容错级别
  557. $matrixPointSize = 3;//生成图片大小
  558. //生成二维码图片
  559. QRcode::png($value, $filepath, $errorCorrectionLevel, $matrixPointSize,0);
  560. // $logo = 'jb51.png';//准备好的logo图片
  561. // $QR = 'qrcode.png';//已经生成的原始二维码图
  562. //
  563. // if ($logo !== FALSE) {
  564. // $QR = imagecreatefromstring(file_get_contents($QR));
  565. // $logo = imagecreatefromstring(file_get_contents($logo));
  566. // $QR_width = imagesx($QR);//二维码图片宽度
  567. // $QR_height = imagesy($QR);//二维码图片高度
  568. // $logo_width = imagesx($logo);//logo图片宽度
  569. // $logo_height = imagesy($logo);//logo图片高度
  570. // $logo_qr_width = $QR_width / 5;
  571. // $scale = $logo_width/$logo_qr_width;
  572. // $logo_qr_height = $logo_height/$scale;
  573. // $from_width = ($QR_width - $logo_qr_width) / 2;
  574. // //重新组合图片并调整大小
  575. // imagecopyresampled($QR, $logo, $from_width, $from_width, 0, 0, $logo_qr_width,
  576. // $logo_qr_height, $logo_width, $logo_height);
  577. // }
  578. //输出图片
  579. // Header("Content-type: image/png");
  580. // ImagePng($QR);
  581. }
  582. }
  583. ?>