| ';
@@ -713,6 +727,7 @@ while ($i < $imaxinloop) {
$selected = 1;
}
}
+ //print $object->getKanbanView('', array('thirdparty'=>$object->thirdparty, 'selected' => $selected));
print $object->getKanbanView('', array('selected' => $selected));
if ($i == ($imaxinloop - 1)) {
print '';
diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php
index e86b0750ff0..8bb88021090 100644
--- a/htdocs/partnership/class/partnership.class.php
+++ b/htdocs/partnership/class/partnership.class.php
@@ -120,12 +120,12 @@ class Partnership extends CommonObject
'model_pdf' => array('type'=>'varchar(255)', 'label'=>'Model pdf', 'enabled'=>'1', 'position'=>1010, 'notnull'=>-1, 'visible'=>0,),
'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,),
- 'url_to_check' => array('type'=>'url', 'label'=>'UrlToCheck', 'enabled'=>'1', 'position'=>70, 'notnull'=>0, 'visible'=>-1, 'csslist'=>'tdoverflowmax150'),
- 'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'1', 'position'=>71, 'notnull'=>0, 'visible'=>-2, 'default'=>'0',),
- 'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'1', 'position'=>72, 'notnull'=>0, 'visible'=>-2,),
+ 'url_to_check' => array('type'=>'url', 'label'=>'UrlToCheck', 'enabled'=>'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")', 'position'=>70, 'notnull'=>0, 'visible'=>-1, 'csslist'=>'tdoverflowmax150'),
+ 'count_last_url_check_error' => array('type'=>'integer', 'label'=>'CountLastUrlCheckError', 'enabled'=>'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")', 'position'=>71, 'notnull'=>0, 'visible'=>-4, 'default'=>'0',),
+ 'last_check_backlink' => array('type'=>'datetime', 'label'=>'LastCheckBacklink', 'enabled'=>'getDolGlobalString("PARTNERSHIP_BACKLINKS_TO_CHECK")', 'position'=>72, 'notnull'=>0, 'visible'=>-4,),
'reason_decline_or_cancel' => array('type'=>'text', 'label'=>'ReasonDeclineOrCancel', 'enabled'=>'1', 'position'=>73, 'notnull'=>0, 'visible'=>-2,),
- 'ip' => array('type'=>'ip', 'label'=>'Ip', 'enabled'=>'1', 'position'=>74, 'notnull'=>0, 'visible'=>-2,),
- 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>2000, 'notnull'=>1, 'visible'=>2, 'default'=>'0', 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Accepted', '2'=>'Refused', '8'=>'Suspended', '9'=>'Terminated'),),
+ 'ip' => array('type'=>'ip', 'label'=>'IPOfApplicant', 'enabled'=>'1', 'position'=>74, 'notnull'=>0, 'visible'=>-2,),
+ 'status' => array('type'=>'smallint', 'label'=>'Status', 'enabled'=>'1', 'position'=>2000, 'notnull'=>1, 'visible'=>2, 'default'=>'0', 'index'=>1, 'arrayofkeyval'=>array('0'=>'Draft', '1'=>'Validated', '2'=>'Approved', '3'=>'Refused', '9'=>'Terminated'),),
);
public $rowid;
public $ref;
@@ -1309,8 +1309,6 @@ class Partnership extends CommonObject
*/
public function doScheduledJob()
{
- global $conf, $langs;
-
//$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log';
$error = 0;
@@ -1319,7 +1317,7 @@ class Partnership extends CommonObject
dol_syslog(__METHOD__, LOG_DEBUG);
- $now = dol_now();
+ //$now = dol_now();
$this->db->begin();
@@ -1352,6 +1350,9 @@ class Partnership extends CommonObject
if (property_exists($this, 'label')) {
$return .= ' '.$this->label.' ';
}
+ if (property_exists($this, 'thirdparty') && is_object($this->thirdparty)) {
+ $return .= '
'.$this->thirdparty->getNomUrl(1).' ';
+ }
if (method_exists($this, 'getLibStatut')) {
$return .= '
'.$this->getLibStatut(3).' ';
}
diff --git a/htdocs/partnership/class/partnershiputils.class.php b/htdocs/partnership/class/partnershiputils.class.php
index c73bc4230d4..96ee748bae3 100644
--- a/htdocs/partnership/class/partnershiputils.class.php
+++ b/htdocs/partnership/class/partnershiputils.class.php
@@ -147,7 +147,7 @@ class PartnershipUtils
$partnershipsprocessed[$object->id] = $object->ref;
// Send an email to inform member
- $labeltemplate = '(SendingEmailOnPartnershipCanceled)';
+ $labeltemplate = '('.getDolGlobalString('PARTNERSHIP_SENDMAIL_IF_AUTO_CANCEL', 'SendingEmailOnPartnershipCanceled').')';
dol_syslog("Now we will send an email to member id=".$object->fk_member." with label ".$labeltemplate);
@@ -175,16 +175,59 @@ class PartnershipUtils
$msg = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs);
$from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>';
+ // We are in the case of autocancellation subscription because of missing backlink
+ $fk_partner = $object->fk_member;
+
$adherent = new Adherent($this->db);
$adherent->fetch($object->fk_member);
- $to = $adherent->email;
+ $sendto = $adherent->email;
+
+ $trackid = 'par'.$object->id;
+ $sendcontext = 'standard';
+
+ $cmail = new CMailFile($subject, $sendto, $from, $msg, array(), array(), array(), '', '', 0, 1, '', '', $trackid, '', $sendcontext);
- $cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1);
$result = $cmail->sendfile();
- if (!$result || $cmail->error) {
+
+ if (!$result || !empty($cmail->error) || !empty($cmail->errors)) {
$erroremail .= ($erroremail ? ', ' : '').$cmail->error;
$this->errors[] = $cmail->error;
if (is_array($cmail->errors) && count($cmail->errors) > 0) $this->errors += $cmail->errors;
+ } else {
+ // Initialisation of datas of object to call trigger
+ if (is_object($object)) {
+ $actiontypecode = 'AC_OTH_AUTO'; // Event insert into agenda automatically
+ $attachedfiles = array();
+
+ $object->actiontypecode = $actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
+ $object->actionmsg = $arraydefaultmessage->topic."\n".$arraydefaultmessage->content; // Long text
+ $object->actionmsg2 = $langs->transnoentities("PartnershipSentByEMail", $object->ref);; // Short text ($langs->transnoentities('MailSentBy')...);
+ if (!empty($conf->global->MAIN_MAIL_REPLACE_EVENT_TITLE_BY_EMAIL_SUBJECT)) {
+ $object->actionmsg2 = $subject; // Short text
+ }
+
+ $object->trackid = $trackid;
+ $object->fk_element = $object->id;
+ $object->elementtype = $object->element;
+ if (is_array($attachedfiles) && count($attachedfiles) > 0) {
+ $object->attachedfiles = $attachedfiles;
+ }
+
+ $object->email_from = $from;
+ $object->email_subject = $subject;
+ $object->email_to = $sendto;
+ $object->email_subject = $subject;
+
+ $triggersendname = 'PARTNERSHIP_SENTBYMAIL';
+ // Call of triggers (you should have set $triggersendname to execute trigger)
+ if (!empty($triggersendname)) {
+ $result = $object->call_trigger($triggersendname, $user);
+ if ($result < 0) {
+ $error++;
+ }
+ }
+ // End call of triggers
+ }
}
}
}
@@ -215,16 +258,19 @@ class PartnershipUtils
*
* CAN BE A CRON TASK
*
- * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK)
+ * @param int $maxpercall Max per call
+ * @return int 0 if OK, <>0 if KO (this function is used also by cron so only 0 is OK)
*/
- public function doWarningOfPartnershipIfDolibarrBacklinkNotfound()
+ public function doWarningOfPartnershipIfDolibarrBacklinkNotfound($maxpercall = 0)
{
global $conf, $langs, $user;
$managedfor = getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR');
$partnership = new Partnership($this->db);
- $MAXPERCALL = (empty($conf->global->PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL) ? 10 : $conf->global->PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL); // Limit to 10 per call
+ if (empty($maxpercall)) {
+ $maxpercall = getDolGlobalInt('PARTNERSHIP_MAX_WARNING_BACKLINK_PER_CALL', 10);
+ }
$langs->loadLangs(array("partnership", "member"));
@@ -236,23 +282,23 @@ class PartnershipUtils
$emailnotfound = '';
$websitenotfound = '';
- $gracedelay = $conf->global->PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL;
+ /*$gracedelay = getDolGlobalInt('PARTNERSHIP_NBDAYS_AFTER_MEMBER_EXPIRATION_BEFORE_CANCEL');
if ($gracedelay < 1) {
$this->error = 'BadValueForDelayBeforeCancelCheckSetup';
return -1;
- }
+ }*/
$fk_partner = ($managedfor == 'member') ? 'fk_member' : 'fk_soc';
dol_syslog(get_class($this)."::doWarningOfPartnershipIfDolibarrBacklinkNotfound Warning of partnership");
$now = dol_now();
- $datetotest = dol_time_plus_duree($now, -1 * abs($gracedelay), 'd');
+ //$datetotest = dol_time_plus_duree($now, -1 * abs($gracedelay), 'd');
$this->db->begin();
$sql = "SELECT p.rowid, p.status, p.".$fk_partner;
- $sql .= ", p.last_check_backlink";
+ $sql .= ", p.url_to_check, p.last_check_backlink";
$sql .= ', partner.url, partner.email';
$sql .= " FROM ".MAIN_DB_PREFIX."partnership as p";
if ($managedfor == 'member') {
@@ -276,10 +322,12 @@ class PartnershipUtils
$obj = $this->db->fetch_object($resql);
if ($obj) {
- if (!empty($partnershipsprocessed[$obj->rowid])) continue;
+ if (!empty($partnershipsprocessed[$obj->rowid])) {
+ continue;
+ }
- if ($somethingdoneonpartnership >= $MAXPERCALL) {
- dol_syslog("We reach the limit of ".$MAXPERCALL." partnership processed, so we quit loop for this batch doWarningOfPartnershipIfDolibarrBacklinkNotfound to avoid to reach email quota.", LOG_WARNING);
+ if ($somethingdoneonpartnership >= $maxpercall) {
+ dol_syslog("We reach the limit of ".$maxpercall." partnership processed, so we quit loop for this batch doWarningOfPartnershipIfDolibarrBacklinkNotfound to avoid to reach email quota.", LOG_WARNING);
break;
}
@@ -294,7 +342,7 @@ class PartnershipUtils
$fk_partner = $object->fk_soc;
}
- $website = $obj->url;
+ $website = (empty($obj->url_to_check) ? $obj->url : $obj->url_to_check);
if (empty($website)) {
$websitenotfound .= ($websitenotfound ? ', ' : '').'Website not found for id="'.$fk_partner.'"'."\n";
@@ -305,51 +353,101 @@ class PartnershipUtils
if (!$backlinkfound) {
$tmpcount = $object->count_last_url_check_error + 1;
- if ($tmpcount > 2 && $tmpcount <= 4) { // Send Warning Email
- if (!empty($obj->email)) {
- $emailnotfound .= ($emailnotfound ? ', ' : '').'Email not found for id="'.$fk_partner.'"'."\n";
- } else {
- $labeltemplate = '(SendingEmailOnPartnershipWillSoonBeCanceled)';
+ $nbminbacklinkerrorforcancel = getDolGlobalString('PARTNERSHIP_MIN_BACKLINK_ERROR_FOR_CANCEL', 3);
+ $nbmaxbacklinkerrorforcancel = getDolGlobalString('PARTNERSHIP_MAX_BACKLINK_ERROR_FOR_CANCEL', $nbminbacklinkerrorforcancel + 2);
- dol_syslog("Now we will send an email to partner id=".$fk_partner." with label ".$labeltemplate);
+ // If $nbminbacklinkerrorforemail = 0, no autoemail
+ if ($nbminbacklinkerrorforcancel > 0) {
+ if ($tmpcount > $nbminbacklinkerrorforcancel && $tmpcount <= $nbmaxbacklinkerrorforcancel) { // Send Warning Email
+ if (!empty($obj->email)) {
+ $emailnotfound .= ($emailnotfound ? ', ' : '').'Email not found for id="'.$fk_partner.'"'."\n";
+ } else {
+ // Example: 'SendingEmailOnPartnershipWillSoonBeCanceled'
+ $labeltemplate = '('.getDolGlobalString('PARTNERSHIP_SENDMAIL_IF_NO_LINK', 'SendingEmailOnPartnershipWillSoonBeCanceled').')';
- // Send deployment email
- include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
- include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
- $formmail = new FormMail($this->db);
+ dol_syslog("Now we will send an email to partner id=".$fk_partner." with label ".$labeltemplate);
- // Define output language
- $outputlangs = $langs;
- $newlang = '';
- if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
- if (!empty($newlang)) {
- $outputlangs = new Translate("", $conf);
- $outputlangs->setDefaultLang($newlang);
- $outputlangs->loadLangs(array('main', 'member', 'partnership'));
- }
-
- $arraydefaultmessage = $formmail->getEMailTemplate($this->db, 'partnership_send', $user, $outputlangs, 0, 1, $labeltemplate);
-
- $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
- complete_substitutions_array($substitutionarray, $outputlangs, $object);
-
- $subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs);
- $msg = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs);
- $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>';
-
- $to = $obj->email;
-
- $cmail = new CMailFile($subject, $to, $from, $msg, array(), array(), array(), '', '', 0, 1);
- $result = $cmail->sendfile();
- if (!$result || $cmail->error) {
- $erroremail .= ($erroremail ? ', ' : '').$cmail->error;
- $this->errors[] = $cmail->error;
- if (is_array($cmail->errors) && count($cmail->errors) > 0) $this->errors += $cmail->errors;
+ // Send deployment email
+ include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
+ include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
+ $formmail = new FormMail($this->db);
+
+ // Define output language
+ $outputlangs = $langs;
+ $newlang = '';
+ if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
+ if (!empty($newlang)) {
+ $outputlangs = new Translate("", $conf);
+ $outputlangs->setDefaultLang($newlang);
+ $outputlangs->loadLangs(array('main', 'member', 'partnership'));
+ }
+
+ $arraydefaultmessage = $formmail->getEMailTemplate($this->db, 'partnership_send', $user, $outputlangs, 0, 1, $labeltemplate);
+
+ $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object);
+ complete_substitutions_array($substitutionarray, $outputlangs, $object);
+
+ $subject = make_substitutions($arraydefaultmessage->topic, $substitutionarray, $outputlangs);
+ $msg = make_substitutions($arraydefaultmessage->content, $substitutionarray, $outputlangs);
+ $from = dol_string_nospecial($conf->global->MAIN_INFO_SOCIETE_NOM, ' ', array(",")).' <'.$conf->global->MAIN_INFO_SOCIETE_MAIL.'>';
+
+ $sendto = $obj->email;
+
+ $trackid = 'par'.$object->id;
+ $sendcontext = 'standard';
+
+ $cmail = new CMailFile($subject, $sendto, $from, $msg, array(), array(), array(), '', '', 0, 1, '', '', $trackid, '', $sendcontext);
+
+ $result = $cmail->sendfile();
+
+ if (!$result || !empty($cmail->error) || !empty($cmail->errors)) {
+ $erroremail .= ($erroremail ? ', ' : '').$cmail->error;
+ $this->errors[] = $cmail->error;
+ if (is_array($cmail->errors) && count($cmail->errors) > 0) $this->errors += $cmail->errors;
+ } else {
+ // Initialisation of datas of object to call trigger
+ if (is_object($object)) {
+ $actiontypecode = 'AC_OTH_AUTO'; // Event insert into agenda automatically
+ $attachedfiles = array();
+
+ if ($managedfor != 'member') {
+ $object->socid = $fk_partner; // To link to a company
+ }
+ $object->actiontypecode = $actiontypecode; // Type of event ('AC_OTH', 'AC_OTH_AUTO', 'AC_XXX'...)
+ $object->actionmsg = $arraydefaultmessage->topic."\n".$arraydefaultmessage->content; // Long text
+ $object->actionmsg2 = $langs->transnoentities("PartnershipSentByEMail", $object->ref);; // Short text ($langs->transnoentities('MailSentBy')...);
+ if (!empty($conf->global->MAIN_MAIL_REPLACE_EVENT_TITLE_BY_EMAIL_SUBJECT)) {
+ $object->actionmsg2 = $subject; // Short text
+ }
+
+ $object->trackid = $trackid;
+ $object->fk_element = $object->id;
+ $object->elementtype = $object->element;
+ if (is_array($attachedfiles) && count($attachedfiles) > 0) {
+ $object->attachedfiles = $attachedfiles;
+ }
+
+ $object->email_from = $from;
+ $object->email_subject = $subject;
+ $object->email_to = $sendto;
+ $object->email_subject = $subject;
+
+ $triggersendname = 'PARTNERSHIP_SENTBYMAIL';
+ // Call of triggers (you should have set $triggersendname to execute trigger)
+ if (!empty($triggersendname)) {
+ $result = $object->call_trigger($triggersendname, $user);
+ if ($result < 0) {
+ $error++;
+ }
+ }
+ // End call of triggers
+ }
+ }
}
+ } elseif ($tmpcount > $nbmaxbacklinkerrorforcancel) { // Cancel Partnership
+ $object->status = $object::STATUS_CANCELED;
+ $object->reason_decline_or_cancel = $langs->trans('BacklinkNotFoundOnPartnerWebsite');
}
- } elseif ($tmpcount > 4) { // Cancel Partnership
- $object->status = $object::STATUS_CANCELED;
- $object->reason_decline_or_cancel = $langs->trans('BacklinkNotFoundOnPartnerWebsite');
}
$object->count_last_url_check_error = $tmpcount;
@@ -360,7 +458,7 @@ class PartnershipUtils
$partnershipsprocessed[$object->id] = $object->ref;
- $object->last_check_backlink = $this->db->idate($now);
+ $object->last_check_backlink = $now;
$object->update($user);
}
@@ -394,7 +492,7 @@ class PartnershipUtils
*/
private function checkDolibarrBacklink($website = null)
{
- global $conf, $langs, $user;
+ global $conf;
$found = 0;
$error = 0;
diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php
index 27821a2b799..a6653c17a17 100644
--- a/htdocs/partnership/partnership_list.php
+++ b/htdocs/partnership/partnership_list.php
@@ -29,6 +29,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/member.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent_type.class.php';
require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership.class.php';
@@ -286,6 +287,7 @@ if (empty($reshook)) {
*/
$form = new Form($db);
+$companystatic = new Societe($db);
$now = dol_now();
@@ -863,13 +865,26 @@ while ($i < $imaxinloop) {
// Store properties in $object
$object->setVarsFromFetchObj($obj);
+ $object->thirdparty = null;
+ if ($obj->fk_soc > 0) {
+ if (!empty($conf->cache['thirdparty'][$obj->fk_soc])) {
+ $companyobj = $conf->cache['thirdparty'][$obj->fk_soc];
+ } else {
+ $companyobj = new Societe($db);
+ $companyobj->fetch($obj->fk_soc);
+ $conf->cache['thirdparty'][$obj->fk_soc] = $companyobj;
+ }
+
+ $object->thirdparty = $companyobj;
+ }
+
if ($mode == 'kanban') {
if ($i == 0) {
print ' |