Patty Posted July 16, 2010 Author Share Posted July 16, 2010 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 More sharing options...
Patty Posted July 16, 2010 Share Posted July 16, 2010 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 More sharing options...
ricardolima Posted July 16, 2010 Share Posted July 16, 2010 Boa Dica. Obrigado Link to comment Share on other sites More sharing options...
menigma Posted August 15, 2010 Share Posted August 15, 2010 Valew teste aqui! Link to comment Share on other sites More sharing options...
Jordan Miguel Posted August 15, 2010 Share Posted August 15, 2010 Vlw patty =) Link to comment Share on other sites More sharing options...
MCelow Posted August 15, 2010 Share Posted August 15, 2010 vlw Patty pela dica! Já to usando :) Link to comment Share on other sites More sharing options...
Lperez Posted August 15, 2010 Share Posted August 15, 2010 Valeu Patty, boa contribuição! Link to comment Share on other sites More sharing options...
Demartini Posted October 5, 2010 Share Posted October 5, 2010 Obrigado pela dica Patty! o/ Abraço. Link to comment Share on other sites More sharing options...
Roots Posted October 6, 2010 Share Posted October 6, 2010 Eu precisava muito dessa solução, sucesso PATTY! Link to comment Share on other sites More sharing options...
Jefferson Posted November 11, 2010 Share Posted November 11, 2010 Perfeito! Obrigado, está de parabens. █ DDR Host - https://www.ddrhost.com.br █ Hospedagem de Sites, Revenda de Hospedagem, Servidores Virtuais, Registro de Domínios Link to comment Share on other sites More sharing options...
Recommended Posts