Jump to content

Fix unmatched due date from products and domain


nka

Recommended Posts

Hello,

 

I'm not a dev, but I made this to help me. Maybe someone would love to have it.

 

What it does it search in the database for annual hosting and search if there's a domain. If yes, it look if both have the same "due date" so the customer won't have two invoice. You can fix that by clicking the "fix" (it will update the due date of the domain to the due date of the products).

 

Maybe there's some more thing we could do, like a "fix all".

 

It's a reports, so just put this file into /modules/reports/ and you'll see it in "reports" into WHMCS Admin.

 

<?php

if (!defined("WHMCS"))
die("This file cannot be accessed directly");

if ($_POST['fixid']) {
$fixid = $_POST['fixid'];
$fixduedate = $_POST['fixduedate'];
$fixquery = "UPDATE tbldomains SET nextduedate=\"". $fixduedate ."\",nextinvoicedate=\"". $fixduedate ."\" WHERE id=\"". $fixid ."\"";
$fixupdate = "Fix Result: ";
$fixresult = mysql_query($fixquery) or $fixupdate = $fixupdate."<FONT COLOR=\"RED\">NOT</FONT> ";
$fixupdate = $fixupdate."UPDATED"; 
} else {
$fixquery="";
$fixupdate="";
$fixresult="";
}


$reportdata["title"] = "Domains not matching products due date";
$reportdata["description"] = $fixupdate;

$query = "SELECT tbldomains.id domainid, tbldomains.domain domaindomain, tbldomains.nextduedate domainnextduedate, tblhosting.nextduedate hostingnextduedate FROM tblhosting INNER JOIN tbldomains ON tblhosting.domain=tbldomains.domain WHERE tblhosting.billingcycle = 'Annually' AND tblhosting.nextduedate != tbldomains.nextduedate";
$result = mysql_query($query);
$num_rows = mysql_num_rows($result);

$reportdata["headertext"] = "Total non-matching domain: $num_rows";

$reportdata["tableheadings"] = array("ID","domain","Domain Due Date", "Hosting Due Date","");

while ($data = mysql_fetch_array($result)) {
$id = $data["domainid"];
$domain = $data["domaindomain"];
$domainduedate = $data["domainnextduedate"];
$hostingduedate = $data["hostingnextduedate"];

$fix = "
<form method=\"post\" action=\"reports.php?report='.$report.'\">
<input type=\"hidden\" name=\"fixid\" value=\"". $id ."\" />
<input type=\"hidden\" name=\"fixduedate\" value=\"".$hostingduedate."\" />
<input type=\"submit\" value=\"Fix\" />";	

$reportdata["tablevalues"][] = array("<a href='clientsdomains.php?id=".$id."' target='_blank'>".$id."</a>",$domain,$domainduedate,$hostingduedate,$fix);
}

$data["footertext"]="";
?>

Link to comment
Share on other sites

Another issue I see is if the domain has 3 years until expire and the hosting is per year, if you click the fix it will change the domain to the account which would be wrong, also I think if you have the CRON run it will change the domain date back.

Link to comment
Share on other sites

For the "Canceled/Terminated", you only need to modify the SQL request and add something like "AND tblhosting.status =! "Canceled"".

 

As for the 3 years... would need some fix for that kind of exception, like reading the number of year of both products and do the math. I didn't go that deep.

 

If someone wish to take and improve it, go for it! ;)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated