191 lines
5.8 KiB
PHP
191 lines
5.8 KiB
PHP
|
|
|
|
<?php
|
|
include_once(__DIR__."/../../core.php");
|
|
include($docroot."/config.inc.php");
|
|
|
|
|
|
$module_name = 'Prospect';
|
|
$iddocumento = $html->form('iddocumento');
|
|
|
|
$filtra_art = $html->form('filtra_art');
|
|
|
|
|
|
|
|
$query = "SELECT * FROM mg_articoli WHERE attivo=1 ORDER BY id_categoria ASC, id_sottocategoria ASC";
|
|
$rs = $dbo->fetchArray( $query );
|
|
$n = sizeof($rs);
|
|
|
|
echo "<label>Inserimento interesse Prospect</label><br><br>\n";
|
|
echo "<form id=\"link_form\" action=\"".$rootdir."/editor.php?id_module=".$modules_info[$module_name]['id']."&id_record=".$iddocumento."\" method=\"post\">\n";
|
|
echo " <input type='hidden' name='op' value='add_interesse'>\n";
|
|
echo " <input type='hidden' name='dir' value='".$dir."'>\n";
|
|
echo " <input type='hidden' name='iddocumento' value='".$iddocumento."'>\n";
|
|
echo " <input type='hidden' name='backto' value='record-edit'>\n";
|
|
|
|
echo " <div class='row'>\n";
|
|
|
|
|
|
//Seleziona articolo
|
|
echo " <div class='col-md-6'>\n";
|
|
echo " <label>Articolo</label>\n";
|
|
|
|
|
|
if( $n==0 ){
|
|
echo " "._("Non ci sono articoli")."\n";
|
|
echo " <input type=\"hidden\" id=\"idarticolo\" value=\"0\">\n";
|
|
}
|
|
|
|
else{
|
|
|
|
$other_js = '';
|
|
|
|
|
|
//Elenco articoli raggruppati per gruppi e sottogruppi
|
|
echo " <select id=\"idarticolo\" name=\"idarticolo\" class=\"superselectajax\" data-source=\"articoli_filtro\" onchange=\"$('#prezzi').html(''); $('#qta').keyup(); $.get( '".$rootdir."/ajax_autocomplete.php?module=Articoli&op=getlotti&idarticolo='+$(this).find('option:selected').val(), function(data){ $('#lotto').html(data); update_jchosen('#lotto'); }); $('textarea[name=descrizione]').val( $(this).find('option:selected').attr('descrizione') ); $other_js\">\n";
|
|
|
|
|
|
echo " <option value=\"0\">- Seleziona un articolo -</option>\n";
|
|
for( $i=0; $i<$n; $i++ ){
|
|
if( $rs[$i-1]['categoria'] != $rs[$i]['categoria'] ){
|
|
echo " <optgroup label='".$rs[$i]['categoria']."'>\n";
|
|
}
|
|
|
|
if( $rs[$i-1]['subcategoria'] != $rs[$i]['subcategoria'] ){
|
|
echo " <optgroup label=' ".$rs[$i]['subcategoria']."'>\n";
|
|
}
|
|
//Cerco listino personalizzato
|
|
$rslist = $dbo->fetchArray("SELECT prc_guadagno FROM mg_listini_art WHERE idlistino='".$id_listino."' and idarticolo='".$rs[$i]['id']."'");
|
|
if( $rslist[0]['prc_guadagno'] <> '0' && sizeof($rslist)>0 ){
|
|
$prc_guadagno_new = - $rslist[0]['prc_guadagno'];
|
|
}
|
|
else{
|
|
$prc_guadagno_new = -$prc_guadagno;
|
|
}
|
|
|
|
if( $dir == 'entrata' ){
|
|
echo " <option value=\"".$rs[$i]['id']."\" sconto='".$prc_guadagno_new."' idconto_riga='".$rs[$i]['id_conto']."' qta_magazzino='".floatval($rs[$i]['qta'])."' prezzo=\"".floatval($rs[$i]['prezzo_vendita'])."\" guadagno=\"".($rs[$i]['prezzo_vendita']/100*$prc_guadagno)."\" idiva=\"".intval($rs[$i]['idiva_vendita'])."\" descrizione=\"".$rs[$i]['descrizione']."\">".$rs[$i]['codice']." - ".$rs[$i]['descrizione']." (".floatval($rs[$i]['qta']).")</option>\n";
|
|
}
|
|
else{
|
|
echo " <option value=\"".$rs[$i]['id']."\" sconto='".$prc_guadagno_new."' idconto_riga='".$rs[$i]['id_conto']."' qta_magazzino='".floatval($rs[$i]['qta'])."' prezzo=\"".floatval($rs[$i]['prezzo_acquisto'])."\" guadagno=\"".($rs[$i]['prezzo_vendita']/100*$prc_guadagno)."\" idiva=\"".intval($rs[$i]['idiva_vendita'])."\" descrizione=\"".$rs[$i]['descrizione']."\">".$rs[$i]['codice']." - ".$rs[$i]['descrizione']." (".floatval($rs[$i]['qta']).")</option>\n";
|
|
}
|
|
|
|
|
|
if( $rs[$i]['categoria'] != $rs[$i+1]['categoria'] ){
|
|
echo " </optgroup>\n";
|
|
}
|
|
|
|
if( $rs[$i]['subcategoria'] != $rs[$i+1]['subcategoria'] ){
|
|
echo " </optgroup>\n";
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
echo " </select>\n";
|
|
echo " </div>\n";
|
|
|
|
//Fltra per Categoria
|
|
$query = "SELECT * FROM mg_categorie where parent='0' order by nome";
|
|
$rs_cat = $dbo->fetchArray($query);
|
|
echo " <div class='col-md-4'>\n";
|
|
echo " <label>Categoria articolo</label>\n";
|
|
echo " <select id='idcategoria' class='superselect' name=\"idcategoria\">\n";
|
|
echo " <option value='0'>Nessun Filtro</option>\n";
|
|
for( $i=0; $i<sizeof($rs); $i++ ){
|
|
echo " <option value='".$rs_cat[$i]['id']."' $attr>".$rs_cat[$i]['nome']."</option>\n";
|
|
}
|
|
echo " </select>\n";
|
|
echo " </div>\n";
|
|
|
|
|
|
|
|
|
|
|
|
echo " </div>\n";
|
|
|
|
|
|
|
|
|
|
echo "<script type=\"text/javascript\" charset=\"utf-8\" src=\"".$rootdir."/lib/ckeditor/ckeditor.js\"></script>\n";
|
|
|
|
//Descrizione
|
|
echo " <div class='row'>\n";
|
|
echo " <div class='col-md-12'>\n";
|
|
echo " <label>Descrizione</label>\n";
|
|
echo " <textarea placeholder=\"\" rows='20' name='descrizione' rows='20' id='descrizione_art' class='form-control'></textarea>\n";
|
|
echo " </div>\n";
|
|
|
|
echo " </div>\n";
|
|
|
|
|
|
echo "<br>";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
dir = '<?php echo $dir ?>';
|
|
|
|
$('#idcategoria').change( function(){
|
|
$.get('<?php echo $rootdir ?>/ajax_autocomplete.php?module=FiltroCat&idcategoria='+this.value+'&idmodulo='+id_module , function(data,response){
|
|
start_jquerychosen();
|
|
start_inputmask();
|
|
});
|
|
});
|
|
|
|
function addarticolo(){
|
|
if( $('#idarticolo').val()!='' ){
|
|
$("#link_form").submit();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function addarticolo_vendita(){
|
|
if( $('#idarticolo').val()!='' ){
|
|
$("#link_form").submit();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
$(document).ready( function(){
|
|
|
|
CKEDITOR.replace( 'descrizione_art', {
|
|
toolbar: [
|
|
{ name: 'document', items: [ 'NewPage', 'Preview', '-', 'Templates' ] },
|
|
['Bold','Italic','Underline','Superscript','-','NumberedList','BulletedList','Outdent','Indent','Blockquote','-','Format',], // Defines toolbar group without name.
|
|
|
|
]
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
</script>
|
|
<script src="<?php echo $rootdir; ?>/lib/init.js"></script>
|
|
|
|
|
|
<?php
|
|
|
|
|
|
echo "<a onclick=\"addarticolo_vendita();\" class=\"btn btn-primary pull-right\"><i class=\"fa fa-plus\"></i> Aggiungi</a>\n";
|
|
|
|
echo "</form>\n";
|
|
|
|
?>
|
|
|
|
<div class="clearfix"></div>
|
|
|
|
|