alert(\"$msg\"); location.href=\"$original_list_page\";"; html_footer(); exit; } ///////////BODY////////////////////////////////////////////////////////////////////////////// session_start(); $count_end=$_POST['count_edit']; $gst_exempt=$_POST['gst_exempt_edited']; $third_co=$_POST['third_co_edited']; if(empty($third_co)) $third_co='SELF'; $vendor_no=$_POST['vendor_no_edited']; $due_date=$_POST['date_due_edited']; $invoice_date=$_POST['invoice_date_edited']; $payable_to=$_POST['payable_to_edited']; ///could be same $vendor_in_db=$_POST['vendor_in_db']; $invoice_id=$_POST['invoice_id_edited']; $office=$_POST['office_edited']; $appt_id_array=$_POST['appt_id_edited']; $appt_type_array=$_POST['appt_type_edited']; //[count] could be 99 $appt_price_array=$_POST['appt_price_edited']; if(!empty($_POST['CL_selected'])){$CL_selected=$_POST['CL_selected'];} else {$CL_selected=0;} $Pro_id=$_SESSION['userProid']; ////[$count] if(empty($_SESSION['userProprov'])){error_message("Enter your province");} else if($_SESSION['userProprov']=="BC"){$servProdb="service_providers"; $apptdb="appointments";$invdb="invoices";$invapptdb="invoice_appt";$vendornodb="vendor_nos";} else if($_SESSION['userProprov']=="AB"){$servProdb="service_providers_ab"; $apptdb="appointments_ab";$invdb="invoices_ab";$invapptdb="invoice_appt_ab";$vendornodb="vendor_nos_ab";} else if($_SESSION['userProprov']=="SK"){$servProdb="service_providers_sk"; $apptdb="appointments_sk";$invdb="invoices_sk";$invapptdb="invoice_appt_sk";$vendornodb="vendor_nos_sk";} else if($_SESSION['userProprov']=="MB"){$servProdb="service_providers_mb"; $apptdb="appointments_mb";$invdb="invoices_mb";$invapptdb="invoice_appt_mb";$vendornodb="vendor_nos_mb";} else if($_SESSION['userProprov']=="ON"){$servProdb="service_providers_on"; $apptdb="appointments_on";$invdb="invoices_on";$invapptdb="invoice_appt_on";$vendornodb="vendor_nos_on";} else if($_SESSION['userProprov']=="QC"){$servProdb="service_providers_qc"; $apptdb="appointments_qc";$invdb="invoices_qc";$invapptdb="invoice_appt_qc";$vendornodb="vendor_nos_qc";} else if($_SESSION['userProprov']=="NS"){$servProdb="service_providers_ns"; $apptdb="appointments_ns";$invdb="invoices_ns";$invapptdb="invoice_appt_ns";$vendornodb="vendor_nos_ns";} else if($_SESSION['userProprov']=="NB"){$servProdb="service_providers_nb"; $apptdb="appointments_nb";$invdb="invoices_nb";$invapptdb="invoice_appt_nb";$vendornodb="vendor_nos_nb";} else if($_SESSION['userProprov']=="PE"){$servProdb="service_providers_pe"; $apptdb="appointments_pe";$invdb="invoices_pe";$invapptdb="invoice_appt_pe";$vendornodb="vendor_nos_pe";} else if($_SESSION['userProprov']=="NL"){$servProdb="service_providers_nl"; $apptdb="appointments_nl";$invdb="invoices_nl";$invapptdb="invoice_appt_nl";$vendornodb="vendor_nos_nl";} else if($_SESSION['userProprov']=="YK"){$servProdb="service_providers_yk"; $apptdb="appointments_yk";$invdb="invoices_yk";$invapptdb="invoice_appt_yk";$vendornodb="vendor_nos_yk";} else if($_SESSION['userProprov']=="NW"){$servProdb="service_providers_nw"; $apptdb="appointments_nw";$invdb="invoices_nw";$invapptdb="invoice_appt_nw";$vendornodb="vendor_nos_nw";} else if($_SESSION['userProprov']=="NV"){$servProdb="service_providers_nv"; $apptdb="appointments_nv";$invdb="invoices_nv";$invapptdb="invoice_appt_nv";} $link_id = db_connect(); if(!link_id) die(sql_error()); ///////get invoice_total and balance, then check if there is a change to the total, if so update total and balance////// $update_query0="SELECT invoice_total, balance from $invdb WHERE invoice_id ='$invoice_id'"; $update_result0=mysql_query($update_query0); if(!update_result0) error_message(sql_error()); $update_resultset=mysql_fetch_array($update_result0); $invoice_total_fdb=$update_resultset['invoice_total']; $balance_fdb=$update_resultset['balance']; $invoice_total=0; $gsttaxable=0; for ($count=0; $count < $count_end; $count++) { $update_query3 = "UPDATE $apptdb SET Assmt='"; $update_query3 .= $appt_type_array[$count]; $update_query3 .= "' WHERE appt_id ="; $update_query3 .= $appt_id_array[$count]; $appt_price_clean=$appt_price_array[$count]; $appt_price_clean=str_replace(",","",$appt_price_clean); $update_query4 = "UPDATE $invapptdb SET appt_price="; $update_query4 .= $appt_price_clean; $update_query4 .= " WHERE invoice_id="; $update_query4 .= $invoice_id; $update_query4 .= " AND appt_id="; $update_query4 .= $appt_id_array[$count]; $invoice_total += $appt_price_clean; $Appt_type=$appt_type_array[$count]; $assmtarray=array(9999,0,4,5,6,12,13,14,15,16, 20,21,22,30,31,32, 93, 170,171,172); $assmtarray2=array($Appt_type); $ASresult=array_intersect($assmtarray, $assmtarray2); if(count($ASresult) !=0){$Assmtnotax=1;} else {$Assmtnotax=0;} if(($Assmtnotax != 1) && (!$gst_exempt)) { $gsttaxable += $appt_price_clean; } } $gst_amt=($gsttaxable * 0.07); $invoice_total=$invoice_total + $gst_amt; $invoice_total=number_format($invoice_total, 2, '.',''); //if($invoice_total != $invoice_total_fdb) //{ $difference=$invoice_total - $invoice_total_fdb; $balance = $balance_fdb + $difference; $balance=number_format($balance, 2, '.',''); $total_balance_query="UPDATE $invdb SET invoice_total=$invoice_total, balance=$balance WHERE invoice_id=$invoice_id"; $total_balance_result=mysql_query($total_balance_query); if(!total_balance_result) error_message(sql_error()); //} $update_query="UPDATE $invdb SET "; if($gst_exempt) { $update_query .= "gst_exempt=1"; } else { $update_query .= "gst_exempt=0"; } $update_query .= ", thirdparty='"; $update_query .= $third_co; $update_query .= "', due_date='"; $update_query .= $due_date; $update_query .= "', invoice_date='"; $update_query .= $invoice_date; if($payable_to != 'same') { $update_query .= "', payable_to='"; $update_query .= $payable_to; } if($office != 'same') { $update_query .= "', office='"; $update_query .= $office; } $update_query .= "', cl_slct='"; $update_query .= $CL_selected; $update_query .= "' WHERE invoice_id="; $update_query .= $invoice_id; if(!empty($vendor_no)) { if($vendor_in_db == '1') { $update_query2="UPDATE $vendornodb SET vendor_no='"; $update_query2 .= $vendor_no; $update_query2 .= "' WHERE Pro_id='"; $update_query2 .= $Pro_id; $update_query2 .= "' AND thirdparty='"; $update_query2 .= $third_co; $update_query2 .= "'"; } else { $update_query2="INSERT INTO $vendornodb (R_id, Pro_id, thirdparty, vendor_no) VALUES (NULL, "; $update_query2 .= "'" . $Pro_id . "', '" . $third_co . "', '" . $vendor_no; $update_query2 .= "')"; } } $update_result=mysql_query($update_query); if(!update_result) error_message(sql_error()); $update_result2=mysql_query($update_query2); if(!update_result2) error_message(sql_error()); $update_result3=mysql_query($update_query3); if(!update_result3) error_message(sql_error()); $update_result4=mysql_query($update_query4); if(!update_result4) error_message(sql_error()); back2pages("Your invoice has been revised!"); echo "

Appointments can be scheduled at www.zappointments.com

"; ?>