diff --git a/application/config/routes.php b/application/config/routes.php index e97952e9..835a0c82 100755 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -148,13 +148,14 @@ $route['pageNotFound'] = "user/pageNotFound"; $route['checkEmailExists'] = "user/checkEmailExists"; $route['forgotPassword'] = "login/forgotPassword"; -$route['ExcelUpload'] = "payslip/viewUpload"; +$route['monthlypay'] = "payslip/monthlyInputs"; $route['ExcelUpload2'] = "payslip/viewUpload2"; $route['FileUpload'] = "payslip/uploadExcel"; $route['FileUpload2'] = "payslip/uploadExcel2"; $route['PrintPdf'] = "payslip/PrintPdf"; $route['ViewPay'] = "payslip/viewGenerator"; $route['updatepayroll'] = "payslip/updatepayroll"; +$route['BankReport'] = "payslip/loadBankreportScreen"; //<-----------Application Requistion Flow Routes------------> diff --git a/application/controllers/emppaydate.php b/application/controllers/emppaydate.php index 33130db9..c195a1ae 100755 --- a/application/controllers/emppaydate.php +++ b/application/controllers/emppaydate.php @@ -61,7 +61,7 @@ class emppaydate extends BaseController $result['empdetails'] = $this->payroll_model->getEmpID($q); - //$data['emp_id'] = $this->monthlypay_model->getmonthlypay(); + $this->global['pageTitle'] = 'Siddharth : Add Employee Pay'; @@ -81,30 +81,12 @@ class emppaydate extends BaseController $this->form_validation->set_rules('HRA_Amount','HRA_Amount','trim|required'); $this->form_validation->set_rules('Basic_Pay','Basic_Pay','trim|required'); $this->form_validation->set_rules('Total_salary','Total_salary','trim|required'); - $this->form_validation->set_rules('OT_Rate','OT_Rate','trim|required'); + $this->form_validation->set_rules('Allowances','Allowances','trim|required'); $this->form_validation->set_rules('PF_Rate','PF_Rate','trim|required'); $this->form_validation->set_rules('ESI_Rate','ESI_Rate','trim|required'); $this->form_validation->set_rules('Food_Allowances','Food_Allowances','trim|required'); - //$Loan_Amount=$this->input->post('Loan_Amount'); - // echo "before if"; - // if($Loan_Amount != 0.00 || $Loan_Amount != "") - // { - // echo "indisde "; - // $Load_Issued_date=$this->input->post('loan_issued_date'); - // $Due_Amount=$this->input->post('monthly_due'); - // $Due_Started=$this->input->post('due_started'); - // echo $Load_Issued_date ."-".$Due_Amount."-".$Due_Started; - // if($Load_Issued_date == "" || $Due_Started =="" || $Due_Amount == "" || $Due_Amount == 0) - // //echo "FAIL";die(); - - // $this->form_validation->set_rules('Loan_Amount','Loan_Amount','trim|required'); - // $this->form_validation->set_rules('loan_issued_date','loan_issued_date','trim|required'); - // $this->form_validation->set_rules('monthly_due','monthly_due','trim|required'); - // $this->form_validation->set_rules('Food_Allodue_startedwances','due_started','trim|required'); - - // } - //die(); + if($this->form_validation->run() == FALSE || $EmpID == -1) { @@ -112,13 +94,13 @@ class emppaydate extends BaseController } else { - //$Pay_Data_ID=$this->input->post('Pay_Data_ID'); + $EmpID = $this->input->post('EmpID'); $Total_Salary=$this->input->post('Total_salary'); $Basic_Pay=$this->input->post('Basic_Pay'); $HRA_Rate=$this->input->post('HRA_Rate'); $HRA_Amount=$this->input->post('HRA_Amount'); - $OT_Rate=$this->input->post('OT_Rate'); + $Allowances=$this->input->post('Allowances'); $PF_Rate=$this->input->post('PF_Rate'); $ESI_Rate=$this->input->post('ESI_Rate'); @@ -141,20 +123,20 @@ class emppaydate extends BaseController $Remaining_Due=$this->input->post('remaining_due'); $Paid_Amount=$this->input->post('Paid_Amount'); - //$All = $this->input->post('All'); + $CreateBy = $this->session->userdata ( 'userId' ); $chked = $this->input->post('is_Active'); $IsActive = '1'; - $emppay = array('EmpID'=>$EmpID,'TotalSalary'=>$Total_Salary,'Basic_Pay'=>$Basic_Pay,'HRA_Rate'=>$HRA_Rate,'HRA_Amount'=>$HRA_Amount, 'OT_Rate'=>$OT_Rate, 'Allowances'=>$Allowances, 'PF_Rate'=>$PF_Rate, 'ESI_Rate'=>$ESI_Rate ,'Food_Allowances'=>$Food_Allowances,'Loan_Amount'=>$Loan_Amount,'Loan_Issued_Date'=>$Load_Issued_date,'Monthly_Due'=>$Due_Amount,'Due_Start_Date'=>$Due_Started,'No_of_Dues'=>$No_Of_Dues,'Paid_Due'=>$Paid_due,'Remaining_Due'=>$Remaining_Due,'Paid_Amount'=>$Paid_Amount,'Created_By'=>$CreateBy); + $emppay = array('EmpID'=>$EmpID,'TotalSalary'=>$Total_Salary,'Basic_Pay'=>$Basic_Pay,'HRA_Rate'=>$HRA_Rate,'HRA_Amount'=>$HRA_Amount,'Allowances'=>$Allowances, 'PF_Rate'=>$PF_Rate, 'ESI_Rate'=>$ESI_Rate ,'Food_Allowances'=>$Food_Allowances,'Loan_Amount'=>$Loan_Amount,'Loan_Issued_Date'=>$Load_Issued_date,'Monthly_Due'=>$Due_Amount,'Due_Start_Date'=>$Due_Started,'No_of_Dues'=>$No_Of_Dues,'Paid_Due'=>$Paid_due,'Remaining_Due'=>$Remaining_Due,'Paid_Amount'=>$Paid_Amount,'Created_By'=>$CreateBy); - //print_r($emppay);die(); + $result = $this->emppaydate_model->addNewemppay($emppay); if($result > 0) { - // $this->session->set_flashdata('success', 'New Asset created successfully'); + redirect('emppaydate/emppayListing','refresh'); echo ""; @@ -176,8 +158,7 @@ class emppaydate extends BaseController { $data['emppay'] = $this->emppaydate_model->getUserInfo($paydataid); - // print_r($data); - //$data['monthly_pay_inputs'] = $this->monthlylisting_model->getUserInfo($employeeid); + $this->global['pageTitle'] = 'Siddharth : Edit Employee Pay Monthly Details '; @@ -203,7 +184,7 @@ class emppaydate extends BaseController $this->form_validation->set_rules('Total_Salary','Total_Salary','trim|required'); $this->form_validation->set_rules('Basic_Pay','Basic_Pay','trim|required'); $this->form_validation->set_rules('HRA_Rate','HRA_Rate','trim|required'); - $this->form_validation->set_rules('OT_Rate','OT_Rate','trim|required'); + $this->form_validation->set_rules('Allowances','Allowances','trim|required'); $this->form_validation->set_rules('PF_Rate','PF_Rate','trim|required'); $this->form_validation->set_rules('ESI_Rate','ESI_Rate','trim|required'); @@ -229,7 +210,7 @@ class emppaydate extends BaseController $Basic_Pay=$this->input->post('Basic_Pay'); $HRA_Rate=$this->input->post('HRA_Rate'); $HRA_Amount=$this->input->post('HRA_Amount'); - $OT_Rate=$this->input->post('OT_Rate'); + $Allowances=$this->input->post('Allowances'); $PF_Rate=$this->input->post('PF_Rate'); $ESI_Rate=$this->input->post('ESI_Rate'); @@ -252,25 +233,12 @@ class emppaydate extends BaseController $Last_Mod_By=$this->session->userdata('userId'); $Last_Mod_Time=date('d-m-Y h:i:sa'); $Food_Allowances=$this->input->post('Food_Allowances'); - // $chked = $this->input->post('is_Active'); - // if( $chked != '') - // { - // $IsActive = '1'; - // } - // else - // { - // $IsActive = '0'; - // } - - - - //$emppaydatas = array(); - $emppaydatas = array('Pay_Data_ID'=>$Pay_Data_ID,'EmpID'=>$EmpID,'TotalSalary'=>$TotalSalary,'Basic_Pay'=>$Basic_Pay,'HRA_Rate'=>$HRA_Rate,'HRA_Amount'=>$HRA_Amount, 'OT_Rate'=>$OT_Rate, 'Allowances'=>$Allowances, 'PF_Rate'=>$PF_Rate, 'ESI_Rate'=>$ESI_Rate ,'Food_Allowances'=>$Food_Allowances,'Loan_Amount'=>$Loan_Amount,'Loan_Issued_Date'=>$Load_Issued_date,'Monthly_Due'=>$Due_Amount,'Due_Start_Date'=>$Due_Started,'No_of_Dues'=>$No_Of_Dues,'Paid_Due'=>$Paid_due,'Remaining_Due'=>$Remaining_Due,'Paid_Amount'=>$Paid_Amount,'Last_Mod_By'=>$Last_Mod_By,'Last_Mod_Time'=>$Last_Mod_Time); - // print_r($emppaydatas);die(); + $emppaydatas = array('Pay_Data_ID'=>$Pay_Data_ID,'EmpID'=>$EmpID,'TotalSalary'=>$TotalSalary,'Basic_Pay'=>$Basic_Pay,'HRA_Rate'=>$HRA_Rate,'HRA_Amount'=>$HRA_Amount,'Allowances'=>$Allowances, 'PF_Rate'=>$PF_Rate, 'ESI_Rate'=>$ESI_Rate ,'Food_Allowances'=>$Food_Allowances,'Loan_Amount'=>$Loan_Amount,'Loan_Issued_Date'=>$Load_Issued_date,'Monthly_Due'=>$Due_Amount,'Due_Start_Date'=>$Due_Started,'No_of_Dues'=>$No_Of_Dues,'Paid_Due'=>$Paid_due,'Remaining_Due'=>$Remaining_Due,'Paid_Amount'=>$Paid_Amount,'Last_Mod_By'=>$Last_Mod_By,'Last_Mod_Time'=>$Last_Mod_Time); + $result = $this->emppaydate_model->editemppay($emppaydatas); @@ -278,7 +246,7 @@ class emppaydate extends BaseController if($result == true) { echo ""; - //$this->session->set_flashdata('success', 'updated successfully'); + } else @@ -294,135 +262,24 @@ class emppaydate extends BaseController } - - /** - * This function is used load user edit information - * @param number $userId : Optional : This is user id - */ - /*function editOldcost($CostCode = NULL) + function deleteEmpPay() { - - if($CostCode == '') - { - $CostCenterID = $_GET['CostCode']; - } - else - { - - $CostCenterID = $CostCode; } - - $data['CostMaster'] = $this->costcenter_model->GetCostCenterMaster($CostCenterID); - $data['CostDepts'] = $this->costcenter_model->GetCostCenterDepartment($CostCenterID); - $data['CostBudget'] = $this->costcenter_model->GetCostCenterBudget($CostCenterID); - // $data['DeptList'] = $this->costcenter_model->GetDepartmentNotinCostCenter($CostCenterID); - - - $this->global['pageTitle'] = 'Siddharth : Edit Cost'; - - $this->loadViews("editOldcost", $this->global, $data,NULL); - - } - - function ech() - { - - echo $this->input->post('CostCentreID'); - echo $this->input->post('CostName'); - echo $this->input->post('Description'); - + $EmpID = $this->input->post('id'); + //echo $EmpID; + $result = $this->emppaydate_model->deleteEmployeePay($EmpID); + if($result == 1) + { + echo "Deleted Sucessfully..!"; + } + else + { + echo "Something Went wrong. Try Later..!"; + } } - /** - * This function is used to edit the user information - - function editcost() - { - - $this->load->library('form_validation'); - - $CostCenterID = $this->input->post('CostCentreID'); - - $this->form_validation->set_rules('CostName','Cost Name','trim|required|'); - $this->form_validation->set_rules('Description','Description','trim|required|'); - - - if($this->form_validation->run() == FALSE) - { - $this->editcost($CostCenterID); - } - else - { - $CostCenterID = $this->input->post('CostCentreID'); - $CostName = ucwords(strtolower($this->input->post('CostName'))); - $Description = $this->input->post('Description'); - - - - //$this->costcenter_model->editcost($Cost); - - $cost = array(); - - - - $Cost = array('CostCentreID'=>$CostCenterID,'CostName'=>$CostName, 'Description'=>$Description,'createdDate'=>date('Y-m-d H:i:sa')); - - - - - $result = $this->costcenter_model->editcost($Cost, $CostCenterID); - - if($result == true) - { - $this->session->set_flashdata('success', 'Cost updated successfully'); - } - else - { - $this->session->set_flashdata('error', 'Cost updation failed'); - } - - redirect('costListing'); - } - - } - function viewcost($CostCenterID = NULL) - { - - if($CostCenterID == null) - { - redirect('costListing'); - } - - $data['Cost'] = $this->costcenter_model->getuserinfo($CostCenterID); - //$data['users'] = $this->purchaseorder_model->getusers(); - - $this->global['pageTitle'] = 'Siddharth : View Cost'; - - $this->loadViews("viewcost", $this->global, $data,NULL); - - } - /** - * This function is used to delete the user using userId - * @return boolean $result : TRUE / FALSE - - function deletecost() - { - if($this->isAdmin() == TRUE) - { - echo(json_encode(array('status'=>'access'))); - } - else - { - $CostCenterID = $this->input->Costst('CostCentreID'); - $cost = array('CreateDate'=>date('Y-m-d H:i:sa')); - - $result = $this->costcenter_model->deletecost($Cost, $CostCenterID); - - if ($result > 0) { echo(json_encode(array('status'=>TRUE))); } - else { echo(json_encode(array('status'=>FALSE))); } - } - } - */ + + function pageNotFound() { diff --git a/application/controllers/payslip.php b/application/controllers/payslip.php index 4d6e3bf2..672775f4 100755 --- a/application/controllers/payslip.php +++ b/application/controllers/payslip.php @@ -18,10 +18,15 @@ class payslip extends BaseController { parent::__construct(); $this->load->model('payroll_model'); + $this->load->model('monthlypay_model'); $this->load->library('form_validation'); $this->isLoggedIn(); } +function phpAlert($msg) { + echo ''; +} + /** * This function used to call stored procedure named with final_payroll_data() @@ -37,6 +42,113 @@ class payslip extends BaseController } + function loadBankreportScreen() + { + + $Data['Payon'] = $this->payroll_model->getPayOn(); + $Data['Bank'] = $this->payroll_model->getBankInfo(); + $this->global['pageTitle'] = 'Siddharth : Bank Report Screen'; + $this->loadViews("bankreport", $this->global,$Data,NULL); + + } + + function getBankReport() + { + $bank = $this->input->post('bank'); + $payon = $this->input->post('month'); + $monthsoptions = array("01" => "Jan", "02" => "Feb","03" => "Mar","04" => "Apr","05" => "May","06" => "June","07"=> "July","08"=> "Aug","09" => "Sep","10"=> "Oct","11" => "Nov","12"=>"Dec"); + $m = substr($payon,0,2); + $y = substr($payon,3); + $month = $monthsoptions[$m]."-".$y; + + + + + $filename = ''; + if($this->input->post('Bank_Report')) + { + $data['result'] = $this->payroll_model->getReportforBank($bank,$payon); + + $totamtwords = ''; + $totalamt=0.00; + if(!empty($data['result'])){ + foreach($data['result'] as $amt) + { + $totalamt += $amt->LessAdvance; + } + } + $totamtwords = $this->convertNumber($totalamt); + $data['BankName']=$bank; + $data['Totalamount']=$totalamt; + $data['Totalamtwords']=$totamtwords; + $data['PayMonth']=$month; + $filename = 'Bank Report for'.$payon.'pdf' ; + $this->load->View("bankreportprint",$data); + } + if($this->input->post('PF_Report')) + { + $data['PFESI'] = $this->payroll_model->getReportforPFESI($payon); + $data['PayMonth']=$month; + $totamtwords = ''; + $totalamt=0.00; + if(!empty($data['PFESI'])){ + foreach($data['PFESI'] as $pf) + { + $totalamt += ($pf->PF + $pf->CompanyPF); + } + } + $data['Totalamount']=$totalamt; + $totamtwords = $this->convertNumber($totalamt); + $data['Totalamtwords']=$totamtwords; + $filename = 'PF Report for'.$payon.'pdf' ; + $this->load->View("pfreportprint",$data); + } + + if($this->input->post('ESI_Report')) + { + $data['PFESI'] = $this->payroll_model->getReportforPFESI($payon); + $data['PayMonth']=$month; + $totamtwords = ''; + $totalamt=0.00; + if(!empty($data['PFESI'])){ + foreach($data['PFESI'] as $pf) + { + $totalamt += ($pf->EmployeeESI + $pf->CompanyESI); + } + } + $data['Totalamount']=$totalamt; + $totamtwords = $this->convertNumber($totalamt); + $data['Totalamtwords']=$totamtwords; + $filename = 'ESI Report for'.$payon.'pdf'; + $this->load->View("esireportprint",$data); + } + + + $php = $this->output->get_output(); + + // Load library + $this->load->library('dompdf_gen'); + + require_once(APPPATH .'third_party/dompdf/dompdf_config.inc.php'); + $dompdf = new DOMPDF(); + $dompdf->set_paper('A4', 'portrait'); + $dompdf->load_html($php); + + $dompdf->render(); + + // add the header + $canvas = $dompdf->get_canvas(); + $font = Font_Metrics::get_font("helvetica", "bold"); + + // the same call as in my previous example + $canvas->page_text(72, 18,"", + $font, 6, array(0,0,0)); + + $dompdf->stream($filename); + + + } + /** @@ -50,15 +162,170 @@ class payslip extends BaseController $this->loadViews("payslipupload2", $this->global, NULL); } + + public function monthlyInputs() + { + $current = date("m-Y"); + $data['month'] = $this-> monthlypay_model->monthlyListing($current); + $data['fresh'] = $this-> monthlypay_model->getEmpPayDetails(); + + $this->global['pageTitle'] = 'Siddharth : Payroll Monthly Inputs'; + $this->loadViews("monthlypayinputs", $this->global,$data,NULL); + + + } + + function changeMonth() + { + + $current = $this->input->post('param1'); + $month = $this-> monthlypay_model->monthlyListing($current); + $fresh = $this-> monthlypay_model->getEmpPayDetails(); + $data = json_encode(array_merge($month,$fresh)); + echo $data; + } + + + function saveMonthlyData() + { + + $month = $this->input->post('param2'); + $jsondata =$this->input->post('param1'); + $json = json_decode($jsondata,true); - /** - * This function used to load the first screen of the user - */ + $mon = substr($month,0,1); + $year = substr($month,2); + + if($mon <10) + { + $mon = '0'.$mon; + + } + $month = $mon ."-". $year; + //echo $month; + $total = 0; + $ErrorEmpId = ''; + $TotalErrorFlag = 0; + foreach($json as $j) + { + $ErrorFlag = 0; + + $EmpID = $j['Employee Id']; + $Name = $j['Employee Name']; + $LOP_Days = $j['LOP Days']; + $Paid_leave = $j['Paid Leave']; + $OT_Hrs_Worked = $j['OT Hours Worked in Hrs']; + $Loan_Recovered = $j['Loan Recovered in ₹']; + $Incentives = $j['Incentives in ₹']; + $Other_Deductions = $j['Other Deductions in ₹']; + $Created_By = $this->session->userdata ( 'userId' ); + if(!is_numeric($LOP_Days) || ($LOP_Days > 31) || (strlen((string)$LOP_Days)) > 5 ) + { + //echo $EmpID . "-LOP_Days Invalid Data!"; + $ErrorFlag++; + } + if(!is_numeric($Paid_leave) || ($Paid_leave > 31) || (strlen((string)$Paid_leave)) > 5) + { + //echo $EmpID . "-Paid Leave Invalid Data!"; + $ErrorFlag++; + } + + + $OT_Hrs_Worked_first = explode(".",$OT_Hrs_Worked); + if(!is_numeric($OT_Hrs_Worked) || (strlen((string)$OT_Hrs_Worked))>6 || (strlen((string)$OT_Hrs_Worked_first[0])) >= 4)// || (strlen((string)$OT_Hrs_Worked_first[1]))> 3 ) + { + //echo $EmpID . "-OT Hrs Invalid Data!"; + $ErrorFlag++; + } + + $Loan_Recovered_first = explode(".",$Loan_Recovered); + if(!is_numeric($Loan_Recovered) || (strlen((string)$Loan_Recovered))>8 || (strlen((string)$Loan_Recovered_first[0]))> 5) + { + //echo $EmpID . "-Loan Recoverd Invalid Data!"; + $ErrorFlag++; + } + + $Incentives_first = explode(".",$Incentives); + if(!is_numeric($Incentives) || (strlen((string)$Incentives))>8 || (strlen((string)$Incentives_first[0]))> 5) + { + //echo $EmpID . "-Loan Recoverd Invalid Data!"; + $ErrorFlag++; + } + + $Other_Deductions_first = explode(".",$Other_Deductions); + if(!is_numeric($Other_Deductions) || (strlen((string)$Other_Deductions))>8 || (strlen((string)$Other_Deductions_first[0]))> 5) + { + //echo $EmpID . "-Loan Recoverd Invalid Data!"; + $ErrorFlag++; + } + + if($ErrorFlag != 0) + { + //echo $EmpID ."- has Invalid Data!"; + $ErrorEmpId = $ErrorEmpId ."|". $EmpID; + $TotalErrorFlag++; + + } + else//if($ErrorFlag == 0) + { + //nothing + } + + + + + + } + + if($TotalErrorFlag == 0) + { + foreach($json as $j) + { + $EmpID = $j['Employee Id']; + $Name = $j['Employee Name']; + $LOP_Days = $j['LOP Days']; + $Paid_leave = $j['Paid Leave']; + $OT_Hrs_Worked = $j['OT Hours Worked in Hrs']; + $Loan_Recovered = $j['Loan Recovered in ₹']; + $Incentives = $j['Incentives in ₹']; + $Other_Deductions = $j['Other Deductions in ₹']; + $Created_By = $this->session->userdata ( 'userId' ); + + $monthlypaydata = array('Month_Year'=>$month,'EmpID'=>$EmpID,'LOP_Days'=>$LOP_Days,'Paid_leave'=>$Paid_leave,'OT_Hrs_Worked'=>$OT_Hrs_Worked,'Loan_Recovered'=>$Loan_Recovered,'Incentives'=>$Incentives,'Other_Deductions'=>$Other_Deductions,'Created_By'=>$Created_By); + $result = $this->monthlypay_model->saveMonthlyData_model($monthlypaydata); + $total = $total + $result; + } + } + //echo ""; + if(!empty($ErrorEmpId)) + { + echo $ErrorEmpId . "- are have Invalid Data!"; + } + echo $total . "- Employees Updated Successfully "; + + } + + + function payslipLisiting() + { + $this->global['pageTitle'] = 'Siddharth : Payslip Listing'; + $data['PayInfo'] = $this->payroll_model->GetPayslipdata(); + $this->loadViews("paysliplist", $this->global, $data , NULL); + } + + function editPayslip($EmpID,$PayOn) + { + + + $this->global['pageTitle'] = 'Siddharth : Edit Employee Payslip'; + $data['PayInfo'] = $this->payroll_model->GetPayslipdata($PayOn,$EmpID); + $this->loadViews("editpayslip", $this->global, $data , NULL); + } public function viewGenerator() { - //echo 'inside funtion'; + $Data['Payon'] = $this->payroll_model->getPayOn(); - //$Data['Emplist'] = $this->payroll_model->getEmployeelist(); + $this->global['pageTitle'] = 'Siddharth : Payroll Generater'; @@ -138,7 +405,7 @@ function getEmployee() else { $Payon = $this->input->post('PayOn'); - + //echo "Payon" . $Payon; if($All != '') { @@ -155,7 +422,7 @@ function getEmployee() $EmpID = $result[$i]['EmpId']; $Data['PayDetails'] = $this->payroll_model->GetPayslipdata($Payon,$EmpID); - //print_r($Data['PayDetails']);//die(); + - $totalsalary =$Data['PayDetails'][0]->LessAdvance; $totalsalaryinwords = $this->convertNumber(round($totalsalary)); $Data['amtinwords']=$totalsalaryinwords; @@ -170,11 +437,13 @@ function getEmployee() else { $EmpID = $this->input->post('Employee'); + //echo "EmpID" . $EmpID; $Data['PayDetails'] = $this->payroll_model->GetPayslipdata($Payon,$EmpID); + $totalsalary =$Data['PayDetails'][0]->LessAdvance; $totalsalaryinwords = $this->convertNumber(round($totalsalary)); $Data['amtinwords']=$totalsalaryinwords; - + $this->load->View("payslipgenerateprint", $Data ); } @@ -214,6 +483,32 @@ function getEmployee() } + function updatePayslip() + { + + $paykey = $this->input->post("Key"); + $EmpID = $this->input->post("EmpID"); + $PayOn = $this->input->post("PayOn"); + $otherallowence = $this->input->post("otherallowence"); + $otherdeductions = $this->input->post("otherdeductions"); + $incentive = $this->input->post("incentive"); + $netpay = $this->input->post("netpay"); + $esi = $this->input->post("txtesi"); + $pf = $this->input->post("txtpf"); + $basic = $this->input->post("txtbasicda"); + $hra = $this->input->post("txthra"); + $otsalary = $this->input->post("otsalary"); + + $Totaldeduction = $esi + $pf + $otherdeductions; + $SalaryAsPerPF = ($basic + $hra + $otsalary) - $Totaldeduction; + $userid = $this->session->userdata ( 'userId' ); + + $remarks = 'Manual Edit By' . $userid ." On " . date('Y-m-d'); + $paydetails = array('Key'=>$paykey,'EmpID'=>$EmpID,'PayOn'=>$PayOn,'Other_allowances'=>$otherallowence,'OtherDeductions'=>$otherdeductions,'Incentive'=>$incentive,'LessAdvance'=>$netpay,'TotalSalary'=>$netpay,'SalaryAsPerPF'=>$SalaryAsPerPF,'Totaldeduction'=>$Totaldeduction,'remarks'=>$remarks); + $result = $this->payroll_model->updateEmpPayslip($paydetails); + echo $result; + } + /** * This function used to upload the Excel file Details diff --git a/application/logs/log-2017-10-05.php b/application/logs/log-2017-10-05.php index 1af524fd..bc5ac9de 100644 --- a/application/logs/log-2017-10-05.php +++ b/application/logs/log-2017-10-05.php @@ -9,3 +9,12 @@ ERROR - 2017-10-05 07:02:30 --> Severity: Warning --> DOMXPath::query(): Invali ERROR - 2017-10-05 07:02:30 --> Severity: Warning --> DOMXPath::query(): Invalid expression /opt/lampp/htdocs/5oct/siddharth_application/application/third_party/dompdf/include/stylesheet.cls.php 697 ERROR - 2017-10-05 07:02:31 --> Severity: Warning --> DOMXPath::query(): Invalid expression /opt/lampp/htdocs/5oct/siddharth_application/application/third_party/dompdf/include/stylesheet.cls.php 697 ERROR - 2017-10-05 07:02:31 --> Severity: Warning --> DOMXPath::query(): Invalid expression /opt/lampp/htdocs/5oct/siddharth_application/application/third_party/dompdf/include/stylesheet.cls.php 697 +ERROR - 2017-10-05 13:21:32 --> Severity: Notice --> Undefined variable: searchText C:\5.6\xampp\htdocs\SIA\SIANEW\siddharth_application\application\views\emppayListing.php 26 +ERROR - 2017-10-05 13:21:32 --> Severity: Notice --> Undefined property: stdClass::$OT_Rate C:\5.6\xampp\htdocs\SIA\SIANEW\siddharth_application\application\views\emppayListing.php 68 +ERROR - 2017-10-05 13:21:32 --> Severity: Notice --> Undefined property: stdClass::$OT_Rate C:\5.6\xampp\htdocs\SIA\SIANEW\siddharth_application\application\views\emppayListing.php 68 +ERROR - 2017-10-05 13:21:32 --> Severity: Notice --> Undefined property: stdClass::$OT_Rate C:\5.6\xampp\htdocs\SIA\SIANEW\siddharth_application\application\views\emppayListing.php 68 +ERROR - 2017-10-05 13:21:32 --> Severity: Notice --> Undefined property: stdClass::$OT_Rate C:\5.6\xampp\htdocs\SIA\SIANEW\siddharth_application\application\views\emppayListing.php 68 +ERROR - 2017-10-05 13:21:32 --> Severity: Notice --> Undefined property: stdClass::$OT_Rate C:\5.6\xampp\htdocs\SIA\SIANEW\siddharth_application\application\views\emppayListing.php 68 +ERROR - 2017-10-05 13:21:32 --> Severity: Notice --> Undefined property: stdClass::$OT_Rate C:\5.6\xampp\htdocs\SIA\SIANEW\siddharth_application\application\views\emppayListing.php 68 +ERROR - 2017-10-05 13:21:32 --> Severity: Notice --> Undefined property: stdClass::$OT_Rate C:\5.6\xampp\htdocs\SIA\SIANEW\siddharth_application\application\views\emppayListing.php 68 +ERROR - 2017-10-05 13:21:37 --> Severity: Notice --> Undefined property: stdClass::$OT_Rate C:\5.6\xampp\htdocs\SIA\SIANEW\siddharth_application\application\views\editOldemppay.php 93 diff --git a/application/models/emppaydate_model.php b/application/models/emppaydate_model.php index c866f08d..1fa28163 100755 --- a/application/models/emppaydate_model.php +++ b/application/models/emppaydate_model.php @@ -25,6 +25,14 @@ class emppaydate_model extends CI_Model return $result; } + function deleteEmployeePay($EmpID) + { + $this->db->where('EmpID',$EmpID); + $query = $this->db->delete('T_Emp_Pay_Data'); + return $query; + + } + diff --git a/application/models/monthlypay_model.php b/application/models/monthlypay_model.php index 718ce286..36fe5ab5 100755 --- a/application/models/monthlypay_model.php +++ b/application/models/monthlypay_model.php @@ -10,19 +10,68 @@ class monthlypay_model extends CI_Model * @param number $segment : This is pagination limit * @return array $result : This is result */ - function monthlyListing() + function monthlyListing($current="") { + $this->db->select('T_Monthly_Pay_Inputs.*,T_Employee_Details.FirstName,T_Employee_Details.LastName'); $this->db->from('T_Monthly_Pay_Inputs'); $this->db->join('T_Employee_Details','T_Monthly_Pay_Inputs.EmpID=T_Employee_Details.EmpID'); - - $this->db->order_by("Month_Year", "desc"); + $this->db->where('Month_Year',$current); + $query = $this->db->get(); - $result = $query->result(); - return $result; + $result = $query->result(); + + return $result; } + function getEmpPayDetails() + { + $this->db->select('T_Emp_Pay_Data.EmpID,T_Employee_Details.FirstName,T_Employee_Details.LastName'); + $this->db->from('T_Emp_Pay_Data'); + $this->db->join('T_Employee_Details','T_Emp_Pay_Data.EmpID=T_Employee_Details.EmpID'); + $query = $this->db->get(); + $result = $query->result(); + return $result; + } + + function saveMonthlyData_model($data) + { + + $month = $data['Month_Year']; + $empid = $data['EmpID']; + $count=0; + + $this->db->select('count(*) as count'); + $this->db->from('T_Monthly_Pay_Inputs'); + $this->db->where('Month_Year',$month); + $this->db->where('EmpID',$empid); + $isExits = $this->db->get(); + $res = $isExits->result_array(); + + if(!empty($res)) + { + + $count = $res[0]['count']; + } + + + if($count == 0 ) + { + $i = $this->db->insert('T_Monthly_Pay_Inputs',$data); + return $i; + + } + elseif($count == 1) + { + $this->db->where('Month_Year',$month); + $this->db->where('EmpID',$empid); + $i = $this->db->update('T_Monthly_Pay_Inputs',$data); + return $i; + + } + + } function addNewmonthlisting($m_list) @@ -41,8 +90,7 @@ function addNewmonthlisting($m_list) $this->db->select('T_Monthly_Pay_Inputs.*,T_Employee_Details.FirstName,T_Employee_Details.LastName'); $this->db->from('T_Monthly_Pay_Inputs'); $this->db->join('T_Employee_Details','T_Monthly_Pay_Inputs.EmpID=T_Employee_Details.EmpID'); - //$this->db->where('isDeleted', 0); - //$this->db->where('roleId !=', 1); + $this->db->where('T_Monthly_Pay_Inputs.EmpID', $EmpID); $this->db->where('T_Monthly_Pay_Inputs.Month_Year', $month_year); $query = $this->db->get(); @@ -56,9 +104,9 @@ function addNewmonthlisting($m_list) $monthyear=$monthdata['Month_Year']; - //$this->db->where('EmpID',$employeeid); + $this->db->where('EmpID' ,$EmpID); - //$this->db->where('Month_Year' ,$EmpID); + $this->db->where('Month_Year',$monthyear); $this->db->update('T_Monthly_Pay_Inputs',$monthdata); diff --git a/application/models/payroll_model.php b/application/models/payroll_model.php index de3d6d86..e28a0614 100755 --- a/application/models/payroll_model.php +++ b/application/models/payroll_model.php @@ -140,22 +140,33 @@ class Payroll_model extends CI_Model */ function GetPayslipdata($PayOn='',$EmpId='') { - $this->db->select('Pay.*,payfile.TotalNoofDays as TotalNoofDays ,Emp.FirstName as FName ,Emp.LastName as Lname,Emp.DateofBirth as Dob,Emp.PANNo as Pan,Emp.BankBranchName as BankName,Emp.AadharNo,Emp.IFSCCode as IFSCCode,Emp.DateofJoining as DOJ,Emp.Designation as Designation,Dep.DepartmentName as DeptName'); + //echo "FROM MODEL" . $PayOn . $EmpId; + $this->db->select('Pay.*,Emp.FirstName as FName ,Emp.LastName as Lname,Emp.DateofBirth as Dob,Emp.PANNo as Pan,Emp.BankBranchName as BankName,Emp.AadharNo,Emp.IFSCCode as IFSCCode,Emp.DateofJoining as DOJ,Emp.Designation as Designation,Dep.DepartmentName as DeptName'); $this->db->from('T_Payroll Pay'); - $this->db->join('T_Payroll_File payfile', 'Pay.PayOn = payfile.PayOn'); + //$this->db->join('T_Payroll_File payfile', 'Pay.PayOn = payfile.PayOn'); $this->db->join('T_Employee_Details Emp', 'Pay.EmpID = Emp.EmpID'); $this->db->join('T_DepartmentDetails Dep', 'Emp.Departmentcode = Dep.DEPCode'); + if($PayOn != '') + { $this->db->where('Pay.PayOn', $PayOn); + } + if($EmpId != '') { $this->db->where('Pay.EmpID', $EmpId); } - - $this->db->order_by("Pay.EmpID", "asc"); - + if($PayOn != '') + { + $this->db->order_by("Pay.EmpID", "asc"); + } + if($PayOn == '' && $EmpId == '') + { + $this->db->order_by("Pay.PayOn", "desc"); + } $query = $this->db->get(); return $query->result(); + //print_r($query->result());die(); } /* *//** @@ -164,12 +175,45 @@ class Payroll_model extends CI_Model */ function getPayOn() { - $this->db->select('DISTINCT(PayOn)'); - $this->db->from('T_Payroll_File'); + $this->db->select('DISTINCT(Month_Year)'); + $this->db->from('T_Monthly_Pay_Inputs'); + $this->db->order_by("Month_Year", "desc"); $query = $this->db->get(); return $query->result(); } + function getBankInfo() + { + $this->db->select('*'); + $this->db->from('T_Bank_Details'); + //$this->db->order_by("Month_Year", "desc"); + $query = $this->db->get(); + return $query->result(); + } + + function getReportforBank($bank,$payon) + { + $this->db->select('Pay.*,Emp.FirstName as FName ,Emp.LastName as Lname,Emp.PANNo as Pan,Emp.BankBranchName as BankName,Emp.IFSCCode as IFSC,Bank.Address as BAddress'); + $this->db->from('T_Payroll Pay'); + $this->db->join('T_Employee_Details Emp', 'Pay.EmpID = Emp.EmpID'); + $this->db->join('T_Bank_Details Bank', 'Emp.BankBranchName = Bank.Bank_name'); + $this->db->where('Emp.BankBranchName',$bank); + $this->db->where('Pay.PayOn',$payon); + $query = $this->db->get(); + return $query->result(); + } + + function getReportforPFESI($payon) + { + $this->db->select('Pay.EmployeeESI,Pay.PF,Pay.CompanyESI,Pay.CompanyPF,Emp.FirstName as FName ,Emp.LastName as Lname,Emp.PFNO,Emp.ESI'); + $this->db->from('T_Payroll Pay'); + $this->db->join('T_Employee_Details Emp', 'Pay.EmpID = Emp.EmpID'); + $this->db->where('Pay.PayOn',$payon); + $query = $this->db->get(); + return $query->result(); + + } + /* *//** * This function is used to get the PayOn details from T_Payroll_File * @return array $result : This is result of the query @@ -258,5 +302,20 @@ class Payroll_model extends CI_Model } + + function updateEmpPayslip($data) + { + + $key = $data['Key']; + $PayOn = $data['PayOn']; + $EmpID = $data['EmpID']; + + $this->db->where('Key', $key); + $this->db->where('PayOn',$PayOn); + $this->db->where('EmpID',$EmpID); + $result = $this->db->update('T_Payroll',$data); + return $result; + + } } ?> \ No newline at end of file diff --git a/application/views/addemppaydate.php b/application/views/addemppaydate.php index 87baddff..d709ad45 100755 --- a/application/views/addemppaydate.php +++ b/application/views/addemppaydate.php @@ -156,19 +156,7 @@ $("#due_started").datepicker({ -
-
- OT Rate(Per Hour)* -
- 'OT_Rate','value' => set_value('OT_Rate'), 'class' => 'form-control num' ,'style'=>'text-transform:uppercase;','pattern="([0-9]{1,3}([.][0-9]{1,2})?' ,'title'=>'Enter the Valid OT Rate, Minimum 1 digit, Maximum 2 digit'); - echo form_input($data); - - ?> -
-
-
+
Allowances* @@ -195,13 +183,8 @@ $("#due_started").datepicker({
- - - -
- - -
+ +
ESI Rate(%)*
@@ -213,6 +196,13 @@ $("#due_started").datepicker({
+ +
+ +
+ + +
@@ -372,12 +362,9 @@ function duecalculation() var totaldue=0; var loan=document.getElementById('Loan_Amount').value; var due=document.getElementById('monthly_due').value; - //alert(loan+'-'+due); - // if(loan == ""){ - // $('#Loan_Amount').val(0.00); - // $('#monthly_due').val(0.00); + + - // } if(loan != 0) { if(due == 0) @@ -387,7 +374,7 @@ function duecalculation() } else { - //due=document.getElementById('monthly_due').value; + totaldue=loan/due; if(totaldue < 1) diff --git a/application/views/bankreport.php b/application/views/bankreport.php new file mode 100644 index 00000000..79031004 --- /dev/null +++ b/application/views/bankreport.php @@ -0,0 +1,165 @@ + + "Jan", "02" => "Feb","03" => "Mar","04" => "Apr","05" => "May","06" => "June","07"=> "July","08"=> "Aug","09" => "Sep","10"=> "Oct","11" => "Nov","12"=>"Dec"); +?> + + +
+ +
+

+
Siddharth Industries - Bank Report Generator
+ +

+
+
+
+
+
+
+ + Select Bank + +
+
+
+ + + Month + + + +
+ +
+
+
+ + + + + + + + +
+ +
+ + +
+
\ No newline at end of file diff --git a/application/views/bankreportprint.php b/application/views/bankreportprint.php new file mode 100644 index 00000000..8aa13b4e --- /dev/null +++ b/application/views/bankreportprint.php @@ -0,0 +1,83 @@ +BAddress; + //die(); + } + } + + +?> + + + + + +

Bank Letter

+ +To
    The bank Manager,
+     ,
+     .
+
+ + + Sir/Madam, +

+ For Your kindly information please credit employees salary of for Siddharth Indistries.Total Amount i- Rs. +   () with cheque No:123456789

+ +

Employee List given Below:

+ + + + + + + + + + + + + + + + + + + + + + + + +
Employee NameSalary AmountAc NoIFSCBANK Name
FName . " ".$data->Lname;?>LessAdvance,2,'.','');?>BankAccountNumber;?>IFSC;?>BankName;?>
+ + \ No newline at end of file diff --git a/application/views/editPayslip.php b/application/views/editPayslip.php new file mode 100644 index 00000000..2100649b --- /dev/null +++ b/application/views/editPayslip.php @@ -0,0 +1,843 @@ + + "Jan", "02" => "Feb","03" => "Mar","04" => "Apr","05" => "May","06" => "June","07"=> "July","08"=> "Aug","09" => "Sep","10"=> "Oct","11" => "Nov","12"=>"Dec"); + +if(!empty($PayInfo)) +{ + + foreach ($PayInfo as $ep) + { + + + $Key = $ep->Key; + $PayOn1=$ep->PayOn; + $month = substr($PayOn1,0,2); + $year = substr($PayOn1,3); + $PayOn = $monthsoptions[$month]."-".$year; + $EmpID=$ep->EmpID; + $Empname=$ep->FName ." ". $ep->Lname ; + $EmpDetails = $EmpID ."-".$Empname; + $TotalCalDays = $ep->TotalCalDays; + $NoofDaysWorked = $ep->NoofDaysWorked; + + $LOP = $ep->LOP; + $Paid_Leave = $ep->Paid_Leave; + $ActualSalary = $ep->ActualSalary; + $PerDaySalary = $ep->PerDaySalary; + $WorkedSalary = $ep->WorkedSalary; + $HRA = $ep->HRA; + $OTperHours = $ep->OTperHours; + $OTSalary = $ep->OTSalary; + $ESIGrossSalary = $ep->ESIGrossSalary; + $EmployeeESI = $ep->EmployeeESI; + $PF = $ep->PF; + $CompanyESI = $ep->CompanyESI; + $CompanyPF = $ep->CompanyPF; + $TotalCompCon = $ep->TotalCompCon; + $OtherDeductions = $ep->OtherDeductions; + $TotalDeduction = $ep->TotalDeduction; + $SalaryAsPerPF = $ep->SalaryAsPerPF; + $FoodAllowance=$ep->FoodAllowance; + $Incentive = $ep->Incentive; + $Advance = $ep->Advance; + $BalanceAdvance = $ep->BalanceAdvance; + $LessAdvance = $ep->LessAdvance; + $Other_allowances = $ep->Other_allowances; + $Remarks = $ep->Remarks; + $BankAccountNumber = $ep->BankAccountNumber; + $PFNumber = $ep->PFNumber; + $ESINumber = $ep->ESINumber; + $UANNO = $ep->UANNO; + $Dob = date_create($ep->Dob); + $Dob = date_format($Dob,"Y-m-d"); + $Pan = $ep->Pan; + $BankName = $ep->BankName; + $AadharNo = $ep->AadharNo; + $IFSCCode = $ep->IFSCCode; + $DOJ = date_create($ep->DOJ); + $DOJ = date_format($DOJ,"Y-m-d"); + $Designation = $ep->Designation; + $DeptName = $ep->DeptName; + $totalearnings = $WorkedSalary + $HRA + $FoodAllowance + $Other_allowances + $Incentive + $OTSalary; + $totaldeductions = $PF + $EmployeeESI + $Advance + $OtherDeductions; + + + } +} + + +?> + + + +
+ +
+

+ +
Edit Payslip Details -
+ +

+
+ +
+
+ Back +
+
+
+ +
+ +
+ + + + +
+
+ Pay Details +
+
+ + + + + + + +
+
+
+ PayOn + + + +
+
+
+ + + +
+
+
+ Employee ID + +
+
+
+ +
+
+
+ Designation & Dept + " readonly> +
+
+
+ +
+
+
+ Total Calendar Days + +
+
+
+
+
+
+ Loss Of Pay + +
+
+
+
+
+
+ Paid Days + +
+
+
+ + + + +
+ + + +
+
+
+
+ Paid Leave + +
+
+
+
+
+
+ Loan Balance + +
+
+
+ +
+
+
+ OT Hrs Worked + +
+
+
+ +
+
+
+ Bank Name + +
+
+
+ +
+
+
+ Account No + +
+
+
+
+
+
+ IFSC Code + +
+
+
+ + + + + +
+ + + + +
+ + + +
+
+
+ PAN + +
+
+
+
+
+
+ PF Number + +
+
+
+ +
+
+
+ ESI Number + +
+
+
+ +
+
+
+ Aadhar No + +
+
+
+
+ +
+ Total Earnings                     +                          +                          +                          +                         Total Deductions +
+ +
+ +
+
+
+ + + +
+
+
+
+ + + + +
+
+
+ + +
+
+
+ + +
+
+
+ +
+ +
+
+
+
+
+
+ + +
+
+
+ +
+ + + + +
+ + +
+
+
+
+
+
+
+ + + + +
+
+
+ + +
+
+
+ + +
+
+
+ +
+ +
+
+
+
+
+
+ + +
+
+
+ +
+ +
+ + +
+
+
+ + + +
+
+
+
+ + + + +
+
+
+ + +
+
+
+ + +
+
+
+ +
+ +
+
+
+
+
+
+ + +
+
+
+ +
+ +
+ + +
+
+
+ + + +
+
+
+
+ + + + +
+
+
+ + +
+
+
+ + +
+
+
+ +
+ +
+
+
+
+
+
+ + +
+
+
+ +
+
+ + +
+
+
+
+
+
+
+ + + + +
+
+
+ + +
+
+
+ + +
+ +
+ +
+
+ +
+
+ + + + +
+ + +
+
+
+
+
+
+
+ + + + +
+
+
+ + +
+
+
+ + +
+ +
+ + +
+ +
+
+ + + +
+ + +
+
+
+ + + +
+
+
+
+ + + + +
+
+
+ + +
+
+
+ + +
+
+
+ +
+ +
+
+
+
+
+
+ + +
+
+
+ +
+ +
+ + +
+ +
+ + + + +
+ +
+ + +
+
+
+ +
+ +
+
+
+
+
+
+ + +
+
+
+ +
+ +
+ + +
+ +
+ + + + +
+ +
+ + +
+
+
+ +
+ +
+
+
+
+
+
+ + +
+
+
+ +
+ + + + + + +
+ + +
+ + + +
+
+
+ + + + + +
+ + + + + + diff --git a/application/views/emppayListing.php b/application/views/emppayListing.php index 3d97128a..123fc72d 100755 --- a/application/views/emppayListing.php +++ b/application/views/emppayListing.php @@ -19,17 +19,7 @@
- - +
@@ -41,7 +31,7 @@ - + @@ -65,7 +55,7 @@ - + @@ -82,7 +72,7 @@ @@ -91,15 +81,7 @@ + + + + + + + +
+ +
+

+
Employee Monthly Payment Listing
+

+
+
+ + +
+
+
+
+ +
+ +
+ + +
+ +
+ "Jan", "2" => "Feb","3" => "Mar","4" => "Apr","5" => "May","6" => "June","7"=> "July","8"=> "Aug","9" => "Sep","10"=> "Oct","11" => "Nov","12"=>"Dec"); + + $currentmontharray = array(array($month."-".$year => $monthsoptions[$month]."-".$year)); + // For find out Next and previous month and year from current year + $aftersix = array(); + for ($i = 0; $i <3;$i++){ + + $month++;; + if($month > 12) + { + $month = 1; + $year = $year +1; + } + + $aftersix[]=array($month."-".$year => $monthsoptions[$month]."-".$year); + + } + + $year = date("Y"); + $month = date("m"); + + $beforesix = array(); + for ($i = 3; $i >0;$i--){ + + $month--; + if($month < 1 ) + { + $month = 12; + $year = $year - 1; + } + + $beforesix[]=array($month."-".$year => $monthsoptions[$month]."-".$year); + + } + + $beforesix = array_reverse($beforesix); + + + $options = array_merge($options,$beforesix); + //echo count($options); + + $options = array_merge($options,$currentmontharray); + $options = array_merge($options,$aftersix); + + $ot = array(); + foreach($options as $o) + { + + foreach($o as $key => $value) + { + + $ot[$key] = $value; + + } + + } + ?> +
+
+ +
+
+
+
Basic Pay in ₹ HRA Rate in % HRA Amt in ₹OT Rate in ₹Allowances in ₹ PF Ratein % ESI Rate in %Basic_Pay ?> HRA_Rate ?> HRA_Amount; ?>OT_Rate ?>Allowances ?> PF_Rate ?> ESI_Rate ?>
+ + + + + + + + + + + + + + + + + + + EmpID,$testarray)) + { + $index--; + + + } + else{ + + + array_push($testarray,$record->EmpID); + + + + ?> + + + + + + + + + + + + + + + + +
S.NoEmployee IdEmployee NameLOP DaysPaid LeaveOT Hours Worked in HrsLoan Recovered in ₹Incentives in ₹Other Deductions in ₹
EmpID ?>FirstName ." ". $record->LastName ?>LOP_Days)){echo $record->LOP_Days;}else{echo "0.00";}?>Paid_leave)){echo $record->Paid_leave;}else { echo number_format(0.00,2,'.','');} ?>OT_Hrs_Worked)){echo $record->OT_Hrs_Worked;}else { echo number_format(0.00,2,'.','');} ?>Loan_Recovered)){if(is_numeric($record->Loan_Recovered)){echo number_format($record->Loan_Recovered,2,'.','');}else {echo $record->Loan_Recovered;}}else{echo number_format(0.00,2,'.','');} ?>Incentives)){echo $record->Incentives;}else{ echo number_format(0.00,2,'.','');;} ?>Other_Deductions)){echo $record->Other_Deductions; }else{ echo number_format(0.00,2,'.','');;} ?>
+

 

+
+
+ +
+
+
+ +
+
+
+ +
+ + \ No newline at end of file diff --git a/application/views/payslipgenerate.php b/application/views/payslipgenerate.php index 1a1d8069..76bee938 100755 --- a/application/views/payslipgenerate.php +++ b/application/views/payslipgenerate.php @@ -8,11 +8,11 @@ $(function() { - //Initialize Select2 Elements + $(".select2").select2(); -//$('#content').html(''); + $('#All').click(function(){ - //alert('clicked'); + if ($('#All').prop('checked')) { $('#Employee').attr('disabled', 'true'); @@ -203,9 +203,10 @@ $(function() { PayOn; + $Pay =$rl->Month_Year; if ($_POST['PayOn'] == $Pay) { @@ -240,10 +241,9 @@ $(function() {
- + - +
diff --git a/application/views/payslipgenerateprint.php b/application/views/payslipgenerateprint.php index ed316f5d..4eb7b28d 100755 --- a/application/views/payslipgenerateprint.php +++ b/application/views/payslipgenerateprint.php @@ -18,6 +18,7 @@ $ESInumber = ''; $TotalNoofDays = ''; $NoOfWorkingdays =''; + $paidleave = 0.00; $LOP=''; $ActualSalary = ''; $PerDaySalary = ''; @@ -45,6 +46,7 @@ $LoanAdvance='0.00'; $Otherallowances='0.00'; $TotalAmountInWords=''; + $TotalComapanyContribution = 0.00; if(!empty($Count)) { @@ -81,8 +83,10 @@ if(!empty($PayDetails)) $BankBranchName = $Pay->BankName; $PFnumber = $Pay->PFNumber; $ESInumber = $Pay->ESINumber; - $TotalNoofDays = $Pay->TotalNoofDays; + $TotalNoofDays = $Pay->TotalCalDays; $NoOfWorkingdays =$Pay->NoofDaysWorked; + $paidleave = $Pay->Paid_Leave; + $NoOfWorkingdays = $NoOfWorkingdays + $paidleave; $ActualSalary = $Pay->ActualSalary; $LOP=$Pay->LOP; $PerDaySalary = $Pay->PerDaySalary; @@ -92,6 +96,7 @@ if(!empty($PayDetails)) $OTWage = $Pay->OTWages; $OtherDeductions=$Pay->OtherDeductions; $LoanAdvance=$Pay->Advance; + $TotalComapanyContribution=$Pay->TotalCompCon; if($OTWage == '') { @@ -213,13 +218,13 @@ if($RecCount > 0) Date Of Birth Loss Of Pay Days - + PF Account Number Paid Days - + Bank Name @@ -298,6 +303,9 @@ if($RecCount > 0) Net Pay (TE - TD)(Rounded)     +Company Contribution(Rounded)   +  + Total Amount In Words   diff --git a/application/views/paysliplist.php b/application/views/paysliplist.php new file mode 100644 index 00000000..f627b5ee --- /dev/null +++ b/application/views/paysliplist.php @@ -0,0 +1,104 @@ + + +
+ +
+

+
Employee Monthly Payslip
+

+
+
+ + +
+
+
+
+ +
+ + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Month YearEmployee IdEmployee NamePaid DaysSalary in ₹Company Contribution in ₹Loan Recoverd in ₹Loan Balance in ₹Action
PayOn ?>EmpID ?>FName ." ". $record->Lname ?>NoofDaysWorked + $record->Paid_Leave) ?>LessAdvance ?>TotalCompCon ?>Advance)){echo number_format($record->Advance,2,'.','');}else {echo $record->Advance;} ?>BalanceAdvance ?> + + EDIT + +
+ +
+ +
+
+
+
+
+ + \ No newline at end of file diff --git a/application/views/pfreportprint.php b/application/views/pfreportprint.php new file mode 100644 index 00000000..e1f09f64 --- /dev/null +++ b/application/views/pfreportprint.php @@ -0,0 +1,85 @@ +BAddress; + //die(); + } + } + + +?> + + + + + +

PF Letter

+ +To
    The Consultant,
+     For Provident Fund,
+     Chennai.
+
+ + + Sir/Madam, +

+ For Your kindly information please credit employees PF of for Siddharth Indistries. +    + +

Employee List given Below:

+ + + + + + + + + + + + + + + + + + + + + + + + +
Employee NamePF Account NoEmployee PFCompany ShareTotal Amount
FName . " ".$data->Lname;?>PFNO;?>PF,2,'.','');?>CompanyPF,2,'.','');?>PF + $data->CompanyPF),2,'.','');?>
+

Total Amount:

+

Total Amount:

+ + + \ No newline at end of file diff --git a/assets/lightswitch/lightswitch/.gitattributes b/assets/lightswitch/lightswitch/.gitattributes new file mode 100644 index 00000000..412eeda7 --- /dev/null +++ b/assets/lightswitch/lightswitch/.gitattributes @@ -0,0 +1,22 @@ +# Auto detect text files and perform LF normalization +* text=auto + +# Custom for Visual Studio +*.cs diff=csharp +*.sln merge=union +*.csproj merge=union +*.vbproj merge=union +*.fsproj merge=union +*.dbproj merge=union + +# Standard to msysgit +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain diff --git a/assets/lightswitch/lightswitch/.gitignore b/assets/lightswitch/lightswitch/.gitignore new file mode 100644 index 00000000..40b878db --- /dev/null +++ b/assets/lightswitch/lightswitch/.gitignore @@ -0,0 +1 @@ +node_modules/ \ No newline at end of file diff --git a/assets/lightswitch/lightswitch/.jshintrc b/assets/lightswitch/lightswitch/.jshintrc new file mode 100644 index 00000000..992413ca --- /dev/null +++ b/assets/lightswitch/lightswitch/.jshintrc @@ -0,0 +1,24 @@ +{ + "bitwise" : true, + "camelcase" : true, + "curly" : true, + "eqeqeq" : true, + "es3" : true, + "eqnull" : true, + "forin" : true, + "freeze" : true, + "immed" : true, + "indent" : 2, + "jquery" : true, + "latedef" : true, + "newcap" : true, + "noarg" : true, + "noempty" : true, + "nonbsp" : true, + "nonew" : true, + "quotmark" : "single", + "sub" : true, + "trailing" : true, + "undef" : true, + "unused" : true +} \ No newline at end of file diff --git a/assets/lightswitch/lightswitch/.travis.yml b/assets/lightswitch/lightswitch/.travis.yml new file mode 100644 index 00000000..992827cf --- /dev/null +++ b/assets/lightswitch/lightswitch/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - "0.12" + - "0.11" + - "0.10" \ No newline at end of file diff --git a/assets/lightswitch/lightswitch/CHANGELOG.md b/assets/lightswitch/lightswitch/CHANGELOG.md new file mode 100644 index 00000000..19573a27 --- /dev/null +++ b/assets/lightswitch/lightswitch/CHANGELOG.md @@ -0,0 +1,56 @@ +## 2017-07-14 - Release 0.13.0 +* Skip columns where headers are not present. + +## 2017-05-10 - Release 0.12.0 +* Added `extractor` option. + +## 2015-06-05 - Release 0.11.1 +* Fixed `colspan` & `rowspan` support for complicated tables. + +## 2015-02-06 - Release 0.11.0 +* Added `textExtractor` option. + +## 2014-11-21 - Release 0.10.0 +* Added `ignoreEmptyRows` option. + +## 2014-9-24 - Release 0.9.0 +* Added `includeRowId` option. + +## 2014-4-14 - Release 0.8.3 +* Updated to correct version number. + +## 2014-4-14 - Release 0.8.2 +* Updated `onlyColumns` & `ignoreColumns` to work with colspans ([demo](http://jsfiddle.net/Mottie/4E2L6/10/)). + +## 2014-4-13 - Release 0.8.1 +* Added basic `.gitattributes` file. +* Updated `colspan` & `rowspan` support to work when applied to the same cell ([demo](http://jsfiddle.net/Mottie/4E2L6/9/)). + +## 2014-4-6 - Release 0.8.0 +* Added `colspan` & `rowspan` support. +* Fixed missing license banner. +* Updated Grunt plugins. +* Added more JSHint requirements and cleaned code. + +## 2014-3-26 - Release 0.7.0 +* Added `allowHTML` option to preserve HTML tags from table cells. +* Fixed Travis & Grunt tests. + +## 2013-07-25 - Release 0.6.0 +* Added `headings` option to define the headings of a table. When supplied, treats entire table as values. + +## 2013-04-23 - Release 0.5.1 +* Halved execution time. +* Added more JSHint requirements. + +## 2013-04-15 - Release 0.5.0 +* **The release breaks backwards compatibility for both option names and data-* attributes.** +* Changed option `ignoreColNum` to `ignoreColumns`. +* Merged `data-cell-value` and `data-column-name` into a single attribute: `data-override`. +* Added a new option `onlyColumns` to set which columns are included and ignores all others. + +## 2013-04-12 - Release 0.4.0 +* No longer requires the use of `th` elements - always uses the first row as column names. + +## 2013-02-15 - Release 0.3.0 +* Added tests and fixed many bugs. diff --git a/assets/lightswitch/lightswitch/Gruntfile.js b/assets/lightswitch/lightswitch/Gruntfile.js new file mode 100644 index 00000000..f0edc3e9 --- /dev/null +++ b/assets/lightswitch/lightswitch/Gruntfile.js @@ -0,0 +1,81 @@ +/*global module:false*/ +module.exports = function(grunt) { + 'use strict'; + + // Project configuration. + grunt.initConfig({ + pkg: grunt.file.readJSON( 'package.json' ), + + clean: { + build: [ 'lib' ] + }, + + concat: { + options: { + banner: '/**\n' + + ' * <%= pkg.name %>\n' + + ' * <%= pkg.description %>\n' + + ' *\n' + + ' * @author <%= pkg.author.name %>\n' + + ' * @copyright <%= pkg.author.name %> <%= grunt.template.today("yyyy") %>\n' + + ' * @license <%= pkg.licenses[0].type %> <<%= pkg.licenses[0].url %>>\n' + + ' * @link <%= pkg.homepage %>\n' + + ' * @module <%= pkg.name %>\n' + + ' * @version <%= pkg.version %>\n' + + ' */\n' + }, + dist: { + src: [ + 'src/jquery.tabletojson.js' + ], + dest : 'lib/jquery.tabletojson.js' + } + }, + jshint: { + files: { + src: [ + 'Gruntfile.js', + 'src/**/*.js', + 'test/specs/*.js' + ] + }, + options: { + jshintrc: '.jshintrc' + } + }, + uglify: { + options: { + banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' + + '<%= pkg.author.name %> */\n', + report: 'gzip' + }, + dist: { + files: { + 'lib/jquery.tabletojson.min.js': ['','lib/jquery.tabletojson.js'] + } + } + }, + qunit: { + files: ['test/index.html'] + }, + watch: { + scripts: { + files: ['src/**/*.js'], + tasks: ['build'] + } + } + }); + + grunt.loadNpmTasks('grunt-contrib-clean' ); + grunt.loadNpmTasks('grunt-contrib-jshint'); + grunt.loadNpmTasks('grunt-contrib-qunit'); + grunt.loadNpmTasks('grunt-contrib-concat'); + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-contrib-watch'); + + // Default task. + grunt.registerTask('build', ['clean:build', 'concat', 'uglify']); + grunt.registerTask('test', ['jshint', 'qunit']); + grunt.registerTask('default', ['test', 'build']); + +}; \ No newline at end of file diff --git a/assets/lightswitch/lightswitch/MIT-LICENSE b/assets/lightswitch/lightswitch/MIT-LICENSE new file mode 100644 index 00000000..ff2a0cd6 --- /dev/null +++ b/assets/lightswitch/lightswitch/MIT-LICENSE @@ -0,0 +1,7 @@ +Copyright (c) 2017 Daniel White + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/assets/lightswitch/lightswitch/README.md b/assets/lightswitch/lightswitch/README.md new file mode 100644 index 00000000..06a8f42c --- /dev/null +++ b/assets/lightswitch/lightswitch/README.md @@ -0,0 +1,163 @@ +# Table To JSON + +[![Build Status](https://travis-ci.org/lightswitch05/table-to-json.png?branch=master)](https://travis-ci.org/lightswitch05/table-to-json) +[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/lightswitch05/table-to-json?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) + +jQuery plugin to serialize HTML tables into javascript objects. + +## Links +- Demo: http://lightswitch05.github.io/table-to-json/ +- Plunker Template: http://plnkr.co/edit/iQFtcEEZkvsMJ2UqcrlW?p=preview + +## Features +- Automatically finds column headings + - Override found column headings by using `data-override="overridden column name"` + - Always uses first row as column headings regardless of `th` and `td` tags +- Override cell values column names by using `data-override="new value"` +- Ignorable columns +- Not confused by nested tables +- Works with `rowspan` and `colspan` + +## Options +- `ignoreColumns` + - Array of column indexes to ignore. + - Default: `[]` +- `onlyColumns` + - Array of column indexes to include, all other columns are ignored. This takes presidence over `ignoreColumns` when provided. + - Default: `null` - all columns +- `ignoreHiddenRows` + - Boolean if hidden rows should be ignored or not. + - Default: `true` +- `ignoreEmptyRows` + - Boolean if empty rows should be ignored or not. + - Default: `false` +- `headings` + - Array of table headings to use. When supplied, treats entire table as values including the first `` + - Default: `null` +- `allowHTML` + - Boolean if HTML tags in table cells should be preserved + - Default: `false` +- `includeRowId` + - Either a `boolean` or a `string`. If `true`, the the `id` attribute on the table's `` elements will be included in the JSON as `rowId`. To override the name `rowId`, supply a string of the name you would like to use. + - Default: `false` +- `textDataOverride` + - String containing data-attribute which contains data which overrides the text contained within the table cell + - Default: 'data-override' +- `textExtractor` + - alias of `extractor` +- `extractor` + - Function : function that is used on all *tbody* cells to extract text from the cells; a value in `data-override` will prevent this function from being called. Example: + + ```js + $('table').tableToJSON({ + extractor : function(cellIndex, $cell) { + // get text from the span inside table cells; + // if empty or non-existant, get the cell text + return $cell.find('span').text() || $cell.text(); + } + }); + ``` + + ```js + $('table').tableToJSON({ + extractor : function(cellIndex, $cell) { + return { + name: $cell.find('span').text(), + avatar: $cell.find('img').attr('src') + }; + } + }); + ``` + + - Object : object containing a zero-based cell index (this *does not* take `colspan` cells into account!) of the table; a value in `data-override` will prevent this function from being called. Example: + + ```js + $('table').tableToJSON({ + extractor : { + 0 : function(cellIndex, $cell) { + return $cell.find('em').text(); + }, + 1 : function(cellIndex, $cell) { + return $cell.find('span').text(); + } + } + }); + ``` + + - Default: `null` + +## Example + +```html + + + + + + + + + + + + + + + + + + + + + + + + + +
First NameLast NamePoints
JillSmith50
EveJackson94
JohnDoe80
AdamJohnson67
+ + +``` + +## Contributing + +* Install [Node.js](http://nodejs.org/). + * this will also the `npm` package manager. +* run `npm install` from app root directory. + * This installs grunt and other dependencies See `package.json` for a full list. +* run `npm install -g grunt-cli`. +* run `grunt` to run tests and create a new build in `/lib`. +* Make the changes you want. +* Make tests for the changes. +* Submit a pull request, please submit to the `develop` branch. + +### Looking for a server-side solution? + +[Colin Tremblay](https://github.com/tremblay) is working on a PHP implementation at [HTML-Table-To-JSON](https://github.com/tremblay/HTML-Table-to-JSON) + +### Special Thanks +* [imamathwiz](https://github.com/imamathwiz) for adding `allowHTML` option and various other changes. +* [nenads](https://github.com/nenads) for adding `headings` option. +* [Mottie](https://github.com/Mottie) for adding `rowspan` & `colspan` support. Also adding the `textExtractor` & `dataOverride` feature! +* [station384](https://github.com/station384) for adding `includeRowId` support. +* [dayAlone](https://github.com/dayAlone) for adding `ignoreEmptyRows` option. +* [danielapsmaior](https://github.com/danielapsmaior) for discovering and fixing a `rowspan` & `colspan` bug. +* [koshuang](https://github.com/koshuang) for adding `extractor` feature! +* [noma4i](https://github.com/noma4i) added feature "Skip columns where headers are not present" + diff --git a/assets/lightswitch/lightswitch/bower.json b/assets/lightswitch/lightswitch/bower.json new file mode 100644 index 00000000..e0b1446f --- /dev/null +++ b/assets/lightswitch/lightswitch/bower.json @@ -0,0 +1,27 @@ +{ + "name": "table-to-json", + "version": "0.13.0", + "main": [ + "./lib/jquery.tabletojson.min.js" + ], + "dependencies": { + "jquery": "*" + }, + "homepage": "https://github.com/lightswitch05/table-to-json", + "authors": [ + "Daniel White " + ], + "description": "jQuery plugin that reads an HTML table and returns a javascript object representing the values and columns of the table", + "license": "MIT", + "keywords": [ + "table-to-json" + ], + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "tests", + "src" + ] +} diff --git a/assets/lightswitch/lightswitch/lib/jquery.tabletojson.js b/assets/lightswitch/lightswitch/lib/jquery.tabletojson.js new file mode 100644 index 00000000..ba8442b5 --- /dev/null +++ b/assets/lightswitch/lightswitch/lib/jquery.tabletojson.js @@ -0,0 +1,193 @@ +/** + * table-to-json + * jQuery plugin that reads an HTML table and returns a javascript object representing the values and columns of the table + * + * @author Daniel White + * @copyright Daniel White 2017 + * @license MIT + * @link https://github.com/lightswitch05/table-to-json + * @module table-to-json + * @version 0.13.0 + */ +(function( $ ) { + 'use strict'; + + $.fn.tableToJSON = function(opts) { + + // Set options + var defaults = { + ignoreColumns: [], + onlyColumns: null, + ignoreHiddenRows: true, + ignoreEmptyRows: false, + headings: null, + allowHTML: false, + includeRowId: false, + textDataOverride: 'data-override', + extractor: null, + textExtractor: null + }; + opts = $.extend(defaults, opts); + + var notNull = function(value) { + return value !== undefined && value !== null; + }; + + var notEmpty = function(value) { + return value !== undefined && value.length > 0; + }; + + var ignoredColumn = function(index) { + if( notNull(opts.onlyColumns) ) { + return $.inArray(index, opts.onlyColumns) === -1; + } + return $.inArray(index, opts.ignoreColumns) !== -1; + }; + + var arraysToHash = function(keys, values) { + var result = {}, index = 0; + $.each(values, function(i, value) { + // when ignoring columns, the header option still starts + // with the first defined column + if ( index < keys.length && notNull(value) ) { + if (notEmpty(keys[index])){ + result[ keys[index] ] = value; + } + index++; + } + }); + return result; + }; + + var cellValues = function(cellIndex, cell, isHeader) { + var $cell = $(cell), + // extractor + extractor = opts.extractor || opts.textExtractor, + override = $cell.attr(opts.textDataOverride), + value; + // don't use extractor for header cells + if ( extractor === null || isHeader ) { + return $.trim( override || ( opts.allowHTML ? $cell.html() : cell.textContent || $cell.text() ) || '' ); + } else { + // overall extractor function + if ( $.isFunction(extractor) ) { + value = override || extractor(cellIndex, $cell); + return typeof value === 'string' ? $.trim( value ) : value; + } else if ( typeof extractor === 'object' && $.isFunction( extractor[cellIndex] ) ) { + value = override || extractor[cellIndex](cellIndex, $cell); + return typeof value === 'string' ? $.trim( value ) : value; + } + } + // fallback + return $.trim( override || ( opts.allowHTML ? $cell.html() : cell.textContent || $cell.text() ) || '' ); + }; + + var rowValues = function(row, isHeader) { + var result = []; + var includeRowId = opts.includeRowId; + var useRowId = (typeof includeRowId === 'boolean') ? includeRowId : (typeof includeRowId === 'string') ? true : false; + var rowIdName = (typeof includeRowId === 'string') === true ? includeRowId : 'rowId'; + if (useRowId) { + if (typeof $(row).attr('id') === 'undefined') { + result.push(rowIdName); + } + } + $(row).children('td,th').each(function(cellIndex, cell) { + result.push( cellValues(cellIndex, cell, isHeader) ); + }); + return result; + }; + + var getHeadings = function(table) { + var firstRow = table.find('tr:first').first(); + return notNull(opts.headings) ? opts.headings : rowValues(firstRow, true); + }; + + var construct = function(table, headings) { + var i, j, len, len2, txt, $row, $cell, + tmpArray = [], cellIndex = 0, result = []; + table.children('tbody,*').children('tr').each(function(rowIndex, row) { + if( rowIndex > 0 || notNull(opts.headings) ) { + var includeRowId = opts.includeRowId; + var useRowId = (typeof includeRowId === 'boolean') ? includeRowId : (typeof includeRowId === 'string') ? true : false; + + $row = $(row); + + var isEmpty = ($row.find('td').length === $row.find('td:empty').length) ? true : false; + + if( ( $row.is(':visible') || !opts.ignoreHiddenRows ) && ( !isEmpty || !opts.ignoreEmptyRows ) && ( !$row.data('ignore') || $row.data('ignore') === 'false' ) ) { + cellIndex = 0; + if (!tmpArray[rowIndex]) { + tmpArray[rowIndex] = []; + } + if (useRowId) { + cellIndex = cellIndex + 1; + if (typeof $row.attr('id') !== 'undefined') { + tmpArray[rowIndex].push($row.attr('id')); + } else { + tmpArray[rowIndex].push(''); + } + } + + $row.children().each(function(){ + $cell = $(this); + // skip column if already defined + while (tmpArray[rowIndex][cellIndex]) { cellIndex++; } + + // process rowspans + if ($cell.filter('[rowspan]').length) { + len = parseInt( $cell.attr('rowspan'), 10) - 1; + txt = cellValues(cellIndex, $cell); + for (i = 1; i <= len; i++) { + if (!tmpArray[rowIndex + i]) { tmpArray[rowIndex + i] = []; } + tmpArray[rowIndex + i][cellIndex] = txt; + } + } + // process colspans + if ($cell.filter('[colspan]').length) { + len = parseInt( $cell.attr('colspan'), 10) - 1; + txt = cellValues(cellIndex, $cell); + for (i = 1; i <= len; i++) { + // cell has both col and row spans + if ($cell.filter('[rowspan]').length) { + len2 = parseInt( $cell.attr('rowspan'), 10); + for (j = 0; j < len2; j++) { + tmpArray[rowIndex + j][cellIndex + i] = txt; + } + } else { + tmpArray[rowIndex][cellIndex + i] = txt; + } + } + } + + txt = tmpArray[rowIndex][cellIndex] || cellValues(cellIndex, $cell); + if (notNull(txt)) { + tmpArray[rowIndex][cellIndex] = txt; + } + cellIndex++; + }); + } + } + }); + $.each(tmpArray, function( i, row ){ + if (notNull(row)) { + // remove ignoredColumns / add onlyColumns + var newRow = notNull(opts.onlyColumns) || opts.ignoreColumns.length ? + $.grep(row, function(v, index){ return !ignoredColumn(index); }) : row, + + // remove ignoredColumns / add onlyColumns if headings is not defined + newHeadings = notNull(opts.headings) ? headings : + $.grep(headings, function(v, index){ return !ignoredColumn(index); }); + + txt = arraysToHash(newHeadings, newRow); + result[result.length] = txt; + } + }); + return result; + }; + + // Run + var headings = getHeadings(this); + return construct(this, headings); + }; +})( jQuery ); diff --git a/assets/lightswitch/lightswitch/lib/jquery.tabletojson.min.js b/assets/lightswitch/lightswitch/lib/jquery.tabletojson.min.js new file mode 100644 index 00000000..783585df --- /dev/null +++ b/assets/lightswitch/lightswitch/lib/jquery.tabletojson.min.js @@ -0,0 +1,2 @@ +/*! table-to-json - v0.13.0 - Daniel White */ +!function(a){"use strict";a.fn.tableToJSON=function(b){var c={ignoreColumns:[],onlyColumns:null,ignoreHiddenRows:!0,ignoreEmptyRows:!1,headings:null,allowHTML:!1,includeRowId:!1,textDataOverride:"data-override",extractor:null,textExtractor:null};b=a.extend(c,b);var d=function(a){return void 0!==a&&null!==a},e=function(a){return void 0!==a&&a.length>0},f=function(c){return d(b.onlyColumns)?-1===a.inArray(c,b.onlyColumns):-1!==a.inArray(c,b.ignoreColumns)},g=function(b,c){var f={},g=0;return a.each(c,function(a,c){g0||d(b.headings)){var f=b.includeRowId,g="boolean"==typeof f?f:"string"==typeof f;n=a(e);var r=n.find("td").length===n.find("td:empty").length;!n.is(":visible")&&b.ignoreHiddenRows||r&&b.ignoreEmptyRows||n.data("ignore")&&"false"!==n.data("ignore")||(q=0,p[c]||(p[c]=[]),g&&(q+=1,void 0!==n.attr("id")?p[c].push(n.attr("id")):p[c].push("")),n.children().each(function(){for(o=a(this);p[c][q];)q++;if(o.filter("[rowspan]").length)for(k=parseInt(o.attr("rowspan"),10)-1,m=h(q,o),i=1;i<=k;i++)p[c+i]||(p[c+i]=[]),p[c+i][q]=m;if(o.filter("[colspan]").length)for(k=parseInt(o.attr("colspan"),10)-1,m=h(q,o),i=1;i<=k;i++)if(o.filter("[rowspan]").length)for(l=parseInt(o.attr("rowspan"),10),j=0;j 0; + }; + + var ignoredColumn = function(index) { + if( notNull(opts.onlyColumns) ) { + return $.inArray(index, opts.onlyColumns) === -1; + } + return $.inArray(index, opts.ignoreColumns) !== -1; + }; + + var arraysToHash = function(keys, values) { + var result = {}, index = 0; + $.each(values, function(i, value) { + // when ignoring columns, the header option still starts + // with the first defined column + if ( index < keys.length && notNull(value) ) { + if (notEmpty(keys[index])){ + result[ keys[index] ] = value; + } + index++; + } + }); + return result; + }; + + var cellValues = function(cellIndex, cell, isHeader) { + var $cell = $(cell), + // extractor + extractor = opts.extractor || opts.textExtractor, + override = $cell.attr(opts.textDataOverride), + value; + // don't use extractor for header cells + if ( extractor === null || isHeader ) { + return $.trim( override || ( opts.allowHTML ? $cell.html() : cell.textContent || $cell.text() ) || '' ); + } else { + // overall extractor function + if ( $.isFunction(extractor) ) { + value = override || extractor(cellIndex, $cell); + return typeof value === 'string' ? $.trim( value ) : value; + } else if ( typeof extractor === 'object' && $.isFunction( extractor[cellIndex] ) ) { + value = override || extractor[cellIndex](cellIndex, $cell); + return typeof value === 'string' ? $.trim( value ) : value; + } + } + // fallback + return $.trim( override || ( opts.allowHTML ? $cell.html() : cell.textContent || $cell.text() ) || '' ); + }; + + var rowValues = function(row, isHeader) { + var result = []; + var includeRowId = opts.includeRowId; + var useRowId = (typeof includeRowId === 'boolean') ? includeRowId : (typeof includeRowId === 'string') ? true : false; + var rowIdName = (typeof includeRowId === 'string') === true ? includeRowId : 'rowId'; + if (useRowId) { + if (typeof $(row).attr('id') === 'undefined') { + result.push(rowIdName); + } + } + $(row).children('td,th').each(function(cellIndex, cell) { + result.push( cellValues(cellIndex, cell, isHeader) ); + }); + return result; + }; + + var getHeadings = function(table) { + var firstRow = table.find('tr:first').first(); + return notNull(opts.headings) ? opts.headings : rowValues(firstRow, true); + }; + + var construct = function(table, headings) { + var i, j, len, len2, txt, $row, $cell, + tmpArray = [], cellIndex = 0, result = []; + table.children('tbody,*').children('tr').each(function(rowIndex, row) { + if( rowIndex > 0 || notNull(opts.headings) ) { + var includeRowId = opts.includeRowId; + var useRowId = (typeof includeRowId === 'boolean') ? includeRowId : (typeof includeRowId === 'string') ? true : false; + + $row = $(row); + + var isEmpty = ($row.find('td').length === $row.find('td:empty').length) ? true : false; + + if( ( $row.is(':visible') || !opts.ignoreHiddenRows ) && ( !isEmpty || !opts.ignoreEmptyRows ) && ( !$row.data('ignore') || $row.data('ignore') === 'false' ) ) { + cellIndex = 0; + if (!tmpArray[rowIndex]) { + tmpArray[rowIndex] = []; + } + if (useRowId) { + cellIndex = cellIndex + 1; + if (typeof $row.attr('id') !== 'undefined') { + tmpArray[rowIndex].push($row.attr('id')); + } else { + tmpArray[rowIndex].push(''); + } + } + + $row.children().each(function(){ + $cell = $(this); + // skip column if already defined + while (tmpArray[rowIndex][cellIndex]) { cellIndex++; } + + // process rowspans + if ($cell.filter('[rowspan]').length) { + len = parseInt( $cell.attr('rowspan'), 10) - 1; + txt = cellValues(cellIndex, $cell); + for (i = 1; i <= len; i++) { + if (!tmpArray[rowIndex + i]) { tmpArray[rowIndex + i] = []; } + tmpArray[rowIndex + i][cellIndex] = txt; + } + } + // process colspans + if ($cell.filter('[colspan]').length) { + len = parseInt( $cell.attr('colspan'), 10) - 1; + txt = cellValues(cellIndex, $cell); + for (i = 1; i <= len; i++) { + // cell has both col and row spans + if ($cell.filter('[rowspan]').length) { + len2 = parseInt( $cell.attr('rowspan'), 10); + for (j = 0; j < len2; j++) { + tmpArray[rowIndex + j][cellIndex + i] = txt; + } + } else { + tmpArray[rowIndex][cellIndex + i] = txt; + } + } + } + + txt = tmpArray[rowIndex][cellIndex] || cellValues(cellIndex, $cell); + if (notNull(txt)) { + tmpArray[rowIndex][cellIndex] = txt; + } + cellIndex++; + }); + } + } + }); + $.each(tmpArray, function( i, row ){ + if (notNull(row)) { + // remove ignoredColumns / add onlyColumns + var newRow = notNull(opts.onlyColumns) || opts.ignoreColumns.length ? + $.grep(row, function(v, index){ return !ignoredColumn(index); }) : row, + + // remove ignoredColumns / add onlyColumns if headings is not defined + newHeadings = notNull(opts.headings) ? headings : + $.grep(headings, function(v, index){ return !ignoredColumn(index); }); + + txt = arraysToHash(newHeadings, newRow); + result[result.length] = txt; + } + }); + return result; + }; + + // Run + var headings = getHeadings(this); + return construct(this, headings); + }; +})( jQuery ); diff --git a/assets/lightswitch/lightswitch/tabletojson.jquery.json b/assets/lightswitch/lightswitch/tabletojson.jquery.json new file mode 100644 index 00000000..f12d44a0 --- /dev/null +++ b/assets/lightswitch/lightswitch/tabletojson.jquery.json @@ -0,0 +1,30 @@ +{ + "name": "tabletojson", + "title": "Table To JSON", + "description": "jQuery plugin that reads an HTML table and returns a javascript object representing the values and columns of the table", + "keywords": [ + "table", + "serialize", + "tabletojson", + "json" + ], + "version": "0.12.0", + "author": { + "name": "Daniel White", + "url": "http://www.developerdan.com" + }, + "licenses": [ + { + "type": "MIT", + "url": "https://github.com/lightswitch05/table-to-json/blob/master/MIT-LICENSE" + } + ], + "bugs": "https://github.com/lightswitch05/table-to-json/issues", + "homepage": "https://github.com/lightswitch05/table-to-json", + "docs": "https://github.com/lightswitch05/table-to-json", + "download": "https://github.com/lightswitch05/table-to-json", + "demo": "http://lightswitch05.github.io/table-to-json/", + "dependencies": { + "jquery": ">=1.5" + } +} diff --git a/assets/lightswitch/lightswitch/test/index.html b/assets/lightswitch/lightswitch/test/index.html new file mode 100644 index 00000000..00fd4162 --- /dev/null +++ b/assets/lightswitch/lightswitch/test/index.html @@ -0,0 +1,22 @@ + + + + + Table To JSON Test + + + + + +

MyApp Test Suite

+

+
+

+
    +
    + + + + + + \ No newline at end of file diff --git a/assets/lightswitch/lightswitch/test/specs/content.test.js b/assets/lightswitch/lightswitch/test/specs/content.test.js new file mode 100644 index 00000000..41796bed --- /dev/null +++ b/assets/lightswitch/lightswitch/test/specs/content.test.js @@ -0,0 +1,645 @@ +/*global module, test, expect, deepEqual */ + +module('content'); + +/* Ignore nested tables in cells with just td's*/ +test('ignore nested in cells', function() { + $('#qunit-fixture').html( + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
    First NameLast NamePoints
    JillSmith50
    Eve
    1
    2
    Jackson94
    JohnDoe80
    ' + ); + + + expect(1); + var table = $('#test-table').tableToJSON(); + var expected = [{'First Name':'Jill', 'Last Name':'Smith', 'Points':'50'}, + {'First Name':'Eve 12', 'Last Name':'Jackson', 'Points':'94'}, + {'First Name':'John', 'Last Name':'Doe', 'Points':'80'}]; + deepEqual(table, expected); +}); + +/* Ignore nested tables in cells with th's and td's*/ +test('ignore nested and in cells', function() { + $('#qunit-fixture').html( + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
    First NameLast NamePoints
    JillSmith50
    Eve
    number
    1
    2
    Jackson94
    JohnDoe80
    ' + ); + + + expect(1); + var table = $('#test-table').tableToJSON(); + var expected = [{'First Name':'Jill', 'Last Name':'Smith', 'Points':'50'}, + {'First Name':'Eve number12', 'Last Name':'Jackson', 'Points':'94'}, + {'First Name':'John', 'Last Name':'Doe', 'Points':'80'}]; + deepEqual(table, expected); +}); + +/* Ignore nested tables in headings with just td's*/ +test('ignore nested in headings', function() { + $('#qunit-fixture').html( + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
    First NameLast Name
    1
    2
    Points
    JillSmith50
    EveJackson94
    JohnDoe80
    ' + ); + + + expect(1); + var table = $('#test-table').tableToJSON(); + var expected = [{'First Name':'Jill', 'Last Name 12':'Smith', 'Points':'50'}, + {'First Name':'Eve', 'Last Name 12':'Jackson', 'Points':'94'}, + {'First Name':'John', 'Last Name 12':'Doe', 'Points':'80'}]; + deepEqual(table, expected); +}); + +/* Ignore nested tables in headings with th's and td's*/ +test('ignore nested and in headings', function() { + $('#qunit-fixture').html( + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
    First NameLast Name
    number
    1
    2
    Points
    JillSmith50
    EveJackson94
    JohnDoe80
    ' + ); + + + expect(1); + var table = $('#test-table').tableToJSON(); + var expected = [{'First Name':'Jill', 'Last Name number12':'Smith', 'Points':'50'}, + {'First Name':'Eve', 'Last Name number12':'Jackson', 'Points':'94'}, + {'First Name':'John', 'Last Name number12':'Doe', 'Points':'80'}]; + deepEqual(table, expected); +}); + +/* Links are retrieved as values */ +test('links are just values', function() { + $('#qunit-fixture').html( + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
    First NameLast NamePoints
    JillSmith50
    EveJackson94
    JohnDoe80
    ' + ); + + + expect(1); + var table = $('#test-table').tableToJSON(); + var expected = [{'First Name':'Jill', 'Last Name':'Smith', 'Points':'50'}, + {'First Name':'Eve', 'Last Name':'Jackson', 'Points':'94'}, + {'First Name':'John', 'Last Name':'Doe', 'Points':'80'}]; + deepEqual(table, expected); +}); + +/* A complex table */ +test('complex table', function() { + $('#qunit-fixture').html( + '
    Status Location Zone Tier Install Calc Install Rate
    INCOMPLETE location 1 QTY B 9.5
    INCOMPLETE Empty Empty Empty Empty Empty
    ' + ); + + + expect(1); + var table = $('#test-table').tableToJSON(); + var expected = [{'id':'oaWd4cs2JHY660pG', 'State':'INCOMPLETE', 'BCS':'location', 'ZONE':'1', 'TIER':'QTY', 'INSTALL_CALC':'B', 'INSTALL_R1':'9.5'}]; + deepEqual(table, expected); +}); + +/* A table with rowspan & colspan */ +test('rowspan & colspan in tbody', function() { + $('#qunit-fixture').html( + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
    linevalue1value2value3value4
    11.11.21.31.4
    1.51.61.7
    22.12.22.32.4
    2.52.62.7
    33.13.2
    3.43.5
    ' + ); + + expect(1); + var table = $('#test-table').tableToJSON(); + var expected = [ + {'line':'1','value1':'1.1','value2':'1.2','value3':'1.3','value4':'1.4'}, + {'line':'1','value1':'1.5','value2':'1.6','value3':'1.7','value4':'1.4'}, + {'line':'2','value1':'2.1','value2':'2.2','value3':'2.3','value4':'2.4'}, + {'line':'2','value1':'2.5','value2':'2.5','value3':'2.6','value4':'2.7'}, + {'line':'3','value1':'3.1','value2':'3.1','value3':'3.2','value4':'3.2'}, + {'line':'3','value1':'3.1','value2':'3.1','value3':'3.4','value4':'3.5'} + ]; + deepEqual(table, expected); +}); + +/* A table with rowspan & colspan & ignoreColumns */ +test('ignoreColumns with rowspan & colspan in tbody', function() { + $('#qunit-fixture').html( + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
    linevalue1value2value3value4
    11.11.21.31.4
    1.51.61.7
    22.12.22.32.4
    2.52.62.7
    33.13.2
    3.43.5
    ' + ); + + expect(5); + var $table = $('#test-table'); + $table.find('tr:eq(0)').hide(); + var table = $table.tableToJSON({ headings: [ 'v1','v2','v3','v4' ], ignoreColumns : [0] }); + $table.find('tr:eq(0)').show(); + var expected = [ + {'v1':'1.1','v2':'1.2','v3':'1.3','v4':'1.4'}, + {'v1':'1.5','v2':'1.6','v3':'1.7','v4':'1.4'}, + {'v1':'2.1','v2':'2.2','v3':'2.3','v4':'2.4'}, + {'v1':'2.5','v2':'2.5','v3':'2.6','v4':'2.7'}, + {'v1':'3.1','v2':'3.1','v3':'3.2','v4':'3.2'}, + {'v1':'3.1','v2':'3.1','v3':'3.4','v4':'3.5'} + ]; + deepEqual(table, expected); + + table = $table.tableToJSON({ ignoreColumns : [1] }); + expected = [ + {'line':'1','value2':'1.2','value3':'1.3','value4':'1.4'}, + {'line':'1','value2':'1.6','value3':'1.7','value4':'1.4'}, + {'line':'2','value2':'2.2','value3':'2.3','value4':'2.4'}, + {'line':'2','value2':'2.5','value3':'2.6','value4':'2.7'}, + {'line':'3','value2':'3.1','value3':'3.2','value4':'3.2'}, + {'line':'3','value2':'3.1','value3':'3.4','value4':'3.5'} + ]; + deepEqual(table, expected); + + table = $table.tableToJSON({ ignoreColumns : [2] }); + expected = [ + {'line':'1','value1':'1.1','value3':'1.3','value4':'1.4'}, + {'line':'1','value1':'1.5','value3':'1.7','value4':'1.4'}, + {'line':'2','value1':'2.1','value3':'2.3','value4':'2.4'}, + {'line':'2','value1':'2.5','value3':'2.6','value4':'2.7'}, + {'line':'3','value1':'3.1','value3':'3.2','value4':'3.2'}, + {'line':'3','value1':'3.1','value3':'3.4','value4':'3.5'} + ]; + deepEqual(table, expected); + + table = $table.tableToJSON({ ignoreColumns : [3] }); + expected = [ + {'line':'1','value1':'1.1','value2':'1.2','value4':'1.4'}, + {'line':'1','value1':'1.5','value2':'1.6','value4':'1.4'}, + {'line':'2','value1':'2.1','value2':'2.2','value4':'2.4'}, + {'line':'2','value1':'2.5','value2':'2.5','value4':'2.7'}, + {'line':'3','value1':'3.1','value2':'3.1','value4':'3.2'}, + {'line':'3','value1':'3.1','value2':'3.1','value4':'3.5'} + ]; + deepEqual(table, expected); + + table = $table.tableToJSON({ ignoreColumns : [4] }); + expected = [ + {'line':'1','value1':'1.1','value2':'1.2','value3':'1.3'}, + {'line':'1','value1':'1.5','value2':'1.6','value3':'1.7'}, + {'line':'2','value1':'2.1','value2':'2.2','value3':'2.3'}, + {'line':'2','value1':'2.5','value2':'2.5','value3':'2.6'}, + {'line':'3','value1':'3.1','value2':'3.1','value3':'3.2'}, + {'line':'3','value1':'3.1','value2':'3.1','value3':'3.4'} + ]; + deepEqual(table, expected); + +}); + +/* A complex table with row & col spans */ +test('complex table with row & col spans', function() { + $('#qunit-fixture').html( + '
    Rota Descrição Descritor Ano Mês (completo) Dia Intervalo 30min Totais
    nullAutoAtendimento201501-Jan0611:00:001
    12:00:003
    Fila201501-Jan0611:00:001
    12:00:002
    2711:30:001
    12:00:001
    15:00:004
    16:00:002
    Inicio201501-Jan0611:00:002
    12:00:005
    2711:30:001
    12:00:001
    15:00:004
    16:00:002
    Rota externaAutoAtendimento201501-Jan0612:00:001
    12:30:002
    Fila201501-Jan0612:00:001
    12:30:002
    2710:30:001
    11:00:002
    11:30:001
    12:00:002
    16:00:002
    18:30:001
    19:00:001
    Inicio201501-Jan0612:00:002
    12:30:004
    2710:30:002
    11:00:002
    11:30:001
    12:00:002
    16:00:002
    18:30:001
    19:00:001
    3020:00:001
    02-Feb0314:30:001
    Totais 34
    ' + ); + + + expect(1); + var table = $('#test-table').tableToJSON(); + var expected = [ + { + 'Ano': '2015', + 'Descrição Descritor': 'AutoAtendimento', + 'Dia': '06', + 'Intervalo 30min': '11:00:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'null', + 'Totais': '1' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'AutoAtendimento', + 'Dia': '06', + 'Intervalo 30min': '12:00:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'null', + 'Totais': '3' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'Fila', + 'Dia': '06', + 'Intervalo 30min': '11:00:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'null', + 'Totais': '1' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'Fila', + 'Dia': '06', + 'Intervalo 30min': '12:00:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'null', + 'Totais': '2' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'Fila', + 'Dia': '27', + 'Intervalo 30min': '11:30:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'null', + 'Totais': '1' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'Fila', + 'Dia': '27', + 'Intervalo 30min': '12:00:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'null', + 'Totais': '1' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'Fila', + 'Dia': '27', + 'Intervalo 30min': '15:00:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'null', + 'Totais': '4' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'Fila', + 'Dia': '27', + 'Intervalo 30min': '16:00:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'null', + 'Totais': '2' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'Inicio', + 'Dia': '06', + 'Intervalo 30min': '11:00:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'null', + 'Totais': '2' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'Inicio', + 'Dia': '06', + 'Intervalo 30min': '12:00:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'null', + 'Totais': '5' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'Inicio', + 'Dia': '27', + 'Intervalo 30min': '11:30:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'null', + 'Totais': '1' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'Inicio', + 'Dia': '27', + 'Intervalo 30min': '12:00:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'null', + 'Totais': '1' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'Inicio', + 'Dia': '27', + 'Intervalo 30min': '15:00:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'null', + 'Totais': '4' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'Inicio', + 'Dia': '27', + 'Intervalo 30min': '16:00:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'null', + 'Totais': '2' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'AutoAtendimento', + 'Dia': '06', + 'Intervalo 30min': '12:00:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'Rota externa', + 'Totais': '1' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'AutoAtendimento', + 'Dia': '06', + 'Intervalo 30min': '12:30:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'Rota externa', + 'Totais': '2' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'Fila', + 'Dia': '06', + 'Intervalo 30min': '12:00:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'Rota externa', + 'Totais': '1' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'Fila', + 'Dia': '06', + 'Intervalo 30min': '12:30:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'Rota externa', + 'Totais': '2' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'Fila', + 'Dia': '27', + 'Intervalo 30min': '10:30:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'Rota externa', + 'Totais': '1' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'Fila', + 'Dia': '27', + 'Intervalo 30min': '11:00:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'Rota externa', + 'Totais': '2' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'Fila', + 'Dia': '27', + 'Intervalo 30min': '11:30:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'Rota externa', + 'Totais': '1' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'Fila', + 'Dia': '27', + 'Intervalo 30min': '12:00:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'Rota externa', + 'Totais': '2' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'Fila', + 'Dia': '27', + 'Intervalo 30min': '16:00:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'Rota externa', + 'Totais': '2' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'Fila', + 'Dia': '27', + 'Intervalo 30min': '18:30:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'Rota externa', + 'Totais': '1' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'Fila', + 'Dia': '27', + 'Intervalo 30min': '19:00:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'Rota externa', + 'Totais': '1' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'Inicio', + 'Dia': '06', + 'Intervalo 30min': '12:00:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'Rota externa', + 'Totais': '2' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'Inicio', + 'Dia': '06', + 'Intervalo 30min': '12:30:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'Rota externa', + 'Totais': '4' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'Inicio', + 'Dia': '27', + 'Intervalo 30min': '10:30:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'Rota externa', + 'Totais': '2' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'Inicio', + 'Dia': '27', + 'Intervalo 30min': '11:00:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'Rota externa', + 'Totais': '2' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'Inicio', + 'Dia': '27', + 'Intervalo 30min': '11:30:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'Rota externa', + 'Totais': '1' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'Inicio', + 'Dia': '27', + 'Intervalo 30min': '12:00:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'Rota externa', + 'Totais': '2' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'Inicio', + 'Dia': '27', + 'Intervalo 30min': '16:00:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'Rota externa', + 'Totais': '2' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'Inicio', + 'Dia': '27', + 'Intervalo 30min': '18:30:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'Rota externa', + 'Totais': '1' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'Inicio', + 'Dia': '27', + 'Intervalo 30min': '19:00:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'Rota externa', + 'Totais': '1' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'Inicio', + 'Dia': '30', + 'Intervalo 30min': '20:00:00', + 'Mês (completo)': '01-Jan', + 'Rota': 'Rota externa', + 'Totais': '1' + }, + { + 'Ano': '2015', + 'Descrição Descritor': 'Inicio', + 'Dia': '03', + 'Intervalo 30min': '14:30:00', + 'Mês (completo)': '02-Feb', + 'Rota': 'Rota externa', + 'Totais': '1' + }, + { + 'Ano': 'Totais', + 'Descrição Descritor': 'Totais', + 'Dia': 'Totais', + 'Intervalo 30min': 'Totais', + 'Mês (completo)': 'Totais', + 'Rota': 'Totais', + 'Totais': '34' + } + ]; + deepEqual(table, expected); +}); \ No newline at end of file diff --git a/assets/lightswitch/lightswitch/test/specs/core.test.js b/assets/lightswitch/lightswitch/test/specs/core.test.js new file mode 100644 index 00000000..efe85f44 --- /dev/null +++ b/assets/lightswitch/lightswitch/test/specs/core.test.js @@ -0,0 +1,817 @@ +/*global module, test, expect, deepEqual */ + +module('core'); + +/* Basic Usage */ +test('basic usage', function() { + $('#qunit-fixture').html( + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
    First NameLast NamePoints
    JillSmith50
    EveJackson94
    JohnDoe80
    ' + ); + + + expect(1); + var table = $('#test-table').tableToJSON(); + var expected = [{'First Name':'Jill', 'Last Name':'Smith', 'Points':'50'}, + {'First Name':'Eve', 'Last Name':'Jackson', 'Points':'94'}, + {'First Name':'John', 'Last Name':'Doe', 'Points':'80'}]; + deepEqual(table, expected); +}); + +/* Basic Usage with thead and tbody*/ +test('basic usage with thead and tbody', function() { + $('#qunit-fixture').html( + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
    First NameLast NamePoints
    JillSmith50
    EveJackson94
    JohnDoe80
    ' + ); + + + expect(1); + var table = $('#test-table').tableToJSON(); + var expected = [{'First Name':'Jill', 'Last Name':'Smith', 'Points':'50'}, + {'First Name':'Eve', 'Last Name':'Jackson', 'Points':'94'}, + {'First Name':'John', 'Last Name':'Doe', 'Points':'80'}]; + deepEqual(table, expected); +}); + +/* Override Column Names */ +test('override column names', function() { + $('#qunit-fixture').html( + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
    First NameLast NamePoints
    JillSmith50
    EveJackson94
    JohnDoe80
    ' + ); + + + expect(1); + var table = $('#test-table').tableToJSON(); + var expected = [{'Nickname':'Jill', 'Last Name':'Smith', 'Points':'50'}, + {'Nickname':'Eve', 'Last Name':'Jackson', 'Points':'94'}, + {'Nickname':'John', 'Last Name':'Doe', 'Points':'80'}]; + deepEqual(table, expected); +}); + +/* Override Cell Values */ +test('override column names', function() { + $('#qunit-fixture').html( + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
    First NameLast NamePoints
    JillSmith50
    EveJackson94
    JohnDoe80
    ' + ); + + + expect(1); + var table = $('#test-table').tableToJSON(); + var expected = [{'Nickname':'Jill', 'Last Name':'Smith', 'Points':'disqualified'}, + {'Nickname':'Eve', 'Last Name':'Jackson', 'Points':'94'}, + {'Nickname':'John', 'Last Name':'Doe', 'Points':'80'}]; + deepEqual(table, expected); +}); + +/* Ignore Column */ +test('ignore columns', function() { + $('#qunit-fixture').html( + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
    First NameLast NamePoints
    JillSmith50
    EveJackson94
    JohnDoe80
    ' + ); + + + expect(1); + var table = $('#test-table').tableToJSON({ + ignoreColumns: [0] + }); + var expected = [ + {'Last Name':'Smith', 'Points':'50'}, + {'Last Name':'Jackson', 'Points':'94'}, + {'Last Name':'Doe', 'Points':'80'} + ]; + deepEqual(table, expected); +}); + +/* Ignore Hidden Row */ +test('ignore hidden rows', function() { + $('#qunit-fixture').html( + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
    First NameLast NamePoints
    JillSmith50
    EveJackson94
    JohnDoe80
    ' + ); + + + expect(1); + var table = $('#test-table').tableToJSON(); + var expected = [{'First Name':'Jill', 'Last Name':'Smith', 'Points':'50'}, + {'First Name':'Eve', 'Last Name':'Jackson', 'Points':'94'}]; + deepEqual(table, expected); +}); + +/* Include Hidden Rows */ +test('Include Hidden Rows', function() { + $('#qunit-fixture').html( + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
    First NameLast NamePoints
    JillSmith50
    EveJackson94
    JohnDoe80
    ' + ); + + + expect(1); + var table = $('#test-table').tableToJSON({ + ignoreHiddenRows: false + }); + var expected = [{'First Name':'Jill', 'Last Name':'Smith', 'Points':'50'}, + {'First Name':'Eve', 'Last Name':'Jackson', 'Points':'94'}, + {'First Name':'John', 'Last Name':'Doe', 'Points':'80'}]; + deepEqual(table, expected); +}); + +/* Ignore Empty Row */ +test('ignore empty rows', function() { + $('#qunit-fixture').html( + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
    First NameLast NamePoints
    JillSmith50
    EveJackson94
    ' + ); + + + expect(1); + var table = $('#test-table').tableToJSON({ignoreEmptyRows:true}); + var expected = [{'First Name':'Jill', 'Last Name':'Smith', 'Points':'50'}, + {'First Name':'Eve', 'Last Name':'Jackson', 'Points':'94'}]; + deepEqual(table, expected); +}); + +/* Include Empty Row */ +test('ignore empty rows', function() { + $('#qunit-fixture').html( + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
    First NameLast NamePoints
    JillSmith50
    EveJackson94
    ' + ); + + + expect(1); + var table = $('#test-table').tableToJSON(); + var expected = [{'First Name':'Jill', 'Last Name':'Smith', 'Points':'50'}, + {'First Name':'Eve', 'Last Name':'Jackson', 'Points':'94'}, + {'First Name':'', 'Last Name':'', 'Points':''}]; + deepEqual(table, expected); +}); + +/* Ignore Row Option */ +test('ignore empty rows', function() { + $('#qunit-fixture').html( + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
    First NameLast NamePoints
    JillSmith50
    EveJackson94
    JohnDoe80
    ' + ); + + + expect(1); + var table = $('#test-table').tableToJSON({ignoreEmptyRows:true}); + var expected = [{'First Name':'Jill', 'Last Name':'Smith', 'Points':'50'}, + {'First Name':'John', 'Last Name':'Doe', 'Points':'80'}]; + deepEqual(table, expected); +}); + +/* Read first row of td's as column when there are no th's*/ +test('without any ', function() { + $('#qunit-fixture').html( + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
    First NameLast NamePoints
    JillSmith50
    EveJackson94
    JohnDoe80
    ' + ); + + + expect(1); + var table = $('#test-table').tableToJSON(); + var expected = [{'First Name':'Jill', 'Last Name':'Smith', 'Points':'50'}, + {'First Name':'Eve', 'Last Name':'Jackson', 'Points':'94'}, + {'First Name':'John', 'Last Name':'Doe', 'Points':'80'}]; + deepEqual(table, expected); +}); + +/* Uses the onlyColumns option to only include the first column*/ +test('Ony include 1 column', function() { + $('#qunit-fixture').html( + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
    First NameLast NamePoints
    JillSmith50
    EveJackson94
    JohnDoe80
    ' + ); + + + expect(1); + var table = $('#test-table').tableToJSON({ + onlyColumns: [0] + }); + var expected = [ + {'First Name':'Jill'}, + {'First Name':'Eve'}, + {'First Name':'John'} + ]; + deepEqual(table, expected); +}); + +/* onlyColumns option overrides ignoreColumns option */ +test('onlyColumns option overrides ignoreColumns option', function() { + $('#qunit-fixture').html( + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
    First NameLast NamePoints
    JillSmith50
    EveJackson94
    JohnDoe80
    ' + ); + + + expect(1); + var table = $('#test-table').tableToJSON({ + onlyColumns: [0, 1], + ignoreColumns: [0, 1] + }); + var expected = [ + {'First Name':'Jill', 'Last Name':'Smith'}, + {'First Name':'Eve', 'Last Name':'Jackson'}, + {'First Name':'John', 'Last Name':'Doe'} + ]; + deepEqual(table, expected); +}); + +/* headings option uses all rows as data */ +test('headings option uses all rows as data', function() { + $('#qunit-fixture').html( + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
    JillSmith50
    EveJackson94
    JohnDoe80
    ' + ); + + + expect(1); + var table = $('#test-table').tableToJSON({ + headings: ['First Name', 'Last Name', 'Points'] + }); + var expected = [ + {'First Name':'Jill', 'Last Name':'Smith', 'Points':'50'}, + {'First Name':'Eve', 'Last Name':'Jackson', 'Points':'94'}, + {'First Name':'John', 'Last Name':'Doe', 'Points':'80'} + ]; + deepEqual(table, expected); +}); + +/* headings option works with ignoreColumns option */ +test('headings option works with ignoreColumns option', function() { + $('#qunit-fixture').html( + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
    JillSmith50
    EveJackson94
    JohnDoe80
    ' + ); + + + expect(1); + var table = $('#test-table').tableToJSON({ + ignoreColumns: [0], + headings: ['Last Name', 'Points'] + }); + var expected = [ + {'Last Name':'Smith', 'Points':'50'}, + {'Last Name':'Jackson', 'Points':'94'}, + {'Last Name':'Doe', 'Points':'80'} + ]; + deepEqual(table, expected); +}); + +/* headings option works with onlyColumns option */ +test('headings option works with onlyColumns option', function() { + $('#qunit-fixture').html( + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
    JillSmith50
    EveJackson94
    JohnDoe80
    ' + ); + + + expect(1); + var table = $('#test-table').tableToJSON({ + onlyColumns: [1, 2], + headings: ['Last Name', 'Points'] + }); + var expected = [ + {'Last Name':'Smith', 'Points':'50'}, + {'Last Name':'Jackson', 'Points':'94'}, + {'Last Name':'Doe', 'Points':'80'} + ]; + deepEqual(table, expected); +}); + +/* allowHTML option allows HTML tags within a table to remain in the object */ +test('allowHTML option allows HTML tags within a table to remain in the object', function () { + $('#qunit-fixture').html( + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
    First NameLast NamePoints
    JillSmith50
    EveJackson94
    JohnDoe80
    ' + ); + + expect(1); + var table = $('#test-table').tableToJSON({ + allowHTML: true + }); + var expected = [ + {'First Name':'Jill', 'Last Name':'Smith', 'Points':'50'}, + {'First Name':'Eve', 'Last Name':'Jackson', 'Points':'94'}, + {'First Name':'John', 'Last Name':'Doe', 'Points':'80'} + ]; + deepEqual(table, expected); +}); + +/* includeRowId option boolean type places the attribute ID from the row as a property of the row */ +test('includeRowId option boolean type places the attribute ID from the row as a property of the row', function () { + $('#qunit-fixture').html( + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
    First NameLast NamePoints
    JillSmith50
    EveJackson94
    JohnDoe80
    NoRowID
    ' + ); + + expect(1); + var table = $('#test-table').tableToJSON({ + includeRowId: true + }); + var expected = [ + {'rowId':'1', 'First Name':'Jill', 'Last Name':'Smith', 'Points':'50'}, + {'rowId':'2', 'First Name':'Eve', 'Last Name':'Jackson', 'Points':'94'}, + {'rowId':'3', 'First Name':'John', 'Last Name':'Doe', 'Points':'80'}, + {'rowId':'', 'First Name':'No', 'Last Name':'Row', 'Points':'ID'} + ]; + deepEqual(table, expected); +}); + +/* includeRowId option custom, instead of a boolean use a string, and string value will be the property name. */ +test('includeRowId option string type, instead of a boolean use a string, and string value will be the property name', function () { + $('#qunit-fixture').html( + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
    First NameLast NamePoints
    JillSmith50
    EveJackson94
    JohnDoe80
    NoRowID
    ' + ); + + expect(1); + var table = $('#test-table').tableToJSON({ + includeRowId: 'customIDname' + }); + var expected = [ + {'customIDname':'1', 'First Name':'Jill', 'Last Name':'Smith', 'Points':'50'}, + {'customIDname':'2', 'First Name':'Eve', 'Last Name':'Jackson', 'Points':'94'}, + {'customIDname':'3', 'First Name':'John', 'Last Name':'Doe', 'Points':'80'}, + {'customIDname':'', 'First Name':'No', 'Last Name':'Row', 'Points':'ID'} + ]; + deepEqual(table, expected); +}); + +test('Basic Usage extractor option', function() { + $('#qunit-fixture').html( + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
    TitleStreet
    Doctor Jill Smith123 Main Street
    President Eve Jackson999 National Blvd.
    Mr. John Doe555 Letter Ave.
    ' + ); + + + expect(1); + var table = $('#test-table').tableToJSON({ + extractor : function(cellIndex, $cell) { + return $cell.find('span').text(); + } + }); + var expected = [{'Title':'Doctor', 'Street':'Main'}, + {'Title':'President', 'Street':'National'}, + {'Title':'Mr.', 'Street':'Letter'}]; + deepEqual(table, expected); +}); + +test('extractor option per column', function() { + $('#qunit-fixture').html( + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '
    TitleNumberDate
    Doctor Jill Smith123 Main Street1/31/2015
    President Eve Jackson999 National Blvd.2/1/2014
    Mr. John Doe555 Letter Ave.12/2/2014
    ' + ); + + + expect(1); + var table = $('#test-table').tableToJSON({ + extractor : { + 0 : function(cellIndex, $cell) { + return $cell.find('span').text(); + }, + 1 : function(cellIndex, $cell) { + return $cell.find('em').text(); + }, + 2 : function(cellIndex, $cell) { + return new Date( $cell.text() ).toString(); + } + } + }); + var dates = [ '1/31/2015', '2/1/2014', '12/2/2014' ]; + $.each(dates, function(i,v){ + dates[i] = new Date(v).toString(); + }); + var expected = [{'Title':'Doctor', 'Number':'345', 'Date': dates[0]}, + {'Title':'President', 'Number':'999', 'Date': dates[1]}, + {'Title':'Mr.', 'Number':'555', 'Date': dates[2] }]; + deepEqual(table, expected); +});