[Contratti Acquisto]

- Ottenimento costo e sconti da listinoacquisto + Possibilità di modificare mediatore e vettore
- Modifiche Minori e Pulizia Codice
This commit is contained in:
2021-12-06 11:56:27 +01:00
parent 549540d9a7
commit a62aedaa99
6 changed files with 80 additions and 70 deletions

View File

@@ -91,21 +91,17 @@ class ContrattiDiAcquisto {
return $ret;
}
public static function searchMediatore($data, $codVage = null) {
public static function searchMediatore($data) {
$ret = new Ret();
$q = trim(strtolower($data["q"]));
if (strlen($q) > 0 || $codVage) {
if (strlen($q) > 0 ) {
$query = new Query();
$query->importSqlFile("search-mediatore");
if ($codVage) {
$query->where("cod_vage = '$codVage'");
} else {
$query->where("cod_vage+';'+rag_soc LIKE '%[Q]%'")
->setVar("Q", str_replace("'", "''", $q));
}
$query->where("cod_vage+' '+rag_soc LIKE '%[Q]%'")
->setVar("Q", str_replace("'", "''", $q));
$ret = $query->toRet()->execute();
} else {
@@ -127,7 +123,7 @@ class ContrattiDiAcquisto {
if ($codVvet) {
$query->where("cod_vvet = '$codVvet'");
} else {
$query->where("cod_vvet+';'+rag_soc LIKE '%[Q]%'")
$query->where("cod_vvet+' '+rag_soc LIKE '%[Q]%'")
->setVar("Q", str_replace("'", "''", $q));
}
@@ -156,6 +152,17 @@ class ContrattiDiAcquisto {
return $ret;
}
public static function searchPrezzo($data)
{
$query = new Query();
$query->importSqlFile("search-prezzo")
->setVar("cod_alis", $data["cod_alis"])
->setVar("cod_mart", $data["cod_mart"]);
return $query->toRet()->firstRow()->execute();
}
public static function saveOfferta($data) {
if (empty($data["codAnag"])) {
$ret = new Ret();

View File

@@ -20,6 +20,9 @@ if (isset($_GET["popupOfferta"])) {
} else if (isset($_GET["searchArticolo"])) {
$data = Utility::sanitizeB64JSON_parse($_GET["searchArticolo"]);
ContrattiDiAcquisto::searchArticolo($data)->display();
} else if (isset($_GET["searchPrezzo"])) {
$data = Utility::sanitizeB64JSON_parse($_GET["searchPrezzo"]);
ContrattiDiAcquisto::searchPrezzo($data)->display();
} else if (isset($_POST["saveOfferta"])) {
$data = Utility::sanitizeB64JSON_parse($_POST["saveOfferta"]);
ContrattiDiAcquisto::saveOfferta($data)->display();

View File

@@ -34,6 +34,16 @@ if ($ret->is_OK()) {
<input type="hidden" id="codAnag" name="codAnag" value="<?= $testataOfferta["cod_anag"] ?>">
</div>
<div class="col-xs-12 col-md-2">
<div>
Listino
</div>
<div class="font-weight-bold">
<?= $testataOfferta["cod_alis"] ?> - <?= $testataOfferta["descrizione_lisa"] ?>
</div>
</div>
<?php } else { ?>
<div class="col-xs-12 col-md-3">
<label for="searchCodAnag">
@@ -45,63 +55,27 @@ if ($ret->is_OK()) {
</div>
<?php } ?>
<?php if ($editMode) { ?>
<div class="col-xs-12 col-md-2">
<div>
Listino
</div>
<div class="col-xs-12 col-md-2">
<label for="searchCodVage">
Mediatore
</label>
<div class="font-weight-bold">
<?= $testataOfferta["cod_alis"] ?> - <?= $testataOfferta["descrizione_lisa"] ?>
</div>
</div>
<?php } ?>
<input type="hidden" id="codVage" name="codVage"
value="<?= $testataOfferta["cod_vage"] ?>">
<input type="text" class="form-control" id="searchCodVage" name="searchCodVage"
value="<?= $testataOfferta["rag_soc_age"] ?>">
</div>
<?php if ($editMode && $testataOfferta["cod_vage"]) { ?>
<div class="col-xs-12 col-md-2">
<div>
Mediatore
</div>
<div class="col-xs-12 col-md-2">
<label for="searchCodVvet">
Vettore
</label>
<div class="font-weight-bold">
<?= $testataOfferta["cod_vage"] ?> - <?= $testataOfferta["rag_soc_age"] ?>
</div>
<input type="hidden" id="codVage" name="codVage" value="<?= $testataOfferta["cod_vage"] ?>">
</div>
<?php } else { ?>
<div class="col-xs-12 col-md-2">
<label for="searchCodVage">
Mediatore
</label>
<input type="hidden" id="codVage" name="codVage">
<input type="text" class="form-control" id="searchCodVage" name="searchCodVage">
</div>
<?php } ?>
<?php if ($editMode && $testataOfferta["cod_vvet"]) { ?>
<div class="col-xs-12 col-md-2">
<div>
Vettore
</div>
<div class="font-weight-bold">
<?= $testataOfferta["cod_vvet"] ?> - <?= $testataOfferta["rag_soc_vet"] ?>
</div>
<input type="hidden" id="codVvet" name="codVvet" value="<?= $testataOfferta["cod_vvet"] ?>">
</div>
<?php } else { ?>
<div class="col-xs-12 col-md-2">
<label for="searchCodVvet">
Vettore
</label>
<input type="hidden" id="codVvet" name="codVvet">
<input type="text" class="form-control" id="searchCodVvet" name="searchCodVvet">
</div>
<?php } ?>
<input type="hidden" id="codVvet" name="codVvet"
value="<?= $testataOfferta["cod_vvet"] ?>">
<input type="text" class="form-control" id="searchCodVvet" name="searchCodVvet"
value="<?= $testataOfferta["rag_soc_vet"] ?>">
</div>
<?php if ($editMode) { ?>
<div class="col-xs-12 col-md-4">
@@ -189,7 +163,7 @@ if ($ret->is_OK()) {
<?php
$html = Utility\Str::remove_multiple_spaces(ob_get_clean());
$html = ob_get_clean();
$ret->set_string($html);
}

View File

@@ -94,7 +94,7 @@ PopupOfferta.prototype.open = function () {
}
})
.content(popupRet.returnString)
.gridSize({xs: 12, sm: 10})
.gridSize({xs: 12})
.style(self.isEditMode() ? "primary" : "success")
.backhash()
.onClose(function () {
@@ -415,7 +415,14 @@ PopupOfferta.prototype.open = function () {
],
columnDefs: [
{type: "non-empty-string", targets: [0, 1, 2]},
{className: "max-width-100px vertical-middle", targets: [2, 3]},
{
className: "max-width-100px vertical-middle",
targets: [2, 3]
},
{
width: "43px",
targets: [7, 8, 9, 10, 11]
},
{className: "vertical-middle", targets: "_all"}
],
rowCallback(row, data) {
@@ -458,7 +465,26 @@ PopupOfferta.prototype.open = function () {
data.arrUntMisAcq.push(result.unt_mis3);
}
row.data(data).draw();
new Ajax()
.get("searchPrezzo")
.data({
cod_alis: self._codAlis,
cod_mart: data.cod_mart
})
.onSuccess(function (ret) {
result = ret.returnData;
if (result) {
data.prz_acq = result.prz_acq;
data.perc_1 = result.perc_1;
data.perc_2 = result.perc_2;
data.perc_3 = result.perc_3;
data.perc_4 = result.perc_4;
}
row.data(data).draw();
}).execute();
}
});

View File

@@ -6,6 +6,4 @@ WHERE mtb_aart.cod_mart + ';' + mtb_aart.descrizione LIKE '%[q]%'
mtb_aart.cod_mgrp IN (SELECT *
FROM Dbo.ParseStringIntoArray(
(SELECT dbo.getGestSetupUser('[userName]', 'PVM', 'PIANO_ARRIVI',
'FILTRO_GRP_MERC')), '|')))
'FILTRO_GRP_MERC')), '|')))

View File

@@ -0,0 +1,2 @@
SELECT *
FROM dbo.getListinoAcquisto(NULL, '[cod_alis]', NULL, '[cod_mart]', 'S', NULL) lis_a