Commit 3f9d74b6 by Denis Chenu

[dev] Review criteria for tid findAll

parent 49382824
Showing with 33 additions and 38 deletions
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
* @copyright 2016-2017 Denis Chenu <https://www.sondages.pro> * @copyright 2016-2017 Denis Chenu <https://www.sondages.pro>
* @copyright 2016 AXA Insurance (Gulf) B.S.C. <http://www.axa-gulf.com> for initial version * @copyright 2016 AXA Insurance (Gulf) B.S.C. <http://www.axa-gulf.com> for initial version
* @copyright 2016-2017 Extract Recherche Marketing for cronTypes and BatchSize * @copyright 2016-2017 Extract Recherche Marketing for cronTypes and BatchSize
* @license AGPL v3 * @license AGPL v3
* @version 0.3.2 * @version 0.3.2
* *
...@@ -634,50 +633,46 @@ class sendMailCron extends \ls\pluginmanager\PluginBase ...@@ -634,50 +633,46 @@ class sendMailCron extends \ls\pluginmanager\PluginBase
$this->sendMailCronLog("Survey {$iSurvey}, {$sType} Valid from {$dFrom} And Valid until {$dTomorrow} (or NULL)",3); $this->sendMailCronLog("Survey {$iSurvey}, {$sType} Valid from {$dFrom} And Valid until {$dTomorrow} (or NULL)",3);
$oCriteria = new CDbCriteria; $oCriteria = new CDbCriteria;
$oCriteria->select = "tid"; $oCriteria->select = "tid";
/* Always needed condition */
$oCriteria->addCondition("emailstatus = 'OK'"); $oCriteria->addCondition("emailstatus = 'OK'");
$oCriteria->addCondition("token != ''"); $oCriteria->addCondition("token != ''");
if($sType=='invite'){
$oCriteria->addCondition("(sent = 'N' OR sent = '' OR sent IS NULL)");
}
if($sType=='remind'){
/* Not sent condition */
$oCriteria->addCondition("(sent != 'N' AND sent != '' AND sent IS NOT NULL)");
}
if($sType=='remind'){
/* Day after sent AND remind*/
$oCriteria->addCondition("(
(remindersent < :remindersent)
) OR (
(sent < :sent) AND (remindercount = '' OR remindercount IS NULL OR remindercount < 1)
)");
}
if($sType=='remind'){
/* Day after remind */
$oCriteria->addCondition("remindercount < :remindercount OR remindercount = '' OR remindercount IS NULL");
}
if($sType=='remind'){ /* add order criteria */
$oCriteria->order="remindercount desc,sent asc";
}
$oCriteria->addCondition("(completed = 'N' OR completed = '' OR completed IS NULL)"); $oCriteria->addCondition("(completed = 'N' OR completed = '' OR completed IS NULL)");
$oCriteria->addCondition("usesleft>0"); $oCriteria->addCondition("usesleft>0");
$oCriteria->addCondition("(validfrom < :validfrom OR validfrom IS NULL)"); $oCriteria->addCondition("(validfrom < :validfrom OR validfrom IS NULL)");
$oCriteria->addCondition("(validuntil > :validuntil OR validuntil IS NULL)"); $oCriteria->addCondition("(validuntil > :validuntil OR validuntil IS NULL)");
if($sType=='invite'){ $aParams=array(
$oCriteria->params = array( ':validfrom'=>$dFrom,
':validfrom'=>$dFrom, ':validuntil'=>$dTomorrow,
':validuntil'=>$dTomorrow );
); switch ($sType) {
} case 'invite':
if($sType=='remind'){ /* Not sent condition */
$oCriteria->params = array( $oCriteria->addCondition("(sent = 'N' OR sent = '' OR sent IS NULL)");
':validfrom'=>$dFrom, break;
':validuntil'=>$dTomorrow, case 'remind':
':remindersent'=>strval($dAfterSentRemind), /* sent condition */
':sent'=>strval($dAfterSent), $oCriteria->addCondition("(sent != 'N' AND sent != '' AND sent IS NOT NULL)");
':remindercount'=>$maxReminder /* Delay by settings condition */
); $oCriteria->addCondition("(
remindersent < :remindersent AND (remindercount != '' AND remindercount IS NOT NULL AND remindercount > 0)
) OR (
sent < :sent AND (remindercount = '' OR remindercount IS NULL OR remindercount < 1)
)");
/* Max by settings condition */
$oCriteria->addCondition("remindercount < :remindercount OR remindercount = '' OR remindercount IS NULL");
$aParams=array_merge($aParams,array(
':remindersent'=>strval($dAfterSentRemind),
':sent'=>strval($dAfterSent),
':remindercount'=>$maxReminder,
));
break;
default:
/* Break for invalid */
throw new Exception("Invalid email type {$sType} in sendMailCron.");
return 1;
} }
# Send invite $oCriteria->params=$aParams;
# Send email
// Find all token // Find all token
$oTokens=TokenDynamic::model($iSurvey)->findAll($oCriteria); $oTokens=TokenDynamic::model($iSurvey)->findAll($oCriteria);
$aCountMail['total']=count($oTokens); $aCountMail['total']=count($oTokens);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment