A Micro CRM for a Yii Framework Application
Install mysql tables:, (*1)
mysql <databasename> < /ruta/al/repo/vendor/freesoftwarefactory/crm/mysql.schema.sql
Install the Console Commands:, (*2)
cd /bla/my-app/commands ln -s ../freesoftwarefactory/crm/console/CrmController.php .
Install the Controller:, (*3)
cd /bla/my-app/controllers ln -s ../freesoftwarefactory/crm/web/CrmController.php .
Setup files:, (*4)
// copy files cp /bla/my-app/vendor/freesoftwarefactory/crm/crm-config.php bla/my-app/config // reflect it in 'components' section config/console.php, config/web.php 'crm' => require(__DIR__.'/crm-config.php'),
Here you define all the crm fields. Copy this file into your config/ path, as:, (*5)
/your/app/config/crm-config.php
register it in your components section inside web.php and console.php:, (*6)
'crm' => require(__DIR__.'/crm-config.php'),
Example setup file:, (*7)
<?php return [ "class"=>"freesoftwarefactory\crm\Api", "layouts"=>array( "default"=>"@crmviews/base", // <-- use this layout "create"=>"", // or, per view: create,edit,view,find "edit"=>"", // ... ), "fields"=>array( "first_name"=>array( "label"=>"Nombre", // come on... "size"=>45, // "min"=>0, // "type"=>"text", // "placeholder"=>"Ingrese el nombre", // "default"=>"", // default value "required"=>true, // mark as required "list"=>1, // used to be showed in find results "browse"=>1, // see also: crm_field ), "last_name"=>array( "label"=>"Apellido", "size"=>45, "min"=>0, "type"=>"text", "placeholder"=>"Ingrese el apellido", "list"=>1, "browse"=>1, // see also: crm_field ), "primary_email"=>array( "label"=>"Correo Personal", "size"=>80, "min"=>0, "type"=>"mail", "placeholder"=>"Ingrese un correo", "list"=>1, "browse"=>1, // see also: crm_field ), "primary_phone"=>array( "label"=>"Telefono Personal", "size"=>45, "min"=>0, "type"=>"text", "placeholder"=>"Ingrese un telefono", ), "notes"=>array( "label"=>"Notas Adicionales", "size"=>45, "min"=>0, "rows"=>5, "type"=>"textarea", "placeholder"=>"Notas adicionales", ), ) ];
This widget is designed to find/edit/create contacts, it has two modalities: 'finder' or 'browser'., (*8)
The 'finder' modality helps you pick one contact and select into a existing text input (a hidden input, as an example)., (*9)
The 'browser' modality will present contacts using a 'checkbox' selector., (*10)
[html] .crm-form-group { display: inline-block; }=\app\components\CrmFindContactWidget::widget([ 'mode'=>'browser', // or 'finder' 'readonly'=>false, 'selector'=>'[name=contact_id_receptor]', 'selector_label'=>'#contact_selector', 'selector_activator'=>'#contacts_activator', 'selector_finder'=>'#contacts_finder', 'crm_field'=>'browse', // show all columns with 'browse' attrib. ]);?> </div> </div>Customize Contact Widget using Events Handlers
The contact widget fires some events to help you take desitions in you own implementation, just add this code snippets:, (*11)
$( document ).on( 'crm:find:list:updated', { some: 'data'}, function( event, list, keywords, resp ) { }); $( document ).on( 'crm:form:launch', { some: 'data'}, function( event, widget, current_contact) { widget.find('.result-list').hide(); }); $( document ).on( 'crm:form:render:contact', { some: 'data'}, function( event, widget, current_contact, response) { });API
Use the api methods via:, (*12)
\Yii::$app->crmConsole Access
Handle all contacts and relationships using a Console:, (*13)
./yii crm