Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- class Project extends CI_Controller {
- /**
- * Index Page for this controller.
- *
- * Maps to the following URL
- * http://example.com/index.php/welcome
- * - or -
- * http://example.com/index.php/welcome/index
- * - or -
- * Since this controller is set as the default controller in
- * config/routes.php, it's displayed at http://example.com/
- *
- * So any other public methods not prefixed with an underscore will
- * map to /index.php/welcome/<method_name>
- * @see https://codeigniter.com/user_guide/general/urls.html
- */
- public function Project(){
- parent::__construct();
- $this->load->Model('projects');
- $this->load->Model('clients');
- $this->load->library("pagination");
- }
- // Function Name : index();
- // Function Work : use for get project list and add new project.
- // Function Input : Send array (array include all fields value).
- // Function Output : Return true and false value (true if record added and false if error occur) and return project list.
- public function index() {
- $result = '';
- $result['employeeDesignation'] = getallEmployeeDesignation();
- $result['resourcesFrom'] = getallClientResources();
- $result['ProjectTehnology'] = getallProjectTehnology();
- $result['ProjectSource'] = getallProjectSource();
- $result['ProjectCategory'] = getallProjectCategory();
- $result['ProjectStatus'] = getallProjectStatus();
- $result['ProjectCurrency'] = getallProjectCurrency();
- $result['getallClients'] = getallClients();
- $result['message'] = 'non';
- if ($_SERVER['REQUEST_METHOD'] === 'POST' && !$this->input->post('ajax')) {
- $userid = $this->session->userdata('userId');
- $startDate = date('Y-m-d', strtotime($_POST['startDate']));
- $estimateEndDate = date('Y-m-d', strtotime($_POST['estimateEndDate']));
- //$submittedOn = date('Y-m-d', strtotime($_POST['submittedOn']));
- $responseClientID = $_POST['clientId'];
- $projectName = $_POST['projectName'];
- $projectNm = substr($projectName, 0, 22);
- $stringProjectNm = preg_replace('/\s+/', '', $projectNm);
- $projectImageNm = trim(strtolower($stringProjectNm));
- if(!empty($_FILES)) {
- $this->load->library('upload');
- $files = $_FILES;
- foreach($files['fileName']['name'] as $key=>$val){
- $this->upload->initialize($this->set_upload_options());
- $_FILES['fileName']['name'] = $val;
- $_FILES['fileName']['type'] = $files['fileName']['type'][$key];
- $_FILES['fileName']['error'] = $files['fileName']['error'][$key];
- $_FILES['fileName']['tmp_name'] = $files['fileName']['tmp_name'][$key];
- $_FILES['fileName']['size'] = $files['fileName']['size'][$key];
- $this->upload->do_upload('fileName');
- $data = $this->upload->data();
- $projectFilesData[] = $data['file_name'];
- }
- }
- if(isset($_POST['include_sat'])){
- $includesat = ($_POST['include_sat'] == 1 ? '1' : '0');
- }else{
- $includesat = 0;
- }
- $ProjectDetail = array(
- 'projectName' => $_POST['projectName'],
- 'clientReporting' => $_POST['clientReporting'],
- 'clientId' => $responseClientID,
- 'category' => $_POST['category'],
- 'technologyUsed' => array_values(array_filter($_POST['technologyUsed'])),
- 'startDate' => $startDate,
- 'estimateEndDate' => $estimateEndDate,
- 'projectStatus' => $_POST['projectStatus'],
- 'requirements' => $_POST['requirements'],
- 'description' => $_POST['description'],
- 'projectsource' => $_POST['projectsource'],
- 'projectType' => $_POST['projectType'],
- 'amount' => $_POST['amount'],
- 'projectCurrency' => $_POST['projectCurrency'],
- 'day_hour' => $_POST['day_hour'],
- 'working_hours' => $_POST['working_hours'],
- 'include_sat' => $includesat,
- 'createdDate' => date('Y-m-d'),
- 'added_by' => $userid,
- //'submittedOn' => $submittedOn,
- 'status' => 1
- );
- $record['projectData'] = $ProjectDetail;
- $resultdata = $this->projects->addProject($record['projectData']);
- $getPasredData = json_decode($resultdata,true);
- if($getPasredData['result'] == 'true' && $_POST['employeesID'] != ''){
- $projectEmployees = array(
- 'projectID'=>$getPasredData['id'],
- 'projectEmpID'=>array_values(array_filter($_POST['employeesID'])),
- 'Status'=>1,
- 'CreatedOn'=>date('Y-m-d')
- );
- $this->projects->addProjectEmployee($projectEmployees);
- $this->projects->addProjectFiles($getPasredData['id'],$responseClientID,$projectFilesData);
- }
- }
- $totalRec = $this->projects->getCountprojects();
- $result['page'] = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
- $result['projectList'] = $this->projects->getAllProjects(5, $result['page']);
- $result['links'] = getPagination(site_url('project/index'),5,$totalRec,0);
- if($this->input->post('ajax')) {
- $outout['links'] = $result['links'];
- $outout['html'] = $this->load->view('project/project_pagination',$result,true);
- echo json_encode($outout);exit;
- }
- else {
- $this->load->view('project/index',$result);
- }
- }
- // Function Name : getAllClient();
- // Function Work : use for get all clients.
- // Function Input : Send nothing.
- // Function Output : Return client list.
- private function set_upload_options(){
- $config = array();
- $config['upload_path'] = 'assets/img/projectFiles';
- $config['allowed_types'] = '*';
- $config['max_size'] = '0';
- $config['overwrite'] = FALSE;
- $config['encrypt_name'] = TRUE;
- return $config;
- }
- public function showupdateProjectpopup() {
- if ($_SERVER['REQUEST_METHOD'] === 'POST') {
- $id = $this->input->post('currentVal');
- $id = $this->encrypt->decode($id);
- if (!empty($id)) {
- $result['page'] = 'update_project';
- $result['title'] = 'Update Project';
- $result['employeeDesignation'] = getallEmployeeDesignation();
- $result['resourcesFrom'] = getallClientResources();
- $result['ProjectTehnology'] = getallProjectTehnology();
- $result['ProjectSource'] = getallProjectSource();
- $result['ProjectCategory'] = getallProjectCategory();
- $result['ProjectStatus'] = getallProjectStatus();
- $result['ProjectCurrency'] = getallProjectCurrency();
- $result['getallClients'] = getallClients();
- $result['projectDetails'] = $this->getProjectDetail($id);
- $this->load->view('project/updateProject', $result);
- }
- }
- }
- public function getAllEmployee(){
- $output = $this->projects->getAllEmployees($_POST['currentVal']);
- echo json_encode($output);exit;
- }
- public function searchEmployeeforProjects(){
- $output = $this->projects->searchEmployeeforProjects($_POST['currentVal'],$_POST['previousEmployeesID']);
- echo json_encode($output);exit;
- }
- // Function Name : getAllClient();
- // Function Work : use for get all clients.
- // Function Input : Send nothing.
- // Function Output : Return client list.
- public function getAllClient(){
- $output = $this->projects->getAllClients($_POST['currentVal']);
- echo json_encode($output);exit;
- }
- // Function Name : getProjectDetail();
- // Function Work : use for get project detail.
- // Function Input : Send project id.
- // Function Output : Return project detail.
- public function getProjectDetail($id){
- $output = $this->projects->projectDetail($id);
- if(!empty($output))
- {
- // $cilentID = $output[0]->clientId;
- // $infoClient = getallclientsInfo($cilentID);
- // $clientFirstname = $infoClient['firstName'].' '.$infoClient['lastName'];
- // $output[0]->clientId = $cilentID.'/'.$clientFirstname;
- $newval = array();
- $newval = explode(',',$output[0]->technologyUsed);
- $output[0]->technologyUsed = $newval;
- }
- //echo json_encode($output);exit;
- return $output[0];
- }
- // Function Name : updateProject();
- // Function Work : use for update project detail.
- // Function Input : Send project id.
- // Function Output : Return true and false value (true if record updated and false if error occur).
- public function updateProject(){
- //print_r($_POST);die;
- $output = $this->projects->updateprojectDetail($_POST['userDetail'],$_POST['projectId']);
- if(isset($_POST['projectEmployeeID']) && ($_POST['projectEmployeeID'] !='')){
- $projectEmployees = array(
- 'projectID'=>$_POST['projectId'],
- 'projectEmpID'=>array_values(array_filter($_POST['projectEmployeeID']['employeesID'])),
- 'Status'=>1,
- );
- $this->projects->addProjectEmployee($projectEmployees);
- }
- echo json_encode($output);exit;
- }
- // Function Name : deleteProject();
- // Function Work : use for detele project detail.
- // Function Input : Send project id.
- // Function Output : Return true and false value (true if record updated and false if error occur).
- // public function deleteProject(){
- // $output = $this->projects->delProjectDetail($_POST['currentDelId']);
- // echo json_encode($output);exit;
- // }
- public function deleteProject(){
- if ($_SERVER['REQUEST_METHOD'] === 'POST') {
- $id = $_POST['currentDelId'];
- $currentDelId = $this->encrypt->decode($id);
- $ProjectDetail = array(
- 'status' => 2
- );
- $record['Project'] = $ProjectDetail;
- $response = $this->projects->delProjectDetail($currentDelId,$record['Project']);
- if($response == 1){
- echo 'yes';
- }else{
- echo 'no';
- }
- } else {
- //show_404();
- }
- }
- //Ajax Search function(Serach,Pagination,Sorting)
- public function getProjectSearchData(){
- $keywords = $_POST['keywords'];
- $orderby = $_POST['keyword_order'];
- $sortbyname = $_POST['sortbyname'];
- $result['page'] = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
- $totalRec = count($this->projects->getProjectSearchedkeyword($keywords,null,null,null, $result['page']));
- $result['projectList'] = $this->projects->getProjectSearchedkeyword($keywords,$orderby,$sortbyname,5,$result['page']);
- $result['links'] = getPagination(site_url('project/getProjectSearchData'), 5, $totalRec,1);
- $outout['html'] = $this->load->view('project/project_pagination',$result,true);
- echo json_encode($outout);exit;
- }
- public function getAjaxProjectSearchData(){
- if($this->input->is_ajax_request()){
- $search = array(
- 'projectName' => $_POST['projectName'],
- 'clientId' => $_POST['clientId'],
- 'projectStatus' => $_POST['ProjectStatus'],
- 'status' => $_POST['status_p']
- );
- $result['page'] = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
- $totalRec = count($this->projects->getAjaxProjectSearchedkeyword($search,null,$result['page']));
- $result['projectList'] = $this->projects->getAjaxProjectSearchedkeyword($search,5,$result['page']);
- $result['links'] = getPagination(site_url('project/getAjaxProjectSearchData'), 5, $totalRec,2);
- $outout['html'] = $this->load->view('project/project_pagination',$result,true);
- echo json_encode($outout);exit;
- }
- }
- public function resetProject() {
- $result['page'] = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
- $result['projectList'] = $this->projects->getAllProjects(5, $result['page']);
- $json = array();
- $total = $this->projects->getCountprojects();
- $json['links'] = getPagination('project/index', 5, $total,0);
- $json['projectList'] = $this->load->view('project/project_pagination', $result,TRUE);
- echo json_encode($json);
- exit;
- }
- //Get Employee Data
- public function getemployeesInfo(){
- if ($_SERVER['REQUEST_METHOD'] === 'POST') {
- $employeeDesgId = $this->input->post('employeeDesgId');
- $employeeLists= $this->projects->getEmployeesListfromDesgID($employeeDesgId);
- if($employeeLists){
- foreach ($employeeLists as $key => $value) {
- echo '<option value="' . $value['id'] . '">' . ucwords($value['firstName'].' '.$value['lastName']) . '</option>';
- }
- }else{
- echo "<option value=''>No Data</option>";
- }
- }
- }
- public function getEmployeeData(){
- if ($_SERVER['REQUEST_METHOD'] === 'POST') {
- $employeeId = $this->input->post('employeeId');
- $employeeLists= $this->projects->getEmployeeDetails($employeeId);
- echo json_encode($employeeLists);
- }
- }
- public function saveCurrentData(){
- if ($_SERVER['REQUEST_METHOD'] === 'POST') {
- $currentValue = $this->input->post('currentVal');
- $TypeVal = $this->input->post('TypeVal');
- $employeeLists= $this->projects->saveCurrentData($currentValue,$TypeVal);
- echo json_encode($employeeLists);
- }
- }
- public function saveCurrentClientInfo(){
- if ($_SERVER['REQUEST_METHOD'] === 'POST') {
- $_POST['createDate'] = date('Y-m-d');
- $newData['title'] = $this->input->post('titleC');
- $newData['firstName'] = $this->input->post('firstName');
- $newData['lastName'] = $this->input->post('lastName');
- $newData['emailId'] = $this->input->post('emailId');
- $newData['skypeId'] = $this->input->post('skypeId');
- $newData['contractNo'] = $this->input->post('contractNo');
- $newData['country'] = $this->input->post('country');
- $newData['source'] = $this->input->post('clientSource');
- $newData['status'] = '1';
- $newData['added_by'] = $this->session->userdata('userId');
- $alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789";
- $pass = array(); //remember to declare $pass as an array
- $alphaLength = strlen($alphabet) - 1; //put the length -1 in cache
- for ($i = 0; $i < 8; $i++)
- {
- $n = rand(0, $alphaLength);
- $pass[] = $alphabet[$n];
- }
- $passwordClient = implode($pass); //turn the array into a string
- $resultdata = $this->clients->addClient($newData,$passwordClient);
- $getPasredData = json_decode($resultdata,true);
- if($getPasredData['results'] == 'true'){
- $subject = 'Login Details';
- $useremail = $_POST['emailId'];
- $data['email'] = $useremail;
- $data['fname'] = $_POST['firstName'];
- $data['password'] = $passwordClient ;
- $message = $this->load->view('templates/emailTemp.php',$data,TRUE);
- $sendEmail = array(
- 'Subject' => $subject,
- 'Message' => $message,
- 'To' => $useremail,
- 'From' => 'onewayitsolutions@gmail.com'
- );
- sendEmail($sendEmail);
- echo $getPasredData['lastinsertedid'];
- // echo "<pre>";
- // print_r($sendEmail);
- // echo "</pre>";
- // die();
- }
- }
- }
- public function deletepEmployee(){
- if ($_SERVER['REQUEST_METHOD'] === 'POST') {
- $pID = $this->input->post('currentVal');
- $delEmp= $this->projects->deleteprojectEmps($pID);
- echo json_encode($delEmp);
- }
- }
- /* Upload Task for Project Section 10-08-2016 Ravinder */
- public function showuploadProjecttasks_form() {
- if ($_SERVER['REQUEST_METHOD'] === 'POST') {
- $id = $this->input->post('currentVal');
- $id = $this->encrypt->decode($id);
- if (!empty($id)) {
- $data['tasks_data'] = $id;
- $this->load->view('project/uploadFormTasks', $data);
- }
- }
- }
- public function upload_ProjectTasks() {
- $user = $this->session->userdata('user');
- if ($_SERVER['REQUEST_METHOD'] === 'POST') {
- $projectID = $_POST['projectID'];
- require_once(APPPATH . 'third_party/PHPExcel.php');
- $file_extensions = array(
- '0' => '.csv',
- '1' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
- '2' => 'application/vnd.ms-excel'
- );
- $max_filesize = 2000000;
- if (!in_array($_FILES['file']['type'], $file_extensions)) {
- $msg = '<div class="alert alert-danger">';
- $msg .= '<i class="glyphicon glyphicon-exclamation-sign"></i> ';
- $msg .= $this->lang->line('BANK_UPLOAD_FILE_ERROR');
- $msg .= '</div>';
- $this->session->set_flashdata('taskError', $msg);
- setRedirect('project');
- }
- $sheet_one_column = array(
- '0' => 'Module',
- '1' => 'Tasks',
- '2' => 'Assigned To',
- '3' => 'Role',
- '4' => 'Estimated Hours',
- '5' => 'Remarks'
- );
- // $first_sheetcount_one = count($sheet_one_column);
- $error_flag = 0;
- $first_sheet = array();
- $path = $_FILES['file']['tmp_name'];
- $inputFileType = PHPExcel_IOFactory::identify($path);
- $objReader = PHPExcel_IOFactory::createReader($inputFileType);
- $objReader->setReadDataOnly(TRUE);
- /** Load $inputFileName to a PHPExcel Object * */
- $objPHPExcel = $objReader->load($path);
- $total_sheets = $objPHPExcel->getSheetCount();
- $allSheetName = $objPHPExcel->getSheetNames('template');
- //$objPHPExcel->getActiveSheet();
- $objWorksheet = $objPHPExcel->setActiveSheetIndex(1);
- $highestRow = $objWorksheet->getHighestRow();
- $highestColumn = $objWorksheet->getHighestColumn();
- $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn);
- $flag = 0;
- $statement_data = array();
- for ($row = 1; $row <= $highestRow; ++$row) {
- for ($col = 0; $col < $highestColumnIndex; ++$col) {
- $value = $objWorksheet->getCellByColumnAndRow($col, $row)->getCalculatedValue();
- $arraydata[$row - 1][$col] = $value;
- }
- $temp = $arraydata[$row - 1];
- /* Remove empty row from the statement */
- if (count($temp) > 0) {
- $statement_data[] = $temp;
- }
- }
- // $first_sheet = array_filter($statement_data);
- $first_sheet = array_filter($statement_data);
- /* Check if first sheet is valid or not */
- if (!isset($first_sheet[1])) {
- $error_flag = 1;
- } else {
- /* Now check the columns name */
- foreach ($first_sheet[1] as $key => $val) {
- if (!in_array($val, $sheet_one_column)) {
- $error_flag = 1;
- }
- }
- }
- if ($error_flag == 1) {
- $msg = '<div class="alert alert-danger"><i class="glyphicon glyphicon-exclamation-sign"></i> ';
- $msg .= $this->lang->line('PROJECTTASK_PATTERNERROR');
- $msg .= '</div>';
- $this->session->set_flashdata('taskError', $msg);
- setRedirect('project');
- }
- /* Check pattern of both the sheets */
- if (count($first_sheet[2]) != count($sheet_one_column)) {
- $error_flag = 1;
- }
- $item_data= array(
- 'ProjectTaskDetails' => array_slice($first_sheet, 2)
- );
- foreach ($item_data['ProjectTaskDetails'] as $key => $val) {
- $temps = array(
- 'taskModule' => $val[0],
- 'taskData' => $val[1],
- 'TaskAssignedTo' => $val[2],
- 'Role' => $val[3],
- 'EstimatedHours' => $val[4],
- 'Remarks' => $val[5],
- 'projectID' =>$projectID,
- );
- $item_data['ProjectTaskDetails'][$key] = (object) $temps;
- }
- /* Save the bank Statement to the server folder */
- $projectName = projectDetailByID($projectID);
- $projectNm = substr($projectName['projectName'], 0, 22);
- $stringProjectNm = preg_replace('/\s+/', '', $projectNm);
- $OrgprojectName = trim(strtolower($stringProjectNm));
- $FileprojectName = $OrgprojectName.$projectID;
- $file_name = 'Project-' . cDate(date('Y-m-d')) . '-' . 'Tasks-' . $FileprojectName . '.xls';
- //die($file_name);
- $config['upload_path'] = './assets/uploads/projecttasks';
- $config['allowed_types'] = '*';
- $config['max_size'] = '1000';
- $config['max_width'] = '1024';
- $config['max_height'] = '768';
- $config['file_name'] = $file_name;
- $this->load->library('upload', $config);
- if (!$this->upload->do_upload('file')) {
- $error = $this->upload->display_errors();
- $msg = '<div class="alert alert-danger"><i class="glyphicon glyphicon-exclamation-sign"></i> ';
- $msg .= $error;
- $msg .= '</div>';
- $this->session->set_flashdata('taskError', $msg);
- $json['error'] = 'error';
- }
- $_FILES['file']['name'] = $file_name;
- $files = json_encode($_FILES['file']);
- $this->session->set_userdata('tasks_file_id', $files);
- //echo json_encode($json);
- $details = json_encode($item_data);
- //echo "<pre>"; print_r($item_data); echo "</pre>"; die();
- $_SESSION['project_tasks_data'] = $details;
- if($_SESSION['project_tasks_data']!=''){
- setRedirect('before_project_tasks');
- }
- } else {
- show_404();
- }
- }
- public function before_projectTasksupload() {
- /* Get the statements from the session */
- $data['title'] = 'Project Task Upload';
- $statements = $_SESSION['project_tasks_data'];
- $statements = json_decode($statements);
- $ProjectTaskDetails= count($statements->ProjectTaskDetails);
- if ($ProjectTaskDetails <= 0) {
- setRedirect(site_url() . 'project');
- }
- $data['taskDetails'] = $statements;
- //echo '<pre>';print_r($data);echo '</pre>'; die;
- $this->load->view('project/projecttasks_edit', $data);
- }
- public function cancelTasksSave() {
- $_SESSION['project_tasks_data'] = '';
- $this->session->set_userdata('tasks_file_id', '');
- setRedirect(site_url() . 'project');
- }
- public function getEmployeeDetailusingID(){
- if ($_SERVER['REQUEST_METHOD'] === 'POST') {
- $employeeID = $this->input->post('employeeID');
- $getData = getEmployeeDetailusingID($employeeID);
- echo json_encode($getData);
- exit();
- }
- }
- public function save_projectTasks() {
- if ($_SERVER['REQUEST_METHOD'] === 'POST') {
- $project_tasks_data = $_SESSION['project_tasks_data'];
- if (empty($project_tasks_data)) {
- show_404();
- }
- $project_tasksinfo = (array) json_decode($project_tasks_data);
- $userId = $this->session->userdata('userId');
- $CreatedBy = $userId;
- $CreatedOn = date('Y-m-d');
- $status = 1;
- $taskModule = $_POST['taskModule'];
- $taskData = $_POST['taskData'];
- $TaskAssignedTo = $_POST['TaskAssignedTo'];
- $estimatedhours = $_POST['EstimatedHours'];
- $remarks = $_POST['remarks'];
- $match_details = array();
- foreach ($project_tasksinfo['ProjectTaskDetails'] as $key => $val) {
- if($val->taskModule != ''){
- $taskModule_DATA = $taskModule[$key];
- }if($taskModule[$key] != ''){
- $taskModule_DATA = $taskModule[$key];
- }
- $match_details[] = array(
- 'TprojectID' => $val->projectID,
- 'taskModule' => $taskModule_DATA,
- 'taskData' => $taskData[$key],
- 'TaskAssignedTo' => $TaskAssignedTo[$key],
- 'EstimatedHours' => $estimatedhours[$key],
- 'Remarks' => $remarks[$key],
- 'CreatedOn' => $CreatedOn,
- 'CreatedBy' => $CreatedBy,
- 'Status' => $status,
- );
- }
- $record = array();
- $record['projectTasks'] = $match_details;
- $response = $this->projects->addProjectTasks($record['projectTasks']);
- if(!empty($response['fail']['lastid'])){
- $sting = implode(',',$response['fail']['lastid']);
- $msg = 'Projects Tasks '.$sting. ' already Exists!';
- $msgss = '<div class="alert alert-danger"><i class="glyphicon glyphicon-ok-circle"></i> ' . $msg . '</div>';
- $this->session->set_flashdata('taskError', $msgss);
- setRedirect(site_url('project'));
- }else{
- $msg = $this->lang->line('PROJECT_TASKS_ADD_SUCCESS');
- $msg = '<div class="alert alert-success"><i class="glyphicon glyphicon-ok-circle"></i> ' . $msg . '</div>';
- $this->session->set_flashdata('taskError', $msg);
- setRedirect(site_url('project'));
- }
- } else {
- show_404();
- }
- }
- public function projectUploadTaskTemplate(){
- require_once(APPPATH . 'third_party/PHPExcel.php');
- $name = "Project Task Upload";
- $allEmployees = getAllEmployeeInformation();
- $arrayval= array();
- foreach($allEmployees as $key=>$value){
- $arrayval[$key] = ucwords($value['EmployeeName'].'/'.$value['designationName']);
- }
- $setStyle = array(
- 'font' => array(
- 'name' => 'Arial',
- 'size' => 10,
- 'bold' => TRUE,
- 'color' => array(
- 'rgb' => 'FFFFFF'
- ),
- ),
- 'borders' => array(
- 'bottom' => array(
- 'style' => PHPExcel_Style_Border::BORDER_THIN,
- 'color' => array(
- 'rgb' => '000000'
- )
- ),
- 'right' => array(
- 'style' => PHPExcel_Style_Border::BORDER_THIN,
- 'color' => array(
- 'rgb' => '000000'
- )
- ),
- 'top' => array(
- 'style' => PHPExcel_Style_Border::BORDER_THIN,
- 'color' => array(
- 'rgb' => '000000'
- )
- ),
- 'left' => array(
- 'style' => PHPExcel_Style_Border::BORDER_THIN,
- 'color' => array(
- 'rgb' => '000000'
- )
- ),
- ),
- 'fill' => array(
- 'type' => PHPExcel_Style_Fill::FILL_SOLID,
- 'startcolor' => array(
- 'rgb' => '2685E1',
- ),
- ),
- );
- $objPHPExcel = new PHPExcel();
- $objPHPExcel->setActiveSheetIndex(0);
- $objPHPExcel->getActiveSheet()->setTitle('HiddenTestingSheet');
- /* This is used in hidden excel sheet.. */
- for ($x = 0; $x < count($arrayval); $x++) {
- $objPHPExcel->getActiveSheet()->setCellValue('C' . ($x + 1), $arrayval[$x]);
- }
- $objPHPExcel->createSheet();
- $objPHPExcel->setActiveSheetIndex(1);
- $objPHPExcel->getActiveSheet()->setCellValue('C1', 'Project Task Upload');
- $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setWidth(20);
- $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(70);
- $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(20);
- $objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(20);
- $objPHPExcel->getActiveSheet()->getColumnDimension('E')->setWidth(20);
- $objPHPExcel->getActiveSheet()->getColumnDimension('F')->setWidth(20);
- $objPHPExcel->getActiveSheet()->getStyle('A2:F2')->applyFromArray($setStyle);
- $objPHPExcel->getActiveSheet()->setCellValue('A2', 'Module');
- $objPHPExcel->getActiveSheet()->setCellValue('B2', 'Tasks');
- $objPHPExcel->getActiveSheet()->setCellValue('C2', 'Assigned To');
- $objPHPExcel->getActiveSheet()->setCellValue('D2', 'Role');
- $objPHPExcel->getActiveSheet()->setCellValue('E2', 'Estimated Hours');
- $objPHPExcel->getActiveSheet()->setCellValue('F2', 'Remarks');
- for ($x = 2; $x < 300; $x++) {
- $objValidation = $objPHPExcel->getActiveSheet()->getCell('C' . ($x + 1))->getDataValidation();
- $objValidation->setType(PHPExcel_Cell_DataValidation::TYPE_LIST);
- $objValidation->setErrorStyle(PHPExcel_Cell_DataValidation::STYLE_INFORMATION);
- $objValidation->setAllowBlank(false);
- $objValidation->setShowInputMessage(true);
- $objValidation->setShowErrorMessage(true);
- $objValidation->setShowDropDown(true);
- $objValidation->setFormula1('HiddenTestingSheet!$C$1:$C$' . (count($arrayval)));
- }
- $objPHPExcel->getActiveSheet()->setTitle('Project Tasks Upload');
- $objPHPExcel->getSheetByName('HiddenTestingSheet')->setSheetState(PHPExcel_Worksheet::SHEETSTATE_HIDDEN);
- header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
- header('Content-Disposition: attachment;filename="' . $name . '.xlsx"');
- header('Cache-Control: max-age=0');
- $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
- $objWriter->save('php://output');
- }
- }
Add Comment
Please, Sign In to add comment