Non puoi selezionare più di 25 argomenti
Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
252 righe
11 KiB
252 righe
11 KiB
<? |
|
$configPath = substr(__DIR__,0,strpos(__DIR__,"/public_html"))."/config.php"; |
|
include_once($configPath); |
|
$error = true; |
|
|
|
if (!empty($_SESSION["utente"]) && $_SESSION["utente"]->permission($radice) && $_SESSION["utente"]->permission("mercato")) { |
|
|
|
$breadcrumb = array(); |
|
$breadcrumb["/".$radice."/"] = Modulo::getInfo($radice)["titolo"]; |
|
$breadcrumb[""] = __("Visualizza Carrello"); |
|
|
|
include_once ($beRoot."/layout/top.php"); |
|
|
|
if(!empty(Market::getOeInMercato())){ |
|
$error = false; |
|
?> |
|
<div class="container-fluid pt-5 pb-3"> |
|
<div class="row"> |
|
<div class="col-12"> |
|
<h2> |
|
<i class="fas fa-shopping-cart"></i> |
|
<?= __('Carrello') ?> |
|
</h2> |
|
</div> |
|
</div> |
|
</div> |
|
<? |
|
|
|
$producsInCart = Market::getProductsInCart(); |
|
if (!empty($producsInCart['prodotti']) ) { |
|
|
|
// variabile utilizzata per i controlli nel javascript |
|
$purchasable = Market::getPurchasableProductsInCart()['prodotti']; |
|
|
|
?> |
|
<div class="container-fluid"> |
|
<div class="row"> |
|
<div class="card col-12"> |
|
<div class="card-body"> |
|
<div class="table-responsive"> |
|
<h2 id="table-title"></h2> |
|
<table class="table table-striped table-hover" id="tab-data" width="100%"> |
|
<thead> |
|
<tr> |
|
<th class=""><?= __("ID") ?></th> |
|
<th class=""><?= __("Denominazione") ?></th> |
|
<th class=""><?= __("Marca") ?></th> |
|
<th class=""><?= __("Fornitore") ?></th> |
|
<th class=""><?= __("Quantita") ?></th> |
|
<th class="text-end " width="10%"><?= __("Prezzo") ?> <?= __("iva esclusa") ?></th> |
|
<th class=""></th> |
|
<th class=""></th> |
|
</tr> |
|
</thead> |
|
<tbody> |
|
<? |
|
$totale = 0; |
|
foreach ($producsInCart['prodotti'] as $key => $record) { |
|
$show = ($record['attivo'] == 'S') ? true : false; |
|
|
|
$oe = oeManager::getOE($record['codice_oe']); |
|
if(empty($record['newVersion']) && $record['attivo'] == 'S'){ |
|
$prezzo = $record['prezzo'] * $record['quantita']; |
|
$totale += $prezzo; |
|
} |
|
|
|
?> |
|
<tr> |
|
<td class=""> |
|
<?= $record["idVenditore"] ?> |
|
</td> |
|
|
|
<td style="width:30%"> |
|
<?= $record["denominazione"] ?> |
|
</td> |
|
|
|
<td class=""> |
|
<?= $record["brand"] ?> |
|
</td> |
|
|
|
<td class=""> |
|
<a href="#" onClick="showCompany(<?= $oe["codice"] ?>);"><?= $oe["ragione_sociale"] ?></a> |
|
</td> |
|
|
|
<!-- controlla se esiste una nuova versione del prodotto --> |
|
<? if(empty($record['newVersion']) && $record['attivo'] === 'S'){ ?> |
|
<td class=""> |
|
<form rel="validate" method="post" action="/backend/marketplace/add-product.php"> |
|
<input id="token" type="hidden" name="token" value="<?= tokenGen() ?>"> |
|
<input type="hidden" name="replace" value="TRUE"> |
|
<input id="codice_prodotto" type="hidden" name="codice_prodotto" value="<?= $record["codice_prodotto"] ?>"> |
|
<input id="codice_oe" type="hidden" name="codice_oe" value="<?= $record["codice_oe"] ?>"> |
|
|
|
<div class="input-group w-50" role="group"> |
|
<input class=" form-control" type="number" |
|
<? if(!empty($record['ordineMinimo'])){?> min="<?=$record['ordineMinimo']?>" <?}?> |
|
<? if(!empty($record['ordineMassimo'])){?> max="<?=$record['ordineMassimo']?>" <?}?> |
|
value="<?= $record['quantita'] ?>" |
|
onchange="$(this).next().slideDown()" |
|
name="quantita" |
|
title="<?= __("quantita") ?>" |
|
onkeypress='return event.charCode >= 48 && event.charCode <= 57' |
|
oninvalid="InvalidMsg(this);" oninput="InvalidMsg(this);" |
|
> |
|
<span class="input-group-btn" style="display:none"> |
|
<button class="btn btn-md btn-primary replace-cart"> |
|
<span class="fa fa-sync"></span> |
|
<span class="sr-only"> |
|
<?= __("aggiorna") ?></span> |
|
</button> |
|
</span> |
|
</div> |
|
</form> |
|
</td> |
|
|
|
<td> |
|
<?= $record['prezzo'] ?> |
|
</td> |
|
<? }else{ ?> |
|
|
|
<td colspan="2" class="text-center"> |
|
<small class="d-block"><?= __('Prodotto non Disponibile') ?></small> |
|
|
|
<? if($show){ ?> |
|
<a href="show.php?codice=<?=$record['newVersion']?>&codice_oe=<?=$record['codice_oe']?>" title="<?= __("Vedi scheda aggiornata") ?>"> |
|
<?= __("Vedi scheda aggiornata") ?> |
|
</a> |
|
<? } ?> |
|
|
|
</td> |
|
<? } ?> |
|
|
|
<td style="width:1px"> |
|
<? if($show){ ?> |
|
<a href='show.php?codice=<?= $record["codice_prodotto"] ?>&codice_oe=<?=$record['codice_oe']?>' title='<?= __("visualizza") ?>' class='btn btn-info btn-sm'><span class='fa fa-search'></span></a> |
|
<? } ?> |
|
</td> |
|
|
|
<td style="width:1px"> |
|
<button title='<?= __("elimina") ?>' class='btn btn-sm btn-danger' onclick='elimina(<?= $record["codice"] ?>,"/marketplace");'><span class='fa fa-times'></span></button> |
|
</td> |
|
|
|
</tr> |
|
<? |
|
} |
|
?> |
|
</tbody> |
|
<? if ($totale > 0) { ?> |
|
<tfoot> |
|
<tr> |
|
<th colspan="5" class="text-right"><?= __("totale") ?></th> |
|
<th class="text-end">€ <?= number_format($totale,2,",","."); ?></th> |
|
<th colspan="2"></th> |
|
</tr> |
|
</tfoot> |
|
<? } ?> |
|
</table> |
|
</div> |
|
|
|
<div class="d-flex justify-content-end align-items-end my-2"> |
|
<? |
|
$enti = $_SESSION["utente"]->getEntiBeneficiari(); |
|
if(!empty($enti)){ |
|
?> |
|
<div class="form-group col-12 col-lg-4 mx-2 mb-0"> |
|
<label for="codice_beneficiario"><?= __("Beneficiario") ?>* </label> |
|
<select name="codice_beneficiario" class="form-control" title="<?= __("Beneficiario") ?>" rel="S;0;0;N" id="codice_beneficiario"> |
|
<option value=""><?= __("Seleziona") ?>...</option> |
|
<? |
|
foreach($enti AS $ente) { |
|
$selected = ""; |
|
if ($record["codice_ente"]==$ente["codice"]) { $selected = "selected"; } |
|
?> |
|
<option <?= $selected ?> value="<?= $ente["codice"] ?>"><?= $ente["denominazione"] ?></option> |
|
<? |
|
} |
|
?> |
|
</select> |
|
</div> |
|
<? } ?> |
|
|
|
<button |
|
onclick="showModalWithURL('/backend/marketplace/ordine.php?codice_beneficiario='+$('#codice_beneficiario').val());" |
|
class="btn btn-primary py-2 px-3 btn-genera-ordine" disabled> |
|
<?= __("Genera ordine") ?> |
|
</button> |
|
</div> |
|
</div> |
|
</div> |
|
</div> |
|
</div> |
|
|
|
<script> |
|
|
|
function InvalidMsg(textbox) { |
|
var value = textbox.value |
|
var min = textbox.min |
|
var max = textbox.max |
|
|
|
if(min != '' && min != undefined && Number(value) < Number(min)){ |
|
textbox.setCustomValidity('<?= __("La quantità Minima ordinabile per questo prodotto è di ") ?>' + min); |
|
}else if(max != '' && max != undefined && Number(value) > Number(max)){ |
|
textbox.setCustomValidity('<?= __("La quantità Massima ordinabile per questo prodotto è di ") ?>' + max); |
|
}else { |
|
textbox.setCustomValidity(''); |
|
} |
|
} |
|
|
|
$(function(){ |
|
var purchasable = <?= json_encode($purchasable) ?>; |
|
$('#codice_beneficiario').on('change.select2', function(){ |
|
if( $(this).val() == '' ){ |
|
$('.btn-genera-ordine').prop('disabled', true); |
|
}else{ |
|
if(purchasable.length > 0){ |
|
$('.btn-genera-ordine').prop('disabled', false); |
|
} |
|
} |
|
}) |
|
}) |
|
</script> |
|
<? |
|
} else { |
|
?> |
|
<div class="row"> |
|
<div class="col-12"> |
|
<? alertManager::printWarningBox(__("Nessun Prodotto nel Carrello")); ?> |
|
</div> |
|
</div> |
|
<? |
|
} |
|
|
|
}else{ |
|
?> |
|
<div class="row"> |
|
<div class="col-12"> |
|
<? alertManager::printWarningBox(__("Nessun Qualifica del Mercato Elettronica Attiva")); ?> |
|
</div> |
|
</div> |
|
<? |
|
} |
|
|
|
include_once ($beRoot."/layout/bottom.php"); |
|
} |
|
|
|
|
|
if($error){ |
|
echo '<meta http-equiv="refresh" content="0;URL=/index.php">'; |
|
die(); |
|
} |
|
|
|
?>
|