$query="SELECT r2.res_id as convert_res_id from res_view_attachments r LEFT JOIN res_view_attachments r2 ON REGEXP_REPLACE(r.filename, '\.(.)*$', '') = REGEXP_REPLACE(r2.filename, '\.(.)*$', '') LEFT JOIN docservers d ON d.docserver_id = r2.docserver_id WHERE r.status in ('DEL', 'OBS', 'TMP') AND r.attachment_type <> 'converted_pdf' AND r2.attachment_type = 'converted_pdf' AND r.res_id <> 0";
$stmt=$db->query($query,[]);
echo"Suppression de {$stmt->rowCount()} PJ de type 'converted_pdf' des PJ en status 'TMP', 'OBS', 'DEL'...\n";
$query="SELECT r2.res_id as convert_res_id from res_view_attachments r LEFT JOIN res_view_attachments r2 ON REGEXP_REPLACE(r.filename, '\.(.)*$', '') = REGEXP_REPLACE(r2.filename, '\.(.)*$', '') LEFT JOIN docservers d ON d.docserver_id = r2.docserver_id WHERE r.status in ('DEL', 'OBS', 'TMP') AND r.attachment_type <> 'converted_pdf' AND r2.attachment_type = 'converted_pdf' AND r.res_id_version <> 0";
$query="SELECT r.res_id as real_res_id, r2.res_id as convert_res_id, d.path_template as convert_path_template, r2.path as convert_path, r2.filename as convert_filename, r2.fingerprint as convert_fingerprint from res_view_attachments r LEFT JOIN res_view_attachments r2 ON REGEXP_REPLACE(r.filename, '\.(.)*$', '') = REGEXP_REPLACE(r2.filename, '\.(.)*$', '') LEFT JOIN docservers d ON d.docserver_id = r2.docserver_id WHERE r.status not in ('DEL', 'OBS', 'TMP') AND r2.status not in ('DEL', 'OBS', 'TMP') AND r.attachment_type <> 'converted_pdf' AND r2.attachment_type = 'converted_pdf' AND r.res_id <> 0";
$stmt=$db->query($query,[]);
echo"{$stmt->rowCount()} Pièce(s) jointe(s) de type 'converted_pdf' trouvée :\n\n";
$query="SELECT r.res_id_version as real_res_id, r2.res_id as convert_res_id, d.path_template as convert_path_template, r2.path as convert_path, r2.filename as convert_filename, r2.fingerprint as convert_fingerprint from res_view_attachments r LEFT JOIN res_view_attachments r2 ON REGEXP_REPLACE(r.filename, '\.(.)*$', '') = REGEXP_REPLACE(r2.filename, '\.(.)*$', '') LEFT JOIN docservers d ON d.docserver_id = r2.docserver_id WHERE r.status not in ('DEL', 'OBS', 'TMP') AND r2.status not in ('DEL', 'OBS', 'TMP') AND r.attachment_type <> 'converted_pdf' AND r2.attachment_type = 'converted_pdf' AND r.res_id_version <> 0";
$stmt=$db->query($query,[]);
echo"{$stmt->rowCount()} Pièce(s) jointe(s) versionnée(s) de type 'converted_pdf' trouvée :\n\n";