From 10b2cd7399800fbad55423af455f93fb4ec7fe01 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 21 Sep 2023 12:17:40 +0200 Subject: [PATCH] NEW Add the status of partnership to select partnership for emailing --- .../modules/mailings/partnership.modules.php | 17 +++++- .../partnership/class/partnership.class.php | 54 ++----------------- 2 files changed, 18 insertions(+), 53 deletions(-) diff --git a/htdocs/core/modules/mailings/partnership.modules.php b/htdocs/core/modules/mailings/partnership.modules.php index 2695444b334..48fabd3b0fe 100644 --- a/htdocs/core/modules/mailings/partnership.modules.php +++ b/htdocs/core/modules/mailings/partnership.modules.php @@ -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 = ' '; + // 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; } diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index 8bb88021090..bedc36f3730 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -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';