Skip to content

Commit

Permalink
Merge pull request #93 from NeoRazorX/logic
Browse files Browse the repository at this point in the history
Logic
  • Loading branch information
NeoRazorX authored Aug 28, 2017
2 parents dc1f591 + 7660c53 commit afb14f9
Show file tree
Hide file tree
Showing 125 changed files with 1,410 additions and 1,384 deletions.
9 changes: 6 additions & 3 deletions controller/admin_agentes.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ private function nuevo_agente()
if ($age0->save()) {
$this->new_message("Empleado " . $age0->codagente . " guardado correctamente.");
header('location: ' . $age0->url());
} else
} else {
$this->new_error_msg("¡Imposible guardar el empleado!");
}
}

private function eliminar_agente()
Expand All @@ -104,10 +105,12 @@ private function eliminar_agente()
$this->new_error_msg('No tienes permiso para eliminar en esta página.');
} else if ($age0->delete()) {
$this->new_message("Empleado " . $age0->codagente . " eliminado correctamente.");
} else
} else {
$this->new_error_msg("¡Imposible eliminar el empleado!");
} else
}
} else {
$this->new_error_msg("¡Empleado no encontrado!");
}
}

public function paginas()
Expand Down
2 changes: 1 addition & 1 deletion controller/admin_empresa.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ protected function private_core()
$fsvar->simple_save('install_step', $step);
}

if ($step == 3 AND $this->empresa->contintegrada) {
if ($step == 3 && $this->empresa->contintegrada) {
$this->new_message('Recuerda que tienes que <a href="index.php?page=contabilidad_ejercicio&cod=' .
$this->empresa->codejercicio . '">importar los datos del ejercicio</a>.');
}
Expand Down
2 changes: 1 addition & 1 deletion controller/articulo_subcuentas.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected function private_core()
$this->articulo->codsubcuentairpfcom = $_POST['codsubcuentairpfcom'];
$aprops = array('codsubcuentaventa' => $_POST['codsubcuentaventa']);

if ($this->articulo->save() AND $ap->array_save($this->articulo->referencia, $aprops)) {
if ($this->articulo->save() && $ap->array_save($this->articulo->referencia, $aprops)) {
$this->new_message('Datos guardados correctamente.');
} else {
$this->new_error_msg('Error al guardar las subcuentas.');
Expand Down
2 changes: 1 addition & 1 deletion controller/articulo_trazabilidad.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected function private_core()

if ($this->articulo) {
if (isset($_POST['numserie'])) {
if ($_POST['numserie'] != '' OR $_POST['lote'] != '') {
if ($_POST['numserie'] != '' || $_POST['lote'] != '') {
$this->edit_traza();
} else {
$this->new_error_msg('Debes escribir un número de serie o un lote o ambos,'
Expand Down
6 changes: 3 additions & 3 deletions controller/base_wizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private function private_core2()

$fsvar = new fs_var();
$this->step = $fsvar->simple_get('install_step');
if ($this->step < 2 OR isset($_GET['restart'])) {
if ($this->step < 2 || isset($_GET['restart'])) {
$this->step = 2;
}

Expand Down Expand Up @@ -123,7 +123,7 @@ private function private_core2()
/// avanzamos el asistente
$this->step = 3;

if ($this->empresa->codpais == 'ESP' OR $this->empresa->codpais == 'ES') {
if ($this->empresa->codpais == 'ESP' || $this->empresa->codpais == 'ES') {
/// si es España nos podemos ahorrar un paso
$this->empresa->coddivisa = 'EUR';
$this->empresa->save();
Expand Down Expand Up @@ -230,7 +230,7 @@ private function check_menu()

/// leemos todos los controladores del plugin
foreach (scandir(__DIR__) as $f) {
if ($f != '.' AND $f != '..' AND is_string($f) AND strlen($f) > 4 AND ! is_dir($f) AND $f != __CLASS__ . '.php') {
if ($f != '.' && $f != '..' && is_string($f) && strlen($f) > 4 && ! is_dir($f) && $f != __CLASS__ . '.php') {
/// obtenemos el nombre
$page_name = substr($f, 0, -4);

Expand Down
6 changes: 3 additions & 3 deletions controller/compras_actualiza_arts.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected function private_core()
$this->documento = FALSE;
$this->lineas = array();
$this->tipodoc = 'Documento';
if (isset($_REQUEST['doc']) AND isset($_REQUEST['id'])) {
if (isset($_REQUEST['doc']) && isset($_REQUEST['id'])) {
if ($_REQUEST['doc'] == 'pedido') {
$pedido0 = new pedido_proveedor();
$this->documento = $pedido0->get($_REQUEST['id']);
Expand Down Expand Up @@ -119,7 +119,7 @@ protected function private_core()
}

/// ¿usamos la referencia de proveedor como equivalencia?
if ($_POST['refproveedor_' . $value->idlinea] != '' AND $_POST['refproveedor_' . $value->idlinea] != $articulo->referencia) {
if ($_POST['refproveedor_' . $value->idlinea] != '' && $_POST['refproveedor_' . $value->idlinea] != $articulo->referencia) {
if (is_null($articulo->equivalencia)) {
$articulo->equivalencia = $_POST['refproveedor_' . $value->idlinea];
}
Expand Down Expand Up @@ -179,7 +179,7 @@ public function url()
{
$url = parent::url();

if (isset($_REQUEST['doc']) AND isset($_REQUEST['id'])) {
if (isset($_REQUEST['doc']) && isset($_REQUEST['id'])) {
$url .= '&doc=' . $_REQUEST['doc'] . '&id=' . $_REQUEST['id'];
}

Expand Down
2 changes: 1 addition & 1 deletion controller/compras_agrupar_albaranes.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ public function pendientes()
/// Comprobamos si el proveedor ya está en la lista.
$encontrado = FALSE;
foreach ($pendientes as $i => $pe) {
if ($alb->codproveedor == $pe['codproveedor'] AND $alb->codserie == $pe['codserie'] AND $alb->coddivisa == $pe['coddivisa']) {
if ($alb->codproveedor == $pe['codproveedor'] && $alb->codserie == $pe['codserie'] && $alb->coddivisa == $pe['coddivisa']) {
$encontrado = TRUE;
$pendientes[$i]['num'] ++;

Expand Down
8 changes: 4 additions & 4 deletions controller/compras_albaran.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected function private_core()
/// comprobamos el albarán
$this->albaran->full_test();

if (isset($_POST['facturar']) AND isset($_POST['petid']) AND $this->albaran->ptefactura) {
if (isset($_POST['facturar']) && isset($_POST['petid']) && $this->albaran->ptefactura) {
if ($this->duplicated_petition($_POST['petid'])) {
$this->new_error_msg('Petición duplicada. Evita hacer doble clic sobre los botones.');
} else
Expand Down Expand Up @@ -243,7 +243,7 @@ private function modificar()
$lineas[$k]->iva = 0;
$lineas[$k]->recargo = 0;
$lineas[$k]->irpf = floatval($_POST['irpf_' . $num]);
if (!$serie->siniva AND $regimeniva != 'Exento') {
if (!$serie->siniva && $regimeniva != 'Exento') {
$imp0 = $this->impuesto->get_by_iva($_POST['iva_' . $num]);
if ($imp0) {
$lineas[$k]->codimpuesto = $imp0->codimpuesto;
Expand Down Expand Up @@ -278,12 +278,12 @@ private function modificar()
}

/// añadimos la línea
if (!$encontrada AND intval($_POST['idlinea_' . $num]) == -1 AND isset($_POST['referencia_' . $num])) {
if (!$encontrada && intval($_POST['idlinea_' . $num]) == -1 && isset($_POST['referencia_' . $num])) {
$linea = new linea_albaran_proveedor();
$linea->idalbaran = $this->albaran->idalbaran;
$linea->descripcion = $_POST['desc_' . $num];

if (!$serie->siniva AND $regimeniva != 'Exento') {
if (!$serie->siniva && $regimeniva != 'Exento') {
$imp0 = $this->impuesto->get_by_iva($_POST['iva_' . $num]);
if ($imp0) {
$linea->codimpuesto = $imp0->codimpuesto;
Expand Down
22 changes: 11 additions & 11 deletions controller/compras_albaranes.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ protected function private_core()
if (isset($_POST['delete'])) {
$this->delete_albaran();
} else {
if (!isset($_GET['mostrar']) AND ( $this->query != '' OR isset($_REQUEST['codagente']) OR isset($_REQUEST['codproveedor']) OR isset($_REQUEST['codserie']))) {
if (!isset($_GET['mostrar']) && ( $this->query != '' || isset($_REQUEST['codagente']) || isset($_REQUEST['codproveedor']) || isset($_REQUEST['codserie']))) {
/**
* si obtenermos un codagente, un codproveedor o un codserie pasamos direcatemente
* a la pestaña de búsqueda, a menos que tengamos un mostrar, que
Expand All @@ -117,11 +117,9 @@ protected function private_core()
$this->mostrar = 'buscar';
}

if (isset($_REQUEST['codproveedor'])) {
if ($_REQUEST['codproveedor'] != '') {
$pro0 = new proveedor();
$this->proveedor = $pro0->get($_REQUEST['codproveedor']);
}
if (isset($_REQUEST['codproveedor']) && $_REQUEST['codproveedor'] != '') {
$pro0 = new proveedor();
$this->proveedor = $pro0->get($_REQUEST['codproveedor']);
}

if (isset($_REQUEST['codagente'])) {
Expand Down Expand Up @@ -193,9 +191,9 @@ public function url($busqueda = FALSE)
. "&hasta=" . $this->hasta;

return $url;
} else {
return parent::url();
}

return parent::url();
}

public function paginas()
Expand Down Expand Up @@ -247,7 +245,7 @@ private function delete_albaran()
* no tocamos, porque sigue estando ese otro albarán.
* (las facturas pueden agrupar albaranes).
*/
if ($linea->referencia AND ( is_null($linea->idalbaran) OR $linea->idalbaran == $alb1->idalbaran)) {
if ($linea->referencia && ( is_null($linea->idalbaran) || $linea->idalbaran == $alb1->idalbaran)) {
$art0 = $articulo->get($linea->referencia);
if ($art0) {
$art0->sum_stock($alb1->codalmacen, 0 - $linea->cantidad, TRUE, $linea->codcombinacion);
Expand All @@ -270,10 +268,12 @@ private function delete_albaran()

if ($alb1->delete()) {
$this->clean_last_changes();
} else
} else {
$this->new_error_msg("¡Imposible eliminar el " . FS_ALBARAN . "!");
} else
}
} else {
$this->new_error_msg("¡" . FS_ALBARAN . " no encontrado!");
}
}

private function share_extension()
Expand Down
10 changes: 5 additions & 5 deletions controller/compras_factura.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected function private_core()
*/
$this->mostrar_boton_pagada = TRUE;
foreach ($this->extensions as $ext) {
if ($ext->type == 'config' AND $ext->text == 'no_button_pagada') {
if ($ext->type == 'config' && $ext->text == 'no_button_pagada') {
$this->mostrar_boton_pagada = FALSE;
break;
}
Expand All @@ -88,7 +88,7 @@ protected function private_core()
$proveedor = new proveedor();
$this->proveedor = $proveedor->get($this->factura->codproveedor);

if (isset($_GET['gen_asiento']) AND isset($_GET['petid'])) {
if (isset($_GET['gen_asiento']) && isset($_GET['petid'])) {
if ($this->duplicated_petition($_GET['petid'])) {
$this->new_error_msg('Petición duplicada. Evita hacer doble clic sobre los botones.');
} else {
Expand Down Expand Up @@ -182,7 +182,7 @@ private function pagar($pagada = TRUE)
if (is_null($this->factura->idasiento)) {
$this->factura->pagada = $pagada;
$this->factura->save();
} else if (!$pagada AND $this->factura->pagada) {
} else if (!$pagada && $this->factura->pagada) {
/// marcar como impagada
$this->factura->pagada = FALSE;

Expand All @@ -200,14 +200,14 @@ private function pagar($pagada = TRUE)
} else {
$this->new_error_msg('Error al modificar la factura.');
}
} else if ($pagada AND ! $this->factura->pagada) {
} else if ($pagada && ! $this->factura->pagada) {
/// marcar como pagada
$asiento = $this->factura->get_asiento();
if ($asiento) {
/// nos aseguramos que el proveedor tenga subcuenta en el ejercicio actual
$subpro = FALSE;
$eje = $this->ejercicio->get_by_fecha($_POST['fpagada']);
if ($eje AND $this->proveedor) {
if ($eje && $this->proveedor) {
$subpro = $this->proveedor->get_subcuenta($eje->codejercicio);
}

Expand Down
20 changes: 10 additions & 10 deletions controller/compras_facturas.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ protected function private_core()
if (isset($_GET['delete'])) {
$this->delete_factura();
} else {
if (!isset($_GET['mostrar']) AND ( $this->query != '' OR isset($_REQUEST['codagente']) OR isset($_REQUEST['codproveedor']) OR isset($_REQUEST['codserie']))) {
if (!isset($_GET['mostrar']) && ( $this->query != '' || isset($_REQUEST['codagente']) || isset($_REQUEST['codproveedor']) || isset($_REQUEST['codserie']))) {
/**
* si obtenermos un codagente, un codproveedor o un codserie pasamos direcatemente
* a la pestaña de búsqueda, a menos que tengamos un mostrar, que
Expand All @@ -120,11 +120,9 @@ protected function private_core()
$this->mostrar = 'buscar';
}

if (isset($_REQUEST['codproveedor'])) {
if ($_REQUEST['codproveedor'] != '') {
$pro0 = new proveedor();
$this->proveedor = $pro0->get($_REQUEST['codproveedor']);
}
if (isset($_REQUEST['codproveedor']) && $_REQUEST['codproveedor'] != '') {
$pro0 = new proveedor();
$this->proveedor = $pro0->get($_REQUEST['codproveedor']);
}

if (isset($_REQUEST['codagente'])) {
Expand Down Expand Up @@ -194,9 +192,9 @@ public function url($busqueda = FALSE)
. "&hasta=" . $this->hasta;

return $url;
} else {
return parent::url();
}

return parent::url();
}

public function paginas()
Expand Down Expand Up @@ -392,10 +390,12 @@ private function delete_factura()
}

$this->clean_last_changes();
} else
} else {
$this->new_error_msg("¡Imposible eliminar la factura!");
} else
}
} else {
$this->new_error_msg("Factura no encontrada.");
}
}

public function orden()
Expand Down
Loading

0 comments on commit afb14f9

Please sign in to comment.