NEW Add the status of partnership to select partnership for emailing

This commit is contained in:
Laurent Destailleur 2023-09-21 12:17:40 +02:00
parent 277d69fe0f
commit 10b2cd7399
2 changed files with 18 additions and 53 deletions

View file

@ -81,6 +81,9 @@ class mailing_partnership extends MailingTargets
if (GETPOST('filter', 'int') > 0) {
$sql .= " AND pt.rowid=".((int) GETPOST('filter', 'int'));
}
if (GETPOSTISSET('filter_status_partnership') && GETPOSTINT('filter_status_partnership') >= 0) {
$sql .= " AND p.status = ".GETPOSTINT('filter_status_partnership');
}
if (empty($this->evenunsubscribe)) {
$sql .= " AND NOT EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX."mailing_unsubscribe as mu WHERE mu.email = s.email and mu.entity = ".((int) $conf->entity).")";
}
@ -97,6 +100,9 @@ class mailing_partnership extends MailingTargets
if (GETPOST('filter', 'int') > 0) {
$sql .= " AND pt.rowid=".((int) GETPOST('filter', 'int'));
}
if (GETPOSTISSET('filter_status_partnership') && GETPOSTINT('filter_status_partnership') >= 0) {
$sql .= " AND p.status = ".GETPOSTINT('filter_status_partnership');
}
if (empty($this->evenunsubscribe)) {
$sql .= " AND NOT EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX."mailing_unsubscribe as mu WHERE mu.email = s.email and mu.entity = ".((int) $conf->entity).")";
}
@ -209,13 +215,13 @@ class mailing_partnership extends MailingTargets
*/
public function formFilter()
{
global $conf, $langs;
global $conf, $langs, $form;
$langs->load("companies");
$s = '<select id="filter_partnership" name="filter" class="flat">';
// Show categories
// Show type of partnership
$sql = "SELECT rowid, label, code, active";
$sql .= " FROM ".MAIN_DB_PREFIX."c_partnership_type";
$sql .= " WHERE active = 1";
@ -250,6 +256,13 @@ class mailing_partnership extends MailingTargets
$s .= '</select> ';
// filter_status_thirdparties
include_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership.class.php';
$tmppartnership = new Partnership($this->db);
$dummy = $tmppartnership->getLibStatut(0); // We call this only to have $tmppartnership->labelStatus loaded
$s .= $form->selectarray('filter_status_partnership', $tmppartnership->labelStatus, GETPOST('filter_status_partnership'), $langs->trans("Status"));
return $s;
}

View file

@ -106,7 +106,7 @@ class Partnership extends CommonObject
public $fields=array(
'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"),
'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>4, 'noteditable'=>'1', 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'comment'=>"Reference of object"),
'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>'1', 'position'=>15, 'notnull'=>1, 'visible'=>-2, 'default'=>'1', 'index'=>1,),
'entity' => array('type'=>'integer', 'label'=>'Entity', 'enabled'=>'isModEnabled("multicompany")', 'position'=>15, 'notnull'=>1, 'visible'=>-2, 'default'=>'1', 'index'=>1,),
'fk_type' => array('type'=>'integer:PartnershipType:partnership/class/partnership_type.class.php:0:(active:=:1)', 'label'=>'Type', 'enabled'=>'1', 'position'=>20, 'notnull'=>1, 'visible'=>1, 'csslist'=>'tdoverflowmax100'),
'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:((status:=:1) AND (entity:IN:__SHARED_ENTITIES__))', 'label'=>'ThirdParty', 'picto'=>'company', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1, 'css'=>'maxwidth500', 'csslist'=>'tdoverflowmax125',),
'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,),
@ -153,41 +153,6 @@ class Partnership extends CommonObject
// END MODULEBUILDER PROPERTIES
// If this object has a subtable with lines
// /**
// * @var string Name of subtable line
// */
// public $table_element_line = 'partnershipline';
// /**
// * @var string Field with ID of parent key if this object has a parent
// */
// public $fk_element = 'fk_partnership';
// /**
// * @var string Name of subtable class that manage subtable lines
// */
// public $class_element_line = 'Partnershipline';
// /**
// * @var array List of child tables. To test if we can delete object.
// */
// protected $childtables = array();
// /**
// * @var array List of child tables. To know object to delete on cascade.
// * If name matches '@ClassNAme:FilePathClass;ParentFkFieldName' it will
// * call method deleteByParentField(parentId, ParentFkFieldName) to fetch and delete child object
// */
// protected $childtablesoncascade = array('partnershipdet');
// /**
// * @var PartnershipLine[] Array of subtable lines
// */
// public $lines = array();
/**
* Constructor
*
@ -208,15 +173,6 @@ class Partnership extends CommonObject
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid']) && !empty($this->fields['ref'])) {
$this->fields['rowid']['visible'] = 0;
}
// if (!isModEnabled('multicompany') && isset($this->fields['entity'])) {
// $this->fields['entity']['enabled'] = 0;
// }
// Example to show how to set values of fields definition dynamically
/*if ($user->rights->partnership->read) {
$this->fields['myfield']['visible'] = 1;
$this->fields['myfield']['noteditable'] = 0;
}*/
// Unset fields that are disabled
foreach ($this->fields as $key => $val) {
@ -367,8 +323,6 @@ class Partnership extends CommonObject
*/
public function fetch($id, $ref = null, $fk_member = null, $fk_soc = null)
{
global $conf;
// Check parameters
if (empty($id) && empty($ref) && empty($fk_member) && empty($fk_soc)) {
return -1;
@ -479,8 +433,6 @@ class Partnership extends CommonObject
*/
public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND')
{
global $conf;
dol_syslog(__METHOD__, LOG_DEBUG);
$records = array();
@ -607,7 +559,7 @@ class Partnership extends CommonObject
*/
public function validate($user, $notrigger = 0)
{
global $conf, $langs;
global $conf;
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@ -731,7 +683,7 @@ class Partnership extends CommonObject
*/
public function approve($user, $notrigger = 0)
{
global $conf, $langs;
global $conf;
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';