Jump to content

Relatório mensal de novos clientes


Patty

Recommended Posts

Bom, vom começar com o pé direito e postar aqui uma dicazinha maneira que postei no meu fórum, no fórum WHMCS e no Hostdime.

Eu queria saber quantos novos clientes assinaram por mês, então eu criei um novo relatório que mostra o ID, nome, status e data de cadastro do cliente.

Clica aqui pra ver a imagem de como ficou (até eu aprender a postar imagem no fórum... rs): http://www.cybernetfx.com.br/images/newclients.gif

Abaixo o código. Salve o arquivo com o nome monthly_clients.php e envie para o diretório whmcs/modules/reports:

<?php

$months = array(\'January\',\'February\',\'March\',\'April\',\'May\',\'June\',\'July\',\'August\',\'September\',\'October\',\'November\',\'December\');

if ($month==\"\") {


    $month=date(\"m\");


    $year=date(\"Y\");


}

$pmonth = str_pad($month, 2, \"0\", STR_PAD_LEFT);  

$reportdata[\"title\"] = \"New Clients for \".$months[$month-1].\" \".$year;


$reportdata[\"description\"] = \"This report shows all new clients for a given month\";

$query = \"SELECT id,firstname,lastname,status,datecreated FROM tblclients WHERE datecreated LIKE \'$year-$pmonth%\' ORDER BY datecreated ASC\";


$result = mysql_query($query);


$num_rows = mysql_num_rows($result);

$reportdata[\"headertext\"] = \"Total New Clients: \" . $num_rows;

$reportdata[\"tableheadings\"] = array(\"ID\",\"Client Name\",\"Status\",\"Signup Date\");

while ($data = mysql_fetch_array($result)) {


    $id = $data[\"id\"];


    $clientname = \"<a>\" . $data[\"firstname\"].\" \".$data[\"lastname\"] . \"</a>\";


    $status = $data[\"status\"];


    $datecreated = $data[\"datecreated\"];


    $datecreated = fromMySQLDate($datecreated);


    $colour = \"<span style=\'color:\";


switch($status)


{


        case \"Active\":


                $colour .= \"blue\";


        break;


        case \"Inactive\":


                $colour .= \"lightgrey\";


        break;


        case \"Closed\":


                $colour .= \"red\";


        break;


}


$colour .= \";\'>\";

    $reportdata[\"tablevalues\"][] = array($id,$clientname,$colour . $status . \"</span>\",$datecreated);


}


$data[\"footertext\"]=\"<table width=90% align=center><tr><td>\";


if ($month==\"1\") {


    $data[\"footertext\"].=\"<a><< December \".($year-1).\"</a>\";


} else {


    $data[\"footertext\"].=\"<a><< \".$months[($month-2)].\" $year</a>\";


}


$data[\"footertext\"].=\"</td><td align=right>\";


if ($month==\"12\") {


    $data[\"footertext\"].=\"<a>January \".($year+1).\" >></a>\";


} else {


    $data[\"footertext\"].=\"<a>\".$months[(($month+1)-1)].\" $year >></a>\";


}


$data[\"footertext\"].=\"</td></tr></table>\";

?>

Espero que sirva pra alguém. :)

Link to comment
Share on other sites

Bom, vom começar com o pé direito e postar aqui uma dicazinha maneira que postei no meu fórum, no fórum WHMCS e no Hostdime.

Eu queria saber quantos novos clientes assinaram por mês, então eu criei um novo relatório que mostra o ID, nome, status e data de cadastro do cliente.

Clica aqui pra ver a imagem de como ficou (até eu aprender a postar imagem no fórum... rs): http://www.cybernetfx.com.br/images/newclients.gif

Abaixo o código. Salve o arquivo com o nome monthly_clients.php e envie para o diretório whmcs/modules/reports:

<?php

$months = array(\\\'January\\\',\\\'February\\\',\\\'March\\\',\\\'April\\\',\\\'May\\\',\\\'June\\\',\\\'July\\\',\\\'August\\\',\\\'September\\\',\\\'October\\\',\\\'November\\\',\\\'December\\\');

if ($month==\\\"\\\") {


    $month=date(\\\"m\\\");


    $year=date(\\\"Y\\\");


}

$pmonth = str_pad($month, 2, \\\"0\\\", STR_PAD_LEFT);  

$reportdata[\\\"title\\\"] = \\\"New Clients for \\\".$months[$month-1].\\\" \\\".$year;


$reportdata[\\\"description\\\"] = \\\"This report shows all new clients for a given month\\\";

$query = \\\"SELECT id,firstname,lastname,status,datecreated FROM tblclients WHERE datecreated LIKE \\\'$year-$pmonth%\\\' ORDER BY datecreated ASC\\\";


$result = mysql_query($query);


$num_rows = mysql_num_rows($result);

$reportdata[\\\"headertext\\\"] = \\\"Total New Clients: \\\" . $num_rows;

$reportdata[\\\"tableheadings\\\"] = array(\\\"ID\\\",\\\"Client Name\\\",\\\"Status\\\",\\\"Signup Date\\\");

while ($data = mysql_fetch_array($result)) {


    $id = $data[\\\"id\\\"];


    $clientname = \\\"<a>\\\" . $data[\\\"firstname\\\"].\\\" \\\".$data[\\\"lastname\\\"] . \\\"</a>\\\";


    $status = $data[\\\"status\\\"];


    $datecreated = $data[\\\"datecreated\\\"];


    $datecreated = fromMySQLDate($datecreated);


    $colour = \\\"<span style=\\\'color:\\\";


switch($status)


{


        case \\\"Active\\\":


                $colour .= \\\"blue\\\";


        break;


        case \\\"Inactive\\\":


                $colour .= \\\"lightgrey\\\";


        break;


        case \\\"Closed\\\":


                $colour .= \\\"red\\\";


        break;


}


$colour .= \\\";\\\'>\\\";

    $reportdata[\\\"tablevalues\\\"][] = array($id,$clientname,$colour . $status . \\\"</span>\\\",$datecreated);


}


$data[\\\"footertext\\\"]=\\\"<table width=90% align=center><tr><td>\\\";


if ($month==\\\"1\\\") {


    $data[\\\"footertext\\\"].=\\\"<a><< December \\\".($year-1).\\\"</a>\\\";


} else {


    $data[\\\"footertext\\\"].=\\\"<a><< \\\".$months[($month-2)].\\\" $year</a>\\\";


}


$data[\\\"footertext\\\"].=\\\"</td><td align=right>\\\";


if ($month==\\\"12\\\") {


    $data[\\\"footertext\\\"].=\\\"<a>January \\\".($year+1).\\\" >></a>\\\";


} else {


    $data[\\\"footertext\\\"].=\\\"<a>\\\".$months[(($month+1)-1)].\\\" $year >></a>\\\";


}


$data[\\\"footertext\\\"].=\\\"</td></tr></table>\\\";

?>

Espero que sirva pra alguém. :)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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

Important Information

Do you agree with our terms?