Files
crmPRO/autoload/Controllers/CrmController.php
Jacek Pyziak f3be8e1025 feat: Refactor CRM and Finances modules
- Updated client-edit template to change 'Firma' to 'Nazwa' and added 'Nazwa firmy' input field.
- Modified main-view template to reflect the new naming conventions for clients.
- Enhanced finances main-view to display a list of clients with revenue details.
- Added client selection dropdown in operation-edit template.
- Improved work-time template by adding keyboard shortcut for task confirmation.
- Introduced CrmController for handling client-related actions.
- Created FinancesController to manage finance operations and categories.
- Implemented ClientRepository for client data management.
- Developed FinanceRepository for finance operations and data handling.
2026-02-14 21:30:02 +01:00

71 lines
1.8 KiB
PHP

<?php
namespace Controllers;
class CrmController
{
public static $source = [ 0 => 'ceidg', 1 => 'kontakt własny', 2 => 'BNI' ];
public static $status = [ 0 => 'kontakt pozyskany', 1 => 'oferta wysłana', 2 => 'follow up', 3 => 'klient niezainteresowany' ];
public static function mainView()
{
global $user;
if ( !$user or !\controls\Users::permissions( $user['id'], 'wiki' ) )
return false;
return \Tpl::view( 'crm/main-view' );
}
public static function clientEdit()
{
global $user;
if ( !$user or !\controls\Users::permissions( $user['id'], 'wiki' ) )
return false;
$repository = new \Domain\Crm\ClientRepository();
return \Tpl::view( 'crm/client-edit', [
'client' => $repository -> getById( (int)\S::get( 'id' ) )
] );
}
public static function clientSave()
{
global $user;
if ( !$user or !\controls\Users::permissions( $user['id'], 'wiki' ) )
return false;
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania klienta wystąpił błąd. Proszę spróbować ponownie.' ];
$values = \S::json_to_array( \S::get( 'values' ) );
$repository = new \Domain\Crm\ClientRepository();
if ( $id = $repository -> save(
(int)$values['id'], $values['firm'], $values['firm_name'], $values['emails'], $values['phones'], $values['notes']
) )
$response = [ 'status' => 'ok', 'msg' => 'Projekt został zapisany.', 'id' => $id ];
echo json_encode( $response );
exit;
}
public static function clientDelete()
{
global $user;
if ( !$user )
return \controls\Users::login_form();
$repository = new \Domain\Crm\ClientRepository();
if ( $repository -> delete( (int)\S::get( 'client_id' ) ) )
{
\S::alert( 'Klient został usunięty' );
header( 'Location: /crm/main_view/' );
exit;
}
}
}