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.
This commit is contained in:
66
autoload/Domain/Crm/ClientRepository.php
Normal file
66
autoload/Domain/Crm/ClientRepository.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
namespace Domain\Crm;
|
||||
|
||||
class ClientRepository
|
||||
{
|
||||
private $mdb;
|
||||
|
||||
public function __construct( $mdb = null )
|
||||
{
|
||||
if ( $mdb )
|
||||
$this -> mdb = $mdb;
|
||||
else
|
||||
{
|
||||
global $mdb;
|
||||
$this -> mdb = $mdb;
|
||||
}
|
||||
}
|
||||
|
||||
public function all()
|
||||
{
|
||||
return $this -> mdb -> select( 'crm_client', '*', [ 'ORDER' => [ 'firm' => 'ASC' ] ] );
|
||||
}
|
||||
|
||||
public function getById( int $client_id )
|
||||
{
|
||||
return \R::load( 'crm_client', $client_id );
|
||||
}
|
||||
|
||||
public function getName( int $client_id )
|
||||
{
|
||||
return $this -> mdb -> get( 'crm_client', 'firm', [ 'id' => $client_id ] );
|
||||
}
|
||||
|
||||
public function save( int $client_id, string $firm, string $firm_name, string $emails, string $phones, string $notes )
|
||||
{
|
||||
$client = \R::load( 'crm_client', $client_id );
|
||||
if ( !$client )
|
||||
{
|
||||
$client = \R::xdispense( 'crm_client' );
|
||||
$client -> date_add = date( 'Y-m-d H:i:s' );
|
||||
}
|
||||
$client -> firm = $firm;
|
||||
$client -> firm_name = $firm_name;
|
||||
$client -> emails = $emails;
|
||||
$client -> phones = $phones;
|
||||
$client -> notes = $notes;
|
||||
$client -> date_update = date( 'Y-m-d H:i:s' );
|
||||
return \R::store( $client );
|
||||
}
|
||||
|
||||
public function delete( int $client_id )
|
||||
{
|
||||
return $this -> mdb -> delete( 'crm_client', [ 'id' => $client_id ] );
|
||||
}
|
||||
|
||||
public function settings()
|
||||
{
|
||||
$settings = [];
|
||||
$results = $this -> mdb -> select( 'settings', '*' );
|
||||
foreach ( $results as $result )
|
||||
{
|
||||
$settings[ $result['name'] ] = $result['value'];
|
||||
}
|
||||
return $settings;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user