include ('inc/init.php');
include("customer_edit_inc/buyerwishs.php");
var_postget ('customer_id');
var_postget ('cue');
$data = $bug_data = array ();
if (isset ($cue))
{
$data['customer_post_class_id'] = $_POST['customer_post_class_id'];
$data['customer_post_id'] = $_POST['customer_post_id'];
$data['customer_priority_id'] = $_POST['customer_priority_id'];
$data['company_name'] = $_POST['company_name'];
chk_var ('surname', 'string', 1, 80, 'Kérem, adja meg a vezetéknevét!');
chk_var ('secname', 'string', 0, 80);
chk_var ('forename', 'string', 1, 80, 'Kérem, adja meg a keresztnevét!');
chk_var ('phone', 'phone', 0, 0, 'Kérem, érvényes telefonszámot adjon meg!');
chk_var ('mobil', 'phone', 0, 0, 'Kérem, érvényes mobilszámot adjon meg!');
if (empty ($data['phone']) && empty ($data['mobil']) && empty ($bug_data['phone']) && empty ($bug_data['mobil']))
$bug_data['phone'] = $bug_data['mobil'] = 'Kérem, mindenképpen adjon meg egy telefonszámot!';
chk_var ('fax', 'phone', 0, 0, 'Amennyiben megad faxszámot, kérem, ügyeljen a helyességére!');
chk_var ('email', 'email', 0, 220, 'Amennyiben megad e-mail címet, kérem, ügyeljen a helyességére!');
$data['web'] = $_POST['web'];
chk_var ('address', 'string', 0, 240, 'Kérem, adja meg az ügyfél címét!');
chk_var ('city', 'string', 0, 120, 'Kérem, adja meg az ügyfél városát!');
chk_var ('zip', 'string', 0, 16, 'Kérem, adja meg az ügyfél riányítószámát!');
$data['state'] = $_POST['state'];
$data['country'] = $_POST['country'];
chk_var ('customer_status_id', 'whole', 1, 15, 'Kérem, adja meg az ügyfél státuszát');
$data['customer_status_id'] = $_POST['customer_status_id'];
$data['customer_source_id'] = $_POST['customer_source_id'];
if ($data['customer_source_id'] < 1 ) $bug_data[customer_source_id]='Kérem, adja meg, honnan jött az ügyfél';
$data['customer_source_other'] = $_POST['customer_source_other'];
if ( $data['customer_source_id']=='5' && strlen($data['customer_source_other']) < 2 ) $bug_data[customer_source_other]='Ha egyéb forrásból jött, kérem írja be honnan.';
$data['contact1_name'] = $_POST['contact1_name'];
$data['contact1_post'] = $_POST['contact1_post'];
chk_var ('contact1_phone', 'phone', 0, 0, 'Amennyiben megad telefonszámot, kérem, ügyeljen a helyességére!');
$data['contact2_name'] = $_POST['contact2_name'];
$data['contact2_post'] = $_POST['contact2_post'];
chk_var ('contact2_phone', 'phone', 0, 0, 'Amennyiben megad telefonszámot, kérem, ügyeljen a helyességére!');
$data['contact3_name'] = $_POST['contact3_name'];
$data['contact3_post'] = $_POST['contact3_post'];
chk_var ('contact3_phone', 'phone', 0, 0, 'Amennyiben megad telefonszámot, kérem, ügyeljen a helyességére!');
chk_var ('home_phone', 'phone', 0, 0, 'Amennyiben megad telefonszámot, kérem, ügyeljen a helyességére!');
chk_var ('home_mobil', 'phone', 0, 0, 'Amennyiben megad mobilszámot, kérem, ügyeljen a helyességére!');
chk_var ('home_fax', 'phone', 0, 0, 'Amennyiben megad faxszámot, kérem, ügyeljen a helyességére!');
chk_var ('home_email', 'email', 0, 220, 'Amennyiben megad e-mail címet, kérem, ügyeljen a helyességére!');
if ( $cue == 'mod' )
{
var_postget ('answ1');
var_postget ('answ2');
var_postget ('answ3');
var_postget ('answ4');
var_postget ('answ5');
var_postget ('answ6');
if ( $answ1 == '' ) $bug_data[answ1]='Kérem töltse ki a mezőt!';
if ( $answ2 == '' ) $bug_data[answ2]='Kérem töltse ki a mezőt!';
if ( $answ3 == '' ) $bug_data[answ3]='Kérem töltse ki a mezőt!';
if ( $answ4 == '' ) $bug_data[answ4]='Kérem töltse ki a mezőt!';
if ( $answ5 == '' ) $bug_data[answ5]='Kérem töltse ki a mezőt!';
if ( $answ6 == '' ) $bug_data[answ6]='Kérem töltse ki a mezőt!';
}
$data['home_address'] = $_POST['home_address'];
$data['home_city'] = $_POST['home_city'];
$data['home_zip'] = $_POST['home_zip'];
$data['home_state'] = $_POST['home_state'];
$data['home_country'] = $_POST['home_country'];
$data['note'] = $_POST['note'];
if (empty ($data['phone']) && empty ($data['mobil']) && empty ($data['home_phone']) && empty ($data['home_mobil']))
$bug_data['customer_phone'] = 'Kérem, legalább egy telefomszámot adjon meg!';
if (empty ($bug_data['phone']) && ! empty ($data['phone'])) {
$cid = my_ff ("
select
id
from
customer
where
phone = '$data[phone]'
and act = 'enabled'
and customer_status_id in (0, 2, 3, 7)
");
$cid2 = my_ff ("
select
customer.id as id
from
customer
inner join
process_customer_mod
on process_customer_mod.customer_id=customer.id
where
customer.phone = '$data[phone]'
and customer.act = 'enabled'
and process_customer_mod.user_id='$_SESSION[user_id]'
and customer_status_id in (0, 2, 3, 7)
");
if (($cid>0) && ($cid!=$customer_id) && empty($cid2) ) {
?>
die ();
}
unset ($cid);
}
if (empty ($bug_data['mobil']) && ! empty ($data['mobil'])) {
$cid = my_ff ("
select
id
from
customer
where
mobil = '$data[mobil]'
and act = 'enabled'
and customer_status_id in (0, 2, 3, 7)
");
$cid2 = my_ff ("
select
customer.id as id
from
customer
inner join
process_customer_mod
on process_customer_mod.customer_id=customer.id
where
customer.mobil = '$data[mobil]'
and customer.act = 'enabled'
and process_customer_mod.user_id='$_SESSION[user_id]'
and customer_status_id in (0, 2, 3, 7)
");
if (($cid>0) && ($cid!=$customer_id) && empty($cid2)) {
?>
die ();
}
unset ($cid);
}
if (! is_bug ($bug_data))
{
switch ($cue)
{
#
case 'add':
$customer_id = my_quid ("
insert into customer
(
customer_post_class_id,
customer_post_id,
customer_priority_id,
company_name,
surname,
secname,
forename,
phone,
mobil,
fax,
email,
web,
address,
city,
zip,
state,
country,
customer_status_id,
customer_source_id,
contact1_name,
contact1_post,
contact1_phone,
contact2_name,
contact2_post,
contact2_phone,
contact3_name,
contact3_post,
contact3_phone,
home_phone,
home_mobil,
home_fax,
home_email,
home_address,
home_city,
home_zip,
home_state,
home_country,
note,
customer_source_other,
type
)
values
(
'$data[customer_post_class_id]',
'$data[customer_post_id]',
'$data[customer_priority_id]',
'$data[company_name]',
'$data[surname]',
'$data[secname]',
'$data[forename]',
'$data[phone]',
'$data[mobil]',
'$data[fax]',
'$data[email]',
'$data[web]',
'$data[address]',
'$data[city]',
'$data[zip]',
'$data[state]',
'$data[country]',
'$data[customer_status_id]',
'$data[customer_source_id]',
'$data[contact1_name]',
'$data[contact1_post]',
'$data[contact1_phone]',
'$data[contact2_name]',
'$data[contact2_post]',
'$data[contact2_phone]',
'$data[contact3_name]',
'$data[contact3_post]',
'$data[contact3_phone]',
'$data[home_phone]',
'$data[home_mobil]',
'$data[home_fax]',
'$data[home_email]',
'$data[home_address]',
'$data[home_city]',
'$data[home_zip]',
'$data[home_state]',
'$data[home_country]',
'$data[note]',
'$data[customer_source_other]',
'customer'
)
");
userlog ('Felvett ügyfelet.');
break;
#
case 'mod':
$mod_sql="
update customer set
customer_post_class_id = '$data[customer_post_class_id]',
customer_post_id = '$data[customer_post_id]',
customer_priority_id = '$data[customer_priority_id]',
company_name = '$data[company_name]',
surname = '$data[surname]',
secname = '$data[secname]',
forename = '$data[forename]',
phone = '$data[phone]',
mobil = '$data[mobil]',
fax = '$data[fax]',
email = '$data[email]',
web = '$data[web]',
address = '$data[address]',
city = '$data[city]',
zip = '$data[zip]',
state = '$data[state]',
country = '$data[country]',
customer_status_id = '$data[customer_status_id]',
customer_source_id = '$data[customer_source_id]',
contact1_name = '$data[contact1_name]',
contact1_post = '$data[contact1_post]',
contact1_phone = '$data[contact1_phone]',
contact2_name = '$data[contact2_name]',
contact2_post = '$data[contact2_post]',
contact2_phone = '$data[contact2_phone]',
contact3_name = '$data[contact3_name]',
contact3_post = '$data[contact3_post]',
contact3_phone = '$data[contact3_phone]',
home_phone = '$data[home_phone]',
home_mobil = '$data[home_mobil]',
home_fax = '$data[home_fax]',
home_email = '$data[home_email]',
home_address = '$data[home_address]',
home_city = '$data[home_city]',
home_zip = '$data[home_zip]',
home_state = '$data[home_state]',
home_country = '$data[home_country]',
note = '$data[note]',
customer_source_other = '$data[customer_source_other]'
where
id = '$customer_id'
";
$mod_res=my_query($mod_sql);
$bqid=my_ff("SELECT id FROM customer_questions WHERE customer_id='$customer_id'");
if ( $bqid>0 )
my_query ("update customer_questions set answ1='$answ1', answ2='$answ2', answ3='$answ3', answ4='$answ4', answ5='$answ5', answ6='$answ6' WHERE customer_id='$customer_id' and id='$bqid'");
else
my_query ("insert into customer_questions ( customer_id, answ1, answ2, answ3, answ4, answ5, answ6 ) values ( '$customer_id', '$answ1', '$answ2', '$answ3', '$answ4', '$answ5', '$answ6' )");
//echo "$mod_sql
";
//echo "$mod_res, customer_status_id = {$data['customer_status_id']}";
userlog ('Módosított ügyfelet.');
break;
}
#
// save buyerwish
save_wishdata();
//echo "{$data['customer_status_id']}";
my_query ("insert into process_customer_mod (moment, customer_id, user_id) values (NOW(), '$customer_id', '$_SESSION[user_id]')");
header ('Location: after.php');
}
}
elseif (isset ($customer_id))
{
$data = my_array ("select * from customer where id = '$customer_id'");
list ($data['phone_pre'], $data['phone_num']) = explode ('-', $data['phone']);
list ($data['mobil_pre'], $data['mobil_num']) = explode ('-', $data['mobil']);
list ($data['fax_pre'], $data['fax_num']) = explode ('-', $data['fax']);
list ($data['contact1_phone_pre'], $data['contact1_phone_num']) = explode ('-', $data['contact1_phone']);
list ($data['contact2_phone_pre'], $data['contact2_phone_num']) = explode ('-', $data['contact2_phone']);
list ($data['contact3_phone_pre'], $data['contact3_phone_num']) = explode ('-', $data['contact3_phone']);
list ($data['home_phone_pre'], $data['home_phone_num']) = explode ('-', $data['home_phone']);
list ($data['home_mobil_pre'], $data['home_mobil_num']) = explode ('-', $data['home_mobil']);
list ($data['home_fax_pre'], $data['home_fax_num']) = explode ('-', $data['home_fax']);
}
#
?>
Ügyfél - Central Home Hungary
Ügyfél = isset ($customer_id) && $_POST['cue'] != 'add' ? 'módosítása' : 'felvétele' ?> |