Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvement: allow to show assignment names in customer search results (print version) #2466

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/locale/pl_PL/strings.php
Original file line number Diff line number Diff line change
Expand Up @@ -5625,6 +5625,8 @@

$_LANG['$a selected contacts of $b customers'] = '$a wybranych kontaktów spośród $b klientów';
$_LANG['show customer list'] = 'pokaż listę klientów';
$_LANG['show assignment names'] = 'pokaż nazwy zobowiązań';
$_LANG['assignment names'] = 'nazwy zobowiązań';
$_LANG['hide customer list'] = 'ukryj listę klientów';

$_LANG['Cannot open event - event closed too long ago.'] = 'Nie można otworzyć zdarzenia - zostało ono zamknięte zbyt dawno.';
Expand Down
245 changes: 137 additions & 108 deletions modules/customersearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,18 @@
}
}

if (!isset($search)) {
$SESSION->restore('customersearch', $search);
} else {
if (isset($search)) {
$SESSION->save('customersearch', $search);
} else {
$SESSION->restore('customersearch', $search);
}

if (!empty($search['balance_date'])) {
$time = intval($search['balance_date']);
$time = (int) $search['balance_date'];
}

if (isset($search['balance_days'])) {
if (strlen($search['balance_days'])) {
$days = intval($search['balance_days']);
} else {
$days = -1;
}
$days = strlen($search['balance_days']) !== 0 ? (int) $search['balance_days'] : -1;
}

if (!isset($_GET['o'])) {
Expand All @@ -64,61 +60,71 @@
}
$SESSION->save('cslo', $order);

if (!isset($_POST['s'])) {
$SESSION->restore('csls', $state);
} else {
if (isset($_POST['s'])) {
$state = $_POST['s'];
} else {
$SESSION->restore('csls', $state);
}
$SESSION->save('csls', $state);

if (!isset($_POST['sk'])) {
$SESSION->restore('cslsk', $statesqlskey);
} else {
if (isset($_POST['sk'])) {
$statesqlskey = $_POST['sk'];
} else {
$SESSION->restore('cslsk', $statesqlskey);
}
$SESSION->save('cslsk', $statesqlskey);

if (!isset($_POST['flags'])) {
$SESSION->restore('cslf', $flags);
} else {
if (isset($_POST['flags'])) {
$flags = $_POST['flags'];
} else {
$SESSION->restore('cslf', $flags);
}
$SESSION->save('cslf', $flags);

if (!isset($_POST['hidessn'])) {
if (isset($_POST['hidessn'])) {
$hidessn = (int) $_POST['hidessn'];
} else {
$SESSION->restore('cshidessn', $hidessn);
if (!isset($hidessn)) {
$hidessn = 1;
}
} else {
$hidessn = intval($_POST['hidessn']);
}
$SESSION->save('cshidessn', $hidessn);

if (!isset($_POST['fk'])) {
$SESSION->restore('cslfk', $flagsqlskey);
if (isset($_POST['showassignments'])) {
$showassignments = (int) $_POST['showassignments'];
} else {
$SESSION->restore('csshowassignments', $showassignments);
if (!isset($showassignments)) {
$showassignments = 1;
}
}
$SESSION->save('csshowassignments', $showassignments);

if (!isset($_POST['fk'])) {
$flagsqlskey = $_POST['fk'];
} else {
$SESSION->restore('cslfk', $flagsqlskey);
}
$SESSION->save('cslfk', $flagsqlskey);

if (!isset($_POST['consents'])) {
$SESSION->restore('csconsents', $consents);
} else {
if (isset($_POST['consents'])) {
$consents = $_POST['consents'];
} else {
$SESSION->restore('csconsents', $consents);
}
$SESSION->save('csconsents', $consents);

if (!isset($_POST['karma'])) {
$SESSION->restore('cslkarma', $karma);
} else {
if (isset($_POST['karma'])) {
$karma = $_POST['karma'];
} else {
$SESSION->restore('cslkarma', $karma);
}
$SESSION->save('cslkarma', $karma);

if (!isset($_POST['n'])) {
$SESSION->restore('csln', $network);
} else if ($_POST['n'] == 'all') {
} elseif ($_POST['n'] == 'all') {
$network = array();
} else {
$network = Utils::filterIntegers($_POST['n']);
Expand All @@ -127,56 +133,54 @@

if (!isset($_POST['g'])) {
$SESSION->restore('cslg', $customergroup);
} else if ($_POST['g'] == 'all') {
} elseif ($_POST['g'] == 'all') {
$customergroup = array();
} elseif (count($_POST['g']) == 1 && (int) $_POST['g'][0] <= 0) {
$customergroup = reset($_POST['g']);
} else {
if (count($_POST['g']) == 1 && intval($_POST['g'][0]) <= 0) {
$customergroup = reset($_POST['g']);
} else {
$customergroup = $_POST['g'];
}
$customergroup = $_POST['g'];
}
$SESSION->save('cslg', $customergroup);

if (!isset($_POST['cgk'])) {
$SESSION->restore('cslcgk', $customergroupsqlskey);
} else {
if (isset($_POST['cgk'])) {
$customergroupsqlskey = $_POST['cgk'];
} else {
$SESSION->restore('cslcgk', $customergroupsqlskey);
}
$SESSION->save('cslcgk', $customergroupsqlskey);

if (!isset($_POST['cgnot'])) {
$SESSION->restore('cslcgnot', $customergroupnegation);
} else {
if (isset($_POST['cgnot'])) {
$customergroupnegation = !empty($_POST['cgnot']);
} else {
$SESSION->restore('cslcgnot', $customergroupnegation);
}
$SESSION->save('cslcgnot', $customergroupnegation);

if (!isset($_POST['k'])) {
$SESSION->restore('cslk', $sqlskey);
} else {
if (isset($_POST['k'])) {
$sqlskey = $_POST['k'];
} else {
$SESSION->restore('cslk', $sqlskey);
}
$SESSION->save('cslk', $sqlskey);

if (!isset($_POST['ng'])) {
$SESSION->restore('cslng', $nodegroup);
} else {
if (isset($_POST['ng'])) {
$nodegroup = $_POST['ng'];
} else {
$SESSION->restore('cslng', $nodegroup);
}
$SESSION->save('cslng', $nodegroup);

if (!isset($_POST['ngnot'])) {
$SESSION->restore('cslngnot', $nodegroupnegation);
} else {
if (isset($_POST['ngnot'])) {
$nodegroupnegation = !empty($_POST['ngnot']);
} else {
$SESSION->restore('cslngnot', $nodegroupnegation);
}
$SESSION->save('cslngnot', $nodegroupnegation);

if (!isset($_POST['d'])) {
$SESSION->restore('csld', $division);
} else {
if (isset($_POST['d'])) {
$division = $_POST['d'];
} else {
$SESSION->restore('csld', $division);
}
$SESSION->save('csld', $division);

Expand Down Expand Up @@ -209,51 +213,69 @@
"division"
));

$listdata['total'] = $customerlist['total'];
$listdata['direction'] = $customerlist['direction'];
$listdata['order'] = $customerlist['order'];
$listdata['below'] = $customerlist['below'];
$listdata['over'] = $customerlist['over'];
$listdata['state'] = $state;
$listdata['flags'] = $flags;
$listdata['hidessn'] = $hidessn;
$listdata['karma'] = $karma;
$listdata['network'] = $network;
$listdata['customergroup'] = empty($customergroup) ? array() : $customergroup;
$listdata['nodegroup'] = $nodegroup;
$listdata['division'] = $division;

unset($customerlist['total']);
unset($customerlist['state']);
unset($customerlist['flags']);
unset($customerlist['karma']);
unset($customerlist['direction']);
unset($customerlist['order']);
unset($customerlist['below']);
unset($customerlist['over']);

if (! isset($_GET['page'])) {
$listdata = array(
'total' => $customerlist['total'],
'direction' => $customerlist['direction'],
'order' => $customerlist['order'],
'below' => $customerlist['below'],
'over' => $customerlist['over'],
'state' => $state,
'flags' => $flags,
'hidessn' => $hidessn,
'showassignments' => $showassignments,
'karma' => $karma,
'network' => $network,
'customergroup' => empty($customergroup) ? array() : $customergroup,
'nodegroup' => $nodegroup,
'division' => $division
);

unset(
$customerlist['total'],
$customerlist['state'],
$customerlist['flags'],
$customerlist['karma'],
$customerlist['direction'],
$customerlist['order'],
$customerlist['below'],
$customerlist['over']
);

if ($showassignments) {
foreach ($customerlist as $idx => $c) {
$ca = $LMS->GetCustomerAssignments($c['id'], false, false);
if (isset($ca)) {
$customerlist[$idx]['assignmentsnames'] = implode(",", array_column($ca, 'name'));
}
}
}

if (!isset($_GET['page'])) {
$SESSION->restore('cslp', $_GET['page']);
}

$page = (! $_GET['page'] ? 1 : $_GET['page']);
$page = $_GET['page'] ?? 1;
$pagelimit = ConfigHelper::getConfig('phpui.customerlist_pagelimit', $listdata['total']);
$start = ($page - 1) * $pagelimit;

$SESSION->save('cslp', $page);

$SMARTY->assign('customerlist', $customerlist);
$SMARTY->assign('listdata', $listdata);
$SMARTY->assign('pagelimit', $pagelimit);
$SMARTY->assign('page', $page);
$SMARTY->assign('start', $start);
$SMARTY->assign(
array(
'customerlist' => $customerlist,
'listdata' => $listdata,
'pagelimit' => $pagelimit,
'page' => $page,
'start' => $start
)
);

if (isset($_GET['print'])) {
$SMARTY->display('print/printcustomerlist.html');
} elseif (isset($_GET['export'])) {
$SMARTY->assign('contactlist', $DB->GetAllByKey(
'SELECT customerid, (' . $DB->GroupConcat('contact') . ') AS phone
FROM customercontacts WHERE contact <> \'\' AND type & ? > 0 GROUP BY customerid',
FROM customercontacts WHERE contact <> \'\' AND type & ? > 0 GROUP BY customerid',
'customerid',
array(CONTACT_MOBILE | CONTACT_LANDLINE)
));
Expand All @@ -273,31 +295,38 @@
} else {
$layout['pagetitle'] = trans('Customer Search');

$listdata['state'] = $state;
$listdata['flags'] = $flags;
$listdata['hidessn'] = $hidessn;
$listdata['karma'] = $karma;
$listdata['network'] = $network;
$listdata['customergroup'] = empty($customergroup) ? array() : $customergroup;
$listdata['nodegroup'] = $nodegroup;
$listdata['division'] = $division;

$SMARTY->assign('listdata', $listdata);
$listdata = array(
'state' => $state,
'flags' => $flags,
'hidessn' => $hidessn,
'showassignments' => $showassignments,
'karma' => $karma,
'network' => $network,
'customergroup' => empty($customergroup) ? array() : $customergroup,
'nodegroup' => $nodegroup,
'division' => $division
);

$SESSION->remove('cslp');

$SMARTY->assign('networks', $LMS->GetNetworks());
$SMARTY->assign('customergroups', $LMS->CustomergroupGetAll());
$SMARTY->assign('nodegroups', $LMS->GetNodeGroupNames());
$SMARTY->assign('cstateslist', $LMS->GetCountryStates());
$SMARTY->assign('tariffs', $LMS->GetTariffs());
$SMARTY->assign('divisions', $LMS->GetDivisions());
$SMARTY->assign('k', $sqlskey);
$SMARTY->assign('sk', $statesqlskey);
$SMARTY->assign('cgk', $customergroupsqlskey);
$SMARTY->assign('cgnot', $customergroupnegation);
$SMARTY->assign('fk', $flagsqlskey);
$SMARTY->assign('ngnot', $nodegroupnegation);
$SMARTY->assign('karma', $karma);
$SMARTY->assign(
array(
'listdata' => $listdata,
'networks' => $LMS->GetNetworks(),
'customergroups' => $LMS->CustomergroupGetAll(),
'nodegroups' => $LMS->GetNodeGroupNames(),
'cstateslist' => $LMS->GetCountryStates(),
'tariffs' => $LMS->GetTariffs(),
'divisions' => $LMS->GetDivisions(),
'k' => $sqlskey,
'sk' => $statesqlskey,
'cgk' => $customergroupsqlskey,
'cgnot' => $customergroupnegation,
'fk' => $flagsqlskey,
'ngnot' => $nodegroupnegation,
'karma' => $karma
)
);

$SMARTY->display('customer/customersearch.html');
}
12 changes: 12 additions & 0 deletions templates/default/customer/customersearch.html
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,18 @@ <H1>{$layout.pagetitle}</H1>
{if !empty($listdata.hidessn) || !isset($listdata.hidessn)} checked{/if}>
</td>
</tr>
<tr>
<td class="bold nobr">
<label for="showassignments">
{icon name="id" label="show assignment names"}
</label>
</td>
<td>
<input type="hidden" name="showassignments" value="0">
<input type="checkbox" name="showassignments" id="showassignments" value="1"
{if !empty($listdata.showassignments)} checked{/if}>
</td>
</tr>
<TR>
<TD class="bold nobr">
{icon name="customer"} {trans("First/last or Company name:")}
Expand Down
Loading