Esempio n. 1
0
 /**
  * Persite um upload de imagem
  * @param type $path
  * @param type $file
  * @param type $menu_id
  * @param type $relacionamento_id
  * @param type $destaque
  * @return boolean
  */
 public static function addUploadImagem($path, $file, $menu_id, $relacionamento_id, $destaque = 0)
 {
     try {
         UtilString::CreatePathPermission($path);
         $upload = new UploadFiles();
         $upload->upload($path, $file);
         $sql = " INSERT INTO imagem(menu_id, relacionamento_id, titulo, nome_img, nome_thumb, destaque) ";
         $sql .= " VALUES(" . $menu_id . "," . $relacionamento_id . ",";
         $sql .= " NULL,";
         $sql .= "'" . $upload->getNameFile() . "','" . $upload->getNameFile() . "','" . $destaque . "'";
         $sql .= ")";
         if (DBSql::getExecute($sql) === false) {
             throw new Exception();
         }
         return true;
     } catch (Exception $e) {
         return false;
     }
 }
Esempio n. 2
0
 /**
  * Modifica la informacion de una sucursal de una empresa, o la info de una empresa
  * sin sucursales
  */
 public function updateEmpresa()
 {
     $info = $this->getInfoEmpresa($_GET['id']);
     $path_img = isset($info['info']->logo) ? $info['info']->logo : '';
     //valida la imagen
     $upload_res = UploadFiles::uploadEmpresaLogo();
     if (is_array($upload_res)) {
         if ($upload_res[0] == false) {
             return array(false, $upload_res[1]);
         }
         if ($path_img != '') {
             UploadFiles::deleteFile($path_img);
         }
         $path_img = APPPATH . 'images/empresas/' . $upload_res[1]['file_name'];
     }
     $data = array('nombre_fiscal' => $this->input->post('dnombre_fiscal'), 'calle' => $this->input->post('dcalle'), 'no_exterior' => $this->input->post('dno_exterior'), 'no_interior' => $this->input->post('dno_interior'), 'colonia' => $this->input->post('dcolonia'), 'localidad' => $this->input->post('dlocalidad'), 'municipio' => $this->input->post('dmunicipio'), 'estado' => $this->input->post('destado'), 'cp' => $this->input->post('dcp'), 'rfc' => $this->input->post('drfc'), 'telefono' => $this->input->post('dtelefono'), 'celular' => $this->input->post('dcelular'), 'email' => $this->input->post('demail'), 'pag_web' => $this->input->post('dpag_web'), 'logo' => $path_img, 'regimen_fiscal' => $this->input->post('dregimen_fiscal'));
     $this->db->update('empresas', $data, "id_empresa = '" . $_GET['id'] . "'");
     return array(true, '', 4);
 }
Esempio n. 3
0
 /**
  * Modifica la informacion de un cliente
  */
 public function updateConfig($id_conf, $data = null, $data_ext = null)
 {
     $msg = 4;
     if ($data == null) {
         $path_img = '';
         //valida la imagen
         $upload_res = UploadFiles::uploadImgLogo();
         if (is_array($upload_res)) {
             if ($upload_res[0] == false) {
                 return array(false, $upload_res[1]);
             }
             $path_img = 'application/images/logos/' . $upload_res[1]['file_name'];
         }
         $data = array('nombre' => $this->input->post('dnombre'), 'razon_social' => $this->input->post('drazon_social'), 'rfc' => $this->input->post('drfc'), 'calle' => $this->input->post('dcalle'), 'num_ext' => $this->input->post('dno_exterior'), 'num_int' => $this->input->post('dno_interior'), 'colonia' => $this->input->post('dcolonia'), 'municipio' => $this->input->post('dmunicipio'), 'estado' => $this->input->post('destado'), 'cp' => $this->input->post('dcp'), 'telefono' => $this->input->post('dtelefono'), 'url_logop' => $this->input->post('durl_logop') == 'true' ? 'true' : 'false', 'email' => $this->input->post('demail'), 'pag_web' => $this->input->post('dpag_web'), 'footer' => $this->input->post('dfooter'), 'color_1' => $this->input->post('dcolor_1'), 'color_2' => $this->input->post('dcolor_2'), 'fuente_pv' => $this->input->post('dfuente_pv'));
         $dataEmpresas = array('nombre_fiscal' => $this->input->post('drazon_social'), 'rfc' => $this->input->post('drfc'), 'calle' => $this->input->post('dcalle'), 'no_exterior' => $this->input->post('dno_exterior'), 'no_interior' => $this->input->post('dno_interior'), 'colonia' => $this->input->post('dcolonia'), 'localidad' => $this->input->post('dmunicipio'), 'municipio' => $this->input->post('dmunicipio'), 'estado' => $this->input->post('destado'), 'cp' => $this->input->post('dcp'), 'telefono' => $this->input->post('dtelefono'), 'email' => $this->input->post('demail'), 'pass' => $this->input->post('dpass'), 'pag_web' => $this->input->post('dpag_web'));
         if ($path_img != '') {
             $data['url_logo'] = $path_img;
             $dataEmpresas['logo'] = $path_img;
         }
     }
     $this->db->update('config', $data, "id = '" . $id_conf . "'");
     $select = $this->db->query("select * from empresas limit 1");
     $info['info'] = $select->row();
     //certificado
     $dcer_org = isset($info['info']->cer_org) ? $info['info']->cer_org : '';
     $dcer = isset($info['info']->cer) ? $info['info']->cer : '';
     $cer_caduca = isset($info['info']->cer_caduca) ? $info['info']->cer_caduca : '';
     $upload_res = UploadFiles::uploadFile('dcer_org');
     if ($upload_res !== false && $upload_res !== 'ok') {
         if ($dcer_org != '' && strpos($dcer_org, $upload_res) === false) {
             UploadFiles::deleteFile($dcer_org);
             UploadFiles::deleteFile($dcer);
         }
         $upload_res = json_decode(file_get_contents(base_url("openssl/bin/cer.php?file={$upload_res}&path=" . APPPATH . "CFDI/certificados/")));
         if ($upload_res[0] == '' || $upload_res[1] == '') {
             return array(false, '', 2);
         }
         $dcer_org = $upload_res[0];
         $dcer = $upload_res[1];
         //se obtiene la fecha que caduca el certificado
         $this->load->library('cfdi');
         $cer_caduca = $this->cfdi->obtenFechaCertificado($dcer_org);
     }
     //llave
     $new_pass = $this->pass_finkok;
     $dkey_path = isset($info['info']->key_path) ? $info['info']->key_path : '';
     $upload_res = UploadFiles::uploadFile('dkey_path');
     if ($upload_res !== false && $upload_res !== 'ok') {
         if ($dkey_path != '' && strpos($dkey_path, $upload_res) === false) {
             UploadFiles::deleteFile($dkey_path);
         }
         $upload_res = json_decode(file_get_contents(base_url("openssl/bin/key.php?newpass={$new_pass}&pass={$this->input->post('dpass')}&file={$upload_res}&path=" . APPPATH . "CFDI/certificados/")));
         print_r($upload_res);
         if ($upload_res[0] == 's' || $upload_res[0] == '') {
             return array(false, '', 2);
         }
         $dkey_path = $upload_res[0];
         $_POST['dpass'] = $new_pass;
     }
     print_r($dkey_path);
     $_POST['dpass'] = $new_pass;
     $dataEmpresas['cer_org'] = $dcer_org;
     $dataEmpresas['cer'] = $dcer;
     $dataEmpresas['key_path'] = $dkey_path;
     $dataEmpresas['pass'] = $_POST['dpass'];
     $this->db->update('empresas', $dataEmpresas);
     return array(true, '', $msg);
 }
 /**
  * Modifica la informacion de un serie/folio
  * @param unknown_type $id_serie_folio
  */
 public function editSerieFolio($id_serie_folio = '')
 {
     $id_serie_folio = $id_serie_folio != '' ? $id_serie_folio : $this->input->get('id');
     $path_img = '';
     //valida la imagen
     $upload_res = UploadFiles::uploadImgSerieFolio();
     if (is_array($upload_res)) {
         if ($upload_res[0] == false) {
             return array(false, $upload_res[1]);
         }
         $path_img = $upload_res[1]['file_name'];
         //APPPATH.'images/series_folios/'.$upload_res[1]['file_name'];
         /*$old_img = $this->db->select('imagen')->from('facturas_series_folios')->where('id_serie_folio',$id_serie_folio)->get()->row()->imagen;
         
         			UploadFiles::deleteFile($old_img);*/
     }
     $data = array('id_empresa' => $this->input->post('fid_empresa'), 'serie' => strtoupper($this->input->post('fserie')), 'no_aprobacion' => $this->input->post('fno_aprobacion'), 'folio_inicio' => $this->input->post('ffolio_inicio'), 'folio_fin' => $this->input->post('ffolio_fin'), 'ano_aprobacion' => $this->input->post('fano_aprobacion'));
     if ($path_img != '') {
         $data['imagen'] = $path_img;
     }
     if ($this->input->post('fleyenda') != '') {
         $data['leyenda'] = $this->input->post('fleyenda');
     }
     if ($this->input->post('fleyenda1') != '') {
         $data['leyenda1'] = $this->input->post('fleyenda1');
     }
     if ($this->input->post('fleyenda2') != '') {
         $data['leyenda2'] = $this->input->post('fleyenda2');
     }
     $this->db->update('facturas_series_folios', $data, array('id_serie_folio' => $id_serie_folio));
     return array(true);
 }
Esempio n. 5
0
 /**
  * Modifica la info de un empleado a la bd
  */
 public function updateEmpleado()
 {
     $empleado = $this->getInfoEmpleado($_GET['id'], true);
     if (is_array($empleado)) {
         $path_img = '';
         //valida la imagen
         $upload_res = UploadFiles::uploadImgEmpleado();
         if (is_array($upload_res)) {
             if ($upload_res[0] == false) {
                 return array(false, $upload_res[1]);
             }
             $path_img = APPPATH . 'images/empleados/' . $upload_res[1]['file_name'];
             UploadFiles::deleteFile($empleado['info']->url_img);
         } else {
             $path_img = $empleado['info']->url_img;
         }
         $data = array('nombre' => $this->input->post('dnombre'), 'apellido_paterno' => $this->input->post('dapellido_paterno'), 'apellido_materno' => $this->input->post('dapellido_materno'), 'url_img' => $path_img, 'calle' => $this->input->post('dcalle'), 'numero' => $this->input->post('dnumero'), 'colonia' => $this->input->post('dcolonia'), 'municipio' => $this->input->post('dmunicipio'), 'estado' => $this->input->post('destado'), 'cp' => $this->input->post('dcp'), 'telefono' => $this->input->post('dtelefono'), 'celular' => $this->input->post('dcelular'), 'email' => $this->input->post('demail'), 'fecha_nacimiento' => $this->input->post('dfecha_nacimiento') != '' ? $this->input->post('dfecha_nacimiento') : NULL, 'fecha_entrada' => $this->input->post('dfecha_entrada') == '' ? date("Y-m-d") : $this->input->post('dfecha_entrada'), 'fecha_salida' => $this->input->post('dfecha_salida') != '' ? $this->input->post('dfecha_salida') : NULL, 'salario' => $this->input->post('dsalario'), 'hora_entrada' => $this->input->post('dhora_entrada'), 'tipo_usuario' => $this->input->post('dtipo_usuario'), 'status' => $this->input->post('dstatus'));
         if ($this->input->post('dusuario') != '') {
             $data['usuario'] = $this->input->post('dusuario');
         }
         if ($this->input->post('dpassword') != '') {
             $data['password'] = $this->input->post('dpassword');
         }
         $this->db->update('empleados', $data, "id_empleado = '" . $_GET['id'] . "'");
         //Privilegios
         if (isset($_POST['dprivilegios']) && isset($_POST['dmod_privilegios'][0])) {
             $this->db->delete('empleados_privilegios', "id_empleado = '" . $_GET['id'] . "'");
             $data_priv = array();
             foreach ($_POST['dprivilegios'] as $priv) {
                 $data_priv[] = array('id_empleado' => $_GET['id'], 'id_privilegio' => $priv);
             }
             if (count($data_priv) > 0) {
                 $this->db->insert_batch('empleados_privilegios', $data_priv);
             }
         }
     }
     return array(true, '');
 }
Esempio n. 6
0
<?php

require "/clases/AutoCarga.php";
$tarjeta = Request::post("id_us");
$dni = Request::post("dni");
$sesion = new Session();
$paciente = new Paciente();
$paciente->setTarjetasanitaria($tarjeta);
$paciente->setDni($dni);
$sesion->setUser($paciente);
$files = new UploadFiles("imagen", "../../../Pacientes/{$tarjeta}/");
// Creamos el objeto upload
if ($files == null) {
    $sesion->sendRedirect("sas.html");
}
if (!is_dir("../../../Pacientes/{$tarjeta}/")) {
    mkdir("../../../Pacientes/{$tarjeta}/", 0777, true);
}
$files->upload();
$sesion->set("exitosos", $files->getSubidosExitosos());
$sesion->set("intentos", count($files->getArray()));
$sesion->sendRedirect("galeriapaciente.php");
Esempio n. 7
0
 /**
  * Agrega un familia a la bd
  */
 public function addFamilia($data = null, $data_cons = null)
 {
     if ($data == null) {
         $path_img = '';
         //valida la imagen
         $upload_res = UploadFiles::uploadImgFamilia();
         if (is_array($upload_res)) {
             if ($upload_res[0] == false) {
                 return array(false, $upload_res[1]);
             }
             $path_img = $upload_res[1]['file_name'];
             //APPPATH.'images/series_folios/'.$upload_res[1]['file_name'];
         }
         $color1 = $this->input->post('dcolor') != '' ? $this->input->post('dcolor') : '#ffffff';
         $color2 = hexdec(str_replace('#', '', $this->input->post('dcolor')));
         if ($this->input->post('dcolor_plano') != 'si') {
             $color2 += 90;
         }
         $data = array('id_padre' => $this->input->post('dfpadre'), 'nombre' => $this->input->post('dnombre'), 'precio_venta' => $this->input->post('dprecio_venta'), 'codigo_barra' => $this->input->post('dcodigo') != '' ? $this->input->post('dcodigo') : NULL, 'imagen' => $path_img, 'color1' => $color1, 'color2' => '#' . dechex($color2));
         if (isset($_POST['dcon_iva'])) {
             $data['con_iva'] = '1';
         }
         if (isset($_POST['dpreparado'])) {
             $data['preparado'] = '1';
         }
     }
     if ($data_cons == null) {
         $data_cons = array('ids' => $this->input->post('dpcids'), 'cantidads' => $this->input->post('dpccantidad'));
     }
     $this->db->insert('productos_familias', $data);
     $id_familia = $this->db->insert_id();
     //Productos que consume
     $tiene_productos = false;
     if (is_array($data_cons['ids'])) {
         $data_consumos = array();
         foreach ($data_cons['ids'] as $key => $idp) {
             $data_consumos[] = array('familia_id' => $id_familia, 'base_id' => $idp, 'cantidad' => $data_cons['cantidads'][$key]);
         }
         if (count($data_consumos) > 0) {
             $this->db->insert_batch('productos_base_familia', $data_consumos);
             $tiene_productos = true;
         }
     }
     // //si no tiene productos base lo pone como si no fuera el ultimo nodo
     // if($tiene_productos==false)
     // 	$this->updateFamilia($id_familia, array('ultimo_nodo' => '0'), null, false);
     //ya no es ultimo nodo el padre
     $this->updateFamilia($data['id_padre'], array('ultimo_nodo' => '0'), null, false);
     return array(true, '');
 }
Esempio n. 8
0
function pageform()
{
    global $session;
    $process = new ProcessForm();
    $validate = $process::validate();
    $postdata = new Page("pages");
    $user = new User("users");
    $uid = $user::findRow("Id={$session->userid}");
    //change this to login session id when login is activated
    $id = $postdata::$id = isset($GLOBALS["id"]) ? "Id=" . $GLOBALS["id"] : null;
    //id recieved form querystring
    if ($GLOBALS["action"] == "editpage") {
        $edit = $postdata::findRow($id);
        //
        $title = $edit->Title;
        $category = $edit->Position;
        $source = $edit->Source;
        $pgcontent = $edit->Content;
        $published = $edit->Published;
        $featured = $edit->Featured;
        $authorid = $uid->Id;
        //image to upload
        $pgimage = "";
        $imgcaption = "";
    } else {
        $title = "";
        $category = "";
        $source = "";
        $pgcontent = "";
        $published = "";
        $featured = "";
        $authorid = $uid->Id;
        //image to upload
        $pgimage = "";
        $imgcaption = "";
        //debug($authorid);
    }
    //Process Page Form
    //Process Image Uploads here
    $upload_path = "../";
    $upload = new UploadFiles($upload_path . PAGEIMG_DIR, $upload_path . TEMP_DIR);
    if ($process->submitForm()) {
        /*@setting validation rules*/
        $upload->Mimetype = array('image/pjpeg' => "jpeg", 'image/jpeg' => "jpeg", 'image/png' => "png", 'image/gif' => "gif");
        $required = array("title", "page_content", "source");
        $process->errorinfo = array_merge($process->errorinfo, $validate->check_requiredFields($required));
        $check_invalidchars = array("title", "source");
        $process->errorinfo = array_merge($process->errorinfo, $validate->check_invalidChars($check_invalidchars));
        $requiredlen = array("title" => 100);
        $process->errorinfo = array_merge($process->errorinfo, $validate->check_FieldLength($requiredlen));
        $selectedindex = array("category" => "--Select Category--");
        $process->errorinfo = array_merge($process->errorinfo, $validate->check_selectField($selectedindex));
        if ($id == null) {
            $getrow = $postdata::fieldExists("Title={$_POST["title"]}");
            if ($getrow) {
                $process->errorinfo["title"] = $_POST["title"] . " already exist";
            }
        }
        /* upload info on validation ,//Sucess*/
        $massage = $process->message("Page has been successfully submmited.");
        if ($process->successflag) {
            //put database table here
            $postdata::$tablefields = array("Title" => $_POST["title"], "Content" => $_POST["page_content"], "Source" => $_POST["source"], "Postedby" => $_POST["authorid"], "Position" => $_POST["category"], "Published" => $_POST["publish"], "Featured" => $_POST["feature"]);
            /*saved to database*/
            $postdata->save();
            //echo "new recored was added with id=".$postdata->lastInsertedId();
            //echo "<br> success happened and all fields are sent to database, Thank you ! :)";
            /*uploads info*/
            $upload->uploadFile("uploadimg");
            //upolads an image
            if ($upload->Upload_status == true) {
                $postimg = new Image("pageimgs");
                $pageid = $id != null ? $id : $postdata->lastInsertedId();
                $postimg::$tablefields = array("Imgname" => $upload->Newfilename, "Width" => $upload->Width, "Height" => $upload->Height, "Imgcaption" => $_POST["imgcaption"], "Mimetype" => $upload->Filetype, "Extention" => $upload->File_ext, "Pageid" => $pageid);
                //check and delete old image record in pageimg table
                $pid = $postimg->findRow("Pageid=" . $pageid);
                if ($pid != null) {
                    //if(file_exists($upload_path.PAGEIMG_DIR.$pid->Imgname.".".$pid->Extention)){
                    $upload->deleteFile($upload_path . PAGEIMG_DIR . $pid->Imgname . "." . $pid->Extention);
                    $upload->deleteFile($upload_path . PAGEIMG_DIR . "thumbnails/" . $pid->Imgname . "." . $pid->Extention);
                }
                // }
                $postimg->save();
            }
        }
        //upload image
    }
    $form = new Form("Pageform", filter_var($_SERVER['PHP_SELF']) . "?" . filter_var($_SERVER['QUERY_STRING']), "post", "enctype=\"multipart/form-data\"\n");
    //Company;
    $form->startForm();
    $form->setFormField("", $form->addFormInfo("<h2>Use this form add new Page..</h2><p>Required Fields are labelled with asterics (*)</p><hr/>"));
    //Page Title
    $form->setFormField($form->inputLabel("title", "*Title"), $form->inputField("text", "title", $process->post("title", $title)), $validate->displayErrorField($process->errorinfo, "title"));
    //Category
    $pgcategory = function () {
        $category = new GetTableRecord("pagecategory");
        $category_options = $category::findAllRecords();
        $options[] = "--Select Category--";
        foreach ($category_options as $opt) {
            $options[$opt->Position] = $opt->Category;
        }
        return $options;
    };
    $form->setFormField($form->inputLabel("category", "*Category"), $form->selectOptions("category", $pgcategory(), $process->post("category", $category)), $validate->displayErrorField($process->errorinfo, "category"));
    //Page Source
    $form->setFormField($form->inputLabel("source", "*Source"), $form->inputField("text", "source", $process->post("source", $source)), $validate->displayErrorField($process->errorinfo, "source"));
    // Page Content
    $form->setFormField($form->inputLabel("page_content", "*Content"), $form->textAreaField("page_content", $process->post("page_content", $pgcontent), "10", "50", "class=\"ckeditor\""), $validate->displayErrorField($process->errorinfo, "page_content"));
    //Upload Image
    $form->setFormField($form->inputLabel("uploadimg", "Upload Image"), $form->uploadField("uploadimg[]", "uploadimg") . "<br>" . $form->textAreaField("imgcaption", $process->post("imgcaption", $imgcaption), "1", "45", 'placeholder="Image Caption"') . $form->inputField("hidden", "MAX_FILE_SIZE", "40000000"), $validate->displayErrorField($process->errorinfo, "uploadimg"));
    //Radio for Visible/
    $form->setFormField($form->inputLabel("publish", "Publish"), $form->radioButton("Yes", "publish", "Y", $process->post("publish", $published) == "Y" ? true : false) . $form->radioButton("No", "publish", "N", $process->post("publish", $published) == "N" ? true : false));
    //Featured Page
    $form->setFormField($form->inputLabel("feature", "Feature"), $form->radioButton("Yes", "feature", "Y", $process->post("feature", $featured) == "Y" ? true : false) . $form->radioButton("No", "feature", "N", $process->post("feature", $featured) == "N" ? true : false));
    //Submit Form
    $form->setFormField(null, $form->inputField("hidden", "authorid", $process->post("authorid", $authorid)) . $form->inputField("submit", "send", "Save"));
    $form->endForm();
    return $form->DisplayFields($GLOBALS["form_labling"], $process->message);
}