$stmt2=$db->query("select group_id from groupbasket WHERE basket_id = '".$line->basket_id."'");
//echo $line->basket_id."\n";
$stmt2=$db->query("SELECT group_id FROM groupbasket WHERE basket_id = ?",array($line->basket_id));
$u=1;
while($line2=$stmt2->fetchObject()){
//echo "_".$line2->group_id."\n";
$stmt3=$db->query("select usergroup_content.user_id,users.status from usergroup_content,users WHERE group_id = '".$line2->group_id."' and usergroup_content.user_id=users.user_id");
$stmt3=$db->query("SELECT usergroup_content.user_id,users.status FROM usergroup_content, users WHERE group_id = ? and usergroup_content.user_id=users.user_id and users.user_id in (?)",array($line2->group_id,$aRecipients));
$baskets_notif=array();
$logger->write("GROUP: ".$line2->group_id." ... ".$stmt3->rowCount()." user(s) to notify",'INFO');
$rowCount3=$stmt3->rowCount();
$logger->write("GROUP: ".$line2->group_id." ... ".$rowCount3." user(s) to notify",'INFO');
$stmt4=$db->query("select * from res_view_letterbox ".$whereClause);
$logger->write($stmt4->rowCount()." document(s) to process for ".$line3->user_id,'INFO');
$i=1;
while($line4=$stmt4->fetchObject()){
echo"DOCUMENT ".$i."/".$stmt4->rowCount()." for USER ".$z."/".$stmt3->rowCount()." and GROUP ".$u."/".$stmt2->rowCount()."\n";
$stmt6=$db->query("SELECT user_id FROM notif_event_stack WHERE record_id = '".$line4->res_id."' and event_info like '%".$line->basket_id."%' and user_id = '".$line3->user_id."'");
$line6=$stmt6->fetchObject();
if($line6){
# code...
}else{
$info="Notification [".$line->basket_id."] pour ".$line3->user_id;
$stmt5=$db->query("INSERT INTO notif_event_stack(table_name,notification_sid,record_id,user_id,event_info,event_date) VALUES('res_letterbox','500','".$line4->res_id."','".$user_id."','".$info."',CURRENT_DATE)");
preg_match_all('#\[(\w+)]#',$info,$result);
$basket_id=$result[1];
if(!in_array($basket_id[0],$baskets_notif)){
$baskets_notif[]=$basket_id[0];
$stmt4=$db->query("SELECT res_id FROM res_view_letterbox ".$whereClause);
if(!empty($stmt4)){
$userNbDoc=$stmt4->rowCount();
$logger->write($userNbDoc." document(s) to process for ".$line3->user_id,'INFO');
$i=1;
$info="Notification [".$line->basket_id."] pour ".$line3->user_id;
$stmt6=$db->query("SELECT record_id FROM notif_event_stack WHERE event_info = ? and user_id = ?",array($info,$line3->user_id));
$aRecordId=[];
while($line6=$stmt6->fetchObject()){
$aRecordId[$line6->record_id]=$line6->record_id;
}
$queryValues="";
while($line4=$stmt4->fetchObject()){
echo"DOCUMENT ".$i."/".$userNbDoc." for USER ".$z."/".$rowCount3." and GROUP ".$u."/".$stmt2->rowCount()."\n";