'.$_nl; if($adata[err_txt])$code.='

'.$adata[err_txt].'

'.$_nl; if($_SEC['_sadmin_flg']) { if($amode=='edit'){ $code.=''; } $code.=' '.$_nl; }else $code.=''; $code.='
Nome e Cognome :
Nome ditta :

Tipo utente :
'.$_nl; if($_SEC['_sadmin_flg']) { $code.=' '.$_nl; } $code.=''.$_nl; if($_SEC['_sadmin_flg']) { $code.='
'.$_LANG['_AREA_UTENTI']['fld_1'].' :
'.$_LANG['_AREA_UTENTI']['fld_2'].' :
'.$_LANG['_AREA_UTENTI']['fld_3'].' :
'.$_LANG['_AREA_UTENTI']['fld_4'].':
'.$_LANG['_AREA_UTENTI']['fld_5'].' : '.do_select_list_countries("nazione",$adata[nazione]).'
'.$_LANG['_AREA_UTENTI']['fld_6'].':
E-mail :
'.$_LANG['_AREA_UTENTI']['fld_7'].' :
User Name :
Password :

Stato dell\'utente:  Attivo   Disattivo

'.$_nl; } else { $code.=''.$_nl; } $btns=new cToolbar(); $btns->addButton($amode=="add"?($_SEC['_sadmin_flg']?"Salva":$_LANG['_AREA_UTENTI']['btn_register']):"Salva modifiche","frm.submit()"); if($amode=="edit"){ $btns->addButton("Elimina","window.location.href='utenti.php?mode=delete&id=".$adata[id]."'"); $btns->addButton($_LANG['_AREA_UTENTI']['btn_cancel'],"frm.reset()"); }elseif($amode=='add'){ $btns->addButton($_LANG['_AREA_UTENTI']['btn_cancel'],"frm.reset()"); } $code.=$btns->draw().'

'; $code.=''; $code=do_block($code,"block_corner"); $btns=""; }else{ $ins_id=do_get_max_id("utenti")+1; if($amode=="add" || $_GET[id]=="new"){ if(!isset($_GPV[user])) { $_GPV[user]=substr($_GPV[nomecogn],0,1).substr(str_replace(array("/","'","."," ",";"),"",$_GPV[ditta]),0,1).rand(100,999); while(strlen($_GPV[user])<5)$_GPV[user].=rand(0,9); } if(!isset($_GPV[pass]))$_GPV[pass]=rand(10000,99999); $sql="INSERT INTO utenti(id,nomecogn,ditta,indirizzo,CAP,loc,prov,nazione,tel,fax,cell,sito_web,user,pass,email,type,status) VALUES("; $sql.="$ins_id,'$_GPV[nomecogn]','$_GPV[ditta]','$_GPV[indirizzo]','$_GPV[CAP]','$_GPV[loc]','$_GPV[prov]','$_GPV[nazione]','$_GPV[tel]','$_GPV[fax]','$_GPV[cell]','$_GPV[sito_web]','$_GPV[user]','$_GPV[pass]','$_GPV[email]','$_GPV[type]','$_GPV[status]')"; }else{ $sql="UPDATE utenti SET nomecogn='$_GPV[nomecogn]',ditta='$_GPV[ditta]',indirizzo='$_GPV[indirizzo]',CAP='$_GPV[CAP]',loc='$_GPV[loc]',prov='$_GPV[prov]',nazione='$_GPV[nazione]',tel='$_GPV[tel]',fax='$_GPV[fax]',cell='$_GPV[cell]',sito_web='$_GPV[sito_web]',user='$_GPV[user]',pass='$_GPV[pass]',email='$_GPV[email]',type='$_GPV[type]',status='$_GPV[status]' WHERE id=".$adata[id]; } $res=db_query_execute($sql) or die(nl2br($sql).'
'.mysql_error()); if($_SEC['_sadmin_flg']) { $descr=$res?"Il salvataggio dei dati dell'utente e avvenuto con successo.
":"Si sono verificati problemi nel salvataggio dei dati dell'utente, riprovare nuovamente. Se il problema persiste, contattare il webmaster."; $code=''; $btns=new cToolbar(); if($amode=="add"){ $btns->addButton("Invia notifica","window.location.href='".$_CCFG['_PKG_URL_BASE']."admin/utenti.php?mode=notify&id=".$ins_id."'"); $btns->addButton("Crea un nuovo utente","window.location.href='".$_CCFG['_PKG_URL_BASE']."admin/utenti.php?mode=add'"); }elseif($amode=="edit"){ $btns->addButton("Invia notifica","window.location.href='".$_CCFG['_PKG_URL_BASE']."admin/utenti.php?mode=notify&id=".$adata[id]."'"); } $code.=$btns->draw().'
'; } else { $descr=($res?$_LANG['_AREA_UTENTI']['creation_ok']:$_LANG['_AREA_UTENTI']['creation_failed'])."
"; } } $_out=do_page($title,$descr,$code,"",""); return $_out; } function DeleteUser($aid,$astage){ global $_CCFG; $btns=new cToolbar(16); $title="Elimina utente"; if($astage==1 || !isset($astage)){ $sql="SELECT nomecogn FROM utenti WHERE id=$aid LIMIT 1"; $res=db_query_execute($sql); $adata=mysql_fetch_array($res); $descr='Sei sicuro di voler rimuovere l\'utente "'.$adata[nomecogn].'" ?

'; $code='
'; $btns->addButton("Elimina utente","frm.submit()"); $btns->addButton("Torna a utenti","window.location.href='".$_CCFG['_PKG_URL_BASE']."admin/utenti.php'"); }else{ $sql="DELETE FROM utenti WHERE id=$aid LIMIT 1"; $res=db_query_execute($sql); $descr='L\'utente selezionato e stato eliminato in modo definitivo.

'; $code=''; $btns->addButton("Amministra","window.location.href='".$_CCFG['_PKG_URL_BASE']."admin/index.php'"); $btns->addButton("Torna alla Homepage","window.location.href='".$_CCFG['_PKG_URL_BASE']."index.php'"); } $_out=do_page($title,$descr,$code,"",$btns); return $_out; } function NotifyUser($aid,$astage){ global $_GPV,$_POST,$_CCFG,$_nl; $btns=new cToolbar(16); $title="Notifica utente"; if($astage==1 || !isset($astage)){ $sql="SELECT * FROM utenti WHERE id=$aid LIMIT 1"; $res=db_query_execute($sql); $adata=mysql_fetch_array($res); $descr='Messaggio di notifica all\'utente "'.$adata[nomecogn].'".

'; $code='
'.$_nl; $code.=''.$_nl; $code.=''.$_nl; $code.=''.$_nl; $code.=''.$_nl; $code.=''.$_nl; $code.='
Mitente :
Destinatario :'.do_select_list_users("id",$aid,true).'
Oggetto :
Messaggio :
'.$_nl; $code.='
'.$_nl; $btns->addButton("Notifica","frm.submit()"); $btns->addButton("Torna a utenti","window.location.href='".$_CCFG['_PKG_URL_BASE']."admin/utenti.php'"); }else{ switch(true){ case $aid=="tutti":$sql="SELECT * FROM utenti";break; case is_numeric($aid):$sql="SELECT * FROM utenti WHERE id='$aid' LIMIT 1";break; default:$sql="SELECT * FROM utenti WHERE type='$aid'"; } $res=db_query_execute($sql); $i=0; $mail['message']=stripslashes($_POST[msg]); $mail['subject']=$_POST[subject]; $mail['from'] =$_CCFG[_COMPANY_NAME].' <'.$_POST[from].'>'; while($data=mysql_fetch_array($res))if($data[email]){ $mail['recip']=$data[email]; $_ret=do_mail_basic($mail); if(!$_ret)$i++; } $descr='Messaggio inviato con successo '.($i==1?'all\'utente':'a '.$i.' utenti').'.

'; $code=''; $btns->addButton("Amministra","window.location.href='".$_CCFG['_PKG_URL_BASE']."admin/index.php'"); $btns->addButton("Torna alla Homepage","window.location.href='".$_CCFG['_PKG_URL_BASE']."index.php'"); } $_out=do_page($title,$descr,$code,"",$btns); return $_out; } # Get security vars $_SEC = get_security_flags(); IF ( !$_SEC['_sadmin_flg'] && $_GPV[mode]!='view' && $_GPV[mode]!='add') { # Set login flag $_login_flag = 1; # Call function for clients listings $_out = ''.$_nl; $_out .= do_login($data, 'admin', '1').$_nl; $title="Login"; } $amode = $_GPV[mode]?$_GPV[mode]:'add'; $astage = $_GPV[stage]; $adata=$_GPV; if($_GPV[user]=='new' || $_GPV[company]=='new')$amode='add'; #Checking if the NomeCogn already exists if(($amode=="add" || $_GET[id]=="new") && $astage>1) { $res=db_query_execute("SELECT * FROM utenti WHERE nomecogn='$_GPV[nomecogn]'"); if(db_query_numrows($res)>0){ $adata[err_txt]=$_LANG['_AREA_UTENTI']['creation_duplicate']; $astage--; } } IF ( $_SEC['_sadmin_flg']) { if($amode=='add' || $amode=='edit'){ if($amode=='edit'){ $res="SELECT * FROM utenti WHERE id=".$_GPV[id]." LIMIT 1"; $adata=mysql_fetch_array(mysql_query($res)); $title="Modifica utente"; } elseif($amode=='add') { $title="Aggiungi utente"; } $_out=AddEditUsers($adata,$amode,$astage); } elseif($amode=='delete') { $title="Elimina utente"; $_out=DeleteUser($_GPV[id],$_GPV[stage]); } elseif($amode=='notify') { $title="Notifica utente"; $_out=NotifyUser($_GPV[id],$_GPV[stage]); } } else { if($amode=='add' || $amode=='edit') { if($amode=='edit'){ $res="SELECT * FROM utenti WHERE id=".$_GPV[id]." LIMIT 1"; $adata=mysql_fetch_array(mysql_query($res)); $title="Modifica utente"; } elseif($amode=='add') { $title="Aggiungi utente"; } $_out=AddEditUsers($adata,$amode,$astage); } } echo do_page_content($_out,$title); ?>