Manage mass action "Send email" for Partnership module
This commit is contained in:
parent
010b89ce78
commit
9304b3c474
@ -90,6 +90,9 @@ if (!$error && $massaction == 'confirm_presend') {
|
||||
if ($objecttmp->element == 'expensereport') {
|
||||
$thirdparty = new User($db);
|
||||
}
|
||||
if ($objecttmp->element == 'partnership' && $conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') {
|
||||
$thirdparty = new Adherent($db);
|
||||
}
|
||||
if ($objecttmp->element == 'holiday') {
|
||||
$thirdparty = new User($db);
|
||||
}
|
||||
@ -107,6 +110,9 @@ if (!$error && $massaction == 'confirm_presend') {
|
||||
if ($objecttmp->element == 'expensereport') {
|
||||
$thirdpartyid = $objecttmp->fk_user_author;
|
||||
}
|
||||
if ($objecttmp->element == 'partnership' && $conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') {
|
||||
$thirdpartyid = $objecttmp->fk_member;
|
||||
}
|
||||
if ($objecttmp->element == 'holiday') {
|
||||
$thirdpartyid = $objecttmp->fk_user;
|
||||
}
|
||||
@ -250,6 +256,10 @@ if (!$error && $massaction == 'confirm_presend') {
|
||||
$fuser = new User($db);
|
||||
$fuser->fetch($objectobj->fk_user_author);
|
||||
$sendto = $fuser->email;
|
||||
} elseif ($objectobj->element == 'partnership' && $conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') {
|
||||
$fadherent = new Adherent($db);
|
||||
$fadherent->fetch($objectobj->fk_member);
|
||||
$sendto = $fadherent->email;
|
||||
} elseif ($objectobj->element == 'holiday') {
|
||||
$fuser = new User($db);
|
||||
$fuser->fetch($objectobj->fk_user);
|
||||
|
||||
@ -151,6 +151,10 @@ if ($action == 'presend') {
|
||||
$fuser = new User($db);
|
||||
$fuser->fetch($object->fk_user_author);
|
||||
$liste['thirdparty'] = $fuser->getFullName($outputlangs)." <".$fuser->email.">";
|
||||
} elseif ($object->element == 'partnership' && $conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') {
|
||||
$fadherent = new Adherent($db);
|
||||
$fadherent->fetch($object->fk_member);
|
||||
$liste['member'] = $fadherent->getFullName($outputlangs)." <".$fadherent->email.">";
|
||||
} elseif ($object->element == 'societe') {
|
||||
foreach ($object->thirdparty_and_contact_email_array(1) as $key => $value) {
|
||||
$liste[$key] = $value;
|
||||
|
||||
@ -127,6 +127,10 @@ if ($massaction == 'presend') {
|
||||
$fuser = new User($db);
|
||||
$fuser->fetch($thirdpartyid);
|
||||
$liste['thirdparty'] = $fuser->getFullName($langs)." <".$fuser->email.">";
|
||||
} elseif ($objecttmp->element == 'partnership' && $conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') {
|
||||
$fadherent = new Adherent($db);
|
||||
$fadherent->fetch($objecttmp->fk_member);
|
||||
$liste['member'] = $fadherent->getFullName($langs)." <".$fadherent->email.">";
|
||||
} else {
|
||||
$soc = new Societe($db);
|
||||
$soc->fetch($thirdpartyid);
|
||||
|
||||
@ -411,7 +411,10 @@ create table llx_partnership_extrafields
|
||||
|
||||
ALTER TABLE llx_partnership_extrafields ADD INDEX idx_partnership_fk_object(fk_object);
|
||||
|
||||
INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'member', '(AlertStatusPartnershipExpiration)', NULL, 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourMembershipWillSoonExpireTopic)__', 0, '<body>\n <p>Dear __MEMBER_FULLNAME__,<br><br>\n__(YourMembershipWillSoonExpireContent)__</p>\n<br />\n\n __(Sincerely)__ <br />\n __[PARTNERSHIP_SOCIETE_NOM]__ <br />\n </body>\n');
|
||||
INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipWillExpire)', NULL, 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipWillSoonExpireTopic)__', 0, '<body>\n <p>Hello,<br><br>\n__(YourPartnershipWillSoonExpireContent)__</p>\n<br />\n\n<br />\n\n __(Sincerely)__ <br />\n __[MAIN_INFO_SOCIETE_NOM]__ <br />\n </body>\n');
|
||||
INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipRefused)', NULL, 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipRefusedTopic)__', 0, '<body>\n <p>Hello,<br><br>\n__(YourPartnershipRefusedContent)__</p>\n<br />\n\n<br />\n\n __(Sincerely)__ <br />\n __[MAIN_INFO_SOCIETE_NOM]__ <br />\n </body>\n');
|
||||
INSERT INTO llx_c_email_templates (entity,module,type_template,label,lang,position,topic,joinfiles,content) VALUES (0, 'partnership', 'partnership_send', '(SendingEmailOnPartnershipCanceled)', NULL, 100, '[__[MAIN_INFO_SOCIETE_NOM]__] - __(YourPartnershipCanceledTopic)__', 0, '<body>\n <p>Hello,<br><br>\n__(YourPartnershipCanceledContent)__</p>\n<br />\n\n<br />\n\n __(Sincerely)__ <br />\n __[MAIN_INFO_SOCIETE_NOM]__ <br />\n </body>\n');
|
||||
ALTER TABLE llx_adherent ADD COLUMN website varchar(255) NULL AFTER email;
|
||||
ALTER TABLE llx_facture_fourn ADD COLUMN date_closing datetime DEFAULT NULL after date_valid;
|
||||
|
||||
ALTER TABLE llx_facture_fourn ADD COLUMN fk_user_closing integer DEFAULT NULL after fk_user_valid;
|
||||
|
||||
@ -16,23 +16,23 @@
|
||||
#
|
||||
# Generic
|
||||
#
|
||||
ModulePartnershipName = Partnership management
|
||||
PartnershipDescription = Module Partnership management
|
||||
ModulePartnershipName=Partnership management
|
||||
PartnershipDescription=Module Partnership management
|
||||
PartnershipDescriptionLong= Module Partnership management
|
||||
|
||||
#
|
||||
# Menu
|
||||
#
|
||||
NewPartnership = New Partnership
|
||||
ListOfPartnerships = List of partnership
|
||||
NewPartnership=New Partnership
|
||||
ListOfPartnerships=List of partnership
|
||||
|
||||
#
|
||||
# Admin page
|
||||
#
|
||||
PartnershipSetup = Partnership setup
|
||||
PartnershipAbout = About Partnership
|
||||
PartnershipAboutPage = Partnership about page
|
||||
PartnershipManagedFor = Partnership managed for
|
||||
PartnershipSetup=Partnership setup
|
||||
PartnershipAbout=About Partnership
|
||||
PartnershipAboutPage=Partnership about page
|
||||
PartnershipManagedFor=Partnership managed for
|
||||
|
||||
#
|
||||
# Object
|
||||
@ -44,12 +44,22 @@ DatePartnershipEnd=End date
|
||||
#
|
||||
# Template Mail
|
||||
#
|
||||
SendingEmailOnPartnershipWillExpire=Partnership will expire
|
||||
SendingEmailOnPartnershipRefused=Partnership refused
|
||||
SendingEmailOnPartnershipCanceled=Partnership canceled
|
||||
|
||||
YourPartnershipWillSoonExpireTopic=Partnership expiration
|
||||
YourPartnershipRefusedTopic=Partnership refused
|
||||
YourPartnershipCanceledTopic=Partnership canceled
|
||||
|
||||
YourPartnershipWillSoonExpireContent=We inform you that your partnership will soon expire.
|
||||
YourPartnershipRefusedContent=We inform you that your partnership request has been refused.
|
||||
YourPartnershipCanceledContent=We inform you that your partnership has been canceled.
|
||||
|
||||
#
|
||||
# Status
|
||||
#
|
||||
PartnershipDraft = Draft
|
||||
PartnershipAccepted = Accepted
|
||||
PartnershipRefused = Refused
|
||||
PartnershipCanceled = Canceled
|
||||
PartnershipDraft=Draft
|
||||
PartnershipAccepted=Accepted
|
||||
PartnershipRefused=Refused
|
||||
PartnershipCanceled=Canceled
|
||||
@ -169,14 +169,9 @@ class Partnership extends CommonObject
|
||||
|
||||
$this->db = $db;
|
||||
|
||||
$fk_soc_visible = ($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') ? 0 : 1;
|
||||
$fk_member_visible = ($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member') ? 1 : 0;
|
||||
|
||||
$this->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"),
|
||||
'fk_soc' => array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>$fk_soc_visible, 'index'=>1,),
|
||||
'fk_member' => array('type'=>'integer:Adherent:adherents/class/adherent.class.php:1', 'label'=>'Member', 'enabled'=>'1', 'position'=>51, 'notnull'=>-1, 'visible'=>$fk_member_visible, 'index'=>1,),
|
||||
'entity' => array('type' => 'integer', 'label' => 'Entity', 'default' => 1, 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 15, 'index' => 1),
|
||||
'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,),
|
||||
'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,),
|
||||
@ -187,13 +182,19 @@ class Partnership extends CommonObject
|
||||
'last_main_doc' => array('type'=>'varchar(255)', 'label'=>'LastMainDoc', 'enabled'=>'1', 'position'=>600, 'notnull'=>0, 'visible'=>0,),
|
||||
'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>'1', 'position'=>1000, 'notnull'=>-1, 'visible'=>-2,),
|
||||
'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,),
|
||||
'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>1000, 'notnull'=>0, 'visible'=>0, 'index'=>1, 'arrayofkeyval'=>array('0'=>'Brouillon', '1'=>'Accepté', '2'=>'Refusé', '9'=>'Annulé'),),
|
||||
'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'=>1, 'visible'=>1,),
|
||||
'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>54, 'notnull'=>0, 'visible'=>2, 'index'=>1, 'arrayofkeyval'=>array('-1'=>'','0'=>$langs->trans('Draft'), '1'=>$langs->trans('Accepted'), '2'=>$langs->trans('Refused'), '9'=>$langs->trans('Canceled')),),
|
||||
'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'1', 'position'=>63, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',),
|
||||
'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>64, 'notnull'=>0, 'visible'=>-2,),
|
||||
);
|
||||
|
||||
if($conf->global->PARTNERSHIP_IS_MANAGED_FOR == 'member'){
|
||||
$this->fields['fk_member'] = array('type'=>'integer:Adherent:adherents/class/adherent.class.php:1', 'label'=>'Member', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1,);
|
||||
} else {
|
||||
$this->fields['fk_soc'] = array('type'=>'integer:Societe:societe/class/societe.class.php:1:status=1 AND entity IN (__SHARED_ENTITIES__)', 'label'=>'ThirdParty', 'enabled'=>'1', 'position'=>50, 'notnull'=>-1, 'visible'=>1, 'index'=>1,);
|
||||
}
|
||||
|
||||
if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) {
|
||||
$this->fields['rowid']['visible'] = 0;
|
||||
}
|
||||
|
||||
@ -123,21 +123,18 @@ if (empty($action) && empty($id) && empty($ref)) {
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once.
|
||||
|
||||
|
||||
$permissiontoread = $user->rights->partnership->read;
|
||||
$permissiontoadd = $user->rights->partnership->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
|
||||
$permissiontodelete = $user->rights->partnership->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
|
||||
$permissionnote = $user->rights->partnership->write; // Used by the include of actions_setnotes.inc.php
|
||||
$permissiondellink = $user->rights->partnership->write; // Used by the include of actions_dellink.inc.php
|
||||
$upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1];
|
||||
|
||||
// Security check - Protection if external user
|
||||
//if ($user->socid > 0) accessforbidden();
|
||||
//if ($user->socid > 0) $socid = $user->socid;
|
||||
//$isdraft = (($object->status == $object::STATUS_DRAFT) ? 1 : 0);
|
||||
//restrictedArea($user, $object->element, $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
|
||||
//if (empty($conf->partnership->enabled)) accessforbidden();
|
||||
//if (empty($permissiontoread)) accessforbidden();
|
||||
$permissiontoread = $user->rights->partnership->read;
|
||||
$permissiontoadd = $user->rights->partnership->write; // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
|
||||
$permissiontodelete = $user->rights->partnership->delete || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_DRAFT);
|
||||
$permissionnote = $user->rights->partnership->write; // Used by the include of actions_setnotes.inc.php
|
||||
$permissiondellink = $user->rights->partnership->write; // Used by the include of actions_dellink.inc.php
|
||||
$upload_dir = $conf->partnership->multidir_output[isset($object->entity) ? $object->entity : 1];
|
||||
$managedfor = $conf->global->PARTNERSHIP_IS_MANAGED_FOR;
|
||||
|
||||
if (empty($conf->partnership->enabled)) accessforbidden();
|
||||
if (empty($permissiontoread)) accessforbidden();
|
||||
if ($object->id > 0 && $object->fk_member > 0 && $managedfor != 'member') accessforbidden();
|
||||
if ($object->id > 0 && $object->fk_soc > 0 && $managedfor != 'thirdparty') accessforbidden();
|
||||
|
||||
/*
|
||||
* Actions
|
||||
@ -502,6 +499,32 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
//unset($object->fields['fk_soc']); // Hide field already shown in banner
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/commonfields_view.tpl.php';
|
||||
|
||||
// End of subscription date
|
||||
if ($managedfor == 'member') {
|
||||
$fadherent = new Adherent($db);
|
||||
$fadherent->fetch($object->fk_member);
|
||||
print '<tr><td>'.$langs->trans("SubscriptionEndDate").'</td><td class="valeur">';
|
||||
if ($fadherent->datefin) {
|
||||
print dol_print_date($fadherent->datefin, 'day');
|
||||
if ($fadherent->hasDelay()) {
|
||||
print " ".img_warning($langs->trans("Late"));
|
||||
}
|
||||
} else {
|
||||
if (!$adht->subscription) {
|
||||
print $langs->trans("SubscriptionNotRecorded");
|
||||
if ($fadherent->statut > 0) {
|
||||
print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled
|
||||
}
|
||||
} else {
|
||||
print $langs->trans("SubscriptionNotReceived");
|
||||
if ($fadherent->statut > 0) {
|
||||
print " ".img_warning($langs->trans("Late")); // Display a delay picto only if it is not a draft and is not canceled
|
||||
}
|
||||
}
|
||||
}
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Other attributes. Fields from hook formObjectOptions and Extrafields.
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
|
||||
|
||||
@ -669,7 +692,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
}
|
||||
|
||||
// Presend form
|
||||
$modelmail = 'partnership';
|
||||
$modelmail = 'partnership_send';
|
||||
$defaulttopic = 'InformationMessage';
|
||||
$diroutput = $conf->partnership->dir_output;
|
||||
$trackid = 'partnership'.$object->id;
|
||||
|
||||
@ -86,7 +86,7 @@ require_once __DIR__.'/class/partnership.class.php';
|
||||
//dol_include_once('/othermodule/class/otherobject.class.php');
|
||||
|
||||
// Load translation files required by the page
|
||||
$langs->loadLangs(array("partnership@partnership", "other"));
|
||||
$langs->loadLangs(array("partnership", "members", "other"));
|
||||
|
||||
$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; // The action 'add', 'create', 'edit', 'update', 'view', ...
|
||||
$massaction = GETPOST('massaction', 'alpha'); // The bulk action (combo box choice into lists)
|
||||
@ -185,8 +185,8 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php';
|
||||
$object->fields = dol_sort_array($object->fields, 'position');
|
||||
$arrayfields = dol_sort_array($arrayfields, 'position');
|
||||
|
||||
$permissiontoread = $user->rights->partnership->read;
|
||||
$permissiontoadd = $user->rights->partnership->write;
|
||||
$permissiontoread = $user->rights->partnership->read;
|
||||
$permissiontoadd = $user->rights->partnership->write;
|
||||
$permissiontodelete = $user->rights->partnership->delete;
|
||||
|
||||
// Security check
|
||||
@ -248,6 +248,38 @@ if (empty($reshook)) {
|
||||
$objectlabel = 'Partnership';
|
||||
$uploaddir = $conf->partnership->dir_output;
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
|
||||
|
||||
// Cancel partnership
|
||||
if ($massaction == 'cancel' && $permissiontoadd) {
|
||||
$db->begin();
|
||||
|
||||
$objecttmp = new $objectclass($db);
|
||||
$nbok = 0;
|
||||
foreach ($toselect as $toselectid) {
|
||||
$result = $objecttmp->fetch($toselectid);
|
||||
if ($result > 0) {
|
||||
$result = $objecttmp->cancel($user, 3);
|
||||
if ($result <= 0) {
|
||||
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
|
||||
$error++;
|
||||
break;
|
||||
} else {
|
||||
$nbok++;
|
||||
}
|
||||
} else {
|
||||
setEventMessages($objecttmp->error, $objecttmp->errors, 'errors');
|
||||
$error++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$error) {
|
||||
setEventMessages($langs->trans("RecordsModified", $nbok), null, 'mesgs');
|
||||
$db->commit();
|
||||
} else {
|
||||
$db->rollback();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -466,7 +498,7 @@ $arrayofmassactions = array(
|
||||
'cancel'=>$langs->trans("Cancel"),
|
||||
//'generate_doc'=>$langs->trans("ReGeneratePDF"),
|
||||
//'builddoc'=>$langs->trans("PDFMerge"),
|
||||
'presend'=>$langs->trans("SendByMail"),
|
||||
'presend'=>$langs->trans("SendMail"),
|
||||
);
|
||||
if ($permissiontodelete) {
|
||||
$arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
|
||||
@ -493,9 +525,9 @@ print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sort
|
||||
|
||||
// Add code for pre mass action (confirmation or email presend form)
|
||||
$topicmail = "SendPartnershipRef";
|
||||
$modelmail = "partnership";
|
||||
$modelmail = "partnership_send";
|
||||
$objecttmp = new Partnership($db);
|
||||
$trackid = 'xxxx'.$object->id;
|
||||
$trackid = 'partnership'.$object->id;
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
|
||||
|
||||
if ($search_all) {
|
||||
@ -742,6 +774,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) {
|
||||
|
||||
$i++;
|
||||
}
|
||||
$totalarray['nbfield']++; // End of subscription date
|
||||
|
||||
// Show total line
|
||||
include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
|
||||
@ -754,6 +787,7 @@ if ($num == 0) {
|
||||
$colspan++;
|
||||
}
|
||||
}
|
||||
$colspan++; // End of subscription date
|
||||
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user