コード例 #1
0
function comparison_form_process()
{
    if (isset($_POST['btnComprison'])) {
        $test_comp = new comparisonClass();
        //        $test_comp->set_goConex_single_switch_price($_POST['goConexSnglPole']);
        //        $test_comp->set_goConex_three_switch_price($_POST['goConexDcro3Wy']);
        //        $test_comp->set_goConex_four_way_switch($_POST['goConexDcro4Wy']);
        //$test_comp->set_goConex_lbr_cst_pr_inst($_POST['goConexWireConStple']);
        $test_comp->set_work_days($_POST['txtAvailbleWrkDay']);
        $test_comp->set_avl_wrk_dy_pr_yr($_POST['txtGC_avlWrkD_prYr']);
        $test_comp->set_lbr_rate_tr($_POST['txt_lbr_rate']);
        $test_comp->set_bldr_share($_POST['txtPrcnt_builderShare']);
        $test_comp->set_prft_dsire_gc($_POST['txtPrftDsireGC']);
        global $wpdb;
        $table_name = $wpdb->prefix . 'comparison_tbl';
        $wpdb->insert($table_name, array('user_id' => get_current_user_id(), 'gc_available_wrk_day_pr_yr' => $_POST['txtAvailbleWrkDay'], 'available_wrk_day_pr_yr' => $_POST['txtGC_avlWrkD_prYr'], 'tr_labor_rate' => $_POST['txt_lbr_rate'], 'builder_share' => $_POST['txtPrcnt_builderShare'], 'gc_profit_dsire' => $_POST['txtPrftDsireGC'], 'tr_wire2cond_total' => $test_comp->get_two_wire_total(), 'tr_wire3cond_total' => $test_comp->get_three_wire_total(), 'tr_pipe_conduit_total' => $test_comp->get_pip_conduit_total(), 'tr_one_gang_box_total' => $test_comp->get_one_gang_box_total(), 'tr_two_gang_box_total' => $test_comp->get_two_gang_box_total(), 'tr_three_gang_box_total' => $test_comp->get_three_gang_box_total(), 'tr_four_gang_box_total' => $test_comp->get_four_gang_box_total(), 'tr_one_gang_vpr_bt_total' => $test_comp->get_one_gang_vapour_total(), 'tr_two_gang_vpr_bt_total' => $test_comp->get_secon_gang_vapour_total(), 'tr_three_gang_vpr_bt_total' => $test_comp->get_third_gang_vapour_total(), 'tr_four_gang_vpr_bt_total' => $test_comp->get_fourth_gang_vapour_total(), 'dec_snglepol_sw_total' => $test_comp->get_dec_single_switch_total(), 'dec_three_wy_sw_total' => $test_comp->get_three_way_switch_total(), 'dec_four_wy_sw_total' => $test_comp->get_four_way_switch_total(), 'wire_connctr_stple_total' => $test_comp->get_wire_conduct_total(), 'tr_mtrial_cst_pr_instltion' => $test_comp->get_material_cost_pr_inst(), 'tr_mtrial_cst_pr_switch' => $test_comp->get_material_cost_pr_switch(), 'tr_nm_sw_pr_home' => $test_comp->get_switces_per_home(), 'tr_roughin_hr_svd_pr_home_no_leg' => $test_comp->get_total_combined_hrly_rate_per_home(), 'tr_mnt_instl_vpr_barriar' => $test_comp->get_total_combined_hrly_rate_install_switch_vpr(), 'tr_mnt_dmge_sw_loc' => $test_comp->get_total_combined_hrly_rate_dmge_switch_loc(), 'tr_fnl_hr_svd_eliminating_sw_legs' => $test_comp->get_total_combined_hrly_rate_eliminatingSwLeg(), 'tr_lbr_cst_pr_installtion' => $test_comp->get_labour_cost_pr_inst(), 'tr_lbr_cst_pr_sw' => $test_comp->get_labour_cost_pr_switch(), 'tr_matrial_and_lbr_cst' => $test_comp->get_material_and_labour_cost(), 'tr_installed_sw_cst' => $test_comp->get_installed_switch_cost(), 'avl_vlue_option_exsting_bsns' => $test_comp->get_new_AvlvalueOptionExistingBsns(), 'total_option_profit_exsting_bsns' => $test_comp->get_totalOptionProfitExistingBsns(), 'tr_annual_man_hrs' => $test_comp->get_annualManHrsTR(), 'gc_annual_man_hrs' => $test_comp->get_annualManHrsGC(), 'tr_avg_hrs_roughin_pr_home' => $test_comp->get_avg_hrs_roughInPrHomeTR(), 'gc_avg_hrs_roughin_pr_home' => $test_comp->get_avg_hrs_roughInPrHomeGC(), 'tr_days_pr_roughin' => $test_comp->get_daysPrRoughInTR(), 'gc_days_pr_roughin' => $test_comp->get_daysPrRoughInGC(), 'annual_hrs_svd_exsting_roughin' => $test_comp->get_AnnualHrsSvdExistingRoughIn(), 'total_pssble_added_roughin_pr_anm' => $test_comp->get_TotalPossibleAddRoughInPrAnm(), 'avg_gross_prft_pr_home' => $test_comp->get_avg_grossProfitPrHome(), 'gc_avg_option_prft_increase_instl' => $test_comp->get_gc_OptionProfitIncrease_Instl(), 'annual_grs_prft_potential' => $test_comp->get_annual_grsPrftPotential(), 'staff_svng_hr_svd_mn_avl_pr_hr' => $test_comp->get_staff_svngHrSvdMnHrAvlPrYr(), 'annual_saving' => $test_comp->get_Annual_Savings(), 'gc_pwr_cntrl_total' => $test_comp->get_totalOptionProfitExistingBsns(), 'gc_pwr_cntrl_value_pr_home' => $test_comp->get_GC_pwr_Conrol_needs(), 'gc_pwr_cntrl_bldr_option_prce_pr_hme' => $test_comp->get_bldr_option_prce_pr_home(), 'gc_pwr_cntrl_total_vlu_dlr_pr_hme' => $test_comp->get_GC_total_value_dlr_pr_home(), 'gc_pwr_cntrl_total_adjust_staff' => $test_comp->get_GC_total_PwrCntrl_adjust_staff(), 'gc_pwr_cntrl_adjust_staff_vlue_pr_hme' => $test_comp->get_GC_PwrCntrl_adjust_staff_VluPrHome(), 'gc_pwr_cntrl_adjust_staff_dlr_vlue_pr_hme' => $test_comp->get_GC_PwrCntrl_value_dlr_pr_home(), 'gc_pwr_cntrl_do_more_exstng_rsrces_total' => $test_comp->get_PwrCntrl_doMoreExistingRsrcs(), 'gc_pwr_cntrl_do_more_exstng_rsrces_vlue_pr_hme' => $test_comp->get_PwrCntrl_doMoreExistingRsrcs_VluePrHome(), 'gc_pwr_cntrl_do_more_exstng_rsrces_dlr_vlue_pr_hme' => $test_comp->get_PwrCntrl_doMoreExistingRsrcs_TotalVluDlrPrHome()));
        echo '<br/>';
        echo '<hr/>';
        echo '<h2>Results:</h2>';
        echo '<br/>';
        echo '<table width="60%">';
        echo '<tbody>';
        echo '<tr style="padding-bottom:30px;">';
        echo '<th colspan="2" style="text-align:right"><strong>Traditional Wiring</strong></th>';
        echo '<th colspan="3" style="text-align:right"><strong>GoConex</strong></th>';
        echo '</tr>';
        echo '<tr>';
        echo '<td><strong>Switch Leg Materials</strong></td>';
        echo '<td><strong>No. Switches per home</strong></td>';
        echo '<td><strong>Total</strong></td>';
        echo '<td><strong>&nbsp;</strong></td>';
        echo '<td><strong>Price</strong></td>';
        echo '<td><strong>Total</strong></td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>Wire - 2 conductor (price per foot or meter)</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>$' . $test_comp->get_two_wire_total() . '</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>Wire - 3 conductor (price per foot or meter)</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>$' . $test_comp->get_three_wire_total() . '</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>Pipe / Conduit (price per unit of length)</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>$' . $test_comp->get_pip_conduit_total() . '</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>&nbsp;</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>&nbsp;</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>1 gang boxes</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>$' . $test_comp->get_one_gang_box_total() . '</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>2 gang boxes</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>$' . $test_comp->get_two_gang_box_total() . '</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>3 gang boxes</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>$' . $test_comp->get_three_gang_box_total() . '</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>3 gang boxes</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>$' . $test_comp->get_four_gang_box_total() . '</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>&nbsp;</td>';
        echo '<td>$' . $test_comp->get_switces_per_home() . '</td>';
        echo '<td>&nbsp;</td>';
        echo '</tr>';
        echo '<tr>';
        echo ' <td>1 gang vapour boot</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>$' . $test_comp->get_one_gang_vapour_total() . '</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>2 gang vapour boot</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>$' . $test_comp->get_secon_gang_vapour_total() . '</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>3 gang vapour boot</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>$' . $test_comp->get_third_gang_vapour_total() . '</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>4 gang vapour boot</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>$' . $test_comp->get_fourth_gang_vapour_total() . '</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>&nbsp;</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>&nbsp;</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>Decora single pole switches</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>$' . $test_comp->get_dec_single_switch_total() . '</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>Decora 3 way switch</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>$' . $test_comp->get_three_way_switch_total() . '</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>Decora 4 way switch</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>$' . $test_comp->get_four_way_switch_total() . '</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>Wire conectors & staples</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>$' . $test_comp->get_wire_conduct_total() . '</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>Material cost per installation</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>$' . $test_comp->get_material_cost_pr_inst() . '</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>&nbsp;</td>';
        // . $test_comp->get_goConex_material_cost_pr_inst() .
        echo '</tr>';
        echo '<tr>';
        echo '<td>Material cost per switch</td>';
        echo '<td>&nbsp;</td>';
        // echo '<td>$' . $test_comp->get_material_cost_pr_switch() . '</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>&nbsp;</td>';
        // echo '<td>$' . $test_comp->get_goConex_material_cost_pr_switch() . '</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td colspan="5"><br/><hr/><h2>Labour</h2></td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>&nbsp;</td>';
        echo '<td>&nbsp;</td>';
        echo '<td><strong>Total</strong></td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>Rough in hours saved per home/unit no switch legs</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>$' . $test_comp->get_total_combined_hrly_rate_per_home() . '</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>Minutes per unit to install switch vapour barrier</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>$' . $test_comp->get_total_combined_hrly_rate_install_switch_vpr() . '</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>Minutes per unit to manage damage to switch locations</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>$' . $test_comp->get_total_combined_hrly_rate_dmge_switch_loc() . '</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>Final hours saved per home/unit eliminating switch legs</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>$' . $test_comp->get_total_combined_hrly_rate_eliminatingSwLeg() . '</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>&nbsp;</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>&nbsp;</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>Labour cost per installation</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>$' . $test_comp->get_labour_cost_pr_inst() . '</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>Labour cost per switch</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>$' . $test_comp->get_labour_cost_pr_switch() . '</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>&nbsp;</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>&nbsp;</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>Materials & labour cost</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>$' . $test_comp->get_material_and_labour_cost() . '</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>&nbsp;</td>';
        //echo '<td>$' . $test_comp->get_goConex_material_cost_pr_inst() . '</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>Installed switch cost</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>$' . $test_comp->get_installed_switch_cost() . '</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>&nbsp;</td>';
        //echo '<td>$' . $test_comp->get_goConex_material_cost_pr_switch() . '</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>New Available Value Options per home/unit on existing business</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>$' . $test_comp->get_new_AvlvalueOptionExistingBsns() . '</td>';
        // echo '<td>$' . $test_comp->get_cost_diff_trad_goConex() . '</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>&nbsp;</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>Total Options Profits existing business</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>$' . $test_comp->get_totalOptionProfitExistingBsns() . '</td>';
        // echo '<td>$' . $test_comp->get_cost_diff_trad_goConex() . '</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>&nbsp;</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td colspan="5"><br/><hr/></td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>Do More With Your Existing People Resources</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>Traditional</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>GoConex</td>';
        echo '<td>&nbsp;</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>Annual Man Hours (8 Hour Day)</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>' . $test_comp->get_annualManHrsTR() . '</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>' . $test_comp->get_annualManHrsGC() . '</td>';
        echo '<td>&nbsp;</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>Average hours for rough-in per home</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>' . $test_comp->get_avg_hrs_roughInPrHomeTR() . '</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>' . $test_comp->get_avg_hrs_roughInPrHomeGC() . '</td>';
        echo '<td>&nbsp;</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>Days Per Rough-in</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>' . $test_comp->get_daysPrRoughInTR() . '</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>' . $test_comp->get_daysPrRoughInGC() . '</td>';
        echo '<td>&nbsp;</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>Annual Hours Saved Existing Rough-ins</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>' . $test_comp->get_AnnualHrsSvdExistingRoughIn() . '</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>&nbsp;</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>Total Possible Additional Rough-ins per Annum</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>' . $test_comp->get_TotalPossibleAddRoughInPrAnm() . '</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>&nbsp;</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>Average Gross Profit Per Home</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>' . $test_comp->get_avg_grossProfitPrHome() . '</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>&nbsp;</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>GoConex Options Profit Increase For Added Installations</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>' . $test_comp->get_gc_OptionProfitIncrease_Instl() . '</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>&nbsp;</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>Annual Gross Profit Increase Potential</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>' . $test_comp->get_annual_grsPrftPotential() . '</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>&nbsp;</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>&nbsp;</td>';
        echo '<td colspan="2"><strong>OR</strong></td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>Staff Savings, Hours Saved vs Man Hours Available Per Year</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>' . $test_comp->get_staff_svngHrSvdMnHrAvlPrYr() . '</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>&nbsp;</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>Annual Savings</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>' . $test_comp->get_Annual_Savings() . '</td>';
        echo '<td>&nbsp;</td>';
        echo '<td>&nbsp;</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td><strong>Available Value Dollars</strong></td>';
        echo '<td colspan="2"> GOOD, BETTER, BEST </td>';
        echo '<td rowspan="2">BUILDER OPTION PRICING PER HOME</td>';
        echo '<td rowspan="2">What % Would The Builder Share?</td>';
        echo '<td rowspan="2">Total Value Dollars Per Home</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>&nbsp;</td>';
        echo '<td>Total</td>';
        echo '<td>Value Per Home</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>Using GoConex For All Your Power Control Needs</td>';
        echo '<td>' . $test_comp->get_totalOptionProfitExistingBsns() . ' </td>';
        echo '<td>' . $test_comp->get_GC_pwr_Conrol_needs() . '</td>';
        echo '<td rowspan="3">' . $test_comp->get_bldr_option_prce_pr_home() . '</td>';
        echo '<td rowspan="3">' . $test_comp->get_bldr_share() * 100 . '</td>';
        echo '<td>' . $test_comp->get_GC_total_value_dlr_pr_home() . '</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>Using GoConex For All Your Power Control Needs AND Adjust Staff Resources For Efficiency</td>';
        echo '<td>' . $test_comp->get_GC_total_PwrCntrl_adjust_staff() . ' </td>';
        echo '<td>' . $test_comp->get_GC_PwrCntrl_adjust_staff_VluPrHome() . ' </td>';
        echo '<td>' . $test_comp->get_GC_PwrCntrl_value_dlr_pr_home() . '</td>';
        echo '</tr>';
        echo '<tr>';
        echo '<td>Using GoConex For All Your Power Control Needs AND Do More With Your Existing People Resources</td>';
        echo '<td>' . $test_comp->get_PwrCntrl_doMoreExistingRsrcs() . ' </td>';
        echo '<td>' . $test_comp->get_PwrCntrl_doMoreExistingRsrcs_VluePrHome() . ' </td>';
        echo '<td>' . $test_comp->get_PwrCntrl_doMoreExistingRsrcs_TotalVluDlrPrHome() . '</td>';
        echo '</tr>';
        echo '</tbody>';
        echo '</table>';
    }
}
コード例 #2
0
ファイル: processOption.php プロジェクト: Junaid-Farid/gocnex
function option_form_process()
{
    global $wpdb;
    $table_name = $wpdb->prefix . 'estimate';
    if (isset($_POST['operation']) && $_POST['operation'] == 'firstoptionform') {
        $userArr = array('user_id' => get_current_user_id());
        //remove from here
        foreach ($_POST['importData'] as $data) {
            $posteddata[$data['name']] = $data['value'];
        }
        $lastid = $posteddata['lastid'];
        array_pop($posteddata);
        $wpdb->update($table_name, $posteddata, array('ID' => $lastid));
        header('Content-Type: application/json');
        wp_die(json_encode(array('lastid' => $lastid, 'posteddata' => $posteddata)));
    }
    if (isset($_POST['operation']) && $_POST['operation'] == 'updatefirstoptionform') {
        $userArr = array('user_id' => get_current_user_id());
        foreach ($_POST['importData'] as $data) {
            $posteddata[$data['name']] = $data['value'];
        }
        $lastid = $posteddata['lastid'];
        array_pop($posteddata);
        $wpdb->update($table_name, $posteddata, array('ID' => $lastid));
        wp_die($lastid);
    }
    if (isset($_POST['operation']) && $_POST['operation'] == '2ndOptionform') {
        $userArr = array('user_id' => get_current_user_id());
        foreach ($_POST['importData'] as $data) {
            $posteddata[$data['name']] = $data['value'];
        }
        $lastid = $posteddata['lastid'];
        array_pop($posteddata);
        /*
         * Results Process statrs
         */
        $table_name = $wpdb->prefix . 'estimate';
        $results = $wpdb->get_results('SELECT * FROM ' . $table_name . ' WHERE id =' . $lastid, OBJECT);
        $goconex = new goconex();
        //estimate excel sheet
        //two wire conductor form one
        $goconex->set_two_wire_conductor($results[0]->wire_two_cond_qnty, $results[0]->wire_two_cond_price);
        $goconex->set_three_wire_conductor($results[0]->wire_three_cond_qnty, $results[0]->wire_three_cond_price);
        $goconex->set_pipe_or_conduit($results[0]->pip_cond_qnty, $results[0]->pip_cond_price);
        //gang box quantity setter form two
        $goconex->set_gang_box($results[0]->one_gang_box_qnty, $results[0]->one_gang_box_price);
        $goconex->set_two_gang_box($results[0]->two_gang_box_qnty, $results[0]->two_gang_box_price);
        $goconex->set_three_gang_box($results[0]->three_gang_box_qnty, $results[0]->three_gang_box_price);
        $goconex->set_four_gang_box($results[0]->four_gang_box_qnty, $results[0]->four_gang_box_price);
        //gang vapour boot form three
        $goconex->set_first_gang_vapour_boot($results[0]->one_gang_vpr_boot_qnty, $results[0]->one_gang_vpr_boot_price);
        $goconex->set_second_gang_vapour_boot($results[0]->twp_gang_vpr_boot_qnty, $results[0]->two_gang_vpr_boot_price);
        $goconex->set_third_gang_vapour_boot($results[0]->three_gang_vpr_boot_qnty, $results[0]->three_gang_vpr_boot_price);
        $goconex->set_four_gang_vapour_boot($results[0]->four_gang_vpr_boot_qnty, $results[0]->four_gang_vpr_boot_price);
        // decora form four
        $goconex->set_decora_single_pole_switches($results[0]->decra_single_pool_qnty, $results[0]->decra_single_pool_price);
        $goconex->set_decora_three_switch_way($results[0]->decra_three_wy_switch_qnty, $results[0]->decra_three_wy_switch_price);
        $goconex->set_decora_four_switch_way($results[0]->decra_four_wy_switch_qnty, $results[0]->decra_four_wy_switch_price);
        $goconex->set_wire_connector($results[0]->wire_conductor_qnty, $results[0]->wire_conductor_price);
        //Time form fifth
        $goconex->set_eight_hr_days_rough_in($results[0]->nm_eight_hr_for_roughin);
        //        $goconex->set_percnt_rough_not_switch_legs($results[0]->prcntge_without_switch);
        $goconex->set_seal_switch_vapour(0);
        $goconex->set_repair_demage_switches(0);
        $goconex->set_eight_hr_days_final_rough($results[0]->nm_eight_days_roughin);
        $goconex->set_eliminating_switch_con_final($results[0]->prcntg_eliminating_sw_con_final);
        // Labor form sixth
        $goconex->set_no_crews_rough_in($results[0]->nm_crews_roughin_qnty);
        $goconex->set_men_per_rough_crew($results[0]->nm_men_rough_in);
        $goconex->set_hourly_labour_rate_rough($results[0]->cmbnd_hrly_lbr_rate_crews_roughin);
        $goconex->set_crew_doing_final($results[0]->nm_crews_doing_final);
        $goconex->set_men_per_final_crew($results[0]->nm_men_pr_final);
        $goconex->set_hourly_final_crews($results[0]->cmbnd_hrly_rate_final_crews);
        //business
        $goconex->set_completed_per_year($results[0]->nm_home_cmpltd_pr_yr);
        $goconex->set_target_gross_profit(1100);
        //$results[0]->trgt_gross_prft_dlr
        //Material and labor cost
        $comparison = new comparisonClass();
        $comparison->estimateObject = $goconex;
        $comparison->sum_ms_zn_ps = $results[0]->sum_ms_zn_ps;
        //Option excel sheet
        //option form one
        //setter
        $comparison->set_avl_wrk_dy_pr_yr(244);
        $comparison->set_work_days(244);
        $comparison->set_lbr_rate_tr(36);
        $labour_rate = $comparison->get_lbr_rate_tr();
        $hrs_fstr_gc = $comparison->get_avg_hrs_roughInPrHomeGC();
        $total_switches_in_home = $goconex->get_total_switches_in_home();
        $roughin_labor_hr = $goconex->get_rough_in_labor_hr();
        $mint_per_switch = $results[0]->mnt_pr_home_seal_switch_vpr_brr;
        $hour_pr_house_rough_in = $total_switches_in_home * $mint_per_switch / 60;
        $hrs_saved_pr_home_installation = number_format((double) ($total_switches_in_home * ($mint_per_switch / 60)), 2, '.', '');
        $prcnt_faster = round(number_format((double) ($roughin_labor_hr - $hrs_saved_pr_home_installation), 2, '.', ''), 2);
        $completed_yr = $results[0]->nm_home_cmpltd_pr_yr;
        //efficiency gain
        $prnct_roughin_sw_no_lg = $hour_pr_house_rough_in / $roughin_labor_hr * 100;
        $goconex->set_percnt_rough_not_switch_legs($prnct_roughin_sw_no_lg);
        $efficiency_gain_prcnt = round(number_format((double) ($hrs_saved_pr_home_installation / $roughin_labor_hr * 100), 2, '.', ''), 2);
        $hour_saved_annually = $hrs_saved_pr_home_installation * $completed_yr;
        $possible_additional_roughin_pr_yr = round($hour_saved_annually / $prcnt_faster);
        $addition_houses = round($possible_additional_roughin_pr_yr);
        $target_gross_proft = 1100;
        //$results[0]->trgt_gross_prft_dlr;
        // first he said use contractor option sum $contractor_prift_options =  $posteddata['sum_ms_zn_ps_builder_proft'];
        // then he said use first form option sum
        $sum_ms_zn_ps = $results[0]->sum_ms_zn_ps;
        $contractor_prift_options = $sum_ms_zn_ps;
        $annual_gross_profit = round(number_format((double) ($contractor_prift_options / $completed_yr * $possible_additional_roughin_pr_yr), 2, '.', ''), 2);
        $profit_increase_additional_unit = $target_gross_proft * $addition_houses;
        // first was that $target_gross_proft * $possible_additional_roughin_pr_yr;
        $annual_gross_proft_increase_add_home = $profit_increase_additional_unit + $annual_gross_profit;
        $annual_man_hr = $comparison->get_annualManHrsGC();
        //possible staff saving
        $staff_hrs_saving = round(number_format((double) ($hour_saved_annually / $annual_man_hr), '3', '.', ''), 3);
        $annual_wages = $annual_man_hr * $labour_rate;
        $last_annual_saving = $comparison->get_Annual_Savings();
        $labour_cost_pr_inst = $goconex->get_labour_cost_pr_inst();
        $material_cost_pr_inst = $goconex->get_material_cost_pr_inst();
        $material_cost_pr_switch = $goconex->get_material_cost_pr_switch();
        $labour_cost_pr_switch = $goconex->get_labour_cost_pr_switch();
        $metrial_and_labour_cost = $goconex->get_material_and_labour_cost();
        $comparison->masterObject = $sum_ms_zn_ps;
        /// i replace $prcnt_faster with $prcnt_faster ;
        $formData = array('get_eight_hr_days_rough_in' => $goconex->get_eight_hr_days_rough_in()["quantity"], 'get_men_per_rough_crew' => $goconex->get_men_per_rough_crew()["quantity"], 'get_rough_in_labor_hr' => $goconex->get_rough_in_labor_hr(), 'total_switches_in_home' => $total_switches_in_home, 'mnt_pr_switch' => $mint_per_switch, 'get_hr_saved_no_switches_legs' => $goconex->get_hr_saved_no_switches_legs(), 'target_gross_profit' => $target_gross_proft, 'hour_saved_faster_gc' => $prcnt_faster, 'hrs_saved_pr_home_installation' => $hrs_saved_pr_home_installation, 'nm_completed_pr_yr' => $completed_yr, 'hrs_saved_annually' => $hour_saved_annually, 'possible_additional_rf_in_pr_yr' => $possible_additional_roughin_pr_yr, 'additional_houses' => $addition_houses, 'profit_increase_additional' => $profit_increase_additional_unit, 'annual_gross_proft' => $annual_gross_profit, 'annual_grs_pft_inr_add_home' => $annual_gross_proft_increase_add_home, 'annual_man_hrs' => $annual_man_hr, 'possible_staff_svng' => $staff_hrs_saving, 'labour_rate' => $labour_rate, 'prcnt_time_saved_no_leg' => $efficiency_gain_prcnt, 'annual_wages' => $annual_wages, 'annual_saving_last' => $last_annual_saving, 'mtrl_cst_pr_inst' => $material_cost_pr_inst, 'mtrl_cst_pr_sw' => $material_cost_pr_switch, 'lbr_cst_pr_inst' => $labour_cost_pr_inst, 'lbr_cst_pr_sw' => $labour_cost_pr_switch, 'metrial_and_lbr_cst' => $metrial_and_labour_cost);
        /*
         * Results Process end
         */
        $wpdb->update($table_name, $posteddata, array('ID' => $lastid));
        header('Content-Type: application/json');
        wp_die(json_encode(array('lastid' => $lastid, 'posteddata' => $posteddata, 'formData' => $formData)));
    }
    if (isset($_POST['operation']) && $_POST['operation'] == '3rdOptionform') {
        $userArr = array('user_id' => get_current_user_id());
        foreach ($_POST['importData'] as $data) {
            $posteddata[$data['name']] = $data['value'];
        }
        $lastid = $posteddata['lastid'];
        array_pop($posteddata);
        /*
         * Results Process statrs
         */
        $table_name = $wpdb->prefix . 'estimate';
        $results = $wpdb->get_results('SELECT * FROM ' . $table_name . ' WHERE id =' . $lastid, OBJECT);
        $goconex = new goconex();
        //estimate excel sheet
        //two wire conductor form one
        $goconex->set_two_wire_conductor($results[0]->wire_two_cond_qnty, $results[0]->wire_two_cond_price);
        $goconex->set_three_wire_conductor($results[0]->wire_three_cond_qnty, $results[0]->wire_three_cond_price);
        $goconex->set_pipe_or_conduit($results[0]->pip_cond_qnty, $results[0]->pip_cond_price);
        //gang box quantity setter form two
        $goconex->set_gang_box($results[0]->one_gang_box_qnty, $results[0]->one_gang_box_price);
        $goconex->set_two_gang_box($results[0]->two_gang_box_qnty, $results[0]->two_gang_box_price);
        $goconex->set_three_gang_box($results[0]->three_gang_box_qnty, $results[0]->three_gang_box_price);
        $goconex->set_four_gang_box($results[0]->four_gang_box_qnty, $results[0]->four_gang_box_price);
        //gang vapour boot form three
        $goconex->set_first_gang_vapour_boot($results[0]->one_gang_vpr_boot_qnty, $results[0]->one_gang_vpr_boot_price);
        $goconex->set_second_gang_vapour_boot($results[0]->twp_gang_vpr_boot_qnty, $results[0]->two_gang_vpr_boot_price);
        $goconex->set_third_gang_vapour_boot($results[0]->three_gang_vpr_boot_qnty, $results[0]->three_gang_vpr_boot_price);
        $goconex->set_four_gang_vapour_boot($results[0]->four_gang_vpr_boot_qnty, $results[0]->four_gang_vpr_boot_price);
        // decora form four
        $goconex->set_decora_single_pole_switches($results[0]->decra_single_pool_qnty, $results[0]->decra_single_pool_price);
        $goconex->set_decora_three_switch_way($results[0]->decra_three_wy_switch_qnty, $results[0]->decra_three_wy_switch_price);
        $goconex->set_decora_four_switch_way($results[0]->decra_four_wy_switch_qnty, $results[0]->decra_four_wy_switch_price);
        $goconex->set_wire_connector($results[0]->wire_conductor_qnty, $results[0]->wire_conductor_price);
        //Time form fifth
        $goconex->set_eight_hr_days_rough_in($results[0]->nm_eight_hr_for_roughin);
        $goconex->set_percnt_rough_not_switch_legs($results[0]->prcntge_without_switch);
        $goconex->set_seal_switch_vapour(0);
        //
        $goconex->set_repair_demage_switches(0);
        $goconex->set_eight_hr_days_final_rough($results[0]->nm_eight_days_roughin);
        $goconex->set_eliminating_switch_con_final(10);
        // Labor form sixth
        $goconex->set_no_crews_rough_in($results[0]->nm_crews_roughin_qnty);
        $goconex->set_men_per_rough_crew($results[0]->nm_men_rough_in);
        $goconex->set_hourly_labour_rate_rough($results[0]->cmbnd_hrly_lbr_rate_crews_roughin);
        $goconex->set_crew_doing_final($results[0]->nm_crews_doing_final);
        $goconex->set_men_per_final_crew($results[0]->nm_men_pr_final);
        $goconex->set_hourly_final_crews($results[0]->cmbnd_hrly_rate_final_crews);
        //business
        $goconex->set_completed_per_year($results[0]->nm_home_cmpltd_pr_yr);
        $goconex->set_target_gross_profit($results[0]->trgt_gross_prft_dlr);
        $comparison = new comparisonClass();
        $comparison->estimateObject = $goconex;
        $comparison->sum_ms_zn_ps = $results[0]->sum_ms_zn_ps;
        //Option excel sheet
        //option form one
        //setter
        $comparison->set_avl_wrk_dy_pr_yr(244);
        $comparison->set_work_days(244);
        $comparison->set_lbr_rate_tr(36);
        $labour_rate = $comparison->get_lbr_rate_tr();
        $hrs_fstr_gc = $comparison->get_avg_hrs_roughInPrHomeGC();
        $hrs_saved_pr_home_installation = $roughin_labor_hr - $hrs_fstr_gc;
        $completed_yr = $results[0]->nm_home_cmpltd_pr_yr;
        $hour_saved_annually = $hrs_saved_pr_home_installation * $completed_yr;
        $possible_additional_roughin_pr_yr = round(number_format((double) ($hour_saved_annually / $hrs_fstr_gc), 2, '.', ''));
        $target_gross_proft = $results[0]->trgt_gross_prft_dlr;
        $annual_gross_profit = $comparison->get_annual_grsPrftPotential();
        $profit_increase_additional_unit = $target_gross_proft * $possible_additional_roughin_pr_yr;
        $annual_gross_proft_increase_add_home = $profit_increase_additional_unit + $annual_gross_profit;
        $annual_man_hr = $comparison->get_annualManHrsGC();
        $staff_hrs_saving = $comparison->get_staff_svngHrSvdMnHrAvlPrYr();
        $annual_wages = $annual_man_hr * $labour_rate;
        $last_annual_saving = $comparison->get_Annual_Savings();
        $sum_ms_zn_ps = $results[0]->sum_ms_zn_ps;
        $comparison->masterObject = $sum_ms_zn_ps;
        $formData = array('get_eight_hr_days_rough_in' => $goconex->get_eight_hr_days_rough_in()["quantity"], 'get_men_per_rough_crew' => $goconex->get_men_per_rough_crew()["quantity"], 'get_rough_in_labor_hr' => $goconex->get_rough_in_labor_hr(), 'get_hr_saved_no_switches_legs' => $goconex->get_hr_saved_no_switches_legs(), 'target_gross_profit' => $results[0]->trgt_gross_prft_dlr, 'hour_saved_faster_gc' => $prcnt_faster, 'hrs_saved_pr_home_installation' => $hrs_saved_pr_home_installation, 'nm_completed_pr_yr' => $completed_yr, 'hrs_saved_annually' => $hour_saved_annually, 'possible_additional_rf_in_pr_yr' => $possible_additional_roughin_pr_yr, 'target_gross_profit' => $target_gross_proft, 'profit_increase_additional' => $profit_increase_additional_unit, 'annual_gross_profit' => $annual_gross_profit, 'annual_grs_pft_inr_add_home' => $annual_gross_proft_increase_add_home, 'annual_man_hrs' => $annual_man_hr, 'possible_staff_svng' => $staff_hrs_saving, 'labour_rate' => $labour_rate, 'annual_wages' => $annual_wages, 'annual_saving_last' => $last_annual_saving);
        /*
         * Results Process end
         */
        $wpdb->update($table_name, $posteddata, array('ID' => $lastid));
        header('Content-Type: application/json');
        wp_die(json_encode(array('lastid' => $lastid, 'posteddata' => $posteddata, 'formData' => $formData)));
    }
    if (isset($_POST['operation']) && $_POST['operation'] == 'getDataestimateform') {
        $table_name = $wpdb->prefix . 'estimate';
        $results = $wpdb->get_results('SELECT * FROM ' . $table_name . ' WHERE id =' . $_POST['importData'], OBJECT);
        header('Content-Type: application/json');
        wp_die(json_encode($results[0]));
    }
    if (isset($_POST['operation']) && $_POST['operation'] == 'getData') {
        $table_name = $wpdb->prefix . 'option_tbl';
        $results = $wpdb->get_results('SELECT * FROM ' . $table_name . ' WHERE id =' . $_POST['importData'], OBJECT);
        header('Content-Type: application/json');
        wp_die(json_encode($results[0]));
    }
}