Enhance the feature of keyword detection for partnership

This commit is contained in:
Laurent Destailleur
2022-04-29 11:16:15 +02:00
parent a5379043e9
commit d496ad65e6
8 changed files with 28 additions and 15 deletions

View File

@@ -219,19 +219,21 @@ class modPartnership extends DolibarrModules
// Label of tables // Label of tables
'tablib'=>array("PartnershipType"), 'tablib'=>array("PartnershipType"),
// Request to select fields // Request to select fields
'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.active FROM '.MAIN_DB_PREFIX.'c_partnership_type as f WHERE f.entity = '.$conf->entity), 'tabsql'=>array('SELECT f.rowid as rowid, f.code, f.label, f.keyword, f.active FROM '.MAIN_DB_PREFIX.'c_partnership_type as f WHERE f.entity = '.((int) $conf->entity)),
// Sort order // Sort order
'tabsqlsort'=>array("label ASC"), 'tabsqlsort'=>array("label ASC"),
// List of fields (result of select to show dictionary) // List of fields (result of select to show dictionary)
'tabfield'=>array("code,label"), 'tabfield'=>array("code,label,keyword"),
// List of fields (list of fields to edit a record) // List of fields (list of fields to edit a record)
'tabfieldvalue'=>array("code,label"), 'tabfieldvalue'=>array("code,label,keyword"),
// List of fields (list of fields for insert) // List of fields (list of fields for insert)
'tabfieldinsert'=>array("code,label"), 'tabfieldinsert'=>array("code,label,keyword"),
// Name of columns with primary key (try to always name it 'rowid') // Name of columns with primary key (try to always name it 'rowid')
'tabrowid'=>array("rowid"), 'tabrowid'=>array("rowid"),
// Condition to show each dictionary // Condition to show each dictionary
'tabcond'=>array($conf->partnership->enabled) 'tabcond'=>array($conf->partnership->enabled),
// Help tooltip for each fields of the dictionary
'tabhelp'=>array(array('keyword'=>$langs->trans('KeywordToCheckInWebsite')))
); );
// Boxes/Widgets // Boxes/Widgets
@@ -428,7 +430,7 @@ class modPartnership extends DolibarrModules
$sql = array(); $sql = array();
// Document templates // Document templates
$moduledir = 'partnership'; $moduledir = dol_sanitizeFileName('partnership');
$myTmpObjects = array(); $myTmpObjects = array();
$myTmpObjects['Partnership'] = array('includerefgeneration'=>0, 'includedocgeneration'=>0); $myTmpObjects['Partnership'] = array('includerefgeneration'=>0, 'includedocgeneration'=>0);
@@ -437,8 +439,8 @@ class modPartnership extends DolibarrModules
continue; continue;
} }
if ($myTmpObjectArray['includerefgeneration']) { if ($myTmpObjectArray['includerefgeneration']) {
$src = DOL_DOCUMENT_ROOT.'/install/doctemplates/partnership/template_partnerships.odt'; $src = DOL_DOCUMENT_ROOT.'/install/doctemplates/'.$moduledir.'/template_partnerships.odt';
$dirodt = DOL_DATA_ROOT.'/doctemplates/partnership'; $dirodt = DOL_DATA_ROOT.'/doctemplates/'.$moduledir;
$dest = $dirodt.'/template_partnerships.odt'; $dest = $dirodt.'/template_partnerships.odt';
if (file_exists($src) && !file_exists($dest)) { if (file_exists($src) && !file_exists($dest)) {

View File

@@ -334,4 +334,8 @@ ALTER TABLE llx_actioncomm MODIFY COLUMN note mediumtext;
DELETE FROM llx_boxes WHERE box_id IN (select rowid FROM llx_boxes_def WHERE file IN ('box_bom.php@bom', 'box_bom.php')); DELETE FROM llx_boxes WHERE box_id IN (select rowid FROM llx_boxes_def WHERE file IN ('box_bom.php@bom', 'box_bom.php'));
DELETE FROM llx_boxes_def WHERE file IN ('box_bom.php@bom', 'box_bom.php'); DELETE FROM llx_boxes_def WHERE file IN ('box_bom.php@bom', 'box_bom.php');
ALTER TABLE llx_takepos_floor_tables ADD UNIQUE(entity,label); ALTER TABLE llx_takepos_floor_tables ADD UNIQUE(entity,label);
ALTER TABLE llx_partnership ADD COLUMN url_to_check varchar(255);
ALTER TABLE llx_c_partnership_type ADD COLUMN keyword varchar(128);

View File

@@ -31,6 +31,7 @@ create table llx_c_partnership_type
entity integer DEFAULT 1 NOT NULL, entity integer DEFAULT 1 NOT NULL,
code varchar(32) NOT NULL, code varchar(32) NOT NULL,
label varchar(128) NOT NULL, label varchar(128) NOT NULL,
keyword varchar(128), -- a keyword to check into url of partner website or a dedicated url defined into partneship record
active tinyint DEFAULT 1 NOT NULL active tinyint DEFAULT 1 NOT NULL
)ENGINE=innodb; )ENGINE=innodb;

View File

@@ -34,8 +34,9 @@ CREATE TABLE llx_partnership(
note_private text, note_private text,
note_public text, note_public text,
last_main_doc varchar(255), last_main_doc varchar(255),
count_last_url_check_error integer DEFAULT '0', url_to_check varchar(255), -- url to check to find a specific keyword (defined into llx_c_partnership) to keep status of partnership valid
last_check_backlink datetime NULL, count_last_url_check_error integer DEFAULT '0', -- last result of check of keyword into url
last_check_backlink datetime NULL, -- date of last check of keyword into url
import_key varchar(14), import_key varchar(14),
model_pdf varchar(255) model_pdf varchar(255)
) ENGINE=innodb; ) ENGINE=innodb;

View File

@@ -59,6 +59,7 @@ BacklinkNotFoundOnPartnerWebsite=Backlink not found on partner website
ConfirmClosePartnershipAsk=Are you sure you want to cancel this partnership? ConfirmClosePartnershipAsk=Are you sure you want to cancel this partnership?
PartnershipType=Partnership type PartnershipType=Partnership type
PartnershipRefApproved=Partnership %s approved PartnershipRefApproved=Partnership %s approved
KeywordToCheckInWebsite=If you want to check that a given keyword is present into the website of each partner, define this keyword here
# #
# Template Mail # Template Mail
@@ -89,4 +90,5 @@ PartnershipDraft=Draft
PartnershipAccepted=Accepted PartnershipAccepted=Accepted
PartnershipRefused=Refused PartnershipRefused=Refused
PartnershipCanceled=Canceled PartnershipCanceled=Canceled
PartnershipManagedFor=Partners are PartnershipManagedFor=Partners are

View File

@@ -222,6 +222,8 @@ class modMyModule extends DolibarrModules
'tabrowid'=>array("rowid", "rowid", "rowid"), 'tabrowid'=>array("rowid", "rowid", "rowid"),
// Condition to show each dictionary // Condition to show each dictionary
'tabcond'=>array($conf->mymodule->enabled, $conf->mymodule->enabled, $conf->mymodule->enabled) 'tabcond'=>array($conf->mymodule->enabled, $conf->mymodule->enabled, $conf->mymodule->enabled)
// Help tooltip for each fields of the dictionary
'tabhelp'=>array(array('code'=>$langs->trans('CodeTooltipHelp')))
); );
*/ */

View File

@@ -119,9 +119,10 @@ class Partnership extends CommonObject
'date_partnership_start' => array('type'=>'date', 'label'=>'DatePartnershipStart', 'enabled'=>'1', 'position'=>52, 'notnull'=>1, 'visible'=>1,), 'date_partnership_start' => array('type'=>'date', 'label'=>'DatePartnershipStart', 'enabled'=>'1', 'position'=>52, 'notnull'=>1, 'visible'=>1,),
'date_partnership_end' => array('type'=>'date', 'label'=>'DatePartnershipEnd', 'enabled'=>'1', 'position'=>53, 'notnull'=>0, 'visible'=>1,), 'date_partnership_end' => array('type'=>'date', 'label'=>'DatePartnershipEnd', 'enabled'=>'1', 'position'=>53, 'notnull'=>0, 'visible'=>1,),
'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>54, 'notnull'=>0, 'visible'=>2, 'index'=>1, 'arrayofkeyval'=>array('-1'=>'','0'=>'Draft', '1'=>'Accepted', '2'=>'Refused', '9'=>'Terminated'),), 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>54, 'notnull'=>0, 'visible'=>2, 'index'=>1, 'arrayofkeyval'=>array('-1'=>'','0'=>'Draft', '1'=>'Accepted', '2'=>'Refused', '9'=>'Terminated'),),
'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'1', 'position'=>63, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',), 'url_to_check' => array('type'=>'varchar(255)', 'label'=>'UrlToCheck', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>-1),
'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'1', 'position'=>65, 'notnull'=>0, 'visible'=>-2,), 'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'1', 'position'=>71, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',),
'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>64, 'notnull'=>0, 'visible'=>-2,), 'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'1', 'position'=>72, 'notnull'=>0, 'visible'=>-2,),
'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>73, 'notnull'=>0, 'visible'=>-2,),
// fk_member and fk_soc are added into constructor // fk_member and fk_soc are added into constructor
); );