Guest User

Untitled

a guest
Aug 12th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.65 KB | None | 0 0
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3.  
  4. class Project extends CI_Controller {
  5.  
  6. /**
  7. * Index Page for this controller.
  8. *
  9. * Maps to the following URL
  10. * http://example.com/index.php/welcome
  11. * - or -
  12. * http://example.com/index.php/welcome/index
  13. * - or -
  14. * Since this controller is set as the default controller in
  15. * config/routes.php, it's displayed at http://example.com/
  16. *
  17. * So any other public methods not prefixed with an underscore will
  18. * map to /index.php/welcome/<method_name>
  19. * @see https://codeigniter.com/user_guide/general/urls.html
  20. */
  21. public function Project(){
  22. parent::__construct();
  23. $this->load->Model('projects');
  24. $this->load->Model('clients');
  25. $this->load->library("pagination");
  26.  
  27.  
  28.  
  29. }
  30.  
  31. // Function Name : index();
  32. // Function Work : use for get project list and add new project.
  33. // Function Input : Send array (array include all fields value).
  34. // Function Output : Return true and false value (true if record added and false if error occur) and return project list.
  35.  
  36.  
  37. public function index() {
  38. $result = '';
  39. $result['employeeDesignation'] = getallEmployeeDesignation();
  40. $result['resourcesFrom'] = getallClientResources();
  41. $result['ProjectTehnology'] = getallProjectTehnology();
  42. $result['ProjectSource'] = getallProjectSource();
  43. $result['ProjectCategory'] = getallProjectCategory();
  44. $result['ProjectStatus'] = getallProjectStatus();
  45. $result['ProjectCurrency'] = getallProjectCurrency();
  46. $result['getallClients'] = getallClients();
  47.  
  48. $result['message'] = 'non';
  49.  
  50. if ($_SERVER['REQUEST_METHOD'] === 'POST' && !$this->input->post('ajax')) {
  51.  
  52. $userid = $this->session->userdata('userId');
  53. $startDate = date('Y-m-d', strtotime($_POST['startDate']));
  54. $estimateEndDate = date('Y-m-d', strtotime($_POST['estimateEndDate']));
  55. //$submittedOn = date('Y-m-d', strtotime($_POST['submittedOn']));
  56. $responseClientID = $_POST['clientId'];
  57. $projectName = $_POST['projectName'];
  58. $projectNm = substr($projectName, 0, 22);
  59. $stringProjectNm = preg_replace('/\s+/', '', $projectNm);
  60. $projectImageNm = trim(strtolower($stringProjectNm));
  61. if(!empty($_FILES)) {
  62. $this->load->library('upload');
  63. $files = $_FILES;
  64. foreach($files['fileName']['name'] as $key=>$val){
  65. $this->upload->initialize($this->set_upload_options());
  66. $_FILES['fileName']['name'] = $val;
  67. $_FILES['fileName']['type'] = $files['fileName']['type'][$key];
  68. $_FILES['fileName']['error'] = $files['fileName']['error'][$key];
  69. $_FILES['fileName']['tmp_name'] = $files['fileName']['tmp_name'][$key];
  70. $_FILES['fileName']['size'] = $files['fileName']['size'][$key];
  71. $this->upload->do_upload('fileName');
  72. $data = $this->upload->data();
  73. $projectFilesData[] = $data['file_name'];
  74. }
  75.  
  76. }
  77. if(isset($_POST['include_sat'])){
  78. $includesat = ($_POST['include_sat'] == 1 ? '1' : '0');
  79. }else{
  80. $includesat = 0;
  81. }
  82. $ProjectDetail = array(
  83. 'projectName' => $_POST['projectName'],
  84. 'clientReporting' => $_POST['clientReporting'],
  85. 'clientId' => $responseClientID,
  86. 'category' => $_POST['category'],
  87. 'technologyUsed' => array_values(array_filter($_POST['technologyUsed'])),
  88. 'startDate' => $startDate,
  89. 'estimateEndDate' => $estimateEndDate,
  90. 'projectStatus' => $_POST['projectStatus'],
  91. 'requirements' => $_POST['requirements'],
  92. 'description' => $_POST['description'],
  93. 'projectsource' => $_POST['projectsource'],
  94. 'projectType' => $_POST['projectType'],
  95. 'amount' => $_POST['amount'],
  96. 'projectCurrency' => $_POST['projectCurrency'],
  97. 'day_hour' => $_POST['day_hour'],
  98. 'working_hours' => $_POST['working_hours'],
  99. 'include_sat' => $includesat,
  100. 'createdDate' => date('Y-m-d'),
  101. 'added_by' => $userid,
  102. //'submittedOn' => $submittedOn,
  103. 'status' => 1
  104. );
  105. $record['projectData'] = $ProjectDetail;
  106. $resultdata = $this->projects->addProject($record['projectData']);
  107. $getPasredData = json_decode($resultdata,true);
  108. if($getPasredData['result'] == 'true' && $_POST['employeesID'] != ''){
  109. $projectEmployees = array(
  110. 'projectID'=>$getPasredData['id'],
  111. 'projectEmpID'=>array_values(array_filter($_POST['employeesID'])),
  112. 'Status'=>1,
  113. 'CreatedOn'=>date('Y-m-d')
  114. );
  115. $this->projects->addProjectEmployee($projectEmployees);
  116. $this->projects->addProjectFiles($getPasredData['id'],$responseClientID,$projectFilesData);
  117. }
  118.  
  119. }
  120. $totalRec = $this->projects->getCountprojects();
  121. $result['page'] = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
  122. $result['projectList'] = $this->projects->getAllProjects(5, $result['page']);
  123.  
  124. $result['links'] = getPagination(site_url('project/index'),5,$totalRec,0);
  125. if($this->input->post('ajax')) {
  126. $outout['links'] = $result['links'];
  127. $outout['html'] = $this->load->view('project/project_pagination',$result,true);
  128. echo json_encode($outout);exit;
  129. }
  130. else {
  131. $this->load->view('project/index',$result);
  132. }
  133.  
  134. }
  135.  
  136. // Function Name : getAllClient();
  137. // Function Work : use for get all clients.
  138. // Function Input : Send nothing.
  139. // Function Output : Return client list.
  140.  
  141. private function set_upload_options(){
  142. $config = array();
  143. $config['upload_path'] = 'assets/img/projectFiles';
  144. $config['allowed_types'] = '*';
  145. $config['max_size'] = '0';
  146. $config['overwrite'] = FALSE;
  147. $config['encrypt_name'] = TRUE;
  148. return $config;
  149. }
  150.  
  151. public function showupdateProjectpopup() {
  152. if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  153. $id = $this->input->post('currentVal');
  154. $id = $this->encrypt->decode($id);
  155. if (!empty($id)) {
  156. $result['page'] = 'update_project';
  157. $result['title'] = 'Update Project';
  158. $result['employeeDesignation'] = getallEmployeeDesignation();
  159. $result['resourcesFrom'] = getallClientResources();
  160. $result['ProjectTehnology'] = getallProjectTehnology();
  161. $result['ProjectSource'] = getallProjectSource();
  162. $result['ProjectCategory'] = getallProjectCategory();
  163. $result['ProjectStatus'] = getallProjectStatus();
  164. $result['ProjectCurrency'] = getallProjectCurrency();
  165. $result['getallClients'] = getallClients();
  166. $result['projectDetails'] = $this->getProjectDetail($id);
  167. $this->load->view('project/updateProject', $result);
  168. }
  169. }
  170. }
  171.  
  172.  
  173. public function getAllEmployee(){
  174. $output = $this->projects->getAllEmployees($_POST['currentVal']);
  175. echo json_encode($output);exit;
  176. }
  177.  
  178. public function searchEmployeeforProjects(){
  179. $output = $this->projects->searchEmployeeforProjects($_POST['currentVal'],$_POST['previousEmployeesID']);
  180. echo json_encode($output);exit;
  181. }
  182.  
  183. // Function Name : getAllClient();
  184. // Function Work : use for get all clients.
  185. // Function Input : Send nothing.
  186. // Function Output : Return client list.
  187.  
  188. public function getAllClient(){
  189. $output = $this->projects->getAllClients($_POST['currentVal']);
  190. echo json_encode($output);exit;
  191. }
  192.  
  193.  
  194. // Function Name : getProjectDetail();
  195. // Function Work : use for get project detail.
  196. // Function Input : Send project id.
  197. // Function Output : Return project detail.
  198.  
  199. public function getProjectDetail($id){
  200. $output = $this->projects->projectDetail($id);
  201. if(!empty($output))
  202. {
  203. // $cilentID = $output[0]->clientId;
  204. // $infoClient = getallclientsInfo($cilentID);
  205. // $clientFirstname = $infoClient['firstName'].' '.$infoClient['lastName'];
  206. // $output[0]->clientId = $cilentID.'/'.$clientFirstname;
  207. $newval = array();
  208. $newval = explode(',',$output[0]->technologyUsed);
  209. $output[0]->technologyUsed = $newval;
  210. }
  211. //echo json_encode($output);exit;
  212. return $output[0];
  213. }
  214.  
  215. // Function Name : updateProject();
  216. // Function Work : use for update project detail.
  217. // Function Input : Send project id.
  218. // Function Output : Return true and false value (true if record updated and false if error occur).
  219.  
  220. public function updateProject(){
  221. //print_r($_POST);die;
  222. $output = $this->projects->updateprojectDetail($_POST['userDetail'],$_POST['projectId']);
  223. if(isset($_POST['projectEmployeeID']) && ($_POST['projectEmployeeID'] !='')){
  224. $projectEmployees = array(
  225. 'projectID'=>$_POST['projectId'],
  226. 'projectEmpID'=>array_values(array_filter($_POST['projectEmployeeID']['employeesID'])),
  227. 'Status'=>1,
  228. );
  229. $this->projects->addProjectEmployee($projectEmployees);
  230. }
  231. echo json_encode($output);exit;
  232. }
  233.  
  234. // Function Name : deleteProject();
  235. // Function Work : use for detele project detail.
  236. // Function Input : Send project id.
  237. // Function Output : Return true and false value (true if record updated and false if error occur).
  238.  
  239. // public function deleteProject(){
  240. // $output = $this->projects->delProjectDetail($_POST['currentDelId']);
  241. // echo json_encode($output);exit;
  242. // }
  243.  
  244. public function deleteProject(){
  245. if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  246. $id = $_POST['currentDelId'];
  247. $currentDelId = $this->encrypt->decode($id);
  248. $ProjectDetail = array(
  249. 'status' => 2
  250. );
  251. $record['Project'] = $ProjectDetail;
  252. $response = $this->projects->delProjectDetail($currentDelId,$record['Project']);
  253. if($response == 1){
  254. echo 'yes';
  255. }else{
  256. echo 'no';
  257. }
  258. } else {
  259. //show_404();
  260. }
  261. }
  262.  
  263.  
  264. //Ajax Search function(Serach,Pagination,Sorting)
  265. public function getProjectSearchData(){
  266. $keywords = $_POST['keywords'];
  267. $orderby = $_POST['keyword_order'];
  268. $sortbyname = $_POST['sortbyname'];
  269. $result['page'] = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
  270. $totalRec = count($this->projects->getProjectSearchedkeyword($keywords,null,null,null, $result['page']));
  271. $result['projectList'] = $this->projects->getProjectSearchedkeyword($keywords,$orderby,$sortbyname,5,$result['page']);
  272. $result['links'] = getPagination(site_url('project/getProjectSearchData'), 5, $totalRec,1);
  273. $outout['html'] = $this->load->view('project/project_pagination',$result,true);
  274. echo json_encode($outout);exit;
  275.  
  276. }
  277.  
  278. public function getAjaxProjectSearchData(){
  279. if($this->input->is_ajax_request()){
  280. $search = array(
  281. 'projectName' => $_POST['projectName'],
  282. 'clientId' => $_POST['clientId'],
  283. 'projectStatus' => $_POST['ProjectStatus'],
  284. 'status' => $_POST['status_p']
  285. );
  286. $result['page'] = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
  287. $totalRec = count($this->projects->getAjaxProjectSearchedkeyword($search,null,$result['page']));
  288. $result['projectList'] = $this->projects->getAjaxProjectSearchedkeyword($search,5,$result['page']);
  289. $result['links'] = getPagination(site_url('project/getAjaxProjectSearchData'), 5, $totalRec,2);
  290. $outout['html'] = $this->load->view('project/project_pagination',$result,true);
  291. echo json_encode($outout);exit;
  292. }
  293. }
  294.  
  295. public function resetProject() {
  296. $result['page'] = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
  297. $result['projectList'] = $this->projects->getAllProjects(5, $result['page']);
  298. $json = array();
  299. $total = $this->projects->getCountprojects();
  300. $json['links'] = getPagination('project/index', 5, $total,0);
  301. $json['projectList'] = $this->load->view('project/project_pagination', $result,TRUE);
  302. echo json_encode($json);
  303. exit;
  304.  
  305.  
  306.  
  307.  
  308. }
  309.  
  310.  
  311. //Get Employee Data
  312.  
  313. public function getemployeesInfo(){
  314. if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  315. $employeeDesgId = $this->input->post('employeeDesgId');
  316. $employeeLists= $this->projects->getEmployeesListfromDesgID($employeeDesgId);
  317. if($employeeLists){
  318. foreach ($employeeLists as $key => $value) {
  319. echo '<option value="' . $value['id'] . '">' . ucwords($value['firstName'].' '.$value['lastName']) . '</option>';
  320. }
  321. }else{
  322. echo "<option value=''>No Data</option>";
  323. }
  324. }
  325. }
  326.  
  327. public function getEmployeeData(){
  328. if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  329. $employeeId = $this->input->post('employeeId');
  330. $employeeLists= $this->projects->getEmployeeDetails($employeeId);
  331. echo json_encode($employeeLists);
  332. }
  333. }
  334.  
  335. public function saveCurrentData(){
  336. if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  337. $currentValue = $this->input->post('currentVal');
  338. $TypeVal = $this->input->post('TypeVal');
  339. $employeeLists= $this->projects->saveCurrentData($currentValue,$TypeVal);
  340. echo json_encode($employeeLists);
  341. }
  342. }
  343.  
  344. public function saveCurrentClientInfo(){
  345. if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  346. $_POST['createDate'] = date('Y-m-d');
  347. $newData['title'] = $this->input->post('titleC');
  348. $newData['firstName'] = $this->input->post('firstName');
  349. $newData['lastName'] = $this->input->post('lastName');
  350. $newData['emailId'] = $this->input->post('emailId');
  351. $newData['skypeId'] = $this->input->post('skypeId');
  352. $newData['contractNo'] = $this->input->post('contractNo');
  353. $newData['country'] = $this->input->post('country');
  354. $newData['source'] = $this->input->post('clientSource');
  355. $newData['status'] = '1';
  356. $newData['added_by'] = $this->session->userdata('userId');
  357. $alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789";
  358. $pass = array(); //remember to declare $pass as an array
  359. $alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
  360. for ($i = 0; $i < 8; $i++)
  361. {
  362. $n = rand(0, $alphaLength);
  363. $pass[] = $alphabet[$n];
  364. }
  365. $passwordClient = implode($pass); //turn the array into a string
  366. $resultdata = $this->clients->addClient($newData,$passwordClient);
  367. $getPasredData = json_decode($resultdata,true);
  368. if($getPasredData['results'] == 'true'){
  369. $subject = 'Login Details';
  370. $useremail = $_POST['emailId'];
  371. $data['email'] = $useremail;
  372. $data['fname'] = $_POST['firstName'];
  373. $data['password'] = $passwordClient ;
  374. $message = $this->load->view('templates/emailTemp.php',$data,TRUE);
  375. $sendEmail = array(
  376. 'Subject' => $subject,
  377. 'Message' => $message,
  378. 'To' => $useremail,
  379. 'From' => 'onewayitsolutions@gmail.com'
  380. );
  381. sendEmail($sendEmail);
  382. echo $getPasredData['lastinsertedid'];
  383. // echo "<pre>";
  384. // print_r($sendEmail);
  385. // echo "</pre>";
  386. // die();
  387.  
  388. }
  389.  
  390. }
  391. }
  392.  
  393. public function deletepEmployee(){
  394. if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  395. $pID = $this->input->post('currentVal');
  396. $delEmp= $this->projects->deleteprojectEmps($pID);
  397. echo json_encode($delEmp);
  398. }
  399.  
  400. }
  401.  
  402.  
  403. /* Upload Task for Project Section 10-08-2016 Ravinder */
  404.  
  405. public function showuploadProjecttasks_form() {
  406. if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  407. $id = $this->input->post('currentVal');
  408. $id = $this->encrypt->decode($id);
  409. if (!empty($id)) {
  410. $data['tasks_data'] = $id;
  411. $this->load->view('project/uploadFormTasks', $data);
  412. }
  413. }
  414. }
  415.  
  416.  
  417. public function upload_ProjectTasks() {
  418. $user = $this->session->userdata('user');
  419. if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  420. $projectID = $_POST['projectID'];
  421. require_once(APPPATH . 'third_party/PHPExcel.php');
  422. $file_extensions = array(
  423. '0' => '.csv',
  424. '1' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
  425. '2' => 'application/vnd.ms-excel'
  426. );
  427. $max_filesize = 2000000;
  428. if (!in_array($_FILES['file']['type'], $file_extensions)) {
  429. $msg = '<div class="alert alert-danger">';
  430. $msg .= '<i class="glyphicon glyphicon-exclamation-sign"></i>&nbsp;';
  431. $msg .= $this->lang->line('BANK_UPLOAD_FILE_ERROR');
  432. $msg .= '</div>';
  433. $this->session->set_flashdata('taskError', $msg);
  434. setRedirect('project');
  435. }
  436.  
  437. $sheet_one_column = array(
  438. '0' => 'Module',
  439. '1' => 'Tasks',
  440. '2' => 'Assigned To',
  441. '3' => 'Role',
  442. '4' => 'Estimated Hours',
  443. '5' => 'Remarks'
  444. );
  445.  
  446. // $first_sheetcount_one = count($sheet_one_column);
  447. $error_flag = 0;
  448. $first_sheet = array();
  449. $path = $_FILES['file']['tmp_name'];
  450. $inputFileType = PHPExcel_IOFactory::identify($path);
  451. $objReader = PHPExcel_IOFactory::createReader($inputFileType);
  452. $objReader->setReadDataOnly(TRUE);
  453.  
  454. /** Load $inputFileName to a PHPExcel Object * */
  455. $objPHPExcel = $objReader->load($path);
  456. $total_sheets = $objPHPExcel->getSheetCount();
  457. $allSheetName = $objPHPExcel->getSheetNames('template');
  458.  
  459. //$objPHPExcel->getActiveSheet();
  460. $objWorksheet = $objPHPExcel->setActiveSheetIndex(1);
  461. $highestRow = $objWorksheet->getHighestRow();
  462. $highestColumn = $objWorksheet->getHighestColumn();
  463. $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);
  464. $flag = 0;
  465.  
  466. $statement_data = array();
  467. for ($row = 1; $row <= $highestRow; ++$row) {
  468. for ($col = 0; $col < $highestColumnIndex; ++$col) {
  469. $value = $objWorksheet->getCellByColumnAndRow($col, $row)->getCalculatedValue();
  470. $arraydata[$row - 1][$col] = $value;
  471. }
  472.  
  473. $temp = $arraydata[$row - 1];
  474.  
  475. /* Remove empty row from the statement */
  476. if (count($temp) > 0) {
  477. $statement_data[] = $temp;
  478. }
  479. }
  480.  
  481. // $first_sheet = array_filter($statement_data);
  482. $first_sheet = array_filter($statement_data);
  483.  
  484. /* Check if first sheet is valid or not */
  485. if (!isset($first_sheet[1])) {
  486. $error_flag = 1;
  487. } else {
  488. /* Now check the columns name */
  489. foreach ($first_sheet[1] as $key => $val) {
  490. if (!in_array($val, $sheet_one_column)) {
  491. $error_flag = 1;
  492. }
  493. }
  494. }
  495.  
  496. if ($error_flag == 1) {
  497. $msg = '<div class="alert alert-danger"><i class="glyphicon glyphicon-exclamation-sign"></i>&nbsp;';
  498. $msg .= $this->lang->line('PROJECTTASK_PATTERNERROR');
  499. $msg .= '</div>';
  500. $this->session->set_flashdata('taskError', $msg);
  501. setRedirect('project');
  502. }
  503.  
  504. /* Check pattern of both the sheets */
  505. if (count($first_sheet[2]) != count($sheet_one_column)) {
  506. $error_flag = 1;
  507. }
  508.  
  509. $item_data= array(
  510. 'ProjectTaskDetails' => array_slice($first_sheet, 2)
  511. );
  512.  
  513. foreach ($item_data['ProjectTaskDetails'] as $key => $val) {
  514. $temps = array(
  515. 'taskModule' => $val[0],
  516. 'taskData' => $val[1],
  517. 'TaskAssignedTo' => $val[2],
  518. 'Role' => $val[3],
  519. 'EstimatedHours' => $val[4],
  520. 'Remarks' => $val[5],
  521. 'projectID' =>$projectID,
  522. );
  523.  
  524. $item_data['ProjectTaskDetails'][$key] = (object) $temps;
  525. }
  526. /* Save the bank Statement to the server folder */
  527. $projectName = projectDetailByID($projectID);
  528. $projectNm = substr($projectName['projectName'], 0, 22);
  529. $stringProjectNm = preg_replace('/\s+/', '', $projectNm);
  530. $OrgprojectName = trim(strtolower($stringProjectNm));
  531. $FileprojectName = $OrgprojectName.$projectID;
  532. $file_name = 'Project-' . cDate(date('Y-m-d')) . '-' . 'Tasks-' . $FileprojectName . '.xls';
  533. //die($file_name);
  534. $config['upload_path'] = './assets/uploads/projecttasks';
  535. $config['allowed_types'] = '*';
  536. $config['max_size'] = '1000';
  537. $config['max_width'] = '1024';
  538. $config['max_height'] = '768';
  539. $config['file_name'] = $file_name;
  540. $this->load->library('upload', $config);
  541. if (!$this->upload->do_upload('file')) {
  542. $error = $this->upload->display_errors();
  543. $msg = '<div class="alert alert-danger"><i class="glyphicon glyphicon-exclamation-sign"></i>&nbsp;';
  544. $msg .= $error;
  545. $msg .= '</div>';
  546. $this->session->set_flashdata('taskError', $msg);
  547. $json['error'] = 'error';
  548. }
  549. $_FILES['file']['name'] = $file_name;
  550. $files = json_encode($_FILES['file']);
  551. $this->session->set_userdata('tasks_file_id', $files);
  552. //echo json_encode($json);
  553. $details = json_encode($item_data);
  554. //echo "<pre>"; print_r($item_data); echo "</pre>"; die();
  555. $_SESSION['project_tasks_data'] = $details;
  556. if($_SESSION['project_tasks_data']!=''){
  557. setRedirect('before_project_tasks');
  558. }
  559. } else {
  560. show_404();
  561. }
  562. }
  563.  
  564. public function before_projectTasksupload() {
  565. /* Get the statements from the session */
  566. $data['title'] = 'Project Task Upload';
  567. $statements = $_SESSION['project_tasks_data'];
  568. $statements = json_decode($statements);
  569. $ProjectTaskDetails= count($statements->ProjectTaskDetails);
  570. if ($ProjectTaskDetails <= 0) {
  571. setRedirect(site_url() . 'project');
  572. }
  573. $data['taskDetails'] = $statements;
  574. //echo '<pre>';print_r($data);echo '</pre>'; die;
  575. $this->load->view('project/projecttasks_edit', $data);
  576. }
  577.  
  578. public function cancelTasksSave() {
  579. $_SESSION['project_tasks_data'] = '';
  580. $this->session->set_userdata('tasks_file_id', '');
  581. setRedirect(site_url() . 'project');
  582. }
  583.  
  584. public function getEmployeeDetailusingID(){
  585. if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  586. $employeeID = $this->input->post('employeeID');
  587. $getData = getEmployeeDetailusingID($employeeID);
  588. echo json_encode($getData);
  589. exit();
  590.  
  591.  
  592. }
  593. }
  594.  
  595. public function save_projectTasks() {
  596. if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  597. $project_tasks_data = $_SESSION['project_tasks_data'];
  598. if (empty($project_tasks_data)) {
  599. show_404();
  600. }
  601. $project_tasksinfo = (array) json_decode($project_tasks_data);
  602. $userId = $this->session->userdata('userId');
  603. $CreatedBy = $userId;
  604. $CreatedOn = date('Y-m-d');
  605. $status = 1;
  606. $taskModule = $_POST['taskModule'];
  607. $taskData = $_POST['taskData'];
  608. $TaskAssignedTo = $_POST['TaskAssignedTo'];
  609. $estimatedhours = $_POST['EstimatedHours'];
  610. $remarks = $_POST['remarks'];
  611. $match_details = array();
  612. foreach ($project_tasksinfo['ProjectTaskDetails'] as $key => $val) {
  613. if($val->taskModule != ''){
  614. $taskModule_DATA = $taskModule[$key];
  615. }if($taskModule[$key] != ''){
  616. $taskModule_DATA = $taskModule[$key];
  617. }
  618. $match_details[] = array(
  619. 'TprojectID' => $val->projectID,
  620. 'taskModule' => $taskModule_DATA,
  621. 'taskData' => $taskData[$key],
  622. 'TaskAssignedTo' => $TaskAssignedTo[$key],
  623. 'EstimatedHours' => $estimatedhours[$key],
  624. 'Remarks' => $remarks[$key],
  625. 'CreatedOn' => $CreatedOn,
  626. 'CreatedBy' => $CreatedBy,
  627. 'Status' => $status,
  628. );
  629. }
  630. $record = array();
  631. $record['projectTasks'] = $match_details;
  632. $response = $this->projects->addProjectTasks($record['projectTasks']);
  633. if(!empty($response['fail']['lastid'])){
  634. $sting = implode(',',$response['fail']['lastid']);
  635. $msg = 'Projects Tasks '.$sting. ' already Exists!';
  636. $msgss = '<div class="alert alert-danger"><i class="glyphicon glyphicon-ok-circle"></i>&nbsp;' . $msg . '</div>';
  637. $this->session->set_flashdata('taskError', $msgss);
  638. setRedirect(site_url('project'));
  639. }else{
  640. $msg = $this->lang->line('PROJECT_TASKS_ADD_SUCCESS');
  641. $msg = '<div class="alert alert-success"><i class="glyphicon glyphicon-ok-circle"></i>&nbsp;' . $msg . '</div>';
  642. $this->session->set_flashdata('taskError', $msg);
  643. setRedirect(site_url('project'));
  644. }
  645. } else {
  646. show_404();
  647. }
  648.  
  649. }
  650.  
  651. public function projectUploadTaskTemplate(){
  652. require_once(APPPATH . 'third_party/PHPExcel.php');
  653. $name = "Project Task Upload";
  654. $allEmployees = getAllEmployeeInformation();
  655.  
  656. $arrayval= array();
  657.  
  658. foreach($allEmployees as $key=>$value){
  659. $arrayval[$key] = ucwords($value['EmployeeName'].'/'.$value['designationName']);
  660. }
  661.  
  662. $setStyle = array(
  663. 'font' => array(
  664. 'name' => 'Arial',
  665. 'size' => 10,
  666. 'bold' => TRUE,
  667. 'color' => array(
  668. 'rgb' => 'FFFFFF'
  669. ),
  670. ),
  671. 'borders' => array(
  672. 'bottom' => array(
  673. 'style' => PHPExcel_Style_Border::BORDER_THIN,
  674. 'color' => array(
  675. 'rgb' => '000000'
  676. )
  677. ),
  678. 'right' => array(
  679. 'style' => PHPExcel_Style_Border::BORDER_THIN,
  680. 'color' => array(
  681. 'rgb' => '000000'
  682. )
  683. ),
  684. 'top' => array(
  685. 'style' => PHPExcel_Style_Border::BORDER_THIN,
  686. 'color' => array(
  687. 'rgb' => '000000'
  688. )
  689. ),
  690. 'left' => array(
  691. 'style' => PHPExcel_Style_Border::BORDER_THIN,
  692. 'color' => array(
  693. 'rgb' => '000000'
  694. )
  695. ),
  696. ),
  697. 'fill' => array(
  698. 'type' => PHPExcel_Style_Fill::FILL_SOLID,
  699. 'startcolor' => array(
  700. 'rgb' => '2685E1',
  701. ),
  702. ),
  703. );
  704.  
  705. $objPHPExcel = new PHPExcel();
  706.  
  707. $objPHPExcel->setActiveSheetIndex(0);
  708. $objPHPExcel->getActiveSheet()->setTitle('HiddenTestingSheet');
  709.  
  710. /* This is used in hidden excel sheet.. */
  711.  
  712. for ($x = 0; $x < count($arrayval); $x++) {
  713. $objPHPExcel->getActiveSheet()->setCellValue('C' . ($x + 1), $arrayval[$x]);
  714. }
  715.  
  716. $objPHPExcel->createSheet();
  717. $objPHPExcel->setActiveSheetIndex(1);
  718.  
  719. $objPHPExcel->getActiveSheet()->setCellValue('C1', 'Project Task Upload');
  720.  
  721. $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(20);
  722. $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(70);
  723. $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(20);
  724. $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(20);
  725. $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(20);
  726. $objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(20);
  727. $objPHPExcel->getActiveSheet()->getStyle('A2:F2')->applyFromArray($setStyle);
  728.  
  729. $objPHPExcel->getActiveSheet()->setCellValue('A2', 'Module');
  730. $objPHPExcel->getActiveSheet()->setCellValue('B2', 'Tasks');
  731. $objPHPExcel->getActiveSheet()->setCellValue('C2', 'Assigned To');
  732. $objPHPExcel->getActiveSheet()->setCellValue('D2', 'Role');
  733. $objPHPExcel->getActiveSheet()->setCellValue('E2', 'Estimated Hours');
  734. $objPHPExcel->getActiveSheet()->setCellValue('F2', 'Remarks');
  735.  
  736.  
  737. for ($x = 2; $x < 300; $x++) {
  738. $objValidation = $objPHPExcel->getActiveSheet()->getCell('C' . ($x + 1))->getDataValidation();
  739. $objValidation->setType(PHPExcel_Cell_DataValidation::TYPE_LIST);
  740. $objValidation->setErrorStyle(PHPExcel_Cell_DataValidation::STYLE_INFORMATION);
  741. $objValidation->setAllowBlank(false);
  742. $objValidation->setShowInputMessage(true);
  743. $objValidation->setShowErrorMessage(true);
  744. $objValidation->setShowDropDown(true);
  745. $objValidation->setFormula1('HiddenTestingSheet!$C$1:$C$' . (count($arrayval)));
  746. }
  747.  
  748. $objPHPExcel->getActiveSheet()->setTitle('Project Tasks Upload');
  749. $objPHPExcel->getSheetByName('HiddenTestingSheet')->setSheetState(PHPExcel_Worksheet::SHEETSTATE_HIDDEN);
  750. header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
  751. header('Content-Disposition: attachment;filename="' . $name . '.xlsx"');
  752. header('Cache-Control: max-age=0');
  753. $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
  754. $objWriter->save('php://output');
  755.  
  756. }
  757.  
  758.  
  759. }
Add Comment
Please, Sign In to add comment