PageRenderTime 46ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/index/controller/enterp/send_interview.php

https://github.com/pennsong/ShiyishiWeb
PHP | 397 lines | 343 code | 22 blank | 32 comment | 51 complexity | 99bf2c0e78d462cbfbd961deb0267e91 MD5 | raw file
  1. <?php
  2. //企业面试
  3. class send_interview_Controller extends Controller{
  4. function init(){
  5. $this->logininfo = F::logininfo("enterp");
  6. $this->logincheck("enterp");
  7. $this->myjob_int = Load::model('myjob_int');
  8. $this->app_video_interview = Load::model('app_video_interview');
  9. $this->app_person_interview = Load::model('app_person_interview');
  10. $this->resume = Load::model('resume');
  11. $this->resume_tmp = Load::model('resume_tmp');
  12. $this->e_user = Load::model('e_user');
  13. $this->jobs = Load::model('jobs');
  14. $this->resume_box = Load::model('resume_box');
  15. $this->resume_download = Load::model('resume_download');
  16. //uname
  17. $this->uid = $this->logininfo['uid'];
  18. $this->conf_db = Load::conf('db');
  19. $this->dbpre = $this->conf_db['default']['prefix'];
  20. $this->conf = Load::conf('conf');
  21. $this->vodrooms = $this->conf['vodrooms'];
  22. }
  23. /*
  24. <li><span class="glogintext">联系人:</span><!--{$e_user.contact}--></li>
  25. <li><span class="glogintext">联系电话:</span><!--{$e_user.tel}--></li>
  26. <li><span class="glogintext">地址:</span>><!--{$e_user.address}--></li>
  27. */
  28. function indexAction(){
  29. //error_reporting(E_ALL);
  30. $id = $this->_get('id');
  31. $aid = $this->_get('aid',0);
  32. if($aid){
  33. $app = $this->app_video_interview->find($aid);
  34. if(!isset($app['id'])){
  35. $aid=0;
  36. }
  37. if(isset($app['status']) && $app['status']){
  38. $aid=0;
  39. }
  40. }
  41. if(!$id){
  42. $PositionID = $this->_get('interview');
  43. if($PositionID){
  44. $PositionID = explode(",",$PositionID);
  45. $this->assign('interview_arr',$PositionID);
  46. $id = array();
  47. if(count($PositionID)>1){
  48. $str = implode(",",$PositionID);
  49. }else{
  50. $str = $PositionID[0];
  51. }
  52. $resume_box = $this->resume_download->fetchAll(' cid='.$this->uid.' and id in ('.$str.')');
  53. foreach($resume_box as $k => $v){
  54. $id[] = $v['rid'];
  55. }
  56. }else{
  57. $str = $this->_get('str');
  58. $id = explode(",",$str);
  59. $this->assign('interview_arr',$id);
  60. }
  61. }
  62. if($id){
  63. $ids = implode(",",$id);
  64. $download = $this->resume_download->fetchAll("cid = ".$this->uid." and rid in ( ".$ids.") ");
  65. if(count($download) == count($id)){
  66. //$interview = $this->app_video_interview->fetchAll( time().' <= starttime and status = 0 and cid = '.$this->uid);
  67. $resume = $this->resume->fetchAll(' id in ('.$ids.') ');
  68. $jobs = $this->jobs->fetchAll(" cid = ".$this->uid);
  69. $e_user = $this->e_user->find($this->uid);
  70. for($i=0;$i<24;$i++){
  71. if($i<10){
  72. $j = "0".$i;
  73. }else{
  74. $j = $i;
  75. }
  76. for($x=0;$x<60;$x=$x+15){
  77. if($x<10){
  78. $n = "0".$x;
  79. }else{
  80. $n = $x;
  81. }
  82. $time[] = $j.":".$n;
  83. }
  84. }
  85. if($aid){
  86. // $tmp = array();
  87. // foreach($resume as $key => $val){
  88. // $tmp[] = $val['uid'];
  89. // }
  90. // $uids = implode(",",$tmp);
  91. $pidrows = $this->app_person_interview->fetchAll(' aid = '.$aid.' ');
  92. foreach($pidrows as $key => $val){
  93. $pidrows[$key]['startdate_p'] = date('Y-m-d',$val['starttime']);
  94. $pidrows[$key]['starttime_p'] = date('H:i',$val['starttime']);
  95. $pidrows[$key]['enddate_p'] = date('Y-m-d',$val['endtime']);
  96. $pidrows[$key]['endtime_p'] = date('H:i',$val['endtime']);
  97. }
  98. $app['startdate'] = date('Y-m-d',$app['starttime']);
  99. $app['starttime'] = date('H:i',$app['starttime']);
  100. $app['enddate'] = date('Y-m-d',$app['endtime']);
  101. $app['endtime'] = date('H:i',$app['endtime']);
  102. //print_r($pidrows);exit;
  103. $this->assign('app',$app);
  104. $this->assign('pidrows',$pidrows);
  105. }
  106. //$this->_forward('list');
  107. $this->assign('resume',$resume);
  108. $this->assign('e_user',$e_user);
  109. $this->assign('time',$time);
  110. $this->assign('jobs',$jobs);
  111. $this->assign('ids',$ids);
  112. $this->assign('aid',$aid);
  113. $this->assign('day',date('Y-m-d'));
  114. $this->display('send_interview.tpl');
  115. }else{
  116. $this->showmsg("非法操作",BASE_URL."/enterp/resume/downlist.html");
  117. }
  118. }else{
  119. $this->showmsg("非法操作",BASE_URL."/enterp/resume/downlist.html");
  120. }
  121. }
  122. function saveAction(){
  123. //error_reporting(E_ALL);
  124. $info = $this->_get('info');
  125. $starttime = $this->_get('starttime');
  126. $endtime = $this->_get('endtime');
  127. $startdate = $this->_get('startdate');
  128. $enddate = $this->_get('enddate');
  129. $info['interview_date'] = strtotime($startdate." ".$starttime);
  130. $interview['starttime'] = strtotime($startdate." ".$starttime.":00");
  131. $interview['endtime'] = strtotime($enddate." ".$endtime.":00");
  132. $info['interview_enddate'] = $interview['endtime'];
  133. if($interview['endtime'] > $interview['starttime']){
  134. $interview['cid'] = $this->uid;
  135. $interview['status'] = 0;
  136. $aid = intval($this->_get('aid',0));
  137. if(!$aid){
  138. //$interview['createtime'] = '';
  139. $s = $this->app_video_interview->fetchRow( $interview['starttime'].' > starttime and endtime > '.$interview['starttime']." and status < 2 and cid = ".$interview['cid']);
  140. $e = $this->app_video_interview->fetchRow( $interview['endtime'].' > starttime and endtime > '.$interview['endtime']." and status < 2 and cid = ".$interview['cid']);
  141. $o = $this->app_video_interview->fetchRow( $interview['endtime'].' > endtime and starttime > '.$interview['starttime']." and status < 2 and cid = ".$interview['cid']);
  142. // echo $interview['starttime'].' > starttime and endtime > '.$interview['starttime']." and status = 1 and cid = ".$interview['cid'];echo"|";
  143. // echo $interview['endtime'].' > starttime and endtime > '.$interview['endtime']." and status = 1 and cid = ".$interview['cid'];echo"|";
  144. // echo $interview['endtime'].' > endtime and starttime > '.$interview['starttime']." and status = 1 and cid = ".$interview['cid'];
  145. // exit;
  146. }
  147. if($s || $e || $o){
  148. $str = "该时间段您已经申请";
  149. $this->showmsg($str,BASE_URL."/enterp/resume/downlist.html");
  150. }else{
  151. if($aid){
  152. $app = $this->app_video_interview->find($aid);
  153. if(!isset($app['id'])){
  154. $aid=0;
  155. }
  156. if(isset($app['status']) && $app['status']){
  157. $aid=0;
  158. }
  159. }
  160. $okrooms = array();
  161. //验证是否还有空闲房间
  162. $arows = $this->app_video_interview->fetchAll($interview['endtime'].' > starttime and endtime > '.$interview['starttime']." and status = 1 ");
  163. if(!empty($arows)){
  164. foreach($arows as $ar){
  165. $okrooms[] = $ar['room'];
  166. }
  167. }
  168. if($okrooms){
  169. $vodrooms = array_diff($this->vodrooms,$okrooms);
  170. }else{
  171. $vodrooms = $this->vodrooms;
  172. }
  173. //print_r($vodrooms);exit;
  174. if(!empty($vodrooms)){
  175. //$info['room'] = $vodrooms[0];
  176. $interview['room'] = "";
  177. if($aid){
  178. $interview['id'] = $aid;
  179. }
  180. //print_r($interview);exit;
  181. if(($aid=$this->app_video_interview->save($interview)) === false){
  182. $this->showmsg($this->user->getError(),1);
  183. }
  184. $pidrows = array();
  185. if(isset($interview['id'])){
  186. $aid = $interview['id'];
  187. $pidrows = $this->app_person_interview->fetchAll(' aid = '.intval($aid));
  188. // foreach($pidrows as $key => $val){
  189. // $this->app_person_interview->remove($val['id']);
  190. // }
  191. $query = "delete from ".$this->dbpre."app_person_interview where aid= ".$aid." ";
  192. $this->resume->queryAll($query);
  193. $query = "delete from ".$this->dbpre."myjob_int where aid= ".$aid." and eid = ".$this->uid." ";
  194. $this->resume->queryAll($query);
  195. }
  196. $gender = substr($info['gender'] ,0,-1);
  197. $genders = explode(',',$gender);
  198. $uid = $this->_get('uid','');
  199. $uid = substr($info['uid'],0,-1);
  200. $uids = explode(',',$uid);
  201. $starttime_p = $this->_get('starttime_p');
  202. $endtime_p = $this->_get('endtime_p');
  203. $startdate_p = $this->_get('startdate_p');
  204. $enddate_p = $this->_get('enddate_p');
  205. //print_r($starttime_p);print_r($endtime_p);
  206. foreach($uids as $k => $v){
  207. $info['uid'] = $uids[$k];
  208. $info['aid'] = $aid;
  209. $info['status'] = -1;
  210. $info['gender'] = $genders[$k];
  211. if(($uid = $this->myjob_int->save($info)) === false){
  212. $this->showmsg($this->myjob_int->getError(),1);
  213. }
  214. if($aid){
  215. $ainfo['starttime'] = strtotime($startdate_p[$k]." ".$starttime_p[$k].":00");
  216. $ainfo['endtime'] = strtotime($enddate_p[$k]." ".$endtime_p[$k].":00");
  217. if($ainfo['starttime']<$interview['starttime'] || $ainfo['starttime']>$interview['endtime']){
  218. $ainfo['starttime'] = $interview['starttime'];
  219. }
  220. if($ainfo['endtime']<$interview['starttime'] || $ainfo['endtime']>$interview['endtime']){
  221. $ainfo['endtime'] = $interview['endtime'];
  222. }
  223. $ainfo['uid'] = $uids[$k];
  224. $ainfo['aid'] = $aid;
  225. if(($pid = $this->app_person_interview->save($ainfo)) === false){
  226. $this->showmsg($this->app_person_interview->getError(),1);
  227. }
  228. }
  229. }
  230. $str = "申请已提交,请耐心等待";
  231. }else{
  232. $str = "该时间段已无空闲视频房间";
  233. }
  234. $this->showmsg($str,BASE_URL."/enterp/resume/downlist.html");
  235. }
  236. }else{
  237. $str = "内容填写错误";
  238. $this->showmsg($str,BASE_URL."/enterp/resume/downlist.html");
  239. }
  240. }
  241. function editAction(){
  242. $id = intval($this->_get('id',0));
  243. if($id){
  244. $myjob_int = $this->myjob_int->fetchRow(' eid = '.$this->uid." and id=".$id);
  245. if(isset($myjob_int['id']) && $myjob_int['id']){
  246. $interview = $this->app_video_interview->fetchAll( time().' >= starttime and endtime > '.time()." and status = 1 and cid = ".$this->uid);
  247. $resume = $this->resume->fetchAll(' uid = '.$myjob_int['uid']);
  248. $jobs = $this->jobs->fetchAll(" cid = ".$this->uid);
  249. $e_user = $this->e_user->find($this->uid);
  250. for($i=0;$i<24;$i++){
  251. if($i<10){
  252. $j = "0".$i;
  253. }else{
  254. $j = $i;
  255. }
  256. for($x=0;$x<60;$x=$x+15){
  257. if($x<10){
  258. $n = "0".$x;
  259. }else{
  260. $n = $x;
  261. }
  262. $time[] = $j.":".$n;
  263. }
  264. }
  265. //$this->_forward('list');
  266. $this->assign('resume',$resume);
  267. $this->assign('e_user',$e_user);
  268. $this->assign('time',$time);
  269. $this->assign('jobs',$jobs);
  270. $this->assign('info',$myjob_int);
  271. $this->assign('interview',$interview);
  272. $this->assign('startdate',date("Y-m-d",$myjob_int['interview_date']));
  273. $this->assign('starttime',date("H:i",$myjob_int['interview_date']));
  274. $this->display('send_interview.tpl');
  275. }else{
  276. $this->showmsg("非法操作",BASE_URL."/enterp/resume/downlist.html");
  277. }
  278. }else{
  279. $this->showmsg("非法操作",BASE_URL."/enterp/resume/downlist.html");
  280. }
  281. }
  282. function listAction(){
  283. if(isset($_GET['s'])){
  284. $status = intval($_GET['s']);
  285. }else{
  286. $status = 1;
  287. }
  288. $page = intval($this->_get('page',1));
  289. $url = $this->getPageUrl().'/list.html?s='.$status;
  290. $orderby = " invite_date desc ";
  291. $where .= " m.status = ".$status." and m.eid = ".$this->uid ;
  292. $sql = "select m.*,r.uname,r.gender,j.title from ".$this->dbpre."myjob_int m
  293. left join ".$this->dbpre."resume r on m.uid=r.uid
  294. left join ".$this->dbpre."jobs j on m.jobid=j.id
  295. where ".$where." order by ".$orderby;
  296. $total = count($this->resume_tmp->queryAll($sql));
  297. $n=25;
  298. $sql .= " limit ".(($page-1)*$n).", ".$n." ";
  299. $rows = $this->resume_tmp->queryAll($sql);
  300. $totalpage = @ceil($total / $n);
  301. $this->assign('totalpage',$totalpage);
  302. $this->assign('url',$url);
  303. $this->assign('total',$total);
  304. $this->assign('page',$page);
  305. $this->assign('s',$status);
  306. $this->assign('send_interview',$rows);
  307. $this->display('send_interview_list.tpl');
  308. }
  309. function delAction(){
  310. $PositionID = $this->_get('PositionID',0);
  311. $table = "myjob_int";
  312. if($PositionID){
  313. if(is_array($PositionID)){
  314. $ids=implode(",",$PositionID);
  315. $sql="update ".$this->dbpre.$table." set status=0 where id in (".$ids.") ";
  316. $rows = $this->resume_tmp->queryAll($sql);
  317. }else{
  318. $sql="update ".$this->dbpre.$table." set status=0 where id=".$PositionID." ";
  319. $rows = $this->resume_tmp->queryAll($sql);
  320. }
  321. $this->showmsg("操作成功",BASE_URL."/enterp/send_interview/list.html");
  322. }else{
  323. $this->showmsg("非法操作",BASE_URL."/enterp/send_interview/list.html");
  324. }
  325. }
  326. function passAction(){
  327. $PositionID = $this->_get('PositionID',0);
  328. $table = "myjob_int";
  329. if($PositionID){
  330. if(is_array($PositionID)){
  331. $ids=implode(",",$PositionID);
  332. $sql="update ".$this->dbpre.$table." set status=1 where id in (".$ids.") ";
  333. $rows = $this->resume_tmp->queryAll($sql);
  334. }else{
  335. $sql="update ".$this->dbpre.$table." set status=1 where id=".$PositionID." ";
  336. $rows = $this->resume_tmp->queryAll($sql);
  337. }
  338. $this->showmsg("操作成功",BASE_URL."/enterp/send_interview/list.html");
  339. }else{
  340. $this->showmsg("非法操作",BASE_URL."/enterp/send_interview/list.html");
  341. }
  342. }
  343. function videolistAction(){
  344. $url = $this->getPageUrl().'/list.html';
  345. $orderby = " invite_date desc ";
  346. $where .= " m.status = 1 and m.eid = ".$this->uid ;
  347. $sql = "select m.*,r.uname,r.gender,j.title from ".$this->dbpre."myjob_int m
  348. left join ".$this->dbpre."resume r on m.uid=r.uid
  349. left join ".$this->dbpre."jobs j on m.jobid=j.id
  350. where ".$where." order by ".$orderby;
  351. $rows = $this->resume_tmp->queryAll($sql);
  352. $interview = $this->app_video_interview->fetchAll( " status = 1 and cid = ".$this->uid);
  353. $tmp = array();
  354. if($rows){
  355. foreach($rows as $key => $val){
  356. foreach($interview as $k => $v){
  357. //echo APP_DATA_DIR."/vods/".$v['id']."_".$val['id'].".flv";
  358. if(file_exists(APP_DATA_DIR."/vods/".$v['id']."_".$val['id'].".flv")){
  359. $val['vid'] = $v['id']."_".$val['id'];
  360. $tmp[] = $val;
  361. }
  362. }
  363. }
  364. }
  365. $this->assign('recode_video',$tmp);
  366. $this->display('recode_video_list.tpl');
  367. }
  368. function videoAction(){
  369. $id = $this->_get('id','');
  370. $this->assign('video',$id.".flv");
  371. $this->assign('video_domain',"http://video.channelwin.info/");
  372. $this->display('recode_video.tpl');
  373. }
  374. }
  375. ?>