Skip to content

Commit

Permalink
- Now we can set a default text to print for every business document.
Browse files Browse the repository at this point in the history
- Now we can filter print formats by company.
  • Loading branch information
NeoRazorX committed Oct 7, 2019
1 parent cc8a155 commit d4fbdd5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
8 changes: 6 additions & 2 deletions Core/Controller/ListFormatoDocumento.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ protected function createFormatView($viewName = 'ListFormatoDocumento')
$this->addSearchFields($viewName, ['titulo', 'texto']);
$this->addOrderBy($viewName, ['id'], 'id');
$this->addOrderBy($viewName, ['titulo'], 'title');

/// Filters
$companies = $this->codeModel->all('empresas', 'idempresa', 'nombrecorto');
$this->addFilterSelect($viewName, 'idempresa', 'company', 'idempresa', $companies);
}

/**
Expand All @@ -68,8 +72,8 @@ protected function createSequenceView($viewName = 'ListSecuenciaDocumento')
$this->addOrderBy($viewName, ['numero'], 'number');

/// Filters
$warehouses = $this->codeModel->all('empresas', 'idempresa', 'nombre');
$this->addFilterSelect($viewName, 'idempresa', 'company', 'idempresa', $warehouses);
$companies = $this->codeModel->all('empresas', 'idempresa', 'nombrecorto');
$this->addFilterSelect($viewName, 'idempresa', 'company', 'idempresa', $companies);

$exercises = $this->codeModel->all('ejercicios', 'codejercicio', 'nombre');
$this->addFilterSelect($viewName, 'codejercicio', 'exercise', 'codejercicio', $exercises);
Expand Down
3 changes: 2 additions & 1 deletion Core/Lib/Export/MAILExport.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@

use FacturaScripts\Core\Model\Base\BusinessDocument;
use FacturaScripts\Core\Model\Base\ModelClass;
use FacturaScripts\Dinamic\Lib\Export\PDFExport as ParentClass;
use Symfony\Component\HttpFoundation\Response;

/**
* Description of MAILExport
*
* @author Carlos García Gómez <carlos@facturascripts.com>
*/
class MAILExport extends PDFExport
class MAILExport extends ParentClass
{

/**
Expand Down
15 changes: 9 additions & 6 deletions Core/Lib/PDF/PDFDocument.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,15 @@ protected function getDivisaName($code): string
protected function getDocumentFormat($model)
{
$documentFormat = new FormatoDocumento();
$where = [
new DataBaseWhere('tipodoc', $model->modelClassName()),
new DataBaseWhere('idempresa', $model->idempresa)
];
foreach ($documentFormat->all($where, ['codserie' => 'DESC']) as $format) {
if ($format->codserie == $model->codserie || null === $format->codserie) {
$where = [new DataBaseWhere('idempresa', $model->idempresa)];
foreach ($documentFormat->all($where, ['tipodoc' => 'DESC', 'codserie' => 'DESC']) as $format) {
if ($format->tipodoc === $model->modelClassName() && $format->codserie === $model->codserie) {
return $format;
} elseif ($format->tipodoc === $model->modelClassName() && $format->codserie === null) {
return $format;
} elseif ($format->tipodoc === null && $format->codserie === $model->codserie) {
return $format;
} elseif ($format->tipodoc === null && $format->codserie === null) {
return $format;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Core/XMLView/EditFormatoDocumento.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<widget type="text" fieldname="id" onclick="EditFormatoDocumento" />
</column>
<column name="doc-type" numcolumns="3" order="110">
<widget type="select" fieldname="tipodoc" translate="true" required="true">
<widget type="select" fieldname="tipodoc" translate="true">
<values title="customer-estimation">PresupuestoCliente</values>
<values title="customer-order">PedidoCliente</values>
<values title="customer-delivery-note">AlbaranCliente</values>
Expand Down

0 comments on commit d4fbdd5

Please sign in to comment.