| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842 |
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- class FirmaController extends CI_Controller {
- public function __construct()
- {
- parent::__construct();
- //$this->load->model("FirmaModel");
- }
-
- /**
- * Index Page for this controller.
- *
- * Maps to the following URL
- * http://example.com/index.php/welcome
- * - or -
- * http://example.com/index.php/welcome/index
- * - or -
- * Since this controller is set as the default controller in
- * config/routes.php, it's displayed at http://example.com/
- *
- * So any other public methods not prefixed with an underscore will
- * map to /index.php/welcome/<method_name>
- * @see https://codeigniter.com/user_guide/general/urls.html
- */
- /** Comentario sobre data_file():
- * ESTA FUNCION REGRESA LA DIRECCION DEL ARCHIVO EXCEL QUE SE ESTÁ LEYENDO PARA GENERAR LAS FIRMAS
- */
- private function data_file(){
- return 'C:\xampp\htdocs\firmasCI\system_files\datos_firmas.xlsx';
- }
- public function index()
- {
- $File = $this->data_file();
- $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx');
- $spreadsheet= $reader->load($File);
- $sheet = $spreadsheet->getActiveSheet();
- $fila_maxima = $sheet->getHighestDataRow();
- #obteniendo headers
- $headers=[];
- foreach($sheet->getRowIterator(1,1) as $row){
- $cellIterator = $row->getCellIterator();
- $cellIterator->setIterateOnlyExistingCells(false);
- foreach($cellIterator as $cell){
- $headers[] = $cell->getCalculatedValue();
- }
- }
- #obteniendo datos de las personas
- $personal =[];
- foreach($sheet->getRowIterator(2,$fila_maxima) as $row){
- $cellIterator = $row->getCellIterator();
- $cellIterator->setIterateOnlyExistingCells(false);
- $i=0;
- $data=[];
- foreach($cellIterator as $cell){
- $data[$headers[$i]] = $cell->getCalculatedValue();
- $i++;
- }
- $personal[]=$data;
- }
-
- $data = ['headers'=>$headers,'personal'=>$personal];
- $this->load->view('lista',$data);
- }
- public function generarVistaPrevia($id){
- $persona = $this->consultarPersonal($id);
- if(isset($persona)){
- list($site,$type,$identifier) = explode("/",$persona['LinkedIn']);
- list($email_id,$email_domain) = explode("@",$persona['Correo']);
- $data=['persona'=>$persona,'site'=>$site,'type'=>$type,'identifier'=>$identifier,'email_id'=>$email_id,'email_domain'=>$email_domain];
-
- //llamada a la vista
- $this->load->view($persona['Plantilla'],$data);
- /*
- *
- *Todas las plantillas de firma en html se han llamado igual que como están en el excel
- *si desea cambiar el nombre de las plantillas debe descomentar el siguiente algoritmo y
- *extenderlo si es necesario.
- *
- if($persona['Plantilla']=='MER'){
- $this->load->view('MER',$data);
-
- }elseif($persona['Plantilla']=='INVER'){
- $this->load->view('INVER',$data);
-
- }elseif($persona['Plantilla']=='INVERSOL'){
- $this->load->view('INVERSOL',$data);
-
- }elseif($persona['Plantilla']=='METCO'){
- $this->load->view('METCO',$data);
-
-
- }else{
- print("NO ESTA ASIGNADO A NINGUNA PLANTILLA, REVISE LOS DATOS");
- }
- */
- }else{
- print("NO EXISTE EL ID ".$id." REGISTRADO EN LA HOJA DE EXCEL,POR FAVOR REVISE LOS DATOS");
- }
- }
- public function consultarPersonal($id){
- $File = 'C:\xampp\htdocs\firmasCI\system_files\datos_firmas.xlsx';
- $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx');
- $spreadsheet= $reader->load($File);
- $sheet = $spreadsheet->getActiveSheet();
- $fila_maxima = $sheet->getHighestDataRow();
- #obteniendo headers
- $headers=[];
- foreach($sheet->getRowIterator(1,1) as $row){
- $cellIterator = $row->getCellIterator();
- $cellIterator->setIterateOnlyExistingCells(false);
- foreach($cellIterator as $cell){
- $headers[] = $cell->getCalculatedValue();
- }
- }
- #obteniendo datos
- foreach($sheet->getRowIterator(2,$fila_maxima) as $row){
- $cellIterator = $row->getCellIterator();
- $cellIterator->setIterateOnlyExistingCells(false);
- $i=0;
- $data=[];
- foreach($cellIterator as $cell){
- $data[$headers[$i]] = $cell->getCalculatedValue();
- $i++;
- if($data['N']!=$id){
- break;
- }else{
- $persona=$data;
- }
- }
-
- if(isset($persona)){
- return $persona;
- }
-
- }
- return null;
- }
- /* Comentario sobre generarZIP($id):
- *ESTA FUNCION GENERA UN ZIP CON LOS ELEMENTOS DE CADA FIRMA
- *DESCARGA LAS IMAGENES, EL TIPO DE FUENTE Y LA VISTA EN HTML DE LA FIRMA.
- *EL CSS ESTÁ SIENDO INCRUSTADO EN LA VISTA, DENTRO DE LA FUNCIÓN generarHTML
- *LA FUNCION generarHTML GENERA LA VISTA DE LA FIRMA DE MODO QUE CONSUMA FUENTE E IMAGENES
- *DESDE UN SERVIDOR, POR LO TANTO DEBERÁ MODIFICARSE LA VISTA PARA QUE TRABAJE DE FORMA LOCAL
- *UNA VEZ LOS ARCHIVOS ESTÉN DESCARGADOS.
- */
- public function generarZIP($id){
- $persona = $this->consultarPersonal($id);
- if(isset($persona)){
- $persona_name = $persona['Primer Nombre']."_".$persona['Primer Apellido'];
- $file_name = $this->generarHTML($persona);
- $zip = new ZipArchive();
- $zip_name = $persona_name."_".$persona['Plantilla'].".zip";
- $zip->open($zip_name,ZipArchive::CREATE);
- $public_folder_dir = "C:/XAMPP/htdocs/firmasCI/public";
- $imagenes_folder = $public_folder_dir."/Imagenes";
- $css_folder = $public_folder_dir."/css";
- $tipograf_folder =$public_folder_dir."/Tipografias";
- $carpetas=[];
- $carpetas['Imagenes']=$imagenes_folder;
- //$carpetas['css']=$css_folder;
- $carpetas['Tipografias']=$tipograf_folder;
- $dir = 'public';
- $zip->addEmptyDir($dir);
- $zip->addFile($file_name,$persona_name.".html");
- foreach($carpetas as $key => $dir_folder){
- $curr_dest_folder=$dir."/".$key;
- $zip->addEmptyDir($curr_dest_folder);
- foreach(array_diff(scandir($dir_folder), array('..', '.','fichas_style.css')) as $file){
- $source_dir=$dir_folder."/".$file;
- $dest_folder=$curr_dest_folder."/".$file;
- $zip->addFile($source_dir,$dest_folder);
- }
- }
- $zip->close();
- // Creamos las cabezeras que forzaran la descarga del archivo como archivo zip.
- header("Content-type: application/octet-stream");
- header("Content-disposition: attachment; filename=".$zip_name);
- // leemos el archivo creado
- readfile($zip_name);
- // Por último eliminamos el archivo temporal creado
- unlink($zip_name);//Destruye el archivo temporal
- }else{
- print("NO EXISTE EL ID ".$id." REGISTRADO EN LA HOJA DE EXCEL,POR FAVOR REVISE LOS DATOS");
- }
- }
- /**
- * comentario sobre la funcion descargarHTML($id)
- */
- public function descargarHTML($id){
- $persona = $this->consultarPersonal($id);
- if(isset($persona)){
- $file_name = $this->generarHTML($persona);
- // Creamos las cabezeras que forzaran la descarga del archivo como archivo zip.
- header("Content-type: application/octet-stream");
- header("Content-disposition: attachment; filename=".$persona['Plantilla']."_".$persona['Nombre Completo'].".html");
- // leemos el archivo creado
- readfile($file_name);
- }else{
- print("ERROR AL CONSULTAR EL EXCEL, REVISE LOS DATOS");
- }
-
- }
- /**
- * comentario sobre generarHTML($persona):
- * ESTA FUNCION GENERA LAS VISTAS HTML PARA DESCARGAR, DE CADA FIRMA ELECTRONICA
- * NECESITA COMO PARAMETRO UNA PERSONA EN ESPECIFICO PARA LA QUE SE GENERARÁ LA VISTA
- * RETORNA LA UBICACION Y EL NOMBRE DEL ARCHIVO CREADO.
- * SE DA POR ALUDIDO QUE LAS IMAGENES Y FUENTE QUE CONSUME LA VISTA, SE ENCUENTRAN EN
- * UN SERVIDOR EN LINEA,LISTO PARA SERVIRLOS.
- */
- public function generarHTML($persona){
- $persona_name = $persona['Primer Nombre']."_".$persona['Primer Apellido'];
- $path='system_files/firmas_generadas/';
- $main_directory = $path.$persona['N']."_".$persona_name;
- $sub_directory = $main_directory."/".$persona['N']."_".$persona_name."_".date("d-m-Y_H_i_s");
- $file_name = $sub_directory."/".$persona_name.".html";
- if(!file_exists($main_directory)){
- mkdir($main_directory);
- }
- if(!file_exists($sub_directory)){
- mkdir($sub_directory);
- }
- list($site,$type,$identifier) = explode("/",$persona['LinkedIn']);
- list($email_id,$email_domain) = explode("@",$persona['Correo']);
- $firma = fopen($file_name,"a") or die("Error al crear el archivo");
-
- if($persona['Plantilla']=='MER'){
- $style ="
- @font-face{
- font-family:HelveticaNeueLTStd-Lt;
- src:url(../Tipografias/HelveticaNeueLTStd-Lt.otf);
- }
- font{
- font-family: Helvetica, sans-serif;
- }
-
- td{
- font-family: Helvetica, sans-serif;
- }
-
- .merelec_name_yellow{
- font-family: Helvetica, sans-serif;
- color: #FCB122;
- font-size: 14pt;
- font-weight: bold;
- }
-
- .merelec_name_gray{
- font-family: Helvetica, sans-serif;
- color: #80888F;
- font-size: 14pt;
- font-weight: bold;
- }
-
- .merelec_puesto{
- font-family: Helvetica, sans-serif;
- color: #80888F;
- font-size: 14pt;
- }
-
- .merelec_yellow_text{
- color: #FCB122;
- font-size: 12pt;
- font-weight: bold;
- }
-
- .merelec_gray_text{
- color: #80888F;
- font-size: 12pt;
- }
- ";
- $body = " <table>
- <tbody>
- <tr>
- <td colspan=\"2\">
- <span class=\"merelec_name_yellow\">".$persona['Primer Nombre']."</span> <span class=\"merelec_name_gray\">".$persona['Primer Apellido']."</span>
- <p style=\"margin-top:1%\"><span class=\"merelec_puesto\">".$persona['Puesto']."</span></p>
- </td>
- </tr>
- <tr height=\"10\"></tr>
- <tr>
- <td width=\"200\" style=\"border-right:2px solid #80888F;\">
- <img src=\"https://www.mercadoselectricos.com.sv/wp-content/uploads/2019/12/IMG_MER_Logo.png\" width=\"200\" height=\"83\">
- </td>
- <td width=\"900\" style=\"margin-left:2px;\">
- <table>
- <tbody>
- <tr align=\"left\">
- <td>
- <span style=\"color: #80888F\"><span class=\"merelec_yellow_text\">T.</span><span class=\"merelec_gray_text\">".$persona['Telefono']."</span>
- <span class=\"merelec_yellow_text\">C.</span><span class=\"merelec_gray_text\">".$persona['Celular']."</span></span>
- </td>
- </tr>
- <tr>
- <td>
- <a href=\"mailto:".$persona['Correo']."\"><span class=\"merelec_yellow_text\">".$email_id."</span><span class=\"merelec_gray_text\">@".$email_domain."</span></a>
- </td>
- </tr>
- <tr>
- <td>
- <a href=\"https://www.".$persona['LinkedIn']."\"> <span class=\"merelec_gray_text\">".$site."/".$type."/"."</span><span class=\"merelec_yellow_text\">".$identifier."</span></a>
- </td>
- </tr>
- <tr>
- <td>
- <table>
- <tr>
- <td>
- <a class=\"social_media\" href=\"https://www.linkedin.com/company/mercados-electricos-centroamerica/\">
- <img width=\"20\" height=\"20\" src=\"https://www.mercadoselectricos.com.sv/wp-content/uploads/2019/12/IMG_MER_Linkedin.png\">
- </a>
- </td>
- <td>
- <a class=\"social_media\" href=\"https://www.facebook.com/MercadosElectricosCentroamerica/\">
- <img width=\"20\" height=\"20\" src=\"https://www.mercadoselectricos.com.sv/wp-content/uploads/2019/12/IMG_MER_Facebook.png\">
- </a>
- </td>
- <td>
- <a class=\"social_media\" href=\"https://www.mercadoselectricos.com.sv\">
- <span class=\"merelec_gray_text\">www.</span><span class=\"merelec_yellow_text\">mercadoselectricos</span><span class=\"merelec_gray_text\">.com.sv</span>
- </a>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </tbody>
- </table>
- </td>
- </tr>
- </tbody>
- </table>
- </body>
- </html>";
-
- }elseif($persona['Plantilla']=='INVER'){
- $style = "@font-face{
- font-family:HelveticaNeueLTStd-Lt;
- src:url(../Tipografias/HelveticaNeueLTStd-Lt.otf);
- }
-
- .inverlec_name_blue{
- font-family: Helvetica, sans-serif;
- color: #00ABE7;
- font-size: 16px;
- font-weight:bold;
- }
- .inverlec_name_black{
- font-family: Helvetica, sans-serif;
- color: black;
- font-size: 16px;
- font-weight:bold;
- }
- .inverlec_puesto{
- font-family: Helvetica, sans-serif;
- color: black;
- font-size: 16px;
- }
- td{
- font-family: Helvetica, sans-serif;
- }
-
- .inverlec_blue_text{
- color: #00ABE7;
- font-family: Helvetica, sans-serif;
- font-size: 15px;
- font-weight:bold;
- }
-
- .inverlec_black_text{
- color: black;
- font-family: Helvetica, sans-serif;
- font-size: 15px;
- }
- ";
- $body="<table>
- <tbody>
- <tr>
- <td colspan=\"2\">
- <span class=\"inverlec_name_blue\">".$persona['Primer Nombre']."</span> <span class=\"inverlec_name_black\">".$persona['Primer Apellido']."</span>
- <p style=\"margin-top:1%\"><span class=\"inverlec_puesto\">".$persona['Puesto']."</span></p>
- </td>
- </tr>
- <tr height=\"10\"></tr>
- <tr>
- <td width=\"160\" style=\"border-right:2px solid #00ABE7;\">
- <img src=\"https://www.mercadoselectricos.com.sv/wp-content/uploads/2019/12/IMG_INVER_Logo.png\" width=\"160\" height=\"90\">
- </td>
- <td width=\"900\" style=\"margin-left:2px;\" >
- <table>
- <tbody>
- <tr align=\"left\">
- <td>
- <span style=\"color: #80888F\"><span class=\"inverlec_blue_text\">T.</span><span class=\"inverlec_black_text\">".$persona['Telefono']."</span>
- <span class=\"inverlec_blue_text\">C.</span><span class=\"inverlec_black_text\">".$persona['Celular']."</span></span>
- </td>
- </tr>
- <tr>
- <td>
- <a href=\"mailto:".$persona['Correo']."\"><span class=\"inverlec_blue_text\">".$email_id."</span><span class=\"inverlec_black_text\">@".$email_domain."</span></a>
- </td>
- </tr>
- <tr>
- <td>
- <a href=\"https://www.".$persona['LinkedIn']."\"> <span class=\"inverlec_black_text\">".$site."/".$type."/"."</span><span class=\"inverlec_blue_text\">".$identifier."</span></a>
- </td>
- </tr>
- <tr>
- <td>
- <table>
- <tr>
- <td>
- <a class=\"social_media\" href=\"https://www.linkedin.com/company/inverlecsv/\">
- <img width=\"20\" height=\"20\" src=\"https://www.mercadoselectricos.com.sv/wp-content/uploads/2019/12/IMG_INVER_Linkedin.png\">
- </a>
- </td>
- <td>
- <a class=\"social_media\" href=\"https://www.facebook.com/Inverlecsv/\">
- <img width=\"20\" height=\"20\" src=\"https://www.mercadoselectricos.com.sv/wp-content/uploads/2019/12/IMG_INVER_Facebook.png\">
- </a>
- </td>
- <td>
- <a class=\"social_media\" href=\"https://www.inverlec.com.sv\">
- <span class=\"inverlec_black_text\">www.</span><span class=\"inverlec_blue_text\">inverlec</span><span class=\"inverlec_black_text\">.com.sv</span>
- </a>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </tbody>
- </table>
- </td>
- </tr>
- </tbody>
- </table>
- </body>
- </html>
- ";
- }elseif($persona['Plantilla']=='INVERSOL'){
- $style = "
- @font-face{
- font-family:HelveticaNeueLTStd-Lt;
- src:url(../Tipografias/HelveticaNeueLTStd-Lt.otf);
- }
- .inversol_name_yellow{
- font-family: Helvetica, sans-serif;
- color: #F78D27;
- font-size: 16px;
- font-weight: bold;
- }
- .inversol_name_black{
- font-family: Helvetica, sans-serif;
- color: black;
- font-size: 16px;
- font-weight: bold;
- }
- .inversol_puesto{
- font-family: Helvetica, sans-serif;
- color: black;
- font-size: 16px;
- }
- td{
- font-family: Helvetica, sans-serif;
- }
-
- .inversol_yellow_text{
- color: #F78D27;
- font-family: Helvetica, sans-serif;
- font-size: 15px;
- font-weight: bold;
- }
-
- .inversol_black_text{
- color: black;
- font-family: Helvetica, sans-serif;
- font-size: 15px;
- }
- ";
-
- $body = "<table>
- <tbody>
- <tr>
- <td colspan=\"2\">
- <span class=\"inversol_name_yellow\">".$persona['Primer Nombre']."</span> <span class=\"inversol_name_black\">".$persona['Primer Apellido']."</span>
- <p style=\"margin-top:1%\"><span class=\"inversol_puesto\">".$persona['Puesto']."</span></p>
- </td>
- </tr>
- <tr height=\"10\"></tr>
- <tr>
- <td width=\"160\" style=\"border-right:2px solid #FBAB20;\">
- <img src=\"https://www.mercadoselectricos.com.sv/wp-content/uploads/2019/12/IMG_INVERSOL_Logo.png\" width=\"160\" height=\"100\">
- </td>
- <td width=\"900\" style=\"margin-left:2px;\">
- <table>
- <tbody>
- <tr align=\"left\">
- <td>
- <span style=\"color: #80888F\"><span class=\"inversol_yellow_text\">T.</span><span class=\"inversol_black_text\">".$persona['Telefono']."</span>
- <span class=\"inversol_yellow_text\">C.</span><span class=\"inversol_black_text\">".$persona['Celular']."</span></span>
- </td>
- </tr>
- <tr>
- <td>
- <a href=\"mailto:".$persona['Correo']."\"><span class=\"inversol_yellow_text\">".$email_id."</span><span class=\"inversol_black_text\">@".$email_domain."</span></a>
- </td>
- </tr>
- <tr>
- <td>
- <a href=\"https://www.".$persona['LinkedIn']."\"> <span class=\"inversol_black_text\">".$site."/".$type."/"."</span><span class=\"inversol_yellow_text\">".$identifier."</span></a>
- </td>
- </tr>
- <tr>
- <td>
- <table>
- <tr>
- <td>
- <a class=\"social_media\" href=\"https://www.linkedin.com/company/inverlecsolar/\">
- <img width=\"20\" height=\"20\" src=\"https://www.mercadoselectricos.com.sv/wp-content/uploads/2019/12/IMG_INVERSOL_Linkedin.png\">
- </a>
- </td>
- <td>
- <a class=\"social_media\" href=\"https://www.facebook.com/inverlec/\">
- <img width=\"20\" height=\"20\" src=\"https://www.mercadoselectricos.com.sv/wp-content/uploads/2019/12/IMG_INVERSOL_Facebook.png\">
- </a>
- </td>
- <td>
- <a class=\"social_media\" href=\"https://www.inverlec.solar\">
- <span class=\"inversol_black_text\">www.</span><span class=\"inversol_yellow_text\">inverlec</span><span class=\"inversol_black_text\">.solar</span>
- </a>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </tbody>
- </table>
- </td>
- </tr>
- </tbody>
- </table>
- </body>
- </html>
- ";
- }elseif($persona['Plantilla']=='METCO'){
- $style = "@font-face{
- font-family:HelveticaNeueLTStd-Lt;
- src:url(../Tipografias/HelveticaNeueLTStd-Lt.ttf);
- }
-
- @font-face{
- font-family:VAGRoundedStd-Light;
- src:url(../Tipografias/VAGRoundedStd-Light.otf);
- }
- .metco_name_yellow{
- font-family: Helvetica, sans-serif;
- color: #DE8C33;
- font-size: 15pt;
- font-weight: bold;
- }
-
- .metco_name_black{
- font-family: Helvetica, sans-serif;
- color: black;
- font-size: 15pt;
- font-weight: bold;
- }
-
- .metco_puesto{
- font-family: Helvetica, sans-serif;
- color: black;
- font-size: 15pt;
- }
-
- td{
- font-family: HelveticaNeueLTStd-Lt;
- }
- .metco_yellow_text{
- color: #DE8C33;
- font-size: 11pt;
- font-family: Helvetica, sans-serif;
- font-weight: bold;
- }
-
- .metco_gray_text{
- color: black;
- font-size: 11pt;
- font-family: Helvetica, sans-serif;
- }
- ";
- $body =" <table>
- <tbody>
- <tr>
- <td colspan=\"2\">
- <span class=\"metco_name_yellow\">".$persona['Primer Nombre']."</span> <span class=\"metco_name_black\">".$persona['Primer Apellido']."</span>
- <p style=\"margin-top:1%\"><span class=\"metco_puesto\">".$persona['Puesto']."</span></p>
- </td>
- </tr>
- <tr height=\"10\"></tr>
- <tr>
- <td width=\"200\" style=\"border-right:2px solid #DE8C33;\">
- <img src=\"https://www.mercadoselectricos.com.sv/wp-content/uploads/2019/12/IMG_METCO_Logo.png\" width=\"200\" height=\"80\">
- </td>
- <td width=\"900\" style=\"margin-left:2px;\">
- <table>
- <tbody>
- <tr align=\"left\">
- <td>
- <span style=\"color: #80888F\"><span class=\"metco_yellow_text\">T.</span><span class=\"metco_gray_text\">".$persona['Telefono']."</span>
- <span class=\"metco_yellow_text\">C.</span><span class=\"metco_gray_text\">".$persona['Celular']."</span></span>
- </td>
- </tr>
- <tr>
- <td>
- <a href=\"mailto:".$persona['Correo']."\"><span class=\"metco_yellow_text\">".$email_id."</span><span class=\"metco_gray_text\">@".$email_domain."</span></a>
- </td>
- </tr>
- <tr>
- <td>
- <a href=\"https://www.".$persona['LinkedIn']."\"> <span class=\"metco_gray_text\">".$site."/".$type."/"."</span><span class=\"metco_yellow_text\">".$identifier."</span></a>
- </td>
- </tr>
- <tr>
- <td>
- <table>
- <tr>
- <td>
- <a class=\"social_media\" href=\"https://www.linkedin.com/company/mexicanenergytradingco/\">
- <img width=\"20\" height=\"20\" src=\"https://www.mercadoselectricos.com.sv/wp-content/uploads/2019/12/IMG_METCO_Logo-02.png\">
- </a>
- </td>
- <td>
- <a class=\"social_media\" href=\"https://www.facebook.com/MexicanEnergyTradingCo/\">
- <img width=\"20\" height=\"20\" src=\"https://www.mercadoselectricos.com.sv/wp-content/uploads/2019/12/IMG_METCO_Logo-03.png\">
- </a>
- </td>
- <td>
- <a class=\"social_media\" href=\"http://www.mexicantradingco.com.mx\">
- <span class=\"metco_gray_text\">www.</span><span class=\"metco_yellow_text\">mexicantradingco</span><span class=\"metco_gray_text\">.com.mx</span>
- </a>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </tbody>
- </table>
- </td>
- </tr>
- </tbody>
- </table>
- </body>
- </html>
- ";
- }else{
- $body = "";
- print("NO ESTA ASIGNADO A NINGUNA PLANTILLA, REVISE LOS DATOS");
- }
- $general_style ="
- a {
- text-decoration: none;
- display:table-cell;
- vertical-align:middle;
- }
- .social_media{
- padding-right:4px;
- }
- ";
-
- $html_header ="<html>
- <head>
- </head>
- <body>
- <style> "." ".$style.$general_style."
- </style>";
- fwrite($firma,$html_header.$body);
- return $file_name;
-
- }
- /**
- * comentario sobre generarTodas():
- * ESTA FUNCION GENERA TODAS LAS FIRMAS EN HTML Y LAS AGREGA A UN ARCHIVO ZIP
- * SE DA POR ALUDIDO QUE LAS IMAGENES Y FUENTE QUE CONSUME CADA VISTA, SE ENCUENTRAN EN
- * UN SERVIDOR EN LINEA,LISTO PARA SERVIRLOS.
- */
- public function generarTodas(){
- $File = $this->data_file();
- $reader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader('Xlsx');
- $spreadsheet= $reader->load($File);
- $sheet = $spreadsheet->getActiveSheet();
- $fila_maxima = $sheet->getHighestDataRow();
- #obteniendo headers
- $headers=[];
- foreach($sheet->getRowIterator(1,1) as $row){
- $cellIterator = $row->getCellIterator();
- $cellIterator->setIterateOnlyExistingCells(false);
- foreach($cellIterator as $cell){
- $headers[] = $cell->getCalculatedValue();
- }
- }
- #obteniendo datos de las personas
- $file_names=[];
- $file_dirs=[];
- foreach($sheet->getRowIterator(2,$fila_maxima) as $row){
- $cellIterator = $row->getCellIterator();
- $cellIterator->setIterateOnlyExistingCells(false);
- $i=0;
- $persona=[];
- foreach($cellIterator as $cell){
- $persona[$headers[$i]] = $cell->getCalculatedValue();
- $i++;
- }
- $file_names[]=$persona['Plantilla']."_".$persona['Nombre Completo'].".html";
- $file_dirs[]=$this->generarHTML($persona);
- }
- $i=0;
- $zip = new ZipArchive();
- $zip_name = "paquete_firmas.zip";
- $zip->open($zip_name,ZipArchive::CREATE);
- foreach($file_dirs as $file){
- $zip->addFile($file,$file_names[$i]);
- $i++;
- }
- $zip->close();
- // Creamos las cabezeras que forzaran la descarga del archivo como archivo zip.
- header("Content-type: application/octet-stream");
- header("Content-disposition: attachment; filename=".$zip_name);
- // leemos el archivo creado
- readfile($zip_name);
- // Por último eliminamos el archivo temporal creado
- unlink($zip_name);//Destruye el archivo temporal
- }
- /*
- *método para guardar en una base de datos
- public function guardar()
- {
- if ($_POST){
- $this->FirmaModel->guardar($_POST);
- $ruta = base_url();
- echo "<script>
- window.location = '{$ruta}';
- </script>";
- }
- }*/
- }
|