UserController.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  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. echo json_encode(array('code' => 200));
  281. die;
  282. // return Doo::conf()->APP_URL . 'user/profile/sms/edit';
  283. }
  284. }
  285. echo json_encode(array('code' => 400));
  286. die;
  287. }
  288. $this->data['uprofile'] = $this->profile->getProWithUid($this->auth->getUid());
  289. $this->render('edit-profile-sms-edit', $this->data, TRUE);
  290. }
  291. /**
  292. *
  293. * @return type
  294. */
  295. public function checkMobile()
  296. {
  297. // $this->data['uprofile']['email'] = $this->auth->getUemail();
  298. // if (isset($_POST['name']) && isset($_POST['company']) && isset($_POST['jobs']) && isset($_POST['phone']) && isset($_POST['mobile'])) {
  299. // $this->profile->upProfile($this->auth->getUid(), $_POST);
  300. // return DOO::conf()->APP_URL . 'user/profile';
  301. // }
  302. die(json_encode(array('mobile' => (int)$this->profile->checkMobile($_POST['mobile']))));
  303. }
  304. /**
  305. *
  306. * @return type
  307. */
  308. public function mobileVerify()
  309. {
  310. // $this->data['uprofile']['email'] = $this->auth->getUemail();
  311. // if (isset($_POST['name']) && isset($_POST['company']) && isset($_POST['jobs']) && isset($_POST['phone']) && isset($_POST['mobile'])) {
  312. // $this->profile->upProfile($this->auth->getUid(), $_POST);
  313. // return DOO::conf()->APP_URL . 'user/profile';
  314. // }
  315. die(json_encode(array('mobile' => (int)$this->profile->checkMobile($_POST['mobile']))));
  316. }
  317. /**
  318. *
  319. * @return type
  320. */
  321. public function smsSend()
  322. {
  323. $randNum = rand(1000, 9999);
  324. $this->auth->setVerifyMobile(array('mobile' => $_POST['mobile'], 'code' => $randNum));
  325. $res = $this->sms->sendSms($_POST['mobile'], Doo::conf()->SMS_TIPS['AUDIT_NOTICE'] . $randNum . Doo::conf()->SMS_TIPS['END_MSG']);
  326. die(json_encode(array('verify' => $res)));
  327. }
  328. Function fNumber($number)
  329. {
  330. if ($number == '')
  331. Return "-";
  332. $nlen = strlen($number);
  333. while ($nlen > 3) {
  334. $fNumber = "," . substr($number, $nlen - 3, 3);
  335. $number = substr($number, 0, -3);
  336. $nlen = strlen($number);
  337. }
  338. if ($nlen <= 3) {
  339. $fNumber = $number . $fNumber;
  340. }
  341. Return $fNumber;
  342. }
  343. private function getFav()
  344. {
  345. $proArray = $this->project->getAll();
  346. $this->data['othrPro'] = [];
  347. foreach ($proArray as $key => $value) {
  348. if ($value['pid'] == $this->params['pid']) {
  349. $this->data['currProName'] = $value['pname'];
  350. $this->data['currProID'] = $value['pid'];
  351. } else {
  352. $this->data['othrPro'][] = $proArray[$key];
  353. }
  354. }
  355. }
  356. public function proSectionMeasure()
  357. {
  358. //此处未做更改,JSON文件已经固定名称
  359. $jsonpath = pathinfo($this->attfile->getMaxRow()['filepath']);
  360. if (isset($jsonpath['dirname'])) {
  361. $extPathdir = Doo::conf()->SITE_PATH . $jsonpath['dirname'] . '/' . $jsonpath['filename'];
  362. if ($handle = opendir($extPathdir)) {
  363. while (false !== ($file = readdir($handle))) {
  364. $filename = NULL;
  365. $filename = pathinfo($file);
  366. if ($filename['extension'] == 'json')
  367. $proArray = json_decode(file_get_contents($extPathdir . '/' . $file), TRUE, JSON_UNESCAPED_UNICODE);
  368. }
  369. closedir($handle);
  370. }
  371. $this->data['proArray'] = $proArray['Bills'];
  372. } else {
  373. $this->data['proArray'] = [];
  374. }
  375. $this->data['mpid'] = $this->params['mpid'];
  376. $this->data['pid'] = $this->params['pid'];
  377. $this->render('w-project-section-measure', $this->data, TRUE);
  378. }
  379. public function substr_replace_cn($string, $repalce = '*', $start = 0, $len = 0)
  380. {
  381. $count = mb_strlen($string, 'UTF-8'); //此处传入编码,建议使用utf-8。此处编码要与下面mb_substr()所使用的一致
  382. if (!$count) {
  383. return $string;
  384. }
  385. if ($len == 0) {
  386. $end = $count; //传入0则替换到最后
  387. } else {
  388. $end = $start + $len; //传入指定长度则为开始长度+指定长度
  389. }
  390. $i = 0;
  391. $returnString = '';
  392. while ($i < $count) { //循环该字符串
  393. $tmpString = mb_substr($string, $i, 1, 'UTF-8'); // 与mb_strlen编码一致
  394. if ($start <= $i && $i < $end) {
  395. $returnString .= $repalce;
  396. } else {
  397. $returnString .= $tmpString;
  398. }
  399. $i++;
  400. }
  401. return $returnString;
  402. }
  403. function unicode_encode($name)
  404. {//to Unicode
  405. $name = iconv('UTF-8', 'UCS-2', $name);
  406. $len = strlen($name);
  407. $str = '';
  408. for ($i = 0; $i < $len - 1; $i = $i + 2) {
  409. $c = $name[$i];
  410. $c2 = $name[$i + 1];
  411. if (ord($c) > 0) {// 两个字节的字
  412. $str .= '\\' . base_convert(ord($c), 10, 16) . base_convert(ord($c2), 10, 16);
  413. } else {
  414. $str .= $c2;
  415. }
  416. }
  417. $str = strtoupper($str);
  418. return $str;
  419. }
  420. function unicode_decode($name)
  421. {//Unicode to
  422. $pattern = '/([\w]+)|(\\\u([\w]{4}))/i';
  423. preg_match_all($pattern, $name, $matches);
  424. if (!empty($matches)) {
  425. $name = '';
  426. for ($j = 0; $j < count($matches[0]); $j++) {
  427. $str = $matches[0][$j];
  428. if (strpos($str, '\\u') === 0) {
  429. $code = base_convert(substr($str, 2, 2), 16, 10);
  430. $code2 = base_convert(substr($str, 4), 16, 10);
  431. $c = chr($code) . chr($code2);
  432. $c = iconv('UCS-2', 'UTF-8', $c);
  433. $name .= $c;
  434. } else {
  435. $name .= $str;
  436. }
  437. }
  438. }
  439. return $name;
  440. }
  441. public function proDetail()
  442. {
  443. // 面包屑导航项目
  444. $this->data['currproArray'] = $this->data['allproArray'] = NULL;
  445. $allproArray = $this->project->getAll();
  446. foreach ($allproArray as $kk => $vv) {
  447. if ($vv['pid'] == $this->params['pid']) {
  448. $this->data['currproArray'] = $vv;
  449. } else {
  450. $this->data['allproArray'][] = $vv;
  451. }
  452. }
  453. // 面包屑导航合同
  454. $conArray = $this->contractact->getAll();
  455. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  456. if (isset($measureArray['stid'])) {
  457. foreach ($conArray as $kkk => $vvv) {
  458. if ($vvv['stid'] == $measureArray['stid']) {
  459. $this->data['currconArray'] = $vvv;
  460. } else {
  461. $this->data['allconArray'][] = $vvv;
  462. }
  463. }
  464. } else {
  465. $this->data['currconArray'] = $this->data['allconArray'] = NULL;
  466. }
  467. // 面包屑导航标段
  468. $this->data['curractmeasureArray'] = NULL;
  469. $this->data['allactmeasureArray'] = [];
  470. $actmeasureArray = $this->actmeasure->getAll();
  471. foreach ($actmeasureArray as $kkkk => $vvvv) {
  472. if ($vvvv['stid'] == $measureArray['stid']) {
  473. if (($vvvv['pmid'] == $this->params['pmid'])) {
  474. $this->data['curractmeasureArray'] = $vvvv;
  475. } else {
  476. $this->data['allactmeasureArray'][] = $vvvv;
  477. }
  478. }
  479. }
  480. // 图标
  481. $this->data['MeasureArray'] = $this->numofperact->getRowByPmid($this->params['pmid']);
  482. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  483. foreach ($this->data['MeasureArray'] as $key => $value) {
  484. if ($measureArray['contracttotal'] > ($value['currdone'] > 0)) {
  485. $this->data['MeasureArray'][$key]['lessTotal'] = round(($value['currdone'] / $measureArray['contracttotal']) * 100);
  486. } else {
  487. $this->data['MeasureArray'][$key]['lessTotal'] = 0;
  488. }
  489. }
  490. $this->data['pmid'] = $this->params['pmid'];
  491. $this->data['pid'] = $this->params['pid'];
  492. $this->render('w-project-section-detail', $this->data, TRUE);
  493. }
  494. public function welcome()
  495. {
  496. // if (!$this->auth->isLoggedIn())
  497. // return Doo::conf()->APP_URL;
  498. if ($this->profile->getProWithUid($this->auth->getUid())['userid'])
  499. return Doo::conf()->APP_URL . 'project/list';
  500. if (isset($_POST['welform'])) {
  501. $profileUserArray = $_POST;
  502. $profileUserArray['userid'] = $this->auth->getUid();
  503. $this->profile->insertProfile($profileUserArray); // 无自增字段返回0
  504. return Doo::conf()->APP_URL . 'project/list';
  505. }
  506. $this->render('welcome', $this->data);
  507. }
  508. public function prolist()
  509. {
  510. // if (!$this->auth->isLoggedIn())
  511. // return Doo::conf()->APP_URL;
  512. // $proArray = new stdClass();
  513. // $jsonpath = pathinfo($this->attfile->getMaxRow()['filepath']);
  514. // $extPathdir = Doo::conf()->SITE_PATH . $jsonpath['dirname'] . '/' . $jsonpath['filename'];
  515. // if ($handle = opendir($extPathdir)) {
  516. // while (false !== ($file = readdir($handle))) {
  517. // $filename = pathinfo($file);
  518. // if ($filename['extension'] == 'json')
  519. // $proArray = json_decode(file_get_contents($extPathdir . '/' . $file));
  520. // }
  521. // closedir($handle);
  522. // }
  523. // $this->data['proArray'] = null;
  524. $this->render('s-project', $this->data);
  525. }
  526. // ajax提取密码名称
  527. public function getAjaxSection()
  528. {
  529. if (!$this->isAjax())
  530. return;
  531. echo json_encode($_POST);
  532. }
  533. public function repasswd()
  534. {
  535. if (isset($_POST['oldpasswd']) && isset($_POST['newpasswd']) && isset($_POST['renewpasswd']) && ($_POST['newpasswd'] == $_POST['renewpasswd'])) {
  536. $userArray = $this->user->getRowUser($this->auth->getUid());
  537. if ($this->ph->CheckPassword($_POST['oldpasswd'], $userArray['upass'])) {
  538. if ($this->user->updatePassWd($this->auth->getUid(), $_POST['newpasswd']))
  539. return Doo::conf()->APP_URL . 'signout';
  540. }
  541. }
  542. $this->render('edit-profile-pw', $this->data, TRUE);
  543. }
  544. public function appdownload(){
  545. $token = $this->auth->getWebToken($this->auth->getUid());
  546. if($token == ''){
  547. exit('token不存在或已过期,请重新登录 '.DOO::conf()->APP_URL);
  548. }
  549. //加密uid
  550. $uid = $this->__hashids->encode($this->auth->getUid());
  551. $content = Doo::conf()->APP_URL.'api/app/scan/validate?user='.$uid.'&token='.$token;
  552. $qrcodeurl = 'global/qrcode/';
  553. $filepath = $qrcodeurl.'qrcode_'.$uid.'.png';
  554. $this->codemake($content,$filepath);
  555. $this->data['qrcode'] = $filepath;
  556. $this->render('edit-app', $this->data, TRUE);
  557. }
  558. function codemake($content,$filepath){
  559. $value = $content;//二维码内容
  560. $errorCorrectionLevel = 'H';//容错级别
  561. $matrixPointSize = 3;//生成图片大小
  562. //生成二维码图片
  563. QRcode::png($value, $filepath, $errorCorrectionLevel, $matrixPointSize,0);
  564. // $logo = 'jb51.png';//准备好的logo图片
  565. // $QR = 'qrcode.png';//已经生成的原始二维码图
  566. //
  567. // if ($logo !== FALSE) {
  568. // $QR = imagecreatefromstring(file_get_contents($QR));
  569. // $logo = imagecreatefromstring(file_get_contents($logo));
  570. // $QR_width = imagesx($QR);//二维码图片宽度
  571. // $QR_height = imagesy($QR);//二维码图片高度
  572. // $logo_width = imagesx($logo);//logo图片宽度
  573. // $logo_height = imagesy($logo);//logo图片高度
  574. // $logo_qr_width = $QR_width / 5;
  575. // $scale = $logo_width/$logo_qr_width;
  576. // $logo_qr_height = $logo_height/$scale;
  577. // $from_width = ($QR_width - $logo_qr_width) / 2;
  578. // //重新组合图片并调整大小
  579. // imagecopyresampled($QR, $logo, $from_width, $from_width, 0, 0, $logo_qr_width,
  580. // $logo_qr_height, $logo_width, $logo_height);
  581. // }
  582. //输出图片
  583. // Header("Content-type: image/png");
  584. // ImagePng($QR);
  585. }
  586. }
  587. ?>