public function listproductosclientesAction($cliente_id) { $model = new Planpagos(); $resul = $model->lista($cliente_id); $this->view->disable(); foreach ($resul as $v) { $customers[] = array('id' => $v->id, 'grupo' => $v->grupo, 'razon_social' => $v->razon_social, 'linea' => $v->linea, 'estacion' => $v->estacion, 'producto' => '<a href="/planpagos/controlpago/' . $v->id . '">' . $v->producto . '</a>', 'contrato' => $v->contrato, 'fecha_contrato' => $v->fecha_contrato, 'fecha_inicio' => $v->fecha_inicio, 'fecha_fin' => $v->fecha_fin, 'total' => $v->total, 'deposito' => $v->deposito, 'cobrar' => $v->total - $v->deposito, 'mora' => $v->mora); } echo json_encode($customers); }
public function reporteAction() { $this->view->disable(); $model = new Planpagos(); $resul = $model->lista(); include_once 'tbs_us/tbs_class.php'; // Load the TinyButStrong template engine include_once 'tbs_us/tbs_plugin_opentbs/tbs_plugin_opentbs.php'; // Load the OpenTBS plugin $TBS = new clsTinyButStrong(); // new instance of TBS $TBS->Plugin(TBS_INSTALL, OPENTBS_PLUGIN); // load the OpenTBS plugin $TBS->VarRef['usuario'] = $this->_user->nombre . ' ' . $this->_user->paterno; $data = array(); $c = 1; foreach ($resul as $v) { $data[] = array('rank' => 'A', 'nro' => $c, 'grupo' => $v->grupo, 'linea' => $v->linea, 'estacion' => $v->estacion, 'razon_social' => $v->razon_social, 'contrato' => $v->contrato, 'fecha_contrato' => $v->fecha_contrato, 'producto' => $v->producto, 'fecha_inicio' => $v->fecha_inicio, 'fecha_fin' => $v->fecha_fin, 'total' => $v->total, 'deposito' => $v->deposito, 'cobrar' => $v->total - $v->deposito, 'mora' => number_format($v->mora, 2, '.', ',')); $c++; } $template = 'file/template/temp_reporte_contratos.xlsx'; $TBS->LoadTemplate($template, OPENTBS_ALREADY_UTF8); // Also merge some [onload] automatic fields (depends of the type of document). // ---------------------- // Debug mode of the demo // ---------------------- // if (isset($_POST['debug']) && ($_POST['debug']=='current')) $TBS->Plugin(OPENTBS_DEBUG_XML_CURRENT, true); // Display the intented XML of the current sub-file, and exit. // if (isset($_POST['debug']) && ($_POST['debug']=='info')) $TBS->Plugin(OPENTBS_DEBUG_INFO, true); // Display information about the document, and exit. // if (isset($_POST['debug']) && ($_POST['debug']=='show')) $TBS->Plugin(OPENTBS_DEBUG_XML_SHOW); // Tells TBS to display information when the document is merged. No exit. // Merge data in the first sheet $TBS->MergeBlock('a,b', $data); // ----------------- // Output the result // ----------------- // $output_file_name = str_replace('.', '_'.date('Y-m-d').'.', $template); $output_file_name = date('Y-m-d') . ' ' . 'reporte.xlsx'; $TBS->Show(OPENTBS_DOWNLOAD, $output_file_name); // Also merges all [onshow] automatic fields. exit; }