Skip to content
Open

fix #133

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
28 changes: 14 additions & 14 deletions simpla/ajax/export_users.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
class ExportAjax extends Simpla
{
private $columns_names = array(
'name'=> '���',
'name'=> 'Èìÿ',
'email'=> 'Email',
'group_name'=> '������',
'discount'=> '������',
'enabled'=> '�������',
'created'=> '����',
'last_ip'=> '��������� IP'
'group_name'=> 'Ãðóïïà',
'discount'=> 'Ñêèäêà',
'enabled'=> 'Àêòèâåí',
'created'=> 'Äàòà',
'last_ip'=> 'Ïîñëåäíèé IP'
);

private $column_delimiter = ';';
Expand All @@ -24,24 +24,24 @@ public function fetch()
if(!$this->managers->access('users'))
return false;

// ������ ������ ������ 1251
// Ýêñåëü êóøàåò òîëüêî 1251
setlocale(LC_ALL, 'ru_RU.1251');
$this->db->query('SET NAMES cp1251');

// ��������, ������� ������������
// Ñòðàíèöà, êîòîðóþ ýêñïîðòèðóåì
$page = $this->request->get('page');
if(empty($page) || $page==1)
{
$page = 1;
// ���� ������ ������� - ������ ������ ���� ��������
// Åñëè íà÷àëè ñíà÷àëà - óäàëèì ñòàðûé ôàéë ýêñïîðòà
if(is_writable($this->export_files_dir.$this->filename))
unlink($this->export_files_dir.$this->filename);
}

// ��������� ���� �������� �� ����������
// Îòêðûâàåì ôàéë ýêñïîðòà íà äîáàâëåíèå
$f = fopen($this->export_files_dir.$this->filename, 'ab');

// ���� ������ ������� - ������� � ������ ������ �������� �������
// Åñëè íà÷àëè ñíà÷àëà - äîáàâèì â ïåðâóþ ñòðîêó íàçâàíèÿ êîëîíîê
if($page == 1)
{
fputcsv($f, $this->columns_names, $this->column_delimiter);
Expand All @@ -55,7 +55,7 @@ public function fetch()
$filter['sort'] = $this->request->get('sort');
$filter['keyword'] = $this->request->get('keyword');

// �������� �������������
// Âûáèðàåì ïîëüçîâàòåëåé
$users = array();
foreach($this->users->get_users($filter) as $u)
{
Expand All @@ -66,7 +66,7 @@ public function fetch()
fputcsv($f, $str, $this->column_delimiter);
}

$total_users = $this->users->count_users();
$total_users = $this->users->count_users($filter);

if($this->users_count*$page < $total_users)
return array('end'=>false, 'page'=>$page, 'totalpages'=>$total_users/$this->users_count);
Expand All @@ -85,4 +85,4 @@ public function fetch()
header("Cache-Control: must-revalidate");
header("Pragma: no-cache");
header("Expires: -1");
print $json;
print $json;