Skip to content

Commit

Permalink
devel/codeclenup: small refactoring of telecentrum callcenter v2 scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
interduo committed Jun 18, 2023
1 parent 2b84047 commit 5cb85ea
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 80 deletions.
86 changes: 46 additions & 40 deletions contrib/tele.centrum.v2/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@

error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);

$uid = isset($_GET['id']) ? intval($_GET['id']) : null;
$agentnr = isset($_GET['agentnr']) ? intval($_GET['agentnr']) : null;

require_once('..' . DIRECTORY_SEPARATOR . 'initLMS.php');
require_once('lib' . DIRECTORY_SEPARATOR . 'definitions.php');

$uid = intval($_GET['id']);
$phone = intval($_GET['phone']);
$agentnr = intval($_GET['agentnr']);
if (!empty($_GET['phone'])) {
$phone = intval($_GET['phone']);
$ticket['phone'] = $phone;
} else {
$phone = null;
}

$ticket['phonetype'] = 'on';

$newticket_subject = ConfigHelper::getConfig(
Expand Down Expand Up @@ -63,35 +70,39 @@
array($phone)
);
// prepare result to put in js
$js_result = json_encode($result, JSON_UNESCAPED_UNICODE);
if (!empty($result)) {
$js_result = json_encode($result, JSON_UNESCAPED_UNICODE);
} else {
$js_result = null;
}
}

if (!empty($_POST)) {
$ticket = $_POST;

if (empty($ticket['phone'])) {
$ticket['phone'] = $ticket['contactphone'];
$ticket['phone'] = empty($ticket['contactphone']) ? null : $ticket['contactphone'];
}

// simple form validation
if ($ticket['body'] == '' && $ticket['queue'] == 1) {
if (isset($ticket['body']) && $ticket['body'] == '' && $ticket['queue'] == 1) {
$error['body'] = 'Podaj treść zgłoszenia!';
}

if ($ticket['name'] == '') {
if (isset($ticket['name']) && $ticket['name'] == '') {
$error['name'] = 'Podaj imię i nazwisko/nazwę klienta!';
}

if ($ticket['address'] == '') {
if (isset($ticket['address']) && $ticket['address'] == '') {
$error['address'] = 'Podaj adres instalacji z którą jest problem!';
}

if ($ticket['phone'] == '') {
if (isset($ticket['phone']) && $ticket['phone'] == '') {
$error['phone'] = 'Podaj telefon do kontaktu ze zgłaszającym usterkę!';
}

// continue if no error found
if (!$error) {
if (!isset($error) || empty($error)) {
if (!$agentnr || !isset($agents[$agentnr])) {
$agent = 'Brak informacji';
} else {
Expand All @@ -105,10 +116,10 @@
// if valid user found in db
if (isset($ticket['othercustomer']) || empty($result)) {
$ticket['customerid'] = null;
if ($ticket['odblokowanie_komunikatu'] == 'tak') {
if (isset($ticket['odblokowanie_komunikatu']) && $ticket['odblokowanie_komunikatu'] == 'tak') {
$ticket['requestor'] = $ticket['name'] . ', ' . $ticket['address'];
$ticket['body'] = 'Prośba o odblokowanie internetu.' . PHP_EOL . 'Agent: ' . $agent . PHP_EOL . 'Numer kontaktowy: ' . $ticket['contactphone'];
} elseif ($ticket['kontakt'] == 'tak') {
} elseif (isset($ticket['kontakt']) && $ticket['kontakt'] == 'tak') {
$ticket['requestor'] = $ticket['name'].', '.$ticket['address'];
$ticket['body'] = 'Prośba o kontakt z ofertą handlową.' . PHP_EOL . 'Agent: '.$agent . PHP_EOL .'Numer kontaktowy: ' . $ticket['contactphone'];
} else {
Expand All @@ -130,22 +141,17 @@
}
}
$ticket['subject'] = $newticket_subject;
// set real quque id
if ($ticket['queue'] == 1) {
$ticket['queue'] = $queues[0];
} elseif ($ticket['queue'] == 2) {
$ticket['queue'] = $queues[1];
} elseif ($ticket['queue'] == 3) {
$ticket['queue'] = $queues[2];
}
$queue = $CUSTOMER_ISSUES[$ticket['queue']]['queueid'];

$firstservice = empty($ticket['service']) ? null : array_shift(array_slice($ticket['service'], 0, 1));

//insert ticket
$DB->Execute(
'INSERT INTO rttickets (queueid, customerid, requestor, subject,
state, owner, createtime, cause, source, creatorid)
VALUES (?, ?, ?, ?, ?, ?, ?NOW?, ?, ?, ?)',
state, owner, createtime, cause, source, creatorid, type, service)
VALUES (?, ?, ?, ?, ?, ?, ?NOW?, ?, ?, ?, ?, ?)',
array(
$ticket['queue'],
$queue,
$ticket['customerid'],
$ticket['requestor'],
$ticket['subject'],
Expand All @@ -154,6 +160,8 @@
RT_CAUSE_OTHER,
RT_SOURCE_CALLCENTER,
$user_id,
$CUSTOMER_ISSUES[$ticket['queue']]['ticket_type'],
$firstservice,
)
);
$id = $DB->GetLastInsertID('rttickets');
Expand All @@ -170,20 +178,16 @@
)
);

if (isset($ticket['internet'])) {
$DB->Execute('INSERT INTO rtticketcategories (ticketid, categoryid) VALUES (?, ?)', array($id, $categories[0]));
}
if (isset($ticket['tv'])) {
$DB->Execute('INSERT INTO rtticketcategories (ticketid, categoryid) VALUES (?, ?)', array($id, $categories[1]));
}
if (isset($ticket['telefon'])) {
$DB->Execute('INSERT INTO rtticketcategories (ticketid, categoryid) VALUES (?, ?)', array($id, $categories[2]));
}
if (is_null($ticket['internet']) && is_null($ticket['tv']) && is_null($ticket['telefon'])) {
$DB->Execute('INSERT INTO rtticketcategories (ticketid, categoryid) VALUES (?, ?)', array($id, $categories[3]));
}
$ticket['service'] = empty($ticket['service']) ? array($default_category) : $ticket['service'];

$queue = $ticket['queue'];
foreach ($ticket['service'] as $idx => $t) {
if (isset($CUSTOMER_VISIBLE_SERVICETYPES[$idx]['categoryid'])) {
$DB->Execute(
'INSERT INTO rtticketcategories (ticketid, categoryid) VALUES (?, ?)',
array($id, $t)
);
}
}

if (ConfigHelper::checkConfig(
'rt.new_ticket_notify',
Expand Down Expand Up @@ -257,7 +261,7 @@
}

if ($id) {
$msg = 'Zgłoszenie zostoło dodane.';
$msg = 'Zgłoszenie o numerze ' . $id . ' zostało dodane.';
$ticket = array();
} else {
$msg = 'Wystąpił błąd. Nie dodano zgłoszenia!';
Expand All @@ -271,12 +275,14 @@
$SMARTY->assign(array(
'welcomeMsg' => $welcomeMsg,
'warning' => $warning,
'result' => $result,
'js_result' => $js_result,
'_CUSTOMER_ISSUES' => $CUSTOMER_ISSUES,
'_CUSTOMER_VISIBLE_SERVICETYPES' => $CUSTOMER_VISIBLE_SERVICETYPES,
'result' => isset($result) ? $result : null,
'js_result' => isset($js_result) ? $js_result : null,
'information' => $information,
'ticket' => $ticket,
'phone' => $phone,
'error' => $error
'error' => !empty($error) ? $error : null,
));

$SMARTY->display('index.html');
60 changes: 57 additions & 3 deletions contrib/tele.centrum.v2/lib/definitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,24 @@
);

$user_id = ConfigHelper::getConfig('callcenter.queueuser');
$queues = explode(',', ConfigHelper::getConfig('callcenter.queues'));
$categories = explode(',', ConfigHelper::getConfig('callcenter.categories'));
$default_category = ConfigHelper::getConfig('callcenter.default_category');
$default_queue = ConfigHelper::getConfig('callcenter.default_queue', 1);
$warning = ConfigHelper::getConfig('callcenter.warning');
$information = ConfigHelper::getConfig('callcenter.information');
$callcenterip = ConfigHelper::getConfig('callcenter.callcenterip');
$networks = explode(",", ConfigHelper::getConfig('callcenter.networks'));

$service_internet_category = ConfigHelper::getConfig('callcenter.service_internet_category', $default_category);
$service_phone_category = ConfigHelper::getConfig('callcenter.service_phone_category', $default_category);
$service_tv_category = ConfigHelper::getConfig('callcenter.service_tv_category', $default_category);

$fault_issues_queue = ConfigHelper::getConfig('callcenter.fault_issues_queue', $default_queue);
$offer_issues_queue = ConfigHelper::getConfig('callcenter.offer_issues_queue', $default_queue);
$payment_issues_queue = ConfigHelper::getConfig('callcenter.payment_issues_queue', $default_queue);

$time = localtime(time(), true)['tm_hour'];
empty($agents[$agentnr]) ? $ag = '...' : $ag = $agents[$agentnr];

$ag = empty($agents[$agentnr]) ? '...' : $agents[$agentnr];
if ($time >= 19 or $time < 6) {
$welcomeMsg = "Dobry wieczór. Nazywam się $ag, w czym mogę pomóc?";
} else {
Expand All @@ -53,3 +62,48 @@ function ip_in_range($ip, $range)

return ( ( $ip_decimal & $netmask_decimal ) == ( $range_decimal & $netmask_decimal ) );
}

define('CUSTOMER_ISSUE_FAULT', 1);
define('CUSTOMER_ISSUE_OFFER', 2);
define('CUSTOMER_ISSUE_PAYMENT', 3);

$CUSTOMER_ISSUES = array(
CUSTOMER_ISSUE_FAULT => array(
'label' => 'Zgłoszenie awarii',
'queueid' => $fault_issues_queue,
'ticket_type' => RT_TYPE_FAULT,
),
CUSTOMER_ISSUE_OFFER => array(
'label' => 'Informacja handlowa',
'queueid' => $offer_issues_queue,
'ticket_type' => RT_TYPE_OFFER,
),
CUSTOMER_ISSUE_PAYMENT => array(
'label' => 'Sprawy finansowe',
'queueid' => $payment_issues_queue,
'ticket_type' => RT_TYPE_PAYMENT,
),
);

$CUSTOMER_VISIBLE_SERVICETYPES = array(
SERVICE_INTERNET => array(
'label' => 'Internet',
'categoryid' => $service_internet_category,
'value' => SERVICE_INTERNET,
),
SERVICE_PHONE => array(
'label' => 'Telefon',
'categoryid' => $service_phone_category,
'value' => SERVICE_PHONE,
),
SERVICE_TV => array(
'label' => 'Telewizja',
'categoryid' => $service_tv_category,
'value' => SERVICE_TV,
),
SERVICE_OTHER => array(
'label' => 'Inna',
'categoryid' => $default_category,
'value' => SERVICE_OTHER,
),
);
15 changes: 9 additions & 6 deletions contrib/tele.centrum.v2/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@ mkdir /var/www/html/lms/contrib/tele.centrum.v2/templates_c/;
chmod 755 /var/www/html/lms/contrib/tele.centrum.v2/templates_c/;
chown 48:48 /var/www/html/lms/contrib/tele.centrum.v2/templates_c/;

Uzupełniamy sekcje o zmienne:
Uzupełniamy zmienne konfiguracyjne z sekcji callcenter:
- callcenterip - podać adres IP z którego łączyć się będą agenci callcenter,
- networks - adresacja sieci, która może wyświetlać formularz callcenter np. 10.10.10.0/24 (można podać kilka sieci oddzielonych przecinkiem),
- queues - id kolejek w LMS, odzielone przecinkami.

Kolejno: Zgłoszenie awarii, informacja handlowa oraz sprawy finansowe,
- categories - id kategorii zgłoszeń w LMS, odzielone przecinkami.
- fault_issues_queue - ID kolejki helpdesk dla zgłoszeń usterek,
- offer_issues_queue - ID kolejki helpdesk dla zgłoszeń ze sprawami handlowymi,
- payment_issues_queue - ID kolejki helpdesk dla zgłoszeń ze sprawami księgowymi,

- service_internet_category - kategoria nadawana zgłoszeniom które dotyczą usługi internet
- service_phone_category - kategoria nadawana zgłoszeniom które dotyczą usługi telefon
- service_tv_category - kategoria nadawana zgłoszeniom które dotyczą usługi telewizja
- default_category - domyślna kategoria, która zostanie nadana zgłoszeniu bez przypisanej usługi

Kolejno: Internet, telewizja, telefon oraz ogólna,
(UWAGA! ZACHOWANIE KOLEJNOŚCI JEST WYMAGANE DO POPRAWNEGO DZIAŁANIA.)
- queueuser - id użytkownika do którego ma być przypisane zgłoszenie (może być 0),
- warning - treść wiadomości specjalnej wyświetlanej na górze strony,
- information - możliwość dodanie dodatkowych informacji do wysuwającego się panelu (np. tabela z godzinami pracy).
Expand Down
56 changes: 25 additions & 31 deletions contrib/tele.centrum.v2/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
</colgroup>
<tr>
<td colspan="2" class="center">
<span style="font-size: 5;">
<span>
<strong>System zgłoszeń</strong>
</span>
<span style="font-size: 3;">
<span>
<br>
Dla operatorów E-Południe Call Center
<br>
Expand All @@ -51,7 +51,7 @@
</tr>
{/if}
<tr>
<td >Przedstawienie się</td>
<td>Przedstawienie się</td>
<td class="center">
{$welcomeMsg}
</td>
Expand All @@ -60,9 +60,9 @@
<td>Określ temat rozmowy</td>
<td class="center">
<select name="queue" form="ticket" onchange="typ_zgloszenia(this.value)">
<option value="1">Zgłoszenie awarii</option>
<option value="2">Informacja handlowa</option>
<option value="3">Sprawy finansowe</option>
{foreach $_CUSTOMER_ISSUES as $idx => $i}
<option value="{$idx}">{$i.label}</option>
{/foreach}
</select>
</td>
</tr>
Expand All @@ -71,21 +71,14 @@
Wybierz usługę która uległa awarii
</td>
<td class="center">
<label>
<input type="checkbox" form="ticket" name="internet"
{if $ticket.internet} checked{/if} value="Internet">
Internet
</label>
<label>
<input type="checkbox" form="ticket" name="tv"
{if $ticket.tv} checked{/if} value="TV">
Telewizja
</label>
<label>
<input type="checkbox" form="ticket" name="telefon"
{if $ticket.telefon} checked{/if} value="telefon">
Telefon
</label>
{foreach $_CUSTOMER_VISIBLE_SERVICETYPES as $idx => $s}
<label>
<input type="checkbox" form="ticket" name="service[]"
{if !empty($ticket.service) && in_array($idx, $ticket.service)} checked{/if}
value="{$idx}">{$s.label}
</label>
{/foreach}
<br>
<br>
Czy urządzenie końcowe jest podłączone do zasilania?<br>
Czy świecą się na nim jakieś diody?<br>
Expand All @@ -98,8 +91,9 @@
</td>
<td class="center">
Proszę podać informację co dokładnie się dzieje?<br>
<input type="text" name="body" form="ticket" value="{$ticket.body}"
autofocus {if $error.body} class="error"{/if} size="80">

<textarea type="text" name="body" form="ticket" value="{if isset($ticket.body)}{$ticket.body}{/if}" placeholder="Opis usterki"
autofocus {if isset($error.body)} class="error"{/if} style="width: 550px; height:100px;">{if isset($ticket.body)}{$ticket.body}{/if}</textarea>
</td>
</tr>
<tr id="informacjahandlowa" style="display:none;">
Expand Down Expand Up @@ -189,30 +183,30 @@
{/if}

Proszę podać imię, nazwisko osoby na którą zawarta jest umowa.<br>
<input type="text" name="name" form="ticket" value="{$ticket.name}" autofocus
{if $error.name} class="error"{/if} size="80">
<input type="text" name="name" form="ticket" value="{if isset($ticket.name)}{$ticket.name}{/if}" autofocus
{if isset($error.name)} class="error"{/if} size="80" placeholder="Dane klienta z umowy">
<br><br>

Proszę podać adres instalacji<br>
<input type="text" name="address" form="ticket" value="{$ticket.address}"
{if $error.address} class="error"{/if} autofocus size="80">
<input type="text" name="address" form="ticket" value="{if isset($ticket.address)}{$ticket.address}{/if}"
{if isset($error.address)} class="error"{/if} autofocus size="80" placeholder="Adres instalacji">
<br><br>

Numer telefonu dzwoniącego<br>
<input type="text" name="phone" form="ticket" readonly value="{$phone}" autofocus
{if $error.phone} class="error"{/if} size="20">
<input type="text" name="phone" form="ticket" readonly value="{if isset($ticket.phone)}{$ticket.phone}{/if}" autofocus
{if isset($error.phone)} class="error"{/if} size="20" style="background: lightgrey;">
<br><br>

<label>
<input type="checkbox" id="phonetype" form="ticket" onchange="phoneContact()"
{if empty($ticket.contactphone)} checked{/if} name="phonetype">
{if isset($ticket.contactphone) && empty($contactphone) || isset($ticket.phone)} checked{/if} name="phonetype">
Telefon kontaktowy jak numer dzwoniącego
</label>
<div id="contact_phone" {if empty($ticket.contactphone)} style="display: none;" {else} style="display: block;"{/if}>
<br>

Proszę podać telefon kontaktowy<br>
<input type="text" name="contactphone" form="ticket" value="{$ticket.contactphone}"
<input type="text" name="contactphone" form="ticket" value="{if isset($ticket.contactphone)}{$ticket.contactphone}{/if}"
autofocus size="20">
<br>
</div>
Expand Down

0 comments on commit 5cb85ea

Please sign in to comment.