Primer commit del sistema avantika sin cambios
This commit is contained in:
275
classes/CNumeroaLetra.class.php
Executable file
275
classes/CNumeroaLetra.class.php
Executable file
@@ -0,0 +1,275 @@
|
||||
<?php
|
||||
/**
|
||||
* OEOG Class para convertir numeros en palabras
|
||||
*
|
||||
*
|
||||
* @version $Id: CNumeroaLetra.php,v 1.0.1 2004-10-29 13:20 ortizom Exp $
|
||||
* @author Omar Eduardo Ortiz Garza <ortizom@siicsa.com>
|
||||
* Gracias a Alberto Gonzalez por su contribucion para corregir
|
||||
* Modificado por Ing. Isaac Morales Cedeño
|
||||
*
|
||||
*
|
||||
* dos errores
|
||||
* @copyright (c) 2004-2005 Omar Eduardo Ortiz Garza
|
||||
* @since Friday, October 29, 2004
|
||||
**/
|
||||
/***************************************************************************
|
||||
|
||||
*
|
||||
* Este programa es software libre; puedes redistribuir y/o modificar
|
||||
* bajo los terminos de la GNU General Public License como se publico por
|
||||
* la Free Software Foundation; version 2 de la Licencia, o cualquier
|
||||
* (a tu eleccion) version posterior.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
class CNumeroaLetra{
|
||||
/***************************************************************************
|
||||
|
||||
*
|
||||
* Propiedades:
|
||||
* $numero: Es la cantidad a ser convertida a letras maximo
|
||||
999,999,999,999.99
|
||||
|
||||
* $genero: 0 para femenino y 1 para masculino, es util dependiendo de la
|
||||
* moneda ej: cuatrocientos pesos / cuatrocientas pesetas
|
||||
* $dinero: 1 cambia a letra agregando los centavos y 0 solo cambia a numero.
|
||||
* $moneda: nombre de la moneda
|
||||
* $prefijo: texto a imprimir antes de la cantidad
|
||||
* $sufijo: texto a imprimir despues de la cantidad
|
||||
* tanto el $sufijo como el $prefijo en la impresion de
|
||||
cheques o
|
||||
|
||||
* facturas, para impedir que se altere la cantidad
|
||||
* $mayusculas: 0 para minusculas, 1 para mayusculas indica como debe
|
||||
* mostrarse el texto
|
||||
* $textos_posibles: contiene todas las posibles palabras a usar
|
||||
* $aTexto: es el arreglo de los textos que se usan de acuerdo al genero
|
||||
|
||||
* seleccionado
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
private $numero=0;
|
||||
private $genero=1;
|
||||
private $dinero=0;
|
||||
private $moneda="PESOS";
|
||||
private $prefijo="(***";
|
||||
private $sufijo="***)";
|
||||
private $mayusculas=1;
|
||||
//textos
|
||||
private $textos_posibles= array(
|
||||
0 => array ('UNA ','DOS ','TRES ','CUATRO ','CINCO ','SEIS ','SIETE ',
|
||||
'OCHO ','NUEVE ','UN '),
|
||||
1 => array ('ONCE ','DOCE ','TRECE ','CATORCE ','QUINCE ','DIECISEIS ',
|
||||
'DIECISIETE ','DIECIOCHO ','DIECINUEVE ',''),
|
||||
2 => array ('DIEZ ','VEINTE ','TREINTA ','CUARENTA ','CINCUENTA ',
|
||||
'SESENTA ','SETENTA ','OCHENTA ','NOVENTA ','VEINTI'),
|
||||
3 => array ('CIEN ','DOSCIENTAS ','TRESCIENTAS ','CUATROCIENTAS ',
|
||||
'QUINIENTAS ','SEISCIENTAS ','SETECIENTAS ','OCHOCIENTAS ','NOVECIENTAS ',
|
||||
'CIENTO '),
|
||||
4 => array ('CIEN ','DOSCIENTOS ','TRESCIENTOS ','CUATROCIENTOS ',
|
||||
'QUINIENTOS ','SEISCIENTOS ','SETECIENTOS ','OCHOCIENTOS ','NOVECIENTOS ',
|
||||
'CIENTO '),
|
||||
5 => array ('MIL ','MILLON ','MILLONES ','CERO ','Y ','UNO ','DOS ',
|
||||
'CON ','','')
|
||||
);
|
||||
private $aTexto;
|
||||
|
||||
/***************************************************************************
|
||||
|
||||
*
|
||||
* Metodos:
|
||||
* _construct: Inicializa textos
|
||||
* setNumero: Asigna el numero a convertir a letra
|
||||
* setPrefijo: Asigna el prefijo
|
||||
* setSufijo: Asiga el sufijo
|
||||
* setMoneda: Asigna la moneda
|
||||
* setGenero: Asigan genero
|
||||
* setMayusculas: Asigna uso de mayusculas o minusculas
|
||||
* letra: Convierte numero en letra
|
||||
* letraUnidad: Convierte unidad en letra, asigna miles y millones
|
||||
* letraDecena: Contiene decena en letra
|
||||
* letraCentena: Convierte centena en letra
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
function __construct(){
|
||||
for($i=0; $i<6;$i++)
|
||||
for($j=0;$j<10;$j++)
|
||||
$this->aTexto[$i][$j]=$this->textos_posibles[$i][$j];
|
||||
}
|
||||
|
||||
function setNumero($num){
|
||||
$this->numero=(double)$num;
|
||||
}
|
||||
|
||||
function setPrefijo($pre){
|
||||
$this->prefijo=$pre;
|
||||
}
|
||||
|
||||
function setSufijo($sub){
|
||||
$this->sufijo=$sub;
|
||||
}
|
||||
|
||||
function setDinero($dinero){
|
||||
$this->dinero=$dinero;
|
||||
}
|
||||
|
||||
function setMoneda($mon){
|
||||
$this->moneda=$mon;
|
||||
}
|
||||
|
||||
function setGenero($gen){
|
||||
$this->genero=(int)$gen;
|
||||
}
|
||||
|
||||
function setMayusculas($may){
|
||||
$this->mayusculas=(int)$may;
|
||||
}
|
||||
|
||||
function letra(){
|
||||
if($this->genero==1){ //masculino
|
||||
$this->aTexto[0][0]=$this->textos_posibles[5][5];
|
||||
for($j=0;$j<9;$j++)
|
||||
$this->aTexto[3][$j]= $this->aTexto[4][$j];
|
||||
|
||||
}else{//femenino
|
||||
$this->aTexto[0][0]=$this->textos_posibles[0][0];
|
||||
for($j=0;$j<9;$j++)
|
||||
$this->aTexto[3][$j]= $this->aTexto[3][$j];
|
||||
}
|
||||
|
||||
$cnumero=sprintf("%015.2f",$this->numero);
|
||||
$texto="";
|
||||
if(strlen($cnumero)>15){
|
||||
$texto="Excede tamaño permitido";
|
||||
}else{
|
||||
$hay_significativo=false;
|
||||
for ($pos=0; $pos<12; $pos++){
|
||||
// Control existencia Dígito significativo
|
||||
if (!($hay_significativo)&&(substr($cnumero,$pos,1) ==
|
||||
'0')) ;
|
||||
else $hay_dignificativo = true;
|
||||
|
||||
// Detectar Tipo de Dígito
|
||||
switch($pos % 3) {
|
||||
case 0:
|
||||
$texto.=$this->letraCentena($pos,$cnumero); break;
|
||||
|
||||
case 1:
|
||||
$texto.=$this->letraDecena($pos,$cnumero); break;
|
||||
|
||||
case 2:
|
||||
$texto.=$this->letraUnidad($pos,$cnumero); break;
|
||||
|
||||
}
|
||||
}
|
||||
// Detectar caso 0
|
||||
if ($texto == '') $texto = $this->aTexto[5][3];
|
||||
if($this->mayusculas){//mayusculas
|
||||
if ($this->dinero == 1){
|
||||
$texto=strtoupper($this->prefijo.$texto." ".$this->moneda." ".substr($cnumero,-2)."/100 ".$this->sufijo);
|
||||
}
|
||||
}else{//minusculas
|
||||
if ($this->dinero == 1){
|
||||
$texto = strtolower($this->prefijo.$texto." ".$this->moneda." ".substr($cnumero,-2)."/100 ".$this->sufijo);
|
||||
}
|
||||
else{
|
||||
$texto = strtolower($texto);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $texto;
|
||||
|
||||
}
|
||||
|
||||
public function __toString() {
|
||||
return $this->letra();
|
||||
}
|
||||
|
||||
//traducir letra a unidad
|
||||
private function letraUnidad($pos,$cnumero){
|
||||
$unidad_texto="";
|
||||
if( !((substr($cnumero,$pos,1) == '0') ||
|
||||
(substr($cnumero,$pos - 1,1) == '1') ||
|
||||
((substr($cnumero, $pos - 2, 3) == '001') && (($pos == 2
|
||||
) || ($pos == 8)) )
|
||||
)
|
||||
){
|
||||
if((substr($cnumero,$pos,1) == '1') && ($pos <= 6)){
|
||||
$unidad_texto.=$this->aTexto[0][9];
|
||||
}else{
|
||||
$unidad_texto.=$this->aTexto[0][substr($cnumero,$pos,1) - 1];
|
||||
|
||||
}
|
||||
}
|
||||
if((($pos == 2) || ($pos == 8)) &&
|
||||
(substr($cnumero, $pos - 2, 3) != '000')){//miles
|
||||
if(substr($cnumero,$pos,1)=='1'){
|
||||
if($pos <= 6){
|
||||
$unidad_texto=substr($unidad_texto,0,-1)." ";
|
||||
}else{
|
||||
$unidad_texto=substr($unidad_texto,0,-2)." ";
|
||||
}
|
||||
$unidad_texto.= $this->aTexto[5][0];
|
||||
}else{
|
||||
$unidad_texto.=$this->aTexto[5][0];
|
||||
}
|
||||
}
|
||||
if($pos == 5 && substr($cnumero, 0, 6) != '000000'){
|
||||
if(substr($cnumero, 0, 6) == '000001'){//millones
|
||||
$unidad_texto.=$this->aTexto[5][1];
|
||||
}else{
|
||||
$unidad_texto.=$this->aTexto[5][2];
|
||||
}
|
||||
}
|
||||
return $unidad_texto;
|
||||
}
|
||||
//traducir digito a decena
|
||||
private function letraDecena($pos,$cnumero){
|
||||
$decena_texto="";
|
||||
if (substr($cnumero,$pos,1) == '0'){
|
||||
return;
|
||||
}else if(substr($cnumero,$pos + 1,1) == '0'){
|
||||
$decena_texto.=$this->aTexto[2][substr($cnumero,$pos,1)-1];
|
||||
}else if(substr($cnumero,$pos,1) == '1'){
|
||||
$decena_texto.=$this->aTexto[1][substr($cnumero,$pos+ 1,1)- 1];
|
||||
|
||||
}else if(substr($cnumero,$pos,1) == '2'){
|
||||
$decena_texto.=$this->aTexto[2][9];
|
||||
}else{
|
||||
$decena_texto.=$this->aTexto[2][substr($cnumero,$pos,1)- 1
|
||||
] . $this->aTexto[5][4];
|
||||
}
|
||||
return $decena_texto;
|
||||
}
|
||||
//traducir digito centena
|
||||
private function letraCentena($pos,$cnumero){
|
||||
$centena_texto="";
|
||||
if (substr($cnumero,$pos,1) == '0') return;
|
||||
$pos2 = 3;
|
||||
if((substr($cnumero,$pos,1) == '1') && (substr($cnumero,$pos+ 1, 2
|
||||
) != '00')){
|
||||
$centena_texto.=$this->aTexto[$pos2][9];
|
||||
}else{
|
||||
$centena_texto.=$this->aTexto[$pos2][substr($cnumero,$pos,1
|
||||
) - 1];
|
||||
}
|
||||
return $centena_texto;
|
||||
}
|
||||
|
||||
}
|
||||
176
classes/atributo.class.php
Executable file
176
classes/atributo.class.php
Executable file
@@ -0,0 +1,176 @@
|
||||
<?php
|
||||
|
||||
class Atributo extends Main
|
||||
{
|
||||
private $atributoId;
|
||||
private $nombre;
|
||||
|
||||
public function setAtributoId($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, "Atributo");
|
||||
$this->atributoId = $value;
|
||||
}
|
||||
|
||||
public function setNombre($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Nombre');
|
||||
$this->nombre = $value;
|
||||
}
|
||||
|
||||
function Info(){
|
||||
|
||||
$sql = "SELECT
|
||||
*
|
||||
FROM
|
||||
atributo
|
||||
WHERE
|
||||
atributoId = '".$this->atributoId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$row = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
function EnumerateAll()
|
||||
{
|
||||
$sql = "SELECT * FROM atributo WHERE baja = '0' ORDER BY nombre ASC";
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$atributos = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $atributos;
|
||||
}
|
||||
|
||||
function EnumerateAll2()
|
||||
{
|
||||
$sql = "SELECT * FROM atributo
|
||||
WHERE atributoId > 2
|
||||
AND baja = '0'
|
||||
ORDER BY nombre ASC";
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$atributos = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $atributos;
|
||||
}
|
||||
|
||||
function Enumerate()
|
||||
{
|
||||
$sql = "SELECT COUNT(*) FROM atributo WHERE baja = '0'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
$pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/atributos");
|
||||
|
||||
$sqlAdd = " LIMIT ".$pages["start"].", ".$pages["items_per_page"];
|
||||
|
||||
$sql = "SELECT * FROM atributo WHERE baja = '0' ORDER BY nombre ASC".$sqlAdd;
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$atributos = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$data["items"] = $atributos;
|
||||
$data["pages"] = $pages;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function Save(){
|
||||
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO `atributo`
|
||||
(
|
||||
nombre
|
||||
)
|
||||
VALUES (
|
||||
'".utf8_decode($this->nombre)."'
|
||||
)";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->ExecuteQuery();
|
||||
|
||||
$this->Util()->setError(30039, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function Update(){
|
||||
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = "UPDATE
|
||||
`atributo`
|
||||
SET
|
||||
nombre = '".utf8_decode($this->nombre)."'
|
||||
WHERE
|
||||
atributoId = ".$this->atributoId;
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->ExecuteQuery();
|
||||
|
||||
$this->Util()->setError(30040, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function Delete(){
|
||||
|
||||
$sql = "DELETE FROM
|
||||
atributo
|
||||
WHERE
|
||||
atributoId = '".$this->atributoId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$sql = "DELETE FROM
|
||||
atributoValor
|
||||
WHERE
|
||||
atributoId = '".$this->atributoId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$this->Util()->setError(30041, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function Baja(){
|
||||
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
|
||||
UPDATE atributo SET baja = '1'
|
||||
WHERE atributoId = '".$this->atributoId."'"
|
||||
);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData();
|
||||
|
||||
$this->Util()->setError(30041, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}//Baja
|
||||
|
||||
function GetNameById(){
|
||||
|
||||
$sql = "SELECT
|
||||
nombre
|
||||
FROM
|
||||
atributo
|
||||
WHERE
|
||||
atributoId = '".$this->atributoId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$name = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
}//Atributo
|
||||
|
||||
?>
|
||||
177
classes/atributoValor.class.php
Executable file
177
classes/atributoValor.class.php
Executable file
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
|
||||
class AtributoValor extends Main
|
||||
{
|
||||
private $atribValId;
|
||||
private $atributoId;
|
||||
private $nombre;
|
||||
|
||||
public function setAtribValId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->atribValId = $value;
|
||||
}
|
||||
|
||||
public function setAtributoId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->atributoId = $value;
|
||||
}
|
||||
|
||||
public function setNombre($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Nombre');
|
||||
$this->nombre = $value;
|
||||
}
|
||||
|
||||
public function Info()
|
||||
{
|
||||
$sql = 'SELECT
|
||||
*
|
||||
FROM
|
||||
atributoValor
|
||||
WHERE
|
||||
atribValId = "'.$this->atribValId.'"';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$info = $this->Util()->DBSelect($_SESSION['empresaId'])->GetRow();
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
public function EnumerateAll()
|
||||
{
|
||||
$sql = 'SELECT
|
||||
*
|
||||
FROM
|
||||
atributoValor
|
||||
WHERE
|
||||
baja = "0"
|
||||
AND
|
||||
atributoId = "'.$this->atributoId.'"
|
||||
ORDER BY
|
||||
nombre ASC';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function Enumerate()
|
||||
{
|
||||
$sql = 'SELECT COUNT(*) FROM atributoValor
|
||||
WHERE baja = "0"
|
||||
AND atributoId = "'.$this->atributoId.'"';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
$pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT.'/atributos-valores');
|
||||
|
||||
$sqlAdd = 'LIMIT '.$pages['start'].', '.$pages['items_per_page'];
|
||||
|
||||
$sql = 'SELECT * FROM atributoValor
|
||||
WHERE baja = "0"
|
||||
AND atributoId = "'.$this->atributoId.'"
|
||||
ORDER BY nombre ASC '.$sqlAdd;
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
$data['items'] = $result;
|
||||
$data['pages'] = $pages;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function Save()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){ return false; }
|
||||
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery('
|
||||
INSERT INTO `atributoValor` (
|
||||
atributoId,
|
||||
nombre
|
||||
)
|
||||
VALUES (
|
||||
"'.$this->atributoId.'",
|
||||
"'.utf8_decode($this->nombre).'"
|
||||
)'
|
||||
);
|
||||
$atribValId = $this->Util()->DBSelect($_SESSION['empresaId'])->InsertData();
|
||||
|
||||
$this->Util()->setError(30042, 'complete');
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return $atribValId;
|
||||
}
|
||||
|
||||
function Update()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){ return false; }
|
||||
|
||||
$sql = '
|
||||
UPDATE `atributoValor` SET
|
||||
`nombre` = "'.utf8_decode($this->nombre).'"
|
||||
WHERE atribValId = "'.$this->atribValId.'"
|
||||
';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData();
|
||||
|
||||
$this->Util()->setError(30043, 'complete');
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function Delete()
|
||||
{
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery('
|
||||
DELETE FROM atributoValor
|
||||
WHERE atribValId = "'.$this->atribValId.'"'
|
||||
);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->DeleteData();
|
||||
|
||||
$this->Util()->setError(30043, 'complete');
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function Baja(){
|
||||
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
|
||||
UPDATE atributoValor SET baja = '1'
|
||||
WHERE atribValId = '".$this->atribValId."'"
|
||||
);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData();
|
||||
|
||||
$this->Util()->setError(30041, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}//Baja
|
||||
|
||||
function GetNameById()
|
||||
{
|
||||
$sql = 'SELECT nombre FROM atributoValor
|
||||
WHERE atribValId = "'.$this->atribValId.'"';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$nombre = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
return $nombre;
|
||||
}
|
||||
|
||||
function ExistValor()
|
||||
{
|
||||
$sql = 'SELECT atribValId FROM atributoValor
|
||||
WHERE atributoId = "'.$this->atributoId.'"
|
||||
AND nombre = "'.$this->nombre.'"
|
||||
LIMIT 1';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$atribValId = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
return $atribValId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
565
classes/bonificacion.class.php
Executable file
565
classes/bonificacion.class.php
Executable file
@@ -0,0 +1,565 @@
|
||||
<?php
|
||||
|
||||
class Bonificacion extends Main
|
||||
{
|
||||
private $bonificacionId;
|
||||
private $pedidoId;
|
||||
private $proveedorId;
|
||||
private $prodItemId;
|
||||
private $productoId;
|
||||
|
||||
private $costo;
|
||||
private $total;
|
||||
private $disponible;
|
||||
private $vendido;
|
||||
private $porcentajeVendido;
|
||||
private $porcentajeAplicado;
|
||||
private $pagoTotal;
|
||||
private $porcentajeBonifica;
|
||||
private $cantidad;
|
||||
private $restante;
|
||||
private $status;
|
||||
private $justificanteRechazo;
|
||||
private $tipo;
|
||||
private $search;
|
||||
|
||||
private $totalBonificacion;
|
||||
private $totalDevolucion;
|
||||
private $porcentaje;
|
||||
private $folioProv;
|
||||
|
||||
function setTotalBonificacion($value)
|
||||
{
|
||||
$this->totalBonificacion = $value;
|
||||
}
|
||||
|
||||
function setTotalDevolucion($value)
|
||||
{
|
||||
$this->totalDevolucion = $value;
|
||||
}
|
||||
|
||||
function setSearch($value)
|
||||
{
|
||||
$this->search = $value;
|
||||
}
|
||||
|
||||
public function setTipo($value)
|
||||
{
|
||||
//$this->Util()->ValidateString($value, $max_chars=255, $minChars = 1, "Justificacion");
|
||||
$this->tipo = $value;
|
||||
}
|
||||
|
||||
public function setJustificanteRechazo($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 1, "Justificacion");
|
||||
$this->justificanteRechazo = $value;
|
||||
}
|
||||
|
||||
public function setStatus($value)
|
||||
{
|
||||
//$this->Util()->ValidateInteger($value);
|
||||
$this->status = $value;
|
||||
}
|
||||
|
||||
public function setBonificacionId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->bonificacionId = $value;
|
||||
}
|
||||
|
||||
public function setRestante($value)
|
||||
{
|
||||
//$this->Util()->ValidateInteger($value);
|
||||
$this->restante = $value;
|
||||
}
|
||||
|
||||
public function setCantidad($value)
|
||||
{
|
||||
//$this->Util()->ValidateInteger($value);
|
||||
$this->cantidad = $value;
|
||||
}
|
||||
|
||||
public function setPorcentajeBonifica($value)
|
||||
{
|
||||
//$this->Util()->ValidateInteger($value);
|
||||
$this->porcentajeBonifica = $value;
|
||||
}
|
||||
|
||||
public function setPagoTotal($value)
|
||||
{
|
||||
//$this->Util()->ValidateInteger($value);
|
||||
$this->pagoTotal = $value;
|
||||
}
|
||||
|
||||
public function setPorcentajeVendido($value)
|
||||
{
|
||||
//$this->Util()->ValidateInteger($value);
|
||||
$this->porcentajeVendido = $value;
|
||||
}
|
||||
|
||||
public function setPorcentajeAplicado($value)
|
||||
{
|
||||
//$this->Util()->ValidateInteger($value);
|
||||
$this->porcentajeAplicado = $value;
|
||||
}
|
||||
|
||||
public function setVendido($value)
|
||||
{
|
||||
//$this->Util()->ValidateInteger($value);
|
||||
$this->vendido = $value;
|
||||
}
|
||||
|
||||
public function setDisponible($value)
|
||||
{
|
||||
//$this->Util()->ValidateInteger($value);
|
||||
$this->disponible = $value;
|
||||
}
|
||||
|
||||
public function setTotal($value)
|
||||
{
|
||||
//$this->Util()->ValidateInteger($value);
|
||||
$this->total = $value;
|
||||
}
|
||||
|
||||
public function setCosto($value)
|
||||
{
|
||||
//$this->Util()->ValidateInteger($value);
|
||||
$this->costo = $value;
|
||||
}
|
||||
|
||||
function setPorcentaje($value){
|
||||
$this->porcentaje = $value;
|
||||
}
|
||||
|
||||
public function setProductoId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->productoId = $value;
|
||||
}
|
||||
|
||||
public function setPedidoId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->pedidoId = $value;
|
||||
}
|
||||
|
||||
public function setProdItemId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->prodItemId = $value;
|
||||
}
|
||||
|
||||
public function setProveedorId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->proveedorId = $value;
|
||||
}
|
||||
|
||||
public function setFolioProv($value)
|
||||
{
|
||||
$this->folioProv = $value;
|
||||
}
|
||||
|
||||
public function searchProductoById()
|
||||
{
|
||||
$sql = 'SELECT * FROM producto LEFT JOIN pedidoProducto ON(pedidoProducto.productoId = producto.productoId) LEFT JOIN pedido ON(pedido.pedidoId = pedidoProducto.pedidoId) LEFT JOIN productoItem ON(productoItem.productoId = producto.productoId) WHERE pedido.pedidoId = '.$this->pedidoId.' AND producto.productoId = '.$this->productoId;
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$producto = $this->Util()->DBSelect($_SESSION['empresaId'])->GetRow();
|
||||
|
||||
return $producto;
|
||||
}
|
||||
|
||||
public function Save()
|
||||
{
|
||||
$sql = "INSERT INTO bonificacion(
|
||||
`prodItemId`,
|
||||
`proveedorId`,
|
||||
`pedidoId`,
|
||||
`productoId`,
|
||||
`porcentajeBonifica`,
|
||||
`totalBonificacion`,
|
||||
`restanteBonificacion`,
|
||||
`porcentajeAplicado`,
|
||||
`fechaBonificacion`,
|
||||
`totalProductos`,
|
||||
`costoProducto`,
|
||||
`disponible`,
|
||||
`vendido`,
|
||||
`porcentajeVendido`,
|
||||
`cantidad`,
|
||||
`tipo`) VALUES
|
||||
('".$this->prodItemId."',
|
||||
'".$this->proveedorId."',
|
||||
'".$this->pedidoId."',
|
||||
'".$this->productoId."',
|
||||
'".$this->porcentajeBonifica."',
|
||||
'".$this->pagoTotal."',
|
||||
'".$this->restante."',
|
||||
'".$this->porcentajeAplicado."',
|
||||
'".$this->Util()->TodayHour()."',
|
||||
'".$this->total."',
|
||||
'".$this->costo."',
|
||||
'".$this->disponible."',
|
||||
'".$this->vendido."',
|
||||
'".$this->porcentajeVendido."',
|
||||
'".$this->cantidad."',
|
||||
'".$this->tipo."')";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->InsertData();
|
||||
$this->Util()->setError(30066, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkBonificacion()
|
||||
{
|
||||
$value = true;
|
||||
|
||||
$sql = "SELECT COUNT(*) FROM bonificacion
|
||||
WHERE proveedorId = '".$this->proveedorId."'
|
||||
AND pedidoId = '".$this->pedidoId."'
|
||||
AND productoId = '".$this->productoId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
if($this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle() > 0)
|
||||
$value = false;
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
function checkBonificacion2()
|
||||
{
|
||||
$value = true;
|
||||
|
||||
$sql = "SELECT COUNT(*) FROM bonificacion
|
||||
WHERE proveedorId = '".$this->proveedorId."'
|
||||
AND pedidoId = '".$this->pedidoId."'
|
||||
AND productoId = '".$this->productoId."'
|
||||
AND estatus LIKE 'Aprobado'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$aprobado = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
$sql = "SELECT COUNT(*) FROM bonificacion
|
||||
WHERE proveedorId = '".$this->proveedorId."'
|
||||
AND pedidoId = '".$this->pedidoId."'
|
||||
AND productoId = '".$this->productoId."'
|
||||
AND estatus LIKE 'Pendiente'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$pendiente = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
$sql = "SELECT COUNT(*) FROM bonificacion
|
||||
WHERE proveedorId = '".$this->proveedorId."'
|
||||
AND pedidoId = '".$this->pedidoId."'
|
||||
AND productoId = '".$this->productoId."'
|
||||
AND estatus LIKE 'Aprobado'
|
||||
AND tipo LIKE 'Devolucion'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$devolucion = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
if($aprobado >= 2 || $pendiente > 0 || $devolucion > 0)
|
||||
$value = false;
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
function Enumerate()
|
||||
{
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT COUNT(*) FROM bonificacion");
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
$pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/bonificaciones-pendientes");
|
||||
|
||||
//$sqlAdd = " LIMIT ".$pages["start"].", ".$pages["items_per_page"];
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT * FROM bonificacion ORDER BY fechaBonificacion ASC".$sqlAdd);
|
||||
$bonificaciones = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$data["items"] = $bonificaciones;
|
||||
$data["pages"] = $pages;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function updateStatus()
|
||||
{
|
||||
$fecha = $this->Util()->Today();
|
||||
$sql = "INSERT INTO pedidoBonifDevolucion(pedidoId, totalBonificacion, totalDevolucion, fechaAplicado)
|
||||
VALUES(".$this->pedidoId.",".$this->totalBonificacion.",".$this->totalDevolucion.",'".$fecha."')";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->InsertData();
|
||||
|
||||
$sql = "SELECT pedidoBonifDevolucionId FROM pedidoBonifDevolucion
|
||||
WHERE pedidoId = ".$this->pedidoId."
|
||||
AND totalBonificacion = ".$this->totalBonificacion."
|
||||
AND totalDevolucion = ".$this->totalDevolucion."
|
||||
AND fechaAplicado = '".$fecha."'
|
||||
ORDER BY fechaAplicado DESC";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$pedidoBonifDevolucionId = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
$sql = "SELECT * FROM bonificacion
|
||||
WHERE pedidoId = ".$this->pedidoId." AND estatus LIKE 'Pendiente'";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$resultBonif = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
$sql = "UPDATE bonificacion
|
||||
SET estatus = 'Aprobado',
|
||||
cantidad = totalBonificacion,
|
||||
pedidoBonifDevolucionId = ".$pedidoBonifDevolucionId."
|
||||
WHERE pedidoId = ".$this->pedidoId."
|
||||
AND estatus LIKE 'Pendiente'";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData();
|
||||
|
||||
foreach($resultBonif as $key => $result)
|
||||
{
|
||||
$sql = "SELECT * FROM producto WHERE productoId = ".$result['productoId'];
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$prodInfo = $this->Util()->DBSelect($_SESSION['empresaId'])->GetRow();
|
||||
|
||||
$nuevoPrecioVenta = $prodInfo['precioVentaIva']-($prodInfo['precioVentaIva']*($result['porcentajeAplicado']/100));
|
||||
$nuevoCosto = $prodInfo['costo']-($prodInfo['costo']*($result['porcentajeAplicado']/100));
|
||||
|
||||
if($result['tipo'] == "Devolucion")
|
||||
{
|
||||
$sql = "UPDATE inventario SET status = 'Devolucion' WHERE pedidoId = ".$result['pedidoId']." AND productoId = ".$result['productoId']." AND `status` LIKE 'Disponible'";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData();
|
||||
|
||||
$sql = "SELECT
|
||||
sucursalId,
|
||||
pedidoId,
|
||||
COUNT(inventarioId) AS cantidadProd
|
||||
FROM inventario
|
||||
WHERE pedidoId = '".$result['pedidoId']."' AND productoId = '".$result['productoId']."' AND `status` LIKE 'Devolucion' GROUP BY sucursalId";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$devolucionDetails = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
foreach($devolucionDetails as $key => $dev)
|
||||
{
|
||||
$costoDevolucion = $prodInfo['costo']*$dev['cantidadProd'];
|
||||
$sql = "INSERT INTO envioDevolucion(sucursalId, pedidoId, productoId, proveedorId, cantidadProd, total, fecha) VALUES('".$dev['sucursalId']."','".$dev['pedidoId']."', '".$prodInfo['productoId']."', '".$prodInfo['proveedorId']."','".$dev['cantidadProd']."','".$costoDevolucion."','".$this->Util()->Today()."')";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->InsertData();
|
||||
}
|
||||
|
||||
}else
|
||||
{
|
||||
$sql = "UPDATE inventario SET rebajado = '1', precioVenta = ".$nuevoPrecioVenta." WHERE pedidoId = ".$result['pedidoId']." AND productoId = ".$result['productoId']." AND `status` LIKE 'Disponible'";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData();
|
||||
|
||||
$sql = "UPDATE producto SET costo = ".$nuevoCosto." WHERE productoId = ".$result['productoId'];
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData();
|
||||
}
|
||||
}
|
||||
$this->Util()->setError(30067, 'complete');
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function getBonificaciones()
|
||||
{
|
||||
$sql = 'SELECT totalBonif FROM pedido
|
||||
WHERE pedidoId = '.$this->pedidoId;
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
function getDevoluciones()
|
||||
{
|
||||
$sql = 'SELECT SUM(totalDevolucion) FROM pedidoBonifDevolucion WHERE pedidoId = '.$this->pedidoId;
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$producto = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
return $producto;
|
||||
}
|
||||
|
||||
public function SaveDevolucion()
|
||||
{
|
||||
$sql = "INSERT INTO devolucionPedido(
|
||||
`prodItemId`,
|
||||
`proveedorId`,
|
||||
`pedidoId`,
|
||||
`productoId`,
|
||||
`totalDevolucion`,
|
||||
`porcentajeAplicado`,
|
||||
`fechaDevolucion`,
|
||||
`totalProductos`,
|
||||
`costoProducto`,
|
||||
`disponible`,
|
||||
`vendido`,
|
||||
`porcentajeVendido`,
|
||||
`cantidad`) VALUES
|
||||
('".$this->prodItemId."',
|
||||
'".$this->proveedorId."',
|
||||
'".$this->pedidoId."',
|
||||
'".$this->productoId."',
|
||||
'".$this->pagoTotal."',
|
||||
'".$this->porcentajeAplicado."',
|
||||
'".$this->Util()->TodayHour()."',
|
||||
'".$this->total."',
|
||||
'".$this->costo."',
|
||||
'".$this->disponible."',
|
||||
'".$this->vendido."',
|
||||
'".$this->porcentajeVendido."',
|
||||
'".$this->cantidad."')";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->InsertData();
|
||||
$this->Util()->setError(30066, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function EnumerateSearch()
|
||||
{
|
||||
if($this->status != "Todos")
|
||||
$sqlAdd1 = " AND estatus LIKE '".$this->status."' ";
|
||||
if($this->pedidoId != 0 && $this->pedidoId != null && $this->pedidoId != "")
|
||||
$sqlAdd2 = " AND pedidoId = '".$this->pedidoId."' ";
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT COUNT(*) FROM bonificacion INNER JOIN proveedor ON(proveedor.proveedorId = bonificacion.proveedorId) WHERE proveedor.nombre LIKE '%".$this->search."%'".$sqlAdd1.$sqlAdd2);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
$pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/bonificaciones-pendientes");
|
||||
|
||||
$sqlAdd = " LIMIT ".$pages["start"].", ".$pages["items_per_page"];
|
||||
|
||||
//echo "SELECT * FROM bonificacion INNER JOIN proveedor ON(proveedor.proveedorId = bonificacion.proveedorId) WHERE proveedor.nombre LIKE '%".$this->search."%'".$sqlAdd1.$sqlAdd2." ORDER BY fechaBonificacion ASC".$sqlAdd;
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT * FROM bonificacion INNER JOIN proveedor ON(proveedor.proveedorId = bonificacion.proveedorId) WHERE proveedor.nombre LIKE '%".$this->search."%'".$sqlAdd1.$sqlAdd2." ORDER BY fechaBonificacion ASC".$sqlAdd);
|
||||
$bonificaciones = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$data["items"] = $bonificaciones;
|
||||
$data["pages"] = $pages;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function GetPedidos()
|
||||
{
|
||||
if($this->status != "Todos")
|
||||
$sqlAdd1 = " AND estatus LIKE '".$this->status."' ";
|
||||
if($this->pedidoId != 0 && $this->pedidoId != null && $this->pedidoId != "")
|
||||
$sqlAdd2 = " AND bonificacion.pedidoId = '".$this->pedidoId."' ";
|
||||
|
||||
$sql = "SELECT
|
||||
bonificacion.pedidoId,
|
||||
proveedor.nombre,
|
||||
bonificacion.proveedorId ,
|
||||
bonificacion.estatus,
|
||||
pedidoBonifDevolucion.totalBonificacion AS totalBonificacion2,
|
||||
pedidoBonifDevolucion.totalDevolucion
|
||||
FROM bonificacion
|
||||
LEFT JOIN proveedor ON(proveedor.proveedorId = bonificacion.proveedorId)
|
||||
LEFT JOIN pedidoBonifDevolucion ON(pedidoBonifDevolucion.pedidoBonifDevolucionId = bonificacion.pedidoBonifDevolucionId)
|
||||
WHERE proveedor.nombre LIKE '%".$this->search."%'".$sqlAdd1.$sqlAdd2."
|
||||
GROUP BY bonificacion.pedidoId ORDER BY bonificacion.pedidoId";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$pedidos = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
return $pedidos;
|
||||
}
|
||||
|
||||
function GetBonifByPedido(){
|
||||
|
||||
$sql = 'SELECT * FROM bonificacion
|
||||
WHERE pedidoId = "'.$this->pedidoId.'"';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$bonificaciones = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
return $bonificaciones;
|
||||
}
|
||||
|
||||
function EnumProdsByPedido(){
|
||||
|
||||
if($this->productoId)
|
||||
$sqlAdd = ' AND prod.productoId = "'.$this->productoId.'"';
|
||||
|
||||
$sql = 'SELECT prod.*, p.totalDesc
|
||||
FROM pedido p, pedidoProducto prod
|
||||
WHERE p.pedidoId = prod.pedidoId
|
||||
AND p.pedidoId = "'.$this->pedidoId.'"'.$sqlAdd;
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$productos = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
return $productos;
|
||||
}
|
||||
|
||||
function CantVtasByProd(){
|
||||
|
||||
$sql = 'SELECT SUM(cantidad) FROM inventario
|
||||
WHERE productoId = "'.$this->productoId.'"
|
||||
AND pedidoId = "'.$this->pedidoId.'"';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
function GetPorcBonif(){
|
||||
|
||||
$sql = 'SELECT * FROM politicaBD
|
||||
WHERE tipo = "Bonificacion"
|
||||
AND baja = "0"
|
||||
ORDER BY porcentajeEvaluacion DESC';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$politicas = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
foreach($politicas as $key => $res)
|
||||
{
|
||||
$porcentaje1 = $res['porcentajeEvaluacion'];
|
||||
if(isset($politicas[$key+1]['porcentajeEvaluacion']))
|
||||
$porcentaje2 = $politicas[$key+1]['porcentajeEvaluacion'];
|
||||
else
|
||||
$porcentaje2 = 0;
|
||||
|
||||
//Porc1 = 70, Porc2 = 65 ::::: Porc1 = 65, Porc2= 60
|
||||
if($this->porcentaje >= $porcentaje2 && $this->porcentaje < $porcentaje1)
|
||||
return $res['porcentajeBonificacion'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function EnumBonifDev()
|
||||
{
|
||||
$sql = "SELECT COUNT(*) FROM bonifDev";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
$pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/bonificaciones");
|
||||
|
||||
$sqlAdd = "LIMIT ".$pages["start"].", ".$pages["items_per_page"];
|
||||
|
||||
$sql = "SELECT * FROM bonifDev ORDER BY fecha DESC ".$sqlAdd;
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$data["items"] = $result;
|
||||
$data["pages"] = $pages;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function GetPedidoByFolio(){
|
||||
|
||||
$sql = 'SELECT * FROM pedido
|
||||
WHERE (folioProv = "'.$this->folioProv.'"
|
||||
OR folioProv2 = "'.$this->folioProv.'"
|
||||
OR folioProv3 = "'.$this->folioProv.'"
|
||||
OR folioProv4 = "'.$this->folioProv.'"
|
||||
OR folioProv5 = "'.$this->folioProv.'")
|
||||
ORDER BY noPedido ASC';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$row = $this->Util()->DBSelect($_SESSION['empresaId'])->GetRow();
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
129
classes/cadena_original_v3.class.php
Executable file
129
classes/cadena_original_v3.class.php
Executable file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
class Cadena extends Comprobante
|
||||
{
|
||||
public function BuildCadenaOriginal($data, $serie, $totales, $nodoEmisor, $nodoReceptor, $nodosConceptos)
|
||||
{
|
||||
//informacion nodo comprobante
|
||||
$cadenaOriginal = "||3.2|";
|
||||
// $cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($serie["serie"]);
|
||||
// $cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["folio"]);
|
||||
$data["fecha"] = explode(" ", $data["fecha"]);
|
||||
$data["fecha"] = $data["fecha"][0]."T".$data["fecha"][1];
|
||||
//$data["fecha"] = "2010-09-22T07:45:09";
|
||||
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["fecha"]);
|
||||
// $cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($serie["noAprobacion"]);
|
||||
// $cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($serie["anoAprobacion"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["tipoDeComprobante"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["formaDePago"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["condicionesDePago"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($totales["subtotal"], true);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($totales["descuento"], true);
|
||||
//tipo de cambio
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["tipoDeCambio"], true);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["tiposDeMoneda"], false);
|
||||
|
||||
//tipo de cambio
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($totales["total"], true);
|
||||
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["metodoDePago"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["sucursal"]["nombre"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["numCtaPago"]);
|
||||
|
||||
//informacion nodo emisor
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["rfc"]["rfc"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["rfc"]["razonSocial"]);
|
||||
|
||||
//informacion nodo domiciliofiscal
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["rfc"]["calle"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["rfc"]["noExt"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["rfc"]["noInt"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["rfc"]["colonia"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["rfc"]["localidad"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["rfc"]["referencia"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["rfc"]["municipio"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["rfc"]["estado"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["rfc"]["pais"]);
|
||||
// $cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["rfc"]["cp"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($this->Util()->PadStringLeft($data["nodoEmisor"]["rfc"]["cp"], 5, "0"));
|
||||
|
||||
if($data["nodoEmisor"]["sucursal"]["sucursalActiva"] == 'no'){
|
||||
|
||||
//informacion nodo expedidoen
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["sucursal"]["calle"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["sucursal"]["noExt"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["sucursal"]["noInt"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["sucursal"]["colonia"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["sucursal"]["localidad"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["sucursal"]["referencia"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["sucursal"]["municipio"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["sucursal"]["estado"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["sucursal"]["pais"]);
|
||||
// $cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["sucursal"]["cp"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($this->Util()->PadStringLeft($data["nodoEmisor"]["sucursal"]["cp"], 5, "0"));
|
||||
|
||||
}
|
||||
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["rfc"]["regimenFiscal"]);
|
||||
|
||||
//informacion nodo receptor
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($nodoReceptor["rfc"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($nodoReceptor["nombre"]);
|
||||
|
||||
//informacion nodo domicilio
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($nodoReceptor["calle"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($nodoReceptor["noExt"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($nodoReceptor["noInt"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($nodoReceptor["colonia"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($nodoReceptor["localidad"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($nodoReceptor["referencia"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($nodoReceptor["municipio"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($nodoReceptor["estado"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($nodoReceptor["pais"]);
|
||||
// $cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($nodoReceptor["cp"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($this->Util()->PadStringLeft($nodoReceptor["cp"], 5, "0"));
|
||||
|
||||
//informacion nodos conceptos
|
||||
foreach($nodosConceptos as $concepto)
|
||||
{
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($concepto["cantidad"],true);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($concepto["unidad"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($concepto["noIdentificacion"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($concepto["descripcion"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($concepto["valorUnitario"],true);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($concepto["importe"],true);
|
||||
//aca falta la informacion aduanera
|
||||
//aca falta cuenta predial
|
||||
}
|
||||
|
||||
//todo complementoconcepto
|
||||
|
||||
//nodoretenciones
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat("IVA");
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($totales["retIva"],true);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat("ISR");
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($totales["retIsr"],true);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($totales["retIsr"]+$totales["retIva"],true);
|
||||
|
||||
//nodotraslados
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat("IVA");
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($totales["tasaIva"], true);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($totales["iva"], true);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat("IEPS");
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($totales["porcentajeIEPS"], true);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($totales["ieps"], true);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($totales["iva"] + $totales["ieps"], true);
|
||||
|
||||
//falta nodo complemento
|
||||
$cadenaOriginal .= "|";
|
||||
|
||||
$cadenaOriginal = utf8_encode($cadenaOriginal);
|
||||
return $cadenaOriginal;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
2320
classes/class.phpmailer.php
Executable file
2320
classes/class.phpmailer.php
Executable file
File diff suppressed because it is too large
Load Diff
814
classes/class.smtp.php
Executable file
814
classes/class.smtp.php
Executable file
@@ -0,0 +1,814 @@
|
||||
<?php
|
||||
/*~ class.smtp.php
|
||||
.---------------------------------------------------------------------------.
|
||||
| Software: PHPMailer - PHP email class |
|
||||
| Version: 5.1 |
|
||||
| Contact: via sourceforge.net support pages (also www.codeworxtech.com) |
|
||||
| Info: http://phpmailer.sourceforge.net |
|
||||
| Support: http://sourceforge.net/projects/phpmailer/ |
|
||||
| ------------------------------------------------------------------------- |
|
||||
| Admin: Andy Prevost (project admininistrator) |
|
||||
| Authors: Andy Prevost (codeworxtech) codeworxtech@users.sourceforge.net |
|
||||
| : Marcus Bointon (coolbru) coolbru@users.sourceforge.net |
|
||||
| Founder: Brent R. Matzelle (original founder) |
|
||||
| Copyright (c) 2004-2009, Andy Prevost. All Rights Reserved. |
|
||||
| Copyright (c) 2001-2003, Brent R. Matzelle |
|
||||
| ------------------------------------------------------------------------- |
|
||||
| License: Distributed under the Lesser General Public License (LGPL) |
|
||||
| http://www.gnu.org/copyleft/lesser.html |
|
||||
| This program is distributed in the hope that it will be useful - WITHOUT |
|
||||
| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
||||
| FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| ------------------------------------------------------------------------- |
|
||||
| We offer a number of paid services (www.codeworxtech.com): |
|
||||
| - Web Hosting on highly optimized fast and secure servers |
|
||||
| - Technology Consulting |
|
||||
| - Oursourcing (highly qualified programmers and graphic designers) |
|
||||
'---------------------------------------------------------------------------'
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPMailer - PHP SMTP email transport class
|
||||
* NOTE: Designed for use with PHP version 5 and up
|
||||
* @package PHPMailer
|
||||
* @author Andy Prevost
|
||||
* @author Marcus Bointon
|
||||
* @copyright 2004 - 2008 Andy Prevost
|
||||
* @license http://www.gnu.org/copyleft/lesser.html Distributed under the Lesser General Public License (LGPL)
|
||||
* @version $Id: class.smtp.php 444 2009-05-05 11:22:26Z coolbru $
|
||||
*/
|
||||
|
||||
/**
|
||||
* SMTP is rfc 821 compliant and implements all the rfc 821 SMTP
|
||||
* commands except TURN which will always return a not implemented
|
||||
* error. SMTP also provides some utility methods for sending mail
|
||||
* to an SMTP server.
|
||||
* original author: Chris Ryan
|
||||
*/
|
||||
|
||||
class SMTP {
|
||||
/**
|
||||
* SMTP server port
|
||||
* @var int
|
||||
*/
|
||||
public $SMTP_PORT = 25;
|
||||
|
||||
/**
|
||||
* SMTP reply line ending
|
||||
* @var string
|
||||
*/
|
||||
public $CRLF = "\r\n";
|
||||
|
||||
/**
|
||||
* Sets whether debugging is turned on
|
||||
* @var bool
|
||||
*/
|
||||
public $do_debug; // the level of debug to perform
|
||||
|
||||
/**
|
||||
* Sets VERP use on/off (default is off)
|
||||
* @var bool
|
||||
*/
|
||||
public $do_verp = false;
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// PROPERTIES, PRIVATE AND PROTECTED
|
||||
/////////////////////////////////////////////////
|
||||
|
||||
private $smtp_conn; // the socket to the server
|
||||
private $error; // error if any on the last call
|
||||
private $helo_rply; // the reply the server sent to us for HELO
|
||||
|
||||
/**
|
||||
* Initialize the class so that the data is in a known state.
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->smtp_conn = 0;
|
||||
$this->error = null;
|
||||
$this->helo_rply = null;
|
||||
|
||||
$this->do_debug = 0;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// CONNECTION FUNCTIONS
|
||||
/////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Connect to the server specified on the port specified.
|
||||
* If the port is not specified use the default SMTP_PORT.
|
||||
* If tval is specified then a connection will try and be
|
||||
* established with the server for that number of seconds.
|
||||
* If tval is not specified the default is 30 seconds to
|
||||
* try on the connection.
|
||||
*
|
||||
* SMTP CODE SUCCESS: 220
|
||||
* SMTP CODE FAILURE: 421
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function Connect($host, $port = 0, $tval = 30) {
|
||||
// set the error val to null so there is no confusion
|
||||
$this->error = null;
|
||||
|
||||
// make sure we are __not__ connected
|
||||
if($this->connected()) {
|
||||
// already connected, generate error
|
||||
$this->error = array("error" => "Already connected to a server");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(empty($port)) {
|
||||
$port = $this->SMTP_PORT;
|
||||
}
|
||||
|
||||
// connect to the smtp server
|
||||
$this->smtp_conn = @fsockopen($host, // the host of the server
|
||||
$port, // the port to use
|
||||
$errno, // error number if any
|
||||
$errstr, // error message if any
|
||||
$tval); // give up after ? secs
|
||||
// verify we connected properly
|
||||
if(empty($this->smtp_conn)) {
|
||||
$this->error = array("error" => "Failed to connect to server",
|
||||
"errno" => $errno,
|
||||
"errstr" => $errstr);
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": $errstr ($errno)" . $this->CRLF . '<br />';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// SMTP server can take longer to respond, give longer timeout for first read
|
||||
// Windows does not have support for this timeout function
|
||||
if(substr(PHP_OS, 0, 3) != "WIN")
|
||||
socket_set_timeout($this->smtp_conn, $tval, 0);
|
||||
|
||||
// get any announcement
|
||||
$announce = $this->get_lines();
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $announce . $this->CRLF . '<br />';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initiate a TLS communication with the server.
|
||||
*
|
||||
* SMTP CODE 220 Ready to start TLS
|
||||
* SMTP CODE 501 Syntax error (no parameters allowed)
|
||||
* SMTP CODE 454 TLS not available due to temporary reason
|
||||
* @access public
|
||||
* @return bool success
|
||||
*/
|
||||
public function StartTLS() {
|
||||
$this->error = null; # to avoid confusion
|
||||
|
||||
if(!$this->connected()) {
|
||||
$this->error = array("error" => "Called StartTLS() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
fputs($this->smtp_conn,"STARTTLS" . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
|
||||
if($code != 220) {
|
||||
$this->error =
|
||||
array("error" => "STARTTLS not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Begin encrypted connection
|
||||
if(!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs SMTP authentication. Must be run after running the
|
||||
* Hello() method. Returns true if successfully authenticated.
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function Authenticate($username, $password) {
|
||||
// Start authentication
|
||||
fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
|
||||
if($code != 334) {
|
||||
$this->error =
|
||||
array("error" => "AUTH not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Send encoded username
|
||||
fputs($this->smtp_conn, base64_encode($username) . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
|
||||
if($code != 334) {
|
||||
$this->error =
|
||||
array("error" => "Username not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Send encoded password
|
||||
fputs($this->smtp_conn, base64_encode($password) . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
|
||||
if($code != 235) {
|
||||
$this->error =
|
||||
array("error" => "Password not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if connected to a server otherwise false
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function Connected() {
|
||||
if(!empty($this->smtp_conn)) {
|
||||
$sock_status = socket_get_status($this->smtp_conn);
|
||||
if($sock_status["eof"]) {
|
||||
// the socket is valid but we are not connected
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> NOTICE:" . $this->CRLF . "EOF caught while checking if connected";
|
||||
}
|
||||
$this->Close();
|
||||
return false;
|
||||
}
|
||||
return true; // everything looks good
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the socket and cleans up the state of the class.
|
||||
* It is not considered good to use this function without
|
||||
* first trying to use QUIT.
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function Close() {
|
||||
$this->error = null; // so there is no confusion
|
||||
$this->helo_rply = null;
|
||||
if(!empty($this->smtp_conn)) {
|
||||
// close the connection and cleanup
|
||||
fclose($this->smtp_conn);
|
||||
$this->smtp_conn = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// SMTP COMMANDS
|
||||
/////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Issues a data command and sends the msg_data to the server
|
||||
* finializing the mail transaction. $msg_data is the message
|
||||
* that is to be send with the headers. Each header needs to be
|
||||
* on a single line followed by a <CRLF> with the message headers
|
||||
* and the message body being seperated by and additional <CRLF>.
|
||||
*
|
||||
* Implements rfc 821: DATA <CRLF>
|
||||
*
|
||||
* SMTP CODE INTERMEDIATE: 354
|
||||
* [data]
|
||||
* <CRLF>.<CRLF>
|
||||
* SMTP CODE SUCCESS: 250
|
||||
* SMTP CODE FAILURE: 552,554,451,452
|
||||
* SMTP CODE FAILURE: 451,554
|
||||
* SMTP CODE ERROR : 500,501,503,421
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function Data($msg_data) {
|
||||
$this->error = null; // so no confusion is caused
|
||||
|
||||
if(!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called Data() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
fputs($this->smtp_conn,"DATA" . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
|
||||
if($code != 354) {
|
||||
$this->error =
|
||||
array("error" => "DATA command not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* the server is ready to accept data!
|
||||
* according to rfc 821 we should not send more than 1000
|
||||
* including the CRLF
|
||||
* characters on a single line so we will break the data up
|
||||
* into lines by \r and/or \n then if needed we will break
|
||||
* each of those into smaller lines to fit within the limit.
|
||||
* in addition we will be looking for lines that start with
|
||||
* a period '.' and append and additional period '.' to that
|
||||
* line. NOTE: this does not count towards limit.
|
||||
*/
|
||||
|
||||
// normalize the line breaks so we know the explode works
|
||||
$msg_data = str_replace("\r\n","\n",$msg_data);
|
||||
$msg_data = str_replace("\r","\n",$msg_data);
|
||||
$lines = explode("\n",$msg_data);
|
||||
|
||||
/* we need to find a good way to determine is headers are
|
||||
* in the msg_data or if it is a straight msg body
|
||||
* currently I am assuming rfc 822 definitions of msg headers
|
||||
* and if the first field of the first line (':' sperated)
|
||||
* does not contain a space then it _should_ be a header
|
||||
* and we can process all lines before a blank "" line as
|
||||
* headers.
|
||||
*/
|
||||
|
||||
$field = substr($lines[0],0,strpos($lines[0],":"));
|
||||
$in_headers = false;
|
||||
if(!empty($field) && !strstr($field," ")) {
|
||||
$in_headers = true;
|
||||
}
|
||||
|
||||
$max_line_length = 998; // used below; set here for ease in change
|
||||
|
||||
while(list(,$line) = @each($lines)) {
|
||||
$lines_out = null;
|
||||
if($line == "" && $in_headers) {
|
||||
$in_headers = false;
|
||||
}
|
||||
// ok we need to break this line up into several smaller lines
|
||||
while(strlen($line) > $max_line_length) {
|
||||
$pos = strrpos(substr($line,0,$max_line_length)," ");
|
||||
|
||||
// Patch to fix DOS attack
|
||||
if(!$pos) {
|
||||
$pos = $max_line_length - 1;
|
||||
$lines_out[] = substr($line,0,$pos);
|
||||
$line = substr($line,$pos);
|
||||
} else {
|
||||
$lines_out[] = substr($line,0,$pos);
|
||||
$line = substr($line,$pos + 1);
|
||||
}
|
||||
|
||||
/* if processing headers add a LWSP-char to the front of new line
|
||||
* rfc 822 on long msg headers
|
||||
*/
|
||||
if($in_headers) {
|
||||
$line = "\t" . $line;
|
||||
}
|
||||
}
|
||||
$lines_out[] = $line;
|
||||
|
||||
// send the lines to the server
|
||||
while(list(,$line_out) = @each($lines_out)) {
|
||||
if(strlen($line_out) > 0)
|
||||
{
|
||||
if(substr($line_out, 0, 1) == ".") {
|
||||
$line_out = "." . $line_out;
|
||||
}
|
||||
}
|
||||
fputs($this->smtp_conn,$line_out . $this->CRLF);
|
||||
}
|
||||
}
|
||||
|
||||
// message data has been sent
|
||||
fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
|
||||
if($code != 250) {
|
||||
$this->error =
|
||||
array("error" => "DATA not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the HELO command to the smtp server.
|
||||
* This makes sure that we and the server are in
|
||||
* the same known state.
|
||||
*
|
||||
* Implements from rfc 821: HELO <SP> <domain> <CRLF>
|
||||
*
|
||||
* SMTP CODE SUCCESS: 250
|
||||
* SMTP CODE ERROR : 500, 501, 504, 421
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function Hello($host = '') {
|
||||
$this->error = null; // so no confusion is caused
|
||||
|
||||
if(!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called Hello() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
// if hostname for HELO was not specified send default
|
||||
if(empty($host)) {
|
||||
// determine appropriate default to send to server
|
||||
$host = "localhost";
|
||||
}
|
||||
|
||||
// Send extended hello first (RFC 2821)
|
||||
if(!$this->SendHello("EHLO", $host)) {
|
||||
if(!$this->SendHello("HELO", $host)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a HELO/EHLO command.
|
||||
* @access private
|
||||
* @return bool
|
||||
*/
|
||||
private function SendHello($hello, $host) {
|
||||
fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER: " . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
|
||||
if($code != 250) {
|
||||
$this->error =
|
||||
array("error" => $hello . " not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->helo_rply = $rply;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a mail transaction from the email address specified in
|
||||
* $from. Returns true if successful or false otherwise. If True
|
||||
* the mail transaction is started and then one or more Recipient
|
||||
* commands may be called followed by a Data command.
|
||||
*
|
||||
* Implements rfc 821: MAIL <SP> FROM:<reverse-path> <CRLF>
|
||||
*
|
||||
* SMTP CODE SUCCESS: 250
|
||||
* SMTP CODE SUCCESS: 552,451,452
|
||||
* SMTP CODE SUCCESS: 500,501,421
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function Mail($from) {
|
||||
$this->error = null; // so no confusion is caused
|
||||
|
||||
if(!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called Mail() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
$useVerp = ($this->do_verp ? "XVERP" : "");
|
||||
fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
|
||||
if($code != 250) {
|
||||
$this->error =
|
||||
array("error" => "MAIL not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the quit command to the server and then closes the socket
|
||||
* if there is no error or the $close_on_error argument is true.
|
||||
*
|
||||
* Implements from rfc 821: QUIT <CRLF>
|
||||
*
|
||||
* SMTP CODE SUCCESS: 221
|
||||
* SMTP CODE ERROR : 500
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function Quit($close_on_error = true) {
|
||||
$this->error = null; // so there is no confusion
|
||||
|
||||
if(!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called Quit() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
// send the quit command to the server
|
||||
fputs($this->smtp_conn,"quit" . $this->CRLF);
|
||||
|
||||
// get any good-bye messages
|
||||
$byemsg = $this->get_lines();
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $byemsg . $this->CRLF . '<br />';
|
||||
}
|
||||
|
||||
$rval = true;
|
||||
$e = null;
|
||||
|
||||
$code = substr($byemsg,0,3);
|
||||
if($code != 221) {
|
||||
// use e as a tmp var cause Close will overwrite $this->error
|
||||
$e = array("error" => "SMTP server rejected quit command",
|
||||
"smtp_code" => $code,
|
||||
"smtp_rply" => substr($byemsg,4));
|
||||
$rval = false;
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $e["error"] . ": " . $byemsg . $this->CRLF . '<br />';
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($e) || $close_on_error) {
|
||||
$this->Close();
|
||||
}
|
||||
|
||||
return $rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the command RCPT to the SMTP server with the TO: argument of $to.
|
||||
* Returns true if the recipient was accepted false if it was rejected.
|
||||
*
|
||||
* Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF>
|
||||
*
|
||||
* SMTP CODE SUCCESS: 250,251
|
||||
* SMTP CODE FAILURE: 550,551,552,553,450,451,452
|
||||
* SMTP CODE ERROR : 500,501,503,421
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function Recipient($to) {
|
||||
$this->error = null; // so no confusion is caused
|
||||
|
||||
if(!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called Recipient() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
|
||||
if($code != 250 && $code != 251) {
|
||||
$this->error =
|
||||
array("error" => "RCPT not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the RSET command to abort and transaction that is
|
||||
* currently in progress. Returns true if successful false
|
||||
* otherwise.
|
||||
*
|
||||
* Implements rfc 821: RSET <CRLF>
|
||||
*
|
||||
* SMTP CODE SUCCESS: 250
|
||||
* SMTP CODE ERROR : 500,501,504,421
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function Reset() {
|
||||
$this->error = null; // so no confusion is caused
|
||||
|
||||
if(!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called Reset() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
fputs($this->smtp_conn,"RSET" . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
|
||||
if($code != 250) {
|
||||
$this->error =
|
||||
array("error" => "RSET failed",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a mail transaction from the email address specified in
|
||||
* $from. Returns true if successful or false otherwise. If True
|
||||
* the mail transaction is started and then one or more Recipient
|
||||
* commands may be called followed by a Data command. This command
|
||||
* will send the message to the users terminal if they are logged
|
||||
* in and send them an email.
|
||||
*
|
||||
* Implements rfc 821: SAML <SP> FROM:<reverse-path> <CRLF>
|
||||
*
|
||||
* SMTP CODE SUCCESS: 250
|
||||
* SMTP CODE SUCCESS: 552,451,452
|
||||
* SMTP CODE SUCCESS: 500,501,502,421
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function SendAndMail($from) {
|
||||
$this->error = null; // so no confusion is caused
|
||||
|
||||
if(!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called SendAndMail() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
|
||||
if($code != 250) {
|
||||
$this->error =
|
||||
array("error" => "SAML not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is an optional command for SMTP that this class does not
|
||||
* support. This method is here to make the RFC821 Definition
|
||||
* complete for this class and __may__ be implimented in the future
|
||||
*
|
||||
* Implements from rfc 821: TURN <CRLF>
|
||||
*
|
||||
* SMTP CODE SUCCESS: 250
|
||||
* SMTP CODE FAILURE: 502
|
||||
* SMTP CODE ERROR : 500, 503
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function Turn() {
|
||||
$this->error = array("error" => "This method, TURN, of the SMTP ".
|
||||
"is not implemented");
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF . '<br />';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current error
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getError() {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// INTERNAL FUNCTIONS
|
||||
/////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Read in as many lines as possible
|
||||
* either before eof or socket timeout occurs on the operation.
|
||||
* With SMTP we can tell if we have more lines to read if the
|
||||
* 4th character is '-' symbol. If it is a space then we don't
|
||||
* need to read anything else.
|
||||
* @access private
|
||||
* @return string
|
||||
*/
|
||||
private function get_lines() {
|
||||
$data = "";
|
||||
while($str = @fgets($this->smtp_conn,515)) {
|
||||
if($this->do_debug >= 4) {
|
||||
echo "SMTP -> get_lines(): \$data was \"$data\"" . $this->CRLF . '<br />';
|
||||
echo "SMTP -> get_lines(): \$str is \"$str\"" . $this->CRLF . '<br />';
|
||||
}
|
||||
$data .= $str;
|
||||
if($this->do_debug >= 4) {
|
||||
echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF . '<br />';
|
||||
}
|
||||
// if 4th character is a space, we are done reading, break the loop
|
||||
if(substr($str,3,1) == " ") { break; }
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
391
classes/cliente.class.php
Executable file
391
classes/cliente.class.php
Executable file
@@ -0,0 +1,391 @@
|
||||
<?php
|
||||
|
||||
class Cliente extends Main
|
||||
{
|
||||
private $clienteId;
|
||||
private $nombre;
|
||||
private $rfc;
|
||||
private $telefono;
|
||||
private $email;
|
||||
private $userId;
|
||||
private $rfcId;
|
||||
private $password;
|
||||
|
||||
private $razonSocial;
|
||||
private $calle;
|
||||
private $noInt;
|
||||
private $noExt;
|
||||
private $referencia;
|
||||
private $colonia;
|
||||
private $localidad;
|
||||
private $municipio;
|
||||
private $ciudad;
|
||||
private $estado;
|
||||
private $pais;
|
||||
private $codigoPostal;
|
||||
|
||||
public function setClienteId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->clienteId = $value;
|
||||
}
|
||||
|
||||
public function setNombre($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, "Nombre");
|
||||
$this->nombre = $value;
|
||||
}
|
||||
|
||||
public function setRfc($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=17, $minChars = 1, "RFC");
|
||||
$this->rfc = $value;
|
||||
}
|
||||
|
||||
public function setEmail($value)
|
||||
{
|
||||
if(trim($value) != '')
|
||||
$this->Util()->ValidateMail($value, 'Correo Electrónico');
|
||||
$this->email = $value;
|
||||
}
|
||||
|
||||
public function setPassword($value)
|
||||
{
|
||||
$this->password = $value;
|
||||
}
|
||||
|
||||
public function setTelefono($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, "Telefono");
|
||||
$this->telefono = $value;
|
||||
}
|
||||
|
||||
public function setRazonSocial($value, $checkIfExists = 0)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=300, $minChars = 1, 'Razón Social');
|
||||
$this->razonSocial = $value;
|
||||
}
|
||||
|
||||
public function setCalle($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=200, $minChars = 0, 'Dirección');
|
||||
$this->calle = $value;
|
||||
}
|
||||
|
||||
public function setNoInt($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'No. Interior');
|
||||
$this->noInt = $value;
|
||||
}
|
||||
|
||||
public function setNoExt($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'No. Exterior');
|
||||
$this->noExt = $value;
|
||||
}
|
||||
|
||||
public function setLocalidad($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'Localidad');
|
||||
$this->localidad = $value;
|
||||
}
|
||||
|
||||
public function setColonia($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'Colonia');
|
||||
$this->colonia = $value;
|
||||
}
|
||||
|
||||
public function setReferencia($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'Referencia');
|
||||
$this->referencia = $value;
|
||||
}
|
||||
|
||||
public function setMunicipio($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'Municipio');
|
||||
$this->municipio = $value;
|
||||
}
|
||||
|
||||
public function setCiudad($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'Ciudad');
|
||||
$this->ciudad = $value;
|
||||
}
|
||||
|
||||
public function setEstado($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'Estado');
|
||||
$this->estado = $value;
|
||||
}
|
||||
|
||||
public function setPais($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'Pais');
|
||||
$this->pais = $value;
|
||||
}
|
||||
|
||||
public function setCodigoPostal($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'Código Postal');
|
||||
$this->codigoPostal = $value;
|
||||
}
|
||||
|
||||
function Info()
|
||||
{
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT * FROM cliente WHERE clienteId ='".$this->clienteId."'");
|
||||
$cliente = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $cliente;
|
||||
}
|
||||
|
||||
function Enumerate()
|
||||
{
|
||||
$sql = "SELECT COUNT(*) FROM cliente WHERE baja = '0'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
$pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/clientes");
|
||||
|
||||
$sqlAdd = " LIMIT ".$pages["start"].", ".$pages["items_per_page"];
|
||||
|
||||
$sql = "SELECT * FROM cliente WHERE baja = '0' ORDER BY nombre ASC".$sqlAdd;
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$clientes = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$data["items"] = $clientes;
|
||||
$data["pages"] = $pages;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function Save()
|
||||
{
|
||||
if($this->Util()->PrintErrors())
|
||||
return false;
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("
|
||||
INSERT INTO `cliente` (
|
||||
`rfc`,
|
||||
`nombre`,
|
||||
`pais`,
|
||||
`calle`,
|
||||
`noInt`,
|
||||
`noExt`,
|
||||
`referencia`,
|
||||
`colonia`,
|
||||
`localidad`,
|
||||
`municipio`,
|
||||
`estado`,
|
||||
`cp`,
|
||||
`email`,
|
||||
`telefono`,
|
||||
`password`
|
||||
)
|
||||
VALUES (
|
||||
'".$this->rfc."',
|
||||
'".$this->razonSocial."',
|
||||
'".$this->pais."',
|
||||
'".$this->calle."',
|
||||
'".$this->noInt."',
|
||||
'".$this->noExt."',
|
||||
'".$this->referencia."',
|
||||
'".$this->colonia."',
|
||||
'".$this->localidad."',
|
||||
'".$this->municipio."',
|
||||
'".$this->estado."',
|
||||
'".$this->codigoPostal."',
|
||||
'".$this->email."',
|
||||
'".$this->telefono."',
|
||||
'".$this->password."'
|
||||
)"
|
||||
);
|
||||
|
||||
$clienteId = $this->Util()->DBSelect($_SESSION["empresaId"])->InsertData();
|
||||
$this->Util()->setError(20020, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return $clienteId;
|
||||
}
|
||||
|
||||
function Delete()
|
||||
{
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("DELETE FROM cliente WHERE clienteId = '".$this->clienteId."'");
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$this->Util()->setError(20021, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function Baja(){
|
||||
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
|
||||
UPDATE cliente SET
|
||||
baja = '1'
|
||||
WHERE
|
||||
clienteId = '".$this->clienteId."'"
|
||||
);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData();
|
||||
|
||||
$this->Util()->setError(20021, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}//Baja
|
||||
|
||||
function GetClteNameById()
|
||||
{
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT nombre FROM cliente WHERE clienteId ='".$this->clienteId."'");
|
||||
$nombre = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $nombre;
|
||||
}
|
||||
|
||||
function Update()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){ return false; }
|
||||
|
||||
if($this->password)
|
||||
{
|
||||
$addPassword = " `password` ='".$this->password."',";
|
||||
}
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("
|
||||
UPDATE `cliente` SET
|
||||
`nombre` = '".$this->razonSocial."',
|
||||
`pais` = '".$this->pais."',
|
||||
`calle` = '".$this->calle."',
|
||||
`noInt` = '".$this->noInt."',
|
||||
`noExt` = '".$this->noExt."',
|
||||
`referencia` = '".$this->referencia."',
|
||||
`colonia` = '".$this->colonia."',
|
||||
`localidad` = '".$this->localidad."',
|
||||
`telefono` = '".$this->telefono."',
|
||||
".$addPassword."
|
||||
`municipio` = '".$this->municipio."',
|
||||
`estado` = '".$this->estado."',
|
||||
`cp` = '".$this->codigoPostal."',
|
||||
`email` = '".$this->email."',
|
||||
`rfc` = '".$this->rfc."'
|
||||
WHERE clienteId = '".$this->clienteId."'"
|
||||
);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
|
||||
|
||||
$this->Util()->setError(20022, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
return true;
|
||||
}
|
||||
|
||||
function Search()
|
||||
{
|
||||
$sql = "SELECT
|
||||
*
|
||||
FROM
|
||||
cliente
|
||||
WHERE
|
||||
baja = '0'
|
||||
AND
|
||||
(
|
||||
nombre LIKE '%".$this->nombre."%' || rfc LIKE '%".$this->nombre."%'
|
||||
)
|
||||
ORDER BY
|
||||
nombre ASC
|
||||
LIMIT
|
||||
20";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$clientes = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$data["items"] = $clientes;
|
||||
$data["pages"] = array();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function Suggest($value)
|
||||
{
|
||||
$sql = "SELECT
|
||||
*
|
||||
FROM
|
||||
cliente
|
||||
WHERE
|
||||
baja = '0'
|
||||
AND
|
||||
(
|
||||
nombre LIKE '%".$value."%'
|
||||
OR rfc LIKE '%".$value."%'
|
||||
)
|
||||
ORDER BY
|
||||
nombre
|
||||
LIMIT 10";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function LoginFactura()
|
||||
{
|
||||
$generalDb = new DB;
|
||||
|
||||
$sql = "SELECT
|
||||
*
|
||||
FROM
|
||||
cliente
|
||||
WHERE
|
||||
rfc = '".$this->rfc."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$info = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
$_SESSION['loginKey'] = $info['clienteId'];
|
||||
$_SESSION['tipoUsr'] = 'Cliente';
|
||||
$_SESSION['rfcClte'] = $this->rfc;
|
||||
|
||||
$sql = "SELECT * FROM empresa
|
||||
WHERE empresaId = '".$_SESSION["empresaId"]."'";
|
||||
$generalDb->setQuery($sql);
|
||||
$infE = $generalDb->GetRow();
|
||||
|
||||
$_SESSION["version"] = $infE["version"];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function ExistRfc()
|
||||
{
|
||||
$sql = "SELECT clienteId FROM cliente
|
||||
WHERE rfc = '".$this->rfc."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$clienteId = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $clienteId;
|
||||
}
|
||||
|
||||
function EnumFacturasByClte()
|
||||
{
|
||||
$sql = "SELECT COUNT(*) FROM comprobante WHERE userId = '".$this->clienteId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
$pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/clientes");
|
||||
|
||||
$sqlAdd = " LIMIT ".$pages["start"].", ".$pages["items_per_page"];
|
||||
|
||||
$sql = "SELECT * FROM comprobante WHERE userId = '".$this->clienteId."' ORDER BY fecha DESC".$sqlAdd;
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$clientes = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$data["items"] = $clientes;
|
||||
$data["pages"] = $pages;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
137
classes/color.class.php
Executable file
137
classes/color.class.php
Executable file
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
|
||||
class Color extends Main
|
||||
{
|
||||
private $colorId;
|
||||
private $nombre;
|
||||
|
||||
public function setColorId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->colorId = $value;
|
||||
}
|
||||
|
||||
public function setNombre($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, "Nombre");
|
||||
$this->nombre = $value;
|
||||
}
|
||||
|
||||
public function Info()
|
||||
{
|
||||
|
||||
$sql = 'SELECT
|
||||
*
|
||||
FROM
|
||||
color
|
||||
WHERE
|
||||
colorId = "'.$this->colorId.'"';
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$info = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
$row = $this->Util->EncodeRow($info);
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function EnumerateAll()
|
||||
{
|
||||
|
||||
$sql = 'SELECT
|
||||
*
|
||||
FROM
|
||||
color
|
||||
ORDER BY
|
||||
nombre ASC';
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function Enumerate()
|
||||
{
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT COUNT(*) FROM color");
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
$pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/colores");
|
||||
|
||||
$sqlAdd = "LIMIT ".$pages["start"].", ".$pages["items_per_page"];
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT * FROM color ORDER BY nombre ASC ".$sqlAdd);
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$data["items"] = $result;
|
||||
$data["pages"] = $pages;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function Save()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){ return false; }
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("
|
||||
INSERT INTO `color` (
|
||||
`nombre`
|
||||
)
|
||||
VALUES (
|
||||
'".utf8_decode($this->nombre)."'
|
||||
)"
|
||||
);
|
||||
|
||||
$colorId = $this->Util()->DBSelect($_SESSION["empresaId"])->InsertData();
|
||||
|
||||
$this->Util()->setError(20046, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function Update()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){ return false; }
|
||||
|
||||
$sql = "
|
||||
UPDATE `color` SET
|
||||
`nombre` = '".utf8_decode($this->nombre)."'
|
||||
WHERE colorId = '".$this->colorId."'
|
||||
";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
|
||||
|
||||
$this->Util()->setError(20047, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function Delete()
|
||||
{
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("
|
||||
DELETE FROM color
|
||||
WHERE colorId = '".$this->colorId."'"
|
||||
);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$this->Util()->setError(20048, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function GetNameById()
|
||||
{
|
||||
$sql = 'SELECT nombre FROM color
|
||||
WHERE colorId = "'.$this->colorId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$nombre = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $nombre;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
194
classes/comision.class.php
Executable file
194
classes/comision.class.php
Executable file
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
|
||||
class Comision extends Main
|
||||
{
|
||||
private $comisionId;
|
||||
private $tipoUsuario;
|
||||
private $comisionBajo;
|
||||
private $comisionAlto;
|
||||
private $rango;
|
||||
|
||||
function setComisionId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->comisionId = $value;
|
||||
}
|
||||
|
||||
function setTipoUsuario($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=300, $minChars = 1, 'Tipo Personal');
|
||||
$this->tipoUsuario = $value;
|
||||
}
|
||||
|
||||
function setComisionBajo($value)
|
||||
{
|
||||
$this->comisionBajo = $value;
|
||||
}
|
||||
|
||||
function setComisionAlto($value)
|
||||
{
|
||||
$this->comisionAlto = $value;
|
||||
}
|
||||
|
||||
function setRango($value)
|
||||
{
|
||||
$this->rango = $value;
|
||||
}
|
||||
|
||||
function Info(){
|
||||
|
||||
$sql = "SELECT
|
||||
*
|
||||
FROM
|
||||
comision
|
||||
WHERE
|
||||
comisionId = '".$this->comisionId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$row = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
function EnumerateAll()
|
||||
{
|
||||
$sql = "SELECT * FROM comision WHERE baja = '0' ORDER BY comisionId ASC";
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$atributos = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $atributos;
|
||||
}
|
||||
|
||||
function Enumerate()
|
||||
{
|
||||
$sql = "SELECT COUNT(*) FROM comision WHERE baja = '0'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
$pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/comisiones");
|
||||
|
||||
$sqlAdd = " LIMIT ".$pages["start"].", ".$pages["items_per_page"];
|
||||
|
||||
$sql = "SELECT * FROM comision WHERE baja = '0' ORDER BY comisionId ASC".$sqlAdd;
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$atributos = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$data["items"] = $atributos;
|
||||
$data["pages"] = $pages;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function Save(){
|
||||
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO `comision`
|
||||
(
|
||||
tipoUsuario,
|
||||
comisionBajo,
|
||||
comisionAlto,
|
||||
rango
|
||||
)
|
||||
VALUES (
|
||||
'".$this->tipoUsuario."',
|
||||
'".$this->comisionBajo."',
|
||||
'".$this->comisionAlto."',
|
||||
'".$this->rango."'
|
||||
)";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->ExecuteQuery();
|
||||
|
||||
$this->Util()->setError(30068, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function Update(){
|
||||
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = "UPDATE
|
||||
`comision`
|
||||
SET
|
||||
tipoUsuario = '".$this->tipoUsuario."',
|
||||
comisionBajo = '".$this->comisionBajo."',
|
||||
comisionAlto = '".$this->comisionAlto."',
|
||||
rango = '".$this->rango."'
|
||||
WHERE
|
||||
comisionId = ".$this->comisionId;
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->ExecuteQuery();
|
||||
|
||||
$this->Util()->setError(30069, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function Delete(){
|
||||
|
||||
echo $sql = "DELETE FROM
|
||||
comision
|
||||
WHERE
|
||||
comisionId = '".$this->comisionId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$this->Util()->setError(30070, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function Baja(){
|
||||
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
|
||||
UPDATE comision SET baja = '1'
|
||||
WHERE comisionId = '".$this->comisionId."'"
|
||||
);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData();
|
||||
|
||||
$this->Util()->setError(30070, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}//Baja
|
||||
|
||||
function getInfoGerente()
|
||||
{
|
||||
$sql = "SELECT * FROM comision WHERE tipoUsuario LIKE 'gerente'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$info = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
function getInfoSubgerente()
|
||||
{
|
||||
$sql = "SELECT * FROM comision WHERE tipoUsuario LIKE 'subgerente'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$info = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
function getInfoVendedor()
|
||||
{
|
||||
$sql = "SELECT * FROM comision WHERE tipoUsuario LIKE 'vendedor'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$info = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $info;
|
||||
}
|
||||
}//Atributo
|
||||
|
||||
?>
|
||||
1601
classes/comprobante.class.php
Executable file
1601
classes/comprobante.class.php
Executable file
File diff suppressed because it is too large
Load Diff
36
classes/config.class.php
Executable file
36
classes/config.class.php
Executable file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
class Config extends Main
|
||||
{
|
||||
private $configId;
|
||||
private $valor;
|
||||
|
||||
public function setConfigId($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, "Atributo");
|
||||
$this->atributoId = $value;
|
||||
}
|
||||
|
||||
public function setValor($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Valor');
|
||||
$this->valor = $value;
|
||||
}
|
||||
|
||||
function GetIva(){
|
||||
|
||||
$sql = "SELECT
|
||||
valor
|
||||
FROM
|
||||
configuracion
|
||||
WHERE
|
||||
configId = 1";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$iva = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $iva;
|
||||
}
|
||||
|
||||
}//Config
|
||||
|
||||
?>
|
||||
194
classes/conjuntoTalla.class.php
Executable file
194
classes/conjuntoTalla.class.php
Executable file
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
|
||||
class ConjuntoTalla extends Main
|
||||
{
|
||||
private $conTallaId;
|
||||
private $tallaId;
|
||||
private $nombre;
|
||||
|
||||
public function setConTallaId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->conTallaId = $value;
|
||||
}
|
||||
|
||||
public function setTallaId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->tallaId = $value;
|
||||
}
|
||||
|
||||
public function setNombre($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Nombre');
|
||||
$this->nombre = $value;
|
||||
}
|
||||
|
||||
function Info(){
|
||||
|
||||
$sql = "SELECT
|
||||
*
|
||||
FROM
|
||||
conjunto_talla
|
||||
WHERE
|
||||
conTallaId = '".$this->conTallaId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$row = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
function EnumerateAll()
|
||||
{
|
||||
$sql = "SELECT * FROM conjunto_talla ORDER BY nombre ASC";
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$atributos = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $atributos;
|
||||
}
|
||||
|
||||
function Enumerate()
|
||||
{
|
||||
$sql = "SELECT COUNT(*) FROM conjunto_talla WHERE baja = '0'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
$pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/conjunto-tallas");
|
||||
|
||||
$sqlAdd = " LIMIT ".$pages["start"].", ".$pages["items_per_page"];
|
||||
|
||||
$sql = "SELECT * FROM conjunto_talla WHERE baja = '0' ORDER BY nombre ASC".$sqlAdd;
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$atributos = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$data["items"] = $atributos;
|
||||
$data["pages"] = $pages;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function Save(){
|
||||
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO `conjunto_talla`
|
||||
(
|
||||
nombre
|
||||
)
|
||||
VALUES (
|
||||
'".utf8_decode($this->nombre)."'
|
||||
)";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$conTallaId = $this->Util()->DBSelect($_SESSION['empresaId'])->InsertData();
|
||||
|
||||
$this->Util()->setError(30048, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return $conTallaId;
|
||||
|
||||
}
|
||||
|
||||
function Update(){
|
||||
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
echo $sql = "UPDATE
|
||||
`conjunto_talla`
|
||||
SET
|
||||
nombre = '".utf8_decode($this->nombre)."'
|
||||
WHERE
|
||||
conTallaId = ".$this->conTallaId;
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->ExecuteQuery();
|
||||
|
||||
$this->Util()->setError(30049, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function Delete(){
|
||||
|
||||
$sql = "DELETE FROM
|
||||
conjunto_talla
|
||||
WHERE
|
||||
conTallaId = '".$this->conTallaId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$sql = "DELETE FROM
|
||||
conjunto_valor
|
||||
WHERE
|
||||
conTallaId = '".$this->conTallaId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$this->Util()->setError(30050, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function Baja(){
|
||||
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
|
||||
UPDATE conjunto_talla SET baja = '1'
|
||||
WHERE conTallaId = '".$this->conTallaId."'"
|
||||
);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData();
|
||||
|
||||
$this->Util()->setError(30050, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}//Baja
|
||||
|
||||
function GetNameById(){
|
||||
|
||||
$sql = "SELECT
|
||||
nombre
|
||||
FROM
|
||||
conjunto_talla
|
||||
WHERE
|
||||
conTallaId = '".$this->conTallaId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$name = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
//TALLAS
|
||||
|
||||
function SaveTalla(){
|
||||
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO conjunto_valor
|
||||
(
|
||||
conTallaId,
|
||||
tallaId
|
||||
)
|
||||
VALUES (
|
||||
'".$this->conTallaId."',
|
||||
'".$this->tallaId."'
|
||||
)";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->InsertData();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}//ConjuntoTalla
|
||||
|
||||
?>
|
||||
68
classes/conjuntoValor.class.php
Executable file
68
classes/conjuntoValor.class.php
Executable file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
class ConjuntoValor extends Main
|
||||
{
|
||||
private $conTallaId;
|
||||
private $tallaId;
|
||||
private $nombre;
|
||||
|
||||
public function setConTallaId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->conTallaId = $value;
|
||||
}
|
||||
|
||||
public function setTallaId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->tallaId = $value;
|
||||
}
|
||||
|
||||
function EnumerateAll()
|
||||
{
|
||||
$sql = "SELECT * FROM conjunto_valor WHERE conTallaId = '".$this->conTallaId."'";
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$tallas = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $tallas;
|
||||
}
|
||||
|
||||
function Save(){
|
||||
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO conjunto_valor
|
||||
(
|
||||
conTallaId,
|
||||
tallaId
|
||||
)
|
||||
VALUES (
|
||||
'".$this->conTallaId."',
|
||||
'".$this->tallaId."'
|
||||
)";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->InsertData();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function DeleteAll(){
|
||||
|
||||
$sql = "DELETE FROM
|
||||
conjunto_valor
|
||||
WHERE
|
||||
conTallaId = '".$this->conTallaId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}//ConjuntoValor
|
||||
|
||||
?>
|
||||
201
classes/cuentaBancaria.class.php
Executable file
201
classes/cuentaBancaria.class.php
Executable file
@@ -0,0 +1,201 @@
|
||||
<?php
|
||||
|
||||
class CuentaBancaria extends Main
|
||||
{
|
||||
private $cuentaBancariaId;
|
||||
private $banco;
|
||||
private $noCuenta;
|
||||
private $sucursal;
|
||||
private $titular;
|
||||
private $clabe;
|
||||
|
||||
public function setCuentaBancariaId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->cuentaBancariaId = $value;
|
||||
}
|
||||
|
||||
public function setBanco($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Nombre del Banco');
|
||||
$this->banco = $value;
|
||||
}
|
||||
|
||||
public function setNoCuenta($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'No. de Cuenta');
|
||||
$this->noCuenta = $value;
|
||||
}
|
||||
|
||||
public function setSucursal($value)
|
||||
{
|
||||
$this->sucursal = $value;
|
||||
}
|
||||
|
||||
public function setTitular($value)
|
||||
{
|
||||
$this->titular = $value;
|
||||
}
|
||||
|
||||
public function setClabe($value)
|
||||
{
|
||||
$this->clabe = $value;
|
||||
}
|
||||
|
||||
public function Info()
|
||||
{
|
||||
$sql = 'SELECT
|
||||
*
|
||||
FROM
|
||||
cuentaBancaria
|
||||
WHERE
|
||||
cuentaBancariaId = "'.$this->cuentaBancariaId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$info = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
public function EnumerateAll()
|
||||
{
|
||||
|
||||
$sql = 'SELECT
|
||||
*
|
||||
FROM
|
||||
cuentaBancaria
|
||||
WHERE
|
||||
baja = "0"
|
||||
ORDER BY
|
||||
banco ASC';
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function Enumerate()
|
||||
{
|
||||
$sql = "SELECT COUNT(*) FROM cuentaBancaria WHERE baja = '0'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
$pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/cuentas-bancarias");
|
||||
|
||||
$sqlAdd = "LIMIT ".$pages["start"].", ".$pages["items_per_page"];
|
||||
|
||||
$sql = "SELECT * FROM cuentaBancaria WHERE baja = '0' ORDER BY banco ASC ".$sqlAdd;
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$data["items"] = $result;
|
||||
$data["pages"] = $pages;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function Save()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){ return false; }
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("
|
||||
INSERT INTO `cuentaBancaria` (
|
||||
banco,
|
||||
noCuenta,
|
||||
sucursal,
|
||||
titular,
|
||||
clabe
|
||||
)
|
||||
VALUES (
|
||||
'".utf8_decode($this->banco)."',
|
||||
'".utf8_decode($this->noCuenta)."',
|
||||
'".utf8_decode($this->sucursal)."',
|
||||
'".utf8_decode($this->titular)."',
|
||||
'".utf8_decode($this->clabe)."'
|
||||
)"
|
||||
);
|
||||
$cuentaBancariaId = $this->Util()->DBSelect($_SESSION["empresaId"])->InsertData();
|
||||
|
||||
$this->Util()->setError(20049, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function Update()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){ return false; }
|
||||
|
||||
$sql = "
|
||||
UPDATE `cuentaBancaria` SET
|
||||
banco = '".utf8_decode($this->banco)."',
|
||||
noCuenta = '".utf8_decode($this->noCuenta)."',
|
||||
sucursal = '".utf8_decode($this->sucursal)."',
|
||||
titular = '".utf8_decode($this->titular)."',
|
||||
clabe = '".utf8_decode($this->clabe)."'
|
||||
WHERE
|
||||
cuentaBancariaId = '".$this->cuentaBancariaId."'
|
||||
";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
|
||||
|
||||
$this->Util()->setError(20050, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function Delete()
|
||||
{
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("
|
||||
DELETE FROM cuentaBancaria
|
||||
WHERE cuentaBancariaId = '".$this->cuentaBancariaId."'"
|
||||
);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$this->Util()->setError(20051, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function Baja(){
|
||||
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
|
||||
UPDATE cuentaBancaria SET
|
||||
baja = '1'
|
||||
WHERE
|
||||
cuentaBancariaId = '".$this->cuentaBancariaId."'"
|
||||
);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData();
|
||||
|
||||
$this->Util()->setError(20051, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}//Baja
|
||||
|
||||
function GetBancoById()
|
||||
{
|
||||
$sql = 'SELECT banco FROM cuentaBancaria
|
||||
WHERE cuentaBancariaId = "'.$this->cuentaBancariaId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$banco = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $banco;
|
||||
}
|
||||
|
||||
function GetNameById()
|
||||
{
|
||||
$sql = 'SELECT CONCAT(banco," ",noCuenta) FROM cuentaBancaria
|
||||
WHERE cuentaBancariaId = "'.$this->cuentaBancariaId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$name = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
459
classes/cuentaPagar.class.php
Executable file
459
classes/cuentaPagar.class.php
Executable file
@@ -0,0 +1,459 @@
|
||||
<?php
|
||||
|
||||
class CuentaPagar extends Main
|
||||
{
|
||||
private $pedidoId;
|
||||
private $pedidoPagoId;
|
||||
private $pedidoNotaId;
|
||||
private $provPagoId;
|
||||
private $metodoPagoId;
|
||||
private $cuentaBancariaId;
|
||||
private $proveedorId;
|
||||
private $cantidad;
|
||||
private $fecha;
|
||||
private $noCheque;
|
||||
private $noFactura;
|
||||
private $noNota;
|
||||
private $status;
|
||||
|
||||
public function setPedidoId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->pedidoId = $value;
|
||||
}
|
||||
|
||||
public function setPedidoPagoId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->pedidoPagoId = $value;
|
||||
}
|
||||
|
||||
public function setPedidoNotaId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->pedidoNotaId = $value;
|
||||
}
|
||||
|
||||
public function setProvPagoId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->provPagoId = $value;
|
||||
}
|
||||
|
||||
public function setMetodoPagoId($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Método de Pago');
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->metodoPagoId = $value;
|
||||
}
|
||||
|
||||
public function setCuentaBancariaId($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Cuenta Bancaria');
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->cuentaBancariaId = $value;
|
||||
}
|
||||
|
||||
public function setProveedorId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->proveedorId = $value;
|
||||
}
|
||||
|
||||
public function setCantidad($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Cantidad');
|
||||
$this->cantidad = $value;
|
||||
}
|
||||
|
||||
public function setFecha($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Fecha');
|
||||
$this->fecha = $value;
|
||||
}
|
||||
|
||||
public function setNoCheque($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'No. de Cheque');
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->noCheque = $value;
|
||||
}
|
||||
|
||||
public function setNoFactura($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'No. de Factura');
|
||||
$this->noFactura = $value;
|
||||
}
|
||||
|
||||
public function setNoNota($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'No. Nota de Crédito');
|
||||
$this->noNota = $value;
|
||||
}
|
||||
|
||||
public function setStatus($value)
|
||||
{
|
||||
$this->status = $value;
|
||||
}
|
||||
|
||||
public function InfoPago(){
|
||||
|
||||
$sql = 'SELECT * FROM pedidoPago
|
||||
WHERE pedidoPagoId = "'.$this->pedidoPagoId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$info = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
public function InfoPagoProv(){
|
||||
|
||||
$sql = 'SELECT * FROM proveedorPago
|
||||
WHERE provPagoId = "'.$this->provPagoId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$info = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
function Enumerate()
|
||||
{
|
||||
$sql = "SELECT COUNT(*) FROM pedido
|
||||
WHERE (status = 'OrdenCompIng'
|
||||
OR status = 'EnvSuc')
|
||||
AND ajuste = '0'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
$pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/cuentas-pagar");
|
||||
|
||||
$sqlAdd = "LIMIT ".$pages["start"].", ".$pages["items_per_page"];
|
||||
|
||||
$sql = "SELECT * FROM pedido
|
||||
WHERE (status = 'OrdenCompIng'
|
||||
OR status = 'EnvSuc')
|
||||
AND ajuste = '0'
|
||||
ORDER BY fecha ASC ".$sqlAdd;
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$data["items"] = $result;
|
||||
$data["pages"] = $pages;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function EnumPagos(){
|
||||
|
||||
$sql = 'SELECT * FROM pedidoPago
|
||||
WHERE pedidoId = "'.$this->pedidoId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$pagos = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $pagos;
|
||||
}
|
||||
|
||||
function EnumPagosProv(){
|
||||
|
||||
$sql = 'SELECT * FROM proveedorPago
|
||||
WHERE proveedorId = "'.$this->proveedorId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$pagos = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $pagos;
|
||||
}
|
||||
|
||||
function GetTotalPagos(){
|
||||
|
||||
$sql = 'SELECT SUM(cantidad) FROM pedidoPago
|
||||
WHERE pedidoId = "'.$this->pedidoId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
function GetTotalPagosProv(){
|
||||
|
||||
$sql = 'SELECT SUM(cantidad) FROM proveedorPago
|
||||
WHERE proveedorId = "'.$this->proveedorId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
function GetTotalPagosByProveedor(){
|
||||
|
||||
$sql = 'SELECT SUM(cantidad) FROM pedidoPago
|
||||
WHERE proveedorId = "'.$this->proveedorId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
function GetTotalByProveedor(){
|
||||
|
||||
$sql = 'SELECT SUM(total) FROM pedido
|
||||
WHERE (status = "OrdenCompIng"
|
||||
OR status = "EnvSuc")
|
||||
AND ajuste = "0"
|
||||
AND proveedorId = "'.$this->proveedorId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
function GetTotalBonifByProv()
|
||||
{
|
||||
$sql = 'SELECT SUM(totalBonificacion)
|
||||
FROM pedidoBonifDevolucion AS b, pedido AS p
|
||||
WHERE p.pedidoId = b.pedidoId
|
||||
AND (p.status = "OrdenCompIng"
|
||||
OR p.status = "EnvSuc")
|
||||
AND p.ajuste = "0"
|
||||
AND p.proveedorId = '.$this->proveedorId;
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
function GetTotalDevByProv()
|
||||
{
|
||||
$sql = 'SELECT SUM(totalDevolucion)
|
||||
FROM pedidoBonifDevolucion AS d, pedido AS p
|
||||
WHERE p.pedidoId = d.pedidoId
|
||||
AND (p.status = "OrdenCompIng"
|
||||
OR p.status = "EnvSuc")
|
||||
AND p.ajuste = "0"
|
||||
AND p.proveedorId = '.$this->proveedorId;
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
function SavePago()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){ return false; }
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("
|
||||
INSERT INTO `pedidoPago` (
|
||||
pedidoId,
|
||||
metodoPagoId,
|
||||
cuentaBancariaId,
|
||||
proveedorId,
|
||||
cantidad,
|
||||
fecha,
|
||||
noCheque,
|
||||
noFactura
|
||||
)
|
||||
VALUES (
|
||||
'".$this->pedidoId."',
|
||||
'".$this->metodoPagoId."',
|
||||
'".$this->cuentaBancariaId."',
|
||||
'".$this->proveedorId."',
|
||||
'".$this->cantidad."',
|
||||
'".$this->fecha."',
|
||||
'".$this->noCheque."',
|
||||
'".$this->noFactura."'
|
||||
)"
|
||||
);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->InsertData();
|
||||
|
||||
$this->Util()->setError(30057, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function DeletePago(){
|
||||
|
||||
$sql = "DELETE FROM
|
||||
pedidoPago
|
||||
WHERE
|
||||
pedidoPagoId = '".$this->pedidoPagoId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$this->Util()->setError(30059, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function SavePagoProv()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){ return false; }
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("
|
||||
INSERT INTO `proveedorPago` (
|
||||
proveedorId,
|
||||
metodoPagoId,
|
||||
cantidad,
|
||||
fecha,
|
||||
noCheque,
|
||||
noFactura
|
||||
)
|
||||
VALUES (
|
||||
'".$this->proveedorId."',
|
||||
'".$this->metodoPagoId."',
|
||||
'".$this->cantidad."',
|
||||
'".$this->fecha."',
|
||||
'".$this->noCheque."',
|
||||
'".$this->noFactura."'
|
||||
)"
|
||||
);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->InsertData();
|
||||
|
||||
$this->Util()->setError(30057, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function DeletePagoProv(){
|
||||
|
||||
$sql = "DELETE FROM
|
||||
proveedorPago
|
||||
WHERE
|
||||
provPagoId = '".$this->provPagoId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$this->Util()->setError(30059, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function EnumerateById()
|
||||
{
|
||||
$sql = "SELECT * FROM pedido
|
||||
WHERE (status = 'OrdenCompIng'
|
||||
OR status = 'EnvSuc') AND
|
||||
pedidoId = '".$this->pedidoId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function Search(){
|
||||
|
||||
if($this->proveedorId)
|
||||
$sqlFilter = ' AND proveedorId = "'.$this->proveedorId.'"';
|
||||
|
||||
$sql = "SELECT * FROM pedido
|
||||
WHERE (status = 'OrdenCompIng'
|
||||
OR status = 'EnvSuc')
|
||||
AND ajuste = '0'
|
||||
AND folioProv NOT REGEXP '^FOLIO'
|
||||
".$sqlFilter."
|
||||
ORDER BY fecha ASC ".$sqlAdd;
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function EnumProveedores()
|
||||
{
|
||||
if($this->proveedorId)
|
||||
$sqlFilter = ' AND proveedorId = "'.$this->proveedorId.'"';
|
||||
|
||||
$sql = "SELECT * FROM pedido
|
||||
WHERE (status = 'OrdenCompIng'
|
||||
OR status = 'EnvSuc')
|
||||
AND ajuste = '0'
|
||||
AND folioProv NOT REGEXP '^FOLIO'
|
||||
".$sqlFilter."
|
||||
GROUP BY proveedorId";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$proveedores = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
return $proveedores;
|
||||
}
|
||||
|
||||
//NOTAS CREDITO
|
||||
|
||||
function SaveNota()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){ return false; }
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("
|
||||
INSERT INTO `pedidoNota` (
|
||||
pedidoId,
|
||||
proveedorId,
|
||||
cantidad,
|
||||
fecha,
|
||||
noNota
|
||||
)
|
||||
VALUES (
|
||||
'".$this->pedidoId."',
|
||||
'".$this->proveedorId."',
|
||||
'".$this->cantidad."',
|
||||
'".$this->fecha."',
|
||||
'".$this->noNota."'
|
||||
)"
|
||||
);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->InsertData();
|
||||
|
||||
$this->Util()->setError(20122, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function DeleteNota(){
|
||||
|
||||
$sql = "DELETE FROM
|
||||
pedidoNota
|
||||
WHERE
|
||||
pedidoNotaId = '".$this->pedidoNotaId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$this->Util()->setError(20123, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function GetTotalNotas(){
|
||||
|
||||
$sql = 'SELECT SUM(cantidad) FROM pedidoNota
|
||||
WHERE pedidoId = "'.$this->pedidoId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
function EnumNotas(){
|
||||
|
||||
$sql = 'SELECT * FROM pedidoNota
|
||||
WHERE pedidoId = "'.$this->pedidoId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$pagos = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $pagos;
|
||||
}
|
||||
|
||||
public function InfoNota(){
|
||||
|
||||
$sql = 'SELECT * FROM pedidoNota
|
||||
WHERE pedidoNotaId = "'.$this->pedidoNotaId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$info = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
222
classes/db.class.php
Executable file
222
classes/db.class.php
Executable file
@@ -0,0 +1,222 @@
|
||||
<?php
|
||||
|
||||
class DB
|
||||
{
|
||||
public $query = NULL;
|
||||
private $sqlResult = NULL;
|
||||
|
||||
private $conn_id = false;
|
||||
|
||||
private $sqlHost;
|
||||
private $sqlDatabase;
|
||||
private $sqlUser;
|
||||
private $sqlPassword;
|
||||
|
||||
private $projectStatus = "test";
|
||||
|
||||
public function setSqlHost($value)
|
||||
{
|
||||
$this->sqlHost = $value;
|
||||
}
|
||||
|
||||
public function getSqlHost()
|
||||
{
|
||||
return $this->sqlHost;
|
||||
}
|
||||
|
||||
public function setSqlDatabase($value)
|
||||
{
|
||||
$this->sqlDatabase = $value;
|
||||
}
|
||||
|
||||
public function getSqlDatabase()
|
||||
{
|
||||
return $this->sqlDatabase;
|
||||
}
|
||||
|
||||
public function setSqlUser($value)
|
||||
{
|
||||
$this->sqlUser = $value;
|
||||
}
|
||||
|
||||
public function getSqlUser()
|
||||
{
|
||||
return $this->sqlUser;
|
||||
}
|
||||
|
||||
public function setSqlPassword($value)
|
||||
{
|
||||
$this->sqlPassword = $value;
|
||||
}
|
||||
|
||||
public function getSqlPassword()
|
||||
{
|
||||
return $this->sqlPassword;
|
||||
}
|
||||
|
||||
public function setQuery($value)
|
||||
{
|
||||
$this->query = $value;
|
||||
}
|
||||
|
||||
public function getQuery()
|
||||
{
|
||||
return $this->query;
|
||||
}
|
||||
|
||||
public function setProjectStatus($value)
|
||||
{
|
||||
$this->projectStatus = $value;
|
||||
}
|
||||
|
||||
public function getProjectStatus()
|
||||
{
|
||||
return $this->projectStatus;
|
||||
}
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$this->sqlHost = SQL_HOST;
|
||||
$this->sqlDatabase = SQL_DATABASE;
|
||||
$this->sqlUser = SQL_USER;
|
||||
$this->sqlPassword = SQL_PASSWORD;
|
||||
}
|
||||
|
||||
public function DatabaseConnect()
|
||||
{
|
||||
$this->conn_id = mysql_connect($this->sqlHost, $this->sqlUser, $this->sqlPassword, 1);
|
||||
mysql_select_db($this->sqlDatabase, $this->conn_id) or die("<br/>".mysql_error()."<br/>");
|
||||
}
|
||||
|
||||
public function ExecuteQuery()
|
||||
{
|
||||
if(!$this->conn_id)
|
||||
$this->DatabaseConnect();
|
||||
|
||||
|
||||
//TODO we might want to add some security in the queries here, but that can be done later, this is the place
|
||||
|
||||
if($this->projectStatus == "test")
|
||||
{
|
||||
//echo "<br><br>".$this->query."<br><br>";
|
||||
// print_r(debug_backtrace());
|
||||
$this->sqlResult = mysql_query($this->query, $this->conn_id) or die (trigger_error($this->query.mysql_error()));
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->sqlResult = @mysql_query($this->query, $this->conn_id);
|
||||
}
|
||||
}
|
||||
|
||||
function GetResult()
|
||||
{
|
||||
$retArray = array();
|
||||
|
||||
$this->ExecuteQuery();
|
||||
|
||||
while($rs=mysql_fetch_assoc($this->sqlResult))
|
||||
{
|
||||
$retArray[] = $rs;
|
||||
}
|
||||
|
||||
$this->CleanQuery();
|
||||
|
||||
return $retArray;
|
||||
}
|
||||
|
||||
function GetResultById($id = NULL)
|
||||
{
|
||||
$retArray = array();
|
||||
|
||||
$this->ExecuteQuery();
|
||||
|
||||
while($rs=mysql_fetch_assoc($this->sqlResult))
|
||||
{
|
||||
$retArray[$rs[$id]] = $rs;
|
||||
}
|
||||
|
||||
$this->CleanQuery();
|
||||
|
||||
return $retArray;
|
||||
}
|
||||
|
||||
function GetTotalRows()
|
||||
{
|
||||
$this->ExecuteQuery();
|
||||
|
||||
return mysql_num_rows($this->sqlResult);
|
||||
}
|
||||
|
||||
function GetRow()
|
||||
{
|
||||
$this->ExecuteQuery();
|
||||
|
||||
$rs=mysql_fetch_assoc($this->sqlResult);
|
||||
|
||||
$this->CleanQuery();
|
||||
|
||||
return $rs;
|
||||
}
|
||||
|
||||
function GetSingle()
|
||||
{
|
||||
$this->ExecuteQuery();
|
||||
|
||||
$rs=@mysql_result($this->sqlResult, 0);
|
||||
|
||||
if(!$rs)
|
||||
$rs = 0;
|
||||
|
||||
$this->CleanQuery();
|
||||
|
||||
return $rs;
|
||||
}
|
||||
|
||||
function InsertData()
|
||||
{
|
||||
$this->ExecuteQuery();
|
||||
$last_id=mysql_insert_id($this->conn_id);
|
||||
|
||||
$this->CleanQuery();
|
||||
|
||||
return $last_id;
|
||||
}
|
||||
|
||||
function UpdateData()
|
||||
{
|
||||
$this->ExecuteQuery();
|
||||
|
||||
$return = mysql_affected_rows($this->conn_id);
|
||||
|
||||
$this->CleanQuery();
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
function DeleteData()
|
||||
{
|
||||
return $this->UpdateData();
|
||||
}
|
||||
|
||||
function CleanQuery()
|
||||
{
|
||||
@mysql_free_result($this->sqlResult);
|
||||
//$this->query = "";
|
||||
}
|
||||
|
||||
function EnumSelect( $table , $field )
|
||||
{
|
||||
$this->query = "SHOW COLUMNS FROM `$table` LIKE '$field' ";
|
||||
$this->ExecuteQuery();
|
||||
|
||||
$row = mysql_fetch_array( $this->sqlResult , MYSQL_NUM );
|
||||
$regex = "/'(.*?)'/";
|
||||
|
||||
preg_match_all( $regex , $row[1], $enum_array );
|
||||
$enum_fields = $enum_array[1];
|
||||
|
||||
return( $enum_fields );
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
153
classes/descuento.class.php
Executable file
153
classes/descuento.class.php
Executable file
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
|
||||
class Descuento extends Main
|
||||
{
|
||||
private $descuentoId;
|
||||
private $ventaId;
|
||||
private $sucursalId;
|
||||
private $usuarioId;
|
||||
private $fecha;
|
||||
private $productoId;
|
||||
private $prodItemId;
|
||||
private $cantidad;
|
||||
private $status;
|
||||
|
||||
private $metodoPagoId;
|
||||
|
||||
public function setDescuentoId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->ventaId = $value;
|
||||
}
|
||||
|
||||
public function setSucursalId($value)
|
||||
{
|
||||
$this->sucursalId = $value;
|
||||
}
|
||||
|
||||
public function setUsuarioId($value)
|
||||
{
|
||||
$this->usuarioId = $value;
|
||||
}
|
||||
|
||||
public function setFecha($value)
|
||||
{
|
||||
$this->fecha = $value;
|
||||
}
|
||||
|
||||
public function setProductoId($value)
|
||||
{
|
||||
$this->productoId = $value;
|
||||
}
|
||||
|
||||
public function setProdItemId($value)
|
||||
{
|
||||
$this->prodItemId = $value;
|
||||
}
|
||||
|
||||
public function setCantidad($value)
|
||||
{
|
||||
$this->cantidad = $value;
|
||||
}
|
||||
|
||||
public function setPrecioUnitario($value)
|
||||
{
|
||||
$this->precioUnitario = $value;
|
||||
}
|
||||
|
||||
public function setStatus($value)
|
||||
{
|
||||
$this->status = $value;
|
||||
}
|
||||
|
||||
function Info()
|
||||
{
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("
|
||||
SELECT * FROM venta
|
||||
WHERE ventaId ='".$this->ventaId."'"
|
||||
);
|
||||
$info = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
function Enumerate()
|
||||
{
|
||||
$sql = "SELECT COUNT(*) FROM venta
|
||||
WHERE (status = 'Descuento' OR status = 'DescAp')
|
||||
AND sucursalId = '".$this->sucursalId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
$pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/ventas");
|
||||
|
||||
$sqlAdd = "LIMIT ".$pages["start"].", ".$pages["items_per_page"];
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM venta
|
||||
WHERE (status = 'Descuento'
|
||||
OR status = 'DescAp')
|
||||
AND sucursalId = '".$this->sucursalId."'
|
||||
ORDER BY fecha DESC ".$sqlAdd;
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$data["items"] = $result;
|
||||
$data["pages"] = $pages;
|
||||
|
||||
return $data;
|
||||
|
||||
}//Enumerate
|
||||
|
||||
function EnumByStatus()
|
||||
{
|
||||
$sql = "SELECT *
|
||||
FROM venta
|
||||
WHERE status = '".$this->status."'
|
||||
AND sucursalId = '".$this->sucursalId."'
|
||||
AND usuarioId = '".$this->usuarioId."'
|
||||
ORDER BY fecha DESC ".$sqlAdd;
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $result;
|
||||
|
||||
}//EnumByStatus
|
||||
|
||||
function Save(){
|
||||
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO venta
|
||||
(
|
||||
sucursalId,
|
||||
usuarioId,
|
||||
fecha,
|
||||
subtotal,
|
||||
iva,
|
||||
total,
|
||||
pago,
|
||||
status
|
||||
)
|
||||
VALUES (
|
||||
'".$this->sucursalId."',
|
||||
'".$this->usuarioId."',
|
||||
'".$this->fecha."',
|
||||
'".$this->subtotal."',
|
||||
'".$this->iva."',
|
||||
'".$this->total."',
|
||||
'".$this->pago."',
|
||||
'".$this->status."'
|
||||
)";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$ventaId = $this->Util()->DBSelect($_SESSION['empresaId'])->InsertData();
|
||||
|
||||
return $ventaId;
|
||||
|
||||
}
|
||||
|
||||
}//Descuento
|
||||
|
||||
?>
|
||||
643
classes/devolucion.class.php
Executable file
643
classes/devolucion.class.php
Executable file
@@ -0,0 +1,643 @@
|
||||
<?php
|
||||
|
||||
class Devolucion extends Main
|
||||
{
|
||||
private $devolucionId;
|
||||
private $devCedisId;
|
||||
private $ventaId;
|
||||
private $sucursalId;
|
||||
private $usuarioId;
|
||||
private $fecha;
|
||||
private $productoId;
|
||||
private $prodItemId;
|
||||
private $cantidad;
|
||||
private $disponible;
|
||||
private $subtotal;
|
||||
private $iva;
|
||||
private $total;
|
||||
private $precioUnitario;
|
||||
|
||||
private $fechaI;
|
||||
private $fechaF;
|
||||
|
||||
public function setDevolucionId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->devolucionId = $value;
|
||||
}
|
||||
|
||||
public function setDevCedisId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->devCedisId = $value;
|
||||
}
|
||||
|
||||
public function setVentaId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->ventaId = $value;
|
||||
}
|
||||
|
||||
public function setSucursalId($value)
|
||||
{
|
||||
$this->sucursalId = $value;
|
||||
}
|
||||
|
||||
public function setUsuarioId($value)
|
||||
{
|
||||
$this->usuarioId = $value;
|
||||
}
|
||||
|
||||
public function setFecha($value)
|
||||
{
|
||||
$this->fecha = $value;
|
||||
}
|
||||
|
||||
public function setProductoId($value)
|
||||
{
|
||||
$this->productoId = $value;
|
||||
}
|
||||
|
||||
public function setProdItemId($value)
|
||||
{
|
||||
$this->prodItemId = $value;
|
||||
}
|
||||
|
||||
public function setCantidad($value)
|
||||
{
|
||||
$this->cantidad = $value;
|
||||
}
|
||||
|
||||
public function setDisponible($value)
|
||||
{
|
||||
$this->disponible = $value;
|
||||
}
|
||||
|
||||
public function setPrecioUnitario($value)
|
||||
{
|
||||
$this->precioUnitario = $value;
|
||||
}
|
||||
|
||||
public function setSubtotal($value)
|
||||
{
|
||||
$this->subtotal = $value;
|
||||
}
|
||||
|
||||
public function setIva($value)
|
||||
{
|
||||
$this->iva = $value;
|
||||
}
|
||||
|
||||
public function setTotal($value)
|
||||
{
|
||||
$this->total = $value;
|
||||
}
|
||||
|
||||
public function setFechaI($value)
|
||||
{
|
||||
$this->fechaI = $value;
|
||||
}
|
||||
|
||||
public function setFechaF($value)
|
||||
{
|
||||
$this->fechaF = $value;
|
||||
}
|
||||
|
||||
function Info()
|
||||
{
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("
|
||||
SELECT * FROM devolucion
|
||||
WHERE devolucionId ='".$this->devolucionId."'"
|
||||
);
|
||||
$info = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
function InfoVenta()
|
||||
{
|
||||
$sql = "SELECT * FROM venta WHERE ventaId = '".$this->ventaId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$info = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
function GetCantAllProds(){
|
||||
|
||||
$sql = 'SELECT SUM(cantidad) FROM ventaProducto
|
||||
WHERE ventaId = "'.$this->ventaId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $total;
|
||||
|
||||
}
|
||||
|
||||
function Enumerate()
|
||||
{
|
||||
if($this->sucursalId)
|
||||
$sqlFilter = ' AND sucursalId = '.$this->sucursalId;
|
||||
|
||||
$sql = "SELECT COUNT(*) FROM devolucion WHERE 1 ".$sqlFilter;
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
$pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/devoluciones");
|
||||
|
||||
$sqlAdd = "LIMIT ".$pages["start"].", ".$pages["items_per_page"];
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM devolucion
|
||||
WHERE 1 ".$sqlFilter."
|
||||
ORDER BY fecha DESC ".$sqlAdd;
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$data["items"] = $result;
|
||||
$data["pages"] = $pages;
|
||||
|
||||
return $data;
|
||||
|
||||
}//Enumerate
|
||||
|
||||
function EnumerateCedis()
|
||||
{
|
||||
$sql = "SELECT COUNT(*) FROM devolucionCedis";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
$pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/devoluciones");
|
||||
|
||||
$sqlAdd = "LIMIT ".$pages["start"].", ".$pages["items_per_page"];
|
||||
|
||||
$sql = "SELECT *
|
||||
FROM devolucionCedis
|
||||
ORDER BY fecha DESC ".$sqlAdd;
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$data["items"] = $result;
|
||||
$data["pages"] = $pages;
|
||||
|
||||
return $data;
|
||||
|
||||
}//EnumerateCedis
|
||||
|
||||
function Save(){
|
||||
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO devolucion
|
||||
(
|
||||
sucursalId,
|
||||
ventaId,
|
||||
usuarioId,
|
||||
fecha,
|
||||
total,
|
||||
usado
|
||||
)
|
||||
VALUES (
|
||||
'".$this->sucursalId."',
|
||||
'".$this->ventaId."',
|
||||
'".$this->usuarioId."',
|
||||
'".$this->fecha."',
|
||||
'".$this->total."',
|
||||
'0'
|
||||
)";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$devolucionId = $this->Util()->DBSelect($_SESSION['empresaId'])->InsertData();
|
||||
|
||||
return $devolucionId;
|
||||
|
||||
}
|
||||
|
||||
function SaveProducto(){
|
||||
|
||||
$sql = "INSERT INTO devolucionProducto
|
||||
(
|
||||
devolucionId,
|
||||
ventaId,
|
||||
prodItemId,
|
||||
productoId,
|
||||
cantidad,
|
||||
precioUnitario,
|
||||
total
|
||||
)
|
||||
VALUES (
|
||||
'".$this->devolucionId."',
|
||||
'".$this->ventaId."',
|
||||
'".$this->prodItemId."',
|
||||
'".$this->productoId."',
|
||||
'".$this->cantidad."',
|
||||
'".$this->precioUnitario."',
|
||||
'".$this->total."'
|
||||
)";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->InsertData();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function GetNextFolio(){
|
||||
|
||||
$sql = 'SHOW TABLE STATUS LIKE "devolucion"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$row = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $row['Auto_increment'];
|
||||
|
||||
}
|
||||
|
||||
function GetProductos(){
|
||||
|
||||
$sql = 'SELECT * FROM devolucionProducto
|
||||
WHERE devolucionId = "'.$this->devolucionId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
function GetProductosReporte(){
|
||||
|
||||
$sql = 'SELECT devolucionProducto.cantidad * producto.costo AS importe FROM devolucionProducto
|
||||
LEFT JOIN producto ON producto.productoId = devolucionProducto.productoId
|
||||
WHERE devolucionId = "'.$this->devolucionId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
function GetSumProductosReporte(){
|
||||
|
||||
$sql = 'SELECT SUM(devolucionProducto.cantidad * producto.costo) AS importe FROM devolucionProducto
|
||||
LEFT JOIN producto ON producto.productoId = devolucionProducto.productoId
|
||||
WHERE devolucionId = "'.$this->devolucionId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
function GetCantProdsByItem(){
|
||||
|
||||
$sql = 'SELECT SUM(cantidad) FROM devolucionProducto
|
||||
WHERE devolucionId = "'.$this->devolucionId.'"
|
||||
AND prodItemId = "'.$this->prodItemId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $total;
|
||||
|
||||
}
|
||||
|
||||
function GetSaldo(){
|
||||
|
||||
$sql= 'SELECT total FROM devolucion
|
||||
WHERE ventaId = "'.$this->ventaId.'"
|
||||
AND usado = "0"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$saldo = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $saldo;
|
||||
}
|
||||
|
||||
function ExistTicketSaldo(){
|
||||
|
||||
$sql= 'SELECT devolucionId FROM devolucion
|
||||
WHERE ventaId = "'.$this->ventaId.'"
|
||||
AND usado = "0"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$devolucionId = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $devolucionId;
|
||||
}
|
||||
|
||||
function UpdateUsado(){
|
||||
|
||||
$sql = 'UPDATE devolucion SET usado = "1" WHERE ventaId = "'.$this->ventaId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function GetNextNoDevCedis(){
|
||||
|
||||
$sql = "SHOW TABLE STATUS LIKE 'devolucionCedis'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$row = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $row['Auto_increment'];
|
||||
|
||||
}//GetNextNoDevCedis
|
||||
|
||||
function GetInsertIdCedis(){
|
||||
|
||||
$sql = "SELECT MAX(devCedisId) FROM devolucionCedis";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$devCedisId = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
return $devCedisId;
|
||||
|
||||
}//GetInsertIdCedis
|
||||
|
||||
function SaveDevCedis(){
|
||||
|
||||
$sql = "INSERT INTO devolucionCedis
|
||||
(
|
||||
fecha,
|
||||
usuarioId
|
||||
)
|
||||
VALUES (
|
||||
'".$this->fecha."',
|
||||
'".$this->usuarioId."'
|
||||
)";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->InsertData();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function SaveProdCedis(){
|
||||
|
||||
$sql = "INSERT INTO devolucionProdCedis
|
||||
(
|
||||
devCedisId,
|
||||
sucursalId,
|
||||
productoId,
|
||||
cantidad,
|
||||
disponible
|
||||
)
|
||||
VALUES (
|
||||
'".$this->devCedisId."',
|
||||
'".$this->sucursalId."',
|
||||
'".$this->productoId."',
|
||||
'".$this->cantidad."',
|
||||
'".$this->disponible."'
|
||||
)";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->InsertData();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function DeleteCedis(){
|
||||
|
||||
$sql = "DELETE FROM
|
||||
devolucionCedis
|
||||
WHERE
|
||||
devCedisId = '".$this->devCedisId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$sql = "DELETE FROM
|
||||
devolucionProdCedis
|
||||
WHERE
|
||||
devCedisId = '".$this->devCedisId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$this->Util()->setError(20128, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function InfoCedis(){
|
||||
|
||||
$sql = "SELECT * FROM devolucionCedis WHERE devCedisId = '".$this->devCedisId."'";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$row = $this->Util()->DBSelect($_SESSION['empresaId'])->GetRow();
|
||||
|
||||
return $row;
|
||||
|
||||
}//InfoCedis
|
||||
|
||||
function GetProdsCedis(){
|
||||
|
||||
$sql = "SELECT * FROM devolucionProdCedis WHERE devCedisId = '".$this->devCedisId."'";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
return $result;
|
||||
|
||||
}//GetProdsCedis
|
||||
|
||||
function UpdateDevProd(){
|
||||
|
||||
$sql = "UPDATE inventario SET status = 'Devuelto', devCedisId = '".$this->devCedisId."'
|
||||
WHERE productoId = '".$this->productoId."'
|
||||
AND sucursalId = '".$this->sucursalId."'
|
||||
AND status = 'Disponible'
|
||||
LIMIT ".$this->cantidad;
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData();
|
||||
|
||||
}//UpdateDevProd
|
||||
|
||||
function UpdateDispProd(){
|
||||
|
||||
$sql = "UPDATE inventario SET status = 'Disponible', devCedisId = 0
|
||||
WHERE devCedisId = '".$this->devCedisId."'";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData();
|
||||
|
||||
}//UpdateDispProd
|
||||
|
||||
function CancelarTicket(){
|
||||
|
||||
global $venta;
|
||||
global $sucursal;
|
||||
|
||||
$sucursalId = $this->sucursalId;
|
||||
|
||||
$infD = $this->Info();
|
||||
|
||||
$ventaId = $infD['ventaId'];
|
||||
|
||||
$venta->setVentaId($ventaId);
|
||||
$pagos = $venta->GetPagos();
|
||||
$infV = $venta->Info();
|
||||
|
||||
$idVendedor = $infV['vendedorId'];
|
||||
$totalPago = $infV['pago'];
|
||||
|
||||
$productos = $venta->GetProdsNoDev();
|
||||
|
||||
if(count($productos) == 0){
|
||||
//Cancelamos el status del ticket original
|
||||
$venta->setVentaId($infD['ventaId']);
|
||||
$venta->setStatus('Cancelado');
|
||||
$venta->UpdateStatusCancel();
|
||||
return;
|
||||
}
|
||||
|
||||
$totalVta = 0;
|
||||
foreach($productos as $res){
|
||||
|
||||
$total = $res['total'];
|
||||
|
||||
$productoId = $res['productoId'];
|
||||
$cantidad = $res['cantidad'];
|
||||
|
||||
$valDesc = $res['valDesc'];
|
||||
if($res['tipoDesc'] == 'Dinero')
|
||||
$total -= $valDesc * $res['cantidad'];
|
||||
elseif($res['tipoDesc'] == 'Porcentaje')
|
||||
$total -= $total * ($valDesc / 100);
|
||||
|
||||
//$total = number_format($total,2,'.','');
|
||||
|
||||
$totalVta += $total;
|
||||
|
||||
}//foreach
|
||||
|
||||
//Calculamos el Subtotal y el Iva
|
||||
|
||||
$sucursal->setSucursalId($sucursalId);
|
||||
$porcIva = $sucursal->GetIva();
|
||||
$porcIva = $porcIva / 100;
|
||||
|
||||
$subtotal = $totalVta / (1 + $porcIva);
|
||||
$subtotal = number_format($subtotal,2,'.','');
|
||||
|
||||
$iva = $subtotal * $porcIva;
|
||||
$iva = number_format($iva,2,'.','');
|
||||
|
||||
$fecha = date('Y-m-d H:i:s');
|
||||
|
||||
$venta->setSucursalId($sucursalId);
|
||||
$folio = $venta->GetNextFolio();
|
||||
|
||||
$venta->setSucursalId($sucursalId);
|
||||
$venta->setUsuarioId($_SESSION['loginKey']);
|
||||
$venta->setVendedorId($idVendedor);
|
||||
$venta->setFolio($folio);
|
||||
$venta->setFecha($fecha);
|
||||
$venta->setPromocionId(0);
|
||||
$venta->setSubtotal($subtotal);
|
||||
$venta->setIva($iva);
|
||||
$venta->setTotal($totalVta);
|
||||
$venta->setPago($totalPago);
|
||||
$venta->setStatus('Activo');
|
||||
|
||||
$ventaId = $venta->Save();
|
||||
|
||||
//Checamos si hay Descuento Global
|
||||
|
||||
if($infV['tipoDesc'] != ''){
|
||||
|
||||
$descVal = 0;
|
||||
if($infV['tipoDesc'] == 'Dinero')
|
||||
$descVal = $infV['valDesc'];
|
||||
elseif($infV['tipoDesc'] == 'Porcentaje')
|
||||
$descVal = $total * ($infV['valDesc']/100);
|
||||
|
||||
$totalVta -= $descVal;
|
||||
|
||||
//Obtenemos los Totales
|
||||
|
||||
$subtotal = $totalVta / (1 + $porcIva);
|
||||
$subtotal = number_format($subtotal,2,'.','');
|
||||
|
||||
$iva = $subtotal * $porcIva;
|
||||
$iva = number_format($iva,2,'.','');
|
||||
|
||||
$venta->setVentaId($ventaId);
|
||||
$venta->setTipoDesc($infV['tipoDesc']);
|
||||
$venta->setValDesc($infV['valDesc']);
|
||||
$venta->setSubtotal($subtotal);
|
||||
$venta->setIva($iva);
|
||||
$venta->setTotal($totalVta);
|
||||
|
||||
$venta->UpdateDescVta();
|
||||
|
||||
$venta->setStatus('Activo');
|
||||
$venta->UpdateStatus();
|
||||
|
||||
}//if
|
||||
|
||||
//Guardamos los Productos
|
||||
|
||||
foreach($productos as $res){
|
||||
|
||||
$venta->setVentaId($ventaId);
|
||||
$venta->setCantidad($res['cantidad']);
|
||||
$venta->setPrecioUnitario($res['precioUnitario']);
|
||||
$venta->setTotal($res['total']);
|
||||
|
||||
$venta->setProdItemId($res['prodItemId']);
|
||||
$venta->setProductoId($res['productoId']);
|
||||
$venta->setMonederoId($res['monederoId']);
|
||||
$venta->setPromocionId($res['promocionId']);
|
||||
|
||||
$venta->setTipoDesc($res['tipoDesc']);
|
||||
$venta->setValDesc($res['valDesc']);
|
||||
|
||||
$venta->SaveProducto();
|
||||
|
||||
}//foreach
|
||||
|
||||
//Guardamos los Pagos
|
||||
|
||||
foreach($pagos as $res){
|
||||
|
||||
$venta->setVentaId($ventaId);
|
||||
$venta->setMetodoPagoId($res['metodoPagoId']);
|
||||
$venta->setMetodoPagoId($res['metodoPagoId']);
|
||||
$venta->setMonederoId($res['monederoId']);
|
||||
$venta->setDevolucionId($res['devolucionId']);
|
||||
$venta->setCantidad($res['cantidad']);
|
||||
|
||||
$venta->SavePago();
|
||||
|
||||
}//foreach
|
||||
|
||||
//Guardamos la Venta Anterior del Ticket Nuevo
|
||||
$venta->setVentaId($ventaId);
|
||||
$venta->UpdateVentaAnt($infD['ventaId']);
|
||||
|
||||
//Cancelamos el status del ticket original
|
||||
$venta->setVentaId($infD['ventaId']);
|
||||
$venta->setStatus('Cancelado');
|
||||
$venta->UpdateStatusCancel();
|
||||
|
||||
return true;
|
||||
|
||||
}//CancelarTicket
|
||||
|
||||
function Search(){
|
||||
|
||||
$sqlFilter = '';
|
||||
|
||||
if($this->usuarioId)
|
||||
$sqlFilter .= ' AND usuarioId = '.$this->usuarioId;
|
||||
|
||||
$sql = "SELECT * FROM devolucion
|
||||
WHERE sucursalId = '".$this->sucursalId."'
|
||||
AND fecha >= '".$this->fechaI." 00:00:00'
|
||||
AND fecha <= '".$this->fechaF." 23:59:59'
|
||||
".$sqlFilter."
|
||||
ORDER BY fecha DESC";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
return $result;
|
||||
|
||||
}//Search
|
||||
|
||||
}//Devolucion
|
||||
|
||||
?>
|
||||
280
classes/devolucionPedido.class.php
Executable file
280
classes/devolucionPedido.class.php
Executable file
@@ -0,0 +1,280 @@
|
||||
<?php
|
||||
|
||||
class Devolucion extends Main
|
||||
{
|
||||
private $bonificacionId;
|
||||
private $pedidoId;
|
||||
private $proveedorId;
|
||||
private $prodItemId;
|
||||
private $productoId;
|
||||
|
||||
private $costo;
|
||||
private $total;
|
||||
private $disponible;
|
||||
private $vendido;
|
||||
private $porcentajeVendido;
|
||||
private $pagoTotal;
|
||||
private $cantidad;
|
||||
private $status;
|
||||
|
||||
public function setJustificanteRechazo($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 1, "Justificacion");
|
||||
$this->justificanteRechazo = $value;
|
||||
}
|
||||
|
||||
public function setStatus($value)
|
||||
{
|
||||
//$this->Util()->ValidateInteger($value);
|
||||
$this->status = $value;
|
||||
}
|
||||
|
||||
public function setBonificacionId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->bonificacionId = $value;
|
||||
}
|
||||
|
||||
public function setRestante($value)
|
||||
{
|
||||
//$this->Util()->ValidateInteger($value);
|
||||
$this->restante = $value;
|
||||
}
|
||||
|
||||
public function setCantidad($value)
|
||||
{
|
||||
//$this->Util()->ValidateInteger($value);
|
||||
$this->cantidad = $value;
|
||||
}
|
||||
|
||||
public function setPorcentajeBonifica($value)
|
||||
{
|
||||
//$this->Util()->ValidateInteger($value);
|
||||
$this->porcentajeBonifica = $value;
|
||||
}
|
||||
|
||||
public function setPagoTotal($value)
|
||||
{
|
||||
//$this->Util()->ValidateInteger($value);
|
||||
$this->pagoTotal = $value;
|
||||
}
|
||||
|
||||
public function setPorcentajeVendido($value)
|
||||
{
|
||||
//$this->Util()->ValidateInteger($value);
|
||||
$this->porcentajeVendido = $value;
|
||||
}
|
||||
|
||||
public function setPorcentajeAplicado($value)
|
||||
{
|
||||
//$this->Util()->ValidateInteger($value);
|
||||
$this->porcentajeAplicado = $value;
|
||||
}
|
||||
|
||||
public function setVendido($value)
|
||||
{
|
||||
//$this->Util()->ValidateInteger($value);
|
||||
$this->vendido = $value;
|
||||
}
|
||||
|
||||
public function setDisponible($value)
|
||||
{
|
||||
//$this->Util()->ValidateInteger($value);
|
||||
$this->disponible = $value;
|
||||
}
|
||||
|
||||
public function setTotal($value)
|
||||
{
|
||||
//$this->Util()->ValidateInteger($value);
|
||||
$this->total = $value;
|
||||
}
|
||||
|
||||
public function setCosto($value)
|
||||
{
|
||||
//$this->Util()->ValidateInteger($value);
|
||||
$this->costo = $value;
|
||||
}
|
||||
|
||||
public function setProductoId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->productoId = $value;
|
||||
}
|
||||
|
||||
public function setPedidoId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->pedidoId = $value;
|
||||
}
|
||||
|
||||
public function setProdItemId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->prodItemId = $value;
|
||||
}
|
||||
|
||||
public function setProveedorId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->proveedorId = $value;
|
||||
}
|
||||
|
||||
public function searchProductoById()
|
||||
{
|
||||
$sql = 'SELECT * FROM producto LEFT JOIN pedidoProducto ON(pedidoProducto.productoId = producto.productoId) LEFT JOIN pedido ON(pedido.pedidoId = pedidoProducto.pedidoId) LEFT JOIN productoItem ON(productoItem.productoId = producto.productoId) WHERE pedido.pedidoId = '.$this->pedidoId.' AND prodItemId = '.$this->prodItemId;
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$producto = $this->Util()->DBSelect($_SESSION['empresaId'])->GetRow();
|
||||
|
||||
return $producto;
|
||||
}
|
||||
|
||||
public function Save()
|
||||
{
|
||||
$sql = "INSERT INTO bonificacion(
|
||||
`prodItemId`,
|
||||
`proveedorId`,
|
||||
`pedidoId`,
|
||||
`productoId`,
|
||||
`porcentajeBonifica`,
|
||||
`totalBonificacion`,
|
||||
`restanteBonificacion`,
|
||||
`porcentajeAplicado`,
|
||||
`fechaBonificacion`,
|
||||
`totalProductos`,
|
||||
`costoProducto`,
|
||||
`disponible`,
|
||||
`vendido`,
|
||||
`porcentajeVendido`,
|
||||
`cantidad`) VALUES
|
||||
('".$this->prodItemId."',
|
||||
'".$this->proveedorId."',
|
||||
'".$this->pedidoId."',
|
||||
'".$this->productoId."',
|
||||
'".$this->porcentajeBonifica."',
|
||||
'".$this->pagoTotal."',
|
||||
'".$this->restante."',
|
||||
'".$this->porcentajeAplicado."',
|
||||
'".$this->Util()->TodayHour()."',
|
||||
'".$this->total."',
|
||||
'".$this->costo."',
|
||||
'".$this->disponible."',
|
||||
'".$this->vendido."',
|
||||
'".$this->porcentajeVendido."',
|
||||
'".$this->cantidad."')";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->InsertData();
|
||||
$this->Util()->setError(30066, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkBonificacion()
|
||||
{
|
||||
$value = true;
|
||||
$sql = "SELECT COUNT(*) FROM bonificacion WHERE prodItemId = '".$this->prodItemId."' AND proveedorId = '".$this->proveedorId."' AND pedidoId = '".$this->pedidoId."' AND productoId = '".$this->productoId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
if($this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle() > 0)
|
||||
$value = false;
|
||||
return $value;
|
||||
}
|
||||
|
||||
function checkBonificacion2()
|
||||
{
|
||||
$value = true;
|
||||
|
||||
$sql = "SELECT COUNT(*) FROM bonificacion WHERE prodItemId = '".$this->prodItemId."' AND proveedorId = '".$this->proveedorId."' AND pedidoId = '".$this->pedidoId."' AND productoId = '".$this->productoId."' AND estatus LIKE 'Aprobado'";
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$aprobado = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
$sql = "SELECT COUNT(*) FROM bonificacion WHERE prodItemId = '".$this->prodItemId."' AND proveedorId = '".$this->proveedorId."' AND pedidoId = '".$this->pedidoId."' AND productoId = '".$this->productoId."' AND estatus LIKE 'Pendiente'";
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$pendiente = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
if($aprobado >= 2 || $pendiente > 0)
|
||||
$value = false;
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
function Enumerate()
|
||||
{
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT COUNT(*) FROM bonificacion");
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
$pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/bonificaciones-pendientes");
|
||||
|
||||
$sqlAdd = " LIMIT ".$pages["start"].", ".$pages["items_per_page"];
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT * FROM bonificacion ORDER BY fechaBonificacion ASC".$sqlAdd);
|
||||
$bonificaciones = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$data["items"] = $bonificaciones;
|
||||
$data["pages"] = $pages;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function updateStatus()
|
||||
{
|
||||
$sql = "UPDATE bonificacion SET estatus = 'Aprobado', cantidad = '".$this->cantidad."' WHERE bonificacionId = ".$this->bonificacionId;
|
||||
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData();
|
||||
|
||||
$this->Util()->setError(30067, 'complete');
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function getBonificaciones()
|
||||
{
|
||||
$sql = 'SELECT SUM(cantidad) FROM bonificacion WHERE pedidoId = '.$this->pedidoId.' AND estatus LIKE "Aprobado"';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$producto = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
return $producto;
|
||||
}
|
||||
|
||||
public function SaveDevolucion()
|
||||
{
|
||||
$sql = "INSERT INTO devolucionPedido(
|
||||
`prodItemId`,
|
||||
`proveedorId`,
|
||||
`pedidoId`,
|
||||
`productoId`,
|
||||
`totalDevolucion`,
|
||||
`porcentajeAplicado`,
|
||||
`fechaDevolucion`,
|
||||
`totalProductos`,
|
||||
`costoProducto`,
|
||||
`disponible`,
|
||||
`vendido`,
|
||||
`porcentajeVendido`,
|
||||
`cantidad`) VALUES
|
||||
('".$this->prodItemId."',
|
||||
'".$this->proveedorId."',
|
||||
'".$this->pedidoId."',
|
||||
'".$this->productoId."',
|
||||
'".$this->pagoTotal."',
|
||||
'".$this->porcentajeAplicado."',
|
||||
'".$this->Util()->TodayHour()."',
|
||||
'".$this->total."',
|
||||
'".$this->costo."',
|
||||
'".$this->disponible."',
|
||||
'".$this->vendido."',
|
||||
'".$this->porcentajeVendido."',
|
||||
'".$this->cantidad."')";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->InsertData();
|
||||
$this->Util()->setError(30066, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
509
classes/empresa.class.php
Executable file
509
classes/empresa.class.php
Executable file
@@ -0,0 +1,509 @@
|
||||
<?php
|
||||
|
||||
class Empresa extends Main
|
||||
{
|
||||
protected $username;
|
||||
|
||||
private $empresaId;
|
||||
private $email;
|
||||
private $password;
|
||||
|
||||
private $rfc;
|
||||
private $calle;
|
||||
private $pais;
|
||||
|
||||
/*
|
||||
private $razonSocial;
|
||||
|
||||
private $noInt;
|
||||
private $noExt;
|
||||
private $referencia;
|
||||
private $colonia;
|
||||
private $localidad;
|
||||
private $municipio;
|
||||
private $ciudad;
|
||||
private $estado;
|
||||
|
||||
private $cp;
|
||||
private $regimenFiscal;
|
||||
|
||||
private $productId;
|
||||
private $empresaId;
|
||||
private $sucursalId;
|
||||
private $proveedorId;
|
||||
private $socioId;
|
||||
private $comprobanteId;
|
||||
private $motivoCancelacion;
|
||||
*/
|
||||
|
||||
/*
|
||||
public function setFolios($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=300, $minChars = 1, "Folios");
|
||||
$this->folios = $value;
|
||||
}
|
||||
|
||||
public function getFolios()
|
||||
{
|
||||
return $this->folios;
|
||||
}
|
||||
|
||||
public function setComprobanteId($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=100, $minChars = 1, "ID Comprobante");
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->comprobanteId = $value;
|
||||
}
|
||||
|
||||
public function getComprobanteId()
|
||||
{
|
||||
return $this->comprobanteId;
|
||||
}
|
||||
|
||||
public function setMotivoCancelacion($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=300, $minChars = 1, "Motivo de Cancelacion");
|
||||
$this->motivoCancelacion = $value;
|
||||
}
|
||||
|
||||
public function getMotivoCancelacion()
|
||||
{
|
||||
return $this->motivoCancelacion;
|
||||
}
|
||||
|
||||
public function setProveedorId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->proveedorId = $value;
|
||||
}
|
||||
|
||||
public function getProveedorId()
|
||||
{
|
||||
return $this->proveedorId;
|
||||
}
|
||||
|
||||
public function setSocioId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->socioId = $value;
|
||||
}
|
||||
|
||||
public function getSocioId()
|
||||
{
|
||||
return $this->socioId;
|
||||
}
|
||||
|
||||
public function setEmpresaId($value, $checkIfExists = 0)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->Util()->DB()->setQuery("SELECT COUNT(*) FROM empresa WHERE empresaId ='".$value."'");
|
||||
if($checkIfExists)
|
||||
{
|
||||
if($this->Util()->DB()->GetSingle() <= 0)
|
||||
{
|
||||
$this->Util()->setError(10030, "error", "");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($this->Util()->DB()->GetSingle() > 0)
|
||||
{
|
||||
$this->Util()->setError(10030, "error", "");
|
||||
return;
|
||||
}
|
||||
}
|
||||
$this->empresaId = $value;
|
||||
}
|
||||
|
||||
public function getEmpresaId()
|
||||
{
|
||||
return $this->empresaId;
|
||||
}
|
||||
|
||||
public function setRazonSocial($value, $checkIfExists = 0)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=300, $minChars = 3, "Razón Social");
|
||||
$this->razonSocial = $value;
|
||||
}
|
||||
|
||||
public function getRazonSocial()
|
||||
{
|
||||
return $this->razonSocial;
|
||||
}
|
||||
|
||||
public function setSucursalId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->sucursalId = $value;
|
||||
}
|
||||
|
||||
public function getSucursalId()
|
||||
{
|
||||
return $this->sucursalId;
|
||||
}
|
||||
|
||||
public function getCalle()
|
||||
{
|
||||
return $this->calle;
|
||||
}
|
||||
|
||||
public function setColonia($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, "Colonia");
|
||||
$this->colonia = $value;
|
||||
}
|
||||
|
||||
public function getColonia()
|
||||
{
|
||||
return $this->colonia;
|
||||
}
|
||||
|
||||
public function setReferencia($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, "Referencia");
|
||||
$this->referencia = $value;
|
||||
}
|
||||
|
||||
public function getReferencia()
|
||||
{
|
||||
return $this->referencia;
|
||||
}
|
||||
|
||||
public function setMunicipio($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, "Municipio");
|
||||
$this->municipio = $value;
|
||||
}
|
||||
|
||||
public function getMunicipio()
|
||||
{
|
||||
return $this->municipio;
|
||||
}
|
||||
|
||||
public function setCiudad($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, "Ciudad");
|
||||
$this->ciudad = $value;
|
||||
}
|
||||
|
||||
public function getCiudad()
|
||||
{
|
||||
return $this->ciudad;
|
||||
}
|
||||
|
||||
public function setEstado($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, "Estado");
|
||||
$this->estado = $value;
|
||||
}
|
||||
|
||||
public function getEstado()
|
||||
{
|
||||
return $this->estado;
|
||||
}
|
||||
|
||||
public function getPais()
|
||||
{
|
||||
return $this->pais;
|
||||
}
|
||||
|
||||
public function getRegimenFiscal()
|
||||
{
|
||||
return $this->regimenFiscal;
|
||||
}
|
||||
|
||||
public function setRegimenFiscal($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 1, "Regimen Fiscal");
|
||||
$this->regimenFiscal = $value;
|
||||
}
|
||||
|
||||
|
||||
public function setNoInt($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, "noInt");
|
||||
$this->noInt = $value;
|
||||
}
|
||||
|
||||
public function getNoInt()
|
||||
{
|
||||
return $this->noInt;
|
||||
}
|
||||
|
||||
public function setNoExt($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 1, "noExt");
|
||||
$this->noExt = $value;
|
||||
}
|
||||
|
||||
public function getNoExt()
|
||||
{
|
||||
return $this->noExt;
|
||||
}
|
||||
|
||||
public function setLocalidad($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, "Localidad");
|
||||
$this->localidad = $value;
|
||||
}
|
||||
|
||||
public function getLocalidad()
|
||||
{
|
||||
return $this->localidad;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getRfc()
|
||||
{
|
||||
return $this->rfc;
|
||||
}
|
||||
|
||||
public function getPassword()
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
public function setEmail($value)
|
||||
{
|
||||
$this->Util()->ValidateMail($value);
|
||||
$this->Util()->DB()->setQuery("SELECT COUNT(*) FROM usuario WHERE email ='".$value."'");
|
||||
if($this->Util()->DB()->GetSingle() > 0)
|
||||
{
|
||||
$this->Util()->setError(10005, "error", "");
|
||||
}
|
||||
$this->email = $value;
|
||||
}
|
||||
|
||||
public function getEmail()
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function getEmailLogin()
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function setCp($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->cp = $value;
|
||||
}
|
||||
|
||||
public function getCp()
|
||||
{
|
||||
return $this->cp;
|
||||
}
|
||||
|
||||
public function setProductId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->productId = $value;
|
||||
}
|
||||
|
||||
public function getProductId()
|
||||
{
|
||||
return $this->productId;
|
||||
}
|
||||
*/
|
||||
|
||||
public function setPais($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, "Pais");
|
||||
$this->pais = $value;
|
||||
}
|
||||
|
||||
public function setCalle($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=200, $minChars = 1, "Dirección");
|
||||
$this->calle = $value;
|
||||
}
|
||||
|
||||
public function setRfc($value)
|
||||
{
|
||||
$value = strtoupper($value);
|
||||
$this->Util()->ValidateString($value, $max_chars=13, $minChars = 12, "RFC");
|
||||
$this->rfc = $value;
|
||||
}
|
||||
|
||||
public function setEmpresaId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->empresaId = $value;
|
||||
}
|
||||
|
||||
public function setPassword($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Password');
|
||||
$this->password = $value;
|
||||
}
|
||||
|
||||
public function setEmail($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Email');
|
||||
if($value != '')
|
||||
$this->Util()->ValidateMail($value);
|
||||
$this->email = $value;
|
||||
}
|
||||
|
||||
public function Info()
|
||||
{
|
||||
$generalDb = new DB;
|
||||
|
||||
$sql = "SELECT * FROM empresa WHERE empresaId = '".$this->empresaId."'";
|
||||
$generalDb->setQuery($sql);
|
||||
$row = $generalDb->GetRow();
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
function InfoAll()
|
||||
{
|
||||
$generalDb = new DB;
|
||||
|
||||
$sql = "SELECT * FROM usuario
|
||||
LEFT JOIN empresa ON usuario.empresaId = empresa.empresaId
|
||||
WHERE usuarioId = '".$_SESSION["loginKey"]."'";
|
||||
$generalDb->setQuery($sql);
|
||||
$row = $generalDb->GetRow();
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
function DoLogin()
|
||||
{
|
||||
if($this->Util()->PrintErrors())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$generalDb = new DB;
|
||||
|
||||
$sql = "SELECT usuarioId FROM usuario
|
||||
WHERE email = '".$this->email."'
|
||||
AND password = '".$this->password."'
|
||||
AND empresaId = '".$this->empresaId."'
|
||||
AND baja = '0'";
|
||||
$generalDb->setQuery($sql);
|
||||
$usuarioId = $generalDb->GetSingle();
|
||||
|
||||
if(!$usuarioId)
|
||||
{
|
||||
unset($_SESSION["loginKey"]);
|
||||
unset($_SESSION["empresaId"]);
|
||||
$this->Util()->setError(10006, "error");
|
||||
|
||||
if($this->Util()->PrintErrors())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM usuario
|
||||
LEFT JOIN empresa ON usuario.empresaId = empresa.empresaId
|
||||
WHERE usuarioId = '".$usuarioId."'";
|
||||
$generalDb->setQuery($sql);
|
||||
$info = $generalDb->GetRow();
|
||||
|
||||
$_SESSION["loginKey"] = $usuarioId;
|
||||
$_SESSION["idSuc"] = $info['sucursalId'];
|
||||
$_SESSION["empresaId"] = $this->empresaId;
|
||||
$_SESSION["version"] = $info["version"];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function DoLogout()
|
||||
{
|
||||
unset($_SESSION["loginKey"]);
|
||||
unset($_SESSION["empresaId"]);
|
||||
}
|
||||
|
||||
function IsLoggedIn()
|
||||
{
|
||||
if($_SESSION["loginKey"])
|
||||
{
|
||||
$GLOBALS["smarty"]->assign('user', $this->Info());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
function Info($userId = 0)
|
||||
{
|
||||
$generalDb = new DB;
|
||||
$generalDb->setQuery("SELECT * FROM usuario
|
||||
LEFT JOIN empresa ON usuario.empresaId = empresa.empresaId WHERE userId = '".$userId."'");
|
||||
if($userId == 0)
|
||||
{
|
||||
$generalDb->setQuery("SELECT * FROM usuario
|
||||
LEFT JOIN empresa ON usuario.empresaId = empresa.empresaId WHERE email = '".$_SESSION["loginKey"]."'");
|
||||
}
|
||||
$user = $generalDb->GetRow();
|
||||
|
||||
if(!$user)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function AuthUser()
|
||||
{
|
||||
if(!$this->IsLoggedIn())
|
||||
{
|
||||
$this->Util()->LoadPage('login');
|
||||
return;
|
||||
}
|
||||
|
||||
}//AuthUser
|
||||
|
||||
/*
|
||||
|
||||
function ListSucursales()
|
||||
{
|
||||
|
||||
$this->Util()->DB()->setQuery("SELECT * FROM sucursal WHERE empresaId = ".$this->empresaId." ORDER BY identificador");
|
||||
|
||||
$result = $this->Util()->DB()->GetResult();
|
||||
|
||||
foreach($result as $key => $periodo)
|
||||
{
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
function GetSucursalInfo()
|
||||
{
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT * FROM sucursal WHERE empresaId = ".$this->empresaId." AND sucursalId = ".$this->sucursalId);
|
||||
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function GetPublicEmpresaInfo()
|
||||
{
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT * FROM rfc LIMIT 1");
|
||||
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $result;
|
||||
}
|
||||
*/
|
||||
|
||||
}//empresa
|
||||
|
||||
|
||||
?>
|
||||
509
classes/empresa.class.php~
Executable file
509
classes/empresa.class.php~
Executable file
@@ -0,0 +1,509 @@
|
||||
<?php
|
||||
|
||||
class Empresa extends Main
|
||||
{
|
||||
protected $username;
|
||||
|
||||
private $empresaId;
|
||||
private $email;
|
||||
private $password;
|
||||
|
||||
private $rfc;
|
||||
private $calle;
|
||||
private $pais;
|
||||
|
||||
/*
|
||||
private $razonSocial;
|
||||
|
||||
private $noInt;
|
||||
private $noExt;
|
||||
private $referencia;
|
||||
private $colonia;
|
||||
private $localidad;
|
||||
private $municipio;
|
||||
private $ciudad;
|
||||
private $estado;
|
||||
|
||||
private $cp;
|
||||
private $regimenFiscal;
|
||||
|
||||
private $productId;
|
||||
private $empresaId;
|
||||
private $sucursalId;
|
||||
private $proveedorId;
|
||||
private $socioId;
|
||||
private $comprobanteId;
|
||||
private $motivoCancelacion;
|
||||
*/
|
||||
|
||||
/*
|
||||
public function setFolios($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=300, $minChars = 1, "Folios");
|
||||
$this->folios = $value;
|
||||
}
|
||||
|
||||
public function getFolios()
|
||||
{
|
||||
return $this->folios;
|
||||
}
|
||||
|
||||
public function setComprobanteId($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=100, $minChars = 1, "ID Comprobante");
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->comprobanteId = $value;
|
||||
}
|
||||
|
||||
public function getComprobanteId()
|
||||
{
|
||||
return $this->comprobanteId;
|
||||
}
|
||||
|
||||
public function setMotivoCancelacion($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=300, $minChars = 1, "Motivo de Cancelacion");
|
||||
$this->motivoCancelacion = $value;
|
||||
}
|
||||
|
||||
public function getMotivoCancelacion()
|
||||
{
|
||||
return $this->motivoCancelacion;
|
||||
}
|
||||
|
||||
public function setProveedorId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->proveedorId = $value;
|
||||
}
|
||||
|
||||
public function getProveedorId()
|
||||
{
|
||||
return $this->proveedorId;
|
||||
}
|
||||
|
||||
public function setSocioId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->socioId = $value;
|
||||
}
|
||||
|
||||
public function getSocioId()
|
||||
{
|
||||
return $this->socioId;
|
||||
}
|
||||
|
||||
public function setEmpresaId($value, $checkIfExists = 0)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->Util()->DB()->setQuery("SELECT COUNT(*) FROM empresa WHERE empresaId ='".$value."'");
|
||||
if($checkIfExists)
|
||||
{
|
||||
if($this->Util()->DB()->GetSingle() <= 0)
|
||||
{
|
||||
$this->Util()->setError(10030, "error", "");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($this->Util()->DB()->GetSingle() > 0)
|
||||
{
|
||||
$this->Util()->setError(10030, "error", "");
|
||||
return;
|
||||
}
|
||||
}
|
||||
$this->empresaId = $value;
|
||||
}
|
||||
|
||||
public function getEmpresaId()
|
||||
{
|
||||
return $this->empresaId;
|
||||
}
|
||||
|
||||
public function setRazonSocial($value, $checkIfExists = 0)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=300, $minChars = 3, "Razón Social");
|
||||
$this->razonSocial = $value;
|
||||
}
|
||||
|
||||
public function getRazonSocial()
|
||||
{
|
||||
return $this->razonSocial;
|
||||
}
|
||||
|
||||
public function setSucursalId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->sucursalId = $value;
|
||||
}
|
||||
|
||||
public function getSucursalId()
|
||||
{
|
||||
return $this->sucursalId;
|
||||
}
|
||||
|
||||
public function getCalle()
|
||||
{
|
||||
return $this->calle;
|
||||
}
|
||||
|
||||
public function setColonia($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, "Colonia");
|
||||
$this->colonia = $value;
|
||||
}
|
||||
|
||||
public function getColonia()
|
||||
{
|
||||
return $this->colonia;
|
||||
}
|
||||
|
||||
public function setReferencia($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, "Referencia");
|
||||
$this->referencia = $value;
|
||||
}
|
||||
|
||||
public function getReferencia()
|
||||
{
|
||||
return $this->referencia;
|
||||
}
|
||||
|
||||
public function setMunicipio($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, "Municipio");
|
||||
$this->municipio = $value;
|
||||
}
|
||||
|
||||
public function getMunicipio()
|
||||
{
|
||||
return $this->municipio;
|
||||
}
|
||||
|
||||
public function setCiudad($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, "Ciudad");
|
||||
$this->ciudad = $value;
|
||||
}
|
||||
|
||||
public function getCiudad()
|
||||
{
|
||||
return $this->ciudad;
|
||||
}
|
||||
|
||||
public function setEstado($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, "Estado");
|
||||
$this->estado = $value;
|
||||
}
|
||||
|
||||
public function getEstado()
|
||||
{
|
||||
return $this->estado;
|
||||
}
|
||||
|
||||
public function getPais()
|
||||
{
|
||||
return $this->pais;
|
||||
}
|
||||
|
||||
public function getRegimenFiscal()
|
||||
{
|
||||
return $this->regimenFiscal;
|
||||
}
|
||||
|
||||
public function setRegimenFiscal($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 1, "Regimen Fiscal");
|
||||
$this->regimenFiscal = $value;
|
||||
}
|
||||
|
||||
|
||||
public function setNoInt($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, "noInt");
|
||||
$this->noInt = $value;
|
||||
}
|
||||
|
||||
public function getNoInt()
|
||||
{
|
||||
return $this->noInt;
|
||||
}
|
||||
|
||||
public function setNoExt($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 1, "noExt");
|
||||
$this->noExt = $value;
|
||||
}
|
||||
|
||||
public function getNoExt()
|
||||
{
|
||||
return $this->noExt;
|
||||
}
|
||||
|
||||
public function setLocalidad($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, "Localidad");
|
||||
$this->localidad = $value;
|
||||
}
|
||||
|
||||
public function getLocalidad()
|
||||
{
|
||||
return $this->localidad;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getRfc()
|
||||
{
|
||||
return $this->rfc;
|
||||
}
|
||||
|
||||
public function getPassword()
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
public function setEmail($value)
|
||||
{
|
||||
$this->Util()->ValidateMail($value);
|
||||
$this->Util()->DB()->setQuery("SELECT COUNT(*) FROM usuario WHERE email ='".$value."'");
|
||||
if($this->Util()->DB()->GetSingle() > 0)
|
||||
{
|
||||
$this->Util()->setError(10005, "error", "");
|
||||
}
|
||||
$this->email = $value;
|
||||
}
|
||||
|
||||
public function getEmail()
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function getEmailLogin()
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function setCp($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->cp = $value;
|
||||
}
|
||||
|
||||
public function getCp()
|
||||
{
|
||||
return $this->cp;
|
||||
}
|
||||
|
||||
public function setProductId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->productId = $value;
|
||||
}
|
||||
|
||||
public function getProductId()
|
||||
{
|
||||
return $this->productId;
|
||||
}
|
||||
*/
|
||||
|
||||
public function setPais($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, "Pais");
|
||||
$this->pais = $value;
|
||||
}
|
||||
|
||||
public function setCalle($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=200, $minChars = 1, "Dirección");
|
||||
$this->calle = $value;
|
||||
}
|
||||
|
||||
public function setRfc($value)
|
||||
{
|
||||
$value = strtoupper($value);
|
||||
$this->Util()->ValidateString($value, $max_chars=13, $minChars = 12, "RFC");
|
||||
$this->rfc = $value;
|
||||
}
|
||||
|
||||
public function setEmpresaId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->empresaId = $value;
|
||||
}
|
||||
|
||||
public function setPassword($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Password');
|
||||
$this->password = $value;
|
||||
}
|
||||
|
||||
public function setEmail($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Email');
|
||||
if($value != '')
|
||||
$this->Util()->ValidateMail($value);
|
||||
$this->email = $value;
|
||||
}
|
||||
|
||||
public function Info()
|
||||
{
|
||||
$generalDb = new DB;
|
||||
|
||||
$sql = "SELECT * FROM empresa WHERE empresaId = '".$this->empresaId."'";
|
||||
$generalDb->setQuery($sql);
|
||||
$row = $generalDb->GetRow();
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
function InfoAll()
|
||||
{
|
||||
$generalDb = new DB;
|
||||
|
||||
$sql = "SELECT * FROM usuario
|
||||
LEFT JOIN empresa ON usuario.empresaId = empresa.empresaId
|
||||
WHERE usuarioId = '".$_SESSION["loginKey"]."'";
|
||||
$generalDb->setQuery($sql);
|
||||
$row = $generalDb->GetRow();
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
function DoLogin()
|
||||
{
|
||||
if($this->Util()->PrintErrors())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$generalDb = new DB;
|
||||
|
||||
echo $sql = "SELECT usuarioId FROM usuario
|
||||
WHERE email = '".$this->email."'
|
||||
AND password = '".$this->password."'
|
||||
AND empresaId = '".$this->empresaId."'
|
||||
AND baja = '0'";
|
||||
$generalDb->setQuery($sql);
|
||||
$usuarioId = $generalDb->GetSingle();
|
||||
|
||||
if(!$usuarioId)
|
||||
{
|
||||
unset($_SESSION["loginKey"]);
|
||||
unset($_SESSION["empresaId"]);
|
||||
$this->Util()->setError(10006, "error");
|
||||
|
||||
if($this->Util()->PrintErrors())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM usuario
|
||||
LEFT JOIN empresa ON usuario.empresaId = empresa.empresaId
|
||||
WHERE usuarioId = '".$usuarioId."'";
|
||||
$generalDb->setQuery($sql);
|
||||
$info = $generalDb->GetRow();
|
||||
|
||||
$_SESSION["loginKey"] = $usuarioId;
|
||||
$_SESSION["idSuc"] = $info['sucursalId'];
|
||||
$_SESSION["empresaId"] = $this->empresaId;
|
||||
$_SESSION["version"] = $info["version"];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function DoLogout()
|
||||
{
|
||||
unset($_SESSION["loginKey"]);
|
||||
unset($_SESSION["empresaId"]);
|
||||
}
|
||||
|
||||
function IsLoggedIn()
|
||||
{
|
||||
if($_SESSION["loginKey"])
|
||||
{
|
||||
$GLOBALS["smarty"]->assign('user', $this->Info());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
function Info($userId = 0)
|
||||
{
|
||||
$generalDb = new DB;
|
||||
$generalDb->setQuery("SELECT * FROM usuario
|
||||
LEFT JOIN empresa ON usuario.empresaId = empresa.empresaId WHERE userId = '".$userId."'");
|
||||
if($userId == 0)
|
||||
{
|
||||
$generalDb->setQuery("SELECT * FROM usuario
|
||||
LEFT JOIN empresa ON usuario.empresaId = empresa.empresaId WHERE email = '".$_SESSION["loginKey"]."'");
|
||||
}
|
||||
$user = $generalDb->GetRow();
|
||||
|
||||
if(!$user)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function AuthUser()
|
||||
{
|
||||
if(!$this->IsLoggedIn())
|
||||
{
|
||||
$this->Util()->LoadPage('login');
|
||||
return;
|
||||
}
|
||||
|
||||
}//AuthUser
|
||||
|
||||
/*
|
||||
|
||||
function ListSucursales()
|
||||
{
|
||||
|
||||
$this->Util()->DB()->setQuery("SELECT * FROM sucursal WHERE empresaId = ".$this->empresaId." ORDER BY identificador");
|
||||
|
||||
$result = $this->Util()->DB()->GetResult();
|
||||
|
||||
foreach($result as $key => $periodo)
|
||||
{
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
function GetSucursalInfo()
|
||||
{
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT * FROM sucursal WHERE empresaId = ".$this->empresaId." AND sucursalId = ".$this->sucursalId);
|
||||
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function GetPublicEmpresaInfo()
|
||||
{
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT * FROM rfc LIMIT 1");
|
||||
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $result;
|
||||
}
|
||||
*/
|
||||
|
||||
}//empresa
|
||||
|
||||
|
||||
?>
|
||||
1489
classes/envio.class.php
Executable file
1489
classes/envio.class.php
Executable file
File diff suppressed because it is too large
Load Diff
95
classes/error.class.php
Executable file
95
classes/error.class.php
Executable file
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
class Error
|
||||
{
|
||||
private $type = array();
|
||||
private $errorField = array();
|
||||
private $error = array();
|
||||
private $complete = false;
|
||||
|
||||
public function Util()
|
||||
{
|
||||
if($this->Util == null )
|
||||
{
|
||||
$this->Util = new Util();
|
||||
}
|
||||
return $this->Util;
|
||||
}
|
||||
|
||||
public function setError($value = NULL, $type="error", $custom = "", $errorField = "")
|
||||
{
|
||||
$this->type[] = $type;
|
||||
$this->setErrorField($errorField);
|
||||
$this->setErrorValue($value, $custom);
|
||||
|
||||
if($type == "complete")
|
||||
{
|
||||
$this->complete = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function setErrorValue($value, $custom)
|
||||
{
|
||||
if($custom != "")
|
||||
{
|
||||
$this->error[] = $custom;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error[] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
function setErrorField($value)
|
||||
{
|
||||
if($value != "")
|
||||
{
|
||||
$this->errorField[] = $value;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->errorField[] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
public function getErrors()
|
||||
{
|
||||
global $property;
|
||||
foreach($this->error as $key => $val)
|
||||
{
|
||||
if(is_numeric($val))
|
||||
{
|
||||
$this->error[$key] = $property["error"][$val];
|
||||
}
|
||||
}
|
||||
|
||||
$errors = array("value" => $this->error, "field" => $this->errorField, "type" => $this->type);
|
||||
|
||||
$errors["total"] = count($errors["value"]);
|
||||
$errors["complete"] = $this->complete;
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
public function cleanErrors()
|
||||
{
|
||||
$this->error = array();
|
||||
$this->errorField = array();
|
||||
$this->type = array();
|
||||
$this->complete = false;
|
||||
}
|
||||
|
||||
public function PrintErrors()
|
||||
{
|
||||
$errors = $this->getErrors();
|
||||
if($errors["total"])
|
||||
{
|
||||
$GLOBALS["smarty"]->assign('errors', $errors);
|
||||
$this->cleanErrors();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
364
classes/evaluaPedido.class.php
Executable file
364
classes/evaluaPedido.class.php
Executable file
@@ -0,0 +1,364 @@
|
||||
<?php
|
||||
|
||||
class EvaluaPedido extends Main
|
||||
{
|
||||
private $pedidoId;
|
||||
private $pedidoPagoId;
|
||||
private $metodoPagoId;
|
||||
private $cuentaBancariaId;
|
||||
private $proveedorId;
|
||||
private $cantidad;
|
||||
private $fecha;
|
||||
private $noCheque;
|
||||
private $noFactura;
|
||||
private $status;
|
||||
private $plazo;
|
||||
private $bonificacion;
|
||||
private $prodItemId;
|
||||
private $productoId;
|
||||
|
||||
public function setProductoId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->productoId = $value;
|
||||
}
|
||||
|
||||
public function setBonificacion($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->bonificacion = $value;
|
||||
}
|
||||
|
||||
public function setPlazo($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->plazo = $value;
|
||||
}
|
||||
|
||||
public function setPedidoPagoId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->pedidoPagoId = $value;
|
||||
}
|
||||
|
||||
public function setPedidoId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->pedidoId = $value;
|
||||
}
|
||||
|
||||
public function setProdItemId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->prodItemId = $value;
|
||||
}
|
||||
|
||||
public function setMetodoPagoId($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Método de Pago');
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->metodoPagoId = $value;
|
||||
}
|
||||
|
||||
public function setCuentaBancariaId($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Cuenta Bancaria');
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->cuentaBancariaId = $value;
|
||||
}
|
||||
|
||||
public function setProveedorId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->proveedorId = $value;
|
||||
}
|
||||
|
||||
public function setCantidad($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Cantidad');
|
||||
$this->cantidad = $value;
|
||||
}
|
||||
|
||||
public function setFecha($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Fecha');
|
||||
$this->fecha = $value;
|
||||
}
|
||||
|
||||
public function setNoCheque($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'No. de Cheque');
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->noCheque = $value;
|
||||
}
|
||||
|
||||
public function setNoFactura($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'No. de Factura');
|
||||
$this->noFactura = $value;
|
||||
}
|
||||
|
||||
public function setStatus($value)
|
||||
{
|
||||
$this->status = $value;
|
||||
}
|
||||
|
||||
public function InfoPago(){
|
||||
|
||||
$sql = 'SELECT * FROM pedidoPago
|
||||
WHERE pedidoPagoId = "'.$this->pedidoPagoId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$info = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
function Enumerate()
|
||||
{
|
||||
$sql = "SELECT * FROM pedido LEFT JOIN proveedor ON(proveedor.proveedorId = pedido.proveedorId) WHERE pedido.`status` LIKE 'EnvSuc' OR pedido.`status` LIKE 'OrdenCompIng'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
$pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/evaluar-pedidos");
|
||||
|
||||
//$sqlAdd = "LIMIT ".$pages["start"].", ".$pages["items_per_page"];
|
||||
|
||||
$sql = "SELECT * FROM pedido LEFT JOIN proveedor ON(proveedor.proveedorId = pedido.proveedorId) WHERE pedido.`status` LIKE 'EnvSuc' OR pedido.`status` LIKE 'OrdenCompIng' ORDER BY `pedido`.`proveedorId`, pedido.fechaOrdenCompIng ASC ";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$data["items"] = $result;
|
||||
$data["pages"] = $pages;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function EnumPagos(){
|
||||
|
||||
$sql = 'SELECT * FROM pedidoPago
|
||||
WHERE pedidoId = "'.$this->pedidoId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$pagos = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $pagos;
|
||||
}
|
||||
|
||||
function GetTotalPagos(){
|
||||
|
||||
$sql = 'SELECT SUM(cantidad) FROM pedidoPago
|
||||
WHERE pedidoId = "'.$this->pedidoId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
function SavePago()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){ return false; }
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("
|
||||
INSERT INTO `pedidoPago` (
|
||||
pedidoId,
|
||||
metodoPagoId,
|
||||
cuentaBancariaId,
|
||||
proveedorId,
|
||||
cantidad,
|
||||
fecha,
|
||||
noCheque,
|
||||
noFactura
|
||||
)
|
||||
VALUES (
|
||||
'".$this->pedidoId."',
|
||||
'".$this->metodoPagoId."',
|
||||
'".$this->cuentaBancariaId."',
|
||||
'".$this->proveedorId."',
|
||||
'".$this->cantidad."',
|
||||
'".$this->fecha."',
|
||||
'".$this->noCheque."',
|
||||
'".$this->noFactura."'
|
||||
)"
|
||||
);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->InsertData();
|
||||
|
||||
$this->Util()->setError(30057, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function DeletePago(){
|
||||
|
||||
$sql = "DELETE FROM
|
||||
pedidoPago
|
||||
WHERE
|
||||
pedidoPagoId = '".$this->pedidoPagoId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$this->Util()->setError(30059, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getTotalVentas()
|
||||
{
|
||||
$sql = 'SELECT SUM(producto.precioVentaIva) FROM producto LEFT JOIN inventario ON(inventario.productoId = producto.productoId) WHERE inventario.status LIKE "Vendido" AND pedidoId = "'.$this->pedidoId.'" GROUP BY pedidoId';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
/* public function getTotalVendidos2()
|
||||
{
|
||||
$sql = 'SELECT COUNT(*) FROM pedido LEFT JOIN inventario ON(inventario.pedidoId = pedido.pedidoId) LEFT JOIN producto ON(producto.productoId = inventario.productoId) WHERE pedido.pedidoId = 2 AND inventario.status = "Vendido" AND pedido.pedidoId = "'.$this->pedidoId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
public function getTotalProductos()
|
||||
{
|
||||
$sql = 'SELECT COUNT(*) FROM pedido LEFT JOIN inventario ON(inventario.pedidoId = pedido.pedidoId) LEFT JOIN producto ON(producto.productoId = inventario.productoId) WHERE pedido.pedidoId = 2 AND pedido.pedidoId = "'.$this->pedidoId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $total;
|
||||
}*/
|
||||
|
||||
public function evaluar()
|
||||
{
|
||||
$opc = false;
|
||||
|
||||
$diasTranscurridos = round($this->Util()->GetDiffDates($this->fecha,$this->Util()->Today()));
|
||||
//echo $diasTranscurridos."<br>";
|
||||
|
||||
if(($diasTranscurridos >= ($this->plazo/2) && $diasTranscurridos < ($this->plazo)))
|
||||
$opc = true;
|
||||
return $opc;
|
||||
}
|
||||
|
||||
public function evaluar2()
|
||||
{
|
||||
$opc = false;
|
||||
|
||||
$diasTranscurridos = round($this->Util()->GetDiffDates($this->fecha,$this->Util()->Today()));
|
||||
//echo $diasTranscurridos."<br>";
|
||||
|
||||
if($diasTranscurridos >= $this->plazo)
|
||||
$opc = true;
|
||||
return $opc;
|
||||
}
|
||||
|
||||
public function evaluarVentas()
|
||||
{
|
||||
@$porcentajeVendidos = round(($this->getTotalVendidos()*100)/$this->GetTotalProductosPedido());
|
||||
return $porcentajeVendidos;
|
||||
}
|
||||
|
||||
function searchProductos()
|
||||
{
|
||||
$sql = 'SELECT * FROM producto LEFT JOIN pedidoProducto ON(pedidoProducto.productoId = producto.productoId) LEFT JOIN pedido ON(pedido.pedidoId = pedidoProducto.pedidoId) WHERE pedido.pedidoId = '.$this->pedidoId;
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$productos = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
return $productos;
|
||||
}
|
||||
|
||||
function GetTotalVendidos()
|
||||
{
|
||||
$totalVendidos = $this->GetTotalProductosPedido()-$this->GetDisponible();
|
||||
return $totalVendidos;
|
||||
}
|
||||
|
||||
function GetTotalProductosPedido()
|
||||
{
|
||||
$sql = "SELECT
|
||||
SUM(cantidad)
|
||||
FROM
|
||||
inventario
|
||||
WHERE
|
||||
pedidoId = '".$this->pedidoId."'
|
||||
AND
|
||||
productoId = '".$this->productoId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
function GetDisponible(){
|
||||
|
||||
$sql = "SELECT
|
||||
SUM(cantidad)
|
||||
FROM
|
||||
inventario
|
||||
WHERE
|
||||
pedidoId = '".$this->pedidoId."'
|
||||
AND
|
||||
productoId = '".$this->productoId."'
|
||||
AND
|
||||
`status` = 'Disponible'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
function InfoPedidoProveedor()
|
||||
{
|
||||
$sql = "SELECT * FROM pedido LEFT JOIN proveedor ON(proveedor.proveedorId = pedido.proveedorId) WHERE pedido.pedidoId = ".$this->pedidoId." ORDER BY `pedido`.`proveedorId`, pedido.fechaEntrega ASC ";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function searchProductoById()
|
||||
{
|
||||
$sql = 'SELECT * FROM producto LEFT JOIN pedidoProducto ON(pedidoProducto.productoId = producto.productoId) LEFT JOIN pedido ON(pedido.pedidoId = pedidoProducto.pedidoId) LEFT JOIN productoItem ON(productoItem.productoId = producto.productoId) WHERE pedido.pedidoId = '.$this->pedidoId.' AND prodItemId = '.$this->prodItemId;
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$producto = $this->Util()->DBSelect($_SESSION['empresaId'])->GetRow();
|
||||
|
||||
return $producto;
|
||||
}
|
||||
|
||||
function ActualizaPendientes()
|
||||
{
|
||||
$sql = 'DELETE FROM bonificacion WHERE estatus LIKE "Pendiente"';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$producto = $this->Util()->DBSelect($_SESSION['empresaId'])->DeleteData();
|
||||
}
|
||||
|
||||
function GetPedidos()
|
||||
{
|
||||
$sql = "SELECT bonificacion.pedidoId, proveedor.nombre, bonificacion.proveedorId, bonificacion.estatus FROM bonificacion LEFT JOIN proveedor ON(proveedor.proveedorId = bonificacion.proveedorId) GROUP BY pedidoId ORDER BY pedidoId";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$pedidos = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
return $pedidos;
|
||||
}
|
||||
|
||||
function getTotalBonificaciones()
|
||||
{
|
||||
$sql = "SELECT SUM(totalBonificacion) FROM bonificacion WHERE pedidoId = '".$this->pedidoId."' AND tipo LIKE 'Bonificacion'";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
function getTotalDevoluciones()
|
||||
{
|
||||
$sql = "SELECT SUM(totalBonificacion) FROM bonificacion WHERE pedidoId = '".$this->pedidoId."' AND tipo LIKE 'Devolucion'";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
return $total;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
465
classes/facturacion.class.php
Executable file
465
classes/facturacion.class.php
Executable file
@@ -0,0 +1,465 @@
|
||||
<?php
|
||||
|
||||
class Facturacion extends Main
|
||||
{
|
||||
private $comprobanteId;
|
||||
private $sucursalId;
|
||||
private $nombre;
|
||||
private $rfc;
|
||||
private $mes;
|
||||
private $anio;
|
||||
private $tiposComprobanteId;
|
||||
private $motivoCancelacion;
|
||||
private $status;
|
||||
|
||||
public function setComprobanteId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->comprobanteId = $value;
|
||||
}
|
||||
|
||||
public function setSucursalId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->sucursalId = $value;
|
||||
}
|
||||
|
||||
public function setNombre($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=30, $minChars = 0, 'Nombre');
|
||||
$this->nombre = $value;
|
||||
}
|
||||
|
||||
public function setRfc($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=12, $minChars = 0, 'RFC');
|
||||
$this->rfc = $value;
|
||||
}
|
||||
|
||||
public function setMes($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->mes = $value;
|
||||
}
|
||||
|
||||
public function setAnio($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->anio = $value;
|
||||
}
|
||||
|
||||
public function setTiposComprobanteId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->tiposComprobanteId = $value;
|
||||
}
|
||||
|
||||
public function setMotivoCancelacion($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=12, $minChars = 1, 'Motivo de Cancelación');
|
||||
$this->motivoCancelacion = $value;
|
||||
}
|
||||
|
||||
public function setStatus($value)
|
||||
{
|
||||
$this->status = $value;
|
||||
}
|
||||
|
||||
function Info()
|
||||
{
|
||||
$sql = 'SELECT * FROM comprobante WHERE comprobanteId = "'.$this->comprobanteId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$row = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
function GetVentaId()
|
||||
{
|
||||
$sql = 'SELECT ventaId FROM venta WHERE comprobanteId = "'.$this->comprobanteId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$ventaId = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $ventaId;
|
||||
}
|
||||
|
||||
function Buscar()
|
||||
{
|
||||
$sqlAdd = '';
|
||||
|
||||
if($this->nombre)
|
||||
$sqlAdd = ' AND clte.nombre LIKE "%'.$this->nombre.'%"';
|
||||
|
||||
if($this->rfc)
|
||||
$sqlAdd = ' AND clte.rfc LIKE "%'.$this->rfc.'%"';
|
||||
|
||||
if($this->mes)
|
||||
$sqlAdd .= ' AND EXTRACT(MONTH FROM comp.fecha) = "'.$this->mes.'"';
|
||||
|
||||
if($this->anio)
|
||||
$sqlAdd .= ' AND EXTRACT(YEAR FROM comp.fecha) = "'.$this->anio.'"';
|
||||
|
||||
if($this->status != '')
|
||||
$sqlAdd .= ' AND comp.status = "'.$this->status.'"';
|
||||
|
||||
if($this->tiposComprobanteId)
|
||||
$sqlAdd .= ' AND comp.tiposComprobanteId = "'.$this->tiposComprobanteId.'"';
|
||||
|
||||
$sql = 'SELECT
|
||||
comp.*
|
||||
FROM
|
||||
comprobante AS comp,
|
||||
cliente AS clte
|
||||
WHERE
|
||||
comp.userId = clte.clienteId
|
||||
AND
|
||||
comp.sucursalId = "'.$this->sucursalId.'"
|
||||
AND
|
||||
facturaGlobal = "0"
|
||||
'.$sqlAdd.'
|
||||
ORDER BY
|
||||
comp.fecha DESC
|
||||
';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$comprobantes = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$data["items"] = $comprobantes;
|
||||
$data["pages"] = array();
|
||||
|
||||
return $data;
|
||||
|
||||
}//Buscar
|
||||
|
||||
function BuscarMens()
|
||||
{
|
||||
$sqlAdd = '';
|
||||
|
||||
if($this->mes)
|
||||
$sqlAdd .= ' AND EXTRACT(MONTH FROM fecha) = "'.$this->mes.'"';
|
||||
|
||||
if($this->anio)
|
||||
$sqlAdd .= ' AND EXTRACT(YEAR FROM fecha) = "'.$this->anio.'"';
|
||||
|
||||
if($this->status != '')
|
||||
$sqlAdd .= ' AND status = "'.$this->status.'"';
|
||||
|
||||
if($this->tiposComprobanteId)
|
||||
$sqlAdd .= ' AND tiposComprobanteId = "'.$this->tiposComprobanteId.'"';
|
||||
|
||||
$sql = 'SELECT
|
||||
*
|
||||
FROM
|
||||
comprobante
|
||||
WHERE
|
||||
sucursalId = "'.$this->sucursalId.'"
|
||||
AND
|
||||
facturaGlobal = "1"
|
||||
'.$sqlAdd.'
|
||||
ORDER BY
|
||||
fecha DESC';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$comprobantes = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$data["items"] = $comprobantes;
|
||||
$data["pages"] = array();
|
||||
|
||||
return $data;
|
||||
|
||||
}//BuscarMens
|
||||
|
||||
function SendComprobante(){
|
||||
|
||||
global $comprobante;
|
||||
global $rfc;
|
||||
global $cliente;
|
||||
|
||||
$infC = $comprobante->GetInfoComprobante($this->comprobanteId);
|
||||
|
||||
$clienteId = $infC['userId'];
|
||||
$cliente->setClienteId($clienteId);
|
||||
$infU = $cliente->Info();
|
||||
|
||||
$nombre = $infU['nombre'];
|
||||
$email = $infU['email'];
|
||||
|
||||
$rfcId = $infC['rfcId'];
|
||||
$empresaId = $infC['empresaId'];
|
||||
$serie = $infC['serie'];
|
||||
$folio = $infC['folio'];
|
||||
|
||||
$archivo = $empresaId.'_'.$serie.'_'.$folio.'.pdf';
|
||||
|
||||
$enlace = DOC_ROOT.'/empresas/'.$empresaId.'/certificados/'.$rfcId.'/facturas/pdf/'.$archivo;
|
||||
|
||||
if($_SESSION["version"] == "v3" || $_SESSION["version"] == "construc")
|
||||
{
|
||||
$archivo_xml = "SIGN_".$empresaId.'_'.$serie.'_'.$folio.'.xml';
|
||||
}
|
||||
else
|
||||
{
|
||||
$archivo_xml = $empresaId.'_'.$serie.'_'.$folio.'.xml';
|
||||
}
|
||||
|
||||
$enlace_xml = DOC_ROOT.'/empresas/'.$empresaId.'/certificados/'.$rfcId.'/facturas/xml/'.$archivo_xml;
|
||||
|
||||
$rfc->setRfcId($rfcId);
|
||||
$info = $rfc->Info();
|
||||
|
||||
$mail = new PHPMailer();
|
||||
$mail->Host = 'localhost';
|
||||
$mail->From = 'facturacion@novomoda.com';
|
||||
$mail->FromName = urldecode($info["razonSocial"]);
|
||||
$mail->Subject = 'Envio de Factura con Folio No. '.$folio;
|
||||
$mail->AddAddress($email, '');
|
||||
$body = "Favor de revisar el archivo adjunto para ver factura.\r\n";
|
||||
$body .= "\r\n";
|
||||
$body .= "Gracias.\r\n";
|
||||
$body .= "www.novomoda.com\r\n";
|
||||
$mail->Body = $body;
|
||||
|
||||
//Adjuntamos un archivo
|
||||
$mail->AddAttachment($enlace, 'Factura_'.$folio.'.pdf');
|
||||
$mail->AddAttachment($enlace_xml, 'XML_Factura_'.$folio.'.xml');
|
||||
$mail->Send();
|
||||
|
||||
$this->Util()->setError(20023, 'complete');
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
}//SendComprobante
|
||||
|
||||
function CancelarComprobante(){
|
||||
|
||||
global $comprobante;
|
||||
|
||||
if($this->Util()->PrintErrors())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$comprobanteId = $this->comprobanteId;
|
||||
$motivoCancelacion = $this->motivoCancelacion;
|
||||
|
||||
$date = date("Y-m-d");
|
||||
$sqlQuery = 'UPDATE comprobante
|
||||
SET motivoCancelacion = "'.utf8_encode($motivoCancelacion).'", status = "0", fechaPedimento = "'.$date.'"
|
||||
WHERE comprobanteId = '.$comprobanteId;
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sqlQuery);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
|
||||
|
||||
$sqlQuery = 'SELECT data, conceptos, userId FROM comprobante WHERE comprobanteId = '.$comprobanteId;
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sqlQuery);
|
||||
$row = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
$data = unserialize(urldecode($row['data']));
|
||||
$conceptos = unserialize(urldecode($row['conceptos']));
|
||||
|
||||
$_SESSION["conceptos"] = array();
|
||||
$_SESSION["conceptos"] = $conceptos;
|
||||
$comprobante->CancelarComprobante($data, $comprobanteId, false, $row["userId"]);
|
||||
|
||||
$this->Util()->setError(20091, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}//CancelarComprobante
|
||||
|
||||
function LoadConceptoPublico($notas, $fechaIni, $fechaFin)
|
||||
{
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$info['sucursalId'] = $_SESSION['idSuc'];
|
||||
|
||||
$count = 0;
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT iva FROM sucursal WHERE sucursalId ='".$info["sucursalId"]."'");
|
||||
$ivaPercent = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
$subtotal = 0;
|
||||
$iva = 0;
|
||||
$notasFacturadas = '';
|
||||
|
||||
$rangos = array();
|
||||
$folioIni = 0;
|
||||
$folioAnt = 0;
|
||||
|
||||
if($notas){
|
||||
|
||||
foreach($notas as $id){
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT * FROM venta WHERE ventaId = '".$id."'");
|
||||
$infV = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
if($infV['subtotalDesc'] > 0){
|
||||
$subtotal += $infV['subtotalDesc'];
|
||||
$iva += $infV['ivaDesc'];
|
||||
}else{
|
||||
$subtotal += $infV['subtotal'];
|
||||
$iva += $infV['iva'];
|
||||
}//else
|
||||
|
||||
//Agrupamos
|
||||
|
||||
$folio = $infV['folio'];
|
||||
|
||||
if($folioAnt == 0){
|
||||
$folioAnt = $folio;
|
||||
$folioIni = $folio;
|
||||
$resta = 0;
|
||||
}
|
||||
|
||||
$resta = $folio - $folioAnt;
|
||||
|
||||
if($resta >= 2){
|
||||
if($folioIni == $folioAnt)
|
||||
$rangos[] = $folioIni;
|
||||
else
|
||||
$rangos[] = $folioIni.'-'.$folioAnt;
|
||||
|
||||
$folioIni = $folio;
|
||||
$folioAnt = $folio;
|
||||
}
|
||||
|
||||
$folioAnt = $folio;
|
||||
|
||||
}//foreach
|
||||
|
||||
}
|
||||
|
||||
if($folioIni == $folioAnt)
|
||||
$rangos[] = $folioIni;
|
||||
else
|
||||
$rangos[] = $folioIni.'-'.$folioAnt;
|
||||
|
||||
$notasFacturadas = implode(', ',$rangos);
|
||||
|
||||
$fechaIni = date('d-m-Y',strtotime($fechaIni));
|
||||
$fechaFin = date('d-m-Y',strtotime($fechaFin));
|
||||
|
||||
$_SESSION["conceptos"][$count]["noIdentificacion"] = "PEG";
|
||||
$_SESSION["conceptos"][$count]["cantidad"] = 1;
|
||||
$_SESSION["conceptos"][$count]["unidad"] = "No Aplica";
|
||||
$_SESSION["conceptos"][$count]["valorUnitario"] = $subtotal;
|
||||
$_SESSION["conceptos"][$count]["importe"] = $subtotal;
|
||||
$_SESSION["conceptos"][$count]["hardCodedIva"] = $iva;
|
||||
$_SESSION["conceptos"][$count]["excentoIva"] = "no";
|
||||
$_SESSION["conceptos"][$count]["descripcion"] = urldecode("Factura correspondiente a los tickets de venta del ".$fechaIni." al ".$fechaFin.": ".$notasFacturadas);
|
||||
|
||||
return true;
|
||||
|
||||
}//LoadConceptoPublico
|
||||
|
||||
function GetTotalDesglosado()
|
||||
{
|
||||
$values = explode("&", $_POST["form"]);
|
||||
foreach($values as $key => $val)
|
||||
{
|
||||
$array = explode("=", $values[$key]);
|
||||
$data[$array[0]] = $array[1];
|
||||
}
|
||||
|
||||
$ivaForm = $data['tasaIva'];
|
||||
|
||||
if(!$_SESSION["conceptos"])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$data["subtotal"] = 0;
|
||||
$data["descuento"] = 0;
|
||||
$data["iva"] = 0;
|
||||
$data["ieps"] = 0;
|
||||
$data["retIva"] = 0;
|
||||
$data["retIsr"] = 0;
|
||||
$data["total"] = 0;
|
||||
|
||||
foreach($data as $key => $value)
|
||||
{
|
||||
$data[$key] = $this->Util()->RoundNumber($data[$key]);
|
||||
}
|
||||
|
||||
$info['sucursalId'] = $_SESSION['idSuc'];
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("
|
||||
SELECT * FROM sucursal
|
||||
LEFT JOIN rfc ON rfc.rfcId = sucursal.rfcId
|
||||
WHERE sucursal.sucursalId ='".$info["sucursalId"]."'");
|
||||
$sucursal = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
$suc['iva'] = $ivaForm;
|
||||
|
||||
foreach($_SESSION["conceptos"] as $key => $concepto)
|
||||
{
|
||||
$data["subtotalOriginal"] = $this->Util()->RoundNumber($data["subtotalOriginal"] + $importe);
|
||||
|
||||
$data["subtotal"] = $this->Util()->RoundNumber($data["subtotal"] + $concepto["importe"]);
|
||||
|
||||
if($concepto["excentoIva"] == "si")
|
||||
{
|
||||
$_SESSION["conceptos"][$key]["tasaIva"] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$_SESSION["conceptos"][$key]["tasaIva"] = $suc["iva"];
|
||||
}
|
||||
|
||||
|
||||
if($data["porcentajeDescuento"])
|
||||
{
|
||||
$data["porcentajeDescuento"];
|
||||
}
|
||||
|
||||
$data["descuentoThis"] = $this->Util()->RoundNumber($_SESSION["conceptos"][$key]["importe"] * ($data["porcentajeDescuento"] / 100));
|
||||
$data["descuento"] += $data["descuentoThis"];
|
||||
|
||||
$afterDescuento = $_SESSION["conceptos"][$key]["importe"] - $data["descuentoThis"];
|
||||
if($concepto["excentoIva"] == "si")
|
||||
{
|
||||
$_SESSION["conceptos"][$key]["tasaIva"] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$_SESSION["conceptos"][$key]["tasaIva"] = $suc["iva"];
|
||||
}
|
||||
|
||||
$data["ivaThis"] = $this->Util()->RoundNumber($afterDescuento * ($_SESSION["conceptos"][$key]["tasaIva"] / 100));
|
||||
|
||||
if(isset($_SESSION["conceptos"][$key]["hardCodedIva"]))
|
||||
{
|
||||
$data["iva"] = $_SESSION["conceptos"][$key]["hardCodedIva"];
|
||||
}
|
||||
else
|
||||
{
|
||||
$data["iva"] += $data["ivaThis"];
|
||||
}
|
||||
}
|
||||
|
||||
$data["impuestos"] = $_SESSION["impuestos"];
|
||||
|
||||
$afterDescuento = $data["subtotal"] - $data["descuento"];
|
||||
|
||||
$data["afterDescuento"] = $afterDescuento;
|
||||
|
||||
$data["afterIva"] = $afterDescuento + $data["iva"];
|
||||
|
||||
if(!$data["porcentajeIEPS"])
|
||||
{
|
||||
$data["porcentajeIEPS"] = 0;
|
||||
}
|
||||
|
||||
$data["ieps"] = $this->Util()->RoundNumber($data["afterDescuento"] * ($data["porcentajeIEPS"] / 100));
|
||||
$afterImpuestos = $afterDescuento + $data["iva"] + $data["ieps"];
|
||||
$data["afterImpuestos"] = $afterImpuestos;
|
||||
|
||||
$data["retIva"] = $this->Util()->RoundNumber($data["afterDescuento"] * ($data["porcentajeRetIva"] / 100));
|
||||
$data["retIsr"] = $this->Util()->RoundNumber($data["afterDescuento"] * ($data["porcentajeRetIsr"] / 100));
|
||||
$data["total"] = $this->Util()->RoundNumber($data["subtotal"] - $data["descuento"] + $data["iva"] + $data["ieps"] - $data["retIva"] - $data["retIsr"]);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}//Facturacion
|
||||
|
||||
?>
|
||||
415
classes/folios.class.php
Executable file
415
classes/folios.class.php
Executable file
@@ -0,0 +1,415 @@
|
||||
<?php
|
||||
|
||||
class Folios extends Main{
|
||||
|
||||
private $id_serie;
|
||||
private $id_empresa;
|
||||
private $id_rfc;
|
||||
private $serie;
|
||||
private $folio_inicial;
|
||||
private $folio_final;
|
||||
private $no_aprobacion;
|
||||
private $anio_aprobacion;
|
||||
private $comprobante;
|
||||
private $lugar_expedicion;
|
||||
private $no_certificado;
|
||||
private $email;
|
||||
|
||||
public function setIdSerie($value){
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 1, 'Serie ID');
|
||||
$this->id_serie = $value;
|
||||
}
|
||||
|
||||
public function setIdEmpresa($value){
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 1, 'Empresa ID');
|
||||
$this->id_empresa = $value;
|
||||
}
|
||||
|
||||
public function setIdRfc($value){
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 1, 'Rfc ID');
|
||||
$this->id_rfc = $value;
|
||||
}
|
||||
|
||||
public function setSerie($value){
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'Serie');
|
||||
$this->serie = $value;
|
||||
}
|
||||
|
||||
public function setFolioInicial($value){
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 1, 'Folio Inicial');
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->folio_inicial = $value;
|
||||
}
|
||||
|
||||
public function setFolioFinal($value){
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 1, 'Folio Final');
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->folio_final = $value;
|
||||
}
|
||||
|
||||
public function setNoAprobacion($value){
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'No de Aprobacion');
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->no_aprobacion = $value;
|
||||
}
|
||||
|
||||
public function setAnioAprobacion($value){
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'Ano de Aprobacion');
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->anio_aprobacion = $value;
|
||||
}
|
||||
|
||||
public function setComprobante($value){
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 1, 'Comprobante');
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->comprobante = $value;
|
||||
}
|
||||
|
||||
public function setLugarExpedicion($value){
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 1, 'Lugar de expedicion');
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->lugar_expedicion = $value;
|
||||
}
|
||||
|
||||
public function setNoCertificado($value){
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 1, 'No Certificado');
|
||||
$this->no_certificado = $value;
|
||||
}
|
||||
|
||||
public function setEmail($value){
|
||||
|
||||
$value = $this->Util()->DecodeVal($value);
|
||||
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 1, 'Email');
|
||||
|
||||
if($value != '')
|
||||
$this->Util()->ValidateMail($value);
|
||||
|
||||
$this->email = $value;
|
||||
}
|
||||
|
||||
/* Return values Var */
|
||||
|
||||
public function getIdSerie(){
|
||||
return $this->id_serie;
|
||||
}
|
||||
|
||||
public function getIdEmpresa(){
|
||||
return $this->id_empresa;
|
||||
}
|
||||
|
||||
public function getIdRfc(){
|
||||
return $this->id_rfc;
|
||||
}
|
||||
|
||||
public function getSerie(){
|
||||
return $this->serie;
|
||||
}
|
||||
|
||||
public function getFolioInicial(){
|
||||
return $this->folio_inicial;
|
||||
}
|
||||
|
||||
public function getFolioFinal(){
|
||||
return $this->folio_final;
|
||||
}
|
||||
|
||||
public function getNoAprobacion(){
|
||||
return $this->no_aprobacion;
|
||||
}
|
||||
|
||||
public function getAnioAprobacion(){
|
||||
return $this->anio_aprobacion;
|
||||
}
|
||||
|
||||
public function getComprobante(){
|
||||
return $this->comprobante;
|
||||
}
|
||||
|
||||
public function getLugarExpedicion(){
|
||||
return $this->lugar_expedicion;
|
||||
}
|
||||
|
||||
public function getNoCertificado(){
|
||||
return $this->no_certificado;
|
||||
}
|
||||
|
||||
public function getEmail(){
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
function AddFolios(){
|
||||
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
if($this->VerifyFolios()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
|
||||
INSERT INTO `serie` (
|
||||
`empresaId`,
|
||||
`rfcId`,
|
||||
`sucursalId`,
|
||||
`serie`,
|
||||
`folioInicial`,
|
||||
`folioFinal`,
|
||||
`noAprobacion`,
|
||||
`anoAprobacion`,
|
||||
`tiposComprobanteId`,
|
||||
`lugarDeExpedicion`,
|
||||
`noCertificado`,
|
||||
`email`,
|
||||
`consecutivo`
|
||||
)
|
||||
VALUES (
|
||||
'".$this->getIdEmpresa()."',
|
||||
'".$this->getIdRfc()."',
|
||||
'".$this->getLugarExpedicion()."',
|
||||
'".$this->getSerie()."',
|
||||
'".$this->getFolioInicial()."',
|
||||
'".$this->getFolioFinal()."',
|
||||
'".$this->getNoAprobacion()."',
|
||||
'".$this->getAnioAprobacion()."',
|
||||
'".$this->getComprobante()."',
|
||||
'".$this->getLugarExpedicion()."',
|
||||
'".$this->getNoCertificado()."',
|
||||
'".$this->getEmail()."',
|
||||
'".$this->getFolioInicial()."')"
|
||||
);
|
||||
|
||||
$id_serie = $this->Util()->DBSelect($_SESSION['empresaId'])->InsertData();
|
||||
|
||||
$this->Util()->setError(20011, 'complete');
|
||||
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}//AddFolios
|
||||
|
||||
function EditFolios(){
|
||||
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
if($this->VerifyFolios()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
|
||||
UPDATE `serie` SET
|
||||
`empresaId` = '".$this->getIdEmpresa()."',
|
||||
`rfcId` = '".$this->getIdRfc()."',
|
||||
`serie` = '".$this->getSerie()."',
|
||||
`folioInicial` = '".$this->getFolioInicial()."',
|
||||
`folioFinal` = '".$this->getFolioFinal()."',
|
||||
`noAprobacion` = '".$this->getNoAprobacion()."',
|
||||
`anoAprobacion` = '".$this->getAnioAprobacion()."',
|
||||
`tiposComprobanteId` = '".$this->getComprobante()."',
|
||||
`sucursalId` = '".$this->getLugarExpedicion()."',
|
||||
`lugarDeExpedicion` = '".$this->getLugarExpedicion()."',
|
||||
`noCertificado` = '".$this->getNoCertificado()."',
|
||||
`email` = '".$this->getEmail()."'
|
||||
WHERE serieId = '".$this->getIdSerie()."'"
|
||||
);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
|
||||
|
||||
$this->Util()->setError(20013, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
return true;
|
||||
}
|
||||
|
||||
function DeleteFolios(){
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("DELETE FROM serie WHERE serieId = '".$this->id_serie."'");
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$this->Util()->setError(20012, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function VerifyFolios(){
|
||||
|
||||
$serieId = $this->getIdSerie();
|
||||
if(!empty($serieId))
|
||||
$sqlSerie = ' AND serieId <> '.$serieId;
|
||||
|
||||
$sqlQuery = "SELECT
|
||||
*
|
||||
FROM
|
||||
serie
|
||||
WHERE
|
||||
`rfcId` = '".$this->getIdRfc()."'
|
||||
AND
|
||||
`sucursalId` = '".$this->getLugarExpedicion()."'
|
||||
AND
|
||||
`serie` = '".$this->getSerie()."'
|
||||
AND
|
||||
`noAprobacion` = '".$this->getNoAprobacion()."'
|
||||
AND
|
||||
`anoAprobacion` = '".$this->getAnioAprobacion()."'
|
||||
AND
|
||||
`tiposComprobanteId` = '".$this->getComprobante()."'
|
||||
AND
|
||||
`lugarDeExpedicion` = '".$this->getLugarExpedicion()."'
|
||||
AND
|
||||
`noCertificado` = '".$this->getNoCertificado()."'
|
||||
".$sqlSerie;
|
||||
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sqlQuery);
|
||||
$result = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
foreach($result as $row){
|
||||
|
||||
$folioInicial = $row['folioInicial'];
|
||||
$folioFinal = $row['folioFinal'];
|
||||
|
||||
$fi = $this->folio_inicial;
|
||||
$ff = $this->folio_final;
|
||||
|
||||
//Checamos si esta dentro del rango de folios ya agregados
|
||||
if($this->inRange($fi, $folioInicial, $folioFinal) || $this->inRange($ff, $folioInicial, $folioFinal)){
|
||||
$this->Util()->setError(20026, 'error');
|
||||
$this->Util()->PrintErrors();
|
||||
return true;
|
||||
}//if
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
function GetFoliosByEmpresa(){
|
||||
|
||||
$sqlQuery = 'SELECT * FROM serie';
|
||||
|
||||
$id_empresa = $_SESSION['empresaId'];
|
||||
|
||||
$this->Util()->DBSelect($id_empresa)->setQuery($sqlQuery);
|
||||
$folios = $this->Util()->DBSelect($id_empresa)->GetResult();
|
||||
|
||||
foreach($folios as $key => $folios)
|
||||
{
|
||||
$qr = "";
|
||||
$ruta_dir = DOC_ROOT.'/empresas/'.$id_empresa.'/qrs';
|
||||
$ruta_web_dir = WEB_ROOT.'/empresas/'.$id_empresa.'/qrs';
|
||||
if(is_dir($ruta_dir)){
|
||||
if($gd = opendir($ruta_dir)){
|
||||
while($archivo = readdir($gd)){
|
||||
$serie = explode("_", $archivo);
|
||||
if($serie[0] == $_POST['id_serie'])
|
||||
{
|
||||
$qr = $ruta_web_dir.'/'.$archivo;
|
||||
break;
|
||||
}
|
||||
}//while
|
||||
closedir($gd);
|
||||
}//if
|
||||
}//if
|
||||
$folios[$key]["qr"] = $qr;
|
||||
|
||||
$folios[$key]["logo"] = DOC_ROOT."/empresas/15/qrs/".$folio["serieId"].".jpg";
|
||||
|
||||
if(file_exists($folios[$key]["logo"]))
|
||||
{
|
||||
$folios[$key]["logo"] = WEB_ROOT."/empresas/15/qrs/".$folio["serieId"].".jpg";
|
||||
}
|
||||
else
|
||||
{
|
||||
$folios[$key]["logo"] = "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $folios;
|
||||
|
||||
}//GetFoliosByEmpresa
|
||||
|
||||
function GetFoliosByRfc(){
|
||||
|
||||
$sqlQuery = 'SELECT * FROM serie WHERE rfcId = '.$this->getIdRfc();
|
||||
|
||||
$id_empresa = $_SESSION['empresaId'];
|
||||
|
||||
$this->Util()->DBSelect($id_empresa)->setQuery($sqlQuery);
|
||||
$folios = $this->Util()->DBSelect($id_empresa)->GetResult();
|
||||
|
||||
foreach($folios as $key => $folio)
|
||||
{
|
||||
$qr = "";
|
||||
$ruta_dir = DOC_ROOT.'/empresas/'.$id_empresa.'/qrs';
|
||||
$ruta_web_dir = WEB_ROOT.'/empresas/'.$id_empresa.'/qrs';
|
||||
if(is_dir($ruta_dir)){
|
||||
if($gd = opendir($ruta_dir)){
|
||||
while($archivo = readdir($gd)){
|
||||
$serie = explode("_", $archivo);
|
||||
if($serie[0] == $folio['serieId'])
|
||||
{
|
||||
$qr = $ruta_web_dir.'/'.$archivo;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
$serie = explode(".", $serie[0]);
|
||||
if($serie[0] == $folio['serieId'])
|
||||
{
|
||||
$qr = $ruta_web_dir.'/'.$archivo;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}//while
|
||||
closedir($gd);
|
||||
}//if
|
||||
}//if
|
||||
$folios[$key]["qr"] = $qr;
|
||||
|
||||
$folios[$key]["logo"] = DOC_ROOT."/empresas/15/qrs/".$folio["serieId"].".jpg";
|
||||
|
||||
if(file_exists($folios[$key]["logo"]))
|
||||
{
|
||||
$folios[$key]["logo"] = WEB_ROOT."/empresas/15/qrs/".$folio["serieId"].".jpg";
|
||||
}
|
||||
else
|
||||
{
|
||||
$folios[$key]["logo"] = "";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return $folios;
|
||||
|
||||
}//GetFoliosByRfc
|
||||
|
||||
public function setFoliosDelete($value){
|
||||
$this->Util()->ValidateString($value, $max_chars=13, $minChars = 1, "Folios");
|
||||
$this->id_serie = $value;
|
||||
}
|
||||
|
||||
function getInfoFolios(){
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT * FROM serie WHERE serieId ='".$this->id_serie."'");
|
||||
$info = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
function inRange($number, $folioInicial, $folioFinal){
|
||||
|
||||
if($number >= $folioInicial && $number <= $folioFinal)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}//Folios
|
||||
|
||||
|
||||
?>
|
||||
250
classes/generate_xml_default.class.php
Executable file
250
classes/generate_xml_default.class.php
Executable file
@@ -0,0 +1,250 @@
|
||||
<?php
|
||||
class XmlGen extends Producto{
|
||||
|
||||
function CargaAtt(&$nodo, $attr)
|
||||
{
|
||||
foreach ($attr as $key => $val)
|
||||
{
|
||||
if (strlen($val)>0)
|
||||
{
|
||||
$nodo->setAttribute($key,$val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function GenerateXML($data, $serie, $totales, $nodoEmisor, $nodoReceptor, $nodosConceptos,$emp)
|
||||
{
|
||||
global $rfc;
|
||||
|
||||
$xml = new DOMdocument("1.0","UTF-8");
|
||||
$root = $xml->createElement("cfdi:Comprobante");
|
||||
$root = $xml->appendChild($root);
|
||||
|
||||
$root->setAttribute("xmlns:cfdi", "http://www.sat.gob.mx/cfd");
|
||||
$root->setAttribute("xmlns:cfdi", "http://www.sat.gob.mx/cfd/3");
|
||||
$root->setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
|
||||
|
||||
|
||||
$data["fecha"] = explode(" ", $data["fecha"]);
|
||||
$data["fecha"] = $data["fecha"][0]."T".$data["fecha"][1];
|
||||
// $data["fecha"] = "2010-09-22T07:45:09";
|
||||
$this->CargaAtt($root, array("version"=>"3.2",
|
||||
"serie"=>$this->Util()->CadenaOriginalVariableFormat($serie["serie"],false,false),
|
||||
"folio"=>$this->Util()->CadenaOriginalVariableFormat($data["folio"],false,false),
|
||||
"fecha"=>$this->Util()->CadenaOriginalVariableFormat($data["fecha"],false,false),
|
||||
"sello"=>$data["sello"],
|
||||
// "noAprobacion"=>$this->Util()->CadenaOriginalVariableFormat($serie["noAprobacion"],false,false),
|
||||
// "anoAprobacion"=>$this->Util()->CadenaOriginalVariableFormat($serie["anoAprobacion"],false,false),
|
||||
"tipoDeComprobante"=>$this->Util()->CadenaOriginalVariableFormat($data["tipoDeComprobante"],false,false),
|
||||
"formaDePago"=>$this->Util()->CadenaOriginalVariableFormat($data["formaDePago"],false,false),
|
||||
"metodoDePago"=>$this->Util()->CadenaOriginalVariableFormat($data["metodoDePago"],false,false),
|
||||
"LugarExpedicion"=>$this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["sucursal"]["nombre"],false,false),
|
||||
"NumCtaPago"=>$this->Util()->CadenaOriginalVariableFormat($data["numCtaPago"],false,false),
|
||||
"condicionesDePago"=>$this->Util()->CadenaOriginalVariableFormat($data["condicionesDePago"],false,false),
|
||||
"noCertificado"=>$this->Util()->CadenaOriginalVariableFormat($serie["noCertificado"],false,false),
|
||||
"certificado"=>$data["certificado"],
|
||||
"subTotal"=>$this->Util()->CadenaOriginalVariableFormat($totales["subtotal"],true,false),
|
||||
"descuento"=>$this->Util()->CadenaOriginalVariableFormat($totales["descuento"], true,false),
|
||||
//tipos de cambio
|
||||
"TipoCambio"=>$this->Util()->CadenaOriginalVariableFormat($data["tipoDeCambio"], true,false),
|
||||
"Moneda"=>$this->Util()->CadenaOriginalVariableFormat($data["tiposDeMoneda"], false,false),
|
||||
//tipos de cambio
|
||||
"total"=>$this->Util()->CadenaOriginalVariableFormat($totales["total"], true,false)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
$emisor = $xml->createElement("cfdi:Emisor");
|
||||
$emisor = $root->appendChild($emisor);
|
||||
$this->CargaAtt($emisor, array("rfc"=>$this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["rfc"]["rfc"],false,false),
|
||||
"nombre"=>$this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["rfc"]["razonSocial"],false,false)
|
||||
)
|
||||
);
|
||||
|
||||
$domfis = $xml->createElement("cfdi:DomicilioFiscal");
|
||||
$domfis = $emisor->appendChild($domfis);
|
||||
|
||||
//echo $data["nodoEmisor"]["rfc"]["pais"];
|
||||
$this->CargaAtt($domfis, array("calle"=>$this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["rfc"]["calle"],false,false),
|
||||
"noExterior"=>$this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["rfc"]["noExt"],false,false),
|
||||
"noInterior"=>$this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["rfc"]["noInt"],false,false),
|
||||
"colonia"=>$this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["rfc"]["colonia"],false,false),
|
||||
"localidad"=>$this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["rfc"]["localidad"],false,false),
|
||||
"referencia"=>$this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["rfc"]["referencia"],false,false),
|
||||
"municipio"=>$this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["rfc"]["municipio"],false,false),
|
||||
"estado"=>$this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["rfc"]["estado"],false,false),
|
||||
"pais"=>$this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["rfc"]["pais"],false,false),
|
||||
"codigoPostal"=>$this->Util()->CadenaOriginalVariableFormat($this->Util()->PadStringLeft($data["nodoEmisor"]["rfc"]["cp"], 5, "0"),false,false)
|
||||
)
|
||||
);
|
||||
|
||||
if($data["nodoEmisor"]["sucursal"]["sucursalActiva"] == 'no'){
|
||||
|
||||
$suc = $xml->createElement("cfdi:ExpedidoEn");
|
||||
$suc = $emisor->appendChild($suc);
|
||||
|
||||
$this->CargaAtt($suc, array("calle"=>$this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["sucursal"]["calle"],false,false),
|
||||
"noExterior"=>$this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["sucursal"]["noExt"],false,false),
|
||||
"noInterior"=>$this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["sucursal"]["noInt"],false,false),
|
||||
"colonia"=>$this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["sucursal"]["colonia"],false,false),
|
||||
"localidad"=>$this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["sucursal"]["localidad"],false,false),
|
||||
"referencia"=>$this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["sucursal"]["referencia"],false,false),
|
||||
"municipio"=>$this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["sucursal"]["municipio"],false,false),
|
||||
"estado"=>$this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["sucursal"]["estado"],false,false),
|
||||
"pais"=>$this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["sucursal"]["pais"],false,false),
|
||||
"codigoPostal"=>$this->Util()->CadenaOriginalVariableFormat($this->Util()->PadStringLeft($data["nodoEmisor"]["sucursal"]["cp"], 5, "0"),false,false)
|
||||
)
|
||||
);
|
||||
|
||||
}//if
|
||||
|
||||
//expedido en aun no porque asumiremos todas las facruras en domicilio fiscal
|
||||
$regfis = $xml->createElement("cfdi:RegimenFiscal");
|
||||
$regfis = $emisor->appendChild($regfis);
|
||||
|
||||
//echo $data["nodoEmisor"]["rfc"]["pais"];
|
||||
$this->CargaAtt($regfis, array("Regimen"=>$this->Util()->CadenaOriginalVariableFormat($data["nodoEmisor"]["rfc"]["regimenFiscal"],false,false)
|
||||
)
|
||||
);
|
||||
|
||||
$receptor = $xml->createElement("cfdi:Receptor");
|
||||
$receptor = $root->appendChild($receptor);
|
||||
$this->CargaAtt($receptor, array("rfc"=>$this->Util()->CadenaOriginalVariableFormat($nodoReceptor["rfc"],false,false),
|
||||
"nombre"=>$this->Util()->CadenaOriginalVariableFormat($nodoReceptor["nombre"],false,false)
|
||||
)
|
||||
);
|
||||
$domicilio = $xml->createElement("cfdi:Domicilio");
|
||||
$domicilio = $receptor->appendChild($domicilio);
|
||||
$this->CargaAtt($domicilio, array("calle"=>$this->Util()->CadenaOriginalVariableFormat($nodoReceptor["calle"],false,false),
|
||||
"noExterior"=>$this->Util()->CadenaOriginalVariableFormat($nodoReceptor["noExt"],false,false),
|
||||
"noInterior"=>$this->Util()->CadenaOriginalVariableFormat($nodoReceptor["noInt"],false,false),
|
||||
"colonia"=>$this->Util()->CadenaOriginalVariableFormat($nodoReceptor["colonia"],false,false),
|
||||
"localidad"=>$this->Util()->CadenaOriginalVariableFormat($nodoReceptor["localidad"],false,false),
|
||||
"referencia"=>$this->Util()->CadenaOriginalVariableFormat($nodoReceptor["referencia"],false,false),
|
||||
"municipio"=>$this->Util()->CadenaOriginalVariableFormat($nodoReceptor["municipio"],false,false),
|
||||
"estado"=>$this->Util()->CadenaOriginalVariableFormat($nodoReceptor["estado"],false,false),
|
||||
"pais"=>$this->Util()->CadenaOriginalVariableFormat($nodoReceptor["pais"],false,false),
|
||||
"codigoPostal"=>$this->Util()->CadenaOriginalVariableFormat($this->Util()->PadStringLeft($nodoReceptor["cp"], 5, "0"),false,false),
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
$conceptos = $xml->createElement("cfdi:Conceptos");
|
||||
$conceptos = $root->appendChild($conceptos);
|
||||
foreach($nodosConceptos as $concepto)
|
||||
{
|
||||
$myConcepto = $xml->createElement("cfdi:Concepto");
|
||||
$myConcepto = $conceptos->appendChild($myConcepto);
|
||||
$this->CargaAtt($myConcepto, array("cantidad"=>$this->Util()->CadenaOriginalVariableFormat($concepto["cantidad"],true,false),
|
||||
"unidad"=>$this->Util()->CadenaOriginalVariableFormat($concepto["unidad"],false,false),
|
||||
"noIdentificacion"=>$this->Util()->CadenaOriginalVariableFormat($concepto["noIdentificacion"],false,false),
|
||||
"descripcion"=>$this->Util()->CadenaOriginalVariableFormat($concepto["descripcion"],false,false),
|
||||
"valorUnitario"=>$this->Util()->CadenaOriginalVariableFormat($concepto["valorUnitario"],true,false),
|
||||
"importe"=>$this->Util()->CadenaOriginalVariableFormat($concepto["importe"],true,false),
|
||||
)
|
||||
);
|
||||
// aca falta la informacion aduanera
|
||||
// aca falta cuenta predial
|
||||
}
|
||||
|
||||
// todo complementoconcepto
|
||||
|
||||
$impuestos = $xml->createElement("cfdi:Impuestos");
|
||||
$impuestos = $root->appendChild($impuestos);
|
||||
|
||||
$this->CargaAtt($impuestos, array(
|
||||
"totalImpuestosRetenidos" => $this->Util()->CadenaOriginalVariableFormat($totales["retIsr"]+$totales["retIva"],true,false),
|
||||
"totalImpuestosTrasladados" => $this->Util()->CadenaOriginalVariableFormat($totales["iva"]+$totales["ieps"],true,false))
|
||||
);
|
||||
|
||||
$retenciones = $xml->createElement("cfdi:Retenciones");
|
||||
$retenciones = $impuestos->appendChild($retenciones);
|
||||
|
||||
$retencion = $xml->createElement("cfdi:Retencion");
|
||||
$retencion = $retenciones->appendChild($retencion);
|
||||
|
||||
$this->CargaAtt($retencion, array(
|
||||
"impuesto" => $this->Util()->CadenaOriginalVariableFormat("IVA",false,false),
|
||||
"importe" => $this->Util()->CadenaOriginalVariableFormat($totales["retIva"],true,false))
|
||||
);
|
||||
|
||||
$retencion = $xml->createElement("cfdi:Retencion");
|
||||
$retencion = $retenciones->appendChild($retencion);
|
||||
|
||||
$this->CargaAtt($retencion, array(
|
||||
"impuesto" => $this->Util()->CadenaOriginalVariableFormat("ISR",false,false),
|
||||
"importe" => $this->Util()->CadenaOriginalVariableFormat($totales["retIsr"],true,false))
|
||||
);
|
||||
|
||||
|
||||
$traslados = $xml->createElement("cfdi:Traslados");
|
||||
$traslados = $impuestos->appendChild($traslados);
|
||||
|
||||
$traslado = $xml->createElement("cfdi:Traslado");
|
||||
$traslado = $traslados->appendChild($traslado);
|
||||
|
||||
$this->CargaAtt($traslado, array(
|
||||
"impuesto" => $this->Util()->CadenaOriginalVariableFormat("IVA",false,false),
|
||||
"tasa" => $this->Util()->CadenaOriginalVariableFormat($totales["tasaIva"],true,false),
|
||||
"importe" => $this->Util()->CadenaOriginalVariableFormat($totales["iva"],true,false))
|
||||
);
|
||||
|
||||
$traslado = $xml->createElement("cfdi:Traslado");
|
||||
$traslado = $traslados->appendChild($traslado);
|
||||
|
||||
$this->CargaAtt($traslado, array(
|
||||
"impuesto" => $this->Util()->CadenaOriginalVariableFormat("IEPS",false,false),
|
||||
"tasa" => $this->Util()->CadenaOriginalVariableFormat($totales["porcentajeIEPS"],true,false),
|
||||
"importe" => $this->Util()->CadenaOriginalVariableFormat($totales["ieps"],true,false))
|
||||
);
|
||||
|
||||
/* Addenda
|
||||
if($_SESSION["impuestos"])
|
||||
{
|
||||
|
||||
$addenda = $xml->createElement("cfdi:Addenda");
|
||||
$addenda = $root->appendChild($addenda);
|
||||
|
||||
foreach($_SESSION["impuestos"] as $impuesto)
|
||||
{
|
||||
$factura = $xml->createElement("impuesto");
|
||||
$factura = $addenda->appendChild($factura);
|
||||
|
||||
$this->CargaAtt($factura, array(
|
||||
"impuesto" => $impuesto["impuesto"],
|
||||
"tasa" => $impuesto["tasa"],
|
||||
"tipo" => $impuesto["tipo"]
|
||||
)
|
||||
);
|
||||
}
|
||||
}*/
|
||||
$complemento = $xml->createElement("cfdi:Complemento");
|
||||
$complemento = $root->appendChild($complemento);
|
||||
|
||||
$root->setAttribute("xsi:schemaLocation", "http://www.sat.gob.mx/cfd/3 http://www.sat.gob.mx/sitio_internet/cfd/3/cfdv32.xsd");
|
||||
|
||||
// falta nodo complemento
|
||||
/**/
|
||||
//$xml->formatOutput = true;
|
||||
$nufa = $emp["empresaId"]."_".$serie["serie"]."_".$data["folio"];
|
||||
|
||||
$rfcActivo = $rfc->getRfcActive();
|
||||
$root = DOC_ROOT."/empresas/".$_SESSION["empresaId"]."/certificados/".$rfcActivo."/facturas/xml/";
|
||||
$rootFacturas = DOC_ROOT."/empresas/".$_SESSION["empresaId"]."/certificados/".$rfcActivo."/facturas/";
|
||||
|
||||
if(!is_dir($rootFacturas))
|
||||
{
|
||||
mkdir($rootFacturas, 0777);
|
||||
}
|
||||
|
||||
if(!is_dir($root))
|
||||
{
|
||||
mkdir($root, 0777);
|
||||
}
|
||||
|
||||
$xml->save($root.$nufa.".xml");
|
||||
return $nufa;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
1117
classes/inventario.class.php
Executable file
1117
classes/inventario.class.php
Executable file
File diff suppressed because it is too large
Load Diff
806
classes/json.class.php
Executable file
806
classes/json.class.php
Executable file
@@ -0,0 +1,806 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* Converts to and from JSON format.
|
||||
*
|
||||
* JSON (JavaScript Object Notation) is a lightweight data-interchange
|
||||
* format. It is easy for humans to read and write. It is easy for machines
|
||||
* to parse and generate. It is based on a subset of the JavaScript
|
||||
* Programming Language, Standard ECMA-262 3rd Edition - December 1999.
|
||||
* This feature can also be found in Python. JSON is a text format that is
|
||||
* completely language independent but uses conventions that are familiar
|
||||
* to programmers of the C-family of languages, including C, C++, C#, Java,
|
||||
* JavaScript, Perl, TCL, and many others. These properties make JSON an
|
||||
* ideal data-interchange language.
|
||||
*
|
||||
* This package provides a simple encoder and decoder for JSON notation. It
|
||||
* is intended for use with client-side Javascript applications that make
|
||||
* use of HTTPRequest to perform server communication functions - data can
|
||||
* be encoded into JSON notation for use in a client-side javascript, or
|
||||
* decoded from incoming Javascript requests. JSON format is native to
|
||||
* Javascript, and can be directly eval()'ed with no further parsing
|
||||
* overhead
|
||||
*
|
||||
* All strings should be in ASCII or UTF-8 format!
|
||||
*
|
||||
* LICENSE: Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met: Redistributions of source code must retain the
|
||||
* above copyright notice, this list of conditions and the following
|
||||
* disclaimer. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*
|
||||
* @category
|
||||
* @package Services_JSON
|
||||
* @author Michal Migurski <mike-json@teczno.com>
|
||||
* @author Matt Knapp <mdknapp[at]gmail[dot]com>
|
||||
* @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
|
||||
* @copyright 2005 Michal Migurski
|
||||
* @version CVS: $Id: JSON.php,v 1.31 2006/06/28 05:54:17 migurski Exp $
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php
|
||||
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198
|
||||
*/
|
||||
|
||||
/**
|
||||
* Marker constant for Services_JSON::decode(), used to flag stack state
|
||||
*/
|
||||
define('SERVICES_JSON_SLICE', 1);
|
||||
|
||||
/**
|
||||
* Marker constant for Services_JSON::decode(), used to flag stack state
|
||||
*/
|
||||
define('SERVICES_JSON_IN_STR', 2);
|
||||
|
||||
/**
|
||||
* Marker constant for Services_JSON::decode(), used to flag stack state
|
||||
*/
|
||||
define('SERVICES_JSON_IN_ARR', 3);
|
||||
|
||||
/**
|
||||
* Marker constant for Services_JSON::decode(), used to flag stack state
|
||||
*/
|
||||
define('SERVICES_JSON_IN_OBJ', 4);
|
||||
|
||||
/**
|
||||
* Marker constant for Services_JSON::decode(), used to flag stack state
|
||||
*/
|
||||
define('SERVICES_JSON_IN_CMT', 5);
|
||||
|
||||
/**
|
||||
* Behavior switch for Services_JSON::decode()
|
||||
*/
|
||||
define('SERVICES_JSON_LOOSE_TYPE', 16);
|
||||
|
||||
/**
|
||||
* Behavior switch for Services_JSON::decode()
|
||||
*/
|
||||
define('SERVICES_JSON_SUPPRESS_ERRORS', 32);
|
||||
|
||||
/**
|
||||
* Converts to and from JSON format.
|
||||
*
|
||||
* Brief example of use:
|
||||
*
|
||||
* <code>
|
||||
* // create a new instance of Services_JSON
|
||||
* $json = new Services_JSON();
|
||||
*
|
||||
* // convert a complexe value to JSON notation, and send it to the browser
|
||||
* $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4)));
|
||||
* $output = $json->encode($value);
|
||||
*
|
||||
* print($output);
|
||||
* // prints: ["foo","bar",[1,2,"baz"],[3,[4]]]
|
||||
*
|
||||
* // accept incoming POST data, assumed to be in JSON notation
|
||||
* $input = file_get_contents('php://input', 1000000);
|
||||
* $value = $json->decode($input);
|
||||
* </code>
|
||||
*/
|
||||
class Services_JSON
|
||||
{
|
||||
/**
|
||||
* constructs a new JSON instance
|
||||
*
|
||||
* @param int $use object behavior flags; combine with boolean-OR
|
||||
*
|
||||
* possible values:
|
||||
* - SERVICES_JSON_LOOSE_TYPE: loose typing.
|
||||
* "{...}" syntax creates associative arrays
|
||||
* instead of objects in decode().
|
||||
* - SERVICES_JSON_SUPPRESS_ERRORS: error suppression.
|
||||
* Values which can't be encoded (e.g. resources)
|
||||
* appear as NULL instead of throwing errors.
|
||||
* By default, a deeply-nested resource will
|
||||
* bubble up with an error, so all return values
|
||||
* from encode() should be checked with isError()
|
||||
*/
|
||||
function Services_JSON($use = 0)
|
||||
{
|
||||
$this->use = $use;
|
||||
}
|
||||
|
||||
/**
|
||||
* convert a string from one UTF-16 char to one UTF-8 char
|
||||
*
|
||||
* Normally should be handled by mb_convert_encoding, but
|
||||
* provides a slower PHP-only method for installations
|
||||
* that lack the multibye string extension.
|
||||
*
|
||||
* @param string $utf16 UTF-16 character
|
||||
* @return string UTF-8 character
|
||||
* @access private
|
||||
*/
|
||||
function utf162utf8($utf16)
|
||||
{
|
||||
// oh please oh please oh please oh please oh please
|
||||
if(function_exists('mb_convert_encoding')) {
|
||||
return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
|
||||
}
|
||||
|
||||
$bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
|
||||
|
||||
switch(true) {
|
||||
case ((0x7F & $bytes) == $bytes):
|
||||
// this case should never be reached, because we are in ASCII range
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
return chr(0x7F & $bytes);
|
||||
|
||||
case (0x07FF & $bytes) == $bytes:
|
||||
// return a 2-byte UTF-8 character
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
return chr(0xC0 | (($bytes >> 6) & 0x1F))
|
||||
. chr(0x80 | ($bytes & 0x3F));
|
||||
|
||||
case (0xFFFF & $bytes) == $bytes:
|
||||
// return a 3-byte UTF-8 character
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
return chr(0xE0 | (($bytes >> 12) & 0x0F))
|
||||
. chr(0x80 | (($bytes >> 6) & 0x3F))
|
||||
. chr(0x80 | ($bytes & 0x3F));
|
||||
}
|
||||
|
||||
// ignoring UTF-32 for now, sorry
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* convert a string from one UTF-8 char to one UTF-16 char
|
||||
*
|
||||
* Normally should be handled by mb_convert_encoding, but
|
||||
* provides a slower PHP-only method for installations
|
||||
* that lack the multibye string extension.
|
||||
*
|
||||
* @param string $utf8 UTF-8 character
|
||||
* @return string UTF-16 character
|
||||
* @access private
|
||||
*/
|
||||
function utf82utf16($utf8)
|
||||
{
|
||||
// oh please oh please oh please oh please oh please
|
||||
if(function_exists('mb_convert_encoding')) {
|
||||
return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
|
||||
}
|
||||
|
||||
switch(strlen($utf8)) {
|
||||
case 1:
|
||||
// this case should never be reached, because we are in ASCII range
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
return $utf8;
|
||||
|
||||
case 2:
|
||||
// return a UTF-16 character from a 2-byte UTF-8 char
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
return chr(0x07 & (ord($utf8{0}) >> 2))
|
||||
. chr((0xC0 & (ord($utf8{0}) << 6))
|
||||
| (0x3F & ord($utf8{1})));
|
||||
|
||||
case 3:
|
||||
// return a UTF-16 character from a 3-byte UTF-8 char
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
return chr((0xF0 & (ord($utf8{0}) << 4))
|
||||
| (0x0F & (ord($utf8{1}) >> 2)))
|
||||
. chr((0xC0 & (ord($utf8{1}) << 6))
|
||||
| (0x7F & ord($utf8{2})));
|
||||
}
|
||||
|
||||
// ignoring UTF-32 for now, sorry
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* encodes an arbitrary variable into JSON format
|
||||
*
|
||||
* @param mixed $var any number, boolean, string, array, or object to be encoded.
|
||||
* see argument 1 to Services_JSON() above for array-parsing behavior.
|
||||
* if var is a strng, note that encode() always expects it
|
||||
* to be in ASCII or UTF-8 format!
|
||||
*
|
||||
* @return mixed JSON string representation of input var or an error if a problem occurs
|
||||
* @access public
|
||||
*/
|
||||
function encode($var)
|
||||
{
|
||||
switch (gettype($var)) {
|
||||
case 'boolean':
|
||||
return $var ? 'true' : 'false';
|
||||
|
||||
case 'NULL':
|
||||
return 'null';
|
||||
|
||||
case 'integer':
|
||||
return (int) $var;
|
||||
|
||||
case 'double':
|
||||
case 'float':
|
||||
return (float) $var;
|
||||
|
||||
case 'string':
|
||||
// STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
|
||||
$ascii = '';
|
||||
$strlen_var = strlen($var);
|
||||
|
||||
/*
|
||||
* Iterate over every character in the string,
|
||||
* escaping with a slash or encoding to UTF-8 where necessary
|
||||
*/
|
||||
for ($c = 0; $c < $strlen_var; ++$c) {
|
||||
|
||||
$ord_var_c = ord($var{$c});
|
||||
|
||||
switch (true) {
|
||||
case $ord_var_c == 0x08:
|
||||
$ascii .= '\b';
|
||||
break;
|
||||
case $ord_var_c == 0x09:
|
||||
$ascii .= '\t';
|
||||
break;
|
||||
case $ord_var_c == 0x0A:
|
||||
$ascii .= '\n';
|
||||
break;
|
||||
case $ord_var_c == 0x0C:
|
||||
$ascii .= '\f';
|
||||
break;
|
||||
case $ord_var_c == 0x0D:
|
||||
$ascii .= '\r';
|
||||
break;
|
||||
|
||||
case $ord_var_c == 0x22:
|
||||
case $ord_var_c == 0x2F:
|
||||
case $ord_var_c == 0x5C:
|
||||
// double quote, slash, slosh
|
||||
$ascii .= '\\'.$var{$c};
|
||||
break;
|
||||
|
||||
case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
|
||||
// characters U-00000000 - U-0000007F (same as ASCII)
|
||||
$ascii .= $var{$c};
|
||||
break;
|
||||
|
||||
case (($ord_var_c & 0xE0) == 0xC0):
|
||||
// characters U-00000080 - U-000007FF, mask 110XXXXX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$char = pack('C*', $ord_var_c, ord($var{$c + 1}));
|
||||
$c += 1;
|
||||
$utf16 = $this->utf82utf16($char);
|
||||
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
||||
break;
|
||||
|
||||
case (($ord_var_c & 0xF0) == 0xE0):
|
||||
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$char = pack('C*', $ord_var_c,
|
||||
ord($var{$c + 1}),
|
||||
ord($var{$c + 2}));
|
||||
$c += 2;
|
||||
$utf16 = $this->utf82utf16($char);
|
||||
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
||||
break;
|
||||
|
||||
case (($ord_var_c & 0xF8) == 0xF0):
|
||||
// characters U-00010000 - U-001FFFFF, mask 11110XXX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$char = pack('C*', $ord_var_c,
|
||||
ord($var{$c + 1}),
|
||||
ord($var{$c + 2}),
|
||||
ord($var{$c + 3}));
|
||||
$c += 3;
|
||||
$utf16 = $this->utf82utf16($char);
|
||||
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
||||
break;
|
||||
|
||||
case (($ord_var_c & 0xFC) == 0xF8):
|
||||
// characters U-00200000 - U-03FFFFFF, mask 111110XX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$char = pack('C*', $ord_var_c,
|
||||
ord($var{$c + 1}),
|
||||
ord($var{$c + 2}),
|
||||
ord($var{$c + 3}),
|
||||
ord($var{$c + 4}));
|
||||
$c += 4;
|
||||
$utf16 = $this->utf82utf16($char);
|
||||
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
||||
break;
|
||||
|
||||
case (($ord_var_c & 0xFE) == 0xFC):
|
||||
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$char = pack('C*', $ord_var_c,
|
||||
ord($var{$c + 1}),
|
||||
ord($var{$c + 2}),
|
||||
ord($var{$c + 3}),
|
||||
ord($var{$c + 4}),
|
||||
ord($var{$c + 5}));
|
||||
$c += 5;
|
||||
$utf16 = $this->utf82utf16($char);
|
||||
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return '"'.$ascii.'"';
|
||||
|
||||
case 'array':
|
||||
/*
|
||||
* As per JSON spec if any array key is not an integer
|
||||
* we must treat the the whole array as an object. We
|
||||
* also try to catch a sparsely populated associative
|
||||
* array with numeric keys here because some JS engines
|
||||
* will create an array with empty indexes up to
|
||||
* max_index which can cause memory issues and because
|
||||
* the keys, which may be relevant, will be remapped
|
||||
* otherwise.
|
||||
*
|
||||
* As per the ECMA and JSON specification an object may
|
||||
* have any string as a property. Unfortunately due to
|
||||
* a hole in the ECMA specification if the key is a
|
||||
* ECMA reserved word or starts with a digit the
|
||||
* parameter is only accessible using ECMAScript's
|
||||
* bracket notation.
|
||||
*/
|
||||
|
||||
// treat as a JSON object
|
||||
if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
|
||||
$properties = array_map(array($this, 'name_value'),
|
||||
array_keys($var),
|
||||
array_values($var));
|
||||
|
||||
foreach($properties as $property) {
|
||||
if(Services_JSON::isError($property)) {
|
||||
return $property;
|
||||
}
|
||||
}
|
||||
|
||||
return '{' . join(',', $properties) . '}';
|
||||
}
|
||||
|
||||
// treat it like a regular array
|
||||
$elements = array_map(array($this, 'encode'), $var);
|
||||
|
||||
foreach($elements as $element) {
|
||||
if(Services_JSON::isError($element)) {
|
||||
return $element;
|
||||
}
|
||||
}
|
||||
|
||||
return '[' . join(',', $elements) . ']';
|
||||
|
||||
case 'object':
|
||||
$vars = get_object_vars($var);
|
||||
|
||||
$properties = array_map(array($this, 'name_value'),
|
||||
array_keys($vars),
|
||||
array_values($vars));
|
||||
|
||||
foreach($properties as $property) {
|
||||
if(Services_JSON::isError($property)) {
|
||||
return $property;
|
||||
}
|
||||
}
|
||||
|
||||
return '{' . join(',', $properties) . '}';
|
||||
|
||||
default:
|
||||
return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
|
||||
? 'null'
|
||||
: new Services_JSON_Error(gettype($var)." can not be encoded as JSON string");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* array-walking function for use in generating JSON-formatted name-value pairs
|
||||
*
|
||||
* @param string $name name of key to use
|
||||
* @param mixed $value reference to an array element to be encoded
|
||||
*
|
||||
* @return string JSON-formatted name-value pair, like '"name":value'
|
||||
* @access private
|
||||
*/
|
||||
function name_value($name, $value)
|
||||
{
|
||||
$encoded_value = $this->encode($value);
|
||||
|
||||
if(Services_JSON::isError($encoded_value)) {
|
||||
return $encoded_value;
|
||||
}
|
||||
|
||||
return $this->encode(strval($name)) . ':' . $encoded_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* reduce a string by removing leading and trailing comments and whitespace
|
||||
*
|
||||
* @param $str string string value to strip of comments and whitespace
|
||||
*
|
||||
* @return string string value stripped of comments and whitespace
|
||||
* @access private
|
||||
*/
|
||||
function reduce_string($str)
|
||||
{
|
||||
$str = preg_replace(array(
|
||||
|
||||
// eliminate single line comments in '// ...' form
|
||||
'#^\s*//(.+)$#m',
|
||||
|
||||
// eliminate multi-line comments in '/* ... */' form, at start of string
|
||||
'#^\s*/\*(.+)\*/#Us',
|
||||
|
||||
// eliminate multi-line comments in '/* ... */' form, at end of string
|
||||
'#/\*(.+)\*/\s*$#Us'
|
||||
|
||||
), '', $str);
|
||||
|
||||
// eliminate extraneous space
|
||||
return trim($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* decodes a JSON string into appropriate variable
|
||||
*
|
||||
* @param string $str JSON-formatted string
|
||||
*
|
||||
* @return mixed number, boolean, string, array, or object
|
||||
* corresponding to given JSON input string.
|
||||
* See argument 1 to Services_JSON() above for object-output behavior.
|
||||
* Note that decode() always returns strings
|
||||
* in ASCII or UTF-8 format!
|
||||
* @access public
|
||||
*/
|
||||
function decode($str)
|
||||
{
|
||||
$str = $this->reduce_string($str);
|
||||
|
||||
switch (strtolower($str)) {
|
||||
case 'true':
|
||||
return true;
|
||||
|
||||
case 'false':
|
||||
return false;
|
||||
|
||||
case 'null':
|
||||
return null;
|
||||
|
||||
default:
|
||||
$m = array();
|
||||
|
||||
if (is_numeric($str)) {
|
||||
// Lookie-loo, it's a number
|
||||
|
||||
// This would work on its own, but I'm trying to be
|
||||
// good about returning integers where appropriate:
|
||||
// return (float)$str;
|
||||
|
||||
// Return float or int, as appropriate
|
||||
return ((float)$str == (integer)$str)
|
||||
? (integer)$str
|
||||
: (float)$str;
|
||||
|
||||
} elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) {
|
||||
// STRINGS RETURNED IN UTF-8 FORMAT
|
||||
$delim = substr($str, 0, 1);
|
||||
$chrs = substr($str, 1, -1);
|
||||
$utf8 = '';
|
||||
$strlen_chrs = strlen($chrs);
|
||||
|
||||
for ($c = 0; $c < $strlen_chrs; ++$c) {
|
||||
|
||||
$substr_chrs_c_2 = substr($chrs, $c, 2);
|
||||
$ord_chrs_c = ord($chrs{$c});
|
||||
|
||||
switch (true) {
|
||||
case $substr_chrs_c_2 == '\b':
|
||||
$utf8 .= chr(0x08);
|
||||
++$c;
|
||||
break;
|
||||
case $substr_chrs_c_2 == '\t':
|
||||
$utf8 .= chr(0x09);
|
||||
++$c;
|
||||
break;
|
||||
case $substr_chrs_c_2 == '\n':
|
||||
$utf8 .= chr(0x0A);
|
||||
++$c;
|
||||
break;
|
||||
case $substr_chrs_c_2 == '\f':
|
||||
$utf8 .= chr(0x0C);
|
||||
++$c;
|
||||
break;
|
||||
case $substr_chrs_c_2 == '\r':
|
||||
$utf8 .= chr(0x0D);
|
||||
++$c;
|
||||
break;
|
||||
|
||||
case $substr_chrs_c_2 == '\\"':
|
||||
case $substr_chrs_c_2 == '\\\'':
|
||||
case $substr_chrs_c_2 == '\\\\':
|
||||
case $substr_chrs_c_2 == '\\/':
|
||||
if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
|
||||
($delim == "'" && $substr_chrs_c_2 != '\\"')) {
|
||||
$utf8 .= $chrs{++$c};
|
||||
}
|
||||
break;
|
||||
|
||||
case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)):
|
||||
// single, escaped unicode character
|
||||
$utf16 = chr(hexdec(substr($chrs, ($c + 2), 2)))
|
||||
. chr(hexdec(substr($chrs, ($c + 4), 2)));
|
||||
$utf8 .= $this->utf162utf8($utf16);
|
||||
$c += 5;
|
||||
break;
|
||||
|
||||
case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
|
||||
$utf8 .= $chrs{$c};
|
||||
break;
|
||||
|
||||
case ($ord_chrs_c & 0xE0) == 0xC0:
|
||||
// characters U-00000080 - U-000007FF, mask 110XXXXX
|
||||
//see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$utf8 .= substr($chrs, $c, 2);
|
||||
++$c;
|
||||
break;
|
||||
|
||||
case ($ord_chrs_c & 0xF0) == 0xE0:
|
||||
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$utf8 .= substr($chrs, $c, 3);
|
||||
$c += 2;
|
||||
break;
|
||||
|
||||
case ($ord_chrs_c & 0xF8) == 0xF0:
|
||||
// characters U-00010000 - U-001FFFFF, mask 11110XXX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$utf8 .= substr($chrs, $c, 4);
|
||||
$c += 3;
|
||||
break;
|
||||
|
||||
case ($ord_chrs_c & 0xFC) == 0xF8:
|
||||
// characters U-00200000 - U-03FFFFFF, mask 111110XX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$utf8 .= substr($chrs, $c, 5);
|
||||
$c += 4;
|
||||
break;
|
||||
|
||||
case ($ord_chrs_c & 0xFE) == 0xFC:
|
||||
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$utf8 .= substr($chrs, $c, 6);
|
||||
$c += 5;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $utf8;
|
||||
|
||||
} elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
|
||||
// array, or object notation
|
||||
|
||||
if ($str{0} == '[') {
|
||||
$stk = array(SERVICES_JSON_IN_ARR);
|
||||
$arr = array();
|
||||
} else {
|
||||
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
|
||||
$stk = array(SERVICES_JSON_IN_OBJ);
|
||||
$obj = array();
|
||||
} else {
|
||||
$stk = array(SERVICES_JSON_IN_OBJ);
|
||||
$obj = new stdClass();
|
||||
}
|
||||
}
|
||||
|
||||
array_push($stk, array('what' => SERVICES_JSON_SLICE,
|
||||
'where' => 0,
|
||||
'delim' => false));
|
||||
|
||||
$chrs = substr($str, 1, -1);
|
||||
$chrs = $this->reduce_string($chrs);
|
||||
|
||||
if ($chrs == '') {
|
||||
if (reset($stk) == SERVICES_JSON_IN_ARR) {
|
||||
return $arr;
|
||||
|
||||
} else {
|
||||
return $obj;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//print("\nparsing {$chrs}\n");
|
||||
|
||||
$strlen_chrs = strlen($chrs);
|
||||
|
||||
for ($c = 0; $c <= $strlen_chrs; ++$c) {
|
||||
|
||||
$top = end($stk);
|
||||
$substr_chrs_c_2 = substr($chrs, $c, 2);
|
||||
|
||||
if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
|
||||
// found a comma that is not inside a string, array, etc.,
|
||||
// OR we've reached the end of the character list
|
||||
$slice = substr($chrs, $top['where'], ($c - $top['where']));
|
||||
array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
|
||||
//print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
|
||||
|
||||
if (reset($stk) == SERVICES_JSON_IN_ARR) {
|
||||
// we are in an array, so just push an element onto the stack
|
||||
array_push($arr, $this->decode($slice));
|
||||
|
||||
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
|
||||
// we are in an object, so figure
|
||||
// out the property name and set an
|
||||
// element in an associative array,
|
||||
// for now
|
||||
$parts = array();
|
||||
|
||||
if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
|
||||
// "name":value pair
|
||||
$key = $this->decode($parts[1]);
|
||||
$val = $this->decode($parts[2]);
|
||||
|
||||
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
|
||||
$obj[$key] = $val;
|
||||
} else {
|
||||
$obj->$key = $val;
|
||||
}
|
||||
} elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
|
||||
// name:value pair, where name is unquoted
|
||||
$key = $parts[1];
|
||||
$val = $this->decode($parts[2]);
|
||||
|
||||
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
|
||||
$obj[$key] = $val;
|
||||
} else {
|
||||
$obj->$key = $val;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
|
||||
// found a quote, and we are not inside a string
|
||||
array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
|
||||
//print("Found start of string at {$c}\n");
|
||||
|
||||
} elseif (($chrs{$c} == $top['delim']) &&
|
||||
($top['what'] == SERVICES_JSON_IN_STR) &&
|
||||
((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
|
||||
// found a quote, we're in a string, and it's not escaped
|
||||
// we know that it's not escaped becase there is _not_ an
|
||||
// odd number of backslashes at the end of the string so far
|
||||
array_pop($stk);
|
||||
//print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
|
||||
|
||||
} elseif (($chrs{$c} == '[') &&
|
||||
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
|
||||
// found a left-bracket, and we are in an array, object, or slice
|
||||
array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
|
||||
//print("Found start of array at {$c}\n");
|
||||
|
||||
} elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
|
||||
// found a right-bracket, and we're in an array
|
||||
array_pop($stk);
|
||||
//print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
|
||||
|
||||
} elseif (($chrs{$c} == '{') &&
|
||||
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
|
||||
// found a left-brace, and we are in an array, object, or slice
|
||||
array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
|
||||
//print("Found start of object at {$c}\n");
|
||||
|
||||
} elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
|
||||
// found a right-brace, and we're in an object
|
||||
array_pop($stk);
|
||||
//print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
|
||||
|
||||
} elseif (($substr_chrs_c_2 == '/*') &&
|
||||
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
|
||||
// found a comment start, and we are in an array, object, or slice
|
||||
array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false));
|
||||
$c++;
|
||||
//print("Found start of comment at {$c}\n");
|
||||
|
||||
} elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) {
|
||||
// found a comment end, and we're in one now
|
||||
array_pop($stk);
|
||||
$c++;
|
||||
|
||||
for ($i = $top['where']; $i <= $c; ++$i)
|
||||
$chrs = substr_replace($chrs, ' ', $i, 1);
|
||||
|
||||
//print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (reset($stk) == SERVICES_JSON_IN_ARR) {
|
||||
return $arr;
|
||||
|
||||
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
|
||||
return $obj;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Ultimately, this should just call PEAR::isError()
|
||||
*/
|
||||
function isError($data, $code = null)
|
||||
{
|
||||
if (class_exists('pear')) {
|
||||
return PEAR::isError($data, $code);
|
||||
} elseif (is_object($data) && (get_class($data) == 'services_json_error' ||
|
||||
is_subclass_of($data, 'services_json_error'))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (class_exists('PEAR_Error')) {
|
||||
|
||||
class Services_JSON_Error extends PEAR_Error
|
||||
{
|
||||
function Services_JSON_Error($message = 'unknown error', $code = null,
|
||||
$mode = null, $options = null, $userinfo = null)
|
||||
{
|
||||
parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
/**
|
||||
* @todo Ultimately, this class shall be descended from PEAR_Error
|
||||
*/
|
||||
class Services_JSON_Error
|
||||
{
|
||||
function Services_JSON_Error($message = 'unknown error', $code = null,
|
||||
$mode = null, $options = null, $userinfo = null)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
146
classes/main.class.php
Executable file
146
classes/main.class.php
Executable file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
class Main
|
||||
{
|
||||
protected $page;
|
||||
|
||||
|
||||
public function setPage($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value, 9999999999, 0);
|
||||
$this->page = $value;
|
||||
}
|
||||
|
||||
public function getPage()
|
||||
{
|
||||
return $this->page;
|
||||
}
|
||||
|
||||
function ListProductos()
|
||||
{
|
||||
$this->Util()->DB()->setQuery("SELECT * FROM product ORDER BY productId ASC");
|
||||
|
||||
$result = $this->Util()->DB()->GetResult();
|
||||
|
||||
foreach($result as $key => $periodo)
|
||||
{
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
function ListTiposDeComprobantes()
|
||||
{
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT * FROM tiposComprobante ORDER BY tiposComprobanteId");
|
||||
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function ListTiposDeComprobantesValidos($sucursalId = 0)
|
||||
{
|
||||
if($sucursalId)
|
||||
$sqlFilter = ' AND serie.sucursalId = '.$sucursalId;
|
||||
|
||||
$activeRfc = 1;
|
||||
|
||||
$sql = "SELECT * FROM tiposComprobante
|
||||
RIGHT JOIN serie ON serie.tiposComprobanteId = tiposComprobante.tiposComprobanteId
|
||||
WHERE serie.rfcId = '".$activeRfc."'
|
||||
".$sqlFilter."
|
||||
ORDER BY tiposComprobante.tiposComprobanteId";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function InfoComprobante($id)
|
||||
{
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT * FROM tiposComprobante WHERE tiposComprobanteId = '".$id."'");
|
||||
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $result;
|
||||
}
|
||||
function ListIvas()
|
||||
{
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->EnumSelect("comprobante", "tasaIva");
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function ListRetIsr()
|
||||
{
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->EnumSelect("comprobante", "porcentajeRetIsr");
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function ListRetIva()
|
||||
{
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->EnumSelect("comprobante", "porcentajeRetIva");
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function ListTipoDeMoneda()
|
||||
{
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->EnumSelect("comprobante", "tipoDeMoneda");
|
||||
|
||||
$monedas = array();
|
||||
foreach($result as $key => $moneda)
|
||||
{
|
||||
switch($moneda)
|
||||
{
|
||||
case "peso":
|
||||
$monedas[$key]["tipo"] = "MXN";
|
||||
$monedas[$key]["moneda"] = "Peso";
|
||||
break;
|
||||
case "dolar":
|
||||
$monedas[$key]["tipo"] = "USD";
|
||||
$monedas[$key]["moneda"] = "Dolar";
|
||||
break;
|
||||
case "euro":
|
||||
$monedas[$key]["tipo"] = "EUR";
|
||||
$monedas[$key]["moneda"] = "Euro";
|
||||
break;
|
||||
}
|
||||
}
|
||||
// print_r($monedas);
|
||||
return $monedas;
|
||||
}
|
||||
|
||||
function ListExcentoIva()
|
||||
{
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->EnumSelect("concepto", "excentoIva");
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function ListSocios()
|
||||
{
|
||||
$this->Util()->DB()->setQuery("SELECT * FROM socio ORDER BY socioId");
|
||||
$result = $this->Util()->DB()->GetResult();
|
||||
return $result;
|
||||
}
|
||||
|
||||
function ProveedoresX($value)
|
||||
{
|
||||
$this->Util()->DB()->setQuery("SELECT * FROM usuario WHERE email LIKE '%".$value."%'ORDER BY email");
|
||||
$result = $this->Util()->DB()->GetResult();
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function Util()
|
||||
{
|
||||
if($this->Util == null )
|
||||
{
|
||||
$this->Util = new Util();
|
||||
}
|
||||
return $this->Util;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
155
classes/material.class.php
Executable file
155
classes/material.class.php
Executable file
@@ -0,0 +1,155 @@
|
||||
<?php
|
||||
|
||||
class Material extends Main
|
||||
{
|
||||
private $materialId;
|
||||
private $nombre;
|
||||
|
||||
public function setMaterialId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->materialId = $value;
|
||||
}
|
||||
|
||||
public function setNombre($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, "Nombre");
|
||||
$this->nombre = $value;
|
||||
}
|
||||
|
||||
public function Info()
|
||||
{
|
||||
|
||||
$sql = 'SELECT
|
||||
*
|
||||
FROM
|
||||
material
|
||||
WHERE
|
||||
materialId = "'.$this->materialId.'"';
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$info = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
$row = $this->Util->EncodeRow($info);
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function EnumerateAll()
|
||||
{
|
||||
|
||||
$sql = 'SELECT
|
||||
*
|
||||
FROM
|
||||
material
|
||||
WHERE
|
||||
baja = "0"
|
||||
ORDER BY
|
||||
nombre ASC';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function Enumerate()
|
||||
{
|
||||
$sql = "SELECT COUNT(*) FROM material WHERE baja = '0'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
$pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/materiales");
|
||||
|
||||
$sqlAdd = "LIMIT ".$pages["start"].", ".$pages["items_per_page"];
|
||||
|
||||
$sql = "SELECT * FROM material WHERE baja = '0' ORDER BY nombre ASC ".$sqlAdd;
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$data["items"] = $result;
|
||||
$data["pages"] = $pages;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function Save()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){ return false; }
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("
|
||||
INSERT INTO `material` (
|
||||
`nombre`
|
||||
)
|
||||
VALUES (
|
||||
'".utf8_decode($this->nombre)."'
|
||||
)"
|
||||
);
|
||||
|
||||
$materialId = $this->Util()->DBSelect($_SESSION["empresaId"])->InsertData();
|
||||
|
||||
$this->Util()->setError(20046, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function Update()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){ return false; }
|
||||
|
||||
$sql = "
|
||||
UPDATE `material` SET
|
||||
`nombre` = '".utf8_decode($this->nombre)."'
|
||||
WHERE materialId = '".$this->materialId."'
|
||||
";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
|
||||
|
||||
$this->Util()->setError(20047, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function Delete()
|
||||
{
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("
|
||||
DELETE FROM material
|
||||
WHERE materialId = '".$this->materialId."'"
|
||||
);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$this->Util()->setError(20048, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function Baja(){
|
||||
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
|
||||
UPDATE material SET baja = '1'
|
||||
WHERE materialId = '".$this->materialId."'"
|
||||
);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData();
|
||||
|
||||
$this->Util()->setError(20048, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}//Baja
|
||||
|
||||
function GetNameById()
|
||||
{
|
||||
$sql = 'SELECT nombre FROM material
|
||||
WHERE materialId = "'.$this->materialId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$nombre = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $nombre;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
171
classes/metodoPago.class.php
Executable file
171
classes/metodoPago.class.php
Executable file
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
|
||||
class MetodoPago extends Main
|
||||
{
|
||||
private $metodoPagoId;
|
||||
private $nombre;
|
||||
|
||||
public function setMetodoPagoId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->metodoPagoId = $value;
|
||||
}
|
||||
|
||||
public function setNombre($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, "Nombre");
|
||||
$this->nombre = $value;
|
||||
}
|
||||
|
||||
public function Info()
|
||||
{
|
||||
|
||||
$sql = 'SELECT
|
||||
*
|
||||
FROM
|
||||
metodoPago
|
||||
WHERE
|
||||
metodoPagoId = "'.$this->metodoPagoId.'"';
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$info = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
$row = $this->Util->EncodeRow($info);
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function EnumerateAll()
|
||||
{
|
||||
$sql = 'SELECT
|
||||
*
|
||||
FROM
|
||||
metodoPago
|
||||
WHERE
|
||||
baja = "0"
|
||||
ORDER BY
|
||||
nombre ASC';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function EnumSingle()
|
||||
{
|
||||
$sql = 'SELECT
|
||||
*
|
||||
FROM
|
||||
metodoPago
|
||||
WHERE
|
||||
metodoPagoId = "'.$this->metodoPagoId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function Enumerate()
|
||||
{
|
||||
$sql = "SELECT COUNT(*) FROM metodoPago WHERE baja = '0'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
$pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/metodos-pago");
|
||||
|
||||
$sqlAdd = "LIMIT ".$pages["start"].", ".$pages["items_per_page"];
|
||||
|
||||
$sql = "SELECT * FROM metodoPago WHERE baja = '0' ORDER BY nombre ASC ".$sqlAdd;
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$data["items"] = $result;
|
||||
$data["pages"] = $pages;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function Save()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){ return false; }
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("
|
||||
INSERT INTO `metodoPago` (
|
||||
`nombre`
|
||||
)
|
||||
VALUES (
|
||||
'".utf8_decode($this->nombre)."'
|
||||
)"
|
||||
);
|
||||
|
||||
$metodoPagoId = $this->Util()->DBSelect($_SESSION["empresaId"])->InsertData();
|
||||
|
||||
$this->Util()->setError(30001, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function Update()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){ return false; }
|
||||
|
||||
$sql = "
|
||||
UPDATE `metodoPago` SET
|
||||
`nombre` = '".utf8_decode($this->nombre)."'
|
||||
WHERE metodoPagoId = '".$this->metodoPagoId."'
|
||||
";
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
|
||||
|
||||
$this->Util()->setError(30002, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function Delete()
|
||||
{
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("
|
||||
DELETE FROM metodoPago
|
||||
WHERE metodoPagoId = '".$this->metodoPagoId."'"
|
||||
);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
$this->Util()->setError(30003, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function Baja(){
|
||||
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
|
||||
UPDATE metodoPago SET
|
||||
baja = '1'
|
||||
WHERE
|
||||
metodoPagoId = '".$this->metodoPagoId."'"
|
||||
);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData();
|
||||
|
||||
$this->Util()->setError(30003, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}//Baja
|
||||
|
||||
function GetNameById()
|
||||
{
|
||||
$sql = 'SELECT nombre FROM metodoPago
|
||||
WHERE metodoPagoId = "'.$this->metodoPagoId.'"';
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$nombre = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $nombre;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
358
classes/monedero.class.php
Executable file
358
classes/monedero.class.php
Executable file
@@ -0,0 +1,358 @@
|
||||
<?php
|
||||
|
||||
class Monedero extends Main
|
||||
{
|
||||
private $monederoId;
|
||||
private $ventaId;
|
||||
private $devolucionId;
|
||||
private $fecha;
|
||||
private $codigo;
|
||||
private $saldo;
|
||||
private $total;
|
||||
private $tipo;
|
||||
private $status;
|
||||
|
||||
public function setMonederoId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->monederoId = $value;
|
||||
}
|
||||
|
||||
public function setVentaId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->ventaId = $value;
|
||||
}
|
||||
|
||||
public function setDevolucionId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->devolucionId = $value;
|
||||
}
|
||||
|
||||
public function setFecha($value)
|
||||
{
|
||||
$this->fecha = $value;
|
||||
}
|
||||
|
||||
public function setCodigo($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Nombre');
|
||||
$this->codigo = $value;
|
||||
}
|
||||
|
||||
public function setSaldo($value)
|
||||
{
|
||||
$this->saldo = $value;
|
||||
}
|
||||
|
||||
public function setTotal($value)
|
||||
{
|
||||
$this->total = $value;
|
||||
}
|
||||
|
||||
public function setTipo($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Tipo');
|
||||
$this->tipo = $value;
|
||||
}
|
||||
|
||||
public function setStatus($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Status');
|
||||
$this->status = $value;
|
||||
}
|
||||
|
||||
function Info(){
|
||||
|
||||
$sql = "SELECT
|
||||
*
|
||||
FROM
|
||||
monedero
|
||||
WHERE
|
||||
monederoId = '".$this->monederoId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$row = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
function EnumHistorial()
|
||||
{
|
||||
$sql = "SELECT * FROM monederoHistorial
|
||||
WHERE monederoId = '".$this->monederoId."'
|
||||
ORDER BY fecha DESC";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$historial = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $historial;
|
||||
}
|
||||
|
||||
function EnumerateAll()
|
||||
{
|
||||
$sql = "SELECT * FROM monedero ORDER BY fecha ASC";
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$monederos = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $monederos;
|
||||
}
|
||||
|
||||
function Enumerate()
|
||||
{
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT COUNT(*) FROM monedero");
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
$pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/monederos");
|
||||
|
||||
$sqlAdd = " LIMIT ".$pages["start"].", ".$pages["items_per_page"];
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT * FROM monedero ORDER BY fecha ASC".$sqlAdd);
|
||||
$monederos = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$data["items"] = $monederos;
|
||||
$data["pages"] = $pages;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function Save(){
|
||||
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO `monedero`
|
||||
(
|
||||
tipo,
|
||||
fecha,
|
||||
codigo,
|
||||
saldo,
|
||||
status
|
||||
)
|
||||
VALUES (
|
||||
'".$this->tipo."',
|
||||
'".$this->fecha."',
|
||||
'".$this->codigo."',
|
||||
'".$this->saldo."',
|
||||
'".$this->status."'
|
||||
)";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$monederoId = $this->Util()->DBSelect($_SESSION['empresaId'])->InsertData();
|
||||
|
||||
$this->Util()->setError(30063, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return $monederoId;
|
||||
|
||||
}
|
||||
|
||||
function Update(){
|
||||
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = "UPDATE
|
||||
`monedero`
|
||||
SET
|
||||
status = '".$this->status."'
|
||||
WHERE
|
||||
monederoId = ".$this->monederoId;
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->ExecuteQuery();
|
||||
|
||||
$this->Util()->setError(30064, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function UpdateStatus(){
|
||||
|
||||
$sql = "UPDATE
|
||||
`monedero`
|
||||
SET
|
||||
status = '".$this->status."'
|
||||
WHERE
|
||||
monederoId = ".$this->monederoId;
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->ExecuteQuery();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function Delete(){
|
||||
|
||||
$sql = "DELETE FROM
|
||||
monedero
|
||||
WHERE
|
||||
monederoId = '".$this->monederoId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$sql = "DELETE FROM
|
||||
monederoHistorial
|
||||
WHERE
|
||||
monederoId = '".$this->monederoId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$this->Util()->setError(30065, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function SaveHistorial(){
|
||||
|
||||
$sql = "INSERT INTO `monederoHistorial`
|
||||
(
|
||||
fecha,
|
||||
monederoId,
|
||||
ventaId,
|
||||
devolucionId,
|
||||
tipo,
|
||||
cantidad
|
||||
)
|
||||
VALUES (
|
||||
'".$this->fecha."',
|
||||
'".$this->monederoId."',
|
||||
'".$this->ventaId."',
|
||||
'".$this->devolucionId."',
|
||||
'".$this->tipo."',
|
||||
'".$this->total."'
|
||||
)";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->ExecuteQuery();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function AddSaldo(){
|
||||
|
||||
$sql = "UPDATE
|
||||
`monedero`
|
||||
SET
|
||||
saldo = saldo + '".$this->total."'
|
||||
WHERE
|
||||
monederoId = ".$this->monederoId;
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->ExecuteQuery();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function RemoveSaldo(){
|
||||
|
||||
$sql = "UPDATE
|
||||
`monedero`
|
||||
SET
|
||||
saldo = saldo - '".$this->total."'
|
||||
WHERE
|
||||
monederoId = ".$this->monederoId;
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->ExecuteQuery();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function GetNameById(){
|
||||
|
||||
$sql = "SELECT
|
||||
nombre
|
||||
FROM
|
||||
monedero
|
||||
WHERE
|
||||
monederoId = '".$this->monederoId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$name = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
function GetIdByCodigo(){
|
||||
|
||||
$sql = "SELECT
|
||||
monederoId
|
||||
FROM
|
||||
monedero
|
||||
WHERE
|
||||
codigo = '".$this->codigo."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$monederoId = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $monederoId;
|
||||
}
|
||||
|
||||
function GeneraCodigo($length = 6){
|
||||
|
||||
$password = '';
|
||||
|
||||
$possible = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
|
||||
$i = 0;
|
||||
while ($i < $length) {
|
||||
$char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
|
||||
if (!strstr($password, $char)) {
|
||||
$password .= $char;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
return $password;
|
||||
|
||||
}//GeneraCodigo
|
||||
|
||||
function GetNextId(){
|
||||
|
||||
$sql = 'SHOW TABLE STATUS LIKE "monedero"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$row = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $row['Auto_increment'];
|
||||
|
||||
}
|
||||
|
||||
function Search()
|
||||
{
|
||||
$sqlAdd = '';
|
||||
|
||||
if($this->tipo)
|
||||
$sqlAdd .= ' AND tipo = "'.$this->tipo.'"';
|
||||
|
||||
if($this->status)
|
||||
$sqlAdd .= ' AND status = "'.$this->status.'"';
|
||||
|
||||
$sql = "SELECT * FROM monedero
|
||||
WHERE 1
|
||||
".$sqlAdd."
|
||||
ORDER BY fecha ASC";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$monederos = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $monederos;
|
||||
}
|
||||
|
||||
function SuggestVta(){
|
||||
|
||||
$sql = "SELECT * FROM monedero
|
||||
WHERE tipo = 'Tarjeta'
|
||||
AND status = 'Disponible'
|
||||
ORDER BY fecha ASC";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$monederos = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $monederos;
|
||||
|
||||
}
|
||||
|
||||
}//Monedero
|
||||
|
||||
?>
|
||||
156
classes/motivo.class.php
Executable file
156
classes/motivo.class.php
Executable file
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
|
||||
class Motivo extends Main
|
||||
{
|
||||
private $motivoId;
|
||||
private $nombre;
|
||||
|
||||
public function setMotivoId($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, "Motivo");
|
||||
$this->motivoId = $value;
|
||||
}
|
||||
|
||||
public function setNombre($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Nombre');
|
||||
$this->nombre = $value;
|
||||
}
|
||||
|
||||
function Info(){
|
||||
|
||||
$sql = "SELECT
|
||||
*
|
||||
FROM
|
||||
motivo
|
||||
WHERE
|
||||
motivoId = '".$this->motivoId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$row = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
function EnumerateAll()
|
||||
{
|
||||
$sql = "SELECT * FROM motivo WHERE baja = '0' ORDER BY nombre ASC";
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$motivos = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $motivos;
|
||||
}
|
||||
|
||||
function Enumerate()
|
||||
{
|
||||
$sql = "SELECT COUNT(*) FROM motivo WHERE baja = '0'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
$pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/motivos");
|
||||
|
||||
$sqlAdd = " LIMIT ".$pages["start"].", ".$pages["items_per_page"];
|
||||
|
||||
$sql = "SELECT * FROM motivo WHERE baja = '0' ORDER BY nombre ASC".$sqlAdd;
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$motivos = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$data["items"] = $motivos;
|
||||
$data["pages"] = $pages;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function Save(){
|
||||
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO `motivo`
|
||||
(
|
||||
nombre
|
||||
)
|
||||
VALUES (
|
||||
'".utf8_decode($this->nombre)."'
|
||||
)";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->ExecuteQuery();
|
||||
|
||||
$this->Util()->setError(30051, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function Update(){
|
||||
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = "UPDATE
|
||||
`motivo`
|
||||
SET
|
||||
nombre = '".utf8_decode($this->nombre)."'
|
||||
WHERE
|
||||
motivoId = ".$this->motivoId;
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->ExecuteQuery();
|
||||
|
||||
$this->Util()->setError(30052, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function Delete(){
|
||||
|
||||
$sql = "DELETE FROM
|
||||
motivo
|
||||
WHERE
|
||||
motivoId = '".$this->motivoId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$this->Util()->setError(30053, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function Baja(){
|
||||
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
|
||||
UPDATE motivo SET baja = '1'
|
||||
WHERE motivoId = '".$this->motivoId."'"
|
||||
);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData();
|
||||
|
||||
$this->Util()->setError(30053, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}//Baja
|
||||
|
||||
function GetNameById(){
|
||||
|
||||
$sql = "SELECT
|
||||
nombre
|
||||
FROM
|
||||
motivo
|
||||
WHERE
|
||||
motivoId = '".$this->motivoId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$name = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
}//Motivo
|
||||
|
||||
?>
|
||||
642
classes/override_generate_pdf_default.php
Executable file
642
classes/override_generate_pdf_default.php
Executable file
@@ -0,0 +1,642 @@
|
||||
<?php
|
||||
|
||||
class Override extends Comprobante
|
||||
{
|
||||
function GeneratePDF($data, $serie, $totales, $nodoEmisor, $nodoReceptor, $nodosConceptos,$empresa, $cancelado = 0, $vistaPrevia = 0)
|
||||
{
|
||||
global $rfc;
|
||||
|
||||
$this->GenerateQR($data, $totales, $nodoEmisor, $nodoReceptor, $empresa, $serie);
|
||||
//Instanciation of inherited class
|
||||
$pdf=new PDF('P', 'mm', "a4");
|
||||
$pdf->SetMargins(0.5,0.1,0.5);
|
||||
$pdf->SetAutoPageBreak(1, 5);
|
||||
|
||||
$pdf->AliasNbPages();
|
||||
$pdf->AddPage();
|
||||
$pdf->AddFont('verdana','','verdana.php');
|
||||
$pdf->SetFont('verdana','',7);
|
||||
|
||||
$pdf->SetY(2);
|
||||
$pdf->SetX(2);
|
||||
$pdf->SetTextColor(200, 0, 0);
|
||||
$pdf->Cell(20,10,$data["comprobante"]["nombre"],0,0,'C');
|
||||
|
||||
$rootQr = DOC_ROOT."/empresas/".$_SESSION["empresaId"]."/qrs/";
|
||||
$qrRfc = strtoupper($data["nodoEmisor"]["rfc"]["rfc"]);
|
||||
$nufa = $serie["serieId"].".jpg";
|
||||
|
||||
if(file_exists($rootQr.$nufa))
|
||||
{
|
||||
//$pdf->Image($rootQr.$nufa,$xstart+160,$setY+15, 27.5, 27.5,'PNG');
|
||||
$pdf->Image($rootQr.$nufa,2,10, 25,25);
|
||||
}
|
||||
|
||||
$nufa = $empresa["empresaId"]."_".$serie["serie"]."_".$data["folio"];
|
||||
|
||||
$rfcActivo = $rfc->getRfcActive();
|
||||
$root = DOC_ROOT."/empresas/".$_SESSION["empresaId"]."/certificados/".$rfcActivo."/facturas/pdf/";
|
||||
$rootFacturas = DOC_ROOT."/empresas/".$_SESSION["empresaId"]."/certificados/".$rfcActivo."/facturas/";
|
||||
$rootQr = DOC_ROOT."/empresas/".$_SESSION["empresaId"]."/certificados/".$rfcActivo."/facturas/qr/";
|
||||
|
||||
$pdf->Image($rootQr.$nufa.'.png',180,8, 28, 28);
|
||||
|
||||
|
||||
$pdf->SetTextColor(255, 255, 255);
|
||||
//block emisor
|
||||
$pdf->SetFillColor(30,30,30);
|
||||
$pdf->SetDrawColor(30,30,30);
|
||||
$pdf->Rect(30, 10, 20, 3, 'DF');
|
||||
|
||||
$xstart = 35;
|
||||
$pdf->SetY(8);
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->Cell(70,8,"Emisor",0);
|
||||
$pdf->SetTextColor(0, 0, 0);
|
||||
|
||||
$pdf->SetFont('verdana','',7);
|
||||
$xstart = 30;
|
||||
$pdf->SetY(14);
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(80,3,utf8_decode(urldecode($data["nodoEmisor"]["rfc"]["razonSocial"])),0);
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(80,3,utf8_decode("Direccion: ".urldecode($data["nodoEmisor"]["rfc"]["calle"]." ".$data["nodoEmisor"]["rfc"]["noExt"]." ".$data["nodoEmisor"]["rfc"]["noInt"]." ".$data["nodoEmisor"]["rfc"]["colonia"])),0);
|
||||
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(80,3,utf8_decode(urldecode($data["nodoEmisor"]["rfc"]["municipio"]." ".$data["nodoEmisor"]["rfc"]["estado"]." ".$data["nodoEmisor"]["rfc"]["pais"]." CP: ".$data["nodoEmisor"]["rfc"]["cp"])),0);
|
||||
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(80,3,"RFC: ".$data["nodoEmisor"]["rfc"]["rfc"],0);
|
||||
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(80,3,"Regimen Fiscal: ".utf8_decode(urldecode($data["nodoEmisor"]["rfc"]["regimenFiscal"])),0);
|
||||
|
||||
//block serie
|
||||
$pdf->SetFillColor(30,30,30);
|
||||
$pdf->SetTextColor(255, 255, 255);
|
||||
$pdf->Rect(112, 10, 25, 22, 'DF');
|
||||
$pdf->SetFillColor(255);
|
||||
|
||||
$xstart = 113;
|
||||
$pdf->SetY(11);
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(70,3,"Serie",0);
|
||||
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(70,3,"Folio",0);
|
||||
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(70,3,"Certificado",0);
|
||||
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(70,3,"Fecha",0);
|
||||
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(90,3,utf8_decode("UUID"),0);
|
||||
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(70,3,"Fecha Timbrado",0);
|
||||
|
||||
$xstart = 138;
|
||||
$pdf->SetY(10);
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->SetTextColor(200, 0, 0);
|
||||
$pdf->MultiCell(43,3,$data["serie"]["serie"],0,0,'R');
|
||||
|
||||
$pdf->SetTextColor(0, 0, 0);
|
||||
$xstart = 138;
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(43,3,$data["folio"],0,0,'R');
|
||||
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(43,3,$data["serie"]["noCertificado"],0,0,'R');
|
||||
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(43,4,$data["fecha"],0,0,'R');
|
||||
|
||||
$pdf->SetFont('verdana','',5);
|
||||
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(43,3,$data["timbreFiscal"]["UUID"],0,0,'R');
|
||||
|
||||
$pdf->SetFont('verdana','',7);
|
||||
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(43,3,$data["timbreFiscal"]["FechaTimbrado"],0,0,'R');
|
||||
|
||||
$pdf->SetY(35);
|
||||
|
||||
$pdf->Line(10,$pdf->GetY()+1,200,$pdf->GetY()+1);
|
||||
$pdf->Line(10,$pdf->GetY()+2,200,$pdf->GetY()+2);
|
||||
|
||||
//block receptor
|
||||
$pdf->SetFillColor(30,30,30);
|
||||
$pdf->Rect(2, 40, 25, 3, 'DF');
|
||||
$pdf->SetTextColor(255, 255, 255);
|
||||
|
||||
$pdf->SetFont('verdana','',7);
|
||||
|
||||
$xstart = 2;
|
||||
$pdf->SetY(38);
|
||||
$pdf->SetX(6);
|
||||
$pdf->MultiCell(70,8,"Receptor",0);
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
|
||||
$data["nodoReceptor"]["nombre"] = urlencode($data["nodoReceptor"]["nombre"]);
|
||||
|
||||
// $pdf->MultiCell(80,3,utf8_decode(urldecode($data["nodoReceptor"]["nombre"])),0);
|
||||
|
||||
$infoReceptor = utf8_decode(urldecode($data["nodoReceptor"]["nombre"]));
|
||||
$infoReceptor .= "\n".utf8_decode(urldecode("Direccion ".$data["nodoReceptor"]["calle"]." ".$data["nodoReceptor"]["noExt"]." ".$data["nodoReceptor"]["noInt"]));
|
||||
$infoReceptor .= "\n".utf8_decode(urldecode($data["nodoReceptor"]["colonia"]));
|
||||
$infoReceptor .= "\n".utf8_decode(urldecode($data["nodoReceptor"]["municipio"]." ".$data["nodoReceptor"]["estado"]." ".$data["nodoReceptor"]["pais"]." CP: ".$data["nodoReceptor"]["cp"]));
|
||||
|
||||
//$pdf->MultiCell(80,3,utf8_decode(urldecode($data["nodoEmisor"]["rfc"]["razonSocial"])),0);
|
||||
|
||||
$infoReceptor .= "\n".urldecode("RFC: ".$this->Util()->CadenaOriginalVariableFormat($data["nodoReceptor"]["rfc"],false,false));
|
||||
|
||||
$xstart = 2;
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
|
||||
|
||||
$pdf->SetFont('verdana','',7);
|
||||
$pdf->SetWidths(array(100));
|
||||
//$data["observaciones"] = substr(str_replace(array("\r", "\r\n", "\n"), "", $data["observaciones"]), 0, 173);
|
||||
$nb = $pdf->WordWrap($infoReceptor, 100);
|
||||
$pdf->Row(
|
||||
array( $infoReceptor), 3
|
||||
);
|
||||
|
||||
$pdf->SetFont('verdana','',7);
|
||||
|
||||
//$pdf->MultiCell(80,4,$infoReceptor,0);
|
||||
|
||||
//block sucursal
|
||||
|
||||
if($data["nodoEmisor"]["sucursal"]["sucursalActiva"] == 'no'){
|
||||
|
||||
$infoSucursal = urldecode($data["nodoEmisor"]["sucursal"]["identificador"]);
|
||||
$infoSucursal .= "\n".urldecode("Direccion: ".$data["nodoEmisor"]["sucursal"]["calle"]." ".$data["nodoEmisor"]["sucursal"]["noExt"]." ".$data["nodoEmisor"]["sucursal"]["noInt"]);
|
||||
$infoSucursal .= "\n".urldecode($data["nodoEmisor"]["sucursal"]["colonia"]);
|
||||
$infoSucursal .= "\n".urldecode($data["nodoEmisor"]["sucursal"]["municipio"]." ".$data["nodoEmisor"]["sucursal"]["estado"]." ".$data["nodoEmisor"]["sucursal"]["pais"]." \nCP: ".$data["nodoEmisor"]["sucursal"]["cp"]);
|
||||
//$infoSucursal .= "\n".urldecode("RFC: ".$data["nodoEmisor"]["sucursal"]["rfc"]);
|
||||
|
||||
$pdf->SetFillColor(30,30,30);
|
||||
$pdf->Rect(105, 40, 35, 3, 'DF');
|
||||
$pdf->SetTextColor(255, 255, 255);
|
||||
|
||||
$xstart = 110;
|
||||
$pdf->SetY(38);
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(70,8,"Lugar de Expedicion:",0);
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
|
||||
$xstart = 105;
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
|
||||
$pdf->SetFont('verdana','',7);
|
||||
$pdf->SetWidths(array(100));
|
||||
//$data["observaciones"] = substr(str_replace(array("\r", "\r\n", "\n"), "", $data["observaciones"]), 0, 173);
|
||||
$nb = $pdf->WordWrap($infoSucursal, 100);
|
||||
$pdf->Row(
|
||||
array( utf8_decode(urldecode($infoSucursal))
|
||||
), 3
|
||||
);
|
||||
$pdf->SetFont('verdana','',8);
|
||||
|
||||
|
||||
}//if
|
||||
else
|
||||
{
|
||||
$infoSucursal = urldecode($data["nodoEmisor"]["sucursal"]["identificador"]."\n . \n . \n . \n");
|
||||
|
||||
$pdf->SetFillColor(30,30,30);
|
||||
$pdf->Rect(105, 40, 35, 3, 'DF');
|
||||
$pdf->SetTextColor(255, 255, 255);
|
||||
|
||||
$xstart = 110;
|
||||
$pdf->SetY(38);
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(70,8,"Lugar de Expedicion:",0);
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
|
||||
$xstart = 105;
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
|
||||
$pdf->SetFont('verdana','',7);
|
||||
$pdf->SetWidths(array(100));
|
||||
//$data["observaciones"] = substr(str_replace(array("\r", "\r\n", "\n"), "", $data["observaciones"]), 0, 173);
|
||||
$nb = $pdf->WordWrap($infoSucursal, 100);
|
||||
$pdf->Row(
|
||||
array( utf8_decode(urldecode($infoSucursal))
|
||||
), 3
|
||||
);
|
||||
$pdf->SetFont('verdana','',8);
|
||||
|
||||
|
||||
}//if
|
||||
|
||||
$setY = $pdf->GetY() + 5;
|
||||
$pdf->SetY($setY);
|
||||
$pdf->Line(10,$pdf->GetY(),200,$pdf->GetY());
|
||||
$pdf->Line(10,$pdf->GetY() + 1,200,$pdf->GetY() + 1);
|
||||
|
||||
//observaciones
|
||||
$pdf->SetY($pdf->GetY() + 2);
|
||||
$pdf->SetFont('courier','',7);
|
||||
$pdf->SetWidths(array(210));
|
||||
//$data["observaciones"] = substr(str_replace(array("\r", "\r\n", "\n"), "", $data["observaciones"]), 0, 173);
|
||||
//$nb = $pdf->WordWrap($data["observaciones"], 180);
|
||||
$pdf->Row(
|
||||
array( utf8_decode(urldecode($data["observaciones"]))), 3
|
||||
);
|
||||
$pdf->SetFont('verdana','',7);
|
||||
//$pdf->CheckPageBreak(50);
|
||||
|
||||
//block conceptos
|
||||
$pdf->SetFillColor(30,30,30);
|
||||
$pdf->SetTextColor(255, 255, 255);
|
||||
$pdf->Rect(2, $pdf->GetY()+2, 205, 6, 'DF');
|
||||
|
||||
$xstart = 2;
|
||||
$y = $pdf->GetY();
|
||||
$pdf->SetY($pdf->GetY()+2);
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->Cell(15,8,"Cnt.",0,0,"C");
|
||||
$pdf->Cell(15,8,"Unid.",0,0,"C");
|
||||
$pdf->Cell(20,8,"No. Id",0,0,"C");
|
||||
$pdf->Cell(113,8,"Descripcion",0,0,"C");
|
||||
$pdf->Cell(17,8,"P. Unit.",0,0,"C");
|
||||
$pdf->Cell(22,8,"Importe",0,0,"C");
|
||||
|
||||
$setY = $pdf->GetY()+10;
|
||||
$pdf->SetY($setY);
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
|
||||
//Table with 20 rows and 4 columns
|
||||
$pdf->SetWidths(array(5,15, 17, 25, 100, 22, 22));
|
||||
$pdf->SetAligns(array('L','L', 'L', 'L', 'L', 'R', 'R'));
|
||||
$pdf->SetFont('courier','',7);
|
||||
$xstart = 15;
|
||||
$count = 1;
|
||||
foreach($nodosConceptos as $concepto)
|
||||
{
|
||||
if($count % 2 == 0)
|
||||
{
|
||||
$pdf->SetTextColor(100, 100, 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
$pdf->SetTextColor(0, 0, 0);
|
||||
}
|
||||
$count++;
|
||||
|
||||
//$nb = $pdf->WordWrap($concepto["descripcion"], 105);
|
||||
$xstart = 15;
|
||||
$pdf->Row(
|
||||
array(
|
||||
"",
|
||||
$this->Util()->CadenaOriginalVariableFormat($concepto["cantidad"],false,false),
|
||||
$this->Util()->CadenaOriginalVariableFormat($concepto["unidad"],false,false),
|
||||
$this->Util()->CadenaOriginalVariableFormat($concepto["noIdentificacion"],false,false),
|
||||
utf8_decode($concepto["descripcion"]),
|
||||
"$".$this->Util()->CadenaOriginalPDFFormat($concepto["valorUnitario"], true,false),
|
||||
"$".$this->Util()->CadenaOriginalPDFFormat($concepto["importe"], true,false)
|
||||
),3
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
$pdf->SetTextColor(0, 0, 0);
|
||||
//check page break
|
||||
// $pdf->CheckPageBreak(50);
|
||||
//$impuesto["importe"] = number_format($impuesto["importe"], 2);
|
||||
|
||||
$count = 1;
|
||||
if($_SESSION["impuestos"])
|
||||
{
|
||||
$setY = $pdf->GetY();
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->Cell(40,8,"Otros impuestos o retenciones",0,0,"C");
|
||||
$pdf->Ln();
|
||||
$pdf->SetTextColor(0, 0, 0);
|
||||
|
||||
//Table with 20 rows and 4 columns
|
||||
$pdf->SetWidths(array(20, 20, 142, 22));
|
||||
$pdf->SetAligns(array('L', 'L', 'L', 'R'));
|
||||
|
||||
$xstart = 15;
|
||||
|
||||
if($count % 2 == 0)
|
||||
{
|
||||
$pdf->SetTextColor(100, 100, 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
$pdf->SetTextColor(0, 0, 0);
|
||||
}
|
||||
$count++;
|
||||
|
||||
foreach($_SESSION["impuestos"] as $impuesto)
|
||||
{
|
||||
$nb = $pdf->WordWrap($impuesto["impuesto"], 80);
|
||||
$xstart = 15;
|
||||
$pdf->Row(
|
||||
array(
|
||||
$this->Util()->CadenaOriginalVariableFormat(ucfirst($impuesto["tipo"]),false,false),
|
||||
$this->Util()->CadenaOriginalVariableFormat($impuesto["tasa"]."%",false,false),
|
||||
$this->Util()->CadenaOriginalVariableFormat($impuesto["impuesto"],false,false),
|
||||
"$".$this->Util()->CadenaOriginalPDFFormat($impuesto["importe"] * count($_SESSION["conceptos"]), true, false)
|
||||
),3
|
||||
);
|
||||
|
||||
//TODO la parte y el complemento.
|
||||
}
|
||||
//check page break
|
||||
// $pdf->CheckPageBreak(50);
|
||||
}
|
||||
|
||||
$setY = $pdf->GetY() + 3;
|
||||
$pdf->Line(10,$setY,200,$setY);
|
||||
$pdf->Line(10,$setY+1,200,$setY+1);
|
||||
|
||||
//block con letra
|
||||
$pdf->SetFillColor(30,30,30);
|
||||
$pdf->Rect(2, $setY+2, 22, 13, 'DF');
|
||||
$pdf->SetTextColor(255, 255, 255);
|
||||
|
||||
$xstart = 3;
|
||||
$pdf->SetY($setY+3);
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->SetFont('verdana','',7);
|
||||
$pdf->MultiCell(25,3,"Total Con letra",0);
|
||||
$totales["total"];
|
||||
$cents = ($totales["total"] - floor($totales["total"]))*100;
|
||||
$totales["total2"] = $totales["total"];
|
||||
|
||||
$centavosLetra = $this->Util()->GetCents($totales["total"]);
|
||||
if($cents >= 99)
|
||||
{
|
||||
$totales["total"] = ceil($totales["total"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$totales["total"] = floor($totales["total"]);
|
||||
}
|
||||
//echo $centavosLetra;
|
||||
$cantidadLetra = $this->Util()->num2letras($totales["total"], false);
|
||||
//tipo de cambio
|
||||
switch($data["tiposDeMoneda"])
|
||||
{
|
||||
case "MXN": $tiposDeCambio = "Pesos"; $tiposDeCambioSufix = "M.N";break;
|
||||
case "USD": $tiposDeCambio = "Dolares"; $tiposDeCambioSufix = "";break;
|
||||
case "EUR": $tiposDeCambio = "Euros"; $tiposDeCambioSufix = "";break;
|
||||
}
|
||||
|
||||
$temp = new CNumeroaLetra ();
|
||||
$temp->setMayusculas(1);
|
||||
$temp->setGenero(1);
|
||||
$temp->setMoneda($tiposDeCambio);
|
||||
$temp->setDinero(1);
|
||||
$temp->setPrefijo('(');
|
||||
$temp->setSufijo($tiposDeCambioSufix.')');
|
||||
$temp->setNumero($totales["total2"]);
|
||||
$letra = $temp->letra();
|
||||
|
||||
// $letra = "(".$cantidadLetra." ".$tiposDeCambio." ".$centavosLetra."/100 ".$tiposDeCambioSufix.")";
|
||||
//tipo de cambio
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
$pdf->SetY($setY+3);
|
||||
$pdf->SetX(25);
|
||||
$pdf->MultiCell(120,3,$letra,0);
|
||||
|
||||
$pdf->SetFont('verdana','',7);
|
||||
|
||||
//add cuenta
|
||||
if($data["NumCtaPago"])
|
||||
{
|
||||
$add = "Numero de Cuenta: ".$data["NumCtaPago"];
|
||||
}
|
||||
|
||||
$y = $pdf->GetY()+3;
|
||||
$pdf->SetY($y);
|
||||
$pdf->SetX($xstart);
|
||||
//echo $data["formaDePago"];
|
||||
$pdf->SetTextColor(255, 255, 255);
|
||||
$pdf->MultiCell(25,3,"Tipo De Pago",0);
|
||||
$pdf->SetY($y);
|
||||
$pdf->SetX(25);
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
$pdf->MultiCell(120,3,$this->Util()->DecodeVal($data["formaDePago"]."\nMetodo de Pago: ".$data["metodoDePago"].". ".$add),0);
|
||||
|
||||
|
||||
//block totales
|
||||
$pdf->SetFillColor(30,30,30);
|
||||
$pdf->Rect(155, $setY+2, 20, 24, 'DF');
|
||||
|
||||
//$pdf->SetFillColor(255);
|
||||
$pdf->SetTextColor(255, 255, 255);
|
||||
|
||||
$xstart = 155;
|
||||
$pdf->SetY($setY+2);
|
||||
$pdf->SetX($xstart);
|
||||
//$pdf->SetFillColor(192);
|
||||
$pdf->MultiCell(20,3,"Subtotal",0,"C",0);
|
||||
$pdf->SetY($pdf->GetY()-3);
|
||||
$pdf->SetX($xstart+20);
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
$pdf->MultiCell(31,3,"$".$this->Util()->CadenaOriginalPDFFormat($totales["subtotal"], true,false),0,"R",0);
|
||||
|
||||
if($totales["descuento"] != 0)
|
||||
{
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->SetTextColor(255, 255, 255);
|
||||
$pdf->MultiCell(20,3,"Descuento",0,"C");
|
||||
$pdf->SetY($pdf->GetY()-3);
|
||||
$pdf->SetX($xstart+20);
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
$pdf->MultiCell(31,3,"$".$this->Util()->CadenaOriginalPDFFormat($totales["descuento"], true,false),0,"R",0);
|
||||
}
|
||||
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->SetTextColor(255, 255, 255);
|
||||
$pdf->MultiCell(20,3,$totales["tasaIva"]."% IVA",0,"C");
|
||||
$pdf->SetY($pdf->GetY()-3);
|
||||
$pdf->SetX($xstart+20);
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
$pdf->MultiCell(31,3,"$".$this->Util()->CadenaOriginalPDFFormat($totales["iva"], true,false),0,"R",0);
|
||||
//print_r($totales);
|
||||
if($totales["retIva"] != 0)
|
||||
{
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->SetTextColor(255, 255, 255);
|
||||
$pdf->MultiCell(20,3,"Ret Iva",0,"C");
|
||||
$pdf->SetY($pdf->GetY()-3);
|
||||
$pdf->SetX($xstart+20);
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
$pdf->MultiCell(31,3,"$".$this->Util()->CadenaOriginalPDFFormat($totales["retIva"], true,false),0,"R",0);
|
||||
}
|
||||
|
||||
if($totales["retIsr"] != 0)
|
||||
{
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->SetTextColor(255, 255, 255);
|
||||
$pdf->MultiCell(20,3,"Ret Isr",0,"C");
|
||||
$pdf->SetY($pdf->GetY()-3);
|
||||
$pdf->SetX($xstart+20);
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
$pdf->MultiCell(31,3,"$".$this->Util()->CadenaOriginalPDFFormat($totales["retIsr"], true,false),0,"R",0);
|
||||
}
|
||||
|
||||
if($totales["porcentajeIEPS"] != 0)
|
||||
{
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->SetTextColor(255, 255, 255);
|
||||
$pdf->MultiCell(20,3,"IEPS",0,"C");
|
||||
$pdf->SetY($pdf->GetY()-3);
|
||||
$pdf->SetX($xstart+20);
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
$pdf->MultiCell(31,3,"$".$this->Util()->CadenaOriginalPDFFormat($totales["ieps"], true,false),0,"R",0);
|
||||
}
|
||||
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->SetTextColor(255, 255, 255);
|
||||
$pdf->MultiCell(20,3,"Total",0,"C");
|
||||
$pdf->SetY($pdf->GetY()-3);
|
||||
$pdf->SetX($xstart+20);
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
$pdf->MultiCell(31,3,"$".$this->Util()->CadenaOriginalPDFFormat($totales["total2"], true,false),0,"R",0);
|
||||
|
||||
$setY = $pdf->GetY() + 15;
|
||||
$pdf->Line(10,$setY+1,200,$setY+1);
|
||||
$pdf->Line(10,$setY+2,200,$setY+2);
|
||||
|
||||
$pdf->SetY($pdf->GetY()+10);
|
||||
$pdf->SetX($xstart);
|
||||
$xstart = 2;
|
||||
$pdf->SetX($xstart);
|
||||
|
||||
$pdf->SetFillColor(255);
|
||||
|
||||
$y = $pdf->GetY() + 10;
|
||||
$pdf->SetY($y);
|
||||
|
||||
if($data["autorizo"])
|
||||
{
|
||||
$pdf->MultiCell(60,3,utf8_decode("AUTORIZO\n\n\n".urldecode($data["autorizo"])),0,"C",0);
|
||||
}
|
||||
$pdf->SetY($y);
|
||||
$pdf->SetX(70);
|
||||
if($data["recibio"])
|
||||
{
|
||||
$pdf->MultiCell(60,3,utf8_decode(urldecode("RECIBIO\n\n\n".$data["recibio"])),0,"C", 0);
|
||||
}
|
||||
$pdf->SetY($y);
|
||||
$pdf->SetX(140);
|
||||
if($data["vobo"])
|
||||
{
|
||||
$pdf->MultiCell(60,3,utf8_decode(urldecode("Vo. Bo\n\n\n".$data["vobo"])),0,"C", 0);
|
||||
}
|
||||
|
||||
if($data["autorizo"] || $data["recibio"] || $data["vobo"])
|
||||
{
|
||||
$pdf->CheckPageBreak(15);
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
}
|
||||
|
||||
//$pdf->SetX(10);
|
||||
$y = $pdf->GetY();
|
||||
$pdf->SetY($y+5);
|
||||
if($data["reviso"])
|
||||
{
|
||||
$pdf->MultiCell(90,3,utf8_decode(urldecode("REVISO\n\n\n".$data["reviso"])),0,"C",0);
|
||||
}
|
||||
|
||||
$pdf->SetY($y+5);
|
||||
$pdf->SetX(100);
|
||||
|
||||
if($data["pago"])
|
||||
{
|
||||
$pdf->MultiCell(90,3,utf8_decode(urldecode("PAGO\n\n\n".$data["pago"])),0,"C",0);
|
||||
}
|
||||
|
||||
$xstart = 2;
|
||||
$pdf->SetY($pdf->GetY()+20);
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(207,3,utf8_decode("ESTE DOCUMENTO ES UNA REPRESENTACION IMPRESA DE UN CFDI"),0,"C");
|
||||
|
||||
$pdf->SetY($pdf->GetY());
|
||||
|
||||
$pdf->SetFont('verdana','',5);
|
||||
$pdf->SetFillColor(255,255,255);
|
||||
$pdf->SetTextColor(0, 0, 0);
|
||||
$pdf->MultiCell(207,3,"Sello Emisor: ".$data["sello"],0,"L",1);
|
||||
// $pdf->Ln();
|
||||
$pdf->MultiCell(207,3,"Sello SAT: ".$data["timbreFiscal"]["selloSAT"],0,"L",1);
|
||||
// $pdf->Ln();
|
||||
$cadena["cadenaOriginal"] = utf8_decode(utf8_decode($data["cadenaOriginal"]));
|
||||
$pdf->MultiCell(207,3,"Cadena Original: \n".$cadena["cadenaOriginal"],0,"L",1);
|
||||
|
||||
$cadena["cadenaOriginalTimbre"] = utf8_decode(utf8_decode($data["timbreFiscal"]["original"]));
|
||||
$pdf->MultiCell(207,3,"Cadena Original Timbre Fiscal: \n".$cadena["cadenaOriginalTimbre"],0,"L",1);
|
||||
|
||||
if($cancelado){
|
||||
|
||||
$xstart = 10;
|
||||
$pdf->SetFont('verdana','',36);
|
||||
$pdf->SetTextColor(255,00,00);
|
||||
$pdf->SetY($setY-15);
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->Cell(180,8,"C A N C E L A D O",0,0,"C");
|
||||
|
||||
}//if
|
||||
|
||||
|
||||
if(!is_dir($rootFacturas))
|
||||
{
|
||||
mkdir($rootFacturas, 0777);
|
||||
}
|
||||
|
||||
if(!is_dir($root))
|
||||
{
|
||||
mkdir($root, 0777);
|
||||
}
|
||||
|
||||
if(!$vistaPrevia)
|
||||
{
|
||||
$pdf->Output($root.$nufa.".pdf", "F");
|
||||
}
|
||||
else
|
||||
{
|
||||
$pdf->Output(DOC_ROOT."/temp/vistaPrevia.pdf", "F");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
602
classes/override_generator_pdf.class.php
Executable file
602
classes/override_generator_pdf.class.php
Executable file
@@ -0,0 +1,602 @@
|
||||
<?php
|
||||
|
||||
class Override extends Main
|
||||
{
|
||||
function GeneratePDF($data, $serie, $totales, $nodoEmisor, $nodoReceptor, $nodosConceptos, $empresa, $cancelado = 0)
|
||||
{
|
||||
global $rfc;
|
||||
global $comprobante;
|
||||
|
||||
//Instanciation of inherited class
|
||||
$pdf=new PDF('P', 'mm', "a4");
|
||||
$pdf->SetMargins(0.5,0.1,0.5);
|
||||
$pdf->SetAutoPageBreak(1, 5);
|
||||
|
||||
$pdf->AliasNbPages();
|
||||
$pdf->AddPage();
|
||||
$pdf->AddFont('verdana','','verdana.php');
|
||||
$pdf->SetFont('verdana','',7);
|
||||
|
||||
$pdf->SetY(2);
|
||||
$pdf->SetX(2);
|
||||
$pdf->SetTextColor(200, 0, 0);
|
||||
$pdf->Cell(20,10,$data["comprobante"]["nombre"],0,0,'C');
|
||||
|
||||
$rootQr = DOC_ROOT.'/empresas/'.$_SESSION['empresaId'].'/qrs/';
|
||||
$qrRfc = strtoupper($data["nodoEmisor"]["rfc"]["rfc"]);
|
||||
$nufa = $serie["serieId"].".jpg";
|
||||
|
||||
if(file_exists($rootQr.$nufa))
|
||||
{
|
||||
//$pdf->Image($rootQr.$nufa,$xstart+160,$setY+15, 27.5, 27.5,'PNG');
|
||||
$pdf->Image($rootQr.$nufa,2,10, 25,25);
|
||||
}
|
||||
|
||||
$nufa = $_SESSION["empresaId"]."_".$serie["serie"]."_".$data["folio"];
|
||||
|
||||
$rfcActivo = $rfc->getRfcActive();
|
||||
$root = DOC_ROOT."/empresas/".$_SESSION["empresaId"]."/certificados/".$rfcActivo."/facturas/pdf/";
|
||||
$rootFacturas = DOC_ROOT."/empresas/".$_SESSION["empresaId"]."/certificados/".$rfcActivo."/facturas/";
|
||||
$rootQr = DOC_ROOT."/empresas/".$_SESSION["empresaId"]."/certificados/".$rfcActivo."/facturas/qr/";
|
||||
|
||||
if(!file_exists($rootQr.nufa)){
|
||||
$comprobante->GenerateQR($data, $totales, $nodoEmisor, $nodoReceptor, $empresa, $serie);
|
||||
}
|
||||
|
||||
$pdf->Image($rootQr.$nufa.'.png',180,8, 28, 28);
|
||||
|
||||
$pdf->SetTextColor(255, 255, 255);
|
||||
//block emisor
|
||||
$pdf->SetFillColor(30,30,30);
|
||||
$pdf->SetDrawColor(30,30,30);
|
||||
$pdf->Rect(30, 10, 20, 3, 'DF');
|
||||
|
||||
$xstart = 35;
|
||||
$pdf->SetY(8);
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->Cell(70,8,"Emisor",0);
|
||||
$pdf->SetTextColor(0, 0, 0);
|
||||
|
||||
$pdf->SetFont('verdana','',7);
|
||||
$xstart = 30;
|
||||
$pdf->SetY(14);
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(80,3,utf8_decode(urldecode($data["nodoEmisor"]["rfc"]["razonSocial"])),0);
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(80,3,utf8_decode("Direccion: ".urldecode($data["nodoEmisor"]["rfc"]["calle"]." ".$data["nodoEmisor"]["rfc"]["noExt"]." ".$data["nodoEmisor"]["rfc"]["noInt"]." ".$data["nodoEmisor"]["rfc"]["colonia"])),0);
|
||||
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(80,3,utf8_decode(urldecode($data["nodoEmisor"]["rfc"]["municipio"]." ".$data["nodoEmisor"]["rfc"]["estado"]." ".$data["nodoEmisor"]["rfc"]["pais"]." CP: ".$data["nodoEmisor"]["rfc"]["cp"])),0);
|
||||
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(80,3,"RFC: ".$data["nodoEmisor"]["rfc"]["rfc"],0);
|
||||
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(80,3,"Regimen Fiscal: ".utf8_decode(urldecode($data["nodoEmisor"]["rfc"]["regimenFiscal"])),0);
|
||||
|
||||
//block serie
|
||||
$pdf->SetFillColor(30,30,30);
|
||||
$pdf->SetTextColor(255, 255, 255);
|
||||
$pdf->Rect(112, 10, 25, 22, 'DF');
|
||||
$pdf->SetFillColor(255);
|
||||
|
||||
$xstart = 113;
|
||||
$pdf->SetY(11);
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(70,3,"Serie",0);
|
||||
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(70,3,"Folio",0);
|
||||
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(70,3,"Certificado",0);
|
||||
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(70,3,"Fecha",0);
|
||||
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(90,3,utf8_decode("UUID"),0);
|
||||
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(70,3,"Fecha Timbrado",0);
|
||||
|
||||
$xstart = 138;
|
||||
$pdf->SetY(10);
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->SetTextColor(200, 0, 0);
|
||||
$pdf->MultiCell(43,3,$serie['serie'],0,0,'R');
|
||||
|
||||
$pdf->SetTextColor(0, 0, 0);
|
||||
$xstart = 138;
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(43,3,$data["folio"],0,0,'R');
|
||||
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(43,3,$serie['noCertificado'],0,0,'R');
|
||||
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(43,4,$data['fecha'],0,0,'R');
|
||||
|
||||
$pdf->SetFont('verdana','',5);
|
||||
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(43,3,$data['UUID'],0,0,'R');
|
||||
|
||||
$pdf->SetFont('verdana','',7);
|
||||
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(43,3,$data['FechaTimbrado'],0,0,'R');
|
||||
|
||||
$pdf->SetY(35);
|
||||
|
||||
$pdf->Line(10,$pdf->GetY()+1,200,$pdf->GetY()+1);
|
||||
$pdf->Line(10,$pdf->GetY()+2,200,$pdf->GetY()+2);
|
||||
|
||||
//block receptor
|
||||
$pdf->SetFillColor(30,30,30);
|
||||
$pdf->Rect(2, 40, 25, 3, 'DF');
|
||||
$pdf->SetTextColor(255, 255, 255);
|
||||
|
||||
$pdf->SetFont('verdana','',7);
|
||||
|
||||
$xstart = 2;
|
||||
$pdf->SetY(38);
|
||||
$pdf->SetX(6);
|
||||
$pdf->MultiCell(70,8,"Receptor",0);
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
|
||||
$data["nodoReceptor"]["nombre"] = urlencode($data["nodoReceptor"]["nombre"]);
|
||||
|
||||
$infoReceptor = utf8_decode(urldecode($data["nodoReceptor"]["nombre"]));
|
||||
$infoReceptor .= "\nDirección: ".utf8_decode(urldecode($data["nodoReceptor"]["calle"]." ".$data["nodoReceptor"]["noExt"]." ".$data["nodoReceptor"]["noInt"]));
|
||||
$infoReceptor .= "\n".utf8_decode(urldecode($data["nodoReceptor"]["colonia"]));
|
||||
$infoReceptor .= "\n".utf8_decode(urldecode($data["nodoReceptor"]["municipio"]." ".$data["nodoReceptor"]["estado"]." ".$data["nodoReceptor"]["pais"]." CP: ".$data["nodoReceptor"]["cp"]));
|
||||
|
||||
$infoReceptor .= "\n".urldecode("RFC: ".$this->Util()->CadenaOriginalVariableFormat($data["nodoReceptor"]["rfc"],false,false));
|
||||
|
||||
$xstart = 2;
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->SetFont('verdana','',7);
|
||||
$pdf->SetWidths(array(100));
|
||||
$nb = $pdf->WordWrap($infoReceptor, 100);
|
||||
$pdf->Row(
|
||||
array($infoReceptor), 3
|
||||
);
|
||||
|
||||
$pdf->SetFont('verdana','',7);
|
||||
|
||||
//block sucursal
|
||||
|
||||
if($data["nodoEmisor"]["sucursal"]["sucursalActiva"] == 'no'){
|
||||
|
||||
$infoSucursal = utf8_decode(urldecode($data["nodoEmisor"]["sucursal"]["identificador"]));
|
||||
$infoSucursal .= "\nDirección: ".utf8_decode(urldecode($data["nodoEmisor"]["sucursal"]["calle"]." ".$data["nodoEmisor"]["sucursal"]["noExt"]." ".$data["nodoEmisor"]["sucursal"]["noInt"]));
|
||||
$infoSucursal .= "\n".utf8_decode(urldecode($data["nodoEmisor"]["sucursal"]["colonia"]));
|
||||
$infoSucursal .= "\n".utf8_decode(urldecode($data["nodoEmisor"]["sucursal"]["municipio"]." ".$data["nodoEmisor"]["sucursal"]["estado"]." ".$data["nodoEmisor"]["sucursal"]["pais"]." \nCP: ".$data["nodoEmisor"]["sucursal"]["cp"]));
|
||||
|
||||
$pdf->SetFillColor(30,30,30);
|
||||
$pdf->Rect(105, 40, 35, 3, 'DF');
|
||||
$pdf->SetTextColor(255, 255, 255);
|
||||
|
||||
$xstart = 110;
|
||||
$pdf->SetY(38);
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(70,8,"Lugar de Expedición:",0);
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
|
||||
$xstart = 105;
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
|
||||
$pdf->SetFont('verdana','',7);
|
||||
$pdf->SetWidths(array(100));
|
||||
//$data["observaciones"] = substr(str_replace(array("\r", "\r\n", "\n"), "", $data["observaciones"]), 0, 173);
|
||||
$nb = $pdf->WordWrap($infoSucursal, 100);
|
||||
$pdf->Row(
|
||||
array($infoSucursal), 3
|
||||
);
|
||||
$pdf->SetFont('verdana','',8);
|
||||
|
||||
|
||||
}//if
|
||||
else
|
||||
{
|
||||
$infoSucursal = urldecode($data["nodoEmisor"]["sucursal"]["identificador"]."\n . \n . \n . \n");
|
||||
|
||||
$pdf->SetFillColor(30,30,30);
|
||||
$pdf->Rect(105, 40, 35, 3, 'DF');
|
||||
$pdf->SetTextColor(255, 255, 255);
|
||||
|
||||
$xstart = 110;
|
||||
$pdf->SetY(38);
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(70,8,"Lugar de Expedicion:",0);
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
|
||||
$xstart = 105;
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
|
||||
$pdf->SetFont('verdana','',7);
|
||||
$pdf->SetWidths(array(100));
|
||||
|
||||
$nb = $pdf->WordWrap($infoSucursal, 100);
|
||||
$pdf->Row(
|
||||
array( utf8_decode(urldecode($infoSucursal))
|
||||
), 3
|
||||
);
|
||||
$pdf->SetFont('verdana','',8);
|
||||
|
||||
|
||||
}//if
|
||||
|
||||
$setY = $pdf->GetY() + 5;
|
||||
$pdf->SetY($setY);
|
||||
$pdf->Line(10,$pdf->GetY(),200,$pdf->GetY());
|
||||
$pdf->Line(10,$pdf->GetY() + 1,200,$pdf->GetY() + 1);
|
||||
|
||||
//Observaciones
|
||||
$pdf->SetY($pdf->GetY() + 2);
|
||||
$pdf->SetFont('courier','',7);
|
||||
$pdf->SetWidths(array(210));
|
||||
$pdf->Row(
|
||||
array( utf8_decode(urldecode($data["observaciones"]))), 3
|
||||
);
|
||||
$pdf->SetFont('verdana','',7);
|
||||
|
||||
//block conceptos
|
||||
$pdf->SetFillColor(30,30,30);
|
||||
$pdf->SetTextColor(255, 255, 255);
|
||||
$pdf->Rect(2, $pdf->GetY()+2, 205, 6, 'DF');
|
||||
|
||||
$xstart = 2;
|
||||
$y = $pdf->GetY();
|
||||
$pdf->SetY($pdf->GetY()+2);
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->Cell(15,8,"Cnt.",0,0,"C");
|
||||
$pdf->Cell(15,8,"Unid.",0,0,"C");
|
||||
$pdf->Cell(20,8,"No. Id",0,0,"C");
|
||||
$pdf->Cell(113,8,"Descripción",0,0,"C");
|
||||
$pdf->Cell(17,8,"P. Unit.",0,0,"C");
|
||||
$pdf->Cell(22,8,"Importe",0,0,"C");
|
||||
|
||||
$setY = $pdf->GetY()+10;
|
||||
$pdf->SetY($setY);
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
|
||||
//Table with 20 rows and 4 columns
|
||||
$pdf->SetWidths(array(5,15, 17, 25, 100, 22, 22));
|
||||
$pdf->SetAligns(array('L','L', 'L', 'L', 'L', 'R', 'R'));
|
||||
$pdf->SetFont('courier','',7);
|
||||
$xstart = 15;
|
||||
$count = 1;
|
||||
foreach($nodosConceptos as $concepto)
|
||||
{
|
||||
if($count % 2 == 0)
|
||||
{
|
||||
$pdf->SetTextColor(100, 100, 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
$pdf->SetTextColor(0, 0, 0);
|
||||
}
|
||||
$count++;
|
||||
|
||||
$xstart = 15;
|
||||
$pdf->Row(
|
||||
array(
|
||||
"",
|
||||
$this->Util()->CadenaOriginalVariableFormat($concepto["cantidad"],false,false),
|
||||
$this->Util()->CadenaOriginalVariableFormat($concepto["unidad"],false,false),
|
||||
$this->Util()->CadenaOriginalVariableFormat($concepto["noIdentificacion"],false,false),
|
||||
utf8_decode($concepto["descripcion"]),
|
||||
"$".$this->Util()->CadenaOriginalPDFFormat($concepto["valorUnitario"], true,false),
|
||||
"$".$this->Util()->CadenaOriginalPDFFormat($concepto["importe"], true,false)
|
||||
),3
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
$pdf->SetTextColor(0, 0, 0);
|
||||
//check page break
|
||||
|
||||
$count = 1;
|
||||
if($_SESSION["impuestos"])
|
||||
{
|
||||
$setY = $pdf->GetY();
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->Cell(40,8,"Otros impuestos o retenciones",0,0,"C");
|
||||
$pdf->Ln();
|
||||
$pdf->SetTextColor(0, 0, 0);
|
||||
|
||||
//Table with 20 rows and 4 columns
|
||||
$pdf->SetWidths(array(20, 20, 142, 22));
|
||||
$pdf->SetAligns(array('L', 'L', 'L', 'R'));
|
||||
|
||||
$xstart = 15;
|
||||
|
||||
if($count % 2 == 0)
|
||||
{
|
||||
$pdf->SetTextColor(100, 100, 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
$pdf->SetTextColor(0, 0, 0);
|
||||
}
|
||||
$count++;
|
||||
|
||||
foreach($_SESSION["impuestos"] as $impuesto)
|
||||
{
|
||||
$nb = $pdf->WordWrap($impuesto["impuesto"], 80);
|
||||
$xstart = 15;
|
||||
$pdf->Row(
|
||||
array(
|
||||
$this->Util()->CadenaOriginalVariableFormat(ucfirst($impuesto["tipo"]),false,false),
|
||||
$this->Util()->CadenaOriginalVariableFormat($impuesto["tasa"]."%",false,false),
|
||||
$this->Util()->CadenaOriginalVariableFormat($impuesto["impuesto"],false,false),
|
||||
"$".$this->Util()->CadenaOriginalPDFFormat($impuesto["importe"] * count($_SESSION["conceptos"]), true, false)
|
||||
),3
|
||||
);
|
||||
|
||||
//TODO la parte y el complemento.
|
||||
}
|
||||
//check page break
|
||||
|
||||
}
|
||||
|
||||
$setY = $pdf->GetY() + 3;
|
||||
$pdf->Line(10,$setY,200,$setY);
|
||||
$pdf->Line(10,$setY+1,200,$setY+1);
|
||||
|
||||
//block con letra
|
||||
$pdf->SetFillColor(30,30,30);
|
||||
$pdf->Rect(2, $setY+2, 22, 13, 'DF');
|
||||
$pdf->SetTextColor(255, 255, 255);
|
||||
|
||||
$xstart = 3;
|
||||
$pdf->SetY($setY+3);
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->SetFont('verdana','',7);
|
||||
$pdf->MultiCell(25,3,"Total Con letra",0);
|
||||
$cents = ($totales["total"] - floor($totales["total"]))*100;
|
||||
$totales["total2"] = $totales["total"];
|
||||
|
||||
$centavosLetra = $this->Util()->GetCents($totales["total"]);
|
||||
if($cents >= 99)
|
||||
{
|
||||
$totales["total"] = ceil($totales["total"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$totales["total"] = floor($totales["total"]);
|
||||
}
|
||||
|
||||
//Tipo de cambio
|
||||
switch($data["tiposDeMoneda"])
|
||||
{
|
||||
case "MXN": $tiposDeCambio = "Pesos"; $tiposDeCambioSufix = "M.N";break;
|
||||
case "USD": $tiposDeCambio = "Dolares"; $tiposDeCambioSufix = "";break;
|
||||
case "EUR": $tiposDeCambio = "Euros"; $tiposDeCambioSufix = "";break;
|
||||
}
|
||||
|
||||
$temp = new CNumeroaLetra ();
|
||||
$temp->setMayusculas(1);
|
||||
$temp->setGenero(1);
|
||||
$temp->setMoneda($tiposDeCambio);
|
||||
$temp->setDinero(1);
|
||||
$temp->setPrefijo('(');
|
||||
$temp->setSufijo($tiposDeCambioSufix.')');
|
||||
$temp->setNumero($totales["total"]);
|
||||
$letra = $temp->letra();
|
||||
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
$pdf->SetY($setY+3);
|
||||
$pdf->SetX(25);
|
||||
$pdf->MultiCell(120,3,$letra,0);
|
||||
|
||||
$pdf->SetFont('verdana','',7);
|
||||
|
||||
//add cuenta
|
||||
if($data["NumCtaPago"])
|
||||
{
|
||||
$add = "Numero de Cuenta: ".$data["NumCtaPago"];
|
||||
}
|
||||
|
||||
$y = $pdf->GetY()+3;
|
||||
$pdf->SetY($y);
|
||||
$pdf->SetX($xstart);
|
||||
|
||||
$pdf->SetTextColor(255, 255, 255);
|
||||
$pdf->MultiCell(25,3,"Tipo De Pago",0);
|
||||
$pdf->SetY($y);
|
||||
$pdf->SetX(25);
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
$pdf->MultiCell(120,3,$this->Util()->DecodeVal($data["formaDePago"]."\nMetodo de Pago: ".$data["metodoDePago"].". ".$add),0);
|
||||
|
||||
|
||||
//block totales
|
||||
$pdf->SetFillColor(30,30,30);
|
||||
$pdf->Rect(155, $setY+2, 20, 24, 'DF');
|
||||
|
||||
//$pdf->SetFillColor(255);
|
||||
$pdf->SetTextColor(255, 255, 255);
|
||||
|
||||
$xstart = 155;
|
||||
$pdf->SetY($setY+2);
|
||||
$pdf->SetX($xstart);
|
||||
//$pdf->SetFillColor(192);
|
||||
$pdf->MultiCell(20,3,"Subtotal",0,"C",0);
|
||||
$pdf->SetY($pdf->GetY()-3);
|
||||
$pdf->SetX($xstart+20);
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
$pdf->MultiCell(31,3,"$".$this->Util()->CadenaOriginalPDFFormat($totales["subtotal"], true,false),0,"R",0);
|
||||
|
||||
if($totales["descuento"] != 0)
|
||||
{
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->SetTextColor(255, 255, 255);
|
||||
$pdf->MultiCell(20,3,"Descuento",0,"C");
|
||||
$pdf->SetY($pdf->GetY()-3);
|
||||
$pdf->SetX($xstart+20);
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
$pdf->MultiCell(31,3,"$".$this->Util()->CadenaOriginalPDFFormat($totales["descuento"], true,false),0,"R",0);
|
||||
}
|
||||
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->SetTextColor(255, 255, 255);
|
||||
$pdf->MultiCell(20,3,$totales["tasaIva"]."% IVA",0,"C");
|
||||
$pdf->SetY($pdf->GetY()-3);
|
||||
$pdf->SetX($xstart+20);
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
$pdf->MultiCell(31,3,"$".$this->Util()->CadenaOriginalPDFFormat($totales["iva"], true,false),0,"R",0);
|
||||
//print_r($totales);
|
||||
if($totales["retIva"] != 0)
|
||||
{
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->SetTextColor(255, 255, 255);
|
||||
$pdf->MultiCell(20,3,"Ret Iva",0,"C");
|
||||
$pdf->SetY($pdf->GetY()-3);
|
||||
$pdf->SetX($xstart+20);
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
$pdf->MultiCell(31,3,"$".$this->Util()->CadenaOriginalPDFFormat($totales["retIva"], true,false),0,"R",0);
|
||||
}
|
||||
|
||||
if($totales["retIsr"] != 0)
|
||||
{
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->SetTextColor(255, 255, 255);
|
||||
$pdf->MultiCell(20,3,"Ret Isr",0,"C");
|
||||
$pdf->SetY($pdf->GetY()-3);
|
||||
$pdf->SetX($xstart+20);
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
$pdf->MultiCell(31,3,"$".$this->Util()->CadenaOriginalPDFFormat($totales["retIsr"], true,false),0,"R",0);
|
||||
}
|
||||
|
||||
if($totales["porcentajeIEPS"] != 0)
|
||||
{
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->SetTextColor(255, 255, 255);
|
||||
$pdf->MultiCell(20,3,"IEPS",0,"C");
|
||||
$pdf->SetY($pdf->GetY()-3);
|
||||
$pdf->SetX($xstart+20);
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
$pdf->MultiCell(31,3,"$".$this->Util()->CadenaOriginalPDFFormat($totales["ieps"], true,false),0,"R",0);
|
||||
}
|
||||
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->SetTextColor(255, 255, 255);
|
||||
$pdf->MultiCell(20,3,"Total",0,"C");
|
||||
$pdf->SetY($pdf->GetY()-3);
|
||||
$pdf->SetX($xstart+20);
|
||||
$pdf->SetTextColor(0,0,0);
|
||||
$pdf->MultiCell(31,3,"$".$this->Util()->CadenaOriginalPDFFormat($totales["total2"], true,false),0,"R",0);
|
||||
|
||||
$setY = $pdf->GetY() + 15;
|
||||
$pdf->Line(10,$setY+1,200,$setY+1);
|
||||
$pdf->Line(10,$setY+2,200,$setY+2);
|
||||
|
||||
$pdf->SetY($pdf->GetY()+10);
|
||||
$pdf->SetX($xstart);
|
||||
$xstart = 2;
|
||||
$pdf->SetX($xstart);
|
||||
|
||||
$pdf->SetFillColor(255);
|
||||
|
||||
$y = $pdf->GetY() + 10;
|
||||
$pdf->SetY($y);
|
||||
|
||||
if($data["autorizo"])
|
||||
{
|
||||
$pdf->MultiCell(60,3,utf8_decode("AUTORIZO\n\n\n".urldecode($data["autorizo"])),0,"C",0);
|
||||
}
|
||||
$pdf->SetY($y);
|
||||
$pdf->SetX(70);
|
||||
if($data["recibio"])
|
||||
{
|
||||
$pdf->MultiCell(60,3,utf8_decode(urldecode("RECIBIO\n\n\n".$data["recibio"])),0,"C", 0);
|
||||
}
|
||||
$pdf->SetY($y);
|
||||
$pdf->SetX(140);
|
||||
if($data["vobo"])
|
||||
{
|
||||
$pdf->MultiCell(60,3,utf8_decode(urldecode("Vo. Bo\n\n\n".$data["vobo"])),0,"C", 0);
|
||||
}
|
||||
|
||||
if($data["autorizo"] || $data["recibio"] || $data["vobo"])
|
||||
{
|
||||
$pdf->CheckPageBreak(15);
|
||||
$pdf->SetY($pdf->GetY());
|
||||
$pdf->SetX($xstart);
|
||||
}
|
||||
|
||||
//$pdf->SetX(10);
|
||||
$y = $pdf->GetY();
|
||||
$pdf->SetY($y+5);
|
||||
if($data["reviso"])
|
||||
{
|
||||
$pdf->MultiCell(90,3,utf8_decode(urldecode("REVISO\n\n\n".$data["reviso"])),0,"C",0);
|
||||
}
|
||||
|
||||
$pdf->SetY($y+5);
|
||||
$pdf->SetX(100);
|
||||
|
||||
if($data["pago"])
|
||||
{
|
||||
$pdf->MultiCell(90,3,utf8_decode(urldecode("PAGO\n\n\n".$data["pago"])),0,"C",0);
|
||||
}
|
||||
|
||||
$xstart = 2;
|
||||
$pdf->SetY($pdf->GetY()+20);
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->MultiCell(207,3,utf8_decode("ESTE DOCUMENTO ES UNA REPRESENTACION IMPRESA DE UN CFDI"),0,"C");
|
||||
|
||||
$pdf->SetY($pdf->GetY());
|
||||
|
||||
$pdf->SetFont('verdana','',5);
|
||||
$pdf->SetFillColor(255,255,255);
|
||||
$pdf->SetTextColor(0, 0, 0);
|
||||
$pdf->MultiCell(207,3,"Sello Emisor: ".$data["sello"],0,"L",1);
|
||||
$pdf->MultiCell(207,3,"Sello SAT: ".$data["selloSAT"],0,"L",1);
|
||||
|
||||
$cadena["cadenaOriginalTimbre"] = utf8_decode(utf8_decode($data["timbreFiscal"]["original"]));
|
||||
$pdf->MultiCell(207,3,"Cadena Original Timbre Fiscal: \n".$cadena["cadenaOriginalTimbre"],0,"L",1);
|
||||
|
||||
if($cancelado){
|
||||
|
||||
$xstart = 10;
|
||||
$pdf->SetFont('verdana','',36);
|
||||
$pdf->SetTextColor(255,00,00);
|
||||
$pdf->SetY($setY-15);
|
||||
$pdf->SetX($xstart);
|
||||
$pdf->Cell(180,8,"C A N C E L A D O",0,0,"C");
|
||||
|
||||
}//if
|
||||
|
||||
$pdf->Output(DOC_ROOT.'/temp/factura_'.$data['sucursalId'].'.pdf', "F");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
212
classes/pac.class.php
Executable file
212
classes/pac.class.php
Executable file
@@ -0,0 +1,212 @@
|
||||
<?php
|
||||
|
||||
class Pac extends Util
|
||||
{
|
||||
function GetCfdiFromUUID($user, $pw, $rfc, $uuid, $idComprobante)
|
||||
{
|
||||
require_once(DOC_ROOT.'/libs/nusoap.php');
|
||||
$client = new nusoap_client('https://cfdiws.sedeb2b.com/EdiwinWS/services/CFDi?wsdl', true);
|
||||
$client->useHTTPPersistentConnection();
|
||||
|
||||
$params = array(
|
||||
'user' => $user,
|
||||
'password' => $pw,
|
||||
'rfc' => $rfc,
|
||||
'uuid' => $uuid
|
||||
);
|
||||
|
||||
//Demo
|
||||
$empresa = 15;
|
||||
$response = $client->call('getCfdiFromUUID', $params, 'http://cfdi.service.ediwinws.edicom.com/');
|
||||
print_r($response);
|
||||
if($response["faultcode"])
|
||||
{
|
||||
return "fault#".$response['detail']['fault']['text'];
|
||||
}
|
||||
$data = base64_decode($response["getCfdiFromUUIDReturn"]);
|
||||
|
||||
//Save new zip
|
||||
$file = DOC_ROOT."/xmlRecuperados/".$idComprobante.".zip";
|
||||
$path = DOC_ROOT."/xmlRecuperados/";
|
||||
$fh = fopen($file, 'w') or die("can't open file");
|
||||
$fh = fwrite($fh, $data);
|
||||
//fclose($fh);
|
||||
|
||||
|
||||
$this->Unzip($path, $file);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
function CancelaCfdi($user, $pw, $rfc, $uuid, $pfx, $pfxPassword)
|
||||
{
|
||||
//open zip and encode it
|
||||
$fh = fopen($pfx, 'r');
|
||||
$theData = fread($fh, filesize($pfx));
|
||||
$zipFileEncoded = base64_encode($theData);
|
||||
fclose($fh);
|
||||
|
||||
require_once(DOC_ROOT.'/libs/nusoap.php');
|
||||
$client = new nusoap_client('https://cfdiws.sedeb2b.com/EdiwinWS/services/CFDi?wsdl', true);
|
||||
$client->useHTTPPersistentConnection();
|
||||
|
||||
$params = array(
|
||||
'user' => $user,
|
||||
'password' => $pw,
|
||||
'rfc' => $rfc,
|
||||
'uuid' => $uuid,
|
||||
'pfx' => "$zipFileEncoded",
|
||||
'pfxPassword' => $pfxPassword
|
||||
);
|
||||
|
||||
$response = $client->call('cancelaCFDi', $params, 'http://cfdi.service.ediwinws.edicom.com/');
|
||||
|
||||
//errors
|
||||
if($response["faultcode"])
|
||||
{
|
||||
print_r($response);
|
||||
return "fault";
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
function GetCfdi($user, $pw, $zipFile, $path, $newFile, $empresa)
|
||||
{
|
||||
//open zip and encode it
|
||||
$fh = fopen($zipFile, 'r');
|
||||
$theData = fread($fh, filesize($zipFile));
|
||||
$zipFileEncoded = base64_encode($theData);
|
||||
fclose($fh);
|
||||
|
||||
require_once(DOC_ROOT.'/libs/nusoap.php');
|
||||
$client = new nusoap_client('https://cfdiws.sedeb2b.com/EdiwinWS/services/CFDi?wsdl', true);
|
||||
$client->useHTTPPersistentConnection();
|
||||
|
||||
$params = array(
|
||||
'user' => $user,
|
||||
'password' => $pw,
|
||||
'file' => "$zipFileEncoded"
|
||||
);
|
||||
|
||||
//Demo
|
||||
$empresa = 15;
|
||||
if($empresa == 150)
|
||||
{
|
||||
$response = $client->call('getCfdiTest', $params, 'http://cfdi.service.ediwinws.edicom.com/');
|
||||
|
||||
if($response["faultcode"])
|
||||
{
|
||||
return "fault#".$response['detail']['fault']['text'];
|
||||
}
|
||||
$data = base64_decode($response["getCfdiTestReturn"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
$response = $client->call('getCfdi', $params, 'http://cfdi.service.ediwinws.edicom.com/');
|
||||
if($response["faultcode"])
|
||||
{
|
||||
return "fault#".$response['detail']['fault']['text'];
|
||||
}
|
||||
$data = base64_decode($response["getCfdiReturn"]);
|
||||
|
||||
}
|
||||
|
||||
//Save new zip
|
||||
|
||||
$fh = fopen($newFile, 'w') or die("can't open file");
|
||||
$fh = fwrite($fh, $data);
|
||||
//fclose($fh);
|
||||
|
||||
$this->Unzip($path, $newFile);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
function GetTimbreCfdi($user, $pw, $zipFile, $path, $newFile, $empresa)
|
||||
{
|
||||
//open zip and encode it
|
||||
|
||||
$fh = fopen($zipFile, 'r');
|
||||
$theData = fread($fh, filesize($zipFile));
|
||||
$zipFileEncoded = base64_encode($theData);
|
||||
fclose($fh);
|
||||
|
||||
require_once(DOC_ROOT.'/libs/nusoap.php');
|
||||
$client = new nusoap_client('https://cfdiws.sedeb2b.com/EdiwinWS/services/CFDi?wsdl', true);
|
||||
$client->useHTTPPersistentConnection();
|
||||
|
||||
$params = array(
|
||||
'user' => $user,
|
||||
'password' => $pw,
|
||||
'file' => "$zipFileEncoded"
|
||||
);
|
||||
|
||||
$empresa = 15;
|
||||
if($empresa == 150)
|
||||
{
|
||||
$response = $client->call('getTimbreCfdiTest', $params, 'http://cfdi.service.ediwinws.edicom.com/');
|
||||
$data = base64_decode($response["getTimbreCfdiTestReturn"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$response = $client->call('getTimbreCfdi', $params, 'http://cfdi.service.ediwinws.edicom.com/');
|
||||
$data = base64_decode($response["getTimbreCfdiReturn"]);
|
||||
}
|
||||
|
||||
//save new zip
|
||||
$fh = fopen($newFile, 'w') or die("can't open file");
|
||||
$fh = fwrite($fh, $data);
|
||||
//fclose($fh);
|
||||
|
||||
$this->Unzip($path."/timbres/", $newFile);
|
||||
|
||||
return $newFile;
|
||||
}
|
||||
|
||||
function ParseTimbre($file)
|
||||
{
|
||||
$fh = fopen($file, 'r');
|
||||
$theData = fread($fh, filesize($file));
|
||||
//$theData = str_replace("<", "#", $theData);
|
||||
//$theData = str_replace(">", "#", $theData);
|
||||
//echo $theData;
|
||||
$pos = strrpos($theData, "<tfd:TimbreFiscalDigital");
|
||||
$theData = substr($theData, $pos);
|
||||
|
||||
$pos = strrpos($theData, "</cfdi:Complemento>");
|
||||
$theData = substr($theData, 0, $pos);
|
||||
|
||||
$xml = @simplexml_load_string($theData);
|
||||
|
||||
$data = array();
|
||||
foreach($xml->attributes() as $key => $attribute)
|
||||
{
|
||||
$data[$key] = (string)$attribute;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
function GenerateCadenaOriginalTimbre($data)
|
||||
{
|
||||
$cadenaOriginal = "||";
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["version"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["UUID"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["FechaTimbrado"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["selloCFD"]);
|
||||
$cadenaOriginal .= $this->Util()->CadenaOriginalVariableFormat($data["noCertificadoSAT"]);
|
||||
$cadenaOriginal .= "|";
|
||||
|
||||
$cadena = utf8_encode($cadenaOriginal);
|
||||
$data["original"] = $cadena;
|
||||
$data["sha1"] = sha1($cadena);
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
1887
classes/pedido.class.php
Executable file
1887
classes/pedido.class.php
Executable file
File diff suppressed because it is too large
Load Diff
132
classes/politica.class.php
Executable file
132
classes/politica.class.php
Executable file
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
class Politica extends Main
|
||||
{
|
||||
private $politicaId;
|
||||
private $tipo;
|
||||
private $porcentajeBonificacion;
|
||||
private $porcentajeEvaluacion;
|
||||
|
||||
public function setPoliticaId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->politicaId = $value;
|
||||
}
|
||||
|
||||
public function setPorcentajeBonificacion($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->porcentajeBonificacion = $value;
|
||||
}
|
||||
|
||||
public function setPorcentajeEvaluacion($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->porcentajeEvaluacion = $value;
|
||||
}
|
||||
|
||||
public function setTipo($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value);
|
||||
$this->tipo = $value;
|
||||
}
|
||||
|
||||
public function Enumerate()
|
||||
{
|
||||
$sql = "SELECT COUNT(*) FROM politicaBD WHERE baja = '0'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
$pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/bonificacion-devolucion");
|
||||
|
||||
$sqlAdd = "LIMIT ".$pages["start"].", ".$pages["items_per_page"];
|
||||
|
||||
$sql = "SELECT * FROM politicaBD WHERE baja = '0' ORDER BY idPoliticaBD ASC ".$sqlAdd;
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$data["items"] = $result;
|
||||
$data["pages"] = $pages;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function Save()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO politicaBD(
|
||||
tipo,
|
||||
porcentajeBonificacion,
|
||||
porcentajeEvaluacion)
|
||||
VALUES('".$this->tipo."',
|
||||
".$this->porcentajeBonificacion.",
|
||||
".$this->porcentajeEvaluacion.")";
|
||||
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->ExecuteQuery();
|
||||
|
||||
$this->Util()->setError(30068, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function EnumerateAll()
|
||||
{
|
||||
$sql = "SELECT * FROM politicaBD WHERE baja = '0' ORDER BY porcentajeEvaluacion DESC ";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function EnumerateBonificacion()
|
||||
{
|
||||
$sql = "SELECT * FROM politicaBD
|
||||
WHERE tipo LIKE 'Bonificacion'
|
||||
AND baja = '0'
|
||||
ORDER BY porcentajeEvaluacion DESC ";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function Delete()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM politicaBD WHERE idPoliticaBD = '".$this->politicaId."'";
|
||||
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->DeleteData();
|
||||
|
||||
$this->Util()->setError(30070, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function Baja(){
|
||||
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
|
||||
UPDATE politicaBD SET baja = '1'
|
||||
WHERE idPoliticaBD = '".$this->politicaId."'"
|
||||
);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData();
|
||||
|
||||
$this->Util()->setError(30070, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}//Baja
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
2126
classes/producto.class.php
Executable file
2126
classes/producto.class.php
Executable file
File diff suppressed because it is too large
Load Diff
146
classes/productoCategoria.class.php
Executable file
146
classes/productoCategoria.class.php
Executable file
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
class ProductoCategoria extends Main
|
||||
{
|
||||
private $prodCatId;
|
||||
private $nombre;
|
||||
|
||||
public function setProdCatId($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, "Categoría");
|
||||
$this->prodCatId = $value;
|
||||
}
|
||||
|
||||
public function setNombre($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Nombre');
|
||||
$this->nombre = $value;
|
||||
}
|
||||
|
||||
function Info(){
|
||||
|
||||
$sql = "SELECT
|
||||
*
|
||||
FROM
|
||||
productoCategoria
|
||||
WHERE
|
||||
prodCatId = '".$this->prodCatId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$row = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
function EnumerateAll()
|
||||
{
|
||||
$sql = "SELECT * FROM productoCategoria ORDER BY nombre ASC";
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$categorias = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $categorias;
|
||||
}
|
||||
|
||||
function Enumerate()
|
||||
{
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT COUNT(*) FROM productoCategoria");
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
$pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/admin-productos/categorias");
|
||||
|
||||
$sqlAdd = " LIMIT ".$pages["start"].", ".$pages["items_per_page"];
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT * FROM productoCategoria ORDER BY nombre ASC".$sqlAdd);
|
||||
$categorias = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$data["items"] = $categorias;
|
||||
$data["pages"] = $pages;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function Save(){
|
||||
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO `productoCategoria`
|
||||
(
|
||||
nombre
|
||||
)
|
||||
VALUES (
|
||||
'".utf8_decode($this->nombre)."'
|
||||
)";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->ExecuteQuery();
|
||||
|
||||
$this->Util()->setError(30021, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function Update(){
|
||||
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
echo $sql = "UPDATE
|
||||
`productoCategoria`
|
||||
SET
|
||||
nombre = '".utf8_decode($this->nombre)."'
|
||||
WHERE
|
||||
prodCatId = ".$this->prodCatId;
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->ExecuteQuery();
|
||||
|
||||
$this->Util()->setError(30022, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function Delete(){
|
||||
|
||||
$sql = "DELETE FROM
|
||||
productoCategoria
|
||||
WHERE
|
||||
prodCatId = '".$this->prodCatId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$sql = "DELETE FROM
|
||||
productoSubcategoria
|
||||
WHERE
|
||||
prodCatId = '".$this->prodCatId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$this->Util()->setError(30023, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function GetNameById(){
|
||||
|
||||
$sql = "SELECT
|
||||
nombre
|
||||
FROM
|
||||
productoCategoria
|
||||
WHERE
|
||||
prodCatId = '".$this->prodCatId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$name = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
}//ProductoCategoria
|
||||
|
||||
?>
|
||||
227
classes/productoSubcategoria.class.php
Executable file
227
classes/productoSubcategoria.class.php
Executable file
@@ -0,0 +1,227 @@
|
||||
<?php
|
||||
|
||||
class ProductoSubcategoria extends Main
|
||||
{
|
||||
private $prodSubcatId;
|
||||
private $prodCatId;
|
||||
private $nombre;
|
||||
|
||||
private $atributoId;
|
||||
|
||||
public function setProdSubcatId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->prodSubcatId = $value;
|
||||
}
|
||||
|
||||
public function setProdCatId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->prodCatId = $value;
|
||||
}
|
||||
|
||||
public function setNombre($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Nombre');
|
||||
$this->nombre = $value;
|
||||
}
|
||||
|
||||
public function setAtributoId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->atributoId = $value;
|
||||
}
|
||||
|
||||
public function Info()
|
||||
{
|
||||
$sql = 'SELECT
|
||||
*
|
||||
FROM
|
||||
productoSubcategoria
|
||||
WHERE
|
||||
prodSubcatId = "'.$this->prodSubcatId.'"';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$info = $this->Util()->DBSelect($_SESSION['empresaId'])->GetRow();
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
public function EnumerateAll()
|
||||
{
|
||||
$sql = 'SELECT
|
||||
*
|
||||
FROM
|
||||
productoSubcategoria
|
||||
WHERE
|
||||
prodCatId = "'.$this->prodCatId.'"
|
||||
ORDER BY
|
||||
nombre ASC';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function EnumAtributos()
|
||||
{
|
||||
$sql = "SELECT * FROM subcategoriaAtributo
|
||||
WHERE prodSubcatId = '".$this->prodSubcatId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$atributos = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $atributos;
|
||||
}
|
||||
|
||||
function Enumerate()
|
||||
{
|
||||
$sql = 'SELECT COUNT(*) FROM productoSubcategoria
|
||||
WHERE prodCatId = "'.$this->prodCatId.'"';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
$pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT.'/productos-subcategorias');
|
||||
|
||||
$sqlAdd = 'LIMIT '.$pages['start'].', '.$pages['items_per_page'];
|
||||
|
||||
$sql = 'SELECT * FROM productoSubcategoria
|
||||
WHERE prodCatId = "'.$this->prodCatId.'"
|
||||
ORDER BY nombre ASC '.$sqlAdd;
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
$data['items'] = $result;
|
||||
$data['pages'] = $pages;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function Save()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){ return false; }
|
||||
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery('
|
||||
INSERT INTO `productoSubcategoria` (
|
||||
prodCatId,
|
||||
nombre
|
||||
)
|
||||
VALUES (
|
||||
"'.$this->prodCatId.'",
|
||||
"'.utf8_decode($this->nombre).'"
|
||||
)'
|
||||
);
|
||||
$prodSubcatId = $this->Util()->DBSelect($_SESSION['empresaId'])->InsertData();
|
||||
|
||||
$this->Util()->setError(30036, 'complete');
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return $prodSubcatId;
|
||||
}
|
||||
|
||||
function Update()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){ return false; }
|
||||
|
||||
$sql = '
|
||||
UPDATE `productoSubcategoria` SET
|
||||
`nombre` = "'.utf8_decode($this->nombre).'"
|
||||
WHERE prodSubcatId = "'.$this->prodSubcatId.'"
|
||||
';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData();
|
||||
|
||||
$this->Util()->setError(30037, 'complete');
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function Delete()
|
||||
{
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery('
|
||||
DELETE FROM productoSubcategoria
|
||||
WHERE prodSubcatId = "'.$this->prodSubcatId.'"'
|
||||
);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->DeleteData();
|
||||
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery('
|
||||
DELETE FROM subcategoriaAtributo
|
||||
WHERE prodSubcatId = "'.$this->prodSubcatId.'"'
|
||||
);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->DeleteData();
|
||||
|
||||
$this->Util()->setError(30038, 'complete');
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function GetNameById()
|
||||
{
|
||||
$sql = 'SELECT nombre FROM productoSubcategoria
|
||||
WHERE prodSubcatId = "'.$this->prodSubcatId.'"';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$nombre = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
return $nombre;
|
||||
}
|
||||
|
||||
//ATRIBUTOS
|
||||
|
||||
function SaveAtributo()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery('
|
||||
INSERT INTO `subcategoriaAtributo` (
|
||||
prodCatId,
|
||||
prodSubcatId,
|
||||
atributoId
|
||||
)
|
||||
VALUES (
|
||||
"'.$this->prodCatId.'",
|
||||
"'.$this->prodSubcatId.'",
|
||||
"'.$this->atributoId.'"
|
||||
)'
|
||||
);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->InsertData();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function DeleteAtributos()
|
||||
{
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery('
|
||||
DELETE FROM subcategoriaAtributo
|
||||
WHERE prodSubcatId = "'.$this->prodSubcatId.'"'
|
||||
);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->DeleteData();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function ExistAtributo(){
|
||||
|
||||
$sql = 'SELECT subcatAtribId FROM subcategoriaAtributo
|
||||
WHERE atributoId = "'.$this->atributoId.'"
|
||||
AND prodSubcatId = "'.$this->prodSubcatId.'"';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$exist = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
return $exist;
|
||||
}
|
||||
|
||||
function GetAtributos(){
|
||||
|
||||
$sql = 'SELECT * FROM subcategoriaAtributo
|
||||
WHERE prodSubcatId = "'.$this->prodSubcatId.'"';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$atributos = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
return $atributos;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
763
classes/promocion.class.php
Executable file
763
classes/promocion.class.php
Executable file
@@ -0,0 +1,763 @@
|
||||
<?php
|
||||
|
||||
class Promocion extends Main
|
||||
{
|
||||
private $promocionId;
|
||||
private $prodCatId;
|
||||
private $prodSubcatId;
|
||||
private $proveedorId;
|
||||
private $productoId;
|
||||
private $prodItemId;
|
||||
private $nombre;
|
||||
private $tipo;
|
||||
private $aplica;
|
||||
private $aplicaTodos;
|
||||
private $totalCompra;
|
||||
private $tipoDesc;
|
||||
private $valorDesc;
|
||||
private $valorN;
|
||||
private $valorX;
|
||||
private $valorY;
|
||||
private $cantArtRegalo;
|
||||
private $sucursalId;
|
||||
private $vigencia;
|
||||
private $fechaIni;
|
||||
private $fechaFin;
|
||||
private $rebajado;
|
||||
private $status;
|
||||
|
||||
public function setPromocionId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->promocionId = $value;
|
||||
}
|
||||
|
||||
public function setProdCatId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->prodCatId = $value;
|
||||
}
|
||||
|
||||
public function setProdSubcatId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->prodSubcatId = $value;
|
||||
}
|
||||
|
||||
public function setProveedorId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->proveedorId = $value;
|
||||
}
|
||||
|
||||
public function setProductoId($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Código Producto a Regalar');
|
||||
$this->productoId = $value;
|
||||
}
|
||||
|
||||
public function setProdItemId($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Producto a Regalar');
|
||||
$this->prodItemId = $value;
|
||||
}
|
||||
|
||||
public function setNombre($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=250, $minChars = 1, 'Nombre');
|
||||
$this->nombre = $value;
|
||||
}
|
||||
|
||||
public function setTipo($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Tipo de Promoción');
|
||||
$this->tipo = $value;
|
||||
}
|
||||
|
||||
public function setAplica($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Aplica en');
|
||||
$this->aplica = $value;
|
||||
}
|
||||
|
||||
public function setAplicaTodos($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Aplicar Promoción a TODOS los productos?');
|
||||
$this->aplicaTodos = $value;
|
||||
}
|
||||
|
||||
public function setTotalCompra($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Total de la Compra');
|
||||
$this->totalCompra = $value;
|
||||
}
|
||||
|
||||
public function setTipoDesc($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Tipo de Descuento');
|
||||
$this->tipoDesc = $value;
|
||||
}
|
||||
|
||||
public function setValorDesc($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Valor del Descuento');
|
||||
$this->valorDesc = $value;
|
||||
}
|
||||
|
||||
public function setValorN($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Valor N');
|
||||
$this->valorN = $value;
|
||||
}
|
||||
|
||||
public function setValorX($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Valor X');
|
||||
$this->valorX = $value;
|
||||
}
|
||||
|
||||
public function setValorY($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Valor Y');
|
||||
$this->valorY = $value;
|
||||
}
|
||||
|
||||
public function setCantArtRegalo($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Cant. de Art. a Regalar');
|
||||
$this->cantArtRegalo = $value;
|
||||
}
|
||||
|
||||
public function setSucursalId($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Sucursal');
|
||||
$this->sucursalId = $value;
|
||||
}
|
||||
|
||||
public function setVigencia($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Vigencia');
|
||||
$this->vigencia = $value;
|
||||
}
|
||||
|
||||
public function setFechaIni($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Fecha Inicial');
|
||||
$this->fechaIni = $value;
|
||||
}
|
||||
|
||||
public function setFechaFin($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Fecha Final');
|
||||
$this->fechaFin = $value;
|
||||
}
|
||||
|
||||
public function setRebajado($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=1, $minChars = 1, 'Rebajado');
|
||||
$this->rebajado = $value;
|
||||
}
|
||||
|
||||
public function setStatus($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Status');
|
||||
$this->status = $value;
|
||||
}
|
||||
|
||||
function Info(){
|
||||
|
||||
$sql = "SELECT
|
||||
*
|
||||
FROM
|
||||
promocion
|
||||
WHERE
|
||||
promocionId = '".$this->promocionId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$row = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
function EnumerateAll()
|
||||
{
|
||||
$sql = "SELECT * FROM promocion ORDER BY nombre ASC";
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$promociones = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $promociones;
|
||||
}
|
||||
|
||||
function EnumBySucursal()
|
||||
{
|
||||
if($this->status)
|
||||
$sqlAdd = ' AND status = "'.$this->status.'"';
|
||||
|
||||
$sql = 'SELECT p.* FROM promocion AS p, promocionSuc AS s
|
||||
WHERE p.promocionId = s.promocionId
|
||||
AND s.sucursalId = "'.$this->sucursalId.'"
|
||||
'.$sqlAdd.'
|
||||
ORDER BY p.nombre ASC';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$promociones = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $promociones;
|
||||
}
|
||||
|
||||
|
||||
function Enumerate()
|
||||
{
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT COUNT(*) FROM promocion");
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
$pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/promociones");
|
||||
|
||||
$sqlAdd = " LIMIT ".$pages["start"].", ".$pages["items_per_page"];
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT * FROM promocion ORDER BY nombre ASC".$sqlAdd);
|
||||
$promociones = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$data["items"] = $promociones;
|
||||
$data["pages"] = $pages;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function SaveTemp(){
|
||||
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function Save(){
|
||||
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO `promocion`
|
||||
(
|
||||
nombre,
|
||||
tipo,
|
||||
aplica,
|
||||
aplicaTodos,
|
||||
totalCompra,
|
||||
tipoDesc,
|
||||
valorDesc,
|
||||
valorN,
|
||||
valorX,
|
||||
valorY,
|
||||
cantArtRegalo,
|
||||
productoId,
|
||||
vigencia,
|
||||
fechaIni,
|
||||
fechaFin,
|
||||
rebajado,
|
||||
status
|
||||
)
|
||||
VALUES (
|
||||
'".utf8_decode($this->nombre)."',
|
||||
'".$this->tipo."',
|
||||
'".$this->aplica."',
|
||||
'".$this->aplicaTodos."',
|
||||
'".$this->totalCompra."',
|
||||
'".$this->tipoDesc."',
|
||||
'".$this->valorDesc."',
|
||||
'".$this->valorN."',
|
||||
'".$this->valorX."',
|
||||
'".$this->valorY."',
|
||||
'".$this->cantArtRegalo."',
|
||||
'".$this->productoId."',
|
||||
'".$this->vigencia."',
|
||||
'".$this->fechaIni."',
|
||||
'".$this->fechaFin."',
|
||||
'".$this->rebajado."',
|
||||
'".$this->status."'
|
||||
)";
|
||||
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$promocionId = $this->Util()->DBSelect($_SESSION['empresaId'])->InsertData();
|
||||
|
||||
$this->Util()->setError(30060, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return $promocionId;
|
||||
|
||||
}
|
||||
|
||||
function Update(){
|
||||
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = "UPDATE
|
||||
`promocion`
|
||||
SET
|
||||
nombre = '".utf8_decode($this->nombre)."',
|
||||
tipo = '".$this->tipo."',
|
||||
aplica = '".$this->aplica."',
|
||||
aplicaTodos = '".$this->aplicaTodos."',
|
||||
totalCompra = '".$this->totalCompra."',
|
||||
tipoDesc = '".$this->tipoDesc."',
|
||||
valorDesc = '".$this->valorDesc."',
|
||||
valorN = '".$this->valorN."',
|
||||
valorX = '".$this->valorX."',
|
||||
valorY = '".$this->valorY."',
|
||||
cantArtRegalo = '".$this->cantArtRegalo."',
|
||||
productoId = '".$this->productoId."',
|
||||
vigencia = '".$this->vigencia."',
|
||||
fechaIni = '".$this->fechaIni."',
|
||||
fechaFin = '".$this->fechaFin."',
|
||||
rebajado = '".$this->rebajado."',
|
||||
status = '".$this->status."'
|
||||
WHERE
|
||||
promocionId = ".$this->promocionId;
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->ExecuteQuery();
|
||||
|
||||
$this->Util()->setError(30061, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function Delete(){
|
||||
|
||||
$sql = "DELETE FROM
|
||||
promocion
|
||||
WHERE
|
||||
promocionId = '".$this->promocionId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$sql = "DELETE FROM
|
||||
promocionSuc
|
||||
WHERE
|
||||
promocionId = '".$this->promocionId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$sql = "DELETE FROM
|
||||
promocionDepto
|
||||
WHERE
|
||||
promocionId = '".$this->promocionId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$sql = "DELETE FROM
|
||||
promocionLinea
|
||||
WHERE
|
||||
promocionId = '".$this->promocionId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$sql = "DELETE FROM
|
||||
promocionProd
|
||||
WHERE
|
||||
promocionId = '".$this->promocionId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$sql = "DELETE FROM
|
||||
promocionProv
|
||||
WHERE
|
||||
promocionId = '".$this->promocionId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$sql = "DELETE FROM
|
||||
promocionProdExc
|
||||
WHERE
|
||||
promocionId = '".$this->promocionId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$this->Util()->setError(30062, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function DeleteExtraInfo(){
|
||||
|
||||
$sql = "DELETE FROM
|
||||
promocionSuc
|
||||
WHERE
|
||||
promocionId = '".$this->promocionId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$sql = "DELETE FROM
|
||||
promocionDepto
|
||||
WHERE
|
||||
promocionId = '".$this->promocionId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$sql = "DELETE FROM
|
||||
promocionLinea
|
||||
WHERE
|
||||
promocionId = '".$this->promocionId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$sql = "DELETE FROM
|
||||
promocionProd
|
||||
WHERE
|
||||
promocionId = '".$this->promocionId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$sql = "DELETE FROM
|
||||
promocionProv
|
||||
WHERE
|
||||
promocionId = '".$this->promocionId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$this->Util()->setError(30062, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function SaveSucursal(){
|
||||
|
||||
$sql = 'INSERT INTO promocionSuc
|
||||
(
|
||||
promocionId,
|
||||
sucursalId
|
||||
)VALUES(
|
||||
"'.$this->promocionId.'",
|
||||
"'.$this->sucursalId.'"
|
||||
)';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->ExecuteQuery();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function SaveDepto(){
|
||||
|
||||
$sql = 'INSERT INTO promocionDepto
|
||||
(
|
||||
promocionId,
|
||||
prodCatId
|
||||
)VALUES(
|
||||
"'.$this->promocionId.'",
|
||||
"'.$this->prodCatId.'"
|
||||
)';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->ExecuteQuery();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function SaveLinea(){
|
||||
|
||||
$sql = 'INSERT INTO promocionLinea
|
||||
(
|
||||
promocionId,
|
||||
prodCatId,
|
||||
prodSubcatId
|
||||
)VALUES(
|
||||
"'.$this->promocionId.'",
|
||||
"'.$this->prodCatId.'",
|
||||
"'.$this->prodSubcatId.'"
|
||||
)';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->ExecuteQuery();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function SaveProveedor(){
|
||||
|
||||
$sql = 'INSERT INTO promocionProv
|
||||
(
|
||||
promocionId,
|
||||
proveedorId
|
||||
)VALUES(
|
||||
"'.$this->promocionId.'",
|
||||
"'.$this->proveedorId.'"
|
||||
)';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->ExecuteQuery();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function SaveProducto(){
|
||||
|
||||
$sql = 'INSERT INTO promocionProd
|
||||
(
|
||||
promocionId,
|
||||
productoId
|
||||
)VALUES(
|
||||
"'.$this->promocionId.'",
|
||||
"'.$this->productoId.'"
|
||||
)';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->ExecuteQuery();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function GetNameById(){
|
||||
|
||||
$sql = "SELECT
|
||||
nombre
|
||||
FROM
|
||||
promocion
|
||||
WHERE
|
||||
promocionId = '".$this->promocionId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$name = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
function ExistSucursal(){
|
||||
|
||||
$sql = "SELECT
|
||||
promSucId
|
||||
FROM
|
||||
promocionSuc
|
||||
WHERE
|
||||
promocionId = '".$this->promocionId."'
|
||||
AND
|
||||
sucursalId = '".$this->sucursalId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$exist = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $exist;
|
||||
}
|
||||
|
||||
function ExistDepto(){
|
||||
|
||||
$sql = "SELECT
|
||||
promDeptoId
|
||||
FROM
|
||||
promocionDepto
|
||||
WHERE
|
||||
promocionId = '".$this->promocionId."'
|
||||
AND
|
||||
prodCatId = '".$this->prodCatId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$exist = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $exist;
|
||||
}
|
||||
|
||||
function ExistLinea(){
|
||||
|
||||
$sql = "SELECT
|
||||
promLineaId
|
||||
FROM
|
||||
promocionLinea
|
||||
WHERE
|
||||
promocionId = '".$this->promocionId."'
|
||||
AND
|
||||
prodCatId = '".$this->prodCatId."'
|
||||
AND
|
||||
prodSubcatId = '".$this->prodSubcatId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$exist = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $exist;
|
||||
}
|
||||
|
||||
function ExistProveedor(){
|
||||
|
||||
$sql = "SELECT
|
||||
promProvId
|
||||
FROM
|
||||
promocionProv
|
||||
WHERE
|
||||
promocionId = '".$this->promocionId."'
|
||||
AND
|
||||
proveedorId = '".$this->proveedorId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$exist = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $exist;
|
||||
}
|
||||
|
||||
function ExistProducto(){
|
||||
|
||||
$sql = "SELECT
|
||||
promProdId
|
||||
FROM
|
||||
promocionProd
|
||||
WHERE
|
||||
promocionId = '".$this->promocionId."'
|
||||
AND
|
||||
productoId = '".$this->productoId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$exist = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $exist;
|
||||
}
|
||||
|
||||
function EnumPromosByProd($idProds)
|
||||
{
|
||||
$sql = 'SELECT * FROM promocionProd
|
||||
WHERE productoId IN ('.$idProds.')';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$promociones = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $promociones;
|
||||
}
|
||||
|
||||
function EnumPromosAplicaTodos()
|
||||
{
|
||||
$sql = 'SELECT promocionId FROM promocion
|
||||
WHERE aplicaTodos = "1"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$promociones = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $promociones;
|
||||
}
|
||||
|
||||
public function GetCantProdsVta(){
|
||||
|
||||
global $producto;
|
||||
|
||||
$conceptos = $_SESSION['conceptos'];
|
||||
|
||||
$cantidad = 0;
|
||||
foreach($conceptos as $res){
|
||||
$producto->setProdItemId($res['prodItemId']);
|
||||
$infP = $producto->GetInfoItemById();
|
||||
|
||||
if($infP['productoId'] == $this->productoId)
|
||||
$cantidad += $res['cantidad'];
|
||||
|
||||
}
|
||||
|
||||
return $cantidad;
|
||||
}
|
||||
|
||||
public function GetCantGralProdsVta(){
|
||||
|
||||
$conceptos = $_SESSION['conceptos'];
|
||||
|
||||
$cantidad = 0;
|
||||
foreach($conceptos as $res){
|
||||
|
||||
$this->setProductoId($res['productoId']);
|
||||
if(!$this->ExistProdInPromo())
|
||||
continue;
|
||||
|
||||
$cantidad += $res['cantidad'];
|
||||
}
|
||||
|
||||
return $cantidad;
|
||||
}
|
||||
|
||||
public function GetProdBuenFin(){
|
||||
|
||||
$conceptos = $_SESSION['conceptos'];
|
||||
|
||||
$precio = 0;
|
||||
$productoId = 0;
|
||||
foreach($conceptos as $res){
|
||||
|
||||
$this->setProductoId($res['productoId']);
|
||||
if(!$this->ExistProdInPromo())
|
||||
continue;
|
||||
|
||||
if($precio == 0){
|
||||
$precio = $res['precio'];
|
||||
$productoId = $res['productoId'];
|
||||
}elseif($res['precio'] < $precio){
|
||||
$precio = $res['precio'];
|
||||
$productoId = $res['productoId'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $productoId;
|
||||
}
|
||||
|
||||
public function GetTotalByProdVta(){
|
||||
|
||||
global $producto;
|
||||
|
||||
$conceptos = $_SESSION['conceptos'];
|
||||
|
||||
$total = 0;
|
||||
foreach($conceptos as $res){
|
||||
$producto->setProdItemId($res['prodItemId']);
|
||||
$infP = $producto->GetInfoItemById();
|
||||
|
||||
if($infP['productoId'] == $this->productoId)
|
||||
$total += $res['total'];
|
||||
|
||||
}
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
function ExistProdInPromo()
|
||||
{
|
||||
$infP = $this->Info();
|
||||
|
||||
if($infP['aplicaTodos'] == 1)
|
||||
return 1;
|
||||
|
||||
$sql = 'SELECT promProdId FROM promocionProd
|
||||
WHERE productoId = "'.$this->productoId.'"
|
||||
AND promocionId = "'.$this->promocionId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$promProdId = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $promProdId;
|
||||
}
|
||||
|
||||
function ExcProdInPromo()
|
||||
{
|
||||
//Checamos si el producto esta excluido
|
||||
|
||||
$sql = 'SELECT promocionId FROM promocionProdExc
|
||||
WHERE productoId = "'.$this->productoId.'"
|
||||
AND promocionId = "'.$this->promocionId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$promocionId = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $promocionId;
|
||||
}
|
||||
|
||||
function GetBuenFinId()
|
||||
{
|
||||
$sql = 'SELECT promocionId FROM promocion
|
||||
WHERE tipo = "BuenFin"
|
||||
LIMIT 1';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$promocionId = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $promocionId;
|
||||
}
|
||||
|
||||
function GetBuenFinIdActivo()
|
||||
{
|
||||
$sql = 'SELECT promocionId FROM promocion
|
||||
WHERE tipo = "BuenFin"
|
||||
AND status = "Activo"
|
||||
LIMIT 1';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$promocionId = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $promocionId;
|
||||
}
|
||||
|
||||
}//Promocion
|
||||
|
||||
?>
|
||||
840
classes/proveedor.class.php
Executable file
840
classes/proveedor.class.php
Executable file
@@ -0,0 +1,840 @@
|
||||
<?php
|
||||
|
||||
class Proveedor extends Main
|
||||
{
|
||||
private $proveedorId;
|
||||
private $proveedorId2;
|
||||
private $productoId;
|
||||
private $prodProvId;
|
||||
private $rfc;
|
||||
private $nombre;
|
||||
private $userId;
|
||||
private $rfcId;
|
||||
private $precio;
|
||||
|
||||
private $calle;
|
||||
private $noInt;
|
||||
private $noExt;
|
||||
private $referencia;
|
||||
private $colonia;
|
||||
private $localidad;
|
||||
private $municipio;
|
||||
private $ciudad;
|
||||
private $estado;
|
||||
private $codigoPostal;
|
||||
private $pais;
|
||||
|
||||
private $nombreVtas;
|
||||
private $telefonoVtas;
|
||||
private $celularVtas;
|
||||
private $emailVtas;
|
||||
|
||||
private $nombrePagos;
|
||||
private $telefonoPagos;
|
||||
private $celularPagos;
|
||||
private $emailPagos;
|
||||
|
||||
private $nombreEnt;
|
||||
private $telefonoEnt;
|
||||
private $celularEnt;
|
||||
private $emailEnt;
|
||||
|
||||
private $banco;
|
||||
private $noCuenta;
|
||||
private $clabe;
|
||||
private $almacen;
|
||||
private $plazo;
|
||||
|
||||
private $publicidad;
|
||||
private $flete;
|
||||
private $desarrollo;
|
||||
private $especial;
|
||||
|
||||
private $compraFirme;
|
||||
private $saldo;
|
||||
private $baja;
|
||||
|
||||
private $pagado;
|
||||
private $noProv;
|
||||
|
||||
private $calificacion;
|
||||
private $comentario;
|
||||
private $pedidoId;
|
||||
|
||||
public function setCompraFirme($value)
|
||||
{
|
||||
$this->compraFirme = $value;
|
||||
}
|
||||
|
||||
public function setPublicidad($value)
|
||||
{
|
||||
$this->publicidad = $value;
|
||||
}
|
||||
|
||||
public function setFlete($value)
|
||||
{
|
||||
$this->flete = $value;
|
||||
}
|
||||
|
||||
public function setDesarrollo($value)
|
||||
{
|
||||
$this->desarrollo = $value;
|
||||
}
|
||||
|
||||
public function setEspecial($value)
|
||||
{
|
||||
$this->especial = $value;
|
||||
}
|
||||
|
||||
public function setProveedorId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->proveedorId = $value;
|
||||
}
|
||||
|
||||
public function setProveedorId2($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->proveedorId2 = $value;
|
||||
}
|
||||
|
||||
public function setProductoId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->productoId = $value;
|
||||
}
|
||||
|
||||
public function setProdProvId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->prodProvId = $value;
|
||||
}
|
||||
|
||||
public function setPrecio($value)
|
||||
{
|
||||
$this->precio = $value;
|
||||
}
|
||||
|
||||
public function setRfc($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 1, 'RFC');
|
||||
$this->rfc = $value;
|
||||
}
|
||||
|
||||
public function setNombre($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 1, 'Nombre Completo o Razón Social');
|
||||
$this->nombre = $value;
|
||||
}
|
||||
|
||||
public function setUserId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->userId = $value;
|
||||
}
|
||||
|
||||
//CONTACTO VENTAS
|
||||
|
||||
public function setNombreVtas($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'Nombre');
|
||||
$this->nombreVtas = $value;
|
||||
}
|
||||
|
||||
public function setTelefonoVtas($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'Teléfono');
|
||||
$this->telefonoVtas = $value;
|
||||
}
|
||||
|
||||
public function setCelularVtas($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'Celular');
|
||||
$this->celularVtas = $value;
|
||||
}
|
||||
|
||||
public function setEmailVtas($value)
|
||||
{
|
||||
if(trim($value) != '')
|
||||
$this->Util()->ValidateMail($value, 'Correo Electrónico Ventas');
|
||||
$this->emailVtas = $value;
|
||||
}
|
||||
|
||||
//CONTACTO PAGOS
|
||||
|
||||
public function setNombrePagos($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'Nombre');
|
||||
$this->nombrePagos = $value;
|
||||
}
|
||||
|
||||
public function setTelefonoPagos($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'Teléfono');
|
||||
$this->telefonoPagos = $value;
|
||||
}
|
||||
|
||||
public function setCelularPagos($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'Celular');
|
||||
$this->celularPagos = $value;
|
||||
}
|
||||
|
||||
public function setEmailPagos($value)
|
||||
{
|
||||
if(trim($value) != '')
|
||||
$this->Util()->ValidateMail($value, 'Correo Electrónico Cobranza');
|
||||
$this->emailPagos = $value;
|
||||
}
|
||||
|
||||
//CONTACTO ENTREGAS
|
||||
|
||||
public function setNombreEnt($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'Nombre');
|
||||
$this->nombreEnt = $value;
|
||||
}
|
||||
|
||||
public function setTelefonoEnt($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'Teléfono');
|
||||
$this->telefonoEnt = $value;
|
||||
}
|
||||
|
||||
public function setCelularEnt($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'Celular');
|
||||
$this->celularEnt = $value;
|
||||
}
|
||||
|
||||
public function setEmailEnt($value)
|
||||
{
|
||||
if(trim($value) != '')
|
||||
$this->Util()->ValidateMail($value, 'Correo Electrónico Entregas');
|
||||
$this->emailEnt = $value;
|
||||
}
|
||||
|
||||
//DIRECCION FISCAL
|
||||
|
||||
public function setCalle($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'Dirección');
|
||||
$this->calle = $value;
|
||||
}
|
||||
|
||||
public function setNoInt($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'No. Interior');
|
||||
$this->noInt = $value;
|
||||
}
|
||||
|
||||
public function setNoExt($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'No. Exterior');
|
||||
$this->noExt = $value;
|
||||
}
|
||||
|
||||
public function setLocalidad($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'Localidad');
|
||||
$this->localidad = $value;
|
||||
}
|
||||
|
||||
public function setColonia($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'Colonia');
|
||||
$this->colonia = $value;
|
||||
}
|
||||
|
||||
public function setReferencia($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'Referencia');
|
||||
$this->referencia = $value;
|
||||
}
|
||||
|
||||
public function setMunicipio($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'Municipio');
|
||||
$this->municipio = $value;
|
||||
}
|
||||
|
||||
public function setCiudad($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'Ciudad');
|
||||
$this->ciudad = $value;
|
||||
}
|
||||
|
||||
public function setEstado($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'Estado');
|
||||
$this->estado = $value;
|
||||
}
|
||||
|
||||
public function setPais($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'Pais');
|
||||
$this->pais = $value;
|
||||
}
|
||||
|
||||
public function setCodigoPostal($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'Codigo Postal');
|
||||
$this->codigoPostal = $value;
|
||||
}
|
||||
|
||||
public function setEmail($value)
|
||||
{
|
||||
if(trim($value) != '')
|
||||
$this->Util()->ValidateMail($value, 'Correo Electrónico');
|
||||
$this->email = $value;
|
||||
}
|
||||
|
||||
public function setTelefono($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'Teléfono');
|
||||
$this->telefono = $value;
|
||||
}
|
||||
|
||||
//DATOS BANCARIOS
|
||||
|
||||
public function setBanco($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'Banco');
|
||||
$this->banco = $value;
|
||||
}
|
||||
|
||||
public function setNoCuenta($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'No. de Cuenta');
|
||||
$this->noCuenta = $value;
|
||||
}
|
||||
|
||||
public function setClabe($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'CLABE');
|
||||
$this->clabe = $value;
|
||||
}
|
||||
|
||||
public function setAlmacen($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'Almacen');
|
||||
$this->almacen = $value;
|
||||
}
|
||||
|
||||
public function setPlazo($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'Plazo');
|
||||
$this->plazo = $value;
|
||||
}
|
||||
|
||||
public function setSaldo($value)
|
||||
{
|
||||
$this->Util()->ValidateFloat($value);
|
||||
$this->saldo = $value;
|
||||
}
|
||||
|
||||
//OTHERS
|
||||
|
||||
public function setPagado($value)
|
||||
{
|
||||
$this->pagado = $value;
|
||||
}
|
||||
|
||||
public function setNoProv($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->noProv = $value;
|
||||
}
|
||||
|
||||
public function setCalificacion($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 1, 'Calificación');
|
||||
$this->calificacion = $value;
|
||||
}
|
||||
|
||||
public function setComentario($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'Comentario');
|
||||
$this->comentario = $value;
|
||||
}
|
||||
|
||||
public function setPedidoId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->pedidoId = $value;
|
||||
}
|
||||
|
||||
function Info()
|
||||
{
|
||||
$sql = "SELECT * FROM proveedor WHERE proveedorId ='".$this->proveedorId."'";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$cliente = $this->Util()->DBSelect($_SESSION['empresaId'])->GetRow();
|
||||
|
||||
return $cliente;
|
||||
}
|
||||
|
||||
function EnumerateAll()
|
||||
{
|
||||
$sql = 'SELECT * FROM proveedor WHERE baja = "0" ORDER BY nombre ASC';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$proveedores = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
return $proveedores;
|
||||
}
|
||||
|
||||
function Enumerate()
|
||||
{
|
||||
$sql = 'SELECT COUNT(*) FROM proveedor WHERE baja = "0"';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
$pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT.'/proveedores');
|
||||
|
||||
$sqlAdd = ' LIMIT '.$pages['start'].', '.$pages['items_per_page'];
|
||||
|
||||
$sql = 'SELECT * FROM proveedor WHERE baja = "0" ORDER BY nombre ASC'.$sqlAdd;
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$proveedores = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
$data['items'] = $proveedores;
|
||||
$data['pages'] = $pages;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function EnumCtaPagarSaldos()
|
||||
{
|
||||
$sql = 'SELECT COUNT(*) FROM proveedor WHERE baja = "0"';
|
||||
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
$pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT.'/cuentas-pagar-saldos');
|
||||
|
||||
$sqlAdd = ' LIMIT '.$pages['start'].', '.$pages['items_per_page'];
|
||||
|
||||
$sql = 'SELECT * FROM proveedor WHERE baja = "0" ORDER BY nombre ASC'.$sqlAdd;
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$proveedores = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
$data['items'] = $proveedores;
|
||||
$data['pages'] = $pages;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function Save()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
|
||||
INSERT INTO `proveedor` (
|
||||
noProv,
|
||||
rfc,
|
||||
nombre,
|
||||
|
||||
nombreVtas,
|
||||
telefonoVtas,
|
||||
celularVtas,
|
||||
emailVtas,
|
||||
|
||||
nombrePagos,
|
||||
telefonoPagos,
|
||||
celularPagos,
|
||||
emailPagos,
|
||||
|
||||
nombreEnt,
|
||||
telefonoEnt,
|
||||
celularEnt,
|
||||
emailEnt,
|
||||
|
||||
calle,
|
||||
noInt,
|
||||
noExt,
|
||||
referencia,
|
||||
colonia,
|
||||
localidad,
|
||||
municipio,
|
||||
estado,
|
||||
pais,
|
||||
codigoPostal,
|
||||
|
||||
banco,
|
||||
noCuenta,
|
||||
clabe,
|
||||
almacen,
|
||||
plazo,
|
||||
bonificacion,
|
||||
|
||||
publicidad,
|
||||
flete,
|
||||
desarrollo,
|
||||
especial,
|
||||
compraFirme
|
||||
)
|
||||
VALUES (
|
||||
'".$this->noProv."',
|
||||
'".utf8_decode($this->rfc)."',
|
||||
'".utf8_decode($this->nombre)."',
|
||||
|
||||
'".utf8_decode($this->nombreVtas)."',
|
||||
'".utf8_decode($this->telefonoVtas)."',
|
||||
'".utf8_decode($this->celularVtas)."',
|
||||
'".$this->emailVtas."',
|
||||
|
||||
'".utf8_decode($this->nombrePagos)."',
|
||||
'".utf8_decode($this->telefonoPagos)."',
|
||||
'".utf8_decode($this->celularPagos)."',
|
||||
'".$this->emailPagos."',
|
||||
|
||||
'".utf8_decode($this->nombreEnt)."',
|
||||
'".utf8_decode($this->telefonoEnt)."',
|
||||
'".utf8_decode($this->celularEnt)."',
|
||||
'".$this->emailEnt."',
|
||||
|
||||
'".utf8_decode($this->calle)."',
|
||||
'".utf8_decode($this->noInt)."',
|
||||
'".utf8_decode($this->noExt)."',
|
||||
'".utf8_decode($this->referencia)."',
|
||||
'".utf8_decode($this->colonia)."',
|
||||
'".utf8_decode($this->localidad)."',
|
||||
'".utf8_decode($this->municipio)."',
|
||||
'".utf8_decode($this->estado)."',
|
||||
'".utf8_decode($this->pais)."',
|
||||
'".utf8_decode($this->codigoPostal)."',
|
||||
|
||||
'".utf8_decode($this->banco)."',
|
||||
'".utf8_decode($this->noCuenta)."',
|
||||
'".utf8_decode($this->clabe)."',
|
||||
'".utf8_decode($this->almacen)."',
|
||||
'".utf8_decode($this->plazo)."',
|
||||
'".utf8_decode($this->bonificacion)."',
|
||||
|
||||
'".$this->publicidad."',
|
||||
'".$this->flete."',
|
||||
'".$this->desarrollo."',
|
||||
'".$this->especial."',
|
||||
'".$this->compraFirme."'
|
||||
)"
|
||||
);
|
||||
$proveedorId = $this->Util()->DBSelect($_SESSION['empresaId'])->InsertData();
|
||||
|
||||
$this->Util()->setError(20034, 'complete', '');
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function Update()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
|
||||
UPDATE proveedor SET
|
||||
noProv ='".utf8_decode($this->noProv)."',
|
||||
rfc ='".utf8_decode($this->rfc)."',
|
||||
nombre = '".utf8_decode($this->nombre)."',
|
||||
|
||||
nombreVtas = '".utf8_decode($this->nombreVtas)."',
|
||||
telefonoVtas = '".utf8_decode($this->telefonoVtas)."',
|
||||
celularVtas = '".utf8_decode($this->celularVtas)."',
|
||||
emailVtas = '".utf8_decode($this->emailVtas)."',
|
||||
|
||||
nombrePagos = '".utf8_decode($this->nombrePagos)."',
|
||||
telefonoPagos = '".utf8_decode($this->telefonoPagos)."',
|
||||
celularPagos = '".utf8_decode($this->celularPagos)."',
|
||||
emailPagos = '".utf8_decode($this->emailPagos)."',
|
||||
|
||||
nombreEnt = '".utf8_decode($this->nombreEnt)."',
|
||||
telefonoEnt = '".utf8_decode($this->telefonoEnt)."',
|
||||
celularEnt = '".utf8_decode($this->celularEnt)."',
|
||||
emailEnt = '".utf8_decode($this->emailEnt)."',
|
||||
|
||||
calle = '".utf8_decode($this->calle)."',
|
||||
noInt = '".utf8_decode($this->noInt)."',
|
||||
noExt = '".utf8_decode($this->noExt)."',
|
||||
referencia = '".utf8_decode($this->referencia)."',
|
||||
colonia = '".utf8_decode($this->colonia)."',
|
||||
localidad = '".utf8_decode($this->localidad)."',
|
||||
municipio = '".utf8_decode($this->municipio)."',
|
||||
estado = '".utf8_decode($this->estado)."',
|
||||
pais = '".utf8_decode($this->pais)."',
|
||||
codigoPostal = '".utf8_decode($this->codigoPostal)."',
|
||||
|
||||
banco = '".utf8_decode($this->banco)."',
|
||||
noCuenta = '".utf8_decode($this->noCuenta)."',
|
||||
clabe = '".utf8_decode($this->clabe)."',
|
||||
almacen = '".utf8_decode($this->almacen)."',
|
||||
bonificacion = '".utf8_decode($this->bonificacion)."',
|
||||
plazo = '".utf8_decode($this->plazo)."',
|
||||
|
||||
publicidad = '".$this->publicidad."',
|
||||
flete = '".$this->flete."',
|
||||
desarrollo = '".$this->desarrollo."',
|
||||
especial = '".$this->especial."',
|
||||
compraFirme = '".$this->compraFirme."'
|
||||
|
||||
WHERE proveedorId = '".$this->proveedorId."'"
|
||||
);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData();
|
||||
|
||||
$this->Util()->setError(20036, 'complete', '');
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function Delete()
|
||||
{
|
||||
$sql = "DELETE FROM proveedor WHERE proveedorId = '".$this->proveedorId."'";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->DeleteData();
|
||||
|
||||
$this->Util()->setError(20035, 'complete', '');
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function Baja(){
|
||||
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
|
||||
UPDATE proveedor SET
|
||||
baja = '1'
|
||||
WHERE
|
||||
proveedorId = '".$this->proveedorId."'"
|
||||
);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData();
|
||||
|
||||
$this->Util()->setError(20035, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}//Baja
|
||||
|
||||
function GetNameById()
|
||||
{
|
||||
$sql = "SELECT nombre FROM proveedor WHERE proveedorId ='".$this->proveedorId."'";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$nombre = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
return $nombre;
|
||||
}
|
||||
|
||||
function GetNoProv()
|
||||
{
|
||||
$sql = "SELECT noProv FROM proveedor WHERE proveedorId ='".$this->proveedorId."'";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$noProv = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
return $noProv;
|
||||
}
|
||||
|
||||
function GetCompraFirme()
|
||||
{
|
||||
$sql = "SELECT compraFirme FROM proveedor WHERE proveedorId ='".$this->proveedorId."'";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$compraFirme = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
return $compraFirme;
|
||||
}
|
||||
|
||||
function Search()
|
||||
{
|
||||
if($this->noProv)
|
||||
$sqlAdd = ' AND noProv = "'.$this->noProv.'"';
|
||||
|
||||
$sql = "SELECT
|
||||
*
|
||||
FROM
|
||||
proveedor
|
||||
WHERE
|
||||
baja = '0'
|
||||
AND
|
||||
(nombre LIKE '%".$this->nombre."%')
|
||||
".$sqlAdd."
|
||||
ORDER BY
|
||||
nombre ASC
|
||||
LIMIT
|
||||
20";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$proveedores = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
$data['items'] = $proveedores;
|
||||
$data['pages'] = array();
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function Suggest()
|
||||
{
|
||||
$sql = "SELECT
|
||||
*
|
||||
FROM
|
||||
proveedor
|
||||
WHERE
|
||||
baja = '0'
|
||||
AND
|
||||
nombre LIKE '%".$this->nombre."%'
|
||||
OR rfc LIKE '%".$this->nombre."%'
|
||||
OR proveedorId = '".$this->nombre."'
|
||||
ORDER BY
|
||||
nombre ASC
|
||||
LIMIT
|
||||
10";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$proveedores = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
return $proveedores;
|
||||
}
|
||||
|
||||
function GetProveedores($id)
|
||||
{
|
||||
$sql = "SELECT *
|
||||
FROM productoProveedor
|
||||
LEFT JOIN proveedor ON productoProveedor.proveedorId = proveedor.proveedorId
|
||||
WHERE proveedor.baja = '0'
|
||||
AND productoProveedor.productoId = '".$id."'
|
||||
ORDER BY proveedor.nombre ";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function GetClientesByEmpresa()
|
||||
{
|
||||
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("SELECT * FROM cliente WHERE empresaId ='".$this->getEmpresaId()."'");
|
||||
$empresaClientes = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
return $empresaClientes;
|
||||
}
|
||||
|
||||
function GetBonificacionById($value)
|
||||
{
|
||||
$sql = "SELECT bonificacion FROM proveedor WHERE proveedorId ='".$this->proveedorId."'";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$nombre = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
return $nombre;
|
||||
}
|
||||
|
||||
function GetDescuentos()
|
||||
{
|
||||
$sql = "SELECT publicidad, flete, desarrollo, especial FROM proveedor WHERE proveedorId ='".$this->proveedorId."'";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$descuentos = $this->Util()->DBSelect($_SESSION['empresaId'])->GetRow();
|
||||
|
||||
return $descuentos;
|
||||
}
|
||||
|
||||
function GetLastProveedorId()
|
||||
{
|
||||
$sql = "SELECT MAX(proveedorId) FROM proveedor";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$proveedorId = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
$proveedorId += 1;
|
||||
|
||||
return $proveedorId;
|
||||
}
|
||||
|
||||
function GetLastNoProv()
|
||||
{
|
||||
$sql = "SELECT MAX(noProv) FROM proveedor";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$proveedorId = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
$proveedorId += 1;
|
||||
|
||||
return $proveedorId;
|
||||
}
|
||||
|
||||
function UpdateSaldoCtaPagar()
|
||||
{
|
||||
$sql = "UPDATE proveedor SET saldoCtaPagar = '".$this->saldo."'
|
||||
WHERE proveedorId = '".$this->proveedorId."'";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData();
|
||||
|
||||
$this->Util()->setError(20105, 'complete', '');
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function ExistProveedorId(){
|
||||
|
||||
$sql = "SELECT COUNT(*) FROM proveedor WHERE proveedorId = '".$this->proveedorId."'";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$exist = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
return $exist;
|
||||
}
|
||||
|
||||
function ExistNoProv(){
|
||||
|
||||
$sql = "SELECT COUNT(*) FROM proveedor WHERE noProv = '".$this->noProv."'";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$exist = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
return $exist;
|
||||
}
|
||||
|
||||
function SearchSaldos($saldoIni)
|
||||
{
|
||||
$sqlFilter = '';
|
||||
if($this->proveedorId)
|
||||
$sqlFilter .= ' AND proveedorId = "'.$this->proveedorId.'"';
|
||||
|
||||
if($saldoIni != ''){
|
||||
if($saldoIni == 0)
|
||||
$sqlFilter .= ' AND saldoCtaPagar = 0';
|
||||
elseif($saldoIni == 1)
|
||||
$sqlFilter .= ' AND saldoCtaPagar > 0';
|
||||
}
|
||||
|
||||
$sql = 'SELECT * FROM proveedor
|
||||
WHERE baja = "0" '.$sqlFilter.'
|
||||
ORDER BY nombre ASC';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$proveedores = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
return $proveedores;
|
||||
}
|
||||
|
||||
function UpdatePagado(){
|
||||
|
||||
$sql = "UPDATE proveedor SET pagadoCtaPagar = '".$this->pagado."'
|
||||
WHERE proveedorId = '".$this->proveedorId."'";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData();
|
||||
|
||||
}
|
||||
|
||||
function UpdateCalifPedido(){
|
||||
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$sql = "UPDATE pedido SET calificacion = '".$this->calificacion."',
|
||||
comentCalif = '".utf8_decode($this->comentario)."'
|
||||
WHERE pedidoId = '".$this->pedidoId."'";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData();
|
||||
|
||||
$this->Util()->setError(20127, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}//Baja
|
||||
|
||||
}//Proveedor
|
||||
|
||||
?>
|
||||
1451
classes/reportes.class.php
Executable file
1451
classes/reportes.class.php
Executable file
File diff suppressed because it is too large
Load Diff
229
classes/rfc.class.php
Executable file
229
classes/rfc.class.php
Executable file
@@ -0,0 +1,229 @@
|
||||
<?php
|
||||
|
||||
class Rfc extends Main
|
||||
{
|
||||
private $rfcId;
|
||||
private $empresaId;
|
||||
private $rfc;
|
||||
private $razonSocial;
|
||||
private $calle;
|
||||
private $noInt;
|
||||
private $noExt;
|
||||
private $referencia;
|
||||
private $colonia;
|
||||
private $localidad;
|
||||
private $municipio;
|
||||
private $ciudad;
|
||||
private $estado;
|
||||
private $pais;
|
||||
private $codigoPostal;
|
||||
private $regimenFiscal;
|
||||
|
||||
private $diasDevolucion;
|
||||
private $bonificacion;
|
||||
private $devolucion;
|
||||
|
||||
public function setRfcId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->rfcId = $value;
|
||||
}
|
||||
|
||||
public function setEmpresaId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->empresaId = $value;
|
||||
}
|
||||
|
||||
public function setRfc($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=13, $minChars = 12, 'RFC');
|
||||
$this->rfc = $value;
|
||||
}
|
||||
|
||||
public function setRazonSocial($value, $checkIfExists = 0)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=300, $minChars = 3, 'Razón Social');
|
||||
$this->razonSocial = $value;
|
||||
}
|
||||
|
||||
public function setCalle($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=200, $minChars = 0, 'Dirección');
|
||||
$this->calle = $value;
|
||||
}
|
||||
|
||||
public function setNoInt($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'No. Interior');
|
||||
$this->noInt = $value;
|
||||
}
|
||||
|
||||
public function setNoExt($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'No. Exterior');
|
||||
$this->noExt = $value;
|
||||
}
|
||||
|
||||
public function setLocalidad($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'Localidad');
|
||||
$this->localidad = $value;
|
||||
}
|
||||
|
||||
public function setColonia($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'Colonia');
|
||||
$this->colonia = $value;
|
||||
}
|
||||
|
||||
public function setReferencia($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'Referencia');
|
||||
$this->referencia = $value;
|
||||
}
|
||||
|
||||
public function setMunicipio($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'Municipio');
|
||||
$this->municipio = $value;
|
||||
}
|
||||
|
||||
public function setCiudad($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'Ciudad');
|
||||
$this->ciudad = $value;
|
||||
}
|
||||
|
||||
public function setEstado($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'Estado');
|
||||
$this->estado = $value;
|
||||
}
|
||||
|
||||
public function setPais($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'Pais');
|
||||
$this->pais = $value;
|
||||
}
|
||||
|
||||
public function setCodigoPostal($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'Código Postal');
|
||||
$this->codigoPostal = $value;
|
||||
}
|
||||
|
||||
public function setRegimenFiscal($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 1, 'Regimen Fiscal');
|
||||
$this->regimenFiscal = $value;
|
||||
}
|
||||
|
||||
public function setDiasDevolucion($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->diasDevolucion = $value;
|
||||
}
|
||||
|
||||
public function setBonificacion($value)
|
||||
{
|
||||
$this->bonificacion = $value;
|
||||
}
|
||||
|
||||
public function setDevolucion($value)
|
||||
{
|
||||
$this->devolucion = $value;
|
||||
}
|
||||
|
||||
function Info()
|
||||
{
|
||||
$sql = "SELECT * FROM rfc WHERE rfcId ='".$this->rfcId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$rfc = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $rfc;
|
||||
}
|
||||
|
||||
function Update()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
|
||||
UPDATE `rfc` SET
|
||||
`rfc` = '".$this->rfc."',
|
||||
`razonSocial` = '".$this->razonSocial."',
|
||||
`calle` = '".$this->calle."',
|
||||
`noInt` = '".$this->noInt."',
|
||||
`noExt` = '".$this->noExt."',
|
||||
`referencia` = '".$this->referencia."',
|
||||
`colonia` = '".$this->colonia."',
|
||||
`regimenFiscal` = '".$this->regimenFiscal."',
|
||||
`localidad` = '".$this->localidad."',
|
||||
`municipio` = '".$this->municipio."',
|
||||
`ciudad` = '".$this->ciudad."',
|
||||
`estado` = '".$this->estado."',
|
||||
`pais` = '".$this->pais."',
|
||||
`cp` = '".$this->codigoPostal."',
|
||||
`diasDevolucion` = '".$this->diasDevolucion."',
|
||||
`porcentajeBonificacion` = '".$this->bonificacion."',
|
||||
`porcentajeDevolucion` = '".$this->devolucion."'
|
||||
WHERE
|
||||
rfcId = '".$this->rfcId."'"
|
||||
);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData();
|
||||
|
||||
$this->Util()->setError(20007, 'complete');
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function GetRfcsByEmpresa()
|
||||
{
|
||||
$sql = 'SELECT * FROM rfc';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$rfcs = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
return $rfcs;
|
||||
}
|
||||
|
||||
function GetCertificadoByRfc(){
|
||||
|
||||
$ruta_dir = DOC_ROOT.'/empresas/'.$this->empresaId.'/certificados/'.$this->rfcId;
|
||||
|
||||
if(is_dir($ruta_dir)){
|
||||
if($gd = opendir($ruta_dir)){
|
||||
while($archivo = readdir($gd)){
|
||||
$info = pathinfo($ruta_dir.'/'.$archivo);
|
||||
if($info['extension'] == 'cer'){
|
||||
$nom_certificado = $info['filename'];
|
||||
break;
|
||||
}//if
|
||||
}//while
|
||||
closedir($gd);
|
||||
}//if
|
||||
}//if
|
||||
|
||||
return $nom_certificado;
|
||||
|
||||
}
|
||||
|
||||
function getRfcActive(){
|
||||
|
||||
$empresaId = $_SESSION['empresaId'];
|
||||
|
||||
$sql = 'SELECT rfcId FROM rfc
|
||||
WHERE rfcId = 1';
|
||||
$this->Util()->DBSelect($id_empresa)->setQuery($sql);
|
||||
$rfcId = $this->Util()->DBSelect($empresaId)->GetSingle();
|
||||
|
||||
return $rfcId;
|
||||
|
||||
}//getRfcActive
|
||||
|
||||
|
||||
}//Rfc
|
||||
|
||||
?>
|
||||
379
classes/sucursal.class.php
Executable file
379
classes/sucursal.class.php
Executable file
@@ -0,0 +1,379 @@
|
||||
<?php
|
||||
|
||||
class Sucursal extends Main
|
||||
{
|
||||
private $sucursalId;
|
||||
private $rfcId;
|
||||
private $nombre;
|
||||
private $noSuc;
|
||||
private $calle;
|
||||
private $noInt;
|
||||
private $noExt;
|
||||
private $referencia;
|
||||
private $colonia;
|
||||
private $localidad;
|
||||
private $municipio;
|
||||
private $ciudad;
|
||||
private $estado;
|
||||
private $pais;
|
||||
private $codigoPostal;
|
||||
private $iva;
|
||||
private $telefono;
|
||||
private $mapa;
|
||||
private $arrendatario;
|
||||
private $montoRenta;
|
||||
private $fechaVenc;
|
||||
private $tipo;
|
||||
|
||||
//private $idNota;
|
||||
|
||||
public function setSucursalId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->sucursalId = $value;
|
||||
}
|
||||
|
||||
public function setRfcId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->rfcId = $value;
|
||||
}
|
||||
|
||||
public function setNombre($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=300, $minChars = 1, "Nombre");
|
||||
$this->nombre = $value;
|
||||
}
|
||||
|
||||
public function setNoSuc($value)
|
||||
{
|
||||
$this->noSuc = $value;
|
||||
}
|
||||
|
||||
public function setCalle($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=200, $minChars = 0, 'Dirección');
|
||||
$this->calle = $value;
|
||||
}
|
||||
|
||||
public function setNoInt($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'No. Interior');
|
||||
$this->noInt = $value;
|
||||
}
|
||||
|
||||
public function setNoExt($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, 'No. Exterior');
|
||||
$this->noExt = $value;
|
||||
}
|
||||
|
||||
public function setLocalidad($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'Localidad');
|
||||
$this->localidad = $value;
|
||||
}
|
||||
|
||||
public function setColonia($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'Colonia');
|
||||
$this->colonia = $value;
|
||||
}
|
||||
|
||||
public function setReferencia($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'Referencia');
|
||||
$this->referencia = $value;
|
||||
}
|
||||
|
||||
public function setMunicipio($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'Municipio');
|
||||
$this->municipio = $value;
|
||||
}
|
||||
|
||||
public function setCiudad($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'Ciudad');
|
||||
$this->ciudad = $value;
|
||||
}
|
||||
|
||||
public function setEstado($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'Estado');
|
||||
$this->estado = $value;
|
||||
}
|
||||
|
||||
public function setPais($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'Pais');
|
||||
$this->pais = $value;
|
||||
}
|
||||
|
||||
public function setCodigoPostal($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'Código Postal');
|
||||
$this->codigoPostal = $value;
|
||||
}
|
||||
|
||||
public function setIva($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, '% IVA');
|
||||
$this->iva = $value;
|
||||
}
|
||||
|
||||
public function setTelefono($value)
|
||||
{
|
||||
$this->telefono = $value;
|
||||
}
|
||||
|
||||
public function setMapa($value)
|
||||
{
|
||||
$this->mapa = $value;
|
||||
}
|
||||
|
||||
public function setArrendatario($value)
|
||||
{
|
||||
$this->arrendatario = $value;
|
||||
}
|
||||
|
||||
public function setMontoRenta($value)
|
||||
{
|
||||
$this->montoRenta = $value;
|
||||
}
|
||||
|
||||
public function setFechaVenc($value)
|
||||
{
|
||||
$this->fechaVenc = $value;
|
||||
}
|
||||
|
||||
public function setTipo($value)
|
||||
{
|
||||
$this->tipo = $value;
|
||||
}
|
||||
|
||||
function Info()
|
||||
{
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("
|
||||
SELECT * FROM sucursal
|
||||
WHERE sucursalId ='".$this->sucursalId."'"
|
||||
);
|
||||
$info = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
function GetSucursalesByEmpresaId($sucursalId = 0)
|
||||
{
|
||||
if($sucursalId)
|
||||
$sqlFilter = ' WHERE sucursalId = '.$sucursalId;
|
||||
|
||||
$sql = "SELECT * FROM sucursal
|
||||
LEFT JOIN rfc ON rfc.rfcId = sucursal.rfcId
|
||||
".$sqlFilter."
|
||||
ORDER BY nombre ASC";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$sucursales = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $sucursales;
|
||||
}
|
||||
|
||||
function GetSucursalesByRfc()
|
||||
{
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
|
||||
SELECT * FROM sucursal
|
||||
LEFT JOIN rfc ON rfc.rfcId = sucursal.rfcId
|
||||
WHERE sucursal.rfcId ='".$this->rfcId."'
|
||||
ORDER BY noSuc ASC");
|
||||
$sucursales = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
return $sucursales;
|
||||
}
|
||||
|
||||
function EnumerateAll()
|
||||
{
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
|
||||
SELECT * FROM sucursal
|
||||
ORDER BY noSuc ASC");
|
||||
$sucursales = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
return $sucursales;
|
||||
}
|
||||
|
||||
function GetNameById()
|
||||
{
|
||||
$sql = 'SELECT nombre FROM sucursal
|
||||
WHERE sucursalId = "'.$this->sucursalId.'"';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$nombre = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
return $nombre;
|
||||
}
|
||||
|
||||
function GetNoSucById()
|
||||
{
|
||||
$sql = 'SELECT noSuc FROM sucursal
|
||||
WHERE sucursalId = "'.$this->sucursalId.'"';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$noSuc = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
return $noSuc;
|
||||
}
|
||||
|
||||
function Save()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("
|
||||
INSERT INTO `sucursal` (
|
||||
`rfcId`,
|
||||
`nombre`,
|
||||
noSuc,
|
||||
`pais`,
|
||||
`calle`,
|
||||
`noInt`,
|
||||
`noExt`,
|
||||
`referencia`,
|
||||
`colonia`,
|
||||
`localidad`,
|
||||
`municipio`,
|
||||
`ciudad`,
|
||||
`iva`,
|
||||
`estado`,
|
||||
`cp`,
|
||||
telefono,
|
||||
mapa,
|
||||
arrendatario,
|
||||
montoRenta,
|
||||
fechaVenc
|
||||
)
|
||||
VALUES (
|
||||
'".$this->rfcId."',
|
||||
'".$this->nombre."',
|
||||
'".$this->noSuc."',
|
||||
'".$this->pais."',
|
||||
'".$this->calle."',
|
||||
'".$this->noInt."',
|
||||
'".$this->noExt."',
|
||||
'".$this->referencia."',
|
||||
'".$this->colonia."',
|
||||
'".$this->localidad."',
|
||||
'".$this->municipio."',
|
||||
'".$this->ciudad."',
|
||||
'".$this->iva."',
|
||||
'".$this->estado."',
|
||||
'".$this->codigoPostal."',
|
||||
'".$this->telefono."',
|
||||
'".$this->mapa."',
|
||||
'".$this->arrendatario."',
|
||||
'".$this->montoRenta."',
|
||||
'".$this->fechaVenc."'
|
||||
)"
|
||||
);
|
||||
$sucursalId = $this->Util()->DBSelect($_SESSION["empresaId"])->InsertData();
|
||||
|
||||
$this->Util()->setError(20009, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return $sucursalId;
|
||||
}
|
||||
|
||||
function Update()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("
|
||||
UPDATE `sucursal` SET
|
||||
`nombre` = '".$this->nombre."',
|
||||
noSuc = '".$this->noSuc."',
|
||||
`pais` = '".$this->pais."',
|
||||
`iva` = '".$this->iva."',
|
||||
`calle` = '".$this->calle."',
|
||||
`noInt` = '".$this->noInt."',
|
||||
`noExt` = '".$this->noExt."',
|
||||
`referencia` = '".$this->referencia."',
|
||||
`colonia` = '".$this->colonia."',
|
||||
`localidad` = '".$this->localidad."',
|
||||
`municipio` = '".$this->municipio."',
|
||||
`ciudad` = '".$this->ciudad."',
|
||||
`estado` = '".$this->estado."',
|
||||
`cp` = '".$this->codigoPostal."',
|
||||
telefono = '".$this->telefono."',
|
||||
mapa = '".$this->mapa."',
|
||||
arrendatario = '".$this->arrendatario."',
|
||||
montoRenta = '".$this->montoRenta."',
|
||||
fechaVenc = '".$this->fechaVenc."'
|
||||
WHERE
|
||||
sucursalId = '".$this->sucursalId."'");
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
|
||||
|
||||
$this->Util()->setError(20010, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function Delete()
|
||||
{
|
||||
$sql = "DELETE FROM sucursal WHERE sucursalId = '".$this->sucursalId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$this->Util()->setError(20008, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function GetIva()
|
||||
{
|
||||
$sql = 'SELECT iva FROM sucursal
|
||||
WHERE sucursalId = "'.$this->sucursalId.'"';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$iva = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
return $iva;
|
||||
}
|
||||
|
||||
function getGerente()
|
||||
{
|
||||
$sql = 'SELECT * FROM usuario
|
||||
WHERE type = "gerente"
|
||||
AND sucursalId = "'.$this->sucursalId.'"';
|
||||
$this->Util()->DB()->setQuery($sql);
|
||||
$infG = $this->Util()->DB()->GetRow();
|
||||
|
||||
return $infG;
|
||||
}
|
||||
|
||||
function getSubGerente()
|
||||
{
|
||||
$sql = 'SELECT * FROM usuario
|
||||
WHERE type = "subgerente"
|
||||
AND sucursalId = "'.$this->sucursalId.'"';
|
||||
$this->Util()->DB()->setQuery($sql);
|
||||
$infSg = $this->Util()->DB()->GetRow();
|
||||
|
||||
return $infSg;
|
||||
}
|
||||
|
||||
function GetNomGerente(){
|
||||
|
||||
$sql = 'SELECT nombre, apellidos FROM usuario
|
||||
WHERE type = "gerente"
|
||||
AND sucursalId = "'.$this->sucursalId.'"';
|
||||
$this->Util()->DB()->setQuery($sql);
|
||||
$info = $this->Util()->DB()->GetRow();
|
||||
|
||||
$nombre = $info['nombre'].' '.$info['apellidos'];
|
||||
|
||||
return $nombre;
|
||||
}
|
||||
|
||||
}//Sucursal
|
||||
|
||||
?>
|
||||
137
classes/talla.class.php
Executable file
137
classes/talla.class.php
Executable file
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
|
||||
class Talla extends Main
|
||||
{
|
||||
private $tallaId;
|
||||
private $nombre;
|
||||
|
||||
public function setTallaId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->tallaId = $value;
|
||||
}
|
||||
|
||||
public function setNombre($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, "Nombre");
|
||||
$this->nombre = $value;
|
||||
}
|
||||
|
||||
public function Info()
|
||||
{
|
||||
|
||||
$sql = 'SELECT
|
||||
*
|
||||
FROM
|
||||
talla
|
||||
WHERE
|
||||
tallaId = "'.$this->tallaId.'"';
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$info = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
$row = $this->Util->EncodeRow($info);
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function EnumerateAll()
|
||||
{
|
||||
|
||||
$sql = 'SELECT
|
||||
*
|
||||
FROM
|
||||
talla
|
||||
ORDER BY
|
||||
nombre ASC';
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function Enumerate()
|
||||
{
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT COUNT(*) FROM talla");
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
$pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/tallas");
|
||||
|
||||
$sqlAdd = "LIMIT ".$pages["start"].", ".$pages["items_per_page"];
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT * FROM talla ORDER BY nombre ASC ".$sqlAdd);
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$data["items"] = $result;
|
||||
$data["pages"] = $pages;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function Save()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){ return false; }
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("
|
||||
INSERT INTO `talla` (
|
||||
`nombre`
|
||||
)
|
||||
VALUES (
|
||||
'".utf8_decode($this->nombre)."'
|
||||
)"
|
||||
);
|
||||
|
||||
$tallaId = $this->Util()->DBSelect($_SESSION["empresaId"])->InsertData();
|
||||
|
||||
$this->Util()->setError(20040, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function Update()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){ return false; }
|
||||
|
||||
$sql = "
|
||||
UPDATE `talla` SET
|
||||
`nombre` = '".utf8_decode($this->nombre)."'
|
||||
WHERE tallaId = '".$this->tallaId."'
|
||||
";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
|
||||
|
||||
$this->Util()->setError(20041, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function Delete()
|
||||
{
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("
|
||||
DELETE FROM talla
|
||||
WHERE tallaId = '".$this->tallaId."'"
|
||||
);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$this->Util()->setError(20042, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function GetNameById()
|
||||
{
|
||||
$sql = 'SELECT nombre FROM talla
|
||||
WHERE tallaId = "'.$this->tallaId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$nombre = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $nombre;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
156
classes/temporada.class.php
Executable file
156
classes/temporada.class.php
Executable file
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
|
||||
class Temporada extends Main
|
||||
{
|
||||
private $temporadaId;
|
||||
private $nombre;
|
||||
|
||||
public function setTemporadaId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->temporadaId = $value;
|
||||
}
|
||||
|
||||
public function setNombre($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, "Nombre");
|
||||
$this->nombre = $value;
|
||||
}
|
||||
|
||||
public function Info()
|
||||
{
|
||||
|
||||
$sql = 'SELECT
|
||||
*
|
||||
FROM
|
||||
temporada
|
||||
WHERE
|
||||
temporadaId = "'.$this->temporadaId.'"';
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$info = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
$row = $this->Util->EncodeRow($info);
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
public function EnumerateAll()
|
||||
{
|
||||
|
||||
$sql = 'SELECT
|
||||
*
|
||||
FROM
|
||||
temporada
|
||||
WHERE
|
||||
baja = "0"
|
||||
ORDER BY
|
||||
nombre ASC';
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function Enumerate()
|
||||
{
|
||||
$sql = "SELECT COUNT(*) FROM temporada WHERE baja = '0'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
$pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/temporadas");
|
||||
|
||||
$sqlAdd = "LIMIT ".$pages["start"].", ".$pages["items_per_page"];
|
||||
|
||||
$sql = "SELECT * FROM temporada WHERE baja = '0' ORDER BY nombre ASC ".$sqlAdd;
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$data["items"] = $result;
|
||||
$data["pages"] = $pages;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function Save()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){ return false; }
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("
|
||||
INSERT INTO `temporada` (
|
||||
`nombre`
|
||||
)
|
||||
VALUES (
|
||||
'".utf8_decode($this->nombre)."'
|
||||
)"
|
||||
);
|
||||
|
||||
$temporadaId = $this->Util()->DBSelect($_SESSION["empresaId"])->InsertData();
|
||||
|
||||
$this->Util()->setError(20037, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function Update()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){ return false; }
|
||||
|
||||
$sql = "
|
||||
UPDATE `temporada` SET
|
||||
`nombre` = '".utf8_decode($this->nombre)."'
|
||||
WHERE temporadaId = '".$this->temporadaId."'
|
||||
";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
|
||||
|
||||
$this->Util()->setError(20038, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function Delete()
|
||||
{
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("
|
||||
DELETE FROM temporada
|
||||
WHERE temporadaId = '".$this->temporadaId."'"
|
||||
);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$this->Util()->setError(20039, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function Baja(){
|
||||
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
|
||||
UPDATE temporada SET baja = '1'
|
||||
WHERE temporadaId = '".$this->temporadaId."'"
|
||||
);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData();
|
||||
|
||||
$this->Util()->setError(20039, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}//Baja
|
||||
|
||||
function GetNameById()
|
||||
{
|
||||
$sql = 'SELECT nombre FROM temporada
|
||||
WHERE temporadaId = "'.$this->temporadaId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$nombre = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $nombre;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
22
classes/user.class.php
Executable file
22
classes/user.class.php
Executable file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
class User extends Main
|
||||
{
|
||||
|
||||
function Info()
|
||||
{
|
||||
$generalDb = new DB;
|
||||
|
||||
$sql = "SELECT * FROM usuario
|
||||
LEFT JOIN empresa ON usuario.empresaId = empresa.empresaId
|
||||
WHERE usuarioId = '".$_SESSION["loginKey"]."'";
|
||||
$generalDb->setQuery($sql);
|
||||
$info = $generalDb->GetRow();
|
||||
|
||||
return $info;
|
||||
|
||||
}//Info
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
716
classes/usuario.class.php
Executable file
716
classes/usuario.class.php
Executable file
@@ -0,0 +1,716 @@
|
||||
<?php
|
||||
|
||||
class Usuario extends Main
|
||||
{
|
||||
private $usuarioId;
|
||||
private $empresaId;
|
||||
private $nombre;
|
||||
private $apellidos;
|
||||
private $calle;
|
||||
private $noInt;
|
||||
private $noExt;
|
||||
private $referencia;
|
||||
private $colonia;
|
||||
private $localidad;
|
||||
private $municipio;
|
||||
private $ciudad;
|
||||
private $estado;
|
||||
private $codigoPostal;
|
||||
private $pais;
|
||||
private $telefono;
|
||||
private $celular;
|
||||
private $noImss;
|
||||
private $curp;
|
||||
private $rfc;
|
||||
private $email;
|
||||
private $passwd;
|
||||
private $tipo;
|
||||
private $sucursalId;
|
||||
|
||||
private $identificacion;
|
||||
private $comprobante;
|
||||
|
||||
public function setUsuarioId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->usuarioId = $value;
|
||||
}
|
||||
|
||||
public function setEmpresaId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->empresaId = $value;
|
||||
}
|
||||
|
||||
public function setNombre($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=300, $minChars = 1, 'Nombre');
|
||||
$this->nombre = $value;
|
||||
}
|
||||
|
||||
public function setApellidos($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=300, $minChars = 0, 'Apellidos');
|
||||
$this->apellidos = $value;
|
||||
}
|
||||
|
||||
public function setCalle($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=200, $minChars = 0, "Dirección");
|
||||
$this->calle = $value;
|
||||
}
|
||||
|
||||
public function setNoInt($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, "noInt");
|
||||
$this->noInt = $value;
|
||||
}
|
||||
|
||||
public function setNoExt($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=255, $minChars = 0, "noExt");
|
||||
$this->noExt = $value;
|
||||
}
|
||||
|
||||
public function setLocalidad($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, "Localidad");
|
||||
$this->localidad = $value;
|
||||
}
|
||||
|
||||
public function setColonia($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, "Colonia");
|
||||
$this->colonia = $value;
|
||||
}
|
||||
|
||||
public function setReferencia($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, "Referencia");
|
||||
$this->referencia = $value;
|
||||
}
|
||||
|
||||
public function setMunicipio($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, "Municipio");
|
||||
$this->municipio = $value;
|
||||
}
|
||||
|
||||
public function setCiudad($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, "Ciudad");
|
||||
$this->ciudad = $value;
|
||||
}
|
||||
|
||||
public function setEstado($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, "Estado");
|
||||
$this->estado = $value;
|
||||
}
|
||||
|
||||
public function setPais($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, "Pais");
|
||||
$this->pais = $value;
|
||||
}
|
||||
|
||||
public function setCodigoPostal($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, "Codigo Postal");
|
||||
$this->codigoPostal = $value;
|
||||
}
|
||||
|
||||
public function setTelefono($value)
|
||||
{
|
||||
$this->telefono = $value;
|
||||
}
|
||||
|
||||
public function setCelular($value)
|
||||
{
|
||||
$this->celular = $value;
|
||||
}
|
||||
|
||||
public function setNoImss($value)
|
||||
{
|
||||
$this->noImss = $value;
|
||||
}
|
||||
|
||||
public function setCurp($value)
|
||||
{
|
||||
$this->curp = $value;
|
||||
}
|
||||
|
||||
public function setRfc($value)
|
||||
{
|
||||
$this->rfc = $value;
|
||||
}
|
||||
|
||||
public function setPassword($value)
|
||||
{
|
||||
$this->passwd = $value;
|
||||
}
|
||||
|
||||
public function setTipo($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=300, $minChars = 1, 'Tipo');
|
||||
$this->tipo = $value;
|
||||
}
|
||||
|
||||
public function setSucursalId($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=300, $minChars = 0, 'Sucursal');
|
||||
$this->sucursalId = $value;
|
||||
}
|
||||
|
||||
public function setEmail($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=300, $minChars = 0, 'Email');
|
||||
if($value)
|
||||
$this->Util()->ValidateMail($value);
|
||||
$this->email = urldecode($value);
|
||||
}
|
||||
|
||||
public function setIdentificacion($value)
|
||||
{
|
||||
$this->identificacion = $value;
|
||||
}
|
||||
|
||||
public function setComprobante($value)
|
||||
{
|
||||
$this->comprobante = $value;
|
||||
}
|
||||
|
||||
public function Info()
|
||||
{
|
||||
$this->Util()->DB()->setQuery("SELECT * FROM usuario WHERE usuarioId ='".$this->usuarioId."'");
|
||||
$usuario = $this->Util()->DB()->GetRow();
|
||||
|
||||
return $usuario;
|
||||
}
|
||||
|
||||
public function GetUsuariosByEmpresa()
|
||||
{
|
||||
$sql = "SELECT * FROM usuario
|
||||
WHERE empresaId ='".$this->empresaId."'
|
||||
AND main = 'no'
|
||||
AND baja = '0'";
|
||||
$this->Util()->DB()->setQuery($sql);
|
||||
$usuarios = $this->Util()->DB()->GetResult();
|
||||
|
||||
return $usuarios;
|
||||
}
|
||||
|
||||
public function GetUsuariosBySuc()
|
||||
{
|
||||
$sql = "SELECT * FROM usuario
|
||||
WHERE empresaId ='".$this->empresaId."'
|
||||
AND main = 'no'
|
||||
AND baja = '0'
|
||||
AND sucursalId = '".$this->sucursalId."'";
|
||||
$this->Util()->DB()->setQuery($sql);
|
||||
$usuarios = $this->Util()->DB()->GetResult();
|
||||
|
||||
return $usuarios;
|
||||
}
|
||||
|
||||
public function SaveTemp()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function Save()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->Util()->DB()->setQuery("
|
||||
INSERT INTO usuario (
|
||||
empresaId,
|
||||
nombre,
|
||||
apellidos,
|
||||
calle,
|
||||
noInt,
|
||||
noExt,
|
||||
referencia,
|
||||
colonia,
|
||||
localidad,
|
||||
municipio,
|
||||
estado,
|
||||
pais,
|
||||
codigoPostal,
|
||||
telefono,
|
||||
celular,
|
||||
noImss,
|
||||
curp,
|
||||
rfc,
|
||||
email,
|
||||
password,
|
||||
`type`,
|
||||
sucursalId
|
||||
)
|
||||
VALUES (
|
||||
'".$_SESSION["empresaId"]."',
|
||||
'".$this->nombre."',
|
||||
'".$this->apellidos."',
|
||||
'".$this->calle."',
|
||||
'".$this->noInt."',
|
||||
'".$this->noExt."',
|
||||
'".$this->referencia."',
|
||||
'".$this->colonia."',
|
||||
'".$this->localidad."',
|
||||
'".$this->municipio."',
|
||||
'".$this->estado."',
|
||||
'".$this->pais."',
|
||||
'".$this->codigoPostal."',
|
||||
'".$this->telefono."',
|
||||
'".$this->celular."',
|
||||
'".$this->noImss."',
|
||||
'".$this->curp."',
|
||||
'".$this->rfc."',
|
||||
'".$this->email."',
|
||||
'".$this->passwd."',
|
||||
'".$this->tipo."',
|
||||
'".$this->sucursalId."')"
|
||||
);
|
||||
$usuarioId = $this->Util()->DB()->InsertData();
|
||||
|
||||
$this->Util()->setError(20017, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return $usuarioId;
|
||||
}
|
||||
|
||||
public function Update()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->Util()->DB()->setQuery("
|
||||
UPDATE usuario SET
|
||||
nombre = '".$this->nombre."',
|
||||
apellidos = '".$this->apellidos."',
|
||||
calle = '".$this->calle."',
|
||||
noInt = '".$this->noInt."',
|
||||
noExt = '".$this->noExt."',
|
||||
referencia = '".$this->referencia."',
|
||||
colonia = '".$this->colonia."',
|
||||
localidad = '".$this->localidad."',
|
||||
municipio = '".$this->municipio."',
|
||||
estado = '".$this->estado."',
|
||||
pais = '".$this->pais."',
|
||||
codigoPostal = '".$this->codigoPostal."',
|
||||
telefono = '".$this->telefono."',
|
||||
celular = '".$this->celular."',
|
||||
noImss = '".$this->noImss."',
|
||||
curp = '".$this->curp."',
|
||||
rfc = '".$this->rfc."',
|
||||
email = '".$this->email."',
|
||||
password = '".$this->passwd."',
|
||||
`type` = '".$this->tipo."',
|
||||
sucursalId = '".$this->sucursalId."'
|
||||
WHERE usuarioId = '".$this->usuarioId."'"
|
||||
);
|
||||
$this->Util()->DB()->UpdateData();
|
||||
|
||||
$this->Util()->setError(20019, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function Delete()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->Util()->DB()->setQuery("DELETE FROM usuario WHERE usuarioId = '".$this->usuarioId."' ");
|
||||
$this->Util()->DB()->DeleteData();
|
||||
|
||||
$this->Util()->setError(20018, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function Baja(){
|
||||
|
||||
$this->Util()->DB()->setQuery("
|
||||
UPDATE usuario SET
|
||||
baja = '1'
|
||||
WHERE
|
||||
usuarioId = '".$this->usuarioId."'"
|
||||
);
|
||||
$this->Util()->DB()->UpdateData();
|
||||
|
||||
$this->Util()->setError(20110, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
|
||||
}//Baja
|
||||
|
||||
function SaveSucursal(){
|
||||
|
||||
$sql = 'INSERT INTO usuarioSuc (usuarioId, sucursalId)
|
||||
VALUES ("'.$this->usuarioId.'", "'.$this->sucursalId.'")';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->InsertData();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function UpdateIdentificacion(){
|
||||
|
||||
$this->Util()->DB()->setQuery("
|
||||
UPDATE usuario SET
|
||||
identificacion = '".$this->identificacion."'
|
||||
WHERE
|
||||
usuarioId = '".$this->usuarioId."'"
|
||||
);
|
||||
$this->Util()->DB()->UpdateData();
|
||||
|
||||
return true;
|
||||
|
||||
}//UpdateIdentificacion
|
||||
|
||||
function UpdateComprobante(){
|
||||
|
||||
$this->Util()->DB()->setQuery("
|
||||
UPDATE usuario SET
|
||||
comprobante = '".$this->comprobante."'
|
||||
WHERE
|
||||
usuarioId = '".$this->usuarioId."'"
|
||||
);
|
||||
$this->Util()->DB()->UpdateData();
|
||||
|
||||
return true;
|
||||
|
||||
}//UpdateComprobante
|
||||
|
||||
function GetNameById()
|
||||
{
|
||||
$sql = 'SELECT nombre FROM usuario
|
||||
WHERE usuarioId = "'.$this->usuarioId.'"';
|
||||
|
||||
$this->Util()->DB()->setQuery($sql);
|
||||
$nombre = $this->Util()->DB()->GetSingle();
|
||||
|
||||
return $nombre;
|
||||
}
|
||||
|
||||
function GetFullNameById()
|
||||
{
|
||||
$sql = 'SELECT CONCAT(nombre," ",apellidos) AS name FROM usuario
|
||||
WHERE usuarioId = "'.$this->usuarioId.'"';
|
||||
|
||||
$this->Util()->DB()->setQuery($sql);
|
||||
$nombre = $this->Util()->DB()->GetSingle();
|
||||
|
||||
return $nombre;
|
||||
}
|
||||
|
||||
function GetInfoBySuc()
|
||||
{
|
||||
$sql = 'SELECT * FROM usuario
|
||||
WHERE sucursalId = "'.$this->sucursalId.'"
|
||||
AND `type` = "'.$this->tipo.'"
|
||||
LIMIT 1';
|
||||
$this->Util()->DB()->setQuery($sql);
|
||||
$info = $this->Util()->DB()->GetRow();
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
function GetTypeById()
|
||||
{
|
||||
$sql = 'SELECT type FROM usuario
|
||||
WHERE usuarioId = "'.$this->usuarioId.'"';
|
||||
$this->Util()->DB()->setQuery($sql);
|
||||
$tipo = $this->Util()->DB()->GetSingle();
|
||||
|
||||
return $tipo;
|
||||
}
|
||||
|
||||
function GetUserByType()
|
||||
{
|
||||
$sql = 'SELECT usuarioId FROM usuario
|
||||
WHERE type = "'.$this->tipo.'"
|
||||
LIMIT 1';
|
||||
$this->Util()->DB()->setQuery($sql);
|
||||
$usuarioId = $this->Util()->DB()->GetSingle();
|
||||
|
||||
return $usuarioId;
|
||||
}
|
||||
|
||||
function GetUserBySucAndType()
|
||||
{
|
||||
$sql = 'SELECT usuarioId FROM usuario
|
||||
WHERE type = "'.$this->tipo.'"
|
||||
AND sucursalId = "'.$this->sucursalId.'"
|
||||
LIMIT 1';
|
||||
$this->Util()->DB()->setQuery($sql);
|
||||
$usuarioId = $this->Util()->DB()->GetSingle();
|
||||
|
||||
return $usuarioId;
|
||||
}
|
||||
|
||||
function GetUsersBySucAndType($usuarioId = 0)
|
||||
{
|
||||
if($usuarioId)
|
||||
$sqlFilter = ' AND usuarioId = '.$usuarioId;
|
||||
|
||||
$sql = 'SELECT * FROM usuario
|
||||
WHERE baja = "0"
|
||||
AND type = "'.$this->tipo.'"
|
||||
AND sucursalId = "'.$this->sucursalId.'"
|
||||
'.$sqlFilter;
|
||||
$this->Util()->DB()->setQuery($sql);
|
||||
$usuarios = $this->Util()->DB()->GetResult();
|
||||
|
||||
return $usuarios;
|
||||
}
|
||||
|
||||
function IsEmailTaked(){
|
||||
|
||||
if($this->usuarioId)
|
||||
$sqlAdd = ' AND usuarioId <> "'.$this->usuarioId.'"';
|
||||
|
||||
$sql = 'SELECT usuarioId FROM usuario
|
||||
WHERE email = "'.$this->email.'"
|
||||
'.$sqlAdd.'
|
||||
LIMIT 1';
|
||||
$this->Util()->DB()->setQuery($sql);
|
||||
$allow = $this->Util()->DB()->GetSingle();
|
||||
|
||||
return $allow;
|
||||
|
||||
}
|
||||
|
||||
function IsSucChecked(){
|
||||
|
||||
$sql = 'SELECT COUNT(*) FROM usuarioSuc
|
||||
WHERE sucursalId = "'.$this->sucursalId.'"
|
||||
AND usuarioId = "'.$this->usuarioId.'"';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$checked = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
return $checked;
|
||||
}
|
||||
|
||||
function DelSupSuc(){
|
||||
|
||||
$sql = 'DELETE FROM usuarioSuc
|
||||
WHERE usuarioId = "'.$this->usuarioId.'"';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->DeleteData();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function Search()
|
||||
{
|
||||
$sqlFilter = '';
|
||||
if($this->tipo)
|
||||
$sqlFilter .= ' AND type = "'.$this->tipo.'"';
|
||||
if($this->sucursalId)
|
||||
$sqlFilter .= ' AND sucursalId = "'.$this->sucursalId.'"';
|
||||
if($this->nombre)
|
||||
$sqlFilter .= ' AND nombre LIKE "%'.$this->nombre.'%"';
|
||||
|
||||
$sql = "SELECT * FROM usuario
|
||||
WHERE empresaId ='".$this->empresaId."'
|
||||
AND main = 'no'
|
||||
AND baja = '0'".$sqlFilter;
|
||||
$this->Util()->DB()->setQuery($sql);
|
||||
$usuarios = $this->Util()->DB()->GetResult();
|
||||
|
||||
return $usuarios;
|
||||
}
|
||||
|
||||
function AllowPage($page, $usuarioId){
|
||||
|
||||
$this->setUsuarioId($usuarioId);
|
||||
$tipo = $this->GetTypeById();
|
||||
|
||||
$pages = array();
|
||||
|
||||
switch($tipo){
|
||||
|
||||
case 'admin':
|
||||
$pages = array(
|
||||
'bonificaciones',
|
||||
'bonificaciones-agregar',
|
||||
'cuentas-pagar',
|
||||
'cuentas-pagar-saldos',
|
||||
'envios',
|
||||
'envios-recibir-reporte',
|
||||
'pedidos',
|
||||
'pedidos-detalles',
|
||||
'devoluciones-pendientes',
|
||||
'inventario-actualizar',
|
||||
'inventario-fisico',
|
||||
'inventario-fisico-agregar',
|
||||
'inventario-fisico-detalles',
|
||||
'inventario-ajustar-list',
|
||||
'ventas',
|
||||
'inventario-bloqueados',
|
||||
'ventas-ticket'
|
||||
);
|
||||
break;
|
||||
|
||||
case 'almacen':
|
||||
$pages = array(
|
||||
'bonificaciones',
|
||||
'bonificaciones-agregar',
|
||||
'envios',
|
||||
'evaluar-pedidos',
|
||||
'pedidos',
|
||||
'pedidos-detalles',
|
||||
'pedidos-agregar',
|
||||
'pedidos-editar',
|
||||
'pedidos-distribucion',
|
||||
'envios-tienda-cedis',
|
||||
'envios-reporte',
|
||||
'envios-recibir-reporte',
|
||||
'cuentas-pagar',
|
||||
'inventario'
|
||||
);
|
||||
break;
|
||||
|
||||
case 'cajero':
|
||||
$pages = array(
|
||||
'descuentos',
|
||||
'descuentos-nuevo',
|
||||
'devoluciones',
|
||||
'devoluciones-nueva',
|
||||
'devoluciones-ticket',
|
||||
'inventario',
|
||||
'inventario-bloqueados',
|
||||
'inventario-detalles',
|
||||
'inventario-bloqueados-detalles',
|
||||
'ventas',
|
||||
'ventas-ticket',
|
||||
'ventas-nueva',
|
||||
'ventas-espera',
|
||||
'ventas-cobrar'
|
||||
);
|
||||
break;
|
||||
|
||||
case 'compras':
|
||||
$pages = array(
|
||||
'envios',
|
||||
'pedidos',
|
||||
'pedidos-detalles',
|
||||
'pedidos-agregar',
|
||||
'pedidos-editar',
|
||||
'inventario-solicitar',
|
||||
'inventario-solicitar-detalles'
|
||||
);
|
||||
break;
|
||||
|
||||
case 'direccion':
|
||||
$pages = array(
|
||||
'envios',
|
||||
'pedidos',
|
||||
'pedidos-detalles',
|
||||
'cuentas-pagar-saldos',
|
||||
'cuentas-pagar',
|
||||
'bonificaciones',
|
||||
'bonificaciones-agregar'
|
||||
);
|
||||
break;
|
||||
|
||||
case 'distribucion':
|
||||
$pages = array(
|
||||
'pedidos',
|
||||
'pedidos-detalles'
|
||||
);
|
||||
break;
|
||||
|
||||
case 'facturacion':
|
||||
$pages = array(
|
||||
'facturacion',
|
||||
'facturacion-nueva',
|
||||
'ventas',
|
||||
'ventas-ticket',
|
||||
'reportes-ventas'
|
||||
);
|
||||
break;
|
||||
|
||||
case 'gerente':
|
||||
$pages = array(
|
||||
'descuentos',
|
||||
'descuentos-nuevo',
|
||||
'devoluciones',
|
||||
'devoluciones-nueva',
|
||||
'devoluciones-ticket',
|
||||
'envios',
|
||||
'envios-recibir-reporte',
|
||||
'inventario',
|
||||
'inventario-bloqueados',
|
||||
'inventario-detalles',
|
||||
'inventario-bloqueados-detalles',
|
||||
'inventario-solicitar',
|
||||
'inventario-solicitar-agregar',
|
||||
'inventario-solicitar-detalles',
|
||||
'ventas',
|
||||
'ventas-ticket',
|
||||
'ventas-nueva',
|
||||
'ventas-espera',
|
||||
'ventas-cobrar',
|
||||
'facturacion-nueva'
|
||||
);
|
||||
break;
|
||||
|
||||
case 'vendedor':
|
||||
$pages = array(
|
||||
'inventario',
|
||||
'inventario-bloqueados',
|
||||
'inventario-detalles',
|
||||
'inventario-bloqueados-detalles'
|
||||
);
|
||||
break;
|
||||
|
||||
case 'centralizador':
|
||||
$pages = array(
|
||||
'ventas',
|
||||
'ventas-ticket',
|
||||
'inventario',
|
||||
'pedidos',
|
||||
'pedidos-detalles',
|
||||
'envios',
|
||||
'devoluciones',
|
||||
'devoluciones-ticket'
|
||||
);
|
||||
break;
|
||||
|
||||
case 'supervisor':
|
||||
|
||||
$pages = array(
|
||||
'inventario-fisico',
|
||||
'inventario-fisico-agregar',
|
||||
'inventario-fisico-detalles'
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if(in_array($page, $pages))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
||||
}//AllowPage
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
1061
classes/util.class.php
Executable file
1061
classes/util.class.php
Executable file
File diff suppressed because it is too large
Load Diff
1712
classes/venta.class.php
Executable file
1712
classes/venta.class.php
Executable file
File diff suppressed because it is too large
Load Diff
245
classes/vistaPrevia.class.php
Executable file
245
classes/vistaPrevia.class.php
Executable file
@@ -0,0 +1,245 @@
|
||||
<?php
|
||||
|
||||
class VistaPrevia extends Comprobante
|
||||
{
|
||||
function VistaPreviaComprobante($data, $notaCredito = false)
|
||||
{
|
||||
global $empresa;
|
||||
global $rfc;
|
||||
global $cliente;
|
||||
global $util;
|
||||
global $venta;
|
||||
|
||||
$myData = urlencode(serialize($data));
|
||||
$infEmp = $empresa->InfoAll();
|
||||
$values = explode("&", $data["datosFacturacion"]);
|
||||
unset($data["datosFacturacion"]);
|
||||
foreach($values as $key => $val)
|
||||
{
|
||||
$array = explode("=", $values[$key]);
|
||||
$data[$array[0]] = $array[1];
|
||||
}
|
||||
|
||||
$tipoSerie = explode("-", $data["tiposComprobanteId"]);
|
||||
$data["tiposComprobanteId"] = $tipoSerie[0];
|
||||
$data["tiposSerieId"] = $tipoSerie[1];
|
||||
|
||||
$empresa->setRFC($data["rfc"]);
|
||||
$empresa->setCalle($data["calle"]);
|
||||
$empresa->setPais($data["pais"]);
|
||||
|
||||
if(strlen($data["formaDePago"]) <= 0)
|
||||
{
|
||||
$empresa->Util()->setError(10041, "error", "");
|
||||
}
|
||||
|
||||
if(count($_SESSION["conceptos"]) < 1)
|
||||
{
|
||||
$empresa->Util()->setError(10040, "error", "");
|
||||
}
|
||||
|
||||
$myConceptos = urlencode(serialize($_SESSION["conceptos"]));
|
||||
|
||||
$userId = $data["userId"];
|
||||
|
||||
$totales = $this->GetTotalDesglosado($data);
|
||||
|
||||
/*** AJUSTAMOS TOTALES ***/
|
||||
|
||||
$ventaId = $data['ventaId'];
|
||||
|
||||
if($ventaId){
|
||||
|
||||
$venta->setVentaId($ventaId);
|
||||
$infV = $venta->Info();
|
||||
|
||||
$difCents = $infV['total'] - $totales['total'];
|
||||
$difCents = number_format($difCents,2,'.','');
|
||||
|
||||
if($difCents == 0.01 || $difCents == -0.01){
|
||||
$totales['iva'] += $difCents;
|
||||
$totales['ivaThis'] += $difCents;
|
||||
$totales['total'] += $difCents;
|
||||
}
|
||||
|
||||
$totales['iva'] = number_format($totales['iva'],2,'.','');
|
||||
$totales['ivaThis'] = number_format($totales['ivaThis'],2,'.','');
|
||||
|
||||
}
|
||||
|
||||
/*** FIN AJUSTAR TOTALES ***/
|
||||
|
||||
if($empresa->Util()->PrintErrors()){ return false; }
|
||||
|
||||
if(!$data["tipoDeCambio"])
|
||||
{
|
||||
$data["tipoDeCambio"] = "1.00";
|
||||
}
|
||||
|
||||
if(!$data["porcentajeDescuento"])
|
||||
{
|
||||
$data["porcentajeDescuento"] = "0";
|
||||
}
|
||||
|
||||
if(!$data["porcentajeIEPS"])
|
||||
{
|
||||
$data["porcentajeIEPS"] = "0";
|
||||
}
|
||||
|
||||
//get active rfc
|
||||
$activeRfc = $rfc->getRfcActive();
|
||||
//get datos serie de acuerdo al tipo de comprobabte expedido.
|
||||
|
||||
if(!$data["tiposComprobanteId"])
|
||||
{
|
||||
$empresa->Util()->setError(10047, "error");
|
||||
}
|
||||
|
||||
if($empresa->Util()->PrintErrors()){ return false; }
|
||||
|
||||
if($notaCredito)
|
||||
{
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT * FROM serie WHERE tiposComprobanteId = '2' AND empresaId = ".$_SESSION["empresaId"]." AND rfcId = '".$activeRfc."' AND consecutivo != folioFinal AND serieId = ".$data["tiposSerieId"]." ORDER BY serieId DESC LIMIT 1");
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "SELECT
|
||||
*
|
||||
FROM
|
||||
serie
|
||||
WHERE
|
||||
tiposComprobanteId = ".$data["tiposComprobanteId"]."
|
||||
AND
|
||||
empresaId = ".$_SESSION["empresaId"]."
|
||||
AND
|
||||
rfcId = '".$activeRfc."'
|
||||
AND
|
||||
consecutivo != folioFinal
|
||||
AND
|
||||
serieId = ".$data["tiposSerieId"]."
|
||||
ORDER BY
|
||||
serieId DESC
|
||||
LIMIT
|
||||
1";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
}
|
||||
|
||||
$serie = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
if(!$serie)
|
||||
{
|
||||
$empresa->Util()->setError(10047, "error");
|
||||
}
|
||||
|
||||
if($empresa->Util()->PrintErrors()){ return false; }
|
||||
|
||||
$folio = $serie["consecutivo"];
|
||||
$fecha = $this->Util()->FormatDateAndTime(time());
|
||||
|
||||
//el tipo de comprobante lo determina tiposComprobanteId
|
||||
$tipoDeComprobante = $this->GetTipoComprobante($data["tiposComprobanteId"]);
|
||||
$data["comprobante"] = $this->InfoComprobante($data["tiposComprobanteId"]);
|
||||
|
||||
$data["serie"] = $serie;
|
||||
$data["folio"] = $folio;
|
||||
$data["fecha"] = $fecha;
|
||||
$data["tipoDeComprobante"] = $tipoDeComprobante;
|
||||
$data["certificado"] = $serie["noCertificado"];
|
||||
|
||||
//build informacion nodo emisor
|
||||
$sucursal = new Sucursal;
|
||||
$sucursal->setSucursalId($data["sucursalId"]);
|
||||
$nodoEmisor = $sucursal->Info();
|
||||
$nodoEmisor['identificador'] = $nodoEmisor['nombre'];
|
||||
|
||||
$rfc->setRfcId($activeRfc);
|
||||
$nodoEmisorRfc = $rfc->Info();
|
||||
|
||||
$data["nodoEmisor"]["sucursal"] = $nodoEmisor;
|
||||
$data["nodoEmisor"]["rfc"] = $nodoEmisorRfc;
|
||||
|
||||
if($_SESSION["version"] == "auto")
|
||||
{
|
||||
$rootQr = DOC_ROOT."/empresas/".$_SESSION["empresaId"]."/qrs/";
|
||||
$qrRfc = strtoupper($nodoEmisorRfc["rfc"]);
|
||||
$nufa = $serie["serieId"]."_".$serie["noAprobacion"]."_".$qrRfc.".png";
|
||||
//echo $rootQr.$nufa;
|
||||
if(!file_exists($rootQr.$nufa))
|
||||
{
|
||||
$nufa = $serie["serieId"]."_".$serie["noAprobacion"]."_".$qrRfc."_.png";
|
||||
if(!file_exists($rootQr.$nufa))
|
||||
{
|
||||
$empresa->Util()->setError(10048, "error");
|
||||
}
|
||||
}
|
||||
|
||||
if($empresa->Util()->PrintErrors()){ return false; }
|
||||
|
||||
}
|
||||
|
||||
//Build informacion Nodo Receptor
|
||||
|
||||
if($_SESSION['tipoComp'] == 'Publico'){
|
||||
|
||||
$rfc->setRfcId($activeRfc);
|
||||
$nodoReceptor = $rfc->Info();
|
||||
$nodoReceptor['nombre'] = $nodoReceptor['razonSocial'];
|
||||
$data["nodoReceptor"] = $nodoReceptor;
|
||||
|
||||
}else{
|
||||
|
||||
$userId = $data["userId"];
|
||||
$cliente->setClienteId($userId);
|
||||
$nodoReceptor = $cliente->Info();
|
||||
$nodoReceptor = $util->EncodeRow($nodoReceptor);
|
||||
$data["nodoReceptor"] = $nodoReceptor;
|
||||
|
||||
}
|
||||
|
||||
//check tipo de cambio
|
||||
|
||||
switch($_SESSION["version"])
|
||||
{
|
||||
case "auto":
|
||||
case "v3":
|
||||
case "construc":
|
||||
include_once(DOC_ROOT.'/classes/cadena_original_v3.class.php');break;
|
||||
case "2":
|
||||
include_once(DOC_ROOT.'/classes/cadena_original_v2.class.php');break;
|
||||
}
|
||||
$cadena = new Cadena;
|
||||
$cadenaOriginal = $cadena->BuildCadenaOriginal($data, $serie, $totales, $nodoEmisor, $nodoReceptor, $_SESSION["conceptos"]);
|
||||
|
||||
$data["cadenaOriginal"] = utf8_encode($cadenaOriginal);
|
||||
$data["cadenaOriginal"] = $cadenaOriginal;
|
||||
|
||||
$md5Cadena = utf8_decode($cadenaOriginal);
|
||||
|
||||
if(date("Y") > 2010)
|
||||
{
|
||||
$md5 = sha1($md5Cadena);
|
||||
}
|
||||
|
||||
//Cambios 29 junio 2011
|
||||
|
||||
switch($_SESSION["version"])
|
||||
{
|
||||
case "v3":
|
||||
case "construc": include_once(DOC_ROOT."/classes/override_generate_pdf_default.php"); break;
|
||||
case "auto": include_once(DOC_ROOT."/classes/override_generate_pdf_default_auto.php");break;
|
||||
case "2": include_once(DOC_ROOT."/classes/override_generate_pdf_default_2.php");break;
|
||||
}
|
||||
|
||||
$override = new Override;
|
||||
$pdf = $override->GeneratePDF($data, $serie, $totales, $nodoEmisor, $nodoReceptor, $_SESSION["conceptos"],$infEmp,0, "vistaPrevia");
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
}//VistaPreviaComprobante
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user