Jump to content

Function Not Returning Duplicate Leads Within 30 Days


Greywacke
 Share

Recommended Posts

hi there,it's me again. i've been through the following PHP function i don't know how many times, but i don't seem to get why it's not trapping duplicate leads. it is supposed to get $dd as 30, $ddate should = $dd days ago from any time and serviceid is 1. the supplier matched has duplicate leads when a client submits the form twice, usually due to a choppy connection. i can always prevent the form from submitting twice, but what if the client refreshes and submits the same data?

function duplicatedays($mail,$serviceid,$supplierid) { // check supplierid too?	$sql = "SELECT smallint_DuplicateDays FROM 2_servicescatalogue WHERE bigint_ServiceID = ".$serviceid.";";	$GLOBALS["sql"] .= $sql;	$result = mysql_query($sql);	$err = mysql_error();	$GLOBALS["sql"] .= strtoupper($err)."\n";	if ($row = mysql_fetch_array($result)) {		$dd = $row["smallint_DuplicateDays"];	}	$ddate = date('Y-m-d H:i:s', strtotime(date("Y-m-d H:i:s"),$dd." days ago"));	$sql = "SELECT bigint_LeadID FROM 6_serviceleads WHERE bigint_ServiceID = ".$serviceid." AND text_Consumer LIKE \"%".$mail."%\" AND bigint_SupplierID = ".$supplierid." AND timestamp_LeadCreated > ".$ddate." ORDER BY timestamp_LeadCreated DESC;";	$GLOBALS["sql"] .= $sql;	$result = mysql_query($sql);	$err = mysql_error();	$GLOBALS["sql"] .= strtoupper($err)."\n";	if ($result) {		$leadids = array();		while ($row = mysql_fetch_array($result)) {			array_push($leadids,"#".($row["bigint_LeadID"]+11001000));		}		return " (".join(", ",$leadids).")";	} else {		return "";	}}

now this function is called as follows further down to set the appendage to the subject line of the lead being sent.

$append = duplicatedays($consumeremail,$service,$recipient[6]);					// check duplicate days

then this variable is later used again where the subject is set, however i don't receive notification of duplicate leads in the subject this way...

$mail->Subject		= getSubText($body,"<title>","</title>").$append;			// set subject to template page title and append text

the leads are sent with this page.what could possibly be wrong with the function that it's not trapping the duplicate leads within the days specified on the service level?the server is using php 5.2.9 so there is not a date_sub functionality available.how could i discover wat the problem is? could it be in the date_sub substitution?

Link to comment
Share on other sites

okay :)here is the problem: the sql string selecting the duplicate leads returns the following:

SELECT bigint_LeadID FROM 6_serviceleads WHERE bigint_ServiceID = 1 AND text_Consumer LIKE "%pierre@greywacke.co.za%" AND bigint_SupplierID = 13 AND timestamp_LeadCreated > 2010-02-25 06:08:28 ORDER BY timestamp_LeadCreated DESC;

YOU HAVE AN ERROR IN YOUR SQL SYNTAX; CHECK THE MANUAL THAT CORRESPONDS TO YOUR MYSQL SERVER VERSION FOR THE RIGHT SYNTAX TO USE NEAR '06:08:28 ORDER BY TIMESTAMP_LEADCREATED DESC' AT LINE 1
issue almost resolved i believe :)
Link to comment
Share on other sites

okay, this problem is still around :)here is the current function, it's supposed to insert the variable into the mails along with the others now, but the function keeps returning blank.

function duplicatedays($mail,$serviceid,$supplierid) { // check supplierid too?	$sql = "SELECT smallint_DuplicateDays FROM 2_servicescatalogue WHERE bigint_ServiceID = ".$serviceid.";";	$GLOBALS["sql"] .= $sql;	$result = mysql_query($sql);	$err = mysql_error();	$GLOBALS["sql"] .= strtoupper($err)."\n";	if ($row = mysql_fetch_array($result)) {		$dd = $row["smallint_DuplicateDays"];	}	$ddate = date('Y-m-d H:i:s', strtotime(date("Y-m-d H:i:s"),$dd." days ago"));	$sql = "SELECT bigint_LeadID FROM 6_serviceleads WHERE bigint_ServiceID = ".$serviceid." AND text_Consumer LIKE \"%".$mail."%\" AND bigint_SupplierID = ".$supplierid." AND timestamp_LeadCreated > \"".$ddate."\" ORDER BY timestamp_LeadCreated DESC;";	$GLOBALS["sql"] .= $sql;	$result = mysql_query($sql);	$err = mysql_error();	$GLOBALS["sql"] .= strtoupper($err)."\n";	if ($result) {		$leadids = array();		while ($row = mysql_fetch_array($result)) {			array_push($leadids,"#".($row["bigint_LeadID"]+11001000));		}		return " (".join(", ",$leadids).")";	} else {		return "";	}}

the criteria for this functions purpose is the following now:

once supplier is matched, then only check within that supplier_loop of matching process whether Service + Supplier + ConsumerEmail combination within Duplicate Days = true --> then duplicate --> then change charge = 0 --< and indicate duplicate number somewhere in body of text (would suggest ... "Andy Cab (Gauteng) was was matched (*** duplicate #11001735 ***) with the following attributes" ...)
$append is set within this loop with the following code.
$append = duplicatedays($consumeremail,$service,$recipient[6]); // check duplicate days

$consumeremail is requested from the form and used in the email and to add leads successfully.$service is set to 1, this is the only service this form is for.$recipient[6] is part of the recipient array, it contains the id of the supplier that was matched.

$body = str_replace("%DUPLICATEDAYS%",$append,$body); // insert duplicate days notification

the previous line of code replaces a %DUPLICATEDAYS% marker in the template file loaded as $body to mail, with $append. it still refuses to acknowledge duplicate leads.i check wether the attribute value is "" (an empty string)

if ($append=="") {

and then don't charge and add transactions.$append is used nowhere else in the handler, incase the value was being deprecated.according to the above criteria... why could this be??? someone PLEASE help! i'm afraid i do not see the pile of oranges for the apples hidden in between...

Edited by Pierre 'Greywacke' du Toit
Link to comment
Share on other sites

this issue has been resolved, it turned out the population of the $append variable happened before a lead was selected - thus the parameters passed to the function were empty...ISSUE RESOLVED :)

Edited by Pierre 'Greywacke' du Toit
Link to comment
Share on other sites

lol well wether i get help or not, these issues i post need resolving.i have to make a living :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...