AppController.php 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. <?php
  2. Doo::loadCore('auth/DooAuth');
  3. Doo::loadClass('PasswordHash');
  4. Doo::loadClass('client');
  5. Doo::loadClass('auth');
  6. Doo::loadClass('attachment');
  7. Doo::loadClass('attfile');
  8. Doo::loadClass('actmeasure');
  9. Doo::loadClass('contractact');
  10. Doo::loadClass('project');
  11. Doo::loadClass('profile');
  12. Doo::loadClass('numofperact');
  13. Doo::loadClass('measureauditact');
  14. Doo::loadClass('itemfile');
  15. Doo::loadModel('users');
  16. Doo::loadClass('itemmeasurenum');
  17. Doo::loadModelAt('aconfig', 'admin');
  18. Doo::loadClass('sms');
  19. /**
  20. * MainController
  21. * Feel free to delete the methods and replace them with your own code.
  22. *
  23. * @author EllisRan
  24. */
  25. class AppController extends DooController {
  26. private $data, $client, $auth, $att, $file, $zip, $actmeasure, $contractact, $project, $profile, $numofperact, $measureauditact, $attfile, $users, $itemfile, $modelconfig, $aconfig, $sms, $itemMeasureNum;
  27. private $statusArray = array('uncheck' => '1', 'checking' => '2', 'checked' => '3', 'checkno' => '4');
  28. private $fileTypeArray = array('台帐附件');
  29. public function __construct()
  30. {
  31. $this->data['rootUrl'] = Doo::conf()->APP_URL;
  32. $this->client = new client();
  33. $this->auth = new Auth();
  34. $this->att = new attachment();
  35. $this->attfile = new attFile();
  36. // $this->zip = new ZipArchive();
  37. $this->actmeasure = new actMeasure();
  38. $this->contractact = new Contractact();
  39. $this->project = new Project();
  40. $this->profile = new Profile();
  41. $this->numofperact = new NumofperAct();
  42. $this->measureauditact = new MeasureauditAct();
  43. $this->users = new Users();
  44. $this->itemfile = new ItemFile();
  45. $this->modelconfig = new AConfig();
  46. $this->itemMeasureNum = new ItemMeasureNumpofper();
  47. $this->aconfig = new AConfig();
  48. $this->sms = new Sms(Doo::conf()->SMS_URL, Doo::conf()->SMS_AUTHKEY);
  49. }
  50. public function ServerLogin() {
  51. if(isset($_POST['sname']) && !empty($_POST['sname'])){
  52. $allserver = array($_SERVER['HTTP_HOST']);
  53. if(in_array(trim($_POST['sname']), $allserver)){
  54. echo json_encode(array('status' => TRUE, 'msg' => ''), JSON_UNESCAPED_UNICODE);
  55. die;
  56. }else{
  57. echo json_encode(array('status' => FALSE, 'msg' => '服务器不存在。'), JSON_UNESCAPED_UNICODE);
  58. die;
  59. }
  60. }else{
  61. echo json_encode(array('status' => FALSE, 'msg' => '请输入服务器名称。'), JSON_UNESCAPED_UNICODE);
  62. die;
  63. }
  64. }
  65. public function AppSignin() {
  66. if(!isset($_POST['username']) || empty($_POST['username'])){
  67. echo json_encode(array('status' => FALSE, 'msg' => '请输入邮箱'), JSON_UNESCAPED_UNICODE);
  68. die;
  69. }
  70. if(!isset($_POST['userpwd']) || empty($_POST['userpwd'])){
  71. echo json_encode(array('status' => FALSE, 'msg' => '请输入密码'), JSON_UNESCAPED_UNICODE);
  72. die;
  73. }
  74. if ($this->auth->login($_POST['username'], $_POST['userpwd'])) {
  75. $uinfo = $this->auth->getUinfo();
  76. if (isset($uinfo['isstop']) && $uinfo['isstop'] > 0) {
  77. echo json_encode(array('status' => FALSE, 'msg' => '邮箱不存在或者密码错误'), JSON_UNESCAPED_UNICODE);
  78. die;
  79. }
  80. if (isset($uinfo['uid'])) {
  81. $userArray = $this->profile->getProWithUid($uinfo['uid']);
  82. $avatarStr = $userArray['avatar'];
  83. if (isset($userArray['userid'])) {
  84. // $this->auth->setUid($uinfo['uid']);
  85. $msgArray = array('uid' => $uinfo['uid'], 'name' => $userArray['name'], 'email' => $uinfo['uemail'], 'ucompany' => $userArray['company'], 'jobtitle' => $userArray['jobs'], 'avatar' => Doo::conf()->APP_URL . $avatarStr);
  86. echo json_encode(array('status' => TRUE, 'msg' => '', 'userinfo' => $msgArray), JSON_UNESCAPED_UNICODE);
  87. die;
  88. }
  89. }
  90. } else {
  91. echo json_encode(array('status' => FALSE, 'msg' => '邮箱不存在或者密码错误'), JSON_UNESCAPED_UNICODE);
  92. die;
  93. }
  94. }
  95. // 获取待审批标段名
  96. public function UnSectionList(){
  97. if(isset($_POST['uid']) && !empty($_POST['uid']) && is_numeric($_POST['uid'])){
  98. $unsectionlist = $this->measureauditact->getCheckedRowbyUID6($_POST['uid']);
  99. $unslist = array();
  100. if(!empty($unsectionlist)){
  101. foreach($unsectionlist as $k => $v){
  102. $unslist[$k]['pname'] = $this->project->getRowByPid($v['pid'])['pname'];
  103. $unslist[$k]['sectionlist'] = array();
  104. $sectionlist = $this->measureauditact->getCheckedRowbyUID7($_POST['uid'],$v['pid']);
  105. if(!empty($sectionlist)){
  106. foreach($sectionlist as $sk => $sv){
  107. $name = $this->actmeasure->getRowByPmid($sv['pmid']);
  108. $unslist[$k]['sectionlist'][$sk]['pmname'] = !empty($name) ? $name['pmname'] : '';
  109. $countNum = $this->numofperact->getLastNew2($sv['pmid'])['numpname'];
  110. $unslist[$k]['sectionlist'][$sk]['countNum'] = !empty($countNum) ? $countNum : 0;
  111. $unslist[$k]['sectionlist'][$sk]['audittime'] = !empty($sv['audittime']) ? date('Y-m-d',$sv['audittime']) : '';
  112. $unslist[$k]['sectionlist'][$sk]['url'] = '/app/rproject/' . $sv['pid'] . '/section/' . $sv['pmid'] . '/detail';
  113. $stname = $this->contractact->getRowByStid($sv['stid']);
  114. $unslist[$k]['sectionlist'][$sk]['stname'] = !empty($stname) ? $stname['stname'] : '';
  115. }
  116. }
  117. }
  118. }
  119. echo json_encode(array('status' => TRUE, 'msg' => '', 'unsectionlist' => $unslist), JSON_UNESCAPED_UNICODE);
  120. die();
  121. }else{
  122. $status = array('status' => FALSE, 'msg' => '获取待审批标段列表出错');
  123. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  124. die();
  125. }
  126. }
  127. //获取已审核项目名
  128. public function ItemCkeckedList(){
  129. if(isset($_POST['uid']) && !empty($_POST['uid']) && is_numeric($_POST['uid'])){
  130. $Itemlist = $this->measureauditact->getCheckedRowbyUID3($_POST['uid']);
  131. $Itemcheckedlist = array();
  132. if(!empty($Itemlist)){
  133. foreach($Itemlist as $k => $v){
  134. $name = $this->project->getRowByPid($v['pid']);
  135. $Itemcheckedlist[$k]['pid'] = $v['pid'];
  136. $Itemcheckedlist[$k]['pname'] = $name['pname'];
  137. }
  138. }
  139. echo json_encode(array('status' => TRUE, 'msg' => '', 'Itemlist' => $Itemcheckedlist), JSON_UNESCAPED_UNICODE);
  140. die();
  141. }else{
  142. $status = array('status' => FALSE, 'msg' => '获取已审核项目列表出错');
  143. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  144. die();
  145. }
  146. }
  147. //获取已审核项目中已审核标段的信息
  148. public function SectionCheckedList(){
  149. if(isset($_POST['uid']) && is_numeric($_POST['uid']) && isset($this->params['pid']) && is_numeric($this->params['pid'])){
  150. //先获取标段类型列表
  151. $stlist = $this->measureauditact->getCheckedRowbyUID4($_POST['uid'], $this->params['pid']);
  152. $sectioncheckedlist = array();
  153. if(!empty($stlist)){
  154. $i = 0;
  155. foreach($stlist as $k => $v){
  156. //再获取标段名信息
  157. $sectionlist = $this->measureauditact->getCheckedRowbyUID5($_POST['uid'], $this->params['pid'],$v['stid']);
  158. $sectioncheckedlistarray = array();
  159. if(!empty($sectionlist)){
  160. $j = 0;
  161. foreach($sectionlist as $key => $value){
  162. $numStatusArray = $this->numofperact->getLastStatus3($this->params['pid'], $value['pmid']);
  163. if (!isset($numStatusArray['currstatus'])) {
  164. $numStatusArray['currstatus'] = 'uncheck';
  165. }
  166. $datatmp = $this->measureauditact->getMyAuditStatus2($numStatusArray['pmid'], $numStatusArray['numpname'], $numStatusArray['times'], $_POST['uid']);
  167. if ($datatmp && ($datatmp['mastatus'] == 'checked' || $datatmp['mastatus'] == 'checkno') ) {
  168. $pmname = $this->actmeasure->getRowByPmid($value['pmid']);
  169. $sectioncheckedlistarray[$j]['pmname'] = !empty($pmname) ? $pmname['pmname'] : '';
  170. $sectioncheckedlistarray[$j]['countNum'] = !empty($datatmp['numpname']) ? $datatmp['numpname'] : 0;
  171. $sectioncheckedlistarray[$j]['audittime'] = !empty($datatmp['audittime']) ? date('Y-m-d',$datatmp['audittime']) : '';
  172. $sectioncheckedlistarray[$j]['url'] = '/app/rproject/' . $this->params['pid'] . '/section/' . $value['pmid'] . '/detail';
  173. $j++;
  174. }
  175. }
  176. }
  177. if(!empty($sectioncheckedlistarray)){
  178. $stname = $this->contractact->getRowByStid($v['stid']);
  179. $sectioncheckedlist[$i]['stname'] = !empty($stname['stname']) ? $stname['stname'] : '';
  180. $sectioncheckedlist[$i]['stlist'] = $sectioncheckedlistarray;
  181. }
  182. $i++;
  183. }
  184. }
  185. echo json_encode(array('status' => TRUE, 'msg' => '', 'sectionlist' => $sectioncheckedlist), JSON_UNESCAPED_UNICODE);
  186. die();
  187. }else{
  188. $status = array('status' => FALSE, 'msg' => '获取已审核标段列表出错');
  189. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  190. die();
  191. }
  192. }
  193. //内嵌app页
  194. public function proDetail() {
  195. if(isset($_GET['uid']) && is_numeric($_GET['uid'])) {
  196. if(isset($_GET['approval'])){
  197. $this->data['approval'] = 1;
  198. }
  199. $numStatusArray = $this->numofperact->getLastStatus3($this->params['pid'], $this->params['pmid']);
  200. if (!isset($numStatusArray['currstatus'])) {
  201. $numStatusArray['currstatus'] = 'uncheck';
  202. }
  203. // 项目名称
  204. $mpidArray = $this->measureauditact->getAuditProject2($_GET['uid']);
  205. foreach ($mpidArray as $k1 => $v1) {
  206. if ($v1['pid'] != $this->params['pid'])
  207. $this->data['allproArray'][] = $this->project->getRowByPid($v1['pid']);
  208. }
  209. $this->data['currproArray'] = $this->project->getRowByPid($this->params['pid']);
  210. $this->data['MeasureArray'] = $this->numofperact->getGroupByLastOne($this->params['pmid']);
  211. $this->data['MeasureArray3'] = array_reverse($this->data['MeasureArray']);
  212. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  213. foreach ($this->data['MeasureArray'] as $key => $value) {
  214. if ($measureArray['contracttotal'] > $value['currdone'] && $value['currdone'] > 0) {
  215. $this->data['MeasureArray'][$key]['lessTotal'] = round(($value['currdone'] / $measureArray['contracttotal']) * 100);
  216. } else {
  217. $this->data['MeasureArray'][$key]['lessTotal'] = 0;
  218. }
  219. }
  220. // 期数列表
  221. $tmpArray = $this->numofperact->getGroupByLastOne2($this->params['pmid']);
  222. foreach ($tmpArray as $k => $v) {
  223. $intTime = $this->numofperact->getMaxTimes($v['pmid'], $v['numpname'])['times'];
  224. $nfArray[] = $this->numofperact->getRow($v['pmid'], $v['numpname'], $intTime);
  225. }
  226. foreach ($nfArray as $k => $v) {
  227. if ($v['mpid'] == $numStatusArray['mpid']) {
  228. $this->data['mpid'] = $v['mpid'];
  229. $this->data['MeasureArray2'][] = $v;
  230. $this->data['currnum'] = $v['numpname'];
  231. } else {
  232. $this->data['numArray'][] = $v;
  233. }
  234. }
  235. $measureArray = $this->actmeasure->getRowByPmid($this->params['pmid']);
  236. foreach ($this->data['MeasureArray2'] as $key => $value) {
  237. if ($value['mpid'] == $numStatusArray['mpid']) {
  238. $this->data['MeasureArray2'][$key]['currstatus'] = $this->statusArray[$value['currstatus']];
  239. if ($measureArray['contracttotal'] > $value['currdone'] && $value['currdone'] > 0) {
  240. $this->data['MeasureArray2'][$key]['lessTotal'] = round(($value['currdone'] / $measureArray['contracttotal']) * 100);
  241. } else {
  242. $this->data['MeasureArray2'][$key]['lessTotal'] = 0;
  243. }
  244. }
  245. }
  246. $lastRowArray = $this->numofperact->getLastNew2($this->params['pmid']);
  247. $maxTimes = $this->numofperact->getMaxTimes($lastRowArray['pmid'], $lastRowArray['numpname']);
  248. // $auditUserArray = $this->measureauditact->getAllAudit($lastRowArray['pmid'], $lastRowArray['numpname'], $maxTimes['times']);
  249. // $maxtimez = $this->measureauditact->getRowGroupByTimes($numStatusArray['mpid']);
  250. $maxtimez = $this->numofperact->getRowByMpid($numStatusArray['mpid']);
  251. $auditUserArray = $this->measureauditact->getRowByMpidTimes($numStatusArray['mpid'], $maxtimez['numpname'], $maxtimez['times']);
  252. $auditArray = $this->measureauditact->getLastNewRowInfo($lastRowArray['pmid'], $lastRowArray['numpname'], $_GET['uid']);
  253. if (isset($_POST['act'])) {
  254. $auditStatusArray = array('checkno', 'checked');
  255. $myAuditStatus = $this->measureauditact->getMyAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], $maxTimes['times'], $_GET['uid']);
  256. if (in_array($myAuditStatus['mastatus'], $auditStatusArray)) {
  257. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  258. die();
  259. }
  260. }
  261. if ($_POST['act'] == 'p') {
  262. if ($this->measureauditact->setMyAuditPass($auditArray['maid'], $_POST['content'], 1, $_GET['uid'])) {
  263. $countAudit = count($auditUserArray);
  264. $this->attfile->updateHash($lastRowArray['pmid'], $lastRowArray['numpname'], $maxTimes['times']);
  265. if ($auditArray['last'] == 1) {
  266. $this->numofperact->updateAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], 'checked', $maxTimes['times']);
  267. // SMS Start
  268. $TenderArray = $this->actmeasure->getRowByPmid($lastRowArray['pmid']);
  269. $userProArray = $this->profile->getProWithUid($TenderArray['uid']);
  270. if (isset($userProArray) && ($userProArray['mobile'])) {
  271. $retval = $this->__auditNotice($userProArray['mobile'], Doo::conf()->SMS_TIPS_PRE . '您好,' . $TenderArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR3"]);
  272. }
  273. // SMS End
  274. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  275. die();
  276. } else {
  277. if (($countAudit == 2) && ($auditUserArray[1]['last'] == 1) && ($auditUserArray[0]['maid'] == $auditArray['maid'])) {
  278. $this->measureauditact->updateMastatus($auditUserArray[1]['maid']);
  279. $this->numofperact->updateAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], 'checking', $maxTimes['times']);
  280. // SMS Start
  281. $verifyUserArray = $this->profile->getVerifiedMobile($auditUserArray[1]['auditoruid']);
  282. $pmnameArray = $this->actmeasure->getRowByPmid($lastRowArray['pmid']);
  283. if (isset($verifyUserArray) && ($verifyUserArray['mobile'])) {// XXXX(标段名),陈特,已审批通过。请您继续审批。
  284. $this->__auditNotice($verifyUserArray['mobile'], Doo::conf()->SMS_TIPS_PRE . '您好,' . $pmnameArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR2"]);
  285. }
  286. // SMS End
  287. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  288. die();
  289. }
  290. if (($countAudit > 2)) {
  291. foreach ($auditUserArray as $k => $v) {
  292. if ($v['maid'] == $auditArray['maid']) {
  293. if ($k == ($countAudit - 1)) {//如果是最后一个
  294. $this->measureauditact->updateMastatus($auditUserArray[0]['maid']);
  295. // SMS Start
  296. $verifyUserArray = $this->profile->getVerifiedMobile($auditUserArray[0]['auditoruid']);
  297. // var_dump($verifyUserArray);
  298. $pmnameArray = $this->actmeasure->getRowByPmid($auditUserArray[0]['pmid']);
  299. // var_dump($pmnameArray);
  300. // SMS End
  301. } else {
  302. $this->measureauditact->updateMastatus($auditUserArray[$k + 1]['maid']);
  303. // SMS Start
  304. $verifyUserArray = $this->profile->getVerifiedMobile($auditUserArray[$k + 1]['auditoruid']);
  305. // var_dump($verifyUserArray);
  306. $pmnameArray = $this->actmeasure->getRowByPmid($auditUserArray[$k + 1]['pmid']);
  307. // var_dump($pmnameArray);
  308. // SMS End
  309. }
  310. // SMS Start
  311. if (isset($verifyUserArray) && ($verifyUserArray['mobile'])) {// XXXX(标段名),陈特,已审批通过。请您继续审批。
  312. // $retval = $this->__auditNotice($verifyUserArray['mobile'], Doo::conf()->SMS_TIPS_PRE . $pmnameArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR2"]);
  313. $this->__auditNotice($verifyUserArray['mobile'], Doo::conf()->SMS_TIPS_PRE . '您好,' . $pmnameArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR2"]);
  314. // var_dump($pmnameArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR2"]);
  315. // var_dump($retval);
  316. // var_dump($this->sms->getErrors());
  317. }
  318. // SMS End
  319. $this->numofperact->updateAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], 'checking', $maxTimes['times']);
  320. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  321. die();
  322. }
  323. }
  324. }
  325. }
  326. }
  327. }
  328. if ($_POST['act'] == 'np') {
  329. $this->measureauditact->setCheckno($auditArray['maid'], $_POST['content'], 1);
  330. $this->numofperact->updateAuditStatus($lastRowArray['pmid'], $lastRowArray['numpname'], 'checkno', $maxTimes['times']);
  331. $this->attfile->updateHash($lastRowArray['pmid'], $lastRowArray['numpname'], $maxTimes['times']);
  332. // SMS Start
  333. $TenderArray = $this->actmeasure->getRowByPmid($lastRowArray['pmid']);
  334. $userProArray = $this->profile->getProWithUid($TenderArray['uid']);
  335. if (isset($userProArray) && ($userProArray['mobile'])) {// // XXXX(标段名),陈特,已审批通过。请您继续审批。
  336. $retval = $this->__auditNotice($userProArray['mobile'], Doo::conf()->SMS_TIPS_PRE . '您好,' . $TenderArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR4"]);
  337. // var_dump($retval);
  338. // var_dump($this->sms->getErrors());
  339. // $this->__auditNotice($userProArray['mobile'], Doo::conf()->SMS_TIPS_PRE . '您好,' . $TenderArray["pmname"] . Doo::conf()->SMS_TIPS["AUDIT_NOTICE_AUDITOR4"]);
  340. }
  341. // SMS End
  342. echo json_encode(array('status' => 1), JSON_UNESCAPED_UNICODE);
  343. die();
  344. }
  345. $this->data['pmid'] = $lastRowArray['pmid'];
  346. $this->data['numpname'] = $lastRowArray['numpname'];
  347. $this->data['times'] = $lastRowArray['times'];
  348. foreach ($auditUserArray as $key => $value) {
  349. $strAvatar = $this->auth->getAvatar($value['auditoruid']);
  350. if ($value['auditoruid'] == $_GET['uid']) {
  351. $this->data['mastatus'] = $value['mastatus'];
  352. $this->data['maid'] = $value['maid'];
  353. $name = $this->profile->getProWithUid($value['auditoruid'])['name'].'(我)';
  354. }else{
  355. $name = $this->profile->getProWithUid($value['auditoruid'])['name'];
  356. }
  357. if ($value['mastatus'] == 'uncheck') {
  358. $statushtml = '<div class="approvalImg"><img class="pa2ss" src="'. $strAvatar .'">'.$name.'<b class="colGray fR">待审</b></div>';
  359. }
  360. if ($value['mastatus'] == 'checking') {
  361. $statushtml = '<div class="approvalImg"><img class="wait" src="'. $strAvatar .'">'.$name.'<b class="colOrange fR">审批中</b></div>';
  362. }
  363. if ($value['mastatus'] == 'checked') {
  364. $statushtml = '<div class="approvalImg"><img class="pass" src="'. $strAvatar .'">'.$name.'<b class="colGreen fR">审批完成(' . date('Y-m-d', $value['audittime']) . ')</b></div>';
  365. }
  366. if ($value['mastatus'] == 'checkno') {
  367. $statushtml = '<div class="approvalImg"><img class="unpass" src="'. $strAvatar .'">'.$name.'<b class="colRed fR">审批不通过(' . date('Y-m-d', $value['audittime']) . ')</b></div>';
  368. }
  369. $auditUserArray[$key]['statushtml'] = $statushtml;
  370. }
  371. $strAvatar = $this->auth->getAvatar($measureArray['uid']);
  372. $orginArrayname = $this->profile->getProWithUid($measureArray['uid'])['name'];
  373. $attfileArray = $this->attfile->getFirstFile($lastRowArray['pmid'], $lastRowArray['numpname'], $lastRowArray['times']);
  374. $orginArray['time'] = date('Y-m-d', $attfileArray['intime']);
  375. $orginArray['statushtml'] = '<div class="approvalImg"><img class="pass" src="'. $strAvatar .'">'.$orginArrayname.'<b class="colGreen fR">原报上报(' . $orginArray['time'] . ')</b></div>';
  376. $this->data['auditArray'] = $auditUserArray;
  377. $this->data['orginArray'] = $orginArray;
  378. $this->data['uid'] = $_GET['uid'];
  379. $this->data['pmid'] = $this->params['pmid'];
  380. $this->data['pid'] = $this->params['pid'];
  381. $this->data['mpid'] = $numStatusArray['mpid'];
  382. $this->render('r-project-section-detail-APP', $this->data, TRUE);
  383. }else{
  384. exit('error:无参数无法访问本页');
  385. }
  386. }
  387. public function getSignPic(){
  388. if(isset($_POST['uid']) && is_numeric($_POST['uid'])){
  389. $userArray = $this->profile->getProWithUid($_POST['uid']);
  390. if(!empty($userArray)){
  391. $signPic = $userArray['signpath'];
  392. $status = array('status' => TRUE, 'msg' => '', 'signpic' => Doo::conf()->APP_URL . $signPic);
  393. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  394. die();
  395. }
  396. }
  397. $status = array('status' => FALSE, 'msg' => '参数有误');
  398. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  399. die();
  400. }
  401. public function uploadSignPic(){
  402. if(isset($_POST['uid']) && is_numeric($_POST['uid']) && isset($_POST['signbase64'])){
  403. $userArray = $this->profile->getProWithUid($_POST['uid']);
  404. if(!empty($userArray)){
  405. $img = base64_decode($_POST['signbase64']);
  406. $dir = 'global/signpath';
  407. $fileName = date("YmdHis") . '_' . floor(microtime() * 1000) . '_' . self::createRandomCode(8);
  408. $virtualPath = "$dir/php_sign_$fileName.jpg";
  409. $a = file_put_contents(Doo::conf()->SITE_PATH .$virtualPath,$img);
  410. // move_uploaded_file($_FILES['sign']["tmp_name"], Doo::conf()->SITE_PATH .$virtualPath);
  411. if($a){
  412. $this->profile->setSignPath($this->params['uid'], $virtualPath);
  413. $status = array('status' => TRUE, 'msg' => '');
  414. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  415. die();
  416. }else{
  417. $status = array('status' => FALSE, 'msg' => '上传签名照失败');
  418. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  419. die();
  420. }
  421. }
  422. }
  423. $status = array('status' => FALSE, 'msg' => '参数有误');
  424. echo json_encode($status, JSON_UNESCAPED_UNICODE);
  425. die();
  426. }
  427. //二维数组去掉重复值 并保留键值
  428. function array_unique_fb($array2D)
  429. {
  430. $key = array();
  431. foreach ($array2D as $k => $v) {
  432. if (empty($key))
  433. $key = array_keys($v); //记录数组的KEY
  434. $v = join(",", $v); //降维,也可以用implode,将一维数组转换为用逗号连接的字符串
  435. $temp[$k] = $v;
  436. }
  437. $temp = array_unique($temp); //去掉重复的字符串,也就是重复的一维数组
  438. foreach ($temp as $k => $v) {
  439. $array = explode(",", $v); //再将拆开的数组重新组装
  440. foreach ($array as $i => $t) {
  441. $temp2[$k] = !empty($temp2[$k]) ? array_merge($temp2[$k], array("{
  442. $key[$i]}" => $t)) : array("{
  443. $key[$i]}" => $t); //依次添加到新的数组中去
  444. }
  445. }
  446. return $temp2;
  447. }
  448. function unique_arr($array2D, $stkeep = false, $ndformat = true)
  449. {
  450. // 判断是否保留一级数组键 (一级数组键可以为非数字)
  451. if ($stkeep)
  452. $stArr = array_keys($array2D);
  453. // 判断是否保留二级数组键 (所有二级数组键必须相同)
  454. if ($ndformat)
  455. $ndArr = array_keys(end($array2D));
  456. //降维,也可以用implode,将一维数组转换为用逗号连接的字符串
  457. foreach ($array2D as $v) {
  458. $v = join(",", $v);
  459. $temp[] = $v;
  460. }
  461. //去掉重复的字符串,也就是重复的一维数组
  462. $temp = array_unique($temp);
  463. //再将拆开的数组重新组装
  464. foreach ($temp as $k => $v) {
  465. if ($stkeep)
  466. $k = $stArr[$k];
  467. if ($ndformat) {
  468. $tempArr = explode(",", $v);
  469. foreach ($tempArr as $ndkey => $ndval) {
  470. $output[$k][$ndArr[$ndkey]] = $ndval;
  471. }
  472. } else {
  473. $output[$k] = explode(",", $v);
  474. }
  475. }
  476. return $output;
  477. }
  478. /**
  479. * 。
  480. * 标段ID,期号
  481. */
  482. private function __auditNotice($mobile, $text)
  483. {
  484. $smsSwitch = $this->aconfig->getOne(array('select' => 'smsSwitch', 'asArray' => TRUE))['smsSwitch'];
  485. if ($smsSwitch > 0)
  486. return $this->sms->sendSms($mobile, $text);
  487. }
  488. function upfile($fildname, $param = 'doc, docx, xls, xlsx, png, zip')
  489. {
  490. return $this->att->uploadMut($fildname, $param);
  491. }
  492. function upItemFile($fildname, $param = 'doc, docx, xls, xlsx, png, zip')
  493. {
  494. $this->att->setUploadDir();
  495. return $this->att->uploadMut($fildname, $param);
  496. }
  497. /**
  498. * 根据标段ID获取标段是否已经被删除的提示
  499. * 标段ID
  500. */
  501. public function getCountPmid()
  502. {
  503. if (isset($this->params['tenderid'])) {
  504. $isexist = $this->actmeasure->getCountPmid($this->params['tenderid']);
  505. if ($isexist > 0) {
  506. echo json_encode(array('status' => TRUE, 'msg' => '', 'info' => null), JSON_UNESCAPED_UNICODE);
  507. die();
  508. } else {
  509. echo json_encode(array('status' => 'FALSE', 'msg' => '该项目[XXX]在云端已被删除,点击“确定”后,可手动删除该项目'), JSON_UNESCAPED_UNICODE);
  510. die();
  511. }
  512. } else {
  513. $this->msg(0, '获取标段是否存在参数错误');
  514. }
  515. }
  516. function getFileupErrorNo()
  517. {
  518. return $this->att->error();
  519. }
  520. function Signout()
  521. {
  522. session_destroy();
  523. }
  524. function isLoggedIn()
  525. {
  526. return isset($_SESSION['user_id']);
  527. }
  528. function generateFormHash($salt)
  529. {
  530. $hash = md5(mt_rand(1, 1000000) . $salt);
  531. $_SESSION['csrf_hash'] = $hash;
  532. return $hash;
  533. }
  534. function isValidFormHash($hash)
  535. {
  536. return $_SESSION['csrf_hash'] === $hash;
  537. }
  538. /**
  539. * 随机字符串函数
  540. * @param $password 密码
  541. * @param $random 随机数
  542. */
  543. function random($length, $chars = '0123456789')
  544. {
  545. $hash = '';
  546. $max = strlen($chars) - 1;
  547. for ($i = 0; $i < $length; $i++) {
  548. $hash .= $chars[mt_rand(0, $max)];
  549. }
  550. return $hash;
  551. }
  552. /**
  553. * 生成随机字符串
  554. * @param string $lenth 长度
  555. * @return string 字符串
  556. */
  557. function create_randomstr($lenth = 6)
  558. {
  559. return $this->random($lenth, '123456789abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ');
  560. }
  561. function dir_create($path, $mode = 0777)
  562. {
  563. if (is_dir($path))
  564. return TRUE;
  565. $path = $this->dir_path($path);
  566. $parent = dirname($path);
  567. if (!is_dir($parent))
  568. @mkdir($parent, 0777, true);
  569. @mkdir($path, 0777, true);
  570. return is_dir($path);
  571. }
  572. function dir_path($path)
  573. {
  574. $path = str_replace('\\', '/', $path);
  575. if (substr($path, -1) != '/')
  576. $path = $path . '/';
  577. return $path;
  578. }
  579. function msg($isTrue = 0, $msg = null, $retmsg = null)
  580. {
  581. if ($isTrue > 0) {
  582. echo json_encode(array('status' => 'TRUE', 'msg' => ''), JSON_UNESCAPED_UNICODE);
  583. die();
  584. } else {
  585. echo json_encode(array('status' => 'FALSE', 'msg' => $msg), JSON_UNESCAPED_UNICODE);
  586. die();
  587. }
  588. }
  589. /* * ************************************************************
  590. * 生成指定长度的随机码。
  591. * @param int $length 随机码的长度。
  592. * @access public
  593. * ************************************************************ */
  594. function createRandomCode($length)
  595. {
  596. $randomCode = "";
  597. $randomChars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  598. for ($i = 0; $i < $length; $i++) {
  599. $randomCode .= $randomChars{mt_rand(0, 35)};
  600. }
  601. return $randomCode;
  602. }
  603. // function checkVersion($version)
  604. // {
  605. // preg_match();
  606. // }
  607. }
  608. ?>