Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- | -------------------------------------------------------------------------------------------
- | Below functions to generate item reports
- | ------------------------------------------------------------------------------------------
- |
- */
- function generateHeader(){
- $data = date('j/m/Y');
- $retorno = "<table class=\"tbl_header\" width=\"1000\">
- <tr>
- <td align=\"left\">Relatório de Clientes</td>
- <td align=\"right\">Gerado em: $data</td>
- </tr>
- </table>";
- return $retorno;
- }
- function generateFooter(){
- $retorno = "<table class=\"tbl_footer\" width=\"1000\">
- <tr>
- <td align=\"left\">Petit Fru Fru Mimos de Luxo</td>
- <td align=\"right\">Página: {PAGENO}</td>
- </tr>
- </table>";
- return $retorno;
- }
- function generateTable( $data = array() )
- {
- $CI =& get_instance();
- $color = false;
- $retorno = "";
- $retorno .= "<h2 style=\"text-align:center\">Relatório Orçamento Clientes</h2>";
- $retorno .= "<table border='0' width='1000' align='center'> ";
- foreach ( dataClient( $data ) as $c) :
- $retorno .= "<tr>
- <td> </td>
- <td> </td>
- <td> </td>
- <td> </td>
- <td> </td>
- </tr>
- <tr>
- <td> </td>
- <td> </td>
- <td> </td>
- <td> </td>
- <td> </td>
- </tr>
- <tr class='header'>
- <th>Código do Cliente</td>
- <th>Nome do Cliente</td>
- <th>Nome do Aniversariante</td>
- <th>Idade do Aniversariante</td>
- <th>Data do Evento</td>
- </tr>";
- $retorno .= ($color) ? "<tr>" : "<tr class=\"zebra\">";
- $retorno .= "<td>{$c->budgets_code_customer}</td>";
- $retorno .= "<td>{$c->budgets_name_customer}</td>";
- $retorno .= "<td>{$c->budgets_name_birthday_person}</td>";
- $retorno .= "<td>{$c->budgets_age_customers}</td>";
- $retorno .= "<td>" . dateBr($c->budgets_date_event) . "</td>";
- $retorno .= "<tr class='header'>
- <th>Código do Produto</td>
- <th>Descrição do Produto</td>
- <th>Quantidade</td>
- <th>Observação</td>
- <th> </td>
- </tr>";
- foreach ( dataProducts( $data, $c->budgets_id_customer ) as $r) :
- $retorno .= ($color) ? "<tr>" : "<tr class=\"zebra\">";
- $retorno .= "<td>{$r->budgets_item_code_product}</td>";
- $retorno .= "<td>{$r->budgets_item_name_product}</td>";
- $retorno .= "<td>{$r->budgets_item_quantity}</td>";
- $retorno .= "<td>{$r->budgets_item_observation}</td>";
- $retorno .= "<tr>";
- $color = !$color;
- endforeach;
- $color = !$color;
- endforeach;
- $retorno .= "</table>";
- return $retorno;
- }
- function dataClient( $data = array() )
- {
- $CI =& get_instance();
- return $CI->db->select( '*' )->from( 'tb_budgets' )
- ->where( 'budgets_code_customer BETWEEN "'. $data['code_start'] . '" AND "' . $data['code_end'] . '"')
- ->where( 'budgets_date_event BETWEEN "'. $data['date_start'] . '" AND "' . $data['date_end'] . '"')
- ->get()->result();
- }
- function dataProducts( $data = array(), $idClient )
- {
- $CI =& get_instance();
- return $CI->db->select( '*' )->from( 'tb_budgets_itens' )
- ->where( 'budgets_item_code_customer BETWEEN "'. $data['code_start'] . '" AND "' . $data['code_end'] . '"')
- ->where( 'budgets_item_id_customer = "'. $idClient . '"' )
- ->get()->result();
- }
- function generateReports( $data = array() )
- {
- require_once DIR_VENDOR;
- $mpdf = new \Mpdf\Mpdf(['debug' => 'true']);
- $stylesheet = file_get_contents( DIR_CSS );
- $mpdf->WriteHTML($stylesheet,1);
- $mpdf->SetHTMLHeader( generateHeader() );
- $mpdf->SetHTMLFooter( generateFooter() );
- $mpdf->WriteHTML( generateTable( $data ) );
- $mpdf->Output( 'teste de relatorio', 'I');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement