
//*********************demo name********************************************//



function demo_name_validate (demo_name)



{



    valid = true;



	if(demo_name== "" )



    {



		document.getElementById("demo_no_err_design").style.display = "block";



		document.getElementById("demo_no_err_msg").style.display = "block";



        return false;



    }



	if(demo_name.length <=3 )



    {



		document.getElementById("demo_no_err_design").style.display = "block";



		document.getElementById("demo_no_err_msg").style.display = "block";



        return false;



    }







	else



	{



		document.getElementById("demo_no_err_design").style.display = "none";



		document.getElementById("demo_no_err_msg").style.display = "none";



        return false;







	}



}



//*************************************sales_name***********************************//



function sales_name_validate(sales_name)



{



    valid = true;



	if(sales_name== "" )



    {



		document.getElementById("sales_name_err_design").style.display = "block";



		document.getElementById("sales_name_err_msg").style.display = "block";



        return false;



    }



	if(sales_name.length <=3 )



    {



		document.getElementById("sales_name_err_design").style.display = "block";



		document.getElementById("sales_name_err_msg").style.display = "block";



        return false;



    }







	else



	{



		document.getElementById("sales_name_err_design").style.display = "none";



		document.getElementById("sales_name_err_msg").style.display = "none";



        return false;







	}



}







//********************************************itm purchased*****************************//



function items_purchased_validate (items_purchased)



{



	



    valid = true;



	if(items_purchased==0 )



    {



		document.getElementById("items_purchased_err_design").style.display = "block";



		document.getElementById("items_purchased_err_msg").style.display = "block";



        return false;



    }



	else



	{



		document.getElementById("items_purchased_err_design").style.display = "none";



		document.getElementById("items_purchased_err_msg").style.display = "none";



        return false;







	}



}



//*************************************total contract amount***********************//



function total_contract_amount_validate (total_contract_amount)



{



valid = true;



	if(total_contract_amount== "" )



    {



		document.getElementById("total_contract_amount_err_design").style.display = "block";



		document.getElementById("total_contract_amount_err_msg").style.display = "block";



        return false;



    }



	



	else



	{



		document.getElementById("total_contract_amount_err_design").style.display = "none";



		document.getElementById("total_contract_amount_err_msg").style.display = "none";



        return false;







	}



}



//************************************AMOUN FINANVED**********************//



function amount_financed_validate (amount_financed)



{



valid = true;



	if(amount_financed== "" )



    {



		document.getElementById("amount_financed_err_design").style.display = "block";



		document.getElementById("amount_financed_err_msg").style.display = "block";



        return false;



    }



	



	else



	{



		document.getElementById("amount_financed_err_design").style.display = "none";



		document.getElementById("amount_financed_err_msg").style.display = "none";



        return false;







	}



}







//*****************************************total_down_payment_***********************



function total_down_payment_validate (total_down_payment)



{



    valid = true;



	if(total_down_payment== "" )



    {



		document.getElementById("total_down_payment_err_design").style.display = "block";



		document.getElementById("total_down_payment_err_msg").style.display = "block";



        return false;



    }



	else



	{



		document.getElementById("total_down_payment_err_design").style.display = "none";



		document.getElementById("total_down_payment_err_msg").style.display = "none";



        return false;







	}



}



//*****************************************total_down_payment_***********************



function total_down_payment_validate (total_down_payment)



{



    valid = true;



	if(total_down_payment== "" )



    {



		document.getElementById("total_down_payment_err_design").style.display = "block";



		document.getElementById("total_down_payment_err_msg").style.display = "block";



        return false;



    }



	else



	{



		document.getElementById("total_down_payment_err_design").style.display = "none";



		document.getElementById("total_down_payment_err_msg").style.display = "none";



        return false;







	}



}







//****************************************initial_amount**************************************///



function initial_amount_validate (initial_amount)



{

    valid = true;

	if(initial_amount== "" )

    {

		document.getElementById("initial_amount_err_design").style.display = "block";

		document.getElementById("initial_amount_err_msg").style.display = "block";

        return false;

    }



	/*var downpayment=document.getElementById("total_down_payment").value;



	var init_amount=document.getElementById("initial_amount").value;



    valid = true;



	if(parseFloat(init_amount) < parseFloat(downpayment)){



		document.getElementById("initial_amount_err_design").style.display = "block";



		document.getElementById("initial_amount_err_msg").style.display = "block";



        return false;



    }*/

	else

	{

		document.getElementById("initial_amount_err_design").style.display = "none";

		document.getElementById("initial_amount_err_msg").style.display = "none";

        return false;

	}

}







//****************************************initial_amount**************************************///



function check_initial_amount_validate ()



{



	



	var downpayment=document.getElementById("total_down_payment").value;



	var init_amount=document.getElementById("initial_amount").value;



    valid = true;



	if(parseFloat(init_amount) < parseFloat(downpayment)){



		document.getElementById("initial_amount_err_design").style.display = "block";



		document.getElementById("initial_amount_err_msg").style.display = "block";



        return false;



    }



	else



	{



		document.getElementById("initial_amount_err_design").style.display = "none";



		document.getElementById("initial_amount_err_msg").style.display = "none";



        return false;







	}



}







//*******************************signed_contract***************************************************//



function signed_contract_validate (signed_contract)



{



    valid = true;



	if(signed_contract== 0 )



    {



		document.getElementById("signed_contract_err_design").style.display = "block";



		document.getElementById("signed_contract_err_msg").style.display = "block";



        return false;



    }



	else



	{



		document.getElementById("signed_contract_err_design").style.display = "none";



		document.getElementById("signed_contract_err_msg").style.display = "none";



        return false;







	}



}



//***********************************support_document*******************************************//



function support_document_validate (support_document)



{



    valid = true;



	if(support_document== 0 )



    {



		document.getElementById("support_document_err_design").style.display = "block";



		document.getElementById("support_document_err_msg").style.display = "block";



        return false;



    }



	else



	{



		document.getElementById("support_document_err_design").style.display = "none";



		document.getElementById("support_document_err_msg").style.display = "none";



        return false;







	}



}



//*****************************************financed********************************************//



function financed_validate (financed)



{



    valid = true;



	if(financed== 0 )



    {



		document.getElementById("financed_document_err_design").style.display = "block";



		document.getElementById("financed_document_err_msg").style.display = "block";



        return false;



    }



	else



	{



		document.getElementById("financed_document_err_design").style.display = "none";



		document.getElementById("financed_document_err_msg").style.display = "none";



        return false;







	}



}







//*****************************************Status********************************************//



function status_new_validate (financed)



{



    valid = true;



	if(financed== 0 )



    {



		document.getElementById("status_new_document_err_design").style.display = "block";



		document.getElementById("status_new_document_err_msg").style.display = "block";



        return false;



    }



	else



	{



		document.getElementById("status_new_document_err_design").style.display = "none";



		document.getElementById("status_new_document_err_msg").style.display = "none";



        return false;







	}



}







//*****************************sales_streeet*******************************************//







function sales_street_validate (sales_street)



{



valid = true;



	if(sales_street== "" )



    {



		document.getElementById("sales_street_err_design").style.display = "block";



		document.getElementById("sales_street_err_msg").style.display = "block";



        return false;



    }



	if(sales_street.length <=3 )



    {



		document.getElementById("sales_street_err_design").style.display = "block";



		document.getElementById("sales_street_err_msg").style.display = "block";



        return false;



    }







	else



	{



		document.getElementById("sales_street_err_design").style.display = "none";



		document.getElementById("sales_street_err_msg").style.display = "none";



        return false;







	}



}



//********************************************************sales_colonia_validate*********************************



function sales_colonia_validate (sales_colonia)



{



    valid = true;



	if(sales_colonia== "" )



    {



		document.getElementById("sales_colonia_err_design").style.display = "block";



		document.getElementById("sales_colonia_err_msg").style.display = "block";



        return false;



    }



	if(sales_colonia.length <=3 )



    {



		document.getElementById("sales_colonia_err_design").style.display = "block";



		document.getElementById("sales_colonia_err_msg").style.display = "block";



        return false;



    }







	else



	{



		document.getElementById("sales_colonia_err_design").style.display = "none";



		document.getElementById("sales_colonia_err_msg").style.display = "none";



        return false;







	}



}



//*****************************************************sales_city****************************************//



function sales_city_validate (sales_city)



{



   valid = true;



	if(sales_city== "" )



    {



		document.getElementById("sales_city_err_design").style.display = "block";



		document.getElementById("sales_city_err_msg").style.display = "block";



        return false;



    }



	if(sales_city.length <=3 )



    {



		document.getElementById("sales_city_err_design").style.display = "block";



		document.getElementById("sales_city_err_msg").style.display = "block";



        return false;



    }







	else



	{



		document.getElementById("sales_city_err_design").style.display = "none";



		document.getElementById("sales_city_err_msg").style.display = "none";



        return false;







	}



}



//*****************************************************sales_city****************************************//



function sales_phone_validate (sales_phone)



{



   valid = true;



	if(sales_phone== "" )



    {



		document.getElementById("sales_phone_err_design").style.display = "block";



		document.getElementById("sales_phone_err_msg").style.display = "block";



        return false;



    }



	if(sales_phone.length <=10 )



    {



		document.getElementById("sales_phone_err_design").style.display = "block";



		document.getElementById("sales_phone_err_msg").style.display = "block";



        return false;



    }







	else



	{



		document.getElementById("sales_phone_err_design").style.display = "none";



		document.getElementById("sales_phone_err_msg").style.display = "none";



        return false;







	}



}







//********************************demo_address_validate**********************************************//



function demo_address_validate (demo_address)



{



       valid = true;



	if(demo_address== "" )



    {



		document.getElementById("demo_address_err_design").style.display = "block";



		document.getElementById("demo_address_err_msg").style.display = "block";



        return false;



    }



	if(demo_address.length <=3 )



    {



		document.getElementById("demo_address_err_design").style.display = "block";



		document.getElementById("demo_address_err_msg").style.display = "block";



        return false;



    }







	else



	{



		document.getElementById("demo_address_err_design").style.display = "none";



		document.getElementById("demo_address_err_msg").style.display = "none";



        return false;







	}



}



//*****************************************demo_colonia****************************************//



function demo_colonia_validate (demo_colonia)



{



	



      valid = true;



	if(demo_colonia== "" )



    {



		document.getElementById("demo_colonia_err_design").style.display = "block";



		document.getElementById("demo_colonia_err_msg").style.display = "block";



        return false;



    }



	if(demo_colonia.length <=3 )



    {



		document.getElementById("demo_colonia_err_design").style.display = "block";



		document.getElementById("demo_colonia_err_msg").style.display = "block";



        return false;



    }







	else



	{



		document.getElementById("demo_colonia_err_design").style.display = "none";



		document.getElementById("demo_colonia_err_msg").style.display = "none";



        return false;







	}



}



//**************************************************demo_city_validate************************//







function demo_city_validate (demo_city)



{ 



valid = true;



	if(demo_city== "" )



    {



		document.getElementById("demo_city_err_design").style.display = "block";



		document.getElementById("demo_city_err_msg").style.display = "block";



        return false;



    }



	if(demo_city.length <=3 )



    {



		document.getElementById("demo_city_err_design").style.display = "block";



		document.getElementById("demo_city_err_msg").style.display = "block";



        return false;



    }







	else



	{



		document.getElementById("demo_city_err_design").style.display = "none";



		document.getElementById("demo_city_err_msg").style.display = "none";



        return false;







	}



}







//**************************************************additional_item************************//







function additional_item_validate (additional_item)



{ 



valid = true;



	if(additional_item== "" )



    {



		document.getElementById("additional_item_err_design").style.display = "block";



		document.getElementById("additional_item_err_msg").style.display = "block";



        return false;



    }



	if(additional_item.length <=3 )



    {



		document.getElementById("additional_item_err_design").style.display = "block";



		document.getElementById("additional_item_err_msg").style.display = "block";



        return false;



    }







	else



	{



		document.getElementById("additional_item_err_design").style.display = "none";



		document.getElementById("additional_item_err_msg").style.display = "none";



        return false;







	}



}







//**************************************************additional_item************************//







function notes_to_sales_person_validate (notes_to_sales)



{ 



valid = true;



	if(notes_to_sales== "" )



    {



		document.getElementById("notes_to_sales_person_err_design").style.display = "block";



		document.getElementById("notes_to_sales_person_err_msg").style.display = "block";



        return false;



    }



	if(notes_to_sales.length <=3 )



    {



		document.getElementById("notes_to_sales_person_err_design").style.display = "block";



		document.getElementById("notes_to_sales_person_err_msg").style.display = "block";



        return false;



    }







	else



	{



		document.getElementById("notes_to_sales_person_err_design").style.display = "none";



		document.getElementById("notes_to_sales_person_err_msg").style.display = "none";



        return false;







	}



}



//***************************************************follow_up_validate*********************



function follow_up_validate (follow_up)



{



    valid = true;



	if(follow_up== 0 )



    {



		document.getElementById("follow_up_err_design").style.display = "block";



		document.getElementById("follow_up_err_msg").style.display = "block";



        return false;



    }



	else



	{



		document.getElementById("follow_up_err_design").style.display = "none";



		document.getElementById("follow_up_err_msg").style.display = "none";



        return false;







	}



}



//****************************************TIME************************************//



function lead_time_validate_follow (datepic)



{



    valid = true;



	if(datepic=="" )



    {



		document.getElementById("date_time_err_design").style.display = "block";



        return false;



    }



	else



	{



		document.getElementById("date_time_err_design").style.display = "none";



        return false;







	}



}











//*******************************drop down change*************************************//



function newindow9(follow_up)



{



    if(follow_up=='Yes')



    {



		document.getElementById("follow_up_details_div").style.display = "inline";



        return false;



    }



	else



	{



		document.getElementById("follow_up_details_div").style.display = "none";



        return false;



	}



}



/****************************** NEW PROSPECTOR ***************************************/
var p5= jQuery.noConflict();
function add_pending_details(prospector_id,demo_name,sales_name,phone,sales_phone,items_purchased,total_contract_amount,total_down_payment,amt_financed,signed_contract,support_document,financed,sales_street,sales_colonia,sales_city,demo_address,demo_colonia,demo_city,additional_item,follow_up,date_pick_pending,time_hr,time_min,note,initial_amount,action_value)
{
	if(follow_up=="Yes")
{ 
		if((date_pick_pending!=""))
		{
			var aa = "OK";	
		}
		else
		{
			var aa = "";	
			lead_time_validate_follow (date_pick_pending);
		}
}
if(follow_up =="No")
{	
var aa = "OK";	
}
	if((demo_name!="")&&(sales_name!='')&&(phone!='')&&(items_purchased!='')&&(total_contract_amount!='')&&(total_down_payment!='')&&(amt_financed!='')&&(signed_contract!='')&&(support_document!='')&&(financed!='')&&(sales_colonia!='')&&(sales_city!='')&&(sales_phone!='')&&(demo_address!='')&&(demo_colonia!='')&&(demo_city!='')&&(initial_amount!='')&&(aa=='OK'))
	{	//alert(action_value);
		p5("#pending_det_div").html('<img src="images/ajax-loader.gif"> Loading...');
		p5.ajax({
		type: "POST",
		url: "sales_manager_approval/manager_pending_sales/pending_sales_db.php",
		data: "prospector_id="+prospector_id+"&demo_name="+demo_name+"&sales_name="+sales_name+"&phone="+phone+"&sales_phone="+sales_phone+"&items_purchased="+items_purchased+"&total_contract_amount="+total_contract_amount+"&total_down_payment="+total_down_payment+"&amt_financed="+amt_financed+"&signed_contract="+signed_contract+"&support_document="+support_document+"&financed="+financed+"&sales_street="+sales_street+"&sales_colonia="+sales_colonia+"&sales_city="+sales_city+"&demo_address="+demo_address+"&demo_colonia="+demo_colonia+"&demo_city="+demo_city+"&additional_item="+additional_item+"&follow_up="+follow_up+"&date_pick_pending="+date_pick_pending+"&time_hr="+time_hr+"&time_min="+time_min+"&note="+note+"&initial_amount="+initial_amount+"&action="+action_value,
		success: function(msg){p5("#pending_det_div").html(msg); 
		load_pending_list();
		}		

		});

/*	    document.getElementById("signed_contract").value="";
    	document.getElementById("initial_amount").value="";
		document.getElementById("items_purchased").value="";
		document.getElementById("total_contract_amount").value="";
	    document.getElementById("total_down_payment").value="";
        document.getElementById("amt_financed").value="";	
		document.getElementById("support_document").value="";
		document.getElementById("financed").value="";
		document.getElementById("additional_item").value="";
		document.getElementById("follow_up").value="";
*/		//window.opener.location.reload(true);
	}
	else
	{

		demo_name_validate(demo_name),sales_name_validate(sales_name),items_purchased_validate (items_purchased),total_contract_amount_validate (total_contract_amount),total_down_payment_validate (total_down_payment),signed_contract_validate (signed_contract),support_document_validate (support_document),financed_validate (financed), sales_colonia_validate(sales_colonia),sales_city_validate(sales_city),sales_phone_validate (sales_phone),demo_address_validate (demo_address),demo_colonia_validate (demo_colonia),demo_city_validate (demo_city),follow_up_validate (follow_up),initial_amount_validate(initial_amount),amount_financed_validate (amt_financed);

	}
}







//***********************************************************************************************************************************************//











function manger_add_pending_details(prospector_id,demo_name,sales_name,phone,sales_phone,items_purchased,total_contract_amount,total_down_payment,amt_financed,signed_contract,support_document,financed,sales_street,sales_colonia,sales_city,demo_address,demo_colonia,demo_city,additional_item,follow_up,date_pick_pending,time_hr,time_min,note,status_new,notes_to_sales_person,initial_amount,action_value)



{



if(follow_up=="Yes")



{ 



		if((date_pick_pending!=""))



		{



			var aa = "OK";	



		}



		else



		{



			var aa = "";	



			lead_time_validate_follow (date_pick_pending);



		}



}



if(follow_up =="No")



{	



var aa = "OK";	



}



if((demo_name!="")&&(sales_name!='')&&(phone!='')&&(items_purchased!='')&&(total_contract_amount!='')&&(total_down_payment!='')&&(amt_financed!='')&&(signed_contract!='')&&(support_document!='')&&(financed!='')&&(sales_colonia!='')&&(sales_city!='')&&(sales_phone!='')&&(demo_address!='')&&(demo_colonia!='')&&(demo_city!='')&&(follow_up!='')&&(initial_amount!='')&&(aa=='OK'))



	{	







		p5("#manger_pending_det_div").html('<img src="images/ajax-loader.gif"> Loading...');



		p5.ajax({



		type: "POST",



		url: "sales_manager_approval/manager_pending_sales/pending_sales_db.php",



		data: "prospector_id="+prospector_id+"&demo_name="+demo_name+"&phone="+phone+"&sales_phone="+sales_phone+"&sales_name="+sales_name+"&items_purchased="+items_purchased+"&total_contract_amount="+total_contract_amount+"&total_down_payment="+total_down_payment+"&amt_financed="+amt_financed+"&signed_contract="+signed_contract+"&support_document="+support_document+"&financed="+financed+"&sales_street="+sales_street+"&sales_colonia="+sales_colonia+"&sales_city="+sales_city+"&demo_address="+demo_address+"&demo_colonia="+demo_colonia+"&demo_city="+demo_city+"&additional_item="+additional_item+"&follow_up="+follow_up+"&date_pick_pending="+date_pick_pending+"&time_hr="+time_hr+"&time_min="+time_min+"&note="+note+



		"&status_new="+status_new+"&notes_to_sales_person="+notes_to_sales_person+"&initial_amount="+initial_amount+"&action="+action_value,



		success: function(msg){p5("#manger_pending_det_div").html(msg);
		manager_load_pending_list();
		}		



		});



/*		document.getElementById("items_purchased").value="";



		document.getElementById("total_contract_amount").value="";



		document.getElementById("total_down_payment").value="";



		document.getElementById("deposit_amount").value="";



		document.getElementById("amt_financed").value="";



		document.getElementById("signed_contract").value="";



		document.getElementById("support_document").value="";



		document.getElementById("financed").value="";



		document.getElementById("additional_item").value="";



		document.getElementById("follow_up").value="";

*/









		window.close();



	}



	else



	{



		demo_name_validate(demo_name),sales_name_validate(sales_name),items_purchased_validate (items_purchased),total_contract_amount_validate (total_contract_amount),signed_contract_validate (signed_contract),support_document_validate (support_document),financed_validate (financed), status_new_validate (financed),sales_colonia_validate(sales_colonia),sales_city_validate(sales_city),sales_phone_validate(sales_phone),demo_address_validate (demo_address),demo_colonia_validate (demo_colonia),demo_city_validate (demo_city),initial_amount_validate(initial_amount),follow_up_validate (follow_up);



	}



}







//*******************************************************************manager status_update****************************************************************************//











function manger_update_pending_details(prospector_id,status_new,notes_to_sales_person)



{



	if((status_new!="")&&(notes_to_sales_person!=''))



	{	







		p5("#manager_update_pending_det_div").html('<img src="images/ajax-loader.gif"> Loading...');



		p5.ajax({



		type: "GET",



		url: "sales_manager_approval/manager_pending_sales/pending_sales_db.php",



		data: "prospector_id="+prospector_id+"&status_new="+status_new+"&notes_to_sales_person="+notes_to_sales_person+"&action=MANGER UPDATE",



		success: function(msg){p5("#manager_update_pending_det_div").html(msg);
		manager_load_pending_list();}		



		});







		window.close();



	}



	else



	{



		 status_new_validate (status_new),notes_to_sales_person_validate(notes_to_sales_person);



	}



}



/****************************** EDIT FORM***************************************/



function update_pending_details_form(prospector_id,demo_name,sales_name,phone,sales_phone,items_purchased,total_contract_amount,total_down_payment,initial_amount,amt_financed,signed_contract,support_document,financed,sales_street,sales_colonia,sales_city,demo_address,demo_colonia,demo_city,additional_item,follow_up,date_pick_pending,time_hr,time_min,note,edit_id,action_value)



{ 



if(follow_up=="Yes")



{ 



		if((date_pick_pending!=""))



		{



			var aa = "OK";	



		}



		else



		{



			var aa = "";	



			lead_time_validate_follow (date_pick_pending);



		}



}



if(follow_up =="No")



{	



var aa = "OK";	



}







	if((demo_name!="")&&(sales_name!='')&&(phone!='')&&(items_purchased!='')&&(total_contract_amount!='')&&(total_down_payment!='')&&(amt_financed!='')&&(signed_contract!='')&&(support_document!='')&&(financed!='')&&(sales_colonia!='')&&(sales_city!='')&&(sales_phone!='')&&(demo_address!='')&&(demo_colonia!='')&&(demo_city!='')&&(follow_up!='')&&(initial_amount!='')&&(aa=='OK'))

	{
alert(prospector_id);
		p1("#pending_det_div").html('<img src="images/ajax-loader.gif"> Loading...');

		p1.ajax({

		type: "POST",

		url: "sales_manager_approval/manager_pending_sales/pending_sales_db.php",

		data: "prospector_id="+prospector_id+"&demo_name="+demo_name+"&sales_name="+sales_name+"&phone="+phone+"&sales_phone="+sales_phone+"&items_purchased="+items_purchased+"&total_contract_amount="+total_contract_amount+"&total_down_payment="+total_down_payment+"&initial_amount="+initial_amount+"&amt_financed="+amt_financed+"&signed_contract="+signed_contract+"&support_document="+support_document+"&financed="+financed+"&sales_street="+sales_street+"&sales_colonia="+sales_colonia+"&sales_city="+sales_city+"&demo_address="+demo_address+"&demo_colonia="+demo_colonia+"&demo_city="+demo_city+"&additional_item="+additional_item+"&follow_up="+follow_up+"&date_pick_pending="+date_pick_pending+"&time_hr="+time_hr+"&time_min="+time_min+"&note="+note+"&edit_id="+edit_id+"&action="+action_value,

		success: function(msg){p1("#pending_det_div").html(msg);
		     load_pending_list();
			  
			  }


		});



/*		document.getElementById("additional_item").value="";



		document.getElementById("follow_up").value="";



	    document.getElementById("signed_contract").value="";



    	document.getElementById("initial_amount").value="";



		document.getElementById("items_purchased").value="";



		document.getElementById("total_contract_amount").value="";



	    document.getElementById("total_down_payment").value="";



		document.getElementById("initial_amount").value="";



		document.getElementById("amt_financed").value="";	



		document.getElementById("support_document").value="";
*/


		document.pending_form.addsales.value="SAVE";






	







		//window.close();



	}



	else



	{



		demo_name_validate(demo_name),sales_name_validate(sales_name),items_purchased_validate (items_purchased),total_contract_amount_validate (total_contract_amount),total_down_payment_validate (total_down_payment),signed_contract_validate (signed_contract),support_document_validate (support_document),financed_validate (financed), sales_colonia_validate(sales_colonia),sales_city_validate(sales_city),sales_phone_validate (sales_phone),demo_address_validate (demo_address),demo_colonia_validate (demo_colonia),demo_city_validate (demo_city),initial_amount_validate(initial_amount),follow_up_validate (follow_up);



	}



}


function load_pending_list()
{
		p1.ajax({
		type: "GET",
		url: "sales_approval/pending_sales/pending_sales_list.php",
		data: "action=add_edit",
		success: function(msg){p1("#prospector_details_div").html(msg);
			  }
		});
}
function manager_load_pending_list()
{//alert();
		p5.ajax({
		type: "GET",
		url: "sales_manager_approval/manager_pending_sales/pending_sales_list.php",
		data: "action=add_edit",
		success: function(msg){p5("#prospector_details_div").html(msg);
			  }
		});
}

/****************************** EDIT FORM***************************************/



function update_manager_pending_details_form(prospector_id,demo_name,sales_name,phone,sales_phone,items_purchased,total_contract_amount,total_down_payment,amt_financed,signed_contract,support_document,financed,sales_street,sales_colonia,sales_city,demo_address,demo_colonia,demo_city,additional_item,follow_up,date_pick_pending,time_hr,time_min,note,status_new,notes_to_sales_person,initial_amount,edit_id,action_value)



{ //alert(action_value);



if(follow_up=="Yes")



{ 



		if((date_pick_pending!=""))



		{



			var aa = "OK";	



		}



		else



		{



			var aa = "";	



			lead_time_validate_follow (date_pick_pending);



		}



}



if(follow_up =="No")



{	



var aa = "OK";	



}



	if((demo_name!="")&&(sales_name!='')&&(phone!='')&&(items_purchased!='')&&(total_contract_amount!='')&&(total_down_payment!='')&&(amt_financed!='')&&(signed_contract!='')&&(support_document!='')&&(financed!='')&&(sales_colonia!='')&&(sales_city!='')&&(sales_phone!='')&&(demo_address!='')&&(demo_colonia!='')&&(demo_city!='')&&(follow_up!='')&&(initial_amount!='')&&(aa=='OK'))



	{



		p1("#manger_pending_det_div").html('<img src="images/ajax-loader.gif"> Loading...');



		p1.ajax({



		type: "POST",



		url: "sales_manager_approval/manager_pending_sales/pending_sales_db.php",



		data: "prospector_id="+prospector_id+"&demo_name="+demo_name+"&sales_name="+sales_name+"&phone="+phone+"&sales_phone="+sales_phone+"&items_purchased="+items_purchased+"&total_contract_amount="+total_contract_amount+"&total_down_payment="+total_down_payment+"&amt_financed="+amt_financed+"&signed_contract="+signed_contract+"&support_document="+support_document+"&financed="+financed+"&sales_street="+sales_street+"&sales_colonia="+sales_colonia+"&sales_city="+sales_city+"&demo_address="+demo_address+"&demo_colonia="+demo_colonia+"&demo_city="+demo_city+"&additional_item="+additional_item+"&follow_up="+follow_up+"&date_pick_pending="+date_pick_pending+"&time_hr="+time_hr+"&time_min="+time_min+"&note="+note+"&status_new="+status_new+"&notes_to_sales_person="+notes_to_sales_person+"&initial_amount="+initial_amount+"&edit_id="+edit_id+"&action="+action_value,



		success: function(msg){p1("#manger_pending_det_div").html(msg);
		manager_load_pending_list()}



		});

		



/*		document.getElementById("items_purchased").value="";



		document.getElementById("total_contract_amount").value="";



		document.getElementById("total_down_payment").value="";



		document.getElementById("amt_financed").value="";



		document.getElementById("signed_contract").value="";



		document.getElementById("support_document").value="";



		document.getElementById("financed").value="";



		document.getElementById("additional_item").value="";



		document.getElementById("follow_up").value="";

*/

        document.sales_manager_pending_form.m_save.value="Add";











		window.close();



	}



	else



	{



		demo_name_validate(demo_name),sales_name_validate(sales_name),items_purchased_validate (items_purchased),total_contract_amount_validate (total_contract_amount),total_down_payment_validate (total_down_payment),signed_contract_validate (signed_contract),support_document_validate (support_document),financed_validate (financed), status_new_validate (financed),sales_colonia_validate(sales_colonia),sales_city_validate(sales_city),sales_phone_validate (sales_phone),demo_address_validate (demo_address),demo_colonia_validate (demo_colonia),demo_city_validate (demo_city),initial_amount_validate(initial_amount),follow_up_validate (follow_up);



	}



}







/***********************************************************************************************************/



function amountcalculation(total_contract_amount){



	



	var amountfinanced=total_contract_amount;



	var downpay=parseFloat(amountfinanced)*(15/100);



	document.getElementById("total_down_payment").value=parseFloat(downpay);



	



}



/***********************************************************************************************************/



function amountfinancedcalculation(total_contract_amount,total_down_payment){



	



	var contract_amount=parseFloat(total_contract_amount);



	var downpayment=parseFloat(total_down_payment);



	var amountfinanced=parseFloat(contract_amount) - parseFloat(downpayment);



	document.getElementById("amt_financed").value=parseFloat(amountfinanced);



	



}







//********************************************************************************************//



function add_sales_person_action(pending_id,sale_action)



{



	if(sale_action!="")



	{



		



		p9("#sales_person_action_div").html('<img src="images/ajax-loader.gif"> Loading...');



		p9.ajax({



		type: "GET",



		url: "pending_sales/pending_sales_form_enry_db.php",



		data: "pending_id="+pending_id+"&sale_action="+sale_action+"&action=SALES_ACTION",



		success: function(msg){p9("#sales_person_action_div").html(msg);}



		});



	}



	else



	{



		alert("Select  Your Action...!");



   }







 



 }



/****************************** EDIT FORM***************************************/



function 	delete_pending_sales_list(delete_id,prospector_id)



{ 



if(confirm('Are You Sure! You Want To Delete?'))



{





		p1("#pending_det_div").html('<img src="images/ajax-loader.gif"> Loading...');



		p1.ajax({



		type: "POST",



		url: "sales_manager_approval/manager_pending_sales/pending_sales_db.php",



		data: "delete_id="+delete_id+"&prospector_id="+prospector_id+"&action=sales_delete",



		success: function(msg){p1("#pending_det_div").html(msg);load_pending_list();}
        


		});



}



}



 



/********************************************************************************************************************/



function edit_pending_sales_list(edit_id,prospector_id)

{

		p8("#pending_edit_det_div").html('<img src="images/ajax-loader.gif"> Loading...');



		p8.ajax({



		type: "GET",



		url: "sales_approval/pending_sales/pending_form_edit.php",



		data: "edit_id="+edit_id+"&prospector_id="+prospector_id,



		success: function(msg){p8("#pending_edit_det_div").html(msg);}



		});



}



/********************************************************************************************************************/



function edit_manager_pending_sales_list(edit_id,prospector_id)



{







		p8("#pending_manager_edit_det_div").html('<img src="images/ajax-loader.gif"> Loading...');



		p8.ajax({



		type: "GET",



		url: "sales_manager_approval/manager_pending_sales/pending_manager_from_edit.php",



		data: "edit_id="+edit_id+"&prospector_id="+prospector_id,



		success: function(msg){p8("#pending_manager_edit_det_div").html(msg);}



		});



}



/****************************** EDIT FORM***************************************/



function delete_manager_pending_sales_list(delete_id,prospector_id)



{ 



if(confirm('Are You Sure! You Want To Delete?'))



{







		p1("#manger_pending_det_div").html('<img src="images/ajax-loader.gif"> Loading...');



		p1.ajax({



		type: "POST",



		url: "sales_manager_approval/manager_pending_sales/pending_sales_db.php",



		data: "delete_id="+delete_id+"&prospector_id="+prospector_id+"&action=manager_sales_delete",



		success: function(msg){p1("#manger_pending_det_div").html(msg);manager_load_pending_list();}



		});



}



}



/********************************************************************************************************************/



//function get_reloaded(edit_id,prospector_id)



//{



//	   alert();



//



//		p8("#pending_manager_reload_div").html('<img src="images/ajax-loader.gif"> Loading...');



//		p8.ajax({



//		type: "GET",



//		url: "sales_manager_approval/manager_pending_sales/pending_sales_list.php",



//		success: function(msg){p8("#pending_manager_reload_div").html(msg);}



//		});



//}







